1 | (function(global, factory) {
|
2 | typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("vue")) : typeof define === "function" && define.amd ? define(["exports", "vue"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.vant = {}, global.Vue));
|
3 | })(this, function(exports2, vue) {
|
4 | "use strict";
|
5 | function noop() {
|
6 | }
|
7 | const extend = Object.assign;
|
8 | const inBrowser$1 = typeof window !== "undefined";
|
9 | const isObject$1 = (val) => val !== null && typeof val === "object";
|
10 | const isDef = (val) => val !== void 0 && val !== null;
|
11 | const isFunction = (val) => typeof val === "function";
|
12 | const isPromise = (val) => isObject$1(val) && isFunction(val.then) && isFunction(val.catch);
|
13 | const isDate = (val) => Object.prototype.toString.call(val) === "[object Date]" && !Number.isNaN(val.getTime());
|
14 | function isMobile(value) {
|
15 | value = value.replace(/[^-|\d]/g, "");
|
16 | return /^((\+86)|(86))?(1)\d{10}$/.test(value) || /^0[0-9-]{10,13}$/.test(value);
|
17 | }
|
18 | const isNumeric = (val) => typeof val === "number" || /^\d+(\.\d+)?$/.test(val);
|
19 | const isIOS$1 = () => inBrowser$1 ? /ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase()) : false;
|
20 | function get(object, path) {
|
21 | const keys = path.split(".");
|
22 | let result = object;
|
23 | keys.forEach((key) => {
|
24 | var _a;
|
25 | result = isObject$1(result) ? (_a = result[key]) != null ? _a : "" : "";
|
26 | });
|
27 | return result;
|
28 | }
|
29 | function pick(obj, keys, ignoreUndefined) {
|
30 | return keys.reduce(
|
31 | (ret, key) => {
|
32 | if (!ignoreUndefined || obj[key] !== void 0) {
|
33 | ret[key] = obj[key];
|
34 | }
|
35 | return ret;
|
36 | },
|
37 | {}
|
38 | );
|
39 | }
|
40 | const isSameValue = (newValue, oldValue) => JSON.stringify(newValue) === JSON.stringify(oldValue);
|
41 | const toArray = (item) => Array.isArray(item) ? item : [item];
|
42 | const flat = (arr) => arr.reduce((acc, val) => acc.concat(val), []);
|
43 | const unknownProp = null;
|
44 | const numericProp = [Number, String];
|
45 | const truthProp = {
|
46 | type: Boolean,
|
47 | default: true
|
48 | };
|
49 | const makeRequiredProp = (type) => ({
|
50 | type,
|
51 | required: true
|
52 | });
|
53 | const makeArrayProp = () => ({
|
54 | type: Array,
|
55 | default: () => []
|
56 | });
|
57 | const makeNumberProp = (defaultVal) => ({
|
58 | type: Number,
|
59 | default: defaultVal
|
60 | });
|
61 | const makeNumericProp = (defaultVal) => ({
|
62 | type: numericProp,
|
63 | default: defaultVal
|
64 | });
|
65 | const makeStringProp = (defaultVal) => ({
|
66 | type: String,
|
67 | default: defaultVal
|
68 | });
|
69 | var inBrowser = typeof window !== "undefined";
|
70 | function raf(fn) {
|
71 | return inBrowser ? requestAnimationFrame(fn) : -1;
|
72 | }
|
73 | function cancelRaf(id) {
|
74 | if (inBrowser) {
|
75 | cancelAnimationFrame(id);
|
76 | }
|
77 | }
|
78 | function doubleRaf(fn) {
|
79 | raf(() => raf(fn));
|
80 | }
|
81 | var isWindow = (val) => val === window;
|
82 | var makeDOMRect = (width2, height2) => ({
|
83 | top: 0,
|
84 | left: 0,
|
85 | right: width2,
|
86 | bottom: height2,
|
87 | width: width2,
|
88 | height: height2
|
89 | });
|
90 | var useRect = (elementOrRef) => {
|
91 | const element = vue.unref(elementOrRef);
|
92 | if (isWindow(element)) {
|
93 | const width2 = element.innerWidth;
|
94 | const height2 = element.innerHeight;
|
95 | return makeDOMRect(width2, height2);
|
96 | }
|
97 | if (element == null ? void 0 : element.getBoundingClientRect) {
|
98 | return element.getBoundingClientRect();
|
99 | }
|
100 | return makeDOMRect(0, 0);
|
101 | };
|
102 | function useToggle(defaultValue = false) {
|
103 | const state = vue.ref(defaultValue);
|
104 | const toggle = (value = !state.value) => {
|
105 | state.value = value;
|
106 | };
|
107 | return [state, toggle];
|
108 | }
|
109 | function useParent(key) {
|
110 | const parent = vue.inject(key, null);
|
111 | if (parent) {
|
112 | const instance2 = vue.getCurrentInstance();
|
113 | const { link, unlink, internalChildren } = parent;
|
114 | link(instance2);
|
115 | vue.onUnmounted(() => unlink(instance2));
|
116 | const index = vue.computed(() => internalChildren.indexOf(instance2));
|
117 | return {
|
118 | parent,
|
119 | index
|
120 | };
|
121 | }
|
122 | return {
|
123 | parent: null,
|
124 | index: vue.ref(-1)
|
125 | };
|
126 | }
|
127 | function flattenVNodes(children) {
|
128 | const result = [];
|
129 | const traverse = (children2) => {
|
130 | if (Array.isArray(children2)) {
|
131 | children2.forEach((child) => {
|
132 | var _a;
|
133 | if (vue.isVNode(child)) {
|
134 | result.push(child);
|
135 | if ((_a = child.component) == null ? void 0 : _a.subTree) {
|
136 | result.push(child.component.subTree);
|
137 | traverse(child.component.subTree.children);
|
138 | }
|
139 | if (child.children) {
|
140 | traverse(child.children);
|
141 | }
|
142 | }
|
143 | });
|
144 | }
|
145 | };
|
146 | traverse(children);
|
147 | return result;
|
148 | }
|
149 | var findVNodeIndex = (vnodes, vnode) => {
|
150 | const index = vnodes.indexOf(vnode);
|
151 | if (index === -1) {
|
152 | return vnodes.findIndex(
|
153 | (item) => vnode.key !== void 0 && vnode.key !== null && item.type === vnode.type && item.key === vnode.key
|
154 | );
|
155 | }
|
156 | return index;
|
157 | };
|
158 | function sortChildren(parent, publicChildren, internalChildren) {
|
159 | const vnodes = flattenVNodes(parent.subTree.children);
|
160 | internalChildren.sort(
|
161 | (a, b) => findVNodeIndex(vnodes, a.vnode) - findVNodeIndex(vnodes, b.vnode)
|
162 | );
|
163 | const orderedPublicChildren = internalChildren.map((item) => item.proxy);
|
164 | publicChildren.sort((a, b) => {
|
165 | const indexA = orderedPublicChildren.indexOf(a);
|
166 | const indexB = orderedPublicChildren.indexOf(b);
|
167 | return indexA - indexB;
|
168 | });
|
169 | }
|
170 | function useChildren(key) {
|
171 | const publicChildren = vue.reactive([]);
|
172 | const internalChildren = vue.reactive([]);
|
173 | const parent = vue.getCurrentInstance();
|
174 | const linkChildren = (value) => {
|
175 | const link = (child) => {
|
176 | if (child.proxy) {
|
177 | internalChildren.push(child);
|
178 | publicChildren.push(child.proxy);
|
179 | sortChildren(parent, publicChildren, internalChildren);
|
180 | }
|
181 | };
|
182 | const unlink = (child) => {
|
183 | const index = internalChildren.indexOf(child);
|
184 | publicChildren.splice(index, 1);
|
185 | internalChildren.splice(index, 1);
|
186 | };
|
187 | vue.provide(
|
188 | key,
|
189 | Object.assign(
|
190 | {
|
191 | link,
|
192 | unlink,
|
193 | children: publicChildren,
|
194 | internalChildren
|
195 | },
|
196 | value
|
197 | )
|
198 | );
|
199 | };
|
200 | return {
|
201 | children: publicChildren,
|
202 | linkChildren
|
203 | };
|
204 | }
|
205 | var SECOND = 1e3;
|
206 | var MINUTE = 60 * SECOND;
|
207 | var HOUR = 60 * MINUTE;
|
208 | var DAY = 24 * HOUR;
|
209 | function parseTime(time) {
|
210 | const days = Math.floor(time / DAY);
|
211 | const hours = Math.floor(time % DAY / HOUR);
|
212 | const minutes = Math.floor(time % HOUR / MINUTE);
|
213 | const seconds = Math.floor(time % MINUTE / SECOND);
|
214 | const milliseconds = Math.floor(time % SECOND);
|
215 | return {
|
216 | total: time,
|
217 | days,
|
218 | hours,
|
219 | minutes,
|
220 | seconds,
|
221 | milliseconds
|
222 | };
|
223 | }
|
224 | function isSameSecond(time1, time2) {
|
225 | return Math.floor(time1 / 1e3) === Math.floor(time2 / 1e3);
|
226 | }
|
227 | function useCountDown(options) {
|
228 | let rafId;
|
229 | let endTime;
|
230 | let counting;
|
231 | let deactivated;
|
232 | const remain = vue.ref(options.time);
|
233 | const current2 = vue.computed(() => parseTime(remain.value));
|
234 | const pause = () => {
|
235 | counting = false;
|
236 | cancelRaf(rafId);
|
237 | };
|
238 | const getCurrentRemain = () => Math.max(endTime - Date.now(), 0);
|
239 | const setRemain = (value) => {
|
240 | var _a, _b;
|
241 | remain.value = value;
|
242 | (_a = options.onChange) == null ? void 0 : _a.call(options, current2.value);
|
243 | if (value === 0) {
|
244 | pause();
|
245 | (_b = options.onFinish) == null ? void 0 : _b.call(options);
|
246 | }
|
247 | };
|
248 | const microTick = () => {
|
249 | rafId = raf(() => {
|
250 | if (counting) {
|
251 | setRemain(getCurrentRemain());
|
252 | if (remain.value > 0) {
|
253 | microTick();
|
254 | }
|
255 | }
|
256 | });
|
257 | };
|
258 | const macroTick = () => {
|
259 | rafId = raf(() => {
|
260 | if (counting) {
|
261 | const remainRemain = getCurrentRemain();
|
262 | if (!isSameSecond(remainRemain, remain.value) || remainRemain === 0) {
|
263 | setRemain(remainRemain);
|
264 | }
|
265 | if (remain.value > 0) {
|
266 | macroTick();
|
267 | }
|
268 | }
|
269 | });
|
270 | };
|
271 | const tick = () => {
|
272 | if (!inBrowser) {
|
273 | return;
|
274 | }
|
275 | if (options.millisecond) {
|
276 | microTick();
|
277 | } else {
|
278 | macroTick();
|
279 | }
|
280 | };
|
281 | const start2 = () => {
|
282 | if (!counting) {
|
283 | endTime = Date.now() + remain.value;
|
284 | counting = true;
|
285 | tick();
|
286 | }
|
287 | };
|
288 | const reset = (totalTime = options.time) => {
|
289 | pause();
|
290 | remain.value = totalTime;
|
291 | };
|
292 | vue.onBeforeUnmount(pause);
|
293 | vue.onActivated(() => {
|
294 | if (deactivated) {
|
295 | counting = true;
|
296 | deactivated = false;
|
297 | tick();
|
298 | }
|
299 | });
|
300 | vue.onDeactivated(() => {
|
301 | if (counting) {
|
302 | pause();
|
303 | deactivated = true;
|
304 | }
|
305 | });
|
306 | return {
|
307 | start: start2,
|
308 | pause,
|
309 | reset,
|
310 | current: current2
|
311 | };
|
312 | }
|
313 | function onMountedOrActivated(hook) {
|
314 | let mounted;
|
315 | vue.onMounted(() => {
|
316 | hook();
|
317 | vue.nextTick(() => {
|
318 | mounted = true;
|
319 | });
|
320 | });
|
321 | vue.onActivated(() => {
|
322 | if (mounted) {
|
323 | hook();
|
324 | }
|
325 | });
|
326 | }
|
327 | function useEventListener(type, listener, options = {}) {
|
328 | if (!inBrowser) {
|
329 | return;
|
330 | }
|
331 | const { target = window, passive: passive2 = false, capture = false } = options;
|
332 | let cleaned = false;
|
333 | let attached;
|
334 | const add = (target2) => {
|
335 | if (cleaned) {
|
336 | return;
|
337 | }
|
338 | const element = vue.unref(target2);
|
339 | if (element && !attached) {
|
340 | element.addEventListener(type, listener, {
|
341 | capture,
|
342 | passive: passive2
|
343 | });
|
344 | attached = true;
|
345 | }
|
346 | };
|
347 | const remove2 = (target2) => {
|
348 | if (cleaned) {
|
349 | return;
|
350 | }
|
351 | const element = vue.unref(target2);
|
352 | if (element && attached) {
|
353 | element.removeEventListener(type, listener, capture);
|
354 | attached = false;
|
355 | }
|
356 | };
|
357 | vue.onUnmounted(() => remove2(target));
|
358 | vue.onDeactivated(() => remove2(target));
|
359 | onMountedOrActivated(() => add(target));
|
360 | let stopWatch;
|
361 | if (vue.isRef(target)) {
|
362 | stopWatch = vue.watch(target, (val, oldVal) => {
|
363 | remove2(oldVal);
|
364 | add(val);
|
365 | });
|
366 | }
|
367 | return () => {
|
368 | stopWatch == null ? void 0 : stopWatch();
|
369 | remove2(target);
|
370 | cleaned = true;
|
371 | };
|
372 | }
|
373 | function useClickAway(target, listener, options = {}) {
|
374 | if (!inBrowser) {
|
375 | return;
|
376 | }
|
377 | const { eventName = "click" } = options;
|
378 | const onClick = (event) => {
|
379 | const targets = Array.isArray(target) ? target : [target];
|
380 | const isClickAway = targets.every((item) => {
|
381 | const element = vue.unref(item);
|
382 | return element && !element.contains(event.target);
|
383 | });
|
384 | if (isClickAway) {
|
385 | listener(event);
|
386 | }
|
387 | };
|
388 | useEventListener(eventName, onClick, { target: document });
|
389 | }
|
390 | var width;
|
391 | var height;
|
392 | function useWindowSize() {
|
393 | if (!width) {
|
394 | width = vue.ref(0);
|
395 | height = vue.ref(0);
|
396 | if (inBrowser) {
|
397 | const update = () => {
|
398 | width.value = window.innerWidth;
|
399 | height.value = window.innerHeight;
|
400 | };
|
401 | update();
|
402 | window.addEventListener("resize", update, { passive: true });
|
403 | window.addEventListener("orientationchange", update, { passive: true });
|
404 | }
|
405 | }
|
406 | return { width, height };
|
407 | }
|
408 | var overflowScrollReg = /scroll|auto|overlay/i;
|
409 | var defaultRoot = inBrowser ? window : void 0;
|
410 | function isElement$1(node) {
|
411 | const ELEMENT_NODE_TYPE = 1;
|
412 | return node.tagName !== "HTML" && node.tagName !== "BODY" && node.nodeType === ELEMENT_NODE_TYPE;
|
413 | }
|
414 | function getScrollParent$1(el, root = defaultRoot) {
|
415 | let node = el;
|
416 | while (node && node !== root && isElement$1(node)) {
|
417 | const { overflowY } = window.getComputedStyle(node);
|
418 | if (overflowScrollReg.test(overflowY)) {
|
419 | return node;
|
420 | }
|
421 | node = node.parentNode;
|
422 | }
|
423 | return root;
|
424 | }
|
425 | function useScrollParent(el, root = defaultRoot) {
|
426 | const scrollParent = vue.ref();
|
427 | vue.onMounted(() => {
|
428 | if (el.value) {
|
429 | scrollParent.value = getScrollParent$1(el.value, root);
|
430 | }
|
431 | });
|
432 | return scrollParent;
|
433 | }
|
434 | var visibility;
|
435 | function usePageVisibility() {
|
436 | if (!visibility) {
|
437 | visibility = vue.ref("visible");
|
438 | if (inBrowser) {
|
439 | const update = () => {
|
440 | visibility.value = document.hidden ? "hidden" : "visible";
|
441 | };
|
442 | update();
|
443 | window.addEventListener("visibilitychange", update);
|
444 | }
|
445 | }
|
446 | return visibility;
|
447 | }
|
448 | var CUSTOM_FIELD_INJECTION_KEY = Symbol("van-field");
|
449 | function useCustomFieldValue(customValue) {
|
450 | const field = vue.inject(CUSTOM_FIELD_INJECTION_KEY, null);
|
451 | if (field && !field.customValue.value) {
|
452 | field.customValue.value = customValue;
|
453 | vue.watch(customValue, () => {
|
454 | field.resetValidation();
|
455 | field.validateWithTrigger("onChange");
|
456 | });
|
457 | }
|
458 | }
|
459 | function getScrollTop(el) {
|
460 | const top2 = "scrollTop" in el ? el.scrollTop : el.pageYOffset;
|
461 | return Math.max(top2, 0);
|
462 | }
|
463 | function setScrollTop(el, value) {
|
464 | if ("scrollTop" in el) {
|
465 | el.scrollTop = value;
|
466 | } else {
|
467 | el.scrollTo(el.scrollX, value);
|
468 | }
|
469 | }
|
470 | function getRootScrollTop() {
|
471 | return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
|
472 | }
|
473 | function setRootScrollTop(value) {
|
474 | setScrollTop(window, value);
|
475 | setScrollTop(document.body, value);
|
476 | }
|
477 | function getElementTop(el, scroller) {
|
478 | if (el === window) {
|
479 | return 0;
|
480 | }
|
481 | const scrollTop = scroller ? getScrollTop(scroller) : getRootScrollTop();
|
482 | return useRect(el).top + scrollTop;
|
483 | }
|
484 | const isIOS = isIOS$1();
|
485 | function resetScroll() {
|
486 | if (isIOS) {
|
487 | setRootScrollTop(getRootScrollTop());
|
488 | }
|
489 | }
|
490 | const stopPropagation = (event) => event.stopPropagation();
|
491 | function preventDefault(event, isStopPropagation) {
|
492 | if (typeof event.cancelable !== "boolean" || event.cancelable) {
|
493 | event.preventDefault();
|
494 | }
|
495 | if (isStopPropagation) {
|
496 | stopPropagation(event);
|
497 | }
|
498 | }
|
499 | function isHidden(elementRef) {
|
500 | const el = vue.unref(elementRef);
|
501 | if (!el) {
|
502 | return false;
|
503 | }
|
504 | const style = window.getComputedStyle(el);
|
505 | const hidden = style.display === "none";
|
506 | const parentHidden = el.offsetParent === null && style.position !== "fixed";
|
507 | return hidden || parentHidden;
|
508 | }
|
509 | const { width: windowWidth, height: windowHeight } = useWindowSize();
|
510 | function isContainingBlock(el) {
|
511 | const css = window.getComputedStyle(el);
|
512 | return css.transform !== "none" || css.perspective !== "none" || ["transform", "perspective", "filter"].some(
|
513 | (value) => (css.willChange || "").includes(value)
|
514 | );
|
515 | }
|
516 | function getContainingBlock$1(el) {
|
517 | let node = el.parentElement;
|
518 | while (node) {
|
519 | if (node && node.tagName !== "HTML" && node.tagName !== "BODY" && isContainingBlock(node)) {
|
520 | return node;
|
521 | }
|
522 | node = node.parentElement;
|
523 | }
|
524 | return null;
|
525 | }
|
526 | function addUnit(value) {
|
527 | if (isDef(value)) {
|
528 | return isNumeric(value) ? `${value}px` : String(value);
|
529 | }
|
530 | return void 0;
|
531 | }
|
532 | function getSizeStyle(originSize) {
|
533 | if (isDef(originSize)) {
|
534 | if (Array.isArray(originSize)) {
|
535 | return {
|
536 | width: addUnit(originSize[0]),
|
537 | height: addUnit(originSize[1])
|
538 | };
|
539 | }
|
540 | const size = addUnit(originSize);
|
541 | return {
|
542 | width: size,
|
543 | height: size
|
544 | };
|
545 | }
|
546 | }
|
547 | function getZIndexStyle(zIndex) {
|
548 | const style = {};
|
549 | if (zIndex !== void 0) {
|
550 | style.zIndex = +zIndex;
|
551 | }
|
552 | return style;
|
553 | }
|
554 | let rootFontSize;
|
555 | function getRootFontSize() {
|
556 | if (!rootFontSize) {
|
557 | const doc = document.documentElement;
|
558 | const fontSize = doc.style.fontSize || window.getComputedStyle(doc).fontSize;
|
559 | rootFontSize = parseFloat(fontSize);
|
560 | }
|
561 | return rootFontSize;
|
562 | }
|
563 | function convertRem(value) {
|
564 | value = value.replace(/rem/g, "");
|
565 | return +value * getRootFontSize();
|
566 | }
|
567 | function convertVw(value) {
|
568 | value = value.replace(/vw/g, "");
|
569 | return +value * windowWidth.value / 100;
|
570 | }
|
571 | function convertVh(value) {
|
572 | value = value.replace(/vh/g, "");
|
573 | return +value * windowHeight.value / 100;
|
574 | }
|
575 | function unitToPx(value) {
|
576 | if (typeof value === "number") {
|
577 | return value;
|
578 | }
|
579 | if (inBrowser$1) {
|
580 | if (value.includes("rem")) {
|
581 | return convertRem(value);
|
582 | }
|
583 | if (value.includes("vw")) {
|
584 | return convertVw(value);
|
585 | }
|
586 | if (value.includes("vh")) {
|
587 | return convertVh(value);
|
588 | }
|
589 | }
|
590 | return parseFloat(value);
|
591 | }
|
592 | const camelizeRE = /-(\w)/g;
|
593 | const camelize = (str) => str.replace(camelizeRE, (_, c) => c.toUpperCase());
|
594 | const kebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase().replace(/^-/, "");
|
595 | function padZero(num, targetLength = 2) {
|
596 | let str = num + "";
|
597 | while (str.length < targetLength) {
|
598 | str = "0" + str;
|
599 | }
|
600 | return str;
|
601 | }
|
602 | const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
|
603 | function trimExtraChar(value, char, regExp) {
|
604 | const index = value.indexOf(char);
|
605 | if (index === -1) {
|
606 | return value;
|
607 | }
|
608 | if (char === "-" && index !== 0) {
|
609 | return value.slice(0, index);
|
610 | }
|
611 | return value.slice(0, index + 1) + value.slice(index).replace(regExp, "");
|
612 | }
|
613 | function formatNumber(value, allowDot = true, allowMinus = true) {
|
614 | if (allowDot) {
|
615 | value = trimExtraChar(value, ".", /\./g);
|
616 | } else {
|
617 | value = value.split(".")[0];
|
618 | }
|
619 | if (allowMinus) {
|
620 | value = trimExtraChar(value, "-", /-/g);
|
621 | } else {
|
622 | value = value.replace(/-/, "");
|
623 | }
|
624 | const regExp = allowDot ? /[^-0-9.]/g : /[^-0-9]/g;
|
625 | return value.replace(regExp, "");
|
626 | }
|
627 | function addNumber(num1, num2) {
|
628 | const cardinal = 10 ** 10;
|
629 | return Math.round((num1 + num2) * cardinal) / cardinal;
|
630 | }
|
631 | const { hasOwnProperty } = Object.prototype;
|
632 | function assignKey(to, from, key) {
|
633 | const val = from[key];
|
634 | if (!isDef(val)) {
|
635 | return;
|
636 | }
|
637 | if (!hasOwnProperty.call(to, key) || !isObject$1(val)) {
|
638 | to[key] = val;
|
639 | } else {
|
640 | to[key] = deepAssign(Object(to[key]), val);
|
641 | }
|
642 | }
|
643 | function deepAssign(to, from) {
|
644 | Object.keys(from).forEach((key) => {
|
645 | assignKey(to, from, key);
|
646 | });
|
647 | return to;
|
648 | }
|
649 | var stdin_default$1W = {
|
650 | name: "姓名",
|
651 | tel: "电话",
|
652 | save: "保存",
|
653 | clear: "清空",
|
654 | cancel: "取消",
|
655 | confirm: "确认",
|
656 | delete: "删除",
|
657 | loading: "加载中...",
|
658 | noCoupon: "暂无优惠券",
|
659 | nameEmpty: "请填写姓名",
|
660 | addContact: "添加联系人",
|
661 | telInvalid: "请填写正确的电话",
|
662 | vanCalendar: {
|
663 | end: "结束",
|
664 | start: "开始",
|
665 | title: "日期选择",
|
666 | weekdays: ["日", "一", "二", "三", "四", "五", "六"],
|
667 | monthTitle: (year, month) => `${year}年${month}月`,
|
668 | rangePrompt: (maxRange) => `最多选择 ${maxRange} 天`
|
669 | },
|
670 | vanCascader: {
|
671 | select: "请选择"
|
672 | },
|
673 | vanPagination: {
|
674 | prev: "上一页",
|
675 | next: "下一页"
|
676 | },
|
677 | vanPullRefresh: {
|
678 | pulling: "下拉即可刷新...",
|
679 | loosing: "释放即可刷新..."
|
680 | },
|
681 | vanSubmitBar: {
|
682 | label: "合计:"
|
683 | },
|
684 | vanCoupon: {
|
685 | unlimited: "无门槛",
|
686 | discount: (discount) => `${discount}折`,
|
687 | condition: (condition) => `满${condition}元可用`
|
688 | },
|
689 | vanCouponCell: {
|
690 | title: "优惠券",
|
691 | count: (count) => `${count}张可用`
|
692 | },
|
693 | vanCouponList: {
|
694 | exchange: "兑换",
|
695 | close: "不使用",
|
696 | enable: "可用",
|
697 | disabled: "不可用",
|
698 | placeholder: "输入优惠码"
|
699 | },
|
700 | vanAddressEdit: {
|
701 | area: "地区",
|
702 | areaEmpty: "请选择地区",
|
703 | addressEmpty: "请填写详细地址",
|
704 | addressDetail: "详细地址",
|
705 | defaultAddress: "设为默认收货地址"
|
706 | },
|
707 | vanAddressList: {
|
708 | add: "新增地址"
|
709 | }
|
710 | };
|
711 | const lang = vue.ref("zh-CN");
|
712 | const messages = vue.reactive({
|
713 | "zh-CN": stdin_default$1W
|
714 | });
|
715 | const Locale = {
|
716 | messages() {
|
717 | return messages[lang.value];
|
718 | },
|
719 | use(newLang, newMessages) {
|
720 | lang.value = newLang;
|
721 | this.add({ [newLang]: newMessages });
|
722 | },
|
723 | add(newMessages = {}) {
|
724 | deepAssign(messages, newMessages);
|
725 | }
|
726 | };
|
727 | const useCurrentLang = () => lang;
|
728 | var stdin_default$1V = Locale;
|
729 | function createTranslate(name2) {
|
730 | const prefix = camelize(name2) + ".";
|
731 | return (path, ...args) => {
|
732 | const messages2 = stdin_default$1V.messages();
|
733 | const message = get(messages2, prefix + path) || get(messages2, path);
|
734 | return isFunction(message) ? message(...args) : message;
|
735 | };
|
736 | }
|
737 | function genBem(name2, mods) {
|
738 | if (!mods) {
|
739 | return "";
|
740 | }
|
741 | if (typeof mods === "string") {
|
742 | return ` ${name2}--${mods}`;
|
743 | }
|
744 | if (Array.isArray(mods)) {
|
745 | return mods.reduce(
|
746 | (ret, item) => ret + genBem(name2, item),
|
747 | ""
|
748 | );
|
749 | }
|
750 | return Object.keys(mods).reduce(
|
751 | (ret, key) => ret + (mods[key] ? genBem(name2, key) : ""),
|
752 | ""
|
753 | );
|
754 | }
|
755 | function createBEM(name2) {
|
756 | return (el, mods) => {
|
757 | if (el && typeof el !== "string") {
|
758 | mods = el;
|
759 | el = "";
|
760 | }
|
761 | el = el ? `${name2}__${el}` : name2;
|
762 | return `${el}${genBem(el, mods)}`;
|
763 | };
|
764 | }
|
765 | function createNamespace(name2) {
|
766 | const prefixedName = `van-${name2}`;
|
767 | return [
|
768 | prefixedName,
|
769 | createBEM(prefixedName),
|
770 | createTranslate(prefixedName)
|
771 | ];
|
772 | }
|
773 | const BORDER = "van-hairline";
|
774 | const BORDER_TOP = `${BORDER}--top`;
|
775 | const BORDER_LEFT = `${BORDER}--left`;
|
776 | const BORDER_RIGHT = `${BORDER}--right`;
|
777 | const BORDER_BOTTOM = `${BORDER}--bottom`;
|
778 | const BORDER_SURROUND = `${BORDER}--surround`;
|
779 | const BORDER_TOP_BOTTOM = `${BORDER}--top-bottom`;
|
780 | const BORDER_UNSET_TOP_BOTTOM = `${BORDER}-unset--top-bottom`;
|
781 | const HAPTICS_FEEDBACK = "van-haptics-feedback";
|
782 | const FORM_KEY = Symbol("van-form");
|
783 | const LONG_PRESS_START_TIME = 500;
|
784 | const TAP_OFFSET = 5;
|
785 | function callInterceptor(interceptor, {
|
786 | args = [],
|
787 | done,
|
788 | canceled,
|
789 | error
|
790 | }) {
|
791 | if (interceptor) {
|
792 | const returnVal = interceptor.apply(null, args);
|
793 | if (isPromise(returnVal)) {
|
794 | returnVal.then((value) => {
|
795 | if (value) {
|
796 | done();
|
797 | } else if (canceled) {
|
798 | canceled();
|
799 | }
|
800 | }).catch(error || noop);
|
801 | } else if (returnVal) {
|
802 | done();
|
803 | } else if (canceled) {
|
804 | canceled();
|
805 | }
|
806 | } else {
|
807 | done();
|
808 | }
|
809 | }
|
810 | function withInstall(options) {
|
811 | options.install = (app) => {
|
812 | const { name: name2 } = options;
|
813 | if (name2) {
|
814 | app.component(name2, options);
|
815 | app.component(camelize(`-${name2}`), options);
|
816 | }
|
817 | };
|
818 | return options;
|
819 | }
|
820 | function closest(arr, target) {
|
821 | return arr.reduce(
|
822 | (pre, cur) => Math.abs(pre - target) < Math.abs(cur - target) ? pre : cur
|
823 | );
|
824 | }
|
825 | const POPUP_TOGGLE_KEY = Symbol();
|
826 | function onPopupReopen(callback) {
|
827 | const popupToggleStatus = vue.inject(POPUP_TOGGLE_KEY, null);
|
828 | if (popupToggleStatus) {
|
829 | vue.watch(popupToggleStatus, (show) => {
|
830 | if (show) {
|
831 | callback();
|
832 | }
|
833 | });
|
834 | }
|
835 | }
|
836 | const useHeight = (element, withSafeArea) => {
|
837 | const height2 = vue.ref();
|
838 | const setHeight = () => {
|
839 | height2.value = useRect(element).height;
|
840 | };
|
841 | vue.onMounted(() => {
|
842 | vue.nextTick(setHeight);
|
843 | if (withSafeArea) {
|
844 | for (let i = 1; i <= 3; i++) {
|
845 | setTimeout(setHeight, 100 * i);
|
846 | }
|
847 | }
|
848 | });
|
849 | onPopupReopen(() => vue.nextTick(setHeight));
|
850 | vue.watch([windowWidth, windowHeight], setHeight);
|
851 | return height2;
|
852 | };
|
853 | function usePlaceholder(contentRef, bem2) {
|
854 | const height2 = useHeight(contentRef, true);
|
855 | return (renderContent) => vue.createVNode("div", {
|
856 | "class": bem2("placeholder"),
|
857 | "style": {
|
858 | height: height2.value ? `${height2.value}px` : void 0
|
859 | }
|
860 | }, [renderContent()]);
|
861 | }
|
862 | const [name$1K, bem$1F] = createNamespace("action-bar");
|
863 | const ACTION_BAR_KEY = Symbol(name$1K);
|
864 | const actionBarProps = {
|
865 | placeholder: Boolean,
|
866 | safeAreaInsetBottom: truthProp
|
867 | };
|
868 | var stdin_default$1U = vue.defineComponent({
|
869 | name: name$1K,
|
870 | props: actionBarProps,
|
871 | setup(props2, {
|
872 | slots
|
873 | }) {
|
874 | const root = vue.ref();
|
875 | const renderPlaceholder = usePlaceholder(root, bem$1F);
|
876 | const {
|
877 | linkChildren
|
878 | } = useChildren(ACTION_BAR_KEY);
|
879 | linkChildren();
|
880 | const renderActionBar = () => {
|
881 | var _a;
|
882 | return vue.createVNode("div", {
|
883 | "ref": root,
|
884 | "class": [bem$1F(), {
|
885 | "van-safe-area-bottom": props2.safeAreaInsetBottom
|
886 | }]
|
887 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
888 | };
|
889 | return () => {
|
890 | if (props2.placeholder) {
|
891 | return renderPlaceholder(renderActionBar);
|
892 | }
|
893 | return renderActionBar();
|
894 | };
|
895 | }
|
896 | });
|
897 | const ActionBar = withInstall(stdin_default$1U);
|
898 | function useExpose(apis) {
|
899 | const instance2 = vue.getCurrentInstance();
|
900 | if (instance2) {
|
901 | extend(instance2.proxy, apis);
|
902 | }
|
903 | }
|
904 | const routeProps = {
|
905 | to: [String, Object],
|
906 | url: String,
|
907 | replace: Boolean
|
908 | };
|
909 | function route({
|
910 | to,
|
911 | url,
|
912 | replace,
|
913 | $router: router
|
914 | }) {
|
915 | if (to && router) {
|
916 | router[replace ? "replace" : "push"](to);
|
917 | } else if (url) {
|
918 | replace ? location.replace(url) : location.href = url;
|
919 | }
|
920 | }
|
921 | function useRoute() {
|
922 | const vm = vue.getCurrentInstance().proxy;
|
923 | return () => route(vm);
|
924 | }
|
925 | const [name$1J, bem$1E] = createNamespace("badge");
|
926 | const badgeProps = {
|
927 | dot: Boolean,
|
928 | max: numericProp,
|
929 | tag: makeStringProp("div"),
|
930 | color: String,
|
931 | offset: Array,
|
932 | content: numericProp,
|
933 | showZero: truthProp,
|
934 | position: makeStringProp("top-right")
|
935 | };
|
936 | var stdin_default$1T = vue.defineComponent({
|
937 | name: name$1J,
|
938 | props: badgeProps,
|
939 | setup(props2, {
|
940 | slots
|
941 | }) {
|
942 | const hasContent = () => {
|
943 | if (slots.content) {
|
944 | return true;
|
945 | }
|
946 | const {
|
947 | content,
|
948 | showZero
|
949 | } = props2;
|
950 | return isDef(content) && content !== "" && (showZero || content !== 0 && content !== "0");
|
951 | };
|
952 | const renderContent = () => {
|
953 | const {
|
954 | dot,
|
955 | max,
|
956 | content
|
957 | } = props2;
|
958 | if (!dot && hasContent()) {
|
959 | if (slots.content) {
|
960 | return slots.content();
|
961 | }
|
962 | if (isDef(max) && isNumeric(content) && +content > +max) {
|
963 | return `${max}+`;
|
964 | }
|
965 | return content;
|
966 | }
|
967 | };
|
968 | const getOffsetWithMinusString = (val) => val.startsWith("-") ? val.replace("-", "") : `-${val}`;
|
969 | const style = vue.computed(() => {
|
970 | const style2 = {
|
971 | background: props2.color
|
972 | };
|
973 | if (props2.offset) {
|
974 | const [x, y] = props2.offset;
|
975 | const {
|
976 | position
|
977 | } = props2;
|
978 | const [offsetY, offsetX] = position.split("-");
|
979 | if (slots.default) {
|
980 | if (typeof y === "number") {
|
981 | style2[offsetY] = addUnit(offsetY === "top" ? y : -y);
|
982 | } else {
|
983 | style2[offsetY] = offsetY === "top" ? addUnit(y) : getOffsetWithMinusString(y);
|
984 | }
|
985 | if (typeof x === "number") {
|
986 | style2[offsetX] = addUnit(offsetX === "left" ? x : -x);
|
987 | } else {
|
988 | style2[offsetX] = offsetX === "left" ? addUnit(x) : getOffsetWithMinusString(x);
|
989 | }
|
990 | } else {
|
991 | style2.marginTop = addUnit(y);
|
992 | style2.marginLeft = addUnit(x);
|
993 | }
|
994 | }
|
995 | return style2;
|
996 | });
|
997 | const renderBadge = () => {
|
998 | if (hasContent() || props2.dot) {
|
999 | return vue.createVNode("div", {
|
1000 | "class": bem$1E([props2.position, {
|
1001 | dot: props2.dot,
|
1002 | fixed: !!slots.default
|
1003 | }]),
|
1004 | "style": style.value
|
1005 | }, [renderContent()]);
|
1006 | }
|
1007 | };
|
1008 | return () => {
|
1009 | if (slots.default) {
|
1010 | const {
|
1011 | tag
|
1012 | } = props2;
|
1013 | return vue.createVNode(tag, {
|
1014 | "class": bem$1E("wrapper")
|
1015 | }, {
|
1016 | default: () => [slots.default(), renderBadge()]
|
1017 | });
|
1018 | }
|
1019 | return renderBadge();
|
1020 | };
|
1021 | }
|
1022 | });
|
1023 | const Badge = withInstall(stdin_default$1T);
|
1024 | let globalZIndex = 2e3;
|
1025 | const useGlobalZIndex = () => ++globalZIndex;
|
1026 | const setGlobalZIndex = (val) => {
|
1027 | globalZIndex = val;
|
1028 | };
|
1029 | const [name$1I, bem$1D] = createNamespace("config-provider");
|
1030 | const CONFIG_PROVIDER_KEY = Symbol(name$1I);
|
1031 | const configProviderProps = {
|
1032 | tag: makeStringProp("div"),
|
1033 | theme: makeStringProp("light"),
|
1034 | zIndex: Number,
|
1035 | themeVars: Object,
|
1036 | themeVarsDark: Object,
|
1037 | themeVarsLight: Object,
|
1038 | themeVarsScope: makeStringProp("local"),
|
1039 | iconPrefix: String
|
1040 | };
|
1041 | function insertDash(str) {
|
1042 | return str.replace(/([a-zA-Z])(\d)/g, "$1-$2");
|
1043 | }
|
1044 | function mapThemeVarsToCSSVars(themeVars) {
|
1045 | const cssVars = {};
|
1046 | Object.keys(themeVars).forEach((key) => {
|
1047 | const formattedKey = insertDash(kebabCase(key));
|
1048 | cssVars[`--van-${formattedKey}`] = themeVars[key];
|
1049 | });
|
1050 | return cssVars;
|
1051 | }
|
1052 | function syncThemeVarsOnRoot(newStyle = {}, oldStyle = {}) {
|
1053 | Object.keys(newStyle).forEach((key) => {
|
1054 | if (newStyle[key] !== oldStyle[key]) {
|
1055 | document.documentElement.style.setProperty(key, newStyle[key]);
|
1056 | }
|
1057 | });
|
1058 | Object.keys(oldStyle).forEach((key) => {
|
1059 | if (!newStyle[key]) {
|
1060 | document.documentElement.style.removeProperty(key);
|
1061 | }
|
1062 | });
|
1063 | }
|
1064 | var stdin_default$1S = vue.defineComponent({
|
1065 | name: name$1I,
|
1066 | props: configProviderProps,
|
1067 | setup(props2, {
|
1068 | slots
|
1069 | }) {
|
1070 | const style = vue.computed(() => mapThemeVarsToCSSVars(extend({}, props2.themeVars, props2.theme === "dark" ? props2.themeVarsDark : props2.themeVarsLight)));
|
1071 | if (inBrowser$1) {
|
1072 | const addTheme = () => {
|
1073 | document.documentElement.classList.add(`van-theme-${props2.theme}`);
|
1074 | };
|
1075 | const removeTheme = (theme = props2.theme) => {
|
1076 | document.documentElement.classList.remove(`van-theme-${theme}`);
|
1077 | };
|
1078 | vue.watch(() => props2.theme, (newVal, oldVal) => {
|
1079 | if (oldVal) {
|
1080 | removeTheme(oldVal);
|
1081 | }
|
1082 | addTheme();
|
1083 | }, {
|
1084 | immediate: true
|
1085 | });
|
1086 | vue.onActivated(addTheme);
|
1087 | vue.onDeactivated(removeTheme);
|
1088 | vue.onBeforeUnmount(removeTheme);
|
1089 | vue.watch(style, (newStyle, oldStyle) => {
|
1090 | if (props2.themeVarsScope === "global") {
|
1091 | syncThemeVarsOnRoot(newStyle, oldStyle);
|
1092 | }
|
1093 | });
|
1094 | vue.watch(() => props2.themeVarsScope, (newScope, oldScope) => {
|
1095 | if (oldScope === "global") {
|
1096 | syncThemeVarsOnRoot({}, style.value);
|
1097 | }
|
1098 | if (newScope === "global") {
|
1099 | syncThemeVarsOnRoot(style.value, {});
|
1100 | }
|
1101 | });
|
1102 | if (props2.themeVarsScope === "global") {
|
1103 | syncThemeVarsOnRoot(style.value, {});
|
1104 | }
|
1105 | }
|
1106 | vue.provide(CONFIG_PROVIDER_KEY, props2);
|
1107 | vue.watchEffect(() => {
|
1108 | if (props2.zIndex !== void 0) {
|
1109 | setGlobalZIndex(props2.zIndex);
|
1110 | }
|
1111 | });
|
1112 | return () => vue.createVNode(props2.tag, {
|
1113 | "class": bem$1D(),
|
1114 | "style": props2.themeVarsScope === "local" ? style.value : void 0
|
1115 | }, {
|
1116 | default: () => {
|
1117 | var _a;
|
1118 | return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
|
1119 | }
|
1120 | });
|
1121 | }
|
1122 | });
|
1123 | const [name$1H, bem$1C] = createNamespace("icon");
|
1124 | const isImage$1 = (name2) => name2 == null ? void 0 : name2.includes("/");
|
1125 | const iconProps = {
|
1126 | dot: Boolean,
|
1127 | tag: makeStringProp("i"),
|
1128 | name: String,
|
1129 | size: numericProp,
|
1130 | badge: numericProp,
|
1131 | color: String,
|
1132 | badgeProps: Object,
|
1133 | classPrefix: String
|
1134 | };
|
1135 | var stdin_default$1R = vue.defineComponent({
|
1136 | name: name$1H,
|
1137 | props: iconProps,
|
1138 | setup(props2, {
|
1139 | slots
|
1140 | }) {
|
1141 | const config = vue.inject(CONFIG_PROVIDER_KEY, null);
|
1142 | const classPrefix = vue.computed(() => props2.classPrefix || (config == null ? void 0 : config.iconPrefix) || bem$1C());
|
1143 | return () => {
|
1144 | const {
|
1145 | tag,
|
1146 | dot,
|
1147 | name: name2,
|
1148 | size,
|
1149 | badge,
|
1150 | color
|
1151 | } = props2;
|
1152 | const isImageIcon = isImage$1(name2);
|
1153 | return vue.createVNode(Badge, vue.mergeProps({
|
1154 | "dot": dot,
|
1155 | "tag": tag,
|
1156 | "class": [classPrefix.value, isImageIcon ? "" : `${classPrefix.value}-${name2}`],
|
1157 | "style": {
|
1158 | color,
|
1159 | fontSize: addUnit(size)
|
1160 | },
|
1161 | "content": badge
|
1162 | }, props2.badgeProps), {
|
1163 | default: () => {
|
1164 | var _a;
|
1165 | return [(_a = slots.default) == null ? void 0 : _a.call(slots), isImageIcon && vue.createVNode("img", {
|
1166 | "class": bem$1C("image"),
|
1167 | "src": name2
|
1168 | }, null)];
|
1169 | }
|
1170 | });
|
1171 | };
|
1172 | }
|
1173 | });
|
1174 | const Icon = withInstall(stdin_default$1R);
|
1175 | var stdin_default$1Q = Icon;
|
1176 | const [name$1G, bem$1B] = createNamespace("loading");
|
1177 | const SpinIcon = Array(12).fill(null).map((_, index) => vue.createVNode("i", {
|
1178 | "class": bem$1B("line", String(index + 1))
|
1179 | }, null));
|
1180 | const CircularIcon = vue.createVNode("svg", {
|
1181 | "class": bem$1B("circular"),
|
1182 | "viewBox": "25 25 50 50"
|
1183 | }, [vue.createVNode("circle", {
|
1184 | "cx": "50",
|
1185 | "cy": "50",
|
1186 | "r": "20",
|
1187 | "fill": "none"
|
1188 | }, null)]);
|
1189 | const loadingProps = {
|
1190 | size: numericProp,
|
1191 | type: makeStringProp("circular"),
|
1192 | color: String,
|
1193 | vertical: Boolean,
|
1194 | textSize: numericProp,
|
1195 | textColor: String
|
1196 | };
|
1197 | var stdin_default$1P = vue.defineComponent({
|
1198 | name: name$1G,
|
1199 | props: loadingProps,
|
1200 | setup(props2, {
|
1201 | slots
|
1202 | }) {
|
1203 | const spinnerStyle = vue.computed(() => extend({
|
1204 | color: props2.color
|
1205 | }, getSizeStyle(props2.size)));
|
1206 | const renderIcon = () => {
|
1207 | const DefaultIcon = props2.type === "spinner" ? SpinIcon : CircularIcon;
|
1208 | return vue.createVNode("span", {
|
1209 | "class": bem$1B("spinner", props2.type),
|
1210 | "style": spinnerStyle.value
|
1211 | }, [slots.icon ? slots.icon() : DefaultIcon]);
|
1212 | };
|
1213 | const renderText = () => {
|
1214 | var _a;
|
1215 | if (slots.default) {
|
1216 | return vue.createVNode("span", {
|
1217 | "class": bem$1B("text"),
|
1218 | "style": {
|
1219 | fontSize: addUnit(props2.textSize),
|
1220 | color: (_a = props2.textColor) != null ? _a : props2.color
|
1221 | }
|
1222 | }, [slots.default()]);
|
1223 | }
|
1224 | };
|
1225 | return () => {
|
1226 | const {
|
1227 | type,
|
1228 | vertical
|
1229 | } = props2;
|
1230 | return vue.createVNode("div", {
|
1231 | "class": bem$1B([type, {
|
1232 | vertical
|
1233 | }]),
|
1234 | "aria-live": "polite",
|
1235 | "aria-busy": true
|
1236 | }, [renderIcon(), renderText()]);
|
1237 | };
|
1238 | }
|
1239 | });
|
1240 | const Loading = withInstall(stdin_default$1P);
|
1241 | const [name$1F, bem$1A] = createNamespace("button");
|
1242 | const buttonProps = extend({}, routeProps, {
|
1243 | tag: makeStringProp("button"),
|
1244 | text: String,
|
1245 | icon: String,
|
1246 | type: makeStringProp("default"),
|
1247 | size: makeStringProp("normal"),
|
1248 | color: String,
|
1249 | block: Boolean,
|
1250 | plain: Boolean,
|
1251 | round: Boolean,
|
1252 | square: Boolean,
|
1253 | loading: Boolean,
|
1254 | hairline: Boolean,
|
1255 | disabled: Boolean,
|
1256 | iconPrefix: String,
|
1257 | nativeType: makeStringProp("button"),
|
1258 | loadingSize: numericProp,
|
1259 | loadingText: String,
|
1260 | loadingType: String,
|
1261 | iconPosition: makeStringProp("left")
|
1262 | });
|
1263 | var stdin_default$1O = vue.defineComponent({
|
1264 | name: name$1F,
|
1265 | props: buttonProps,
|
1266 | emits: ["click"],
|
1267 | setup(props2, {
|
1268 | emit,
|
1269 | slots
|
1270 | }) {
|
1271 | const route2 = useRoute();
|
1272 | const renderLoadingIcon = () => {
|
1273 | if (slots.loading) {
|
1274 | return slots.loading();
|
1275 | }
|
1276 | return vue.createVNode(Loading, {
|
1277 | "size": props2.loadingSize,
|
1278 | "type": props2.loadingType,
|
1279 | "class": bem$1A("loading")
|
1280 | }, null);
|
1281 | };
|
1282 | const renderIcon = () => {
|
1283 | if (props2.loading) {
|
1284 | return renderLoadingIcon();
|
1285 | }
|
1286 | if (slots.icon) {
|
1287 | return vue.createVNode("div", {
|
1288 | "class": bem$1A("icon")
|
1289 | }, [slots.icon()]);
|
1290 | }
|
1291 | if (props2.icon) {
|
1292 | return vue.createVNode(Icon, {
|
1293 | "name": props2.icon,
|
1294 | "class": bem$1A("icon"),
|
1295 | "classPrefix": props2.iconPrefix
|
1296 | }, null);
|
1297 | }
|
1298 | };
|
1299 | const renderText = () => {
|
1300 | let text;
|
1301 | if (props2.loading) {
|
1302 | text = props2.loadingText;
|
1303 | } else {
|
1304 | text = slots.default ? slots.default() : props2.text;
|
1305 | }
|
1306 | if (text) {
|
1307 | return vue.createVNode("span", {
|
1308 | "class": bem$1A("text")
|
1309 | }, [text]);
|
1310 | }
|
1311 | };
|
1312 | const getStyle = () => {
|
1313 | const {
|
1314 | color,
|
1315 | plain
|
1316 | } = props2;
|
1317 | if (color) {
|
1318 | const style = {
|
1319 | color: plain ? color : "white"
|
1320 | };
|
1321 | if (!plain) {
|
1322 | style.background = color;
|
1323 | }
|
1324 | if (color.includes("gradient")) {
|
1325 | style.border = 0;
|
1326 | } else {
|
1327 | style.borderColor = color;
|
1328 | }
|
1329 | return style;
|
1330 | }
|
1331 | };
|
1332 | const onClick = (event) => {
|
1333 | if (props2.loading) {
|
1334 | preventDefault(event);
|
1335 | } else if (!props2.disabled) {
|
1336 | emit("click", event);
|
1337 | route2();
|
1338 | }
|
1339 | };
|
1340 | return () => {
|
1341 | const {
|
1342 | tag,
|
1343 | type,
|
1344 | size,
|
1345 | block,
|
1346 | round: round2,
|
1347 | plain,
|
1348 | square,
|
1349 | loading,
|
1350 | disabled,
|
1351 | hairline,
|
1352 | nativeType,
|
1353 | iconPosition
|
1354 | } = props2;
|
1355 | const classes = [bem$1A([type, size, {
|
1356 | plain,
|
1357 | block,
|
1358 | round: round2,
|
1359 | square,
|
1360 | loading,
|
1361 | disabled,
|
1362 | hairline
|
1363 | }]), {
|
1364 | [BORDER_SURROUND]: hairline
|
1365 | }];
|
1366 | return vue.createVNode(tag, {
|
1367 | "type": nativeType,
|
1368 | "class": classes,
|
1369 | "style": getStyle(),
|
1370 | "disabled": disabled,
|
1371 | "onClick": onClick
|
1372 | }, {
|
1373 | default: () => [vue.createVNode("div", {
|
1374 | "class": bem$1A("content")
|
1375 | }, [iconPosition === "left" && renderIcon(), renderText(), iconPosition === "right" && renderIcon()])]
|
1376 | });
|
1377 | };
|
1378 | }
|
1379 | });
|
1380 | const Button = withInstall(stdin_default$1O);
|
1381 | const [name$1E, bem$1z] = createNamespace("action-bar-button");
|
1382 | const actionBarButtonProps = extend({}, routeProps, {
|
1383 | type: String,
|
1384 | text: String,
|
1385 | icon: String,
|
1386 | color: String,
|
1387 | loading: Boolean,
|
1388 | disabled: Boolean
|
1389 | });
|
1390 | var stdin_default$1N = vue.defineComponent({
|
1391 | name: name$1E,
|
1392 | props: actionBarButtonProps,
|
1393 | setup(props2, {
|
1394 | slots
|
1395 | }) {
|
1396 | const route2 = useRoute();
|
1397 | const {
|
1398 | parent,
|
1399 | index
|
1400 | } = useParent(ACTION_BAR_KEY);
|
1401 | const isFirst = vue.computed(() => {
|
1402 | if (parent) {
|
1403 | const prev = parent.children[index.value - 1];
|
1404 | return !(prev && "isButton" in prev);
|
1405 | }
|
1406 | });
|
1407 | const isLast = vue.computed(() => {
|
1408 | if (parent) {
|
1409 | const next = parent.children[index.value + 1];
|
1410 | return !(next && "isButton" in next);
|
1411 | }
|
1412 | });
|
1413 | useExpose({
|
1414 | isButton: true
|
1415 | });
|
1416 | return () => {
|
1417 | const {
|
1418 | type,
|
1419 | icon,
|
1420 | text,
|
1421 | color,
|
1422 | loading,
|
1423 | disabled
|
1424 | } = props2;
|
1425 | return vue.createVNode(Button, {
|
1426 | "class": bem$1z([type, {
|
1427 | last: isLast.value,
|
1428 | first: isFirst.value
|
1429 | }]),
|
1430 | "size": "large",
|
1431 | "type": type,
|
1432 | "icon": icon,
|
1433 | "color": color,
|
1434 | "loading": loading,
|
1435 | "disabled": disabled,
|
1436 | "onClick": route2
|
1437 | }, {
|
1438 | default: () => [slots.default ? slots.default() : text]
|
1439 | });
|
1440 | };
|
1441 | }
|
1442 | });
|
1443 | const ActionBarButton = withInstall(stdin_default$1N);
|
1444 | const [name$1D, bem$1y] = createNamespace("action-bar-icon");
|
1445 | const actionBarIconProps = extend({}, routeProps, {
|
1446 | dot: Boolean,
|
1447 | text: String,
|
1448 | icon: String,
|
1449 | color: String,
|
1450 | badge: numericProp,
|
1451 | iconClass: unknownProp,
|
1452 | badgeProps: Object,
|
1453 | iconPrefix: String
|
1454 | });
|
1455 | var stdin_default$1M = vue.defineComponent({
|
1456 | name: name$1D,
|
1457 | props: actionBarIconProps,
|
1458 | setup(props2, {
|
1459 | slots
|
1460 | }) {
|
1461 | const route2 = useRoute();
|
1462 | useParent(ACTION_BAR_KEY);
|
1463 | const renderIcon = () => {
|
1464 | const {
|
1465 | dot,
|
1466 | badge,
|
1467 | icon,
|
1468 | color,
|
1469 | iconClass,
|
1470 | badgeProps: badgeProps2,
|
1471 | iconPrefix
|
1472 | } = props2;
|
1473 | if (slots.icon) {
|
1474 | return vue.createVNode(Badge, vue.mergeProps({
|
1475 | "dot": dot,
|
1476 | "class": bem$1y("icon"),
|
1477 | "content": badge
|
1478 | }, badgeProps2), {
|
1479 | default: slots.icon
|
1480 | });
|
1481 | }
|
1482 | return vue.createVNode(Icon, {
|
1483 | "tag": "div",
|
1484 | "dot": dot,
|
1485 | "name": icon,
|
1486 | "badge": badge,
|
1487 | "color": color,
|
1488 | "class": [bem$1y("icon"), iconClass],
|
1489 | "badgeProps": badgeProps2,
|
1490 | "classPrefix": iconPrefix
|
1491 | }, null);
|
1492 | };
|
1493 | return () => vue.createVNode("div", {
|
1494 | "role": "button",
|
1495 | "class": bem$1y(),
|
1496 | "tabindex": 0,
|
1497 | "onClick": route2
|
1498 | }, [renderIcon(), slots.default ? slots.default() : props2.text]);
|
1499 | }
|
1500 | });
|
1501 | const ActionBarIcon = withInstall(stdin_default$1M);
|
1502 | const popupSharedProps = {
|
1503 |
|
1504 | show: Boolean,
|
1505 |
|
1506 | zIndex: numericProp,
|
1507 |
|
1508 | overlay: truthProp,
|
1509 |
|
1510 | duration: numericProp,
|
1511 |
|
1512 | teleport: [String, Object],
|
1513 |
|
1514 | lockScroll: truthProp,
|
1515 |
|
1516 | lazyRender: truthProp,
|
1517 |
|
1518 | beforeClose: Function,
|
1519 |
|
1520 | overlayStyle: Object,
|
1521 |
|
1522 | overlayClass: unknownProp,
|
1523 |
|
1524 | transitionAppear: Boolean,
|
1525 |
|
1526 | closeOnClickOverlay: truthProp
|
1527 | };
|
1528 | const popupSharedPropKeys = Object.keys(
|
1529 | popupSharedProps
|
1530 | );
|
1531 | function getDirection(x, y) {
|
1532 | if (x > y) {
|
1533 | return "horizontal";
|
1534 | }
|
1535 | if (y > x) {
|
1536 | return "vertical";
|
1537 | }
|
1538 | return "";
|
1539 | }
|
1540 | function useTouch() {
|
1541 | const startX = vue.ref(0);
|
1542 | const startY = vue.ref(0);
|
1543 | const deltaX = vue.ref(0);
|
1544 | const deltaY = vue.ref(0);
|
1545 | const offsetX = vue.ref(0);
|
1546 | const offsetY = vue.ref(0);
|
1547 | const direction = vue.ref("");
|
1548 | const isTap = vue.ref(true);
|
1549 | const isVertical = () => direction.value === "vertical";
|
1550 | const isHorizontal = () => direction.value === "horizontal";
|
1551 | const reset = () => {
|
1552 | deltaX.value = 0;
|
1553 | deltaY.value = 0;
|
1554 | offsetX.value = 0;
|
1555 | offsetY.value = 0;
|
1556 | direction.value = "";
|
1557 | isTap.value = true;
|
1558 | };
|
1559 | const start2 = (event) => {
|
1560 | reset();
|
1561 | startX.value = event.touches[0].clientX;
|
1562 | startY.value = event.touches[0].clientY;
|
1563 | };
|
1564 | const move = (event) => {
|
1565 | const touch = event.touches[0];
|
1566 | deltaX.value = (touch.clientX < 0 ? 0 : touch.clientX) - startX.value;
|
1567 | deltaY.value = touch.clientY - startY.value;
|
1568 | offsetX.value = Math.abs(deltaX.value);
|
1569 | offsetY.value = Math.abs(deltaY.value);
|
1570 | const LOCK_DIRECTION_DISTANCE = 10;
|
1571 | if (!direction.value || offsetX.value < LOCK_DIRECTION_DISTANCE && offsetY.value < LOCK_DIRECTION_DISTANCE) {
|
1572 | direction.value = getDirection(offsetX.value, offsetY.value);
|
1573 | }
|
1574 | if (isTap.value && (offsetX.value > TAP_OFFSET || offsetY.value > TAP_OFFSET)) {
|
1575 | isTap.value = false;
|
1576 | }
|
1577 | };
|
1578 | return {
|
1579 | move,
|
1580 | start: start2,
|
1581 | reset,
|
1582 | startX,
|
1583 | startY,
|
1584 | deltaX,
|
1585 | deltaY,
|
1586 | offsetX,
|
1587 | offsetY,
|
1588 | direction,
|
1589 | isVertical,
|
1590 | isHorizontal,
|
1591 | isTap
|
1592 | };
|
1593 | }
|
1594 | let totalLockCount = 0;
|
1595 | const BODY_LOCK_CLASS = "van-overflow-hidden";
|
1596 | function useLockScroll(rootRef, shouldLock) {
|
1597 | const touch = useTouch();
|
1598 | const DIRECTION_UP = "01";
|
1599 | const DIRECTION_DOWN = "10";
|
1600 | const onTouchMove = (event) => {
|
1601 | touch.move(event);
|
1602 | const direction = touch.deltaY.value > 0 ? DIRECTION_DOWN : DIRECTION_UP;
|
1603 | const el = getScrollParent$1(
|
1604 | event.target,
|
1605 | rootRef.value
|
1606 | );
|
1607 | const { scrollHeight, offsetHeight, scrollTop } = el;
|
1608 | let status = "11";
|
1609 | if (scrollTop === 0) {
|
1610 | status = offsetHeight >= scrollHeight ? "00" : "01";
|
1611 | } else if (scrollTop + offsetHeight >= scrollHeight) {
|
1612 | status = "10";
|
1613 | }
|
1614 | if (status !== "11" && touch.isVertical() && !(parseInt(status, 2) & parseInt(direction, 2))) {
|
1615 | preventDefault(event, true);
|
1616 | }
|
1617 | };
|
1618 | const lock = () => {
|
1619 | document.addEventListener("touchstart", touch.start);
|
1620 | document.addEventListener("touchmove", onTouchMove, { passive: false });
|
1621 | if (!totalLockCount) {
|
1622 | document.body.classList.add(BODY_LOCK_CLASS);
|
1623 | }
|
1624 | totalLockCount++;
|
1625 | };
|
1626 | const unlock = () => {
|
1627 | if (totalLockCount) {
|
1628 | document.removeEventListener("touchstart", touch.start);
|
1629 | document.removeEventListener("touchmove", onTouchMove);
|
1630 | totalLockCount--;
|
1631 | if (!totalLockCount) {
|
1632 | document.body.classList.remove(BODY_LOCK_CLASS);
|
1633 | }
|
1634 | }
|
1635 | };
|
1636 | const init = () => shouldLock() && lock();
|
1637 | const destroy = () => shouldLock() && unlock();
|
1638 | onMountedOrActivated(init);
|
1639 | vue.onDeactivated(destroy);
|
1640 | vue.onBeforeUnmount(destroy);
|
1641 | vue.watch(shouldLock, (value) => {
|
1642 | value ? lock() : unlock();
|
1643 | });
|
1644 | }
|
1645 | function useLazyRender(show) {
|
1646 | const inited = vue.ref(false);
|
1647 | vue.watch(
|
1648 | show,
|
1649 | (value) => {
|
1650 | if (value) {
|
1651 | inited.value = value;
|
1652 | }
|
1653 | },
|
1654 | { immediate: true }
|
1655 | );
|
1656 | return (render) => () => inited.value ? render() : null;
|
1657 | }
|
1658 | const useScopeId = () => {
|
1659 | var _a;
|
1660 | const { scopeId } = ((_a = vue.getCurrentInstance()) == null ? void 0 : _a.vnode) || {};
|
1661 | return scopeId ? { [scopeId]: "" } : null;
|
1662 | };
|
1663 | const [name$1C, bem$1x] = createNamespace("overlay");
|
1664 | const overlayProps = {
|
1665 | show: Boolean,
|
1666 | zIndex: numericProp,
|
1667 | duration: numericProp,
|
1668 | className: unknownProp,
|
1669 | lockScroll: truthProp,
|
1670 | lazyRender: truthProp,
|
1671 | customStyle: Object,
|
1672 | teleport: [String, Object]
|
1673 | };
|
1674 | var stdin_default$1L = vue.defineComponent({
|
1675 | name: name$1C,
|
1676 | props: overlayProps,
|
1677 | setup(props2, {
|
1678 | slots
|
1679 | }) {
|
1680 | const root = vue.ref();
|
1681 | const lazyRender = useLazyRender(() => props2.show || !props2.lazyRender);
|
1682 | const onTouchMove = (event) => {
|
1683 | if (props2.lockScroll) {
|
1684 | preventDefault(event, true);
|
1685 | }
|
1686 | };
|
1687 | const renderOverlay = lazyRender(() => {
|
1688 | var _a;
|
1689 | const style = extend(getZIndexStyle(props2.zIndex), props2.customStyle);
|
1690 | if (isDef(props2.duration)) {
|
1691 | style.animationDuration = `${props2.duration}s`;
|
1692 | }
|
1693 | return vue.withDirectives(vue.createVNode("div", {
|
1694 | "ref": root,
|
1695 | "style": style,
|
1696 | "class": [bem$1x(), props2.className]
|
1697 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), [[vue.vShow, props2.show]]);
|
1698 | });
|
1699 | useEventListener("touchmove", onTouchMove, {
|
1700 | target: root
|
1701 | });
|
1702 | return () => {
|
1703 | const Content = vue.createVNode(vue.Transition, {
|
1704 | "name": "van-fade",
|
1705 | "appear": true
|
1706 | }, {
|
1707 | default: renderOverlay
|
1708 | });
|
1709 | if (props2.teleport) {
|
1710 | return vue.createVNode(vue.Teleport, {
|
1711 | "to": props2.teleport
|
1712 | }, {
|
1713 | default: () => [Content]
|
1714 | });
|
1715 | }
|
1716 | return Content;
|
1717 | };
|
1718 | }
|
1719 | });
|
1720 | const Overlay = withInstall(stdin_default$1L);
|
1721 | const popupProps$2 = extend({}, popupSharedProps, {
|
1722 | round: Boolean,
|
1723 | position: makeStringProp("center"),
|
1724 | closeIcon: makeStringProp("cross"),
|
1725 | closeable: Boolean,
|
1726 | transition: String,
|
1727 | iconPrefix: String,
|
1728 | closeOnPopstate: Boolean,
|
1729 | closeIconPosition: makeStringProp("top-right"),
|
1730 | safeAreaInsetTop: Boolean,
|
1731 | safeAreaInsetBottom: Boolean
|
1732 | });
|
1733 | const [name$1B, bem$1w] = createNamespace("popup");
|
1734 | var stdin_default$1K = vue.defineComponent({
|
1735 | name: name$1B,
|
1736 | inheritAttrs: false,
|
1737 | props: popupProps$2,
|
1738 | emits: ["open", "close", "opened", "closed", "keydown", "update:show", "clickOverlay", "clickCloseIcon"],
|
1739 | setup(props2, {
|
1740 | emit,
|
1741 | attrs,
|
1742 | slots
|
1743 | }) {
|
1744 | let opened;
|
1745 | let shouldReopen;
|
1746 | const zIndex = vue.ref();
|
1747 | const popupRef = vue.ref();
|
1748 | const lazyRender = useLazyRender(() => props2.show || !props2.lazyRender);
|
1749 | const style = vue.computed(() => {
|
1750 | const style2 = {
|
1751 | zIndex: zIndex.value
|
1752 | };
|
1753 | if (isDef(props2.duration)) {
|
1754 | const key = props2.position === "center" ? "animationDuration" : "transitionDuration";
|
1755 | style2[key] = `${props2.duration}s`;
|
1756 | }
|
1757 | return style2;
|
1758 | });
|
1759 | const open = () => {
|
1760 | if (!opened) {
|
1761 | opened = true;
|
1762 | zIndex.value = props2.zIndex !== void 0 ? +props2.zIndex : useGlobalZIndex();
|
1763 | emit("open");
|
1764 | }
|
1765 | };
|
1766 | const close = () => {
|
1767 | if (opened) {
|
1768 | callInterceptor(props2.beforeClose, {
|
1769 | done() {
|
1770 | opened = false;
|
1771 | emit("close");
|
1772 | emit("update:show", false);
|
1773 | }
|
1774 | });
|
1775 | }
|
1776 | };
|
1777 | const onClickOverlay = (event) => {
|
1778 | emit("clickOverlay", event);
|
1779 | if (props2.closeOnClickOverlay) {
|
1780 | close();
|
1781 | }
|
1782 | };
|
1783 | const renderOverlay = () => {
|
1784 | if (props2.overlay) {
|
1785 | return vue.createVNode(Overlay, vue.mergeProps({
|
1786 | "show": props2.show,
|
1787 | "class": props2.overlayClass,
|
1788 | "zIndex": zIndex.value,
|
1789 | "duration": props2.duration,
|
1790 | "customStyle": props2.overlayStyle,
|
1791 | "role": props2.closeOnClickOverlay ? "button" : void 0,
|
1792 | "tabindex": props2.closeOnClickOverlay ? 0 : void 0
|
1793 | }, useScopeId(), {
|
1794 | "onClick": onClickOverlay
|
1795 | }), {
|
1796 | default: slots["overlay-content"]
|
1797 | });
|
1798 | }
|
1799 | };
|
1800 | const onClickCloseIcon = (event) => {
|
1801 | emit("clickCloseIcon", event);
|
1802 | close();
|
1803 | };
|
1804 | const renderCloseIcon = () => {
|
1805 | if (props2.closeable) {
|
1806 | return vue.createVNode(Icon, {
|
1807 | "role": "button",
|
1808 | "tabindex": 0,
|
1809 | "name": props2.closeIcon,
|
1810 | "class": [bem$1w("close-icon", props2.closeIconPosition), HAPTICS_FEEDBACK],
|
1811 | "classPrefix": props2.iconPrefix,
|
1812 | "onClick": onClickCloseIcon
|
1813 | }, null);
|
1814 | }
|
1815 | };
|
1816 | let timer2;
|
1817 | const onOpened = () => {
|
1818 | if (timer2) clearTimeout(timer2);
|
1819 | timer2 = setTimeout(() => {
|
1820 | emit("opened");
|
1821 | });
|
1822 | };
|
1823 | const onClosed = () => emit("closed");
|
1824 | const onKeydown = (event) => emit("keydown", event);
|
1825 | const renderPopup = lazyRender(() => {
|
1826 | var _a;
|
1827 | const {
|
1828 | round: round2,
|
1829 | position,
|
1830 | safeAreaInsetTop,
|
1831 | safeAreaInsetBottom
|
1832 | } = props2;
|
1833 | return vue.withDirectives(vue.createVNode("div", vue.mergeProps({
|
1834 | "ref": popupRef,
|
1835 | "style": style.value,
|
1836 | "role": "dialog",
|
1837 | "tabindex": 0,
|
1838 | "class": [bem$1w({
|
1839 | round: round2,
|
1840 | [position]: position
|
1841 | }), {
|
1842 | "van-safe-area-top": safeAreaInsetTop,
|
1843 | "van-safe-area-bottom": safeAreaInsetBottom
|
1844 | }],
|
1845 | "onKeydown": onKeydown
|
1846 | }, attrs, useScopeId()), [(_a = slots.default) == null ? void 0 : _a.call(slots), renderCloseIcon()]), [[vue.vShow, props2.show]]);
|
1847 | });
|
1848 | const renderTransition = () => {
|
1849 | const {
|
1850 | position,
|
1851 | transition,
|
1852 | transitionAppear
|
1853 | } = props2;
|
1854 | const name2 = position === "center" ? "van-fade" : `van-popup-slide-${position}`;
|
1855 | return vue.createVNode(vue.Transition, {
|
1856 | "name": transition || name2,
|
1857 | "appear": transitionAppear,
|
1858 | "onAfterEnter": onOpened,
|
1859 | "onAfterLeave": onClosed
|
1860 | }, {
|
1861 | default: renderPopup
|
1862 | });
|
1863 | };
|
1864 | vue.watch(() => props2.show, (show) => {
|
1865 | if (show && !opened) {
|
1866 | open();
|
1867 | if (attrs.tabindex === 0) {
|
1868 | vue.nextTick(() => {
|
1869 | var _a;
|
1870 | (_a = popupRef.value) == null ? void 0 : _a.focus();
|
1871 | });
|
1872 | }
|
1873 | }
|
1874 | if (!show && opened) {
|
1875 | opened = false;
|
1876 | emit("close");
|
1877 | }
|
1878 | });
|
1879 | useExpose({
|
1880 | popupRef
|
1881 | });
|
1882 | useLockScroll(popupRef, () => props2.show && props2.lockScroll);
|
1883 | useEventListener("popstate", () => {
|
1884 | if (props2.closeOnPopstate) {
|
1885 | close();
|
1886 | shouldReopen = false;
|
1887 | }
|
1888 | });
|
1889 | vue.onMounted(() => {
|
1890 | if (props2.show) {
|
1891 | open();
|
1892 | }
|
1893 | });
|
1894 | vue.onActivated(() => {
|
1895 | if (shouldReopen) {
|
1896 | emit("update:show", true);
|
1897 | shouldReopen = false;
|
1898 | }
|
1899 | });
|
1900 | vue.onDeactivated(() => {
|
1901 | if (props2.show && props2.teleport) {
|
1902 | close();
|
1903 | shouldReopen = true;
|
1904 | }
|
1905 | });
|
1906 | vue.provide(POPUP_TOGGLE_KEY, () => props2.show);
|
1907 | return () => {
|
1908 | if (props2.teleport) {
|
1909 | return vue.createVNode(vue.Teleport, {
|
1910 | "to": props2.teleport
|
1911 | }, {
|
1912 | default: () => [renderOverlay(), renderTransition()]
|
1913 | });
|
1914 | }
|
1915 | return vue.createVNode(vue.Fragment, null, [renderOverlay(), renderTransition()]);
|
1916 | };
|
1917 | }
|
1918 | });
|
1919 | const Popup = withInstall(stdin_default$1K);
|
1920 | const [name$1A, bem$1v] = createNamespace("action-sheet");
|
1921 | const actionSheetProps = extend({}, popupSharedProps, {
|
1922 | title: String,
|
1923 | round: truthProp,
|
1924 | actions: makeArrayProp(),
|
1925 | closeIcon: makeStringProp("cross"),
|
1926 | closeable: truthProp,
|
1927 | cancelText: String,
|
1928 | description: String,
|
1929 | closeOnPopstate: truthProp,
|
1930 | closeOnClickAction: Boolean,
|
1931 | safeAreaInsetBottom: truthProp
|
1932 | });
|
1933 | const popupInheritKeys$2 = [...popupSharedPropKeys, "round", "closeOnPopstate", "safeAreaInsetBottom"];
|
1934 | var stdin_default$1J = vue.defineComponent({
|
1935 | name: name$1A,
|
1936 | props: actionSheetProps,
|
1937 | emits: ["select", "cancel", "update:show"],
|
1938 | setup(props2, {
|
1939 | slots,
|
1940 | emit
|
1941 | }) {
|
1942 | const updateShow = (show) => emit("update:show", show);
|
1943 | const onCancel = () => {
|
1944 | updateShow(false);
|
1945 | emit("cancel");
|
1946 | };
|
1947 | const renderHeader = () => {
|
1948 | if (props2.title) {
|
1949 | return vue.createVNode("div", {
|
1950 | "class": bem$1v("header")
|
1951 | }, [props2.title, props2.closeable && vue.createVNode(Icon, {
|
1952 | "name": props2.closeIcon,
|
1953 | "class": [bem$1v("close"), HAPTICS_FEEDBACK],
|
1954 | "onClick": onCancel
|
1955 | }, null)]);
|
1956 | }
|
1957 | };
|
1958 | const renderCancel = () => {
|
1959 | if (slots.cancel || props2.cancelText) {
|
1960 | return [vue.createVNode("div", {
|
1961 | "class": bem$1v("gap")
|
1962 | }, null), vue.createVNode("button", {
|
1963 | "type": "button",
|
1964 | "class": bem$1v("cancel"),
|
1965 | "onClick": onCancel
|
1966 | }, [slots.cancel ? slots.cancel() : props2.cancelText])];
|
1967 | }
|
1968 | };
|
1969 | const renderIcon = (action) => {
|
1970 | if (action.icon) {
|
1971 | return vue.createVNode(Icon, {
|
1972 | "class": bem$1v("item-icon"),
|
1973 | "name": action.icon
|
1974 | }, null);
|
1975 | }
|
1976 | };
|
1977 | const renderActionContent = (action, index) => {
|
1978 | if (action.loading) {
|
1979 | return vue.createVNode(Loading, {
|
1980 | "class": bem$1v("loading-icon")
|
1981 | }, null);
|
1982 | }
|
1983 | if (slots.action) {
|
1984 | return slots.action({
|
1985 | action,
|
1986 | index
|
1987 | });
|
1988 | }
|
1989 | return [vue.createVNode("span", {
|
1990 | "class": bem$1v("name")
|
1991 | }, [action.name]), action.subname && vue.createVNode("div", {
|
1992 | "class": bem$1v("subname")
|
1993 | }, [action.subname])];
|
1994 | };
|
1995 | const renderAction = (action, index) => {
|
1996 | const {
|
1997 | color,
|
1998 | loading,
|
1999 | callback,
|
2000 | disabled,
|
2001 | className
|
2002 | } = action;
|
2003 | const onClick = () => {
|
2004 | if (disabled || loading) {
|
2005 | return;
|
2006 | }
|
2007 | if (callback) {
|
2008 | callback(action);
|
2009 | }
|
2010 | if (props2.closeOnClickAction) {
|
2011 | updateShow(false);
|
2012 | }
|
2013 | vue.nextTick(() => emit("select", action, index));
|
2014 | };
|
2015 | return vue.createVNode("button", {
|
2016 | "type": "button",
|
2017 | "style": {
|
2018 | color
|
2019 | },
|
2020 | "class": [bem$1v("item", {
|
2021 | loading,
|
2022 | disabled
|
2023 | }), className],
|
2024 | "onClick": onClick
|
2025 | }, [renderIcon(action), renderActionContent(action, index)]);
|
2026 | };
|
2027 | const renderDescription = () => {
|
2028 | if (props2.description || slots.description) {
|
2029 | const content = slots.description ? slots.description() : props2.description;
|
2030 | return vue.createVNode("div", {
|
2031 | "class": bem$1v("description")
|
2032 | }, [content]);
|
2033 | }
|
2034 | };
|
2035 | return () => vue.createVNode(Popup, vue.mergeProps({
|
2036 | "class": bem$1v(),
|
2037 | "position": "bottom",
|
2038 | "onUpdate:show": updateShow
|
2039 | }, pick(props2, popupInheritKeys$2)), {
|
2040 | default: () => {
|
2041 | var _a;
|
2042 | return [renderHeader(), renderDescription(), vue.createVNode("div", {
|
2043 | "class": bem$1v("content")
|
2044 | }, [props2.actions.map(renderAction), (_a = slots.default) == null ? void 0 : _a.call(slots)]), renderCancel()];
|
2045 | }
|
2046 | });
|
2047 | }
|
2048 | });
|
2049 | const ActionSheet = withInstall(stdin_default$1J);
|
2050 | const [name$1z, bem$1u, t$k] = createNamespace("picker");
|
2051 | const getFirstEnabledOption = (options) => options.find((option) => !option.disabled) || options[0];
|
2052 | function getColumnsType(columns, fields) {
|
2053 | const firstColumn = columns[0];
|
2054 | if (firstColumn) {
|
2055 | if (Array.isArray(firstColumn)) {
|
2056 | return "multiple";
|
2057 | }
|
2058 | if (fields.children in firstColumn) {
|
2059 | return "cascade";
|
2060 | }
|
2061 | }
|
2062 | return "default";
|
2063 | }
|
2064 | function findIndexOfEnabledOption(options, index) {
|
2065 | index = clamp(index, 0, options.length);
|
2066 | for (let i = index; i < options.length; i++) {
|
2067 | if (!options[i].disabled) return i;
|
2068 | }
|
2069 | for (let i = index - 1; i >= 0; i--) {
|
2070 | if (!options[i].disabled) return i;
|
2071 | }
|
2072 | return 0;
|
2073 | }
|
2074 | const isOptionExist = (options, value, fields) => value !== void 0 && !!options.find((option) => option[fields.value] === value);
|
2075 | function findOptionByValue(options, value, fields) {
|
2076 | const index = options.findIndex((option) => option[fields.value] === value);
|
2077 | const enabledIndex = findIndexOfEnabledOption(options, index);
|
2078 | return options[enabledIndex];
|
2079 | }
|
2080 | function formatCascadeColumns(columns, fields, selectedValues) {
|
2081 | const formatted = [];
|
2082 | let cursor = {
|
2083 | [fields.children]: columns
|
2084 | };
|
2085 | let columnIndex = 0;
|
2086 | while (cursor && cursor[fields.children]) {
|
2087 | const options = cursor[fields.children];
|
2088 | const value = selectedValues.value[columnIndex];
|
2089 | cursor = isDef(value) ? findOptionByValue(options, value, fields) : void 0;
|
2090 | if (!cursor && options.length) {
|
2091 | const firstValue = getFirstEnabledOption(options)[fields.value];
|
2092 | cursor = findOptionByValue(options, firstValue, fields);
|
2093 | }
|
2094 | columnIndex++;
|
2095 | formatted.push(options);
|
2096 | }
|
2097 | return formatted;
|
2098 | }
|
2099 | function getElementTranslateY(element) {
|
2100 | const { transform } = window.getComputedStyle(element);
|
2101 | const translateY = transform.slice(7, transform.length - 1).split(", ")[5];
|
2102 | return Number(translateY);
|
2103 | }
|
2104 | function assignDefaultFields(fields) {
|
2105 | return extend(
|
2106 | {
|
2107 | text: "text",
|
2108 | value: "value",
|
2109 | children: "children"
|
2110 | },
|
2111 | fields
|
2112 | );
|
2113 | }
|
2114 | const DEFAULT_DURATION = 200;
|
2115 | const MOMENTUM_TIME = 300;
|
2116 | const MOMENTUM_DISTANCE = 15;
|
2117 | const [name$1y, bem$1t] = createNamespace("picker-column");
|
2118 | const PICKER_KEY = Symbol(name$1y);
|
2119 | var stdin_default$1I = vue.defineComponent({
|
2120 | name: name$1y,
|
2121 | props: {
|
2122 | value: numericProp,
|
2123 | fields: makeRequiredProp(Object),
|
2124 | options: makeArrayProp(),
|
2125 | readonly: Boolean,
|
2126 | allowHtml: Boolean,
|
2127 | optionHeight: makeRequiredProp(Number),
|
2128 | swipeDuration: makeRequiredProp(numericProp),
|
2129 | visibleOptionNum: makeRequiredProp(numericProp)
|
2130 | },
|
2131 | emits: ["change", "clickOption", "scrollInto"],
|
2132 | setup(props2, {
|
2133 | emit,
|
2134 | slots
|
2135 | }) {
|
2136 | let moving;
|
2137 | let startOffset;
|
2138 | let touchStartTime;
|
2139 | let momentumOffset;
|
2140 | let transitionEndTrigger;
|
2141 | const root = vue.ref();
|
2142 | const wrapper = vue.ref();
|
2143 | const currentOffset = vue.ref(0);
|
2144 | const currentDuration = vue.ref(0);
|
2145 | const touch = useTouch();
|
2146 | const count = () => props2.options.length;
|
2147 | const baseOffset = () => props2.optionHeight * (+props2.visibleOptionNum - 1) / 2;
|
2148 | const updateValueByIndex = (index) => {
|
2149 | let enabledIndex = findIndexOfEnabledOption(props2.options, index);
|
2150 | const offset2 = -enabledIndex * props2.optionHeight;
|
2151 | const trigger = () => {
|
2152 | if (enabledIndex > count() - 1) {
|
2153 | enabledIndex = findIndexOfEnabledOption(props2.options, index);
|
2154 | }
|
2155 | const value = props2.options[enabledIndex][props2.fields.value];
|
2156 | if (value !== props2.value) {
|
2157 | emit("change", value);
|
2158 | }
|
2159 | };
|
2160 | if (moving && offset2 !== currentOffset.value) {
|
2161 | transitionEndTrigger = trigger;
|
2162 | } else {
|
2163 | trigger();
|
2164 | }
|
2165 | currentOffset.value = offset2;
|
2166 | };
|
2167 | const isReadonly = () => props2.readonly || !props2.options.length;
|
2168 | const onClickOption = (index) => {
|
2169 | if (moving || isReadonly()) {
|
2170 | return;
|
2171 | }
|
2172 | transitionEndTrigger = null;
|
2173 | currentDuration.value = DEFAULT_DURATION;
|
2174 | updateValueByIndex(index);
|
2175 | emit("clickOption", props2.options[index]);
|
2176 | };
|
2177 | const getIndexByOffset = (offset2) => clamp(Math.round(-offset2 / props2.optionHeight), 0, count() - 1);
|
2178 | const currentIndex = vue.computed(() => getIndexByOffset(currentOffset.value));
|
2179 | const momentum = (distance, duration) => {
|
2180 | const speed = Math.abs(distance / duration);
|
2181 | distance = currentOffset.value + speed / 3e-3 * (distance < 0 ? -1 : 1);
|
2182 | const index = getIndexByOffset(distance);
|
2183 | currentDuration.value = +props2.swipeDuration;
|
2184 | updateValueByIndex(index);
|
2185 | };
|
2186 | const stopMomentum = () => {
|
2187 | moving = false;
|
2188 | currentDuration.value = 0;
|
2189 | if (transitionEndTrigger) {
|
2190 | transitionEndTrigger();
|
2191 | transitionEndTrigger = null;
|
2192 | }
|
2193 | };
|
2194 | const onTouchStart = (event) => {
|
2195 | if (isReadonly()) {
|
2196 | return;
|
2197 | }
|
2198 | touch.start(event);
|
2199 | if (moving) {
|
2200 | const translateY = getElementTranslateY(wrapper.value);
|
2201 | currentOffset.value = Math.min(0, translateY - baseOffset());
|
2202 | }
|
2203 | currentDuration.value = 0;
|
2204 | startOffset = currentOffset.value;
|
2205 | touchStartTime = Date.now();
|
2206 | momentumOffset = startOffset;
|
2207 | transitionEndTrigger = null;
|
2208 | };
|
2209 | const onTouchMove = (event) => {
|
2210 | if (isReadonly()) {
|
2211 | return;
|
2212 | }
|
2213 | touch.move(event);
|
2214 | if (touch.isVertical()) {
|
2215 | moving = true;
|
2216 | preventDefault(event, true);
|
2217 | }
|
2218 | const newOffset = clamp(startOffset + touch.deltaY.value, -(count() * props2.optionHeight), props2.optionHeight);
|
2219 | const newIndex = getIndexByOffset(newOffset);
|
2220 | if (newIndex !== currentIndex.value) {
|
2221 | emit("scrollInto", props2.options[newIndex]);
|
2222 | }
|
2223 | currentOffset.value = newOffset;
|
2224 | const now = Date.now();
|
2225 | if (now - touchStartTime > MOMENTUM_TIME) {
|
2226 | touchStartTime = now;
|
2227 | momentumOffset = newOffset;
|
2228 | }
|
2229 | };
|
2230 | const onTouchEnd = () => {
|
2231 | if (isReadonly()) {
|
2232 | return;
|
2233 | }
|
2234 | const distance = currentOffset.value - momentumOffset;
|
2235 | const duration = Date.now() - touchStartTime;
|
2236 | const startMomentum = duration < MOMENTUM_TIME && Math.abs(distance) > MOMENTUM_DISTANCE;
|
2237 | if (startMomentum) {
|
2238 | momentum(distance, duration);
|
2239 | return;
|
2240 | }
|
2241 | const index = getIndexByOffset(currentOffset.value);
|
2242 | currentDuration.value = DEFAULT_DURATION;
|
2243 | updateValueByIndex(index);
|
2244 | setTimeout(() => {
|
2245 | moving = false;
|
2246 | }, 0);
|
2247 | };
|
2248 | const renderOptions = () => {
|
2249 | const optionStyle = {
|
2250 | height: `${props2.optionHeight}px`
|
2251 | };
|
2252 | return props2.options.map((option, index) => {
|
2253 | const text = option[props2.fields.text];
|
2254 | const {
|
2255 | disabled
|
2256 | } = option;
|
2257 | const value = option[props2.fields.value];
|
2258 | const data = {
|
2259 | role: "button",
|
2260 | style: optionStyle,
|
2261 | tabindex: disabled ? -1 : 0,
|
2262 | class: [bem$1t("item", {
|
2263 | disabled,
|
2264 | selected: value === props2.value
|
2265 | }), option.className],
|
2266 | onClick: () => onClickOption(index)
|
2267 | };
|
2268 | const childData = {
|
2269 | class: "van-ellipsis",
|
2270 | [props2.allowHtml ? "innerHTML" : "textContent"]: text
|
2271 | };
|
2272 | return vue.createVNode("li", data, [slots.option ? slots.option(option, index) : vue.createVNode("div", childData, null)]);
|
2273 | });
|
2274 | };
|
2275 | useParent(PICKER_KEY);
|
2276 | useExpose({
|
2277 | stopMomentum
|
2278 | });
|
2279 | vue.watchEffect(() => {
|
2280 | const index = moving ? Math.floor(-currentOffset.value / props2.optionHeight) : props2.options.findIndex((option) => option[props2.fields.value] === props2.value);
|
2281 | const enabledIndex = findIndexOfEnabledOption(props2.options, index);
|
2282 | const offset2 = -enabledIndex * props2.optionHeight;
|
2283 | if (moving && enabledIndex < index) stopMomentum();
|
2284 | currentOffset.value = offset2;
|
2285 | });
|
2286 | useEventListener("touchmove", onTouchMove, {
|
2287 | target: root
|
2288 | });
|
2289 | return () => vue.createVNode("div", {
|
2290 | "ref": root,
|
2291 | "class": bem$1t(),
|
2292 | "onTouchstartPassive": onTouchStart,
|
2293 | "onTouchend": onTouchEnd,
|
2294 | "onTouchcancel": onTouchEnd
|
2295 | }, [vue.createVNode("ul", {
|
2296 | "ref": wrapper,
|
2297 | "style": {
|
2298 | transform: `translate3d(0, ${currentOffset.value + baseOffset()}px, 0)`,
|
2299 | transitionDuration: `${currentDuration.value}ms`,
|
2300 | transitionProperty: currentDuration.value ? "all" : "none"
|
2301 | },
|
2302 | "class": bem$1t("wrapper"),
|
2303 | "onTransitionend": stopMomentum
|
2304 | }, [renderOptions()])]);
|
2305 | }
|
2306 | });
|
2307 | const [name$1x] = createNamespace("picker-toolbar");
|
2308 | const pickerToolbarProps = {
|
2309 | title: String,
|
2310 | cancelButtonText: String,
|
2311 | confirmButtonText: String
|
2312 | };
|
2313 | const pickerToolbarSlots = ["cancel", "confirm", "title", "toolbar"];
|
2314 | const pickerToolbarPropKeys = Object.keys(pickerToolbarProps);
|
2315 | var stdin_default$1H = vue.defineComponent({
|
2316 | name: name$1x,
|
2317 | props: pickerToolbarProps,
|
2318 | emits: ["confirm", "cancel"],
|
2319 | setup(props2, {
|
2320 | emit,
|
2321 | slots
|
2322 | }) {
|
2323 | const renderTitle = () => {
|
2324 | if (slots.title) {
|
2325 | return slots.title();
|
2326 | }
|
2327 | if (props2.title) {
|
2328 | return vue.createVNode("div", {
|
2329 | "class": [bem$1u("title"), "van-ellipsis"]
|
2330 | }, [props2.title]);
|
2331 | }
|
2332 | };
|
2333 | const onCancel = () => emit("cancel");
|
2334 | const onConfirm = () => emit("confirm");
|
2335 | const renderCancel = () => {
|
2336 | var _a;
|
2337 | const text = (_a = props2.cancelButtonText) != null ? _a : t$k("cancel");
|
2338 | if (!slots.cancel && !text) {
|
2339 | return;
|
2340 | }
|
2341 | return vue.createVNode("button", {
|
2342 | "type": "button",
|
2343 | "class": [bem$1u("cancel"), HAPTICS_FEEDBACK],
|
2344 | "onClick": onCancel
|
2345 | }, [slots.cancel ? slots.cancel() : text]);
|
2346 | };
|
2347 | const renderConfirm = () => {
|
2348 | var _a;
|
2349 | const text = (_a = props2.confirmButtonText) != null ? _a : t$k("confirm");
|
2350 | if (!slots.confirm && !text) {
|
2351 | return;
|
2352 | }
|
2353 | return vue.createVNode("button", {
|
2354 | "type": "button",
|
2355 | "class": [bem$1u("confirm"), HAPTICS_FEEDBACK],
|
2356 | "onClick": onConfirm
|
2357 | }, [slots.confirm ? slots.confirm() : text]);
|
2358 | };
|
2359 | return () => vue.createVNode("div", {
|
2360 | "class": bem$1u("toolbar")
|
2361 | }, [slots.toolbar ? slots.toolbar() : [renderCancel(), renderTitle(), renderConfirm()]]);
|
2362 | }
|
2363 | });
|
2364 | const useSyncPropRef = (getProp, setProp) => {
|
2365 | const propRef = vue.ref(getProp());
|
2366 | vue.watch(getProp, (value) => {
|
2367 | if (value !== propRef.value) {
|
2368 | propRef.value = value;
|
2369 | }
|
2370 | });
|
2371 | vue.watch(propRef, (value) => {
|
2372 | if (value !== getProp()) {
|
2373 | setProp(value);
|
2374 | }
|
2375 | });
|
2376 | return propRef;
|
2377 | };
|
2378 | |
2379 |
|
2380 |
|
2381 |
|
2382 |
|
2383 | const isArray = Array.isArray;
|
2384 | const isString = (val) => typeof val === "string";
|
2385 | const isObject = (val) => val !== null && typeof val === "object";
|
2386 | const cacheStringFunction = (fn) => {
|
2387 | const cache = Object.create(null);
|
2388 | return (str) => {
|
2389 | const hit = cache[str];
|
2390 | return hit || (cache[str] = fn(str));
|
2391 | };
|
2392 | };
|
2393 | const hyphenateRE = /\B([A-Z])/g;
|
2394 | const hyphenate = cacheStringFunction(
|
2395 | (str) => str.replace(hyphenateRE, "-$1").toLowerCase()
|
2396 | );
|
2397 | function normalizeStyle(value) {
|
2398 | if (isArray(value)) {
|
2399 | const res = {};
|
2400 | for (let i = 0; i < value.length; i++) {
|
2401 | const item = value[i];
|
2402 | const normalized = isString(item) ? parseStringStyle(item) : normalizeStyle(item);
|
2403 | if (normalized) {
|
2404 | for (const key in normalized) {
|
2405 | res[key] = normalized[key];
|
2406 | }
|
2407 | }
|
2408 | }
|
2409 | return res;
|
2410 | } else if (isString(value) || isObject(value)) {
|
2411 | return value;
|
2412 | }
|
2413 | }
|
2414 | const listDelimiterRE = /;(?![^(]*\))/g;
|
2415 | const propertyDelimiterRE = /:([^]+)/;
|
2416 | const styleCommentRE = /\/\*[^]*?\*\//g;
|
2417 | function parseStringStyle(cssText) {
|
2418 | const ret = {};
|
2419 | cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
|
2420 | if (item) {
|
2421 | const tmp = item.split(propertyDelimiterRE);
|
2422 | tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
|
2423 | }
|
2424 | });
|
2425 | return ret;
|
2426 | }
|
2427 | function stringifyStyle(styles) {
|
2428 | let ret = "";
|
2429 | if (!styles || isString(styles)) {
|
2430 | return ret;
|
2431 | }
|
2432 | for (const key in styles) {
|
2433 | const value = styles[key];
|
2434 | if (isString(value) || typeof value === "number") {
|
2435 | const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
|
2436 | ret += `${normalizedKey}:${value};`;
|
2437 | }
|
2438 | }
|
2439 | return ret;
|
2440 | }
|
2441 | function normalizeClass(value) {
|
2442 | let res = "";
|
2443 | if (isString(value)) {
|
2444 | res = value;
|
2445 | } else if (isArray(value)) {
|
2446 | for (let i = 0; i < value.length; i++) {
|
2447 | const normalized = normalizeClass(value[i]);
|
2448 | if (normalized) {
|
2449 | res += normalized + " ";
|
2450 | }
|
2451 | }
|
2452 | } else if (isObject(value)) {
|
2453 | for (const name2 in value) {
|
2454 | if (value[name2]) {
|
2455 | res += name2 + " ";
|
2456 | }
|
2457 | }
|
2458 | }
|
2459 | return res.trim();
|
2460 | }
|
2461 | function scrollLeftTo(scroller, to, duration) {
|
2462 | let rafId;
|
2463 | let count = 0;
|
2464 | const from = scroller.scrollLeft;
|
2465 | const frames = duration === 0 ? 1 : Math.round(duration * 1e3 / 16);
|
2466 | let scrollLeft = from;
|
2467 | function cancel() {
|
2468 | cancelRaf(rafId);
|
2469 | }
|
2470 | function animate() {
|
2471 | scrollLeft += (to - from) / frames;
|
2472 | scroller.scrollLeft = scrollLeft;
|
2473 | if (++count < frames) {
|
2474 | rafId = raf(animate);
|
2475 | }
|
2476 | }
|
2477 | animate();
|
2478 | return cancel;
|
2479 | }
|
2480 | function scrollTopTo(scroller, to, duration, callback) {
|
2481 | let rafId;
|
2482 | let current2 = getScrollTop(scroller);
|
2483 | const isDown = current2 < to;
|
2484 | const frames = duration === 0 ? 1 : Math.round(duration * 1e3 / 16);
|
2485 | const step = (to - current2) / frames;
|
2486 | function cancel() {
|
2487 | cancelRaf(rafId);
|
2488 | }
|
2489 | function animate() {
|
2490 | current2 += step;
|
2491 | if (isDown && current2 > to || !isDown && current2 < to) {
|
2492 | current2 = to;
|
2493 | }
|
2494 | setScrollTop(scroller, current2);
|
2495 | if (isDown && current2 < to || !isDown && current2 > to) {
|
2496 | rafId = raf(animate);
|
2497 | } else if (callback) {
|
2498 | rafId = raf(callback);
|
2499 | }
|
2500 | }
|
2501 | animate();
|
2502 | return cancel;
|
2503 | }
|
2504 | let current = 0;
|
2505 | function useId() {
|
2506 | const vm = vue.getCurrentInstance();
|
2507 | const { name: name2 = "unknown" } = (vm == null ? void 0 : vm.type) || {};
|
2508 | return `${name2}-${++current}`;
|
2509 | }
|
2510 | function useRefs() {
|
2511 | const refs = vue.ref([]);
|
2512 | const cache = [];
|
2513 | vue.onBeforeUpdate(() => {
|
2514 | refs.value = [];
|
2515 | });
|
2516 | const setRefs = (index) => {
|
2517 | if (!cache[index]) {
|
2518 | cache[index] = (el) => {
|
2519 | refs.value[index] = el;
|
2520 | };
|
2521 | }
|
2522 | return cache[index];
|
2523 | };
|
2524 | return [refs, setRefs];
|
2525 | }
|
2526 | function useVisibilityChange(target, onChange) {
|
2527 | if (!inBrowser$1 || !window.IntersectionObserver) {
|
2528 | return;
|
2529 | }
|
2530 | const observer = new IntersectionObserver(
|
2531 | (entries) => {
|
2532 | onChange(entries[0].intersectionRatio > 0);
|
2533 | },
|
2534 | { root: document.body }
|
2535 | );
|
2536 | const observe = () => {
|
2537 | if (target.value) {
|
2538 | observer.observe(target.value);
|
2539 | }
|
2540 | };
|
2541 | const unobserve = () => {
|
2542 | if (target.value) {
|
2543 | observer.unobserve(target.value);
|
2544 | }
|
2545 | };
|
2546 | vue.onDeactivated(unobserve);
|
2547 | vue.onBeforeUnmount(unobserve);
|
2548 | onMountedOrActivated(observe);
|
2549 | }
|
2550 | const [name$1w, bem$1s] = createNamespace("sticky");
|
2551 | const stickyProps = {
|
2552 | zIndex: numericProp,
|
2553 | position: makeStringProp("top"),
|
2554 | container: Object,
|
2555 | offsetTop: makeNumericProp(0),
|
2556 | offsetBottom: makeNumericProp(0)
|
2557 | };
|
2558 | var stdin_default$1G = vue.defineComponent({
|
2559 | name: name$1w,
|
2560 | props: stickyProps,
|
2561 | emits: ["scroll", "change"],
|
2562 | setup(props2, {
|
2563 | emit,
|
2564 | slots
|
2565 | }) {
|
2566 | const root = vue.ref();
|
2567 | const scrollParent = useScrollParent(root);
|
2568 | const state = vue.reactive({
|
2569 | fixed: false,
|
2570 | width: 0,
|
2571 |
|
2572 | height: 0,
|
2573 |
|
2574 | transform: 0
|
2575 | });
|
2576 | const isReset = vue.ref(false);
|
2577 | const offset2 = vue.computed(() => unitToPx(props2.position === "top" ? props2.offsetTop : props2.offsetBottom));
|
2578 | const rootStyle = vue.computed(() => {
|
2579 | if (isReset.value) {
|
2580 | return;
|
2581 | }
|
2582 | const {
|
2583 | fixed,
|
2584 | height: height2,
|
2585 | width: width2
|
2586 | } = state;
|
2587 | if (fixed) {
|
2588 | return {
|
2589 | width: `${width2}px`,
|
2590 | height: `${height2}px`
|
2591 | };
|
2592 | }
|
2593 | });
|
2594 | const stickyStyle = vue.computed(() => {
|
2595 | if (!state.fixed || isReset.value) {
|
2596 | return;
|
2597 | }
|
2598 | const style = extend(getZIndexStyle(props2.zIndex), {
|
2599 | width: `${state.width}px`,
|
2600 | height: `${state.height}px`,
|
2601 | [props2.position]: `${offset2.value}px`
|
2602 | });
|
2603 | if (state.transform) {
|
2604 | style.transform = `translate3d(0, ${state.transform}px, 0)`;
|
2605 | }
|
2606 | return style;
|
2607 | });
|
2608 | const emitScroll = (scrollTop) => emit("scroll", {
|
2609 | scrollTop,
|
2610 | isFixed: state.fixed
|
2611 | });
|
2612 | const onScroll = () => {
|
2613 | if (!root.value || isHidden(root)) {
|
2614 | return;
|
2615 | }
|
2616 | const {
|
2617 | container,
|
2618 | position
|
2619 | } = props2;
|
2620 | const rootRect = useRect(root);
|
2621 | const scrollTop = getScrollTop(window);
|
2622 | state.width = rootRect.width;
|
2623 | state.height = rootRect.height;
|
2624 | if (position === "top") {
|
2625 | if (container) {
|
2626 | const containerRect = useRect(container);
|
2627 | const difference = containerRect.bottom - offset2.value - state.height;
|
2628 | state.fixed = offset2.value > rootRect.top && containerRect.bottom > 0;
|
2629 | state.transform = difference < 0 ? difference : 0;
|
2630 | } else {
|
2631 | state.fixed = offset2.value > rootRect.top;
|
2632 | }
|
2633 | } else {
|
2634 | const {
|
2635 | clientHeight
|
2636 | } = document.documentElement;
|
2637 | if (container) {
|
2638 | const containerRect = useRect(container);
|
2639 | const difference = clientHeight - containerRect.top - offset2.value - state.height;
|
2640 | state.fixed = clientHeight - offset2.value < rootRect.bottom && clientHeight > containerRect.top;
|
2641 | state.transform = difference < 0 ? -difference : 0;
|
2642 | } else {
|
2643 | state.fixed = clientHeight - offset2.value < rootRect.bottom;
|
2644 | }
|
2645 | }
|
2646 | emitScroll(scrollTop);
|
2647 | };
|
2648 | vue.watch(() => state.fixed, (value) => emit("change", value));
|
2649 | useEventListener("scroll", onScroll, {
|
2650 | target: scrollParent,
|
2651 | passive: true
|
2652 | });
|
2653 | useVisibilityChange(root, onScroll);
|
2654 | vue.watch([windowWidth, windowHeight], () => {
|
2655 | if (!root.value || isHidden(root) || !state.fixed) {
|
2656 | return;
|
2657 | }
|
2658 | isReset.value = true;
|
2659 | vue.nextTick(() => {
|
2660 | const rootRect = useRect(root);
|
2661 | state.width = rootRect.width;
|
2662 | state.height = rootRect.height;
|
2663 | isReset.value = false;
|
2664 | });
|
2665 | });
|
2666 | return () => {
|
2667 | var _a;
|
2668 | return vue.createVNode("div", {
|
2669 | "ref": root,
|
2670 | "style": rootStyle.value
|
2671 | }, [vue.createVNode("div", {
|
2672 | "class": bem$1s({
|
2673 | fixed: state.fixed && !isReset.value
|
2674 | }),
|
2675 | "style": stickyStyle.value
|
2676 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
|
2677 | };
|
2678 | }
|
2679 | });
|
2680 | const Sticky = withInstall(stdin_default$1G);
|
2681 | const [name$1v, bem$1r] = createNamespace("swipe");
|
2682 | const swipeProps = {
|
2683 | loop: truthProp,
|
2684 | width: numericProp,
|
2685 | height: numericProp,
|
2686 | vertical: Boolean,
|
2687 | autoplay: makeNumericProp(0),
|
2688 | duration: makeNumericProp(500),
|
2689 | touchable: truthProp,
|
2690 | lazyRender: Boolean,
|
2691 | initialSwipe: makeNumericProp(0),
|
2692 | indicatorColor: String,
|
2693 | showIndicators: truthProp,
|
2694 | stopPropagation: truthProp
|
2695 | };
|
2696 | const SWIPE_KEY = Symbol(name$1v);
|
2697 | var stdin_default$1F = vue.defineComponent({
|
2698 | name: name$1v,
|
2699 | props: swipeProps,
|
2700 | emits: ["change", "dragStart", "dragEnd"],
|
2701 | setup(props2, {
|
2702 | emit,
|
2703 | slots
|
2704 | }) {
|
2705 | const root = vue.ref();
|
2706 | const track = vue.ref();
|
2707 | const state = vue.reactive({
|
2708 | rect: null,
|
2709 | width: 0,
|
2710 | height: 0,
|
2711 | offset: 0,
|
2712 | active: 0,
|
2713 | swiping: false
|
2714 | });
|
2715 | let dragging = false;
|
2716 | const touch = useTouch();
|
2717 | const {
|
2718 | children,
|
2719 | linkChildren
|
2720 | } = useChildren(SWIPE_KEY);
|
2721 | const count = vue.computed(() => children.length);
|
2722 | const size = vue.computed(() => state[props2.vertical ? "height" : "width"]);
|
2723 | const delta = vue.computed(() => props2.vertical ? touch.deltaY.value : touch.deltaX.value);
|
2724 | const minOffset = vue.computed(() => {
|
2725 | if (state.rect) {
|
2726 | const base = props2.vertical ? state.rect.height : state.rect.width;
|
2727 | return base - size.value * count.value;
|
2728 | }
|
2729 | return 0;
|
2730 | });
|
2731 | const maxCount = vue.computed(() => size.value ? Math.ceil(Math.abs(minOffset.value) / size.value) : count.value);
|
2732 | const trackSize = vue.computed(() => count.value * size.value);
|
2733 | const activeIndicator = vue.computed(() => (state.active + count.value) % count.value);
|
2734 | const isCorrectDirection = vue.computed(() => {
|
2735 | const expect = props2.vertical ? "vertical" : "horizontal";
|
2736 | return touch.direction.value === expect;
|
2737 | });
|
2738 | const trackStyle = vue.computed(() => {
|
2739 | const style = {
|
2740 | transitionDuration: `${state.swiping ? 0 : props2.duration}ms`,
|
2741 | transform: `translate${props2.vertical ? "Y" : "X"}(${+state.offset.toFixed(2)}px)`
|
2742 | };
|
2743 | if (size.value) {
|
2744 | const mainAxis = props2.vertical ? "height" : "width";
|
2745 | const crossAxis = props2.vertical ? "width" : "height";
|
2746 | style[mainAxis] = `${trackSize.value}px`;
|
2747 | style[crossAxis] = props2[crossAxis] ? `${props2[crossAxis]}px` : "";
|
2748 | }
|
2749 | return style;
|
2750 | });
|
2751 | const getTargetActive = (pace) => {
|
2752 | const {
|
2753 | active
|
2754 | } = state;
|
2755 | if (pace) {
|
2756 | if (props2.loop) {
|
2757 | return clamp(active + pace, -1, count.value);
|
2758 | }
|
2759 | return clamp(active + pace, 0, maxCount.value);
|
2760 | }
|
2761 | return active;
|
2762 | };
|
2763 | const getTargetOffset = (targetActive, offset2 = 0) => {
|
2764 | let currentPosition = targetActive * size.value;
|
2765 | if (!props2.loop) {
|
2766 | currentPosition = Math.min(currentPosition, -minOffset.value);
|
2767 | }
|
2768 | let targetOffset = offset2 - currentPosition;
|
2769 | if (!props2.loop) {
|
2770 | targetOffset = clamp(targetOffset, minOffset.value, 0);
|
2771 | }
|
2772 | return targetOffset;
|
2773 | };
|
2774 | const move = ({
|
2775 | pace = 0,
|
2776 | offset: offset2 = 0,
|
2777 | emitChange
|
2778 | }) => {
|
2779 | if (count.value <= 1) {
|
2780 | return;
|
2781 | }
|
2782 | const {
|
2783 | active
|
2784 | } = state;
|
2785 | const targetActive = getTargetActive(pace);
|
2786 | const targetOffset = getTargetOffset(targetActive, offset2);
|
2787 | if (props2.loop) {
|
2788 | if (children[0] && targetOffset !== minOffset.value) {
|
2789 | const outRightBound = targetOffset < minOffset.value;
|
2790 | children[0].setOffset(outRightBound ? trackSize.value : 0);
|
2791 | }
|
2792 | if (children[count.value - 1] && targetOffset !== 0) {
|
2793 | const outLeftBound = targetOffset > 0;
|
2794 | children[count.value - 1].setOffset(outLeftBound ? -trackSize.value : 0);
|
2795 | }
|
2796 | }
|
2797 | state.active = targetActive;
|
2798 | state.offset = targetOffset;
|
2799 | if (emitChange && targetActive !== active) {
|
2800 | emit("change", activeIndicator.value);
|
2801 | }
|
2802 | };
|
2803 | const correctPosition = () => {
|
2804 | state.swiping = true;
|
2805 | if (state.active <= -1) {
|
2806 | move({
|
2807 | pace: count.value
|
2808 | });
|
2809 | } else if (state.active >= count.value) {
|
2810 | move({
|
2811 | pace: -count.value
|
2812 | });
|
2813 | }
|
2814 | };
|
2815 | const prev = () => {
|
2816 | correctPosition();
|
2817 | touch.reset();
|
2818 | doubleRaf(() => {
|
2819 | state.swiping = false;
|
2820 | move({
|
2821 | pace: -1,
|
2822 | emitChange: true
|
2823 | });
|
2824 | });
|
2825 | };
|
2826 | const next = () => {
|
2827 | correctPosition();
|
2828 | touch.reset();
|
2829 | doubleRaf(() => {
|
2830 | state.swiping = false;
|
2831 | move({
|
2832 | pace: 1,
|
2833 | emitChange: true
|
2834 | });
|
2835 | });
|
2836 | };
|
2837 | let autoplayTimer;
|
2838 | const stopAutoplay = () => clearTimeout(autoplayTimer);
|
2839 | const autoplay = () => {
|
2840 | stopAutoplay();
|
2841 | if (+props2.autoplay > 0 && count.value > 1) {
|
2842 | autoplayTimer = setTimeout(() => {
|
2843 | next();
|
2844 | autoplay();
|
2845 | }, +props2.autoplay);
|
2846 | }
|
2847 | };
|
2848 | const initialize = (active = +props2.initialSwipe) => {
|
2849 | if (!root.value) {
|
2850 | return;
|
2851 | }
|
2852 | const cb = () => {
|
2853 | var _a, _b;
|
2854 | if (!isHidden(root)) {
|
2855 | const rect = {
|
2856 | width: root.value.offsetWidth,
|
2857 | height: root.value.offsetHeight
|
2858 | };
|
2859 | state.rect = rect;
|
2860 | state.width = +((_a = props2.width) != null ? _a : rect.width);
|
2861 | state.height = +((_b = props2.height) != null ? _b : rect.height);
|
2862 | }
|
2863 | if (count.value) {
|
2864 | active = Math.min(count.value - 1, active);
|
2865 | if (active === -1) {
|
2866 | active = count.value - 1;
|
2867 | }
|
2868 | }
|
2869 | state.active = active;
|
2870 | state.swiping = true;
|
2871 | state.offset = getTargetOffset(active);
|
2872 | children.forEach((swipe) => {
|
2873 | swipe.setOffset(0);
|
2874 | });
|
2875 | autoplay();
|
2876 | };
|
2877 | if (isHidden(root)) {
|
2878 | vue.nextTick().then(cb);
|
2879 | } else {
|
2880 | cb();
|
2881 | }
|
2882 | };
|
2883 | const resize = () => initialize(state.active);
|
2884 | let touchStartTime;
|
2885 | const onTouchStart = (event) => {
|
2886 | if (!props2.touchable ||
|
2887 | event.touches.length > 1) return;
|
2888 | touch.start(event);
|
2889 | dragging = false;
|
2890 | touchStartTime = Date.now();
|
2891 | stopAutoplay();
|
2892 | correctPosition();
|
2893 | };
|
2894 | const onTouchMove = (event) => {
|
2895 | if (props2.touchable && state.swiping) {
|
2896 | touch.move(event);
|
2897 | if (isCorrectDirection.value) {
|
2898 | const isEdgeTouch = !props2.loop && (state.active === 0 && delta.value > 0 || state.active === count.value - 1 && delta.value < 0);
|
2899 | if (!isEdgeTouch) {
|
2900 | preventDefault(event, props2.stopPropagation);
|
2901 | move({
|
2902 | offset: delta.value
|
2903 | });
|
2904 | if (!dragging) {
|
2905 | emit("dragStart", {
|
2906 | index: activeIndicator.value
|
2907 | });
|
2908 | dragging = true;
|
2909 | }
|
2910 | }
|
2911 | }
|
2912 | }
|
2913 | };
|
2914 | const onTouchEnd = () => {
|
2915 | if (!props2.touchable || !state.swiping) {
|
2916 | return;
|
2917 | }
|
2918 | const duration = Date.now() - touchStartTime;
|
2919 | const speed = delta.value / duration;
|
2920 | const shouldSwipe = Math.abs(speed) > 0.25 || Math.abs(delta.value) > size.value / 2;
|
2921 | if (shouldSwipe && isCorrectDirection.value) {
|
2922 | const offset2 = props2.vertical ? touch.offsetY.value : touch.offsetX.value;
|
2923 | let pace = 0;
|
2924 | if (props2.loop) {
|
2925 | pace = offset2 > 0 ? delta.value > 0 ? -1 : 1 : 0;
|
2926 | } else {
|
2927 | pace = -Math[delta.value > 0 ? "ceil" : "floor"](delta.value / size.value);
|
2928 | }
|
2929 | move({
|
2930 | pace,
|
2931 | emitChange: true
|
2932 | });
|
2933 | } else if (delta.value) {
|
2934 | move({
|
2935 | pace: 0
|
2936 | });
|
2937 | }
|
2938 | dragging = false;
|
2939 | state.swiping = false;
|
2940 | emit("dragEnd", {
|
2941 | index: activeIndicator.value
|
2942 | });
|
2943 | autoplay();
|
2944 | };
|
2945 | const swipeTo = (index, options = {}) => {
|
2946 | correctPosition();
|
2947 | touch.reset();
|
2948 | doubleRaf(() => {
|
2949 | let targetIndex;
|
2950 | if (props2.loop && index === count.value) {
|
2951 | targetIndex = state.active === 0 ? 0 : index;
|
2952 | } else {
|
2953 | targetIndex = index % count.value;
|
2954 | }
|
2955 | if (options.immediate) {
|
2956 | doubleRaf(() => {
|
2957 | state.swiping = false;
|
2958 | });
|
2959 | } else {
|
2960 | state.swiping = false;
|
2961 | }
|
2962 | move({
|
2963 | pace: targetIndex - state.active,
|
2964 | emitChange: true
|
2965 | });
|
2966 | });
|
2967 | };
|
2968 | const renderDot = (_, index) => {
|
2969 | const active = index === activeIndicator.value;
|
2970 | const style = active ? {
|
2971 | backgroundColor: props2.indicatorColor
|
2972 | } : void 0;
|
2973 | return vue.createVNode("i", {
|
2974 | "style": style,
|
2975 | "class": bem$1r("indicator", {
|
2976 | active
|
2977 | })
|
2978 | }, null);
|
2979 | };
|
2980 | const renderIndicator = () => {
|
2981 | if (slots.indicator) {
|
2982 | return slots.indicator({
|
2983 | active: activeIndicator.value,
|
2984 | total: count.value
|
2985 | });
|
2986 | }
|
2987 | if (props2.showIndicators && count.value > 1) {
|
2988 | return vue.createVNode("div", {
|
2989 | "class": bem$1r("indicators", {
|
2990 | vertical: props2.vertical
|
2991 | })
|
2992 | }, [Array(count.value).fill("").map(renderDot)]);
|
2993 | }
|
2994 | };
|
2995 | useExpose({
|
2996 | prev,
|
2997 | next,
|
2998 | state,
|
2999 | resize,
|
3000 | swipeTo
|
3001 | });
|
3002 | linkChildren({
|
3003 | size,
|
3004 | props: props2,
|
3005 | count,
|
3006 | activeIndicator
|
3007 | });
|
3008 | vue.watch(() => props2.initialSwipe, (value) => initialize(+value));
|
3009 | vue.watch(count, () => initialize(state.active));
|
3010 | vue.watch(() => props2.autoplay, autoplay);
|
3011 | vue.watch([windowWidth, windowHeight, () => props2.width, () => props2.height], resize);
|
3012 | vue.watch(usePageVisibility(), (visible) => {
|
3013 | if (visible === "visible") {
|
3014 | autoplay();
|
3015 | } else {
|
3016 | stopAutoplay();
|
3017 | }
|
3018 | });
|
3019 | vue.onMounted(initialize);
|
3020 | vue.onActivated(() => initialize(state.active));
|
3021 | onPopupReopen(() => initialize(state.active));
|
3022 | vue.onDeactivated(stopAutoplay);
|
3023 | vue.onBeforeUnmount(stopAutoplay);
|
3024 | useEventListener("touchmove", onTouchMove, {
|
3025 | target: track
|
3026 | });
|
3027 | return () => {
|
3028 | var _a;
|
3029 | return vue.createVNode("div", {
|
3030 | "ref": root,
|
3031 | "class": bem$1r()
|
3032 | }, [vue.createVNode("div", {
|
3033 | "ref": track,
|
3034 | "style": trackStyle.value,
|
3035 | "class": bem$1r("track", {
|
3036 | vertical: props2.vertical
|
3037 | }),
|
3038 | "onTouchstartPassive": onTouchStart,
|
3039 | "onTouchend": onTouchEnd,
|
3040 | "onTouchcancel": onTouchEnd
|
3041 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), renderIndicator()]);
|
3042 | };
|
3043 | }
|
3044 | });
|
3045 | const Swipe = withInstall(stdin_default$1F);
|
3046 | const [name$1u, bem$1q] = createNamespace("tabs");
|
3047 | var stdin_default$1E = vue.defineComponent({
|
3048 | name: name$1u,
|
3049 | props: {
|
3050 | count: makeRequiredProp(Number),
|
3051 | inited: Boolean,
|
3052 | animated: Boolean,
|
3053 | duration: makeRequiredProp(numericProp),
|
3054 | swipeable: Boolean,
|
3055 | lazyRender: Boolean,
|
3056 | currentIndex: makeRequiredProp(Number)
|
3057 | },
|
3058 | emits: ["change"],
|
3059 | setup(props2, {
|
3060 | emit,
|
3061 | slots
|
3062 | }) {
|
3063 | const swipeRef = vue.ref();
|
3064 | const onChange = (index) => emit("change", index);
|
3065 | const renderChildren = () => {
|
3066 | var _a;
|
3067 | const Content = (_a = slots.default) == null ? void 0 : _a.call(slots);
|
3068 | if (props2.animated || props2.swipeable) {
|
3069 | return vue.createVNode(Swipe, {
|
3070 | "ref": swipeRef,
|
3071 | "loop": false,
|
3072 | "class": bem$1q("track"),
|
3073 | "duration": +props2.duration * 1e3,
|
3074 | "touchable": props2.swipeable,
|
3075 | "lazyRender": props2.lazyRender,
|
3076 | "showIndicators": false,
|
3077 | "onChange": onChange
|
3078 | }, {
|
3079 | default: () => [Content]
|
3080 | });
|
3081 | }
|
3082 | return Content;
|
3083 | };
|
3084 | const swipeToCurrentTab = (index) => {
|
3085 | const swipe = swipeRef.value;
|
3086 | if (swipe && swipe.state.active !== index) {
|
3087 | swipe.swipeTo(index, {
|
3088 | immediate: !props2.inited
|
3089 | });
|
3090 | }
|
3091 | };
|
3092 | vue.watch(() => props2.currentIndex, swipeToCurrentTab);
|
3093 | vue.onMounted(() => {
|
3094 | swipeToCurrentTab(props2.currentIndex);
|
3095 | });
|
3096 | useExpose({
|
3097 | swipeRef
|
3098 | });
|
3099 | return () => vue.createVNode("div", {
|
3100 | "class": bem$1q("content", {
|
3101 | animated: props2.animated || props2.swipeable
|
3102 | })
|
3103 | }, [renderChildren()]);
|
3104 | }
|
3105 | });
|
3106 | const [name$1t, bem$1p] = createNamespace("tabs");
|
3107 | const tabsProps = {
|
3108 | type: makeStringProp("line"),
|
3109 | color: String,
|
3110 | border: Boolean,
|
3111 | sticky: Boolean,
|
3112 | shrink: Boolean,
|
3113 | active: makeNumericProp(0),
|
3114 | duration: makeNumericProp(0.3),
|
3115 | animated: Boolean,
|
3116 | ellipsis: truthProp,
|
3117 | swipeable: Boolean,
|
3118 | scrollspy: Boolean,
|
3119 | offsetTop: makeNumericProp(0),
|
3120 | background: String,
|
3121 | lazyRender: truthProp,
|
3122 | showHeader: truthProp,
|
3123 | lineWidth: numericProp,
|
3124 | lineHeight: numericProp,
|
3125 | beforeChange: Function,
|
3126 | swipeThreshold: makeNumericProp(5),
|
3127 | titleActiveColor: String,
|
3128 | titleInactiveColor: String
|
3129 | };
|
3130 | const TABS_KEY = Symbol(name$1t);
|
3131 | var stdin_default$1D = vue.defineComponent({
|
3132 | name: name$1t,
|
3133 | props: tabsProps,
|
3134 | emits: ["change", "scroll", "rendered", "clickTab", "update:active"],
|
3135 | setup(props2, {
|
3136 | emit,
|
3137 | slots
|
3138 | }) {
|
3139 | let tabHeight;
|
3140 | let lockScroll;
|
3141 | let stickyFixed;
|
3142 | let cancelScrollLeftToRaf;
|
3143 | let cancelScrollTopToRaf;
|
3144 | const root = vue.ref();
|
3145 | const navRef = vue.ref();
|
3146 | const wrapRef = vue.ref();
|
3147 | const contentRef = vue.ref();
|
3148 | const id = useId();
|
3149 | const scroller = useScrollParent(root);
|
3150 | const [titleRefs, setTitleRefs] = useRefs();
|
3151 | const {
|
3152 | children,
|
3153 | linkChildren
|
3154 | } = useChildren(TABS_KEY);
|
3155 | const state = vue.reactive({
|
3156 | inited: false,
|
3157 | position: "",
|
3158 | lineStyle: {},
|
3159 | currentIndex: -1
|
3160 | });
|
3161 | const scrollable = vue.computed(() => children.length > +props2.swipeThreshold || !props2.ellipsis || props2.shrink);
|
3162 | const navStyle = vue.computed(() => ({
|
3163 | borderColor: props2.color,
|
3164 | background: props2.background
|
3165 | }));
|
3166 | const getTabName = (tab, index) => {
|
3167 | var _a;
|
3168 | return (_a = tab.name) != null ? _a : index;
|
3169 | };
|
3170 | const currentName = vue.computed(() => {
|
3171 | const activeTab = children[state.currentIndex];
|
3172 | if (activeTab) {
|
3173 | return getTabName(activeTab, state.currentIndex);
|
3174 | }
|
3175 | });
|
3176 | const offsetTopPx = vue.computed(() => unitToPx(props2.offsetTop));
|
3177 | const scrollOffset = vue.computed(() => {
|
3178 | if (props2.sticky) {
|
3179 | return offsetTopPx.value + tabHeight;
|
3180 | }
|
3181 | return 0;
|
3182 | });
|
3183 | const scrollIntoView = (immediate) => {
|
3184 | const nav = navRef.value;
|
3185 | const titles = titleRefs.value;
|
3186 | if (!scrollable.value || !nav || !titles || !titles[state.currentIndex]) {
|
3187 | return;
|
3188 | }
|
3189 | const title = titles[state.currentIndex].$el;
|
3190 | const to = title.offsetLeft - (nav.offsetWidth - title.offsetWidth) / 2;
|
3191 | if (cancelScrollLeftToRaf) cancelScrollLeftToRaf();
|
3192 | cancelScrollLeftToRaf = scrollLeftTo(nav, to, immediate ? 0 : +props2.duration);
|
3193 | };
|
3194 | const setLine = () => {
|
3195 | const shouldAnimate = state.inited;
|
3196 | vue.nextTick(() => {
|
3197 | const titles = titleRefs.value;
|
3198 | if (!titles || !titles[state.currentIndex] || props2.type !== "line" || isHidden(root.value)) {
|
3199 | return;
|
3200 | }
|
3201 | const title = titles[state.currentIndex].$el;
|
3202 | const {
|
3203 | lineWidth,
|
3204 | lineHeight
|
3205 | } = props2;
|
3206 | const left2 = title.offsetLeft + title.offsetWidth / 2;
|
3207 | const lineStyle = {
|
3208 | width: addUnit(lineWidth),
|
3209 | backgroundColor: props2.color,
|
3210 | transform: `translateX(${left2}px) translateX(-50%)`
|
3211 | };
|
3212 | if (shouldAnimate) {
|
3213 | lineStyle.transitionDuration = `${props2.duration}s`;
|
3214 | }
|
3215 | if (isDef(lineHeight)) {
|
3216 | const height2 = addUnit(lineHeight);
|
3217 | lineStyle.height = height2;
|
3218 | lineStyle.borderRadius = height2;
|
3219 | }
|
3220 | state.lineStyle = lineStyle;
|
3221 | });
|
3222 | };
|
3223 | const findAvailableTab = (index) => {
|
3224 | const diff = index < state.currentIndex ? -1 : 1;
|
3225 | while (index >= 0 && index < children.length) {
|
3226 | if (!children[index].disabled) {
|
3227 | return index;
|
3228 | }
|
3229 | index += diff;
|
3230 | }
|
3231 | };
|
3232 | const setCurrentIndex = (currentIndex, skipScrollIntoView) => {
|
3233 | const newIndex = findAvailableTab(currentIndex);
|
3234 | if (!isDef(newIndex)) {
|
3235 | return;
|
3236 | }
|
3237 | const newTab = children[newIndex];
|
3238 | const newName = getTabName(newTab, newIndex);
|
3239 | const shouldEmitChange = state.currentIndex !== null;
|
3240 | if (state.currentIndex !== newIndex) {
|
3241 | state.currentIndex = newIndex;
|
3242 | if (!skipScrollIntoView) {
|
3243 | scrollIntoView();
|
3244 | }
|
3245 | setLine();
|
3246 | }
|
3247 | if (newName !== props2.active) {
|
3248 | emit("update:active", newName);
|
3249 | if (shouldEmitChange) {
|
3250 | emit("change", newName, newTab.title);
|
3251 | }
|
3252 | }
|
3253 | if (stickyFixed && !props2.scrollspy) {
|
3254 | setRootScrollTop(Math.ceil(getElementTop(root.value) - offsetTopPx.value));
|
3255 | }
|
3256 | };
|
3257 | const setCurrentIndexByName = (name2, skipScrollIntoView) => {
|
3258 | const matched = children.find((tab, index2) => getTabName(tab, index2) === name2);
|
3259 | const index = matched ? children.indexOf(matched) : 0;
|
3260 | setCurrentIndex(index, skipScrollIntoView);
|
3261 | };
|
3262 | const scrollToCurrentContent = (immediate = false) => {
|
3263 | if (props2.scrollspy) {
|
3264 | const target = children[state.currentIndex].$el;
|
3265 | if (target && scroller.value) {
|
3266 | const to = getElementTop(target, scroller.value) - scrollOffset.value;
|
3267 | lockScroll = true;
|
3268 | if (cancelScrollTopToRaf) cancelScrollTopToRaf();
|
3269 | cancelScrollTopToRaf = scrollTopTo(scroller.value, to, immediate ? 0 : +props2.duration, () => {
|
3270 | lockScroll = false;
|
3271 | });
|
3272 | }
|
3273 | }
|
3274 | };
|
3275 | const onClickTab = (item, index, event) => {
|
3276 | const {
|
3277 | title,
|
3278 | disabled
|
3279 | } = children[index];
|
3280 | const name2 = getTabName(children[index], index);
|
3281 | if (!disabled) {
|
3282 | callInterceptor(props2.beforeChange, {
|
3283 | args: [name2],
|
3284 | done: () => {
|
3285 | setCurrentIndex(index);
|
3286 | scrollToCurrentContent();
|
3287 | }
|
3288 | });
|
3289 | route(item);
|
3290 | }
|
3291 | emit("clickTab", {
|
3292 | name: name2,
|
3293 | title,
|
3294 | event,
|
3295 | disabled
|
3296 | });
|
3297 | };
|
3298 | const onStickyScroll = (params) => {
|
3299 | stickyFixed = params.isFixed;
|
3300 | emit("scroll", params);
|
3301 | };
|
3302 | const scrollTo = (name2) => {
|
3303 | vue.nextTick(() => {
|
3304 | setCurrentIndexByName(name2);
|
3305 | scrollToCurrentContent(true);
|
3306 | });
|
3307 | };
|
3308 | const getCurrentIndexOnScroll = () => {
|
3309 | for (let index = 0; index < children.length; index++) {
|
3310 | const {
|
3311 | top: top2
|
3312 | } = useRect(children[index].$el);
|
3313 | if (top2 > scrollOffset.value) {
|
3314 | return index === 0 ? 0 : index - 1;
|
3315 | }
|
3316 | }
|
3317 | return children.length - 1;
|
3318 | };
|
3319 | const onScroll = () => {
|
3320 | if (props2.scrollspy && !lockScroll) {
|
3321 | const index = getCurrentIndexOnScroll();
|
3322 | setCurrentIndex(index);
|
3323 | }
|
3324 | };
|
3325 | const renderLine = () => {
|
3326 | if (props2.type === "line" && children.length) {
|
3327 | return vue.createVNode("div", {
|
3328 | "class": bem$1p("line"),
|
3329 | "style": state.lineStyle
|
3330 | }, null);
|
3331 | }
|
3332 | };
|
3333 | const renderHeader = () => {
|
3334 | var _a, _b, _c;
|
3335 | const {
|
3336 | type,
|
3337 | border,
|
3338 | sticky
|
3339 | } = props2;
|
3340 | const Header = [vue.createVNode("div", {
|
3341 | "ref": sticky ? void 0 : wrapRef,
|
3342 | "class": [bem$1p("wrap"), {
|
3343 | [BORDER_TOP_BOTTOM]: type === "line" && border
|
3344 | }]
|
3345 | }, [vue.createVNode("div", {
|
3346 | "ref": navRef,
|
3347 | "role": "tablist",
|
3348 | "class": bem$1p("nav", [type, {
|
3349 | shrink: props2.shrink,
|
3350 | complete: scrollable.value
|
3351 | }]),
|
3352 | "style": navStyle.value,
|
3353 | "aria-orientation": "horizontal"
|
3354 | }, [(_a = slots["nav-left"]) == null ? void 0 : _a.call(slots), children.map((item) => item.renderTitle(onClickTab)), renderLine(), (_b = slots["nav-right"]) == null ? void 0 : _b.call(slots)])]), (_c = slots["nav-bottom"]) == null ? void 0 : _c.call(slots)];
|
3355 | if (sticky) {
|
3356 | return vue.createVNode("div", {
|
3357 | "ref": wrapRef
|
3358 | }, [Header]);
|
3359 | }
|
3360 | return Header;
|
3361 | };
|
3362 | const resize = () => {
|
3363 | setLine();
|
3364 | vue.nextTick(() => {
|
3365 | var _a, _b;
|
3366 | scrollIntoView(true);
|
3367 | (_b = (_a = contentRef.value) == null ? void 0 : _a.swipeRef.value) == null ? void 0 : _b.resize();
|
3368 | });
|
3369 | };
|
3370 | vue.watch(() => [props2.color, props2.duration, props2.lineWidth, props2.lineHeight], setLine);
|
3371 | vue.watch(windowWidth, resize);
|
3372 | vue.watch(() => props2.active, (value) => {
|
3373 | if (value !== currentName.value) {
|
3374 | setCurrentIndexByName(value);
|
3375 | }
|
3376 | });
|
3377 | vue.watch(() => children.length, () => {
|
3378 | if (state.inited) {
|
3379 | setCurrentIndexByName(props2.active);
|
3380 | setLine();
|
3381 | vue.nextTick(() => {
|
3382 | scrollIntoView(true);
|
3383 | });
|
3384 | }
|
3385 | });
|
3386 | const init = () => {
|
3387 | setCurrentIndexByName(props2.active, true);
|
3388 | vue.nextTick(() => {
|
3389 | state.inited = true;
|
3390 | if (wrapRef.value) {
|
3391 | tabHeight = useRect(wrapRef.value).height;
|
3392 | }
|
3393 | scrollIntoView(true);
|
3394 | });
|
3395 | };
|
3396 | const onRendered = (name2, title) => emit("rendered", name2, title);
|
3397 | useExpose({
|
3398 | resize,
|
3399 | scrollTo
|
3400 | });
|
3401 | vue.onActivated(setLine);
|
3402 | onPopupReopen(setLine);
|
3403 | onMountedOrActivated(init);
|
3404 | useVisibilityChange(root, setLine);
|
3405 | useEventListener("scroll", onScroll, {
|
3406 | target: scroller,
|
3407 | passive: true
|
3408 | });
|
3409 | linkChildren({
|
3410 | id,
|
3411 | props: props2,
|
3412 | setLine,
|
3413 | scrollable,
|
3414 | onRendered,
|
3415 | currentName,
|
3416 | setTitleRefs,
|
3417 | scrollIntoView
|
3418 | });
|
3419 | return () => vue.createVNode("div", {
|
3420 | "ref": root,
|
3421 | "class": bem$1p([props2.type])
|
3422 | }, [props2.showHeader ? props2.sticky ? vue.createVNode(Sticky, {
|
3423 | "container": root.value,
|
3424 | "offsetTop": offsetTopPx.value,
|
3425 | "onScroll": onStickyScroll
|
3426 | }, {
|
3427 | default: () => [renderHeader()]
|
3428 | }) : renderHeader() : null, vue.createVNode(stdin_default$1E, {
|
3429 | "ref": contentRef,
|
3430 | "count": children.length,
|
3431 | "inited": state.inited,
|
3432 | "animated": props2.animated,
|
3433 | "duration": props2.duration,
|
3434 | "swipeable": props2.swipeable,
|
3435 | "lazyRender": props2.lazyRender,
|
3436 | "currentIndex": state.currentIndex,
|
3437 | "onChange": setCurrentIndex
|
3438 | }, {
|
3439 | default: () => {
|
3440 | var _a;
|
3441 | return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
|
3442 | }
|
3443 | })]);
|
3444 | }
|
3445 | });
|
3446 | const TAB_STATUS_KEY = Symbol();
|
3447 | const useTabStatus = () => vue.inject(TAB_STATUS_KEY, null);
|
3448 | const [name$1s, bem$1o] = createNamespace("tab");
|
3449 | const TabTitle = vue.defineComponent({
|
3450 | name: name$1s,
|
3451 | props: {
|
3452 | id: String,
|
3453 | dot: Boolean,
|
3454 | type: String,
|
3455 | color: String,
|
3456 | title: String,
|
3457 | badge: numericProp,
|
3458 | shrink: Boolean,
|
3459 | isActive: Boolean,
|
3460 | disabled: Boolean,
|
3461 | controls: String,
|
3462 | scrollable: Boolean,
|
3463 | activeColor: String,
|
3464 | inactiveColor: String,
|
3465 | showZeroBadge: truthProp
|
3466 | },
|
3467 | setup(props2, {
|
3468 | slots
|
3469 | }) {
|
3470 | const style = vue.computed(() => {
|
3471 | const style2 = {};
|
3472 | const {
|
3473 | type,
|
3474 | color,
|
3475 | disabled,
|
3476 | isActive,
|
3477 | activeColor,
|
3478 | inactiveColor
|
3479 | } = props2;
|
3480 | const isCard = type === "card";
|
3481 | if (color && isCard) {
|
3482 | style2.borderColor = color;
|
3483 | if (!disabled) {
|
3484 | if (isActive) {
|
3485 | style2.backgroundColor = color;
|
3486 | } else {
|
3487 | style2.color = color;
|
3488 | }
|
3489 | }
|
3490 | }
|
3491 | const titleColor = isActive ? activeColor : inactiveColor;
|
3492 | if (titleColor) {
|
3493 | style2.color = titleColor;
|
3494 | }
|
3495 | return style2;
|
3496 | });
|
3497 | const renderText = () => {
|
3498 | const Text = vue.createVNode("span", {
|
3499 | "class": bem$1o("text", {
|
3500 | ellipsis: !props2.scrollable
|
3501 | })
|
3502 | }, [slots.title ? slots.title() : props2.title]);
|
3503 | if (props2.dot || isDef(props2.badge) && props2.badge !== "") {
|
3504 | return vue.createVNode(Badge, {
|
3505 | "dot": props2.dot,
|
3506 | "content": props2.badge,
|
3507 | "showZero": props2.showZeroBadge
|
3508 | }, {
|
3509 | default: () => [Text]
|
3510 | });
|
3511 | }
|
3512 | return Text;
|
3513 | };
|
3514 | return () => vue.createVNode("div", {
|
3515 | "id": props2.id,
|
3516 | "role": "tab",
|
3517 | "class": [bem$1o([props2.type, {
|
3518 | grow: props2.scrollable && !props2.shrink,
|
3519 | shrink: props2.shrink,
|
3520 | active: props2.isActive,
|
3521 | disabled: props2.disabled
|
3522 | }])],
|
3523 | "style": style.value,
|
3524 | "tabindex": props2.disabled ? void 0 : props2.isActive ? 0 : -1,
|
3525 | "aria-selected": props2.isActive,
|
3526 | "aria-disabled": props2.disabled || void 0,
|
3527 | "aria-controls": props2.controls,
|
3528 | "data-allow-mismatch": "attribute"
|
3529 | }, [renderText()]);
|
3530 | }
|
3531 | });
|
3532 | const [name$1r, bem$1n] = createNamespace("swipe-item");
|
3533 | var stdin_default$1C = vue.defineComponent({
|
3534 | name: name$1r,
|
3535 | setup(props2, {
|
3536 | slots
|
3537 | }) {
|
3538 | let rendered;
|
3539 | const state = vue.reactive({
|
3540 | offset: 0,
|
3541 | inited: false,
|
3542 | mounted: false
|
3543 | });
|
3544 | const {
|
3545 | parent,
|
3546 | index
|
3547 | } = useParent(SWIPE_KEY);
|
3548 | if (!parent) {
|
3549 | return;
|
3550 | }
|
3551 | const style = vue.computed(() => {
|
3552 | const style2 = {};
|
3553 | const {
|
3554 | vertical
|
3555 | } = parent.props;
|
3556 | if (parent.size.value) {
|
3557 | style2[vertical ? "height" : "width"] = `${parent.size.value}px`;
|
3558 | }
|
3559 | if (state.offset) {
|
3560 | style2.transform = `translate${vertical ? "Y" : "X"}(${state.offset}px)`;
|
3561 | }
|
3562 | return style2;
|
3563 | });
|
3564 | const shouldRender = vue.computed(() => {
|
3565 | const {
|
3566 | loop,
|
3567 | lazyRender
|
3568 | } = parent.props;
|
3569 | if (!lazyRender || rendered) {
|
3570 | return true;
|
3571 | }
|
3572 | if (!state.mounted) {
|
3573 | return false;
|
3574 | }
|
3575 | const active = parent.activeIndicator.value;
|
3576 | const maxActive = parent.count.value - 1;
|
3577 | const prevActive = active === 0 && loop ? maxActive : active - 1;
|
3578 | const nextActive = active === maxActive && loop ? 0 : active + 1;
|
3579 | rendered = index.value === active || index.value === prevActive || index.value === nextActive;
|
3580 | return rendered;
|
3581 | });
|
3582 | const setOffset = (offset2) => {
|
3583 | state.offset = offset2;
|
3584 | };
|
3585 | vue.onMounted(() => {
|
3586 | vue.nextTick(() => {
|
3587 | state.mounted = true;
|
3588 | });
|
3589 | });
|
3590 | useExpose({
|
3591 | setOffset
|
3592 | });
|
3593 | return () => {
|
3594 | var _a;
|
3595 | return vue.createVNode("div", {
|
3596 | "class": bem$1n(),
|
3597 | "style": style.value
|
3598 | }, [shouldRender.value ? (_a = slots.default) == null ? void 0 : _a.call(slots) : null]);
|
3599 | };
|
3600 | }
|
3601 | });
|
3602 | const SwipeItem = withInstall(stdin_default$1C);
|
3603 | const [name$1q, bem$1m] = createNamespace("tab");
|
3604 | const tabProps = extend({}, routeProps, {
|
3605 | dot: Boolean,
|
3606 | name: numericProp,
|
3607 | badge: numericProp,
|
3608 | title: String,
|
3609 | disabled: Boolean,
|
3610 | titleClass: unknownProp,
|
3611 | titleStyle: [String, Object],
|
3612 | showZeroBadge: truthProp
|
3613 | });
|
3614 | var stdin_default$1B = vue.defineComponent({
|
3615 | name: name$1q,
|
3616 | props: tabProps,
|
3617 | setup(props2, {
|
3618 | slots
|
3619 | }) {
|
3620 | const id = useId();
|
3621 | const inited = vue.ref(false);
|
3622 | const instance2 = vue.getCurrentInstance();
|
3623 | const {
|
3624 | parent,
|
3625 | index
|
3626 | } = useParent(TABS_KEY);
|
3627 | if (!parent) {
|
3628 | return;
|
3629 | }
|
3630 | const getName = () => {
|
3631 | var _a;
|
3632 | return (_a = props2.name) != null ? _a : index.value;
|
3633 | };
|
3634 | const init = () => {
|
3635 | inited.value = true;
|
3636 | if (parent.props.lazyRender) {
|
3637 | vue.nextTick(() => {
|
3638 | parent.onRendered(getName(), props2.title);
|
3639 | });
|
3640 | }
|
3641 | };
|
3642 | const active = vue.computed(() => {
|
3643 | const isActive = getName() === parent.currentName.value;
|
3644 | if (isActive && !inited.value) {
|
3645 | init();
|
3646 | }
|
3647 | return isActive;
|
3648 | });
|
3649 | const parsedClass = vue.ref("");
|
3650 | const parsedStyle = vue.ref("");
|
3651 | vue.watchEffect(() => {
|
3652 | const {
|
3653 | titleClass,
|
3654 | titleStyle
|
3655 | } = props2;
|
3656 | parsedClass.value = titleClass ? normalizeClass(titleClass) : "";
|
3657 | parsedStyle.value = titleStyle && typeof titleStyle !== "string" ? stringifyStyle(normalizeStyle(titleStyle)) : titleStyle;
|
3658 | });
|
3659 | const renderTitle = (onClickTab) => vue.createVNode(TabTitle, vue.mergeProps({
|
3660 | "key": id,
|
3661 | "id": `${parent.id}-${index.value}`,
|
3662 | "ref": parent.setTitleRefs(index.value),
|
3663 | "style": parsedStyle.value,
|
3664 | "class": parsedClass.value,
|
3665 | "isActive": active.value,
|
3666 | "controls": id,
|
3667 | "scrollable": parent.scrollable.value,
|
3668 | "activeColor": parent.props.titleActiveColor,
|
3669 | "inactiveColor": parent.props.titleInactiveColor,
|
3670 | "onClick": (event) => onClickTab(instance2.proxy, index.value, event)
|
3671 | }, pick(parent.props, ["type", "color", "shrink"]), pick(props2, ["dot", "badge", "title", "disabled", "showZeroBadge"])), {
|
3672 | title: slots.title
|
3673 | });
|
3674 | const hasInactiveClass = vue.ref(!active.value);
|
3675 | vue.watch(active, (val) => {
|
3676 | if (val) {
|
3677 | hasInactiveClass.value = false;
|
3678 | } else {
|
3679 | doubleRaf(() => {
|
3680 | hasInactiveClass.value = true;
|
3681 | });
|
3682 | }
|
3683 | });
|
3684 | vue.watch(() => props2.title, () => {
|
3685 | parent.setLine();
|
3686 | parent.scrollIntoView();
|
3687 | });
|
3688 | vue.provide(TAB_STATUS_KEY, active);
|
3689 | useExpose({
|
3690 | id,
|
3691 | renderTitle
|
3692 | });
|
3693 | return () => {
|
3694 | var _a;
|
3695 | const label = `${parent.id}-${index.value}`;
|
3696 | const {
|
3697 | animated,
|
3698 | swipeable,
|
3699 | scrollspy,
|
3700 | lazyRender
|
3701 | } = parent.props;
|
3702 | if (!slots.default && !animated) {
|
3703 | return;
|
3704 | }
|
3705 | const show = scrollspy || active.value;
|
3706 | if (animated || swipeable) {
|
3707 | return vue.createVNode(SwipeItem, {
|
3708 | "id": id,
|
3709 | "role": "tabpanel",
|
3710 | "class": bem$1m("panel-wrapper", {
|
3711 | inactive: hasInactiveClass.value
|
3712 | }),
|
3713 | "tabindex": active.value ? 0 : -1,
|
3714 | "aria-hidden": !active.value,
|
3715 | "aria-labelledby": label,
|
3716 | "data-allow-mismatch": "attribute"
|
3717 | }, {
|
3718 | default: () => {
|
3719 | var _a2;
|
3720 | return [vue.createVNode("div", {
|
3721 | "class": bem$1m("panel")
|
3722 | }, [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)])];
|
3723 | }
|
3724 | });
|
3725 | }
|
3726 | const shouldRender = inited.value || scrollspy || !lazyRender;
|
3727 | const Content = shouldRender ? (_a = slots.default) == null ? void 0 : _a.call(slots) : null;
|
3728 | return vue.withDirectives(vue.createVNode("div", {
|
3729 | "id": id,
|
3730 | "role": "tabpanel",
|
3731 | "class": bem$1m("panel"),
|
3732 | "tabindex": show ? 0 : -1,
|
3733 | "aria-labelledby": label,
|
3734 | "data-allow-mismatch": "attribute"
|
3735 | }, [Content]), [[vue.vShow, show]]);
|
3736 | };
|
3737 | }
|
3738 | });
|
3739 | const Tab = withInstall(stdin_default$1B);
|
3740 | const Tabs = withInstall(stdin_default$1D);
|
3741 | const [name$1p, bem$1l] = createNamespace("picker-group");
|
3742 | const PICKER_GROUP_KEY = Symbol(name$1p);
|
3743 | const pickerGroupProps = extend({
|
3744 | tabs: makeArrayProp(),
|
3745 | activeTab: makeNumericProp(0),
|
3746 | nextStepText: String,
|
3747 | showToolbar: truthProp
|
3748 | }, pickerToolbarProps);
|
3749 | var stdin_default$1A = vue.defineComponent({
|
3750 | name: name$1p,
|
3751 | props: pickerGroupProps,
|
3752 | emits: ["confirm", "cancel", "update:activeTab"],
|
3753 | setup(props2, {
|
3754 | emit,
|
3755 | slots
|
3756 | }) {
|
3757 | const activeTab = useSyncPropRef(() => props2.activeTab, (value) => emit("update:activeTab", value));
|
3758 | const {
|
3759 | children,
|
3760 | linkChildren
|
3761 | } = useChildren(PICKER_GROUP_KEY);
|
3762 | linkChildren();
|
3763 | const showNextButton = () => +activeTab.value < props2.tabs.length - 1 && props2.nextStepText;
|
3764 | const onConfirm = () => {
|
3765 | if (showNextButton()) {
|
3766 | activeTab.value = +activeTab.value + 1;
|
3767 | } else {
|
3768 | emit("confirm", children.map((item) => item.confirm()));
|
3769 | }
|
3770 | };
|
3771 | const onCancel = () => emit("cancel");
|
3772 | return () => {
|
3773 | var _a, _b;
|
3774 | let childNodes = (_b = (_a = slots.default) == null ? void 0 : _a.call(slots)) == null ? void 0 : _b.filter((node) => node.type !== vue.Comment).map((node) => {
|
3775 | if (node.type === vue.Fragment) {
|
3776 | return node.children;
|
3777 | }
|
3778 | return node;
|
3779 | });
|
3780 | if (childNodes) {
|
3781 | childNodes = flat(childNodes);
|
3782 | }
|
3783 | const confirmButtonText = showNextButton() ? props2.nextStepText : props2.confirmButtonText;
|
3784 | return vue.createVNode("div", {
|
3785 | "class": bem$1l()
|
3786 | }, [props2.showToolbar ? vue.createVNode(stdin_default$1H, {
|
3787 | "title": props2.title,
|
3788 | "cancelButtonText": props2.cancelButtonText,
|
3789 | "confirmButtonText": confirmButtonText,
|
3790 | "onConfirm": onConfirm,
|
3791 | "onCancel": onCancel
|
3792 | }, pick(slots, pickerToolbarSlots)) : null, vue.createVNode(Tabs, {
|
3793 | "active": activeTab.value,
|
3794 | "onUpdate:active": ($event) => activeTab.value = $event,
|
3795 | "class": bem$1l("tabs"),
|
3796 | "shrink": true,
|
3797 | "animated": true,
|
3798 | "lazyRender": false
|
3799 | }, {
|
3800 | default: () => [props2.tabs.map((title, index) => vue.createVNode(Tab, {
|
3801 | "title": title,
|
3802 | "titleClass": bem$1l("tab-title")
|
3803 | }, {
|
3804 | default: () => [childNodes == null ? void 0 : childNodes[index]]
|
3805 | }))]
|
3806 | })]);
|
3807 | };
|
3808 | }
|
3809 | });
|
3810 | const pickerSharedProps = extend({
|
3811 | loading: Boolean,
|
3812 | readonly: Boolean,
|
3813 | allowHtml: Boolean,
|
3814 | optionHeight: makeNumericProp(44),
|
3815 | showToolbar: truthProp,
|
3816 | swipeDuration: makeNumericProp(1e3),
|
3817 | visibleOptionNum: makeNumericProp(6)
|
3818 | }, pickerToolbarProps);
|
3819 | const pickerProps = extend({}, pickerSharedProps, {
|
3820 | columns: makeArrayProp(),
|
3821 | modelValue: makeArrayProp(),
|
3822 | toolbarPosition: makeStringProp("top"),
|
3823 | columnsFieldNames: Object
|
3824 | });
|
3825 | var stdin_default$1z = vue.defineComponent({
|
3826 | name: name$1z,
|
3827 | props: pickerProps,
|
3828 | emits: ["confirm", "cancel", "change", "scrollInto", "clickOption", "update:modelValue"],
|
3829 | setup(props2, {
|
3830 | emit,
|
3831 | slots
|
3832 | }) {
|
3833 | const columnsRef = vue.ref();
|
3834 | const selectedValues = vue.ref(props2.modelValue.slice(0));
|
3835 | const {
|
3836 | parent
|
3837 | } = useParent(PICKER_GROUP_KEY);
|
3838 | const {
|
3839 | children,
|
3840 | linkChildren
|
3841 | } = useChildren(PICKER_KEY);
|
3842 | linkChildren();
|
3843 | const fields = vue.computed(() => assignDefaultFields(props2.columnsFieldNames));
|
3844 | const optionHeight = vue.computed(() => unitToPx(props2.optionHeight));
|
3845 | const columnsType = vue.computed(() => getColumnsType(props2.columns, fields.value));
|
3846 | const currentColumns = vue.computed(() => {
|
3847 | const {
|
3848 | columns
|
3849 | } = props2;
|
3850 | switch (columnsType.value) {
|
3851 | case "multiple":
|
3852 | return columns;
|
3853 | case "cascade":
|
3854 | return formatCascadeColumns(columns, fields.value, selectedValues);
|
3855 | default:
|
3856 | return [columns];
|
3857 | }
|
3858 | });
|
3859 | const hasOptions = vue.computed(() => currentColumns.value.some((options) => options.length));
|
3860 | const selectedOptions = vue.computed(() => currentColumns.value.map((options, index) => findOptionByValue(options, selectedValues.value[index], fields.value)));
|
3861 | const selectedIndexes = vue.computed(() => currentColumns.value.map((options, index) => options.findIndex((option) => option[fields.value.value] === selectedValues.value[index])));
|
3862 | const setValue = (index, value) => {
|
3863 | if (selectedValues.value[index] !== value) {
|
3864 | const newValues = selectedValues.value.slice(0);
|
3865 | newValues[index] = value;
|
3866 | selectedValues.value = newValues;
|
3867 | }
|
3868 | };
|
3869 | const getEventParams = () => ({
|
3870 | selectedValues: selectedValues.value.slice(0),
|
3871 | selectedOptions: selectedOptions.value,
|
3872 | selectedIndexes: selectedIndexes.value
|
3873 | });
|
3874 | const onChange = (value, columnIndex) => {
|
3875 | setValue(columnIndex, value);
|
3876 | if (columnsType.value === "cascade") {
|
3877 | selectedValues.value.forEach((value2, index) => {
|
3878 | const options = currentColumns.value[index];
|
3879 | if (!isOptionExist(options, value2, fields.value)) {
|
3880 | setValue(index, options.length ? options[0][fields.value.value] : void 0);
|
3881 | }
|
3882 | });
|
3883 | }
|
3884 | vue.nextTick(() => {
|
3885 | emit("change", extend({
|
3886 | columnIndex
|
3887 | }, getEventParams()));
|
3888 | });
|
3889 | };
|
3890 | const onClickOption = (currentOption, columnIndex) => {
|
3891 | const params = {
|
3892 | columnIndex,
|
3893 | currentOption
|
3894 | };
|
3895 | emit("clickOption", extend(getEventParams(), params));
|
3896 | emit("scrollInto", params);
|
3897 | };
|
3898 | const confirm = () => {
|
3899 | children.forEach((child) => child.stopMomentum());
|
3900 | const params = getEventParams();
|
3901 | vue.nextTick(() => {
|
3902 | emit("confirm", params);
|
3903 | });
|
3904 | return params;
|
3905 | };
|
3906 | const cancel = () => emit("cancel", getEventParams());
|
3907 | const renderColumnItems = () => currentColumns.value.map((options, columnIndex) => vue.createVNode(stdin_default$1I, {
|
3908 | "value": selectedValues.value[columnIndex],
|
3909 | "fields": fields.value,
|
3910 | "options": options,
|
3911 | "readonly": props2.readonly,
|
3912 | "allowHtml": props2.allowHtml,
|
3913 | "optionHeight": optionHeight.value,
|
3914 | "swipeDuration": props2.swipeDuration,
|
3915 | "visibleOptionNum": props2.visibleOptionNum,
|
3916 | "onChange": (value) => onChange(value, columnIndex),
|
3917 | "onClickOption": (option) => onClickOption(option, columnIndex),
|
3918 | "onScrollInto": (option) => {
|
3919 | emit("scrollInto", {
|
3920 | currentOption: option,
|
3921 | columnIndex
|
3922 | });
|
3923 | }
|
3924 | }, {
|
3925 | option: slots.option
|
3926 | }));
|
3927 | const renderMask = (wrapHeight) => {
|
3928 | if (hasOptions.value) {
|
3929 | const frameStyle = {
|
3930 | height: `${optionHeight.value}px`
|
3931 | };
|
3932 | const maskStyle = {
|
3933 | backgroundSize: `100% ${(wrapHeight - optionHeight.value) / 2}px`
|
3934 | };
|
3935 | return [vue.createVNode("div", {
|
3936 | "class": bem$1u("mask"),
|
3937 | "style": maskStyle
|
3938 | }, null), vue.createVNode("div", {
|
3939 | "class": [BORDER_UNSET_TOP_BOTTOM, bem$1u("frame")],
|
3940 | "style": frameStyle
|
3941 | }, null)];
|
3942 | }
|
3943 | };
|
3944 | const renderColumns = () => {
|
3945 | const wrapHeight = optionHeight.value * +props2.visibleOptionNum;
|
3946 | const columnsStyle = {
|
3947 | height: `${wrapHeight}px`
|
3948 | };
|
3949 | return vue.createVNode("div", {
|
3950 | "ref": columnsRef,
|
3951 | "class": bem$1u("columns"),
|
3952 | "style": columnsStyle
|
3953 | }, [renderColumnItems(), renderMask(wrapHeight)]);
|
3954 | };
|
3955 | const renderToolbar = () => {
|
3956 | if (props2.showToolbar && !parent) {
|
3957 | return vue.createVNode(stdin_default$1H, vue.mergeProps(pick(props2, pickerToolbarPropKeys), {
|
3958 | "onConfirm": confirm,
|
3959 | "onCancel": cancel
|
3960 | }), pick(slots, pickerToolbarSlots));
|
3961 | }
|
3962 | };
|
3963 | vue.watch(currentColumns, (columns) => {
|
3964 | columns.forEach((options, index) => {
|
3965 | if (options.length && !isOptionExist(options, selectedValues.value[index], fields.value)) {
|
3966 | setValue(index, getFirstEnabledOption(options)[fields.value.value]);
|
3967 | }
|
3968 | });
|
3969 | }, {
|
3970 | immediate: true
|
3971 | });
|
3972 | let lastEmittedModelValue;
|
3973 | vue.watch(() => props2.modelValue, (newValues) => {
|
3974 | if (!isSameValue(newValues, selectedValues.value) && !isSameValue(newValues, lastEmittedModelValue)) {
|
3975 | selectedValues.value = newValues.slice(0);
|
3976 | lastEmittedModelValue = newValues.slice(0);
|
3977 | }
|
3978 | }, {
|
3979 | deep: true
|
3980 | });
|
3981 | vue.watch(selectedValues, (newValues) => {
|
3982 | if (!isSameValue(newValues, props2.modelValue)) {
|
3983 | lastEmittedModelValue = newValues.slice(0);
|
3984 | emit("update:modelValue", lastEmittedModelValue);
|
3985 | }
|
3986 | }, {
|
3987 | immediate: true
|
3988 | });
|
3989 | useEventListener("touchmove", preventDefault, {
|
3990 | target: columnsRef
|
3991 | });
|
3992 | const getSelectedOptions = () => selectedOptions.value;
|
3993 | useExpose({
|
3994 | confirm,
|
3995 | getSelectedOptions
|
3996 | });
|
3997 | return () => {
|
3998 | var _a, _b;
|
3999 | return vue.createVNode("div", {
|
4000 | "class": bem$1u()
|
4001 | }, [props2.toolbarPosition === "top" ? renderToolbar() : null, props2.loading ? vue.createVNode(Loading, {
|
4002 | "class": bem$1u("loading")
|
4003 | }, null) : null, (_a = slots["columns-top"]) == null ? void 0 : _a.call(slots), renderColumns(), (_b = slots["columns-bottom"]) == null ? void 0 : _b.call(slots), props2.toolbarPosition === "bottom" ? renderToolbar() : null]);
|
4004 | };
|
4005 | }
|
4006 | });
|
4007 | const AREA_EMPTY_CODE = "000000";
|
4008 | const INHERIT_SLOTS = [
|
4009 | "title",
|
4010 | "cancel",
|
4011 | "confirm",
|
4012 | "toolbar",
|
4013 | "columns-top",
|
4014 | "columns-bottom"
|
4015 | ];
|
4016 | const INHERIT_PROPS = [
|
4017 | "title",
|
4018 | "loading",
|
4019 | "readonly",
|
4020 | "optionHeight",
|
4021 | "swipeDuration",
|
4022 | "visibleOptionNum",
|
4023 | "cancelButtonText",
|
4024 | "confirmButtonText"
|
4025 | ];
|
4026 | const makeOption = (text = "", value = AREA_EMPTY_CODE, children = void 0) => ({
|
4027 | text,
|
4028 | value,
|
4029 | children
|
4030 | });
|
4031 | function formatDataForCascade({
|
4032 | areaList,
|
4033 | columnsNum,
|
4034 | columnsPlaceholder: placeholder
|
4035 | }) {
|
4036 | const {
|
4037 | city_list: city = {},
|
4038 | county_list: county = {},
|
4039 | province_list: province = {}
|
4040 | } = areaList;
|
4041 | const showCity = +columnsNum > 1;
|
4042 | const showCounty = +columnsNum > 2;
|
4043 | const getProvinceChildren = () => {
|
4044 | if (showCity) {
|
4045 | return placeholder.length > 1 ? [
|
4046 | makeOption(
|
4047 | placeholder[1],
|
4048 | AREA_EMPTY_CODE,
|
4049 | showCounty ? [] : void 0
|
4050 | )
|
4051 | ] : [];
|
4052 | }
|
4053 | };
|
4054 | const provinceMap = new Map();
|
4055 | Object.keys(province).forEach((code) => {
|
4056 | provinceMap.set(
|
4057 | code.slice(0, 2),
|
4058 | makeOption(province[code], code, getProvinceChildren())
|
4059 | );
|
4060 | });
|
4061 | const cityMap = new Map();
|
4062 | if (showCity) {
|
4063 | const getCityChildren = () => {
|
4064 | if (showCounty) {
|
4065 | return placeholder.length > 2 ? [makeOption(placeholder[2])] : [];
|
4066 | }
|
4067 | };
|
4068 | Object.keys(city).forEach((code) => {
|
4069 | const option = makeOption(city[code], code, getCityChildren());
|
4070 | cityMap.set(code.slice(0, 4), option);
|
4071 | const province2 = provinceMap.get(code.slice(0, 2));
|
4072 | if (province2) {
|
4073 | province2.children.push(option);
|
4074 | }
|
4075 | });
|
4076 | }
|
4077 | if (showCounty) {
|
4078 | Object.keys(county).forEach((code) => {
|
4079 | const city2 = cityMap.get(code.slice(0, 4));
|
4080 | if (city2) {
|
4081 | city2.children.push(makeOption(county[code], code));
|
4082 | }
|
4083 | });
|
4084 | }
|
4085 | const options = Array.from(provinceMap.values());
|
4086 | if (placeholder.length) {
|
4087 | const county2 = showCounty ? [makeOption(placeholder[2])] : void 0;
|
4088 | const city2 = showCity ? [makeOption(placeholder[1], AREA_EMPTY_CODE, county2)] : void 0;
|
4089 | options.unshift(makeOption(placeholder[0], AREA_EMPTY_CODE, city2));
|
4090 | }
|
4091 | return options;
|
4092 | }
|
4093 | const Picker = withInstall(stdin_default$1z);
|
4094 | const [name$1o, bem$1k] = createNamespace("area");
|
4095 | const areaProps = extend({}, pick(pickerSharedProps, INHERIT_PROPS), {
|
4096 | modelValue: String,
|
4097 | columnsNum: makeNumericProp(3),
|
4098 | columnsPlaceholder: makeArrayProp(),
|
4099 | areaList: {
|
4100 | type: Object,
|
4101 | default: () => ({})
|
4102 | }
|
4103 | });
|
4104 | var stdin_default$1y = vue.defineComponent({
|
4105 | name: name$1o,
|
4106 | props: areaProps,
|
4107 | emits: ["change", "confirm", "cancel", "update:modelValue"],
|
4108 | setup(props2, {
|
4109 | emit,
|
4110 | slots
|
4111 | }) {
|
4112 | const codes = vue.ref([]);
|
4113 | const picker = vue.ref();
|
4114 | const columns = vue.computed(() => formatDataForCascade(props2));
|
4115 | const onChange = (...args) => emit("change", ...args);
|
4116 | const onCancel = (...args) => emit("cancel", ...args);
|
4117 | const onConfirm = (...args) => emit("confirm", ...args);
|
4118 | vue.watch(codes, (newCodes) => {
|
4119 | const lastCode = newCodes.length ? newCodes[newCodes.length - 1] : "";
|
4120 | if (lastCode && lastCode !== props2.modelValue) {
|
4121 | emit("update:modelValue", lastCode);
|
4122 | }
|
4123 | }, {
|
4124 | deep: true
|
4125 | });
|
4126 | vue.watch(() => props2.modelValue, (newCode) => {
|
4127 | if (newCode) {
|
4128 | const lastCode = codes.value.length ? codes.value[codes.value.length - 1] : "";
|
4129 | if (newCode !== lastCode) {
|
4130 | codes.value = [`${newCode.slice(0, 2)}0000`, `${newCode.slice(0, 4)}00`, newCode].slice(0, +props2.columnsNum);
|
4131 | }
|
4132 | } else {
|
4133 | codes.value = [];
|
4134 | }
|
4135 | }, {
|
4136 | immediate: true
|
4137 | });
|
4138 | useExpose({
|
4139 | confirm: () => {
|
4140 | var _a;
|
4141 | return (_a = picker.value) == null ? void 0 : _a.confirm();
|
4142 | },
|
4143 | getSelectedOptions: () => {
|
4144 | var _a;
|
4145 | return ((_a = picker.value) == null ? void 0 : _a.getSelectedOptions()) || [];
|
4146 | }
|
4147 | });
|
4148 | return () => vue.createVNode(Picker, vue.mergeProps({
|
4149 | "ref": picker,
|
4150 | "modelValue": codes.value,
|
4151 | "onUpdate:modelValue": ($event) => codes.value = $event,
|
4152 | "class": bem$1k(),
|
4153 | "columns": columns.value,
|
4154 | "onChange": onChange,
|
4155 | "onCancel": onCancel,
|
4156 | "onConfirm": onConfirm
|
4157 | }, pick(props2, INHERIT_PROPS)), pick(slots, INHERIT_SLOTS));
|
4158 | }
|
4159 | });
|
4160 | const Area = withInstall(stdin_default$1y);
|
4161 | const [name$1n, bem$1j] = createNamespace("cell");
|
4162 | const cellSharedProps = {
|
4163 | tag: makeStringProp("div"),
|
4164 | icon: String,
|
4165 | size: String,
|
4166 | title: numericProp,
|
4167 | value: numericProp,
|
4168 | label: numericProp,
|
4169 | center: Boolean,
|
4170 | isLink: Boolean,
|
4171 | border: truthProp,
|
4172 | iconPrefix: String,
|
4173 | valueClass: unknownProp,
|
4174 | labelClass: unknownProp,
|
4175 | titleClass: unknownProp,
|
4176 | titleStyle: null,
|
4177 | arrowDirection: String,
|
4178 | required: {
|
4179 | type: [Boolean, String],
|
4180 | default: null
|
4181 | },
|
4182 | clickable: {
|
4183 | type: Boolean,
|
4184 | default: null
|
4185 | }
|
4186 | };
|
4187 | const cellProps = extend({}, cellSharedProps, routeProps);
|
4188 | var stdin_default$1x = vue.defineComponent({
|
4189 | name: name$1n,
|
4190 | props: cellProps,
|
4191 | setup(props2, {
|
4192 | slots
|
4193 | }) {
|
4194 | const route2 = useRoute();
|
4195 | const renderLabel = () => {
|
4196 | const showLabel = slots.label || isDef(props2.label);
|
4197 | if (showLabel) {
|
4198 | return vue.createVNode("div", {
|
4199 | "class": [bem$1j("label"), props2.labelClass]
|
4200 | }, [slots.label ? slots.label() : props2.label]);
|
4201 | }
|
4202 | };
|
4203 | const renderTitle = () => {
|
4204 | var _a;
|
4205 | if (slots.title || isDef(props2.title)) {
|
4206 | const titleSlot = (_a = slots.title) == null ? void 0 : _a.call(slots);
|
4207 | if (Array.isArray(titleSlot) && titleSlot.length === 0) {
|
4208 | return;
|
4209 | }
|
4210 | return vue.createVNode("div", {
|
4211 | "class": [bem$1j("title"), props2.titleClass],
|
4212 | "style": props2.titleStyle
|
4213 | }, [titleSlot || vue.createVNode("span", null, [props2.title]), renderLabel()]);
|
4214 | }
|
4215 | };
|
4216 | const renderValue = () => {
|
4217 | const slot = slots.value || slots.default;
|
4218 | const hasValue = slot || isDef(props2.value);
|
4219 | if (hasValue) {
|
4220 | return vue.createVNode("div", {
|
4221 | "class": [bem$1j("value"), props2.valueClass]
|
4222 | }, [slot ? slot() : vue.createVNode("span", null, [props2.value])]);
|
4223 | }
|
4224 | };
|
4225 | const renderLeftIcon = () => {
|
4226 | if (slots.icon) {
|
4227 | return slots.icon();
|
4228 | }
|
4229 | if (props2.icon) {
|
4230 | return vue.createVNode(Icon, {
|
4231 | "name": props2.icon,
|
4232 | "class": bem$1j("left-icon"),
|
4233 | "classPrefix": props2.iconPrefix
|
4234 | }, null);
|
4235 | }
|
4236 | };
|
4237 | const renderRightIcon = () => {
|
4238 | if (slots["right-icon"]) {
|
4239 | return slots["right-icon"]();
|
4240 | }
|
4241 | if (props2.isLink) {
|
4242 | const name2 = props2.arrowDirection && props2.arrowDirection !== "right" ? `arrow-${props2.arrowDirection}` : "arrow";
|
4243 | return vue.createVNode(Icon, {
|
4244 | "name": name2,
|
4245 | "class": bem$1j("right-icon")
|
4246 | }, null);
|
4247 | }
|
4248 | };
|
4249 | return () => {
|
4250 | var _a;
|
4251 | const {
|
4252 | tag,
|
4253 | size,
|
4254 | center,
|
4255 | border,
|
4256 | isLink,
|
4257 | required
|
4258 | } = props2;
|
4259 | const clickable = (_a = props2.clickable) != null ? _a : isLink;
|
4260 | const classes = {
|
4261 | center,
|
4262 | required: !!required,
|
4263 | clickable,
|
4264 | borderless: !border
|
4265 | };
|
4266 | if (size) {
|
4267 | classes[size] = !!size;
|
4268 | }
|
4269 | return vue.createVNode(tag, {
|
4270 | "class": bem$1j(classes),
|
4271 | "role": clickable ? "button" : void 0,
|
4272 | "tabindex": clickable ? 0 : void 0,
|
4273 | "onClick": route2
|
4274 | }, {
|
4275 | default: () => {
|
4276 | var _a2;
|
4277 | return [renderLeftIcon(), renderTitle(), renderValue(), renderRightIcon(), (_a2 = slots.extra) == null ? void 0 : _a2.call(slots)];
|
4278 | }
|
4279 | });
|
4280 | };
|
4281 | }
|
4282 | });
|
4283 | const Cell = withInstall(stdin_default$1x);
|
4284 | const [name$1m, bem$1i] = createNamespace("form");
|
4285 | const formProps = {
|
4286 | colon: Boolean,
|
4287 | disabled: Boolean,
|
4288 | readonly: Boolean,
|
4289 | required: [Boolean, String],
|
4290 | showError: Boolean,
|
4291 | labelWidth: numericProp,
|
4292 | labelAlign: String,
|
4293 | inputAlign: String,
|
4294 | scrollToError: Boolean,
|
4295 | scrollToErrorPosition: String,
|
4296 | validateFirst: Boolean,
|
4297 | submitOnEnter: truthProp,
|
4298 | showErrorMessage: truthProp,
|
4299 | errorMessageAlign: String,
|
4300 | validateTrigger: {
|
4301 | type: [String, Array],
|
4302 | default: "onBlur"
|
4303 | }
|
4304 | };
|
4305 | var stdin_default$1w = vue.defineComponent({
|
4306 | name: name$1m,
|
4307 | props: formProps,
|
4308 | emits: ["submit", "failed"],
|
4309 | setup(props2, {
|
4310 | emit,
|
4311 | slots
|
4312 | }) {
|
4313 | const {
|
4314 | children,
|
4315 | linkChildren
|
4316 | } = useChildren(FORM_KEY);
|
4317 | const getFieldsByNames = (names) => {
|
4318 | if (names) {
|
4319 | return children.filter((field) => names.includes(field.name));
|
4320 | }
|
4321 | return children;
|
4322 | };
|
4323 | const validateSeq = (names) => new Promise((resolve, reject) => {
|
4324 | const errors = [];
|
4325 | const fields = getFieldsByNames(names);
|
4326 | fields.reduce((promise, field) => promise.then(() => {
|
4327 | if (!errors.length) {
|
4328 | return field.validate().then((error) => {
|
4329 | if (error) {
|
4330 | errors.push(error);
|
4331 | }
|
4332 | });
|
4333 | }
|
4334 | }), Promise.resolve()).then(() => {
|
4335 | if (errors.length) {
|
4336 | reject(errors);
|
4337 | } else {
|
4338 | resolve();
|
4339 | }
|
4340 | });
|
4341 | });
|
4342 | const validateAll = (names) => new Promise((resolve, reject) => {
|
4343 | const fields = getFieldsByNames(names);
|
4344 | Promise.all(fields.map((item) => item.validate())).then((errors) => {
|
4345 | errors = errors.filter(Boolean);
|
4346 | if (errors.length) {
|
4347 | reject(errors);
|
4348 | } else {
|
4349 | resolve();
|
4350 | }
|
4351 | });
|
4352 | });
|
4353 | const validateField = (name2) => {
|
4354 | const matched = children.find((item) => item.name === name2);
|
4355 | if (matched) {
|
4356 | return new Promise((resolve, reject) => {
|
4357 | matched.validate().then((error) => {
|
4358 | if (error) {
|
4359 | reject(error);
|
4360 | } else {
|
4361 | resolve();
|
4362 | }
|
4363 | });
|
4364 | });
|
4365 | }
|
4366 | return Promise.reject();
|
4367 | };
|
4368 | const validate = (name2) => {
|
4369 | if (typeof name2 === "string") {
|
4370 | return validateField(name2);
|
4371 | }
|
4372 | return props2.validateFirst ? validateSeq(name2) : validateAll(name2);
|
4373 | };
|
4374 | const resetValidation = (name2) => {
|
4375 | if (typeof name2 === "string") {
|
4376 | name2 = [name2];
|
4377 | }
|
4378 | const fields = getFieldsByNames(name2);
|
4379 | fields.forEach((item) => {
|
4380 | item.resetValidation();
|
4381 | });
|
4382 | };
|
4383 | const getValidationStatus = () => children.reduce((form, field) => {
|
4384 | form[field.name] = field.getValidationStatus();
|
4385 | return form;
|
4386 | }, {});
|
4387 | const scrollToField = (name2, options) => {
|
4388 | children.some((item) => {
|
4389 | if (item.name === name2) {
|
4390 | item.$el.scrollIntoView(options);
|
4391 | return true;
|
4392 | }
|
4393 | return false;
|
4394 | });
|
4395 | };
|
4396 | const getValues = () => children.reduce((form, field) => {
|
4397 | if (field.name !== void 0) {
|
4398 | form[field.name] = field.formValue.value;
|
4399 | }
|
4400 | return form;
|
4401 | }, {});
|
4402 | const submit = () => {
|
4403 | const values = getValues();
|
4404 | validate().then(() => emit("submit", values)).catch((errors) => {
|
4405 | emit("failed", {
|
4406 | values,
|
4407 | errors
|
4408 | });
|
4409 | const {
|
4410 | scrollToError,
|
4411 | scrollToErrorPosition
|
4412 | } = props2;
|
4413 | if (scrollToError && errors[0].name) {
|
4414 | scrollToField(errors[0].name, scrollToErrorPosition ? {
|
4415 | block: scrollToErrorPosition
|
4416 | } : void 0);
|
4417 | }
|
4418 | });
|
4419 | };
|
4420 | const onSubmit = (event) => {
|
4421 | preventDefault(event);
|
4422 | submit();
|
4423 | };
|
4424 | linkChildren({
|
4425 | props: props2
|
4426 | });
|
4427 | useExpose({
|
4428 | submit,
|
4429 | validate,
|
4430 | getValues,
|
4431 | scrollToField,
|
4432 | resetValidation,
|
4433 | getValidationStatus
|
4434 | });
|
4435 | return () => {
|
4436 | var _a;
|
4437 | return vue.createVNode("form", {
|
4438 | "class": bem$1i(),
|
4439 | "onSubmit": onSubmit
|
4440 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
4441 | };
|
4442 | }
|
4443 | });
|
4444 | const Form = withInstall(stdin_default$1w);
|
4445 | function isEmptyValue(value) {
|
4446 | if (Array.isArray(value)) {
|
4447 | return !value.length;
|
4448 | }
|
4449 | if (value === 0) {
|
4450 | return false;
|
4451 | }
|
4452 | return !value;
|
4453 | }
|
4454 | function runSyncRule(value, rule) {
|
4455 | if (isEmptyValue(value)) {
|
4456 | if (rule.required) {
|
4457 | return false;
|
4458 | }
|
4459 | if (rule.validateEmpty === false) {
|
4460 | return true;
|
4461 | }
|
4462 | }
|
4463 | if (rule.pattern && !rule.pattern.test(String(value))) {
|
4464 | return false;
|
4465 | }
|
4466 | return true;
|
4467 | }
|
4468 | function runRuleValidator(value, rule) {
|
4469 | return new Promise((resolve) => {
|
4470 | const returnVal = rule.validator(value, rule);
|
4471 | if (isPromise(returnVal)) {
|
4472 | returnVal.then(resolve);
|
4473 | return;
|
4474 | }
|
4475 | resolve(returnVal);
|
4476 | });
|
4477 | }
|
4478 | function getRuleMessage(value, rule) {
|
4479 | const { message } = rule;
|
4480 | if (isFunction(message)) {
|
4481 | return message(value, rule);
|
4482 | }
|
4483 | return message || "";
|
4484 | }
|
4485 | function startComposing({ target }) {
|
4486 | target.composing = true;
|
4487 | }
|
4488 | function endComposing({ target }) {
|
4489 | if (target.composing) {
|
4490 | target.composing = false;
|
4491 | target.dispatchEvent(new Event("input"));
|
4492 | }
|
4493 | }
|
4494 | function resizeTextarea(input, autosize) {
|
4495 | const scrollTop = getRootScrollTop();
|
4496 | input.style.height = "auto";
|
4497 | let height2 = input.scrollHeight;
|
4498 | if (isObject$1(autosize)) {
|
4499 | const { maxHeight, minHeight } = autosize;
|
4500 | if (maxHeight !== void 0) {
|
4501 | height2 = Math.min(height2, maxHeight);
|
4502 | }
|
4503 | if (minHeight !== void 0) {
|
4504 | height2 = Math.max(height2, minHeight);
|
4505 | }
|
4506 | }
|
4507 | if (height2) {
|
4508 | input.style.height = `${height2}px`;
|
4509 | setRootScrollTop(scrollTop);
|
4510 | }
|
4511 | }
|
4512 | function mapInputType(type) {
|
4513 | if (type === "number") {
|
4514 | return {
|
4515 | type: "text",
|
4516 | inputmode: "decimal"
|
4517 | };
|
4518 | }
|
4519 | if (type === "digit") {
|
4520 | return {
|
4521 | type: "tel",
|
4522 | inputmode: "numeric"
|
4523 | };
|
4524 | }
|
4525 | return { type };
|
4526 | }
|
4527 | function getStringLength(str) {
|
4528 | return [...str].length;
|
4529 | }
|
4530 | function cutString(str, maxlength) {
|
4531 | return [...str].slice(0, maxlength).join("");
|
4532 | }
|
4533 | const [name$1l, bem$1h] = createNamespace("field");
|
4534 | const fieldSharedProps = {
|
4535 | id: String,
|
4536 | name: String,
|
4537 | leftIcon: String,
|
4538 | rightIcon: String,
|
4539 | autofocus: Boolean,
|
4540 | clearable: Boolean,
|
4541 | maxlength: numericProp,
|
4542 | max: Number,
|
4543 | min: Number,
|
4544 | formatter: Function,
|
4545 | clearIcon: makeStringProp("clear"),
|
4546 | modelValue: makeNumericProp(""),
|
4547 | inputAlign: String,
|
4548 | placeholder: String,
|
4549 | autocomplete: String,
|
4550 | autocapitalize: String,
|
4551 | autocorrect: String,
|
4552 | errorMessage: String,
|
4553 | enterkeyhint: String,
|
4554 | clearTrigger: makeStringProp("focus"),
|
4555 | formatTrigger: makeStringProp("onChange"),
|
4556 | spellcheck: {
|
4557 | type: Boolean,
|
4558 | default: null
|
4559 | },
|
4560 | error: {
|
4561 | type: Boolean,
|
4562 | default: null
|
4563 | },
|
4564 | disabled: {
|
4565 | type: Boolean,
|
4566 | default: null
|
4567 | },
|
4568 | readonly: {
|
4569 | type: Boolean,
|
4570 | default: null
|
4571 | }
|
4572 | };
|
4573 | const fieldProps = extend({}, cellSharedProps, fieldSharedProps, {
|
4574 | rows: numericProp,
|
4575 | type: makeStringProp("text"),
|
4576 | rules: Array,
|
4577 | autosize: [Boolean, Object],
|
4578 | labelWidth: numericProp,
|
4579 | labelClass: unknownProp,
|
4580 | labelAlign: String,
|
4581 | showWordLimit: Boolean,
|
4582 | errorMessageAlign: String,
|
4583 | colon: {
|
4584 | type: Boolean,
|
4585 | default: null
|
4586 | }
|
4587 | });
|
4588 | var stdin_default$1v = vue.defineComponent({
|
4589 | name: name$1l,
|
4590 | props: fieldProps,
|
4591 | emits: ["blur", "focus", "clear", "keypress", "clickInput", "endValidate", "startValidate", "clickLeftIcon", "clickRightIcon", "update:modelValue"],
|
4592 | setup(props2, {
|
4593 | emit,
|
4594 | slots
|
4595 | }) {
|
4596 | const id = useId();
|
4597 | const state = vue.reactive({
|
4598 | status: "unvalidated",
|
4599 | focused: false,
|
4600 | validateMessage: ""
|
4601 | });
|
4602 | const inputRef = vue.ref();
|
4603 | const clearIconRef = vue.ref();
|
4604 | const customValue = vue.ref();
|
4605 | const {
|
4606 | parent: form
|
4607 | } = useParent(FORM_KEY);
|
4608 | const getModelValue = () => {
|
4609 | var _a;
|
4610 | return String((_a = props2.modelValue) != null ? _a : "");
|
4611 | };
|
4612 | const getProp = (key) => {
|
4613 | if (isDef(props2[key])) {
|
4614 | return props2[key];
|
4615 | }
|
4616 | if (form && isDef(form.props[key])) {
|
4617 | return form.props[key];
|
4618 | }
|
4619 | };
|
4620 | const showClear = vue.computed(() => {
|
4621 | const readonly = getProp("readonly");
|
4622 | if (props2.clearable && !readonly) {
|
4623 | const hasValue = getModelValue() !== "";
|
4624 | const trigger = props2.clearTrigger === "always" || props2.clearTrigger === "focus" && state.focused;
|
4625 | return hasValue && trigger;
|
4626 | }
|
4627 | return false;
|
4628 | });
|
4629 | const formValue = vue.computed(() => {
|
4630 | if (customValue.value && slots.input) {
|
4631 | return customValue.value();
|
4632 | }
|
4633 | return props2.modelValue;
|
4634 | });
|
4635 | const showRequiredMark = vue.computed(() => {
|
4636 | var _a;
|
4637 | const required = getProp("required");
|
4638 | if (required === "auto") {
|
4639 | return (_a = props2.rules) == null ? void 0 : _a.some((rule) => rule.required);
|
4640 | }
|
4641 | return required;
|
4642 | });
|
4643 | const runRules = (rules) => rules.reduce((promise, rule) => promise.then(() => {
|
4644 | if (state.status === "failed") {
|
4645 | return;
|
4646 | }
|
4647 | let {
|
4648 | value
|
4649 | } = formValue;
|
4650 | if (rule.formatter) {
|
4651 | value = rule.formatter(value, rule);
|
4652 | }
|
4653 | if (!runSyncRule(value, rule)) {
|
4654 | state.status = "failed";
|
4655 | state.validateMessage = getRuleMessage(value, rule);
|
4656 | return;
|
4657 | }
|
4658 | if (rule.validator) {
|
4659 | if (isEmptyValue(value) && rule.validateEmpty === false) {
|
4660 | return;
|
4661 | }
|
4662 | return runRuleValidator(value, rule).then((result) => {
|
4663 | if (result && typeof result === "string") {
|
4664 | state.status = "failed";
|
4665 | state.validateMessage = result;
|
4666 | } else if (result === false) {
|
4667 | state.status = "failed";
|
4668 | state.validateMessage = getRuleMessage(value, rule);
|
4669 | }
|
4670 | });
|
4671 | }
|
4672 | }), Promise.resolve());
|
4673 | const resetValidation = () => {
|
4674 | state.status = "unvalidated";
|
4675 | state.validateMessage = "";
|
4676 | };
|
4677 | const endValidate = () => emit("endValidate", {
|
4678 | status: state.status,
|
4679 | message: state.validateMessage
|
4680 | });
|
4681 | const validate = (rules = props2.rules) => new Promise((resolve) => {
|
4682 | resetValidation();
|
4683 | if (rules) {
|
4684 | emit("startValidate");
|
4685 | runRules(rules).then(() => {
|
4686 | if (state.status === "failed") {
|
4687 | resolve({
|
4688 | name: props2.name,
|
4689 | message: state.validateMessage
|
4690 | });
|
4691 | endValidate();
|
4692 | } else {
|
4693 | state.status = "passed";
|
4694 | resolve();
|
4695 | endValidate();
|
4696 | }
|
4697 | });
|
4698 | } else {
|
4699 | resolve();
|
4700 | }
|
4701 | });
|
4702 | const validateWithTrigger = (trigger) => {
|
4703 | if (form && props2.rules) {
|
4704 | const {
|
4705 | validateTrigger
|
4706 | } = form.props;
|
4707 | const defaultTrigger = toArray(validateTrigger).includes(trigger);
|
4708 | const rules = props2.rules.filter((rule) => {
|
4709 | if (rule.trigger) {
|
4710 | return toArray(rule.trigger).includes(trigger);
|
4711 | }
|
4712 | return defaultTrigger;
|
4713 | });
|
4714 | if (rules.length) {
|
4715 | validate(rules);
|
4716 | }
|
4717 | }
|
4718 | };
|
4719 | const limitValueLength = (value) => {
|
4720 | var _a;
|
4721 | const {
|
4722 | maxlength
|
4723 | } = props2;
|
4724 | if (isDef(maxlength) && getStringLength(value) > +maxlength) {
|
4725 | const modelValue = getModelValue();
|
4726 | if (modelValue && getStringLength(modelValue) === +maxlength) {
|
4727 | return modelValue;
|
4728 | }
|
4729 | const selectionEnd = (_a = inputRef.value) == null ? void 0 : _a.selectionEnd;
|
4730 | if (state.focused && selectionEnd) {
|
4731 | const valueArr = [...value];
|
4732 | const exceededLength = valueArr.length - +maxlength;
|
4733 | valueArr.splice(selectionEnd - exceededLength, exceededLength);
|
4734 | return valueArr.join("");
|
4735 | }
|
4736 | return cutString(value, +maxlength);
|
4737 | }
|
4738 | return value;
|
4739 | };
|
4740 | const updateValue = (value, trigger = "onChange") => {
|
4741 | var _a, _b;
|
4742 | const originalValue = value;
|
4743 | value = limitValueLength(value);
|
4744 | const limitDiffLen = getStringLength(originalValue) - getStringLength(value);
|
4745 | if (props2.type === "number" || props2.type === "digit") {
|
4746 | const isNumber = props2.type === "number";
|
4747 | value = formatNumber(value, isNumber, isNumber);
|
4748 | if (trigger === "onBlur" && value !== "" && (props2.min !== void 0 || props2.max !== void 0)) {
|
4749 | const adjustedValue = clamp(+value, (_a = props2.min) != null ? _a : -Infinity, (_b = props2.max) != null ? _b : Infinity);
|
4750 | value = adjustedValue.toString();
|
4751 | }
|
4752 | }
|
4753 | let formatterDiffLen = 0;
|
4754 | if (props2.formatter && trigger === props2.formatTrigger) {
|
4755 | const {
|
4756 | formatter,
|
4757 | maxlength
|
4758 | } = props2;
|
4759 | value = formatter(value);
|
4760 | if (isDef(maxlength) && getStringLength(value) > +maxlength) {
|
4761 | value = cutString(value, +maxlength);
|
4762 | }
|
4763 | if (inputRef.value && state.focused) {
|
4764 | const {
|
4765 | selectionEnd
|
4766 | } = inputRef.value;
|
4767 | const bcoVal = cutString(originalValue, selectionEnd);
|
4768 | formatterDiffLen = getStringLength(formatter(bcoVal)) - getStringLength(bcoVal);
|
4769 | }
|
4770 | }
|
4771 | if (inputRef.value && inputRef.value.value !== value) {
|
4772 | if (state.focused) {
|
4773 | let {
|
4774 | selectionStart,
|
4775 | selectionEnd
|
4776 | } = inputRef.value;
|
4777 | inputRef.value.value = value;
|
4778 | if (isDef(selectionStart) && isDef(selectionEnd)) {
|
4779 | const valueLen = getStringLength(value);
|
4780 | if (limitDiffLen) {
|
4781 | selectionStart -= limitDiffLen;
|
4782 | selectionEnd -= limitDiffLen;
|
4783 | } else if (formatterDiffLen) {
|
4784 | selectionStart += formatterDiffLen;
|
4785 | selectionEnd += formatterDiffLen;
|
4786 | }
|
4787 | inputRef.value.setSelectionRange(Math.min(selectionStart, valueLen), Math.min(selectionEnd, valueLen));
|
4788 | }
|
4789 | } else {
|
4790 | inputRef.value.value = value;
|
4791 | }
|
4792 | }
|
4793 | if (value !== props2.modelValue) {
|
4794 | emit("update:modelValue", value);
|
4795 | }
|
4796 | };
|
4797 | const onInput = (event) => {
|
4798 | if (!event.target.composing) {
|
4799 | updateValue(event.target.value);
|
4800 | }
|
4801 | };
|
4802 | const blur = () => {
|
4803 | var _a;
|
4804 | return (_a = inputRef.value) == null ? void 0 : _a.blur();
|
4805 | };
|
4806 | const focus = () => {
|
4807 | var _a;
|
4808 | return (_a = inputRef.value) == null ? void 0 : _a.focus();
|
4809 | };
|
4810 | const adjustTextareaSize = () => {
|
4811 | const input = inputRef.value;
|
4812 | if (props2.type === "textarea" && props2.autosize && input) {
|
4813 | resizeTextarea(input, props2.autosize);
|
4814 | }
|
4815 | };
|
4816 | const onFocus = (event) => {
|
4817 | state.focused = true;
|
4818 | emit("focus", event);
|
4819 | vue.nextTick(adjustTextareaSize);
|
4820 | if (getProp("readonly")) {
|
4821 | blur();
|
4822 | }
|
4823 | };
|
4824 | const onBlur = (event) => {
|
4825 | state.focused = false;
|
4826 | updateValue(getModelValue(), "onBlur");
|
4827 | emit("blur", event);
|
4828 | if (getProp("readonly")) {
|
4829 | return;
|
4830 | }
|
4831 | validateWithTrigger("onBlur");
|
4832 | vue.nextTick(adjustTextareaSize);
|
4833 | resetScroll();
|
4834 | };
|
4835 | const onClickInput = (event) => emit("clickInput", event);
|
4836 | const onClickLeftIcon = (event) => emit("clickLeftIcon", event);
|
4837 | const onClickRightIcon = (event) => emit("clickRightIcon", event);
|
4838 | const onClear = (event) => {
|
4839 | preventDefault(event);
|
4840 | emit("update:modelValue", "");
|
4841 | emit("clear", event);
|
4842 | };
|
4843 | const showError = vue.computed(() => {
|
4844 | if (typeof props2.error === "boolean") {
|
4845 | return props2.error;
|
4846 | }
|
4847 | if (form && form.props.showError && state.status === "failed") {
|
4848 | return true;
|
4849 | }
|
4850 | });
|
4851 | const labelStyle = vue.computed(() => {
|
4852 | const labelWidth = getProp("labelWidth");
|
4853 | const labelAlign = getProp("labelAlign");
|
4854 | if (labelWidth && labelAlign !== "top") {
|
4855 | return {
|
4856 | width: addUnit(labelWidth)
|
4857 | };
|
4858 | }
|
4859 | });
|
4860 | const onKeypress = (event) => {
|
4861 | const ENTER_CODE = 13;
|
4862 | if (event.keyCode === ENTER_CODE) {
|
4863 | const submitOnEnter = form && form.props.submitOnEnter;
|
4864 | if (!submitOnEnter && props2.type !== "textarea") {
|
4865 | preventDefault(event);
|
4866 | }
|
4867 | if (props2.type === "search") {
|
4868 | blur();
|
4869 | }
|
4870 | }
|
4871 | emit("keypress", event);
|
4872 | };
|
4873 | const getInputId = () => props2.id || `${id}-input`;
|
4874 | const getValidationStatus = () => state.status;
|
4875 | const renderInput = () => {
|
4876 | const controlClass = bem$1h("control", [getProp("inputAlign"), {
|
4877 | error: showError.value,
|
4878 | custom: !!slots.input,
|
4879 | "min-height": props2.type === "textarea" && !props2.autosize
|
4880 | }]);
|
4881 | if (slots.input) {
|
4882 | return vue.createVNode("div", {
|
4883 | "class": controlClass,
|
4884 | "onClick": onClickInput
|
4885 | }, [slots.input()]);
|
4886 | }
|
4887 | const inputAttrs = {
|
4888 | id: getInputId(),
|
4889 | ref: inputRef,
|
4890 | name: props2.name,
|
4891 | rows: props2.rows !== void 0 ? +props2.rows : void 0,
|
4892 | class: controlClass,
|
4893 | disabled: getProp("disabled"),
|
4894 | readonly: getProp("readonly"),
|
4895 | autofocus: props2.autofocus,
|
4896 | placeholder: props2.placeholder,
|
4897 | autocomplete: props2.autocomplete,
|
4898 | autocapitalize: props2.autocapitalize,
|
4899 | autocorrect: props2.autocorrect,
|
4900 | enterkeyhint: props2.enterkeyhint,
|
4901 | spellcheck: props2.spellcheck,
|
4902 | "aria-labelledby": props2.label ? `${id}-label` : void 0,
|
4903 | "data-allow-mismatch": "attribute",
|
4904 | onBlur,
|
4905 | onFocus,
|
4906 | onInput,
|
4907 | onClick: onClickInput,
|
4908 | onChange: endComposing,
|
4909 | onKeypress,
|
4910 | onCompositionend: endComposing,
|
4911 | onCompositionstart: startComposing
|
4912 | };
|
4913 | if (props2.type === "textarea") {
|
4914 | return vue.createVNode("textarea", inputAttrs, null);
|
4915 | }
|
4916 | return vue.createVNode("input", vue.mergeProps(mapInputType(props2.type), inputAttrs), null);
|
4917 | };
|
4918 | const renderLeftIcon = () => {
|
4919 | const leftIconSlot = slots["left-icon"];
|
4920 | if (props2.leftIcon || leftIconSlot) {
|
4921 | return vue.createVNode("div", {
|
4922 | "class": bem$1h("left-icon"),
|
4923 | "onClick": onClickLeftIcon
|
4924 | }, [leftIconSlot ? leftIconSlot() : vue.createVNode(Icon, {
|
4925 | "name": props2.leftIcon,
|
4926 | "classPrefix": props2.iconPrefix
|
4927 | }, null)]);
|
4928 | }
|
4929 | };
|
4930 | const renderRightIcon = () => {
|
4931 | const rightIconSlot = slots["right-icon"];
|
4932 | if (props2.rightIcon || rightIconSlot) {
|
4933 | return vue.createVNode("div", {
|
4934 | "class": bem$1h("right-icon"),
|
4935 | "onClick": onClickRightIcon
|
4936 | }, [rightIconSlot ? rightIconSlot() : vue.createVNode(Icon, {
|
4937 | "name": props2.rightIcon,
|
4938 | "classPrefix": props2.iconPrefix
|
4939 | }, null)]);
|
4940 | }
|
4941 | };
|
4942 | const renderWordLimit = () => {
|
4943 | if (props2.showWordLimit && props2.maxlength) {
|
4944 | const count = getStringLength(getModelValue());
|
4945 | return vue.createVNode("div", {
|
4946 | "class": bem$1h("word-limit")
|
4947 | }, [vue.createVNode("span", {
|
4948 | "class": bem$1h("word-num")
|
4949 | }, [count]), vue.createTextVNode("/"), props2.maxlength]);
|
4950 | }
|
4951 | };
|
4952 | const renderMessage = () => {
|
4953 | if (form && form.props.showErrorMessage === false) {
|
4954 | return;
|
4955 | }
|
4956 | const message = props2.errorMessage || state.validateMessage;
|
4957 | if (message) {
|
4958 | const slot = slots["error-message"];
|
4959 | const errorMessageAlign = getProp("errorMessageAlign");
|
4960 | return vue.createVNode("div", {
|
4961 | "class": bem$1h("error-message", errorMessageAlign)
|
4962 | }, [slot ? slot({
|
4963 | message
|
4964 | }) : message]);
|
4965 | }
|
4966 | };
|
4967 | const renderLabel = () => {
|
4968 | const labelWidth = getProp("labelWidth");
|
4969 | const labelAlign = getProp("labelAlign");
|
4970 | const colon = getProp("colon") ? ":" : "";
|
4971 | if (slots.label) {
|
4972 | return [slots.label(), colon];
|
4973 | }
|
4974 | if (props2.label) {
|
4975 | return vue.createVNode("label", {
|
4976 | "id": `${id}-label`,
|
4977 | "for": slots.input ? void 0 : getInputId(),
|
4978 | "data-allow-mismatch": "attribute",
|
4979 | "onClick": (event) => {
|
4980 | preventDefault(event);
|
4981 | focus();
|
4982 | },
|
4983 | "style": labelAlign === "top" && labelWidth ? {
|
4984 | width: addUnit(labelWidth)
|
4985 | } : void 0
|
4986 | }, [props2.label + colon]);
|
4987 | }
|
4988 | };
|
4989 | const renderFieldBody = () => [vue.createVNode("div", {
|
4990 | "class": bem$1h("body")
|
4991 | }, [renderInput(), showClear.value && vue.createVNode(Icon, {
|
4992 | "ref": clearIconRef,
|
4993 | "name": props2.clearIcon,
|
4994 | "class": bem$1h("clear")
|
4995 | }, null), renderRightIcon(), slots.button && vue.createVNode("div", {
|
4996 | "class": bem$1h("button")
|
4997 | }, [slots.button()])]), renderWordLimit(), renderMessage()];
|
4998 | useExpose({
|
4999 | blur,
|
5000 | focus,
|
5001 | validate,
|
5002 | formValue,
|
5003 | resetValidation,
|
5004 | getValidationStatus
|
5005 | });
|
5006 | vue.provide(CUSTOM_FIELD_INJECTION_KEY, {
|
5007 | customValue,
|
5008 | resetValidation,
|
5009 | validateWithTrigger
|
5010 | });
|
5011 | vue.watch(() => props2.modelValue, () => {
|
5012 | updateValue(getModelValue());
|
5013 | resetValidation();
|
5014 | validateWithTrigger("onChange");
|
5015 | vue.nextTick(adjustTextareaSize);
|
5016 | });
|
5017 | vue.onMounted(() => {
|
5018 | updateValue(getModelValue(), props2.formatTrigger);
|
5019 | vue.nextTick(adjustTextareaSize);
|
5020 | });
|
5021 | useEventListener("touchstart", onClear, {
|
5022 | target: vue.computed(() => {
|
5023 | var _a;
|
5024 | return (_a = clearIconRef.value) == null ? void 0 : _a.$el;
|
5025 | })
|
5026 | });
|
5027 | return () => {
|
5028 | const disabled = getProp("disabled");
|
5029 | const labelAlign = getProp("labelAlign");
|
5030 | const LeftIcon = renderLeftIcon();
|
5031 | const renderTitle = () => {
|
5032 | const Label = renderLabel();
|
5033 | if (labelAlign === "top") {
|
5034 | return [LeftIcon, Label].filter(Boolean);
|
5035 | }
|
5036 | return Label || [];
|
5037 | };
|
5038 | return vue.createVNode(Cell, {
|
5039 | "size": props2.size,
|
5040 | "class": bem$1h({
|
5041 | error: showError.value,
|
5042 | disabled,
|
5043 | [`label-${labelAlign}`]: labelAlign
|
5044 | }),
|
5045 | "center": props2.center,
|
5046 | "border": props2.border,
|
5047 | "isLink": props2.isLink,
|
5048 | "clickable": props2.clickable,
|
5049 | "titleStyle": labelStyle.value,
|
5050 | "valueClass": bem$1h("value"),
|
5051 | "titleClass": [bem$1h("label", [labelAlign, {
|
5052 | required: showRequiredMark.value
|
5053 | }]), props2.labelClass],
|
5054 | "arrowDirection": props2.arrowDirection
|
5055 | }, {
|
5056 | icon: LeftIcon && labelAlign !== "top" ? () => LeftIcon : null,
|
5057 | title: renderTitle,
|
5058 | value: renderFieldBody,
|
5059 | extra: slots.extra
|
5060 | });
|
5061 | };
|
5062 | }
|
5063 | });
|
5064 | const Field = withInstall(stdin_default$1v);
|
5065 | let lockCount = 0;
|
5066 | function lockClick(lock) {
|
5067 | if (lock) {
|
5068 | if (!lockCount) {
|
5069 | document.body.classList.add("van-toast--unclickable");
|
5070 | }
|
5071 | lockCount++;
|
5072 | } else if (lockCount) {
|
5073 | lockCount--;
|
5074 | if (!lockCount) {
|
5075 | document.body.classList.remove("van-toast--unclickable");
|
5076 | }
|
5077 | }
|
5078 | }
|
5079 | const [name$1k, bem$1g] = createNamespace("toast");
|
5080 | const popupInheritProps$1 = ["show", "overlay", "teleport", "transition", "overlayClass", "overlayStyle", "closeOnClickOverlay", "zIndex"];
|
5081 | const toastProps = {
|
5082 | icon: String,
|
5083 | show: Boolean,
|
5084 | type: makeStringProp("text"),
|
5085 | overlay: Boolean,
|
5086 | message: numericProp,
|
5087 | iconSize: numericProp,
|
5088 | duration: makeNumberProp(2e3),
|
5089 | position: makeStringProp("middle"),
|
5090 | teleport: [String, Object],
|
5091 | wordBreak: String,
|
5092 | className: unknownProp,
|
5093 | iconPrefix: String,
|
5094 | transition: makeStringProp("van-fade"),
|
5095 | loadingType: String,
|
5096 | forbidClick: Boolean,
|
5097 | overlayClass: unknownProp,
|
5098 | overlayStyle: Object,
|
5099 | closeOnClick: Boolean,
|
5100 | closeOnClickOverlay: Boolean,
|
5101 | zIndex: numericProp
|
5102 | };
|
5103 | var stdin_default$1u = vue.defineComponent({
|
5104 | name: name$1k,
|
5105 | props: toastProps,
|
5106 | emits: ["update:show"],
|
5107 | setup(props2, {
|
5108 | emit,
|
5109 | slots
|
5110 | }) {
|
5111 | let timer2;
|
5112 | let clickable = false;
|
5113 | const toggleClickable = () => {
|
5114 | const newValue = props2.show && props2.forbidClick;
|
5115 | if (clickable !== newValue) {
|
5116 | clickable = newValue;
|
5117 | lockClick(clickable);
|
5118 | }
|
5119 | };
|
5120 | const updateShow = (show) => emit("update:show", show);
|
5121 | const onClick = () => {
|
5122 | if (props2.closeOnClick) {
|
5123 | updateShow(false);
|
5124 | }
|
5125 | };
|
5126 | const clearTimer = () => clearTimeout(timer2);
|
5127 | const renderIcon = () => {
|
5128 | const {
|
5129 | icon,
|
5130 | type,
|
5131 | iconSize,
|
5132 | iconPrefix,
|
5133 | loadingType
|
5134 | } = props2;
|
5135 | const hasIcon = icon || type === "success" || type === "fail";
|
5136 | if (hasIcon) {
|
5137 | return vue.createVNode(Icon, {
|
5138 | "name": icon || type,
|
5139 | "size": iconSize,
|
5140 | "class": bem$1g("icon"),
|
5141 | "classPrefix": iconPrefix
|
5142 | }, null);
|
5143 | }
|
5144 | if (type === "loading") {
|
5145 | return vue.createVNode(Loading, {
|
5146 | "class": bem$1g("loading"),
|
5147 | "size": iconSize,
|
5148 | "type": loadingType
|
5149 | }, null);
|
5150 | }
|
5151 | };
|
5152 | const renderMessage = () => {
|
5153 | const {
|
5154 | type,
|
5155 | message
|
5156 | } = props2;
|
5157 | if (slots.message) {
|
5158 | return vue.createVNode("div", {
|
5159 | "class": bem$1g("text")
|
5160 | }, [slots.message()]);
|
5161 | }
|
5162 | if (isDef(message) && message !== "") {
|
5163 | return type === "html" ? vue.createVNode("div", {
|
5164 | "key": 0,
|
5165 | "class": bem$1g("text"),
|
5166 | "innerHTML": String(message)
|
5167 | }, null) : vue.createVNode("div", {
|
5168 | "class": bem$1g("text")
|
5169 | }, [message]);
|
5170 | }
|
5171 | };
|
5172 | vue.watch(() => [props2.show, props2.forbidClick], toggleClickable);
|
5173 | vue.watch(() => [props2.show, props2.type, props2.message, props2.duration], () => {
|
5174 | clearTimer();
|
5175 | if (props2.show && props2.duration > 0) {
|
5176 | timer2 = setTimeout(() => {
|
5177 | updateShow(false);
|
5178 | }, props2.duration);
|
5179 | }
|
5180 | });
|
5181 | vue.onMounted(toggleClickable);
|
5182 | vue.onUnmounted(toggleClickable);
|
5183 | return () => vue.createVNode(Popup, vue.mergeProps({
|
5184 | "class": [bem$1g([props2.position, props2.wordBreak === "normal" ? "break-normal" : props2.wordBreak, {
|
5185 | [props2.type]: !props2.icon
|
5186 | }]), props2.className],
|
5187 | "lockScroll": false,
|
5188 | "onClick": onClick,
|
5189 | "onClosed": clearTimer,
|
5190 | "onUpdate:show": updateShow
|
5191 | }, pick(props2, popupInheritProps$1)), {
|
5192 | default: () => [renderIcon(), renderMessage()]
|
5193 | });
|
5194 | }
|
5195 | });
|
5196 | function usePopupState() {
|
5197 | const state = vue.reactive({
|
5198 | show: false
|
5199 | });
|
5200 | const toggle = (show) => {
|
5201 | state.show = show;
|
5202 | };
|
5203 | const open = (props2) => {
|
5204 | extend(state, props2, { transitionAppear: true });
|
5205 | toggle(true);
|
5206 | };
|
5207 | const close = () => toggle(false);
|
5208 | useExpose({ open, close, toggle });
|
5209 | return {
|
5210 | open,
|
5211 | close,
|
5212 | state,
|
5213 | toggle
|
5214 | };
|
5215 | }
|
5216 | function mountComponent(RootComponent) {
|
5217 | const app = vue.createApp(RootComponent);
|
5218 | const root = document.createElement("div");
|
5219 | document.body.appendChild(root);
|
5220 | return {
|
5221 | instance: app.mount(root),
|
5222 | unmount() {
|
5223 | app.unmount();
|
5224 | document.body.removeChild(root);
|
5225 | }
|
5226 | };
|
5227 | }
|
5228 | const defaultOptions$1 = {
|
5229 | icon: "",
|
5230 | type: "text",
|
5231 | message: "",
|
5232 | className: "",
|
5233 | overlay: false,
|
5234 | onClose: void 0,
|
5235 | onOpened: void 0,
|
5236 | duration: 2e3,
|
5237 | teleport: "body",
|
5238 | iconSize: void 0,
|
5239 | iconPrefix: void 0,
|
5240 | position: "middle",
|
5241 | transition: "van-fade",
|
5242 | forbidClick: false,
|
5243 | loadingType: void 0,
|
5244 | overlayClass: "",
|
5245 | overlayStyle: void 0,
|
5246 | closeOnClick: false,
|
5247 | closeOnClickOverlay: false
|
5248 | };
|
5249 | let queue = [];
|
5250 | let allowMultiple = false;
|
5251 | let currentOptions$2 = extend({}, defaultOptions$1);
|
5252 | const defaultOptionsMap = new Map();
|
5253 | function parseOptions$1(message) {
|
5254 | if (isObject$1(message)) {
|
5255 | return message;
|
5256 | }
|
5257 | return {
|
5258 | message
|
5259 | };
|
5260 | }
|
5261 | function createInstance() {
|
5262 | const {
|
5263 | instance: instance2,
|
5264 | unmount
|
5265 | } = mountComponent({
|
5266 | setup() {
|
5267 | const message = vue.ref("");
|
5268 | const {
|
5269 | open,
|
5270 | state,
|
5271 | close,
|
5272 | toggle
|
5273 | } = usePopupState();
|
5274 | const onClosed = () => {
|
5275 | if (allowMultiple) {
|
5276 | queue = queue.filter((item) => item !== instance2);
|
5277 | unmount();
|
5278 | }
|
5279 | };
|
5280 | const render = () => {
|
5281 | const attrs = {
|
5282 | onClosed,
|
5283 | "onUpdate:show": toggle
|
5284 | };
|
5285 | return vue.createVNode(stdin_default$1u, vue.mergeProps(state, attrs), null);
|
5286 | };
|
5287 | vue.watch(message, (val) => {
|
5288 | state.message = val;
|
5289 | });
|
5290 | vue.getCurrentInstance().render = render;
|
5291 | return {
|
5292 | open,
|
5293 | close,
|
5294 | message
|
5295 | };
|
5296 | }
|
5297 | });
|
5298 | return instance2;
|
5299 | }
|
5300 | function getInstance() {
|
5301 | if (!queue.length || allowMultiple) {
|
5302 | const instance2 = createInstance();
|
5303 | queue.push(instance2);
|
5304 | }
|
5305 | return queue[queue.length - 1];
|
5306 | }
|
5307 | function showToast(options = {}) {
|
5308 | if (!inBrowser$1) {
|
5309 | return {};
|
5310 | }
|
5311 | const toast = getInstance();
|
5312 | const parsedOptions = parseOptions$1(options);
|
5313 | toast.open(extend({}, currentOptions$2, defaultOptionsMap.get(parsedOptions.type || currentOptions$2.type), parsedOptions));
|
5314 | return toast;
|
5315 | }
|
5316 | const createMethod = (type) => (options) => showToast(extend({
|
5317 | type
|
5318 | }, parseOptions$1(options)));
|
5319 | const showLoadingToast = createMethod("loading");
|
5320 | const showSuccessToast = createMethod("success");
|
5321 | const showFailToast = createMethod("fail");
|
5322 | const closeToast = (all) => {
|
5323 | var _a;
|
5324 | if (queue.length) {
|
5325 | if (all) {
|
5326 | queue.forEach((toast) => {
|
5327 | toast.close();
|
5328 | });
|
5329 | queue = [];
|
5330 | } else if (!allowMultiple) {
|
5331 | queue[0].close();
|
5332 | } else {
|
5333 | (_a = queue.shift()) == null ? void 0 : _a.close();
|
5334 | }
|
5335 | }
|
5336 | };
|
5337 | function setToastDefaultOptions(type, options) {
|
5338 | if (typeof type === "string") {
|
5339 | defaultOptionsMap.set(type, options);
|
5340 | } else {
|
5341 | extend(currentOptions$2, type);
|
5342 | }
|
5343 | }
|
5344 | const resetToastDefaultOptions = (type) => {
|
5345 | if (typeof type === "string") {
|
5346 | defaultOptionsMap.delete(type);
|
5347 | } else {
|
5348 | currentOptions$2 = extend({}, defaultOptions$1);
|
5349 | defaultOptionsMap.clear();
|
5350 | }
|
5351 | };
|
5352 | const allowMultipleToast = (value = true) => {
|
5353 | allowMultiple = value;
|
5354 | };
|
5355 | const Toast = withInstall(stdin_default$1u);
|
5356 | const [name$1j, bem$1f] = createNamespace("switch");
|
5357 | const switchProps = {
|
5358 | size: numericProp,
|
5359 | loading: Boolean,
|
5360 | disabled: Boolean,
|
5361 | modelValue: unknownProp,
|
5362 | activeColor: String,
|
5363 | inactiveColor: String,
|
5364 | activeValue: {
|
5365 | type: unknownProp,
|
5366 | default: true
|
5367 | },
|
5368 | inactiveValue: {
|
5369 | type: unknownProp,
|
5370 | default: false
|
5371 | }
|
5372 | };
|
5373 | var stdin_default$1t = vue.defineComponent({
|
5374 | name: name$1j,
|
5375 | props: switchProps,
|
5376 | emits: ["change", "update:modelValue"],
|
5377 | setup(props2, {
|
5378 | emit,
|
5379 | slots
|
5380 | }) {
|
5381 | const isChecked = () => props2.modelValue === props2.activeValue;
|
5382 | const onClick = () => {
|
5383 | if (!props2.disabled && !props2.loading) {
|
5384 | const newValue = isChecked() ? props2.inactiveValue : props2.activeValue;
|
5385 | emit("update:modelValue", newValue);
|
5386 | emit("change", newValue);
|
5387 | }
|
5388 | };
|
5389 | const renderLoading = () => {
|
5390 | if (props2.loading) {
|
5391 | const color = isChecked() ? props2.activeColor : props2.inactiveColor;
|
5392 | return vue.createVNode(Loading, {
|
5393 | "class": bem$1f("loading"),
|
5394 | "color": color
|
5395 | }, null);
|
5396 | }
|
5397 | if (slots.node) {
|
5398 | return slots.node();
|
5399 | }
|
5400 | };
|
5401 | useCustomFieldValue(() => props2.modelValue);
|
5402 | return () => {
|
5403 | var _a;
|
5404 | const {
|
5405 | size,
|
5406 | loading,
|
5407 | disabled,
|
5408 | activeColor,
|
5409 | inactiveColor
|
5410 | } = props2;
|
5411 | const checked = isChecked();
|
5412 | const style = {
|
5413 | fontSize: addUnit(size),
|
5414 | backgroundColor: checked ? activeColor : inactiveColor
|
5415 | };
|
5416 | return vue.createVNode("div", {
|
5417 | "role": "switch",
|
5418 | "class": bem$1f({
|
5419 | on: checked,
|
5420 | loading,
|
5421 | disabled
|
5422 | }),
|
5423 | "style": style,
|
5424 | "tabindex": disabled ? void 0 : 0,
|
5425 | "aria-checked": checked,
|
5426 | "onClick": onClick
|
5427 | }, [vue.createVNode("div", {
|
5428 | "class": bem$1f("node")
|
5429 | }, [renderLoading()]), (_a = slots.background) == null ? void 0 : _a.call(slots)]);
|
5430 | };
|
5431 | }
|
5432 | });
|
5433 | const Switch = withInstall(stdin_default$1t);
|
5434 | const [name$1i, bem$1e] = createNamespace("address-edit-detail");
|
5435 | const t$j = createNamespace("address-edit")[2];
|
5436 | var stdin_default$1s = vue.defineComponent({
|
5437 | name: name$1i,
|
5438 | props: {
|
5439 | show: Boolean,
|
5440 | rows: numericProp,
|
5441 | value: String,
|
5442 | rules: Array,
|
5443 | focused: Boolean,
|
5444 | maxlength: numericProp,
|
5445 | searchResult: Array,
|
5446 | showSearchResult: Boolean
|
5447 | },
|
5448 | emits: ["blur", "focus", "input", "selectSearch"],
|
5449 | setup(props2, {
|
5450 | emit
|
5451 | }) {
|
5452 | const field = vue.ref();
|
5453 | const showSearchResult = () => props2.focused && props2.searchResult && props2.showSearchResult;
|
5454 | const onSelect = (express) => {
|
5455 | emit("selectSearch", express);
|
5456 | emit("input", `${express.address || ""} ${express.name || ""}`.trim());
|
5457 | };
|
5458 | const renderSearchResult = () => {
|
5459 | if (!showSearchResult()) {
|
5460 | return;
|
5461 | }
|
5462 | const {
|
5463 | searchResult
|
5464 | } = props2;
|
5465 | return searchResult.map((express) => vue.createVNode(Cell, {
|
5466 | "clickable": true,
|
5467 | "key": (express.name || "") + (express.address || ""),
|
5468 | "icon": "location-o",
|
5469 | "title": express.name,
|
5470 | "label": express.address,
|
5471 | "class": bem$1e("search-item"),
|
5472 | "border": false,
|
5473 | "onClick": () => onSelect(express)
|
5474 | }, null));
|
5475 | };
|
5476 | const onBlur = (event) => emit("blur", event);
|
5477 | const onFocus = (event) => emit("focus", event);
|
5478 | const onInput = (value) => emit("input", value);
|
5479 | return () => {
|
5480 | if (props2.show) {
|
5481 | return vue.createVNode(vue.Fragment, null, [vue.createVNode(Field, {
|
5482 | "autosize": true,
|
5483 | "clearable": true,
|
5484 | "ref": field,
|
5485 | "class": bem$1e(),
|
5486 | "rows": props2.rows,
|
5487 | "type": "textarea",
|
5488 | "rules": props2.rules,
|
5489 | "label": t$j("addressDetail"),
|
5490 | "border": !showSearchResult(),
|
5491 | "maxlength": props2.maxlength,
|
5492 | "modelValue": props2.value,
|
5493 | "placeholder": t$j("addressDetail"),
|
5494 | "onBlur": onBlur,
|
5495 | "onFocus": onFocus,
|
5496 | "onUpdate:modelValue": onInput
|
5497 | }, null), renderSearchResult()]);
|
5498 | }
|
5499 | };
|
5500 | }
|
5501 | });
|
5502 | const [name$1h, bem$1d, t$i] = createNamespace("address-edit");
|
5503 | const DEFAULT_DATA = {
|
5504 | name: "",
|
5505 | tel: "",
|
5506 | city: "",
|
5507 | county: "",
|
5508 | country: "",
|
5509 | province: "",
|
5510 | areaCode: "",
|
5511 | isDefault: false,
|
5512 | addressDetail: ""
|
5513 | };
|
5514 | const addressEditProps = {
|
5515 | areaList: Object,
|
5516 | isSaving: Boolean,
|
5517 | isDeleting: Boolean,
|
5518 | validator: Function,
|
5519 | showArea: truthProp,
|
5520 | showDetail: truthProp,
|
5521 | showDelete: Boolean,
|
5522 | disableArea: Boolean,
|
5523 | searchResult: Array,
|
5524 | telMaxlength: numericProp,
|
5525 | showSetDefault: Boolean,
|
5526 | saveButtonText: String,
|
5527 | areaPlaceholder: String,
|
5528 | deleteButtonText: String,
|
5529 | showSearchResult: Boolean,
|
5530 | detailRows: makeNumericProp(1),
|
5531 | detailMaxlength: makeNumericProp(200),
|
5532 | areaColumnsPlaceholder: makeArrayProp(),
|
5533 | addressInfo: {
|
5534 | type: Object,
|
5535 | default: () => extend({}, DEFAULT_DATA)
|
5536 | },
|
5537 | telValidator: {
|
5538 | type: Function,
|
5539 | default: isMobile
|
5540 | }
|
5541 | };
|
5542 | var stdin_default$1r = vue.defineComponent({
|
5543 | name: name$1h,
|
5544 | props: addressEditProps,
|
5545 | emits: ["save", "focus", "change", "delete", "clickArea", "changeArea", "changeDetail", "selectSearch", "changeDefault"],
|
5546 | setup(props2, {
|
5547 | emit,
|
5548 | slots
|
5549 | }) {
|
5550 | const areaRef = vue.ref();
|
5551 | const data = vue.reactive({});
|
5552 | const showAreaPopup = vue.ref(false);
|
5553 | const detailFocused = vue.ref(false);
|
5554 | const areaListLoaded = vue.computed(() => isObject$1(props2.areaList) && Object.keys(props2.areaList).length);
|
5555 | const areaText = vue.computed(() => {
|
5556 | const {
|
5557 | province,
|
5558 | city,
|
5559 | county,
|
5560 | areaCode
|
5561 | } = data;
|
5562 | if (areaCode) {
|
5563 | const arr = [province, city, county];
|
5564 | if (province && province === city) {
|
5565 | arr.splice(1, 1);
|
5566 | }
|
5567 | return arr.filter(Boolean).join("/");
|
5568 | }
|
5569 | return "";
|
5570 | });
|
5571 | const hideBottomFields = vue.computed(() => {
|
5572 | var _a;
|
5573 | return ((_a = props2.searchResult) == null ? void 0 : _a.length) && detailFocused.value;
|
5574 | });
|
5575 | const onFocus = (key) => {
|
5576 | detailFocused.value = key === "addressDetail";
|
5577 | emit("focus", key);
|
5578 | };
|
5579 | const onChange = (key, value) => {
|
5580 | emit("change", {
|
5581 | key,
|
5582 | value
|
5583 | });
|
5584 | };
|
5585 | const rules = vue.computed(() => {
|
5586 | const {
|
5587 | validator,
|
5588 | telValidator
|
5589 | } = props2;
|
5590 | const makeRule = (name2, emptyMessage) => ({
|
5591 | validator: (value) => {
|
5592 | if (validator) {
|
5593 | const message = validator(name2, value);
|
5594 | if (message) {
|
5595 | return message;
|
5596 | }
|
5597 | }
|
5598 | if (!value) {
|
5599 | return emptyMessage;
|
5600 | }
|
5601 | return true;
|
5602 | }
|
5603 | });
|
5604 | return {
|
5605 | name: [makeRule("name", t$i("nameEmpty"))],
|
5606 | tel: [makeRule("tel", t$i("telInvalid")), {
|
5607 | validator: telValidator,
|
5608 | message: t$i("telInvalid")
|
5609 | }],
|
5610 | areaCode: [makeRule("areaCode", t$i("areaEmpty"))],
|
5611 | addressDetail: [makeRule("addressDetail", t$i("addressEmpty"))]
|
5612 | };
|
5613 | });
|
5614 | const onSave = () => emit("save", data);
|
5615 | const onChangeDetail = (val) => {
|
5616 | data.addressDetail = val;
|
5617 | emit("changeDetail", val);
|
5618 | };
|
5619 | const assignAreaText = (options) => {
|
5620 | data.province = options[0].text;
|
5621 | data.city = options[1].text;
|
5622 | data.county = options[2].text;
|
5623 | };
|
5624 | const onAreaConfirm = ({
|
5625 | selectedValues,
|
5626 | selectedOptions
|
5627 | }) => {
|
5628 | if (selectedValues.some((value) => value === AREA_EMPTY_CODE)) {
|
5629 | showToast(t$i("areaEmpty"));
|
5630 | } else {
|
5631 | showAreaPopup.value = false;
|
5632 | assignAreaText(selectedOptions);
|
5633 | emit("changeArea", selectedOptions);
|
5634 | }
|
5635 | };
|
5636 | const onDelete = () => emit("delete", data);
|
5637 | const setAreaCode = (code) => {
|
5638 | data.areaCode = code || "";
|
5639 | };
|
5640 | const onDetailBlur = () => {
|
5641 | setTimeout(() => {
|
5642 | detailFocused.value = false;
|
5643 | });
|
5644 | };
|
5645 | const setAddressDetail = (value) => {
|
5646 | data.addressDetail = value;
|
5647 | };
|
5648 | const renderSetDefaultCell = () => {
|
5649 | if (props2.showSetDefault) {
|
5650 | const slots2 = {
|
5651 | "right-icon": () => vue.createVNode(Switch, {
|
5652 | "modelValue": data.isDefault,
|
5653 | "onUpdate:modelValue": ($event) => data.isDefault = $event,
|
5654 | "onChange": (event) => emit("changeDefault", event)
|
5655 | }, null)
|
5656 | };
|
5657 | return vue.withDirectives(vue.createVNode(Cell, {
|
5658 | "center": true,
|
5659 | "border": false,
|
5660 | "title": t$i("defaultAddress"),
|
5661 | "class": bem$1d("default")
|
5662 | }, slots2), [[vue.vShow, !hideBottomFields.value]]);
|
5663 | }
|
5664 | };
|
5665 | useExpose({
|
5666 | setAreaCode,
|
5667 | setAddressDetail
|
5668 | });
|
5669 | vue.watch(() => props2.addressInfo, (value) => {
|
5670 | extend(data, DEFAULT_DATA, value);
|
5671 | vue.nextTick(() => {
|
5672 | var _a;
|
5673 | const options = (_a = areaRef.value) == null ? void 0 : _a.getSelectedOptions();
|
5674 | if (options && options.every((option) => option && option.value !== AREA_EMPTY_CODE)) {
|
5675 | assignAreaText(options);
|
5676 | }
|
5677 | });
|
5678 | }, {
|
5679 | deep: true,
|
5680 | immediate: true
|
5681 | });
|
5682 | return () => {
|
5683 | const {
|
5684 | disableArea
|
5685 | } = props2;
|
5686 | return vue.createVNode(Form, {
|
5687 | "class": bem$1d(),
|
5688 | "onSubmit": onSave
|
5689 | }, {
|
5690 | default: () => {
|
5691 | var _a;
|
5692 | return [vue.createVNode("div", {
|
5693 | "class": bem$1d("fields")
|
5694 | }, [vue.createVNode(Field, {
|
5695 | "modelValue": data.name,
|
5696 | "onUpdate:modelValue": [($event) => data.name = $event, (val) => onChange("name", val)],
|
5697 | "clearable": true,
|
5698 | "label": t$i("name"),
|
5699 | "rules": rules.value.name,
|
5700 | "placeholder": t$i("name"),
|
5701 | "onFocus": () => onFocus("name")
|
5702 | }, null), vue.createVNode(Field, {
|
5703 | "modelValue": data.tel,
|
5704 | "onUpdate:modelValue": [($event) => data.tel = $event, (val) => onChange("tel", val)],
|
5705 | "clearable": true,
|
5706 | "type": "tel",
|
5707 | "label": t$i("tel"),
|
5708 | "rules": rules.value.tel,
|
5709 | "maxlength": props2.telMaxlength,
|
5710 | "placeholder": t$i("tel"),
|
5711 | "onFocus": () => onFocus("tel")
|
5712 | }, null), vue.withDirectives(vue.createVNode(Field, {
|
5713 | "readonly": true,
|
5714 | "label": t$i("area"),
|
5715 | "is-link": !disableArea,
|
5716 | "modelValue": areaText.value,
|
5717 | "rules": props2.showArea ? rules.value.areaCode : void 0,
|
5718 | "placeholder": props2.areaPlaceholder || t$i("area"),
|
5719 | "onFocus": () => onFocus("areaCode"),
|
5720 | "onClick": () => {
|
5721 | emit("clickArea");
|
5722 | showAreaPopup.value = !disableArea;
|
5723 | }
|
5724 | }, null), [[vue.vShow, props2.showArea]]), vue.createVNode(stdin_default$1s, {
|
5725 | "show": props2.showDetail,
|
5726 | "rows": props2.detailRows,
|
5727 | "rules": rules.value.addressDetail,
|
5728 | "value": data.addressDetail,
|
5729 | "focused": detailFocused.value,
|
5730 | "maxlength": props2.detailMaxlength,
|
5731 | "searchResult": props2.searchResult,
|
5732 | "showSearchResult": props2.showSearchResult,
|
5733 | "onBlur": onDetailBlur,
|
5734 | "onFocus": () => onFocus("addressDetail"),
|
5735 | "onInput": onChangeDetail,
|
5736 | "onSelectSearch": (event) => emit("selectSearch", event)
|
5737 | }, null), (_a = slots.default) == null ? void 0 : _a.call(slots)]), renderSetDefaultCell(), vue.withDirectives(vue.createVNode("div", {
|
5738 | "class": bem$1d("buttons")
|
5739 | }, [vue.createVNode(Button, {
|
5740 | "block": true,
|
5741 | "round": true,
|
5742 | "type": "primary",
|
5743 | "text": props2.saveButtonText || t$i("save"),
|
5744 | "class": bem$1d("button"),
|
5745 | "loading": props2.isSaving,
|
5746 | "nativeType": "submit"
|
5747 | }, null), props2.showDelete && vue.createVNode(Button, {
|
5748 | "block": true,
|
5749 | "round": true,
|
5750 | "class": bem$1d("button"),
|
5751 | "loading": props2.isDeleting,
|
5752 | "text": props2.deleteButtonText || t$i("delete"),
|
5753 | "onClick": onDelete
|
5754 | }, null)]), [[vue.vShow, !hideBottomFields.value]]), vue.createVNode(Popup, {
|
5755 | "show": showAreaPopup.value,
|
5756 | "onUpdate:show": ($event) => showAreaPopup.value = $event,
|
5757 | "round": true,
|
5758 | "teleport": "body",
|
5759 | "position": "bottom",
|
5760 | "lazyRender": false
|
5761 | }, {
|
5762 | default: () => [vue.createVNode(Area, {
|
5763 | "modelValue": data.areaCode,
|
5764 | "onUpdate:modelValue": ($event) => data.areaCode = $event,
|
5765 | "ref": areaRef,
|
5766 | "loading": !areaListLoaded.value,
|
5767 | "areaList": props2.areaList,
|
5768 | "columnsPlaceholder": props2.areaColumnsPlaceholder,
|
5769 | "onConfirm": onAreaConfirm,
|
5770 | "onCancel": () => {
|
5771 | showAreaPopup.value = false;
|
5772 | }
|
5773 | }, null)]
|
5774 | })];
|
5775 | }
|
5776 | });
|
5777 | };
|
5778 | }
|
5779 | });
|
5780 | const AddressEdit = withInstall(stdin_default$1r);
|
5781 | const [name$1g, bem$1c] = createNamespace("radio-group");
|
5782 | const radioGroupProps = {
|
5783 | shape: String,
|
5784 | disabled: Boolean,
|
5785 | iconSize: numericProp,
|
5786 | direction: String,
|
5787 | modelValue: unknownProp,
|
5788 | checkedColor: String
|
5789 | };
|
5790 | const RADIO_KEY = Symbol(name$1g);
|
5791 | var stdin_default$1q = vue.defineComponent({
|
5792 | name: name$1g,
|
5793 | props: radioGroupProps,
|
5794 | emits: ["change", "update:modelValue"],
|
5795 | setup(props2, {
|
5796 | emit,
|
5797 | slots
|
5798 | }) {
|
5799 | const {
|
5800 | linkChildren
|
5801 | } = useChildren(RADIO_KEY);
|
5802 | const updateValue = (value) => emit("update:modelValue", value);
|
5803 | vue.watch(() => props2.modelValue, (value) => emit("change", value));
|
5804 | linkChildren({
|
5805 | props: props2,
|
5806 | updateValue
|
5807 | });
|
5808 | useCustomFieldValue(() => props2.modelValue);
|
5809 | return () => {
|
5810 | var _a;
|
5811 | return vue.createVNode("div", {
|
5812 | "class": bem$1c([props2.direction]),
|
5813 | "role": "radiogroup"
|
5814 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
5815 | };
|
5816 | }
|
5817 | });
|
5818 | const RadioGroup = withInstall(stdin_default$1q);
|
5819 | const [name$1f, bem$1b] = createNamespace("checkbox-group");
|
5820 | const checkboxGroupProps = {
|
5821 | max: numericProp,
|
5822 | shape: makeStringProp("round"),
|
5823 | disabled: Boolean,
|
5824 | iconSize: numericProp,
|
5825 | direction: String,
|
5826 | modelValue: makeArrayProp(),
|
5827 | checkedColor: String
|
5828 | };
|
5829 | const CHECKBOX_GROUP_KEY = Symbol(name$1f);
|
5830 | var stdin_default$1p = vue.defineComponent({
|
5831 | name: name$1f,
|
5832 | props: checkboxGroupProps,
|
5833 | emits: ["change", "update:modelValue"],
|
5834 | setup(props2, {
|
5835 | emit,
|
5836 | slots
|
5837 | }) {
|
5838 | const {
|
5839 | children,
|
5840 | linkChildren
|
5841 | } = useChildren(CHECKBOX_GROUP_KEY);
|
5842 | const updateValue = (value) => emit("update:modelValue", value);
|
5843 | const toggleAll = (options = {}) => {
|
5844 | if (typeof options === "boolean") {
|
5845 | options = {
|
5846 | checked: options
|
5847 | };
|
5848 | }
|
5849 | const {
|
5850 | checked,
|
5851 | skipDisabled
|
5852 | } = options;
|
5853 | const checkedChildren = children.filter((item) => {
|
5854 | if (!item.props.bindGroup) {
|
5855 | return false;
|
5856 | }
|
5857 | if (item.props.disabled && skipDisabled) {
|
5858 | return item.checked.value;
|
5859 | }
|
5860 | return checked != null ? checked : !item.checked.value;
|
5861 | });
|
5862 | const names = checkedChildren.map((item) => item.name);
|
5863 | updateValue(names);
|
5864 | };
|
5865 | vue.watch(() => props2.modelValue, (value) => emit("change", value));
|
5866 | useExpose({
|
5867 | toggleAll
|
5868 | });
|
5869 | useCustomFieldValue(() => props2.modelValue);
|
5870 | linkChildren({
|
5871 | props: props2,
|
5872 | updateValue
|
5873 | });
|
5874 | return () => {
|
5875 | var _a;
|
5876 | return vue.createVNode("div", {
|
5877 | "class": bem$1b([props2.direction])
|
5878 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
5879 | };
|
5880 | }
|
5881 | });
|
5882 | const CheckboxGroup = withInstall(stdin_default$1p);
|
5883 | const [name$1e, bem$1a] = createNamespace("tag");
|
5884 | const tagProps = {
|
5885 | size: String,
|
5886 | mark: Boolean,
|
5887 | show: truthProp,
|
5888 | type: makeStringProp("default"),
|
5889 | color: String,
|
5890 | plain: Boolean,
|
5891 | round: Boolean,
|
5892 | textColor: String,
|
5893 | closeable: Boolean
|
5894 | };
|
5895 | var stdin_default$1o = vue.defineComponent({
|
5896 | name: name$1e,
|
5897 | props: tagProps,
|
5898 | emits: ["close"],
|
5899 | setup(props2, {
|
5900 | slots,
|
5901 | emit
|
5902 | }) {
|
5903 | const onClose = (event) => {
|
5904 | event.stopPropagation();
|
5905 | emit("close", event);
|
5906 | };
|
5907 | const getStyle = () => {
|
5908 | if (props2.plain) {
|
5909 | return {
|
5910 | color: props2.textColor || props2.color,
|
5911 | borderColor: props2.color
|
5912 | };
|
5913 | }
|
5914 | return {
|
5915 | color: props2.textColor,
|
5916 | background: props2.color
|
5917 | };
|
5918 | };
|
5919 | const renderTag = () => {
|
5920 | var _a;
|
5921 | const {
|
5922 | type,
|
5923 | mark,
|
5924 | plain,
|
5925 | round: round2,
|
5926 | size,
|
5927 | closeable
|
5928 | } = props2;
|
5929 | const classes = {
|
5930 | mark,
|
5931 | plain,
|
5932 | round: round2
|
5933 | };
|
5934 | if (size) {
|
5935 | classes[size] = size;
|
5936 | }
|
5937 | const CloseIcon = closeable && vue.createVNode(Icon, {
|
5938 | "name": "cross",
|
5939 | "class": [bem$1a("close"), HAPTICS_FEEDBACK],
|
5940 | "onClick": onClose
|
5941 | }, null);
|
5942 | return vue.createVNode("span", {
|
5943 | "style": getStyle(),
|
5944 | "class": bem$1a([classes, type])
|
5945 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots), CloseIcon]);
|
5946 | };
|
5947 | return () => vue.createVNode(vue.Transition, {
|
5948 | "name": props2.closeable ? "van-fade" : void 0
|
5949 | }, {
|
5950 | default: () => [props2.show ? renderTag() : null]
|
5951 | });
|
5952 | }
|
5953 | });
|
5954 | const Tag = withInstall(stdin_default$1o);
|
5955 | const checkerProps = {
|
5956 | name: unknownProp,
|
5957 | disabled: Boolean,
|
5958 | iconSize: numericProp,
|
5959 | modelValue: unknownProp,
|
5960 | checkedColor: String,
|
5961 | labelPosition: String,
|
5962 | labelDisabled: Boolean
|
5963 | };
|
5964 | var stdin_default$1n = vue.defineComponent({
|
5965 | props: extend({}, checkerProps, {
|
5966 | bem: makeRequiredProp(Function),
|
5967 | role: String,
|
5968 | shape: String,
|
5969 | parent: Object,
|
5970 | checked: Boolean,
|
5971 | bindGroup: truthProp,
|
5972 | indeterminate: {
|
5973 | type: Boolean,
|
5974 | default: null
|
5975 | }
|
5976 | }),
|
5977 | emits: ["click", "toggle"],
|
5978 | setup(props2, {
|
5979 | emit,
|
5980 | slots
|
5981 | }) {
|
5982 | const iconRef = vue.ref();
|
5983 | const getParentProp = (name2) => {
|
5984 | if (props2.parent && props2.bindGroup) {
|
5985 | return props2.parent.props[name2];
|
5986 | }
|
5987 | };
|
5988 | const disabled = vue.computed(() => {
|
5989 | if (props2.parent && props2.bindGroup) {
|
5990 | const disabled2 = getParentProp("disabled") || props2.disabled;
|
5991 | if (props2.role === "checkbox") {
|
5992 | const checkedCount = getParentProp("modelValue").length;
|
5993 | const max = getParentProp("max");
|
5994 | const overlimit = max && checkedCount >= +max;
|
5995 | return disabled2 || overlimit && !props2.checked;
|
5996 | }
|
5997 | return disabled2;
|
5998 | }
|
5999 | return props2.disabled;
|
6000 | });
|
6001 | const direction = vue.computed(() => getParentProp("direction"));
|
6002 | const iconStyle = vue.computed(() => {
|
6003 | const checkedColor = props2.checkedColor || getParentProp("checkedColor");
|
6004 | if (checkedColor && props2.checked && !disabled.value) {
|
6005 | return {
|
6006 | borderColor: checkedColor,
|
6007 | backgroundColor: checkedColor
|
6008 | };
|
6009 | }
|
6010 | });
|
6011 | const shape = vue.computed(() => {
|
6012 | return props2.shape || getParentProp("shape") || "round";
|
6013 | });
|
6014 | const onClick = (event) => {
|
6015 | const {
|
6016 | target
|
6017 | } = event;
|
6018 | const icon = iconRef.value;
|
6019 | const iconClicked = icon === target || (icon == null ? void 0 : icon.contains(target));
|
6020 | if (!disabled.value && (iconClicked || !props2.labelDisabled)) {
|
6021 | emit("toggle");
|
6022 | }
|
6023 | emit("click", event);
|
6024 | };
|
6025 | const renderIcon = () => {
|
6026 | var _a, _b;
|
6027 | const {
|
6028 | bem: bem2,
|
6029 | checked,
|
6030 | indeterminate
|
6031 | } = props2;
|
6032 | const iconSize = props2.iconSize || getParentProp("iconSize");
|
6033 | return vue.createVNode("div", {
|
6034 | "ref": iconRef,
|
6035 | "class": bem2("icon", [shape.value, {
|
6036 | disabled: disabled.value,
|
6037 | checked,
|
6038 | indeterminate
|
6039 | }]),
|
6040 | "style": shape.value !== "dot" ? {
|
6041 | fontSize: addUnit(iconSize)
|
6042 | } : {
|
6043 | width: addUnit(iconSize),
|
6044 | height: addUnit(iconSize),
|
6045 | borderColor: (_a = iconStyle.value) == null ? void 0 : _a.borderColor
|
6046 | }
|
6047 | }, [slots.icon ? slots.icon({
|
6048 | checked,
|
6049 | disabled: disabled.value
|
6050 | }) : shape.value !== "dot" ? vue.createVNode(Icon, {
|
6051 | "name": indeterminate ? "minus" : "success",
|
6052 | "style": iconStyle.value
|
6053 | }, null) : vue.createVNode("div", {
|
6054 | "class": bem2("icon--dot__icon"),
|
6055 | "style": {
|
6056 | backgroundColor: (_b = iconStyle.value) == null ? void 0 : _b.backgroundColor
|
6057 | }
|
6058 | }, null)]);
|
6059 | };
|
6060 | const renderLabel = () => {
|
6061 | const {
|
6062 | checked
|
6063 | } = props2;
|
6064 | if (slots.default) {
|
6065 | return vue.createVNode("span", {
|
6066 | "class": props2.bem("label", [props2.labelPosition, {
|
6067 | disabled: disabled.value
|
6068 | }])
|
6069 | }, [slots.default({
|
6070 | checked,
|
6071 | disabled: disabled.value
|
6072 | })]);
|
6073 | }
|
6074 | };
|
6075 | return () => {
|
6076 | const nodes = props2.labelPosition === "left" ? [renderLabel(), renderIcon()] : [renderIcon(), renderLabel()];
|
6077 | return vue.createVNode("div", {
|
6078 | "role": props2.role,
|
6079 | "class": props2.bem([{
|
6080 | disabled: disabled.value,
|
6081 | "label-disabled": props2.labelDisabled
|
6082 | }, direction.value]),
|
6083 | "tabindex": disabled.value ? void 0 : 0,
|
6084 | "aria-checked": props2.checked,
|
6085 | "onClick": onClick
|
6086 | }, [nodes]);
|
6087 | };
|
6088 | }
|
6089 | });
|
6090 | const radioProps = extend({}, checkerProps, {
|
6091 | shape: String
|
6092 | });
|
6093 | const [name$1d, bem$19] = createNamespace("radio");
|
6094 | var stdin_default$1m = vue.defineComponent({
|
6095 | name: name$1d,
|
6096 | props: radioProps,
|
6097 | emits: ["update:modelValue"],
|
6098 | setup(props2, {
|
6099 | emit,
|
6100 | slots
|
6101 | }) {
|
6102 | const {
|
6103 | parent
|
6104 | } = useParent(RADIO_KEY);
|
6105 | const checked = () => {
|
6106 | const value = parent ? parent.props.modelValue : props2.modelValue;
|
6107 | return value === props2.name;
|
6108 | };
|
6109 | const toggle = () => {
|
6110 | if (parent) {
|
6111 | parent.updateValue(props2.name);
|
6112 | } else {
|
6113 | emit("update:modelValue", props2.name);
|
6114 | }
|
6115 | };
|
6116 | return () => vue.createVNode(stdin_default$1n, vue.mergeProps({
|
6117 | "bem": bem$19,
|
6118 | "role": "radio",
|
6119 | "parent": parent,
|
6120 | "checked": checked(),
|
6121 | "onToggle": toggle
|
6122 | }, props2), pick(slots, ["default", "icon"]));
|
6123 | }
|
6124 | });
|
6125 | const Radio = withInstall(stdin_default$1m);
|
6126 | const [name$1c, bem$18] = createNamespace("checkbox");
|
6127 | const checkboxProps = extend({}, checkerProps, {
|
6128 | shape: String,
|
6129 | bindGroup: truthProp,
|
6130 | indeterminate: {
|
6131 | type: Boolean,
|
6132 | default: null
|
6133 | }
|
6134 | });
|
6135 | var stdin_default$1l = vue.defineComponent({
|
6136 | name: name$1c,
|
6137 | props: checkboxProps,
|
6138 | emits: ["change", "update:modelValue"],
|
6139 | setup(props2, {
|
6140 | emit,
|
6141 | slots
|
6142 | }) {
|
6143 | const {
|
6144 | parent
|
6145 | } = useParent(CHECKBOX_GROUP_KEY);
|
6146 | const setParentValue = (checked2) => {
|
6147 | const {
|
6148 | name: name2
|
6149 | } = props2;
|
6150 | const {
|
6151 | max,
|
6152 | modelValue
|
6153 | } = parent.props;
|
6154 | const value = modelValue.slice();
|
6155 | if (checked2) {
|
6156 | const overlimit = max && value.length >= +max;
|
6157 | if (!overlimit && !value.includes(name2)) {
|
6158 | value.push(name2);
|
6159 | if (props2.bindGroup) {
|
6160 | parent.updateValue(value);
|
6161 | }
|
6162 | }
|
6163 | } else {
|
6164 | const index = value.indexOf(name2);
|
6165 | if (index !== -1) {
|
6166 | value.splice(index, 1);
|
6167 | if (props2.bindGroup) {
|
6168 | parent.updateValue(value);
|
6169 | }
|
6170 | }
|
6171 | }
|
6172 | };
|
6173 | const checked = vue.computed(() => {
|
6174 | if (parent && props2.bindGroup) {
|
6175 | return parent.props.modelValue.indexOf(props2.name) !== -1;
|
6176 | }
|
6177 | return !!props2.modelValue;
|
6178 | });
|
6179 | const toggle = (newValue = !checked.value) => {
|
6180 | if (parent && props2.bindGroup) {
|
6181 | setParentValue(newValue);
|
6182 | } else {
|
6183 | emit("update:modelValue", newValue);
|
6184 | }
|
6185 | if (props2.indeterminate !== null) emit("change", newValue);
|
6186 | };
|
6187 | vue.watch(() => props2.modelValue, (value) => {
|
6188 | if (props2.indeterminate === null) emit("change", value);
|
6189 | });
|
6190 | useExpose({
|
6191 | toggle,
|
6192 | props: props2,
|
6193 | checked
|
6194 | });
|
6195 | useCustomFieldValue(() => props2.modelValue);
|
6196 | return () => vue.createVNode(stdin_default$1n, vue.mergeProps({
|
6197 | "bem": bem$18,
|
6198 | "role": "checkbox",
|
6199 | "parent": parent,
|
6200 | "checked": checked.value,
|
6201 | "onToggle": toggle
|
6202 | }, props2), pick(slots, ["default", "icon"]));
|
6203 | }
|
6204 | });
|
6205 | const Checkbox = withInstall(stdin_default$1l);
|
6206 | const [name$1b, bem$17] = createNamespace("address-item");
|
6207 | var stdin_default$1k = vue.defineComponent({
|
6208 | name: name$1b,
|
6209 | props: {
|
6210 | address: makeRequiredProp(Object),
|
6211 | disabled: Boolean,
|
6212 | switchable: Boolean,
|
6213 | singleChoice: Boolean,
|
6214 | defaultTagText: String,
|
6215 | rightIcon: makeStringProp("edit")
|
6216 | },
|
6217 | emits: ["edit", "click", "select"],
|
6218 | setup(props2, {
|
6219 | slots,
|
6220 | emit
|
6221 | }) {
|
6222 | const onClick = (event) => {
|
6223 | if (props2.switchable) {
|
6224 | emit("select");
|
6225 | }
|
6226 | emit("click", event);
|
6227 | };
|
6228 | const renderRightIcon = () => vue.createVNode(Icon, {
|
6229 | "name": props2.rightIcon,
|
6230 | "class": bem$17("edit"),
|
6231 | "onClick": (event) => {
|
6232 | event.stopPropagation();
|
6233 | emit("edit");
|
6234 | emit("click", event);
|
6235 | }
|
6236 | }, null);
|
6237 | const renderTag = () => {
|
6238 | if (slots.tag) {
|
6239 | return slots.tag(props2.address);
|
6240 | }
|
6241 | if (props2.address.isDefault && props2.defaultTagText) {
|
6242 | return vue.createVNode(Tag, {
|
6243 | "type": "primary",
|
6244 | "round": true,
|
6245 | "class": bem$17("tag")
|
6246 | }, {
|
6247 | default: () => [props2.defaultTagText]
|
6248 | });
|
6249 | }
|
6250 | };
|
6251 | const renderContent = () => {
|
6252 | const {
|
6253 | address,
|
6254 | disabled,
|
6255 | switchable,
|
6256 | singleChoice
|
6257 | } = props2;
|
6258 | const Info = [vue.createVNode("div", {
|
6259 | "class": bem$17("name")
|
6260 | }, [`${address.name} ${address.tel}`, renderTag()]), vue.createVNode("div", {
|
6261 | "class": bem$17("address")
|
6262 | }, [address.address])];
|
6263 | if (switchable && !disabled) {
|
6264 | if (singleChoice) {
|
6265 | return vue.createVNode(Radio, {
|
6266 | "name": address.id,
|
6267 | "iconSize": 18
|
6268 | }, {
|
6269 | default: () => [Info]
|
6270 | });
|
6271 | } else {
|
6272 | return vue.createVNode(Checkbox, {
|
6273 | "name": address.id,
|
6274 | "iconSize": 18
|
6275 | }, {
|
6276 | default: () => [Info]
|
6277 | });
|
6278 | }
|
6279 | }
|
6280 | return Info;
|
6281 | };
|
6282 | return () => {
|
6283 | var _a;
|
6284 | const {
|
6285 | disabled
|
6286 | } = props2;
|
6287 | return vue.createVNode("div", {
|
6288 | "class": bem$17({
|
6289 | disabled
|
6290 | }),
|
6291 | "onClick": onClick
|
6292 | }, [vue.createVNode(Cell, {
|
6293 | "border": false,
|
6294 | "titleClass": bem$17("title")
|
6295 | }, {
|
6296 | title: renderContent,
|
6297 | "right-icon": renderRightIcon
|
6298 | }), (_a = slots.bottom) == null ? void 0 : _a.call(slots, extend({}, props2.address, {
|
6299 | disabled
|
6300 | }))]);
|
6301 | };
|
6302 | }
|
6303 | });
|
6304 | const [name$1a, bem$16, t$h] = createNamespace("address-list");
|
6305 | const addressListProps = {
|
6306 | list: makeArrayProp(),
|
6307 | modelValue: [...numericProp, Array],
|
6308 | switchable: truthProp,
|
6309 | disabledText: String,
|
6310 | disabledList: makeArrayProp(),
|
6311 | showAddButton: truthProp,
|
6312 | addButtonText: String,
|
6313 | defaultTagText: String,
|
6314 | rightIcon: makeStringProp("edit")
|
6315 | };
|
6316 | var stdin_default$1j = vue.defineComponent({
|
6317 | name: name$1a,
|
6318 | props: addressListProps,
|
6319 | emits: ["add", "edit", "select", "clickItem", "editDisabled", "selectDisabled", "update:modelValue"],
|
6320 | setup(props2, {
|
6321 | slots,
|
6322 | emit
|
6323 | }) {
|
6324 | const singleChoice = vue.computed(() => !Array.isArray(props2.modelValue));
|
6325 | const renderItem = (item, index, disabled) => {
|
6326 | const onEdit = () => emit(disabled ? "editDisabled" : "edit", item, index);
|
6327 | const onClick = (event) => emit("clickItem", item, index, {
|
6328 | event
|
6329 | });
|
6330 | const onSelect = () => {
|
6331 | emit(disabled ? "selectDisabled" : "select", item, index);
|
6332 | if (!disabled) {
|
6333 | if (singleChoice.value) {
|
6334 | emit("update:modelValue", item.id);
|
6335 | } else {
|
6336 | const value = props2.modelValue;
|
6337 | if (value.includes(item.id)) {
|
6338 | emit("update:modelValue", value.filter((id) => id !== item.id));
|
6339 | } else {
|
6340 | emit("update:modelValue", [...value, item.id]);
|
6341 | }
|
6342 | }
|
6343 | }
|
6344 | };
|
6345 | return vue.createVNode(stdin_default$1k, {
|
6346 | "key": item.id,
|
6347 | "address": item,
|
6348 | "disabled": disabled,
|
6349 | "switchable": props2.switchable,
|
6350 | "singleChoice": singleChoice.value,
|
6351 | "defaultTagText": props2.defaultTagText,
|
6352 | "rightIcon": props2.rightIcon,
|
6353 | "onEdit": onEdit,
|
6354 | "onClick": onClick,
|
6355 | "onSelect": onSelect
|
6356 | }, {
|
6357 | bottom: slots["item-bottom"],
|
6358 | tag: slots.tag
|
6359 | });
|
6360 | };
|
6361 | const renderList = (list, disabled) => {
|
6362 | if (list) {
|
6363 | return list.map((item, index) => renderItem(item, index, disabled));
|
6364 | }
|
6365 | };
|
6366 | const renderBottom = () => props2.showAddButton ? vue.createVNode("div", {
|
6367 | "class": [bem$16("bottom"), "van-safe-area-bottom"]
|
6368 | }, [vue.createVNode(Button, {
|
6369 | "round": true,
|
6370 | "block": true,
|
6371 | "type": "primary",
|
6372 | "text": props2.addButtonText || t$h("add"),
|
6373 | "class": bem$16("add"),
|
6374 | "onClick": () => emit("add")
|
6375 | }, null)]) : void 0;
|
6376 | return () => {
|
6377 | var _a, _b;
|
6378 | const List2 = renderList(props2.list);
|
6379 | const DisabledList = renderList(props2.disabledList, true);
|
6380 | const DisabledText = props2.disabledText && vue.createVNode("div", {
|
6381 | "class": bem$16("disabled-text")
|
6382 | }, [props2.disabledText]);
|
6383 | return vue.createVNode("div", {
|
6384 | "class": bem$16()
|
6385 | }, [(_a = slots.top) == null ? void 0 : _a.call(slots), !singleChoice.value && Array.isArray(props2.modelValue) ? vue.createVNode(CheckboxGroup, {
|
6386 | "modelValue": props2.modelValue
|
6387 | }, {
|
6388 | default: () => [List2]
|
6389 | }) : vue.createVNode(RadioGroup, {
|
6390 | "modelValue": props2.modelValue
|
6391 | }, {
|
6392 | default: () => [List2]
|
6393 | }), DisabledText, DisabledList, (_b = slots.default) == null ? void 0 : _b.call(slots), renderBottom()]);
|
6394 | };
|
6395 | }
|
6396 | });
|
6397 | const AddressList = withInstall(stdin_default$1j);
|
6398 | const hasIntersectionObserver = inBrowser && "IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype;
|
6399 | const modeType = {
|
6400 | event: "event",
|
6401 | observer: "observer"
|
6402 | };
|
6403 | function remove(arr, item) {
|
6404 | if (!arr.length) return;
|
6405 | const index = arr.indexOf(item);
|
6406 | if (index > -1) return arr.splice(index, 1);
|
6407 | }
|
6408 | function getBestSelectionFromSrcset(el, scale) {
|
6409 | if (el.tagName !== "IMG" || !el.getAttribute("data-srcset")) return;
|
6410 | let options = el.getAttribute("data-srcset");
|
6411 | const container = el.parentNode;
|
6412 | const containerWidth = container.offsetWidth * scale;
|
6413 | let spaceIndex;
|
6414 | let tmpSrc;
|
6415 | let tmpWidth;
|
6416 | options = options.trim().split(",");
|
6417 | const result = options.map((item) => {
|
6418 | item = item.trim();
|
6419 | spaceIndex = item.lastIndexOf(" ");
|
6420 | if (spaceIndex === -1) {
|
6421 | tmpSrc = item;
|
6422 | tmpWidth = 999998;
|
6423 | } else {
|
6424 | tmpSrc = item.substr(0, spaceIndex);
|
6425 | tmpWidth = parseInt(
|
6426 | item.substr(spaceIndex + 1, item.length - spaceIndex - 2),
|
6427 | 10
|
6428 | );
|
6429 | }
|
6430 | return [tmpWidth, tmpSrc];
|
6431 | });
|
6432 | result.sort((a, b) => {
|
6433 | if (a[0] < b[0]) {
|
6434 | return 1;
|
6435 | }
|
6436 | if (a[0] > b[0]) {
|
6437 | return -1;
|
6438 | }
|
6439 | if (a[0] === b[0]) {
|
6440 | if (b[1].indexOf(".webp", b[1].length - 5) !== -1) {
|
6441 | return 1;
|
6442 | }
|
6443 | if (a[1].indexOf(".webp", a[1].length - 5) !== -1) {
|
6444 | return -1;
|
6445 | }
|
6446 | }
|
6447 | return 0;
|
6448 | });
|
6449 | let bestSelectedSrc = "";
|
6450 | let tmpOption;
|
6451 | for (let i = 0; i < result.length; i++) {
|
6452 | tmpOption = result[i];
|
6453 | bestSelectedSrc = tmpOption[1];
|
6454 | const next = result[i + 1];
|
6455 | if (next && next[0] < containerWidth) {
|
6456 | bestSelectedSrc = tmpOption[1];
|
6457 | break;
|
6458 | } else if (!next) {
|
6459 | bestSelectedSrc = tmpOption[1];
|
6460 | break;
|
6461 | }
|
6462 | }
|
6463 | return bestSelectedSrc;
|
6464 | }
|
6465 | const getDPR = (scale = 1) => inBrowser ? window.devicePixelRatio || scale : scale;
|
6466 | function supportWebp() {
|
6467 | if (!inBrowser) return false;
|
6468 | let support = true;
|
6469 | try {
|
6470 | const elem = document.createElement("canvas");
|
6471 | if (elem.getContext && elem.getContext("2d")) {
|
6472 | support = elem.toDataURL("image/webp").indexOf("data:image/webp") === 0;
|
6473 | }
|
6474 | } catch (err) {
|
6475 | support = false;
|
6476 | }
|
6477 | return support;
|
6478 | }
|
6479 | function throttle(action, delay) {
|
6480 | let timeout = null;
|
6481 | let lastRun = 0;
|
6482 | return function(...args) {
|
6483 | if (timeout) {
|
6484 | return;
|
6485 | }
|
6486 | const elapsed = Date.now() - lastRun;
|
6487 | const runCallback = () => {
|
6488 | lastRun = Date.now();
|
6489 | timeout = false;
|
6490 | action.apply(this, args);
|
6491 | };
|
6492 | if (elapsed >= delay) {
|
6493 | runCallback();
|
6494 | } else {
|
6495 | timeout = setTimeout(runCallback, delay);
|
6496 | }
|
6497 | };
|
6498 | }
|
6499 | function on(el, type, func) {
|
6500 | el.addEventListener(type, func, {
|
6501 | capture: false,
|
6502 | passive: true
|
6503 | });
|
6504 | }
|
6505 | function off(el, type, func) {
|
6506 | el.removeEventListener(type, func, false);
|
6507 | }
|
6508 | const loadImageAsync = (item, resolve, reject) => {
|
6509 | const image = new Image();
|
6510 | if (!item || !item.src) {
|
6511 | return reject(new Error("image src is required"));
|
6512 | }
|
6513 | image.src = item.src;
|
6514 | if (item.cors) {
|
6515 | image.crossOrigin = item.cors;
|
6516 | }
|
6517 | image.onload = () => resolve({
|
6518 | naturalHeight: image.naturalHeight,
|
6519 | naturalWidth: image.naturalWidth,
|
6520 | src: image.src
|
6521 | });
|
6522 | image.onerror = (e) => reject(e);
|
6523 | };
|
6524 | class ImageCache {
|
6525 | constructor({ max }) {
|
6526 | this.options = {
|
6527 | max: max || 100
|
6528 | };
|
6529 | this.caches = [];
|
6530 | }
|
6531 | has(key) {
|
6532 | return this.caches.indexOf(key) > -1;
|
6533 | }
|
6534 | add(key) {
|
6535 | if (this.has(key)) return;
|
6536 | this.caches.push(key);
|
6537 | if (this.caches.length > this.options.max) {
|
6538 | this.free();
|
6539 | }
|
6540 | }
|
6541 | free() {
|
6542 | this.caches.shift();
|
6543 | }
|
6544 | }
|
6545 | const [name$19, bem$15] = createNamespace("back-top");
|
6546 | const backTopProps = {
|
6547 | right: numericProp,
|
6548 | bottom: numericProp,
|
6549 | zIndex: numericProp,
|
6550 | target: [String, Object],
|
6551 | offset: makeNumericProp(200),
|
6552 | immediate: Boolean,
|
6553 | teleport: {
|
6554 | type: [String, Object],
|
6555 | default: "body"
|
6556 | }
|
6557 | };
|
6558 | var stdin_default$1i = vue.defineComponent({
|
6559 | name: name$19,
|
6560 | inheritAttrs: false,
|
6561 | props: backTopProps,
|
6562 | emits: ["click"],
|
6563 | setup(props2, {
|
6564 | emit,
|
6565 | slots,
|
6566 | attrs
|
6567 | }) {
|
6568 | let shouldReshow = false;
|
6569 | const show = vue.ref(false);
|
6570 | const root = vue.ref();
|
6571 | const scrollParent = vue.ref();
|
6572 | const style = vue.computed(() => extend(getZIndexStyle(props2.zIndex), {
|
6573 | right: addUnit(props2.right),
|
6574 | bottom: addUnit(props2.bottom)
|
6575 | }));
|
6576 | const onClick = (event) => {
|
6577 | var _a;
|
6578 | emit("click", event);
|
6579 | (_a = scrollParent.value) == null ? void 0 : _a.scrollTo({
|
6580 | top: 0,
|
6581 | behavior: props2.immediate ? "auto" : "smooth"
|
6582 | });
|
6583 | };
|
6584 | const scroll = () => {
|
6585 | show.value = scrollParent.value ? getScrollTop(scrollParent.value) >= +props2.offset : false;
|
6586 | };
|
6587 | const getTarget = () => {
|
6588 | const {
|
6589 | target
|
6590 | } = props2;
|
6591 | if (typeof target === "string") {
|
6592 | const el = document.querySelector(target);
|
6593 | if (el) {
|
6594 | return el;
|
6595 | }
|
6596 | } else {
|
6597 | return target;
|
6598 | }
|
6599 | };
|
6600 | const updateTarget = () => {
|
6601 | if (inBrowser$1) {
|
6602 | vue.nextTick(() => {
|
6603 | scrollParent.value = props2.target ? getTarget() : getScrollParent$1(root.value);
|
6604 | scroll();
|
6605 | });
|
6606 | }
|
6607 | };
|
6608 | useEventListener("scroll", throttle(scroll, 100), {
|
6609 | target: scrollParent
|
6610 | });
|
6611 | vue.onMounted(updateTarget);
|
6612 | vue.onActivated(() => {
|
6613 | if (shouldReshow) {
|
6614 | show.value = true;
|
6615 | shouldReshow = false;
|
6616 | }
|
6617 | });
|
6618 | vue.onDeactivated(() => {
|
6619 | if (show.value && props2.teleport) {
|
6620 | show.value = false;
|
6621 | shouldReshow = true;
|
6622 | }
|
6623 | });
|
6624 | vue.watch(() => props2.target, updateTarget);
|
6625 | return () => {
|
6626 | const Content = vue.createVNode("div", vue.mergeProps({
|
6627 | "ref": !props2.teleport ? root : void 0,
|
6628 | "class": bem$15({
|
6629 | active: show.value
|
6630 | }),
|
6631 | "style": style.value,
|
6632 | "onClick": onClick
|
6633 | }, attrs), [slots.default ? slots.default() : vue.createVNode(Icon, {
|
6634 | "name": "back-top",
|
6635 | "class": bem$15("icon")
|
6636 | }, null)]);
|
6637 | if (props2.teleport) {
|
6638 | return [vue.createVNode("div", {
|
6639 | "ref": root,
|
6640 | "class": bem$15("placeholder")
|
6641 | }, null), vue.createVNode(vue.Teleport, {
|
6642 | "to": props2.teleport
|
6643 | }, {
|
6644 | default: () => [Content]
|
6645 | })];
|
6646 | }
|
6647 | return Content;
|
6648 | };
|
6649 | }
|
6650 | });
|
6651 | const BackTop = withInstall(stdin_default$1i);
|
6652 | var __async = (__this, __arguments, generator) => {
|
6653 | return new Promise((resolve, reject) => {
|
6654 | var fulfilled = (value) => {
|
6655 | try {
|
6656 | step(generator.next(value));
|
6657 | } catch (e) {
|
6658 | reject(e);
|
6659 | }
|
6660 | };
|
6661 | var rejected = (value) => {
|
6662 | try {
|
6663 | step(generator.throw(value));
|
6664 | } catch (e) {
|
6665 | reject(e);
|
6666 | }
|
6667 | };
|
6668 | var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
6669 | step((generator = generator.apply(__this, __arguments)).next());
|
6670 | });
|
6671 | };
|
6672 | const barrageProps = {
|
6673 | top: makeNumericProp(10),
|
6674 | rows: makeNumericProp(4),
|
6675 | duration: makeNumericProp(4e3),
|
6676 | autoPlay: truthProp,
|
6677 | delay: makeNumberProp(300),
|
6678 | modelValue: makeArrayProp()
|
6679 | };
|
6680 | const [name$18, bem$14] = createNamespace("barrage");
|
6681 | var stdin_default$1h = vue.defineComponent({
|
6682 | name: name$18,
|
6683 | props: barrageProps,
|
6684 | emits: ["update:modelValue"],
|
6685 | setup(props2, {
|
6686 | emit,
|
6687 | slots
|
6688 | }) {
|
6689 | const barrageWrapper = vue.ref();
|
6690 | const className = bem$14("item");
|
6691 | const total = vue.ref(0);
|
6692 | const barrageItems = [];
|
6693 | const createBarrageItem = (text, delay = props2.delay) => {
|
6694 | const item = document.createElement("span");
|
6695 | item.className = className;
|
6696 | item.innerText = String(text);
|
6697 | item.style.animationDuration = `${props2.duration}ms`;
|
6698 | item.style.animationDelay = `${delay}ms`;
|
6699 | item.style.animationName = "van-barrage";
|
6700 | item.style.animationTimingFunction = "linear";
|
6701 | return item;
|
6702 | };
|
6703 | const isInitBarrage = vue.ref(true);
|
6704 | const isPlay = vue.ref(props2.autoPlay);
|
6705 | const appendBarrageItem = ({
|
6706 | id,
|
6707 | text
|
6708 | }, i) => {
|
6709 | var _a;
|
6710 | const item = createBarrageItem(text, isInitBarrage.value ? i * props2.delay : void 0);
|
6711 | if (!props2.autoPlay && isPlay.value === false) {
|
6712 | item.style.animationPlayState = "paused";
|
6713 | }
|
6714 | (_a = barrageWrapper.value) == null ? void 0 : _a.append(item);
|
6715 | total.value++;
|
6716 | const top2 = (total.value - 1) % +props2.rows * item.offsetHeight + +props2.top;
|
6717 | item.style.top = `${top2}px`;
|
6718 | item.dataset.id = String(id);
|
6719 | barrageItems.push(item);
|
6720 | item.addEventListener("animationend", () => {
|
6721 | emit("update:modelValue", [...props2.modelValue].filter((v) => String(v.id) !== item.dataset.id));
|
6722 | });
|
6723 | };
|
6724 | const updateBarrages = (newValue, oldValue) => {
|
6725 | const map = new Map(oldValue.map((item) => [item.id, item]));
|
6726 | newValue.forEach((item, i) => {
|
6727 | if (map.has(item.id)) {
|
6728 | map.delete(item.id);
|
6729 | } else {
|
6730 | appendBarrageItem(item, i);
|
6731 | }
|
6732 | });
|
6733 | map.forEach((item) => {
|
6734 | const index = barrageItems.findIndex((span) => span.dataset.id === String(item.id));
|
6735 | if (index > -1) {
|
6736 | barrageItems[index].remove();
|
6737 | barrageItems.splice(index, 1);
|
6738 | }
|
6739 | });
|
6740 | isInitBarrage.value = false;
|
6741 | };
|
6742 | vue.watch(() => props2.modelValue.slice(), (newValue, oldValue) => updateBarrages(newValue != null ? newValue : [], oldValue != null ? oldValue : []), {
|
6743 | deep: true
|
6744 | });
|
6745 | const rootStyle = vue.ref({});
|
6746 | vue.onMounted(() => __async(this, null, function* () {
|
6747 | var _a;
|
6748 | rootStyle.value["--move-distance"] = `-${(_a = barrageWrapper.value) == null ? void 0 : _a.offsetWidth}px`;
|
6749 | yield vue.nextTick();
|
6750 | updateBarrages(props2.modelValue, []);
|
6751 | }));
|
6752 | const play = () => {
|
6753 | isPlay.value = true;
|
6754 | barrageItems.forEach((item) => {
|
6755 | item.style.animationPlayState = "running";
|
6756 | });
|
6757 | };
|
6758 | const pause = () => {
|
6759 | isPlay.value = false;
|
6760 | barrageItems.forEach((item) => {
|
6761 | item.style.animationPlayState = "paused";
|
6762 | });
|
6763 | };
|
6764 | useExpose({
|
6765 | play,
|
6766 | pause
|
6767 | });
|
6768 | return () => {
|
6769 | var _a;
|
6770 | return vue.createVNode("div", {
|
6771 | "class": bem$14(),
|
6772 | "ref": barrageWrapper,
|
6773 | "style": rootStyle.value
|
6774 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
6775 | };
|
6776 | }
|
6777 | });
|
6778 | const Barrage = withInstall(stdin_default$1h);
|
6779 | const [name$17, bem$13, t$g] = createNamespace("calendar");
|
6780 | const formatMonthTitle = (date) => t$g("monthTitle", date.getFullYear(), date.getMonth() + 1);
|
6781 | function compareMonth(date1, date2) {
|
6782 | const year1 = date1.getFullYear();
|
6783 | const year2 = date2.getFullYear();
|
6784 | if (year1 === year2) {
|
6785 | const month1 = date1.getMonth();
|
6786 | const month2 = date2.getMonth();
|
6787 | return month1 === month2 ? 0 : month1 > month2 ? 1 : -1;
|
6788 | }
|
6789 | return year1 > year2 ? 1 : -1;
|
6790 | }
|
6791 | function compareDay(day1, day2) {
|
6792 | const compareMonthResult = compareMonth(day1, day2);
|
6793 | if (compareMonthResult === 0) {
|
6794 | const date1 = day1.getDate();
|
6795 | const date2 = day2.getDate();
|
6796 | return date1 === date2 ? 0 : date1 > date2 ? 1 : -1;
|
6797 | }
|
6798 | return compareMonthResult;
|
6799 | }
|
6800 | const cloneDate = (date) => new Date(date);
|
6801 | const cloneDates = (dates) => Array.isArray(dates) ? dates.map(cloneDate) : cloneDate(dates);
|
6802 | function getDayByOffset(date, offset2) {
|
6803 | const cloned = cloneDate(date);
|
6804 | cloned.setDate(cloned.getDate() + offset2);
|
6805 | return cloned;
|
6806 | }
|
6807 | function getMonthByOffset(date, offset2) {
|
6808 | const cloned = cloneDate(date);
|
6809 | cloned.setMonth(cloned.getMonth() + offset2);
|
6810 | if (cloned.getDate() !== date.getDate()) {
|
6811 | cloned.setDate(0);
|
6812 | }
|
6813 | return cloned;
|
6814 | }
|
6815 | function getYearByOffset(date, offset2) {
|
6816 | const cloned = cloneDate(date);
|
6817 | cloned.setFullYear(cloned.getFullYear() + offset2);
|
6818 | if (cloned.getDate() !== date.getDate()) {
|
6819 | cloned.setDate(0);
|
6820 | }
|
6821 | return cloned;
|
6822 | }
|
6823 | const getPrevDay = (date) => getDayByOffset(date, -1);
|
6824 | const getNextDay = (date) => getDayByOffset(date, 1);
|
6825 | const getPrevMonth = (date) => getMonthByOffset(date, -1);
|
6826 | const getNextMonth = (date) => getMonthByOffset(date, 1);
|
6827 | const getPrevYear = (date) => getYearByOffset(date, -1);
|
6828 | const getNextYear = (date) => getYearByOffset(date, 1);
|
6829 | const getToday = () => {
|
6830 | const today = new Date();
|
6831 | today.setHours(0, 0, 0, 0);
|
6832 | return today;
|
6833 | };
|
6834 | function calcDateNum(date) {
|
6835 | const day1 = date[0].getTime();
|
6836 | const day2 = date[1].getTime();
|
6837 | return (day2 - day1) / (1e3 * 60 * 60 * 24) + 1;
|
6838 | }
|
6839 | const sharedProps = extend({}, pickerSharedProps, {
|
6840 | modelValue: makeArrayProp(),
|
6841 | filter: Function,
|
6842 | formatter: {
|
6843 | type: Function,
|
6844 | default: (type, option) => option
|
6845 | }
|
6846 | });
|
6847 | const pickerInheritKeys = Object.keys(pickerSharedProps);
|
6848 | function times(n, iteratee) {
|
6849 | if (n < 0) {
|
6850 | return [];
|
6851 | }
|
6852 | const result = Array(n);
|
6853 | let index = -1;
|
6854 | while (++index < n) {
|
6855 | result[index] = iteratee(index);
|
6856 | }
|
6857 | return result;
|
6858 | }
|
6859 | const getMonthEndDay = (year, month) => 32 - new Date(year, month - 1, 32).getDate();
|
6860 | const genOptions = (min, max, type, formatter, filter, values) => {
|
6861 | const options = times(max - min + 1, (index) => {
|
6862 | const value = padZero(min + index);
|
6863 | return formatter(type, {
|
6864 | text: value,
|
6865 | value
|
6866 | });
|
6867 | });
|
6868 | return filter ? filter(type, options, values) : options;
|
6869 | };
|
6870 | const formatValueRange = (values, columns) => values.map((value, index) => {
|
6871 | const column = columns[index];
|
6872 | if (column.length) {
|
6873 | const minValue = +column[0].value;
|
6874 | const maxValue = +column[column.length - 1].value;
|
6875 | return padZero(clamp(+value, minValue, maxValue));
|
6876 | }
|
6877 | return value;
|
6878 | });
|
6879 | const [name$16] = createNamespace("calendar-day");
|
6880 | var stdin_default$1g = vue.defineComponent({
|
6881 | name: name$16,
|
6882 | props: {
|
6883 | item: makeRequiredProp(Object),
|
6884 | color: String,
|
6885 | index: Number,
|
6886 | offset: makeNumberProp(0),
|
6887 | rowHeight: String
|
6888 | },
|
6889 | emits: ["click", "clickDisabledDate"],
|
6890 | setup(props2, {
|
6891 | emit,
|
6892 | slots
|
6893 | }) {
|
6894 | const style = vue.computed(() => {
|
6895 | var _a;
|
6896 | const {
|
6897 | item,
|
6898 | index,
|
6899 | color,
|
6900 | offset: offset2,
|
6901 | rowHeight
|
6902 | } = props2;
|
6903 | const style2 = {
|
6904 | height: rowHeight
|
6905 | };
|
6906 | if (item.type === "placeholder") {
|
6907 | style2.width = "100%";
|
6908 | return style2;
|
6909 | }
|
6910 | if (index === 0) {
|
6911 | style2.marginLeft = `${100 * offset2 / 7}%`;
|
6912 | }
|
6913 | if (color) {
|
6914 | switch (item.type) {
|
6915 | case "end":
|
6916 | case "start":
|
6917 | case "start-end":
|
6918 | case "multiple-middle":
|
6919 | case "multiple-selected":
|
6920 | style2.background = color;
|
6921 | break;
|
6922 | case "middle":
|
6923 | style2.color = color;
|
6924 | break;
|
6925 | }
|
6926 | }
|
6927 | if (offset2 + (((_a = item.date) == null ? void 0 : _a.getDate()) || 1) > 28) {
|
6928 | style2.marginBottom = 0;
|
6929 | }
|
6930 | return style2;
|
6931 | });
|
6932 | const onClick = () => {
|
6933 | if (props2.item.type !== "disabled") {
|
6934 | emit("click", props2.item);
|
6935 | } else {
|
6936 | emit("clickDisabledDate", props2.item);
|
6937 | }
|
6938 | };
|
6939 | const renderTopInfo = () => {
|
6940 | const {
|
6941 | topInfo
|
6942 | } = props2.item;
|
6943 | if (topInfo || slots["top-info"]) {
|
6944 | return vue.createVNode("div", {
|
6945 | "class": bem$13("top-info")
|
6946 | }, [slots["top-info"] ? slots["top-info"](props2.item) : topInfo]);
|
6947 | }
|
6948 | };
|
6949 | const renderBottomInfo = () => {
|
6950 | const {
|
6951 | bottomInfo
|
6952 | } = props2.item;
|
6953 | if (bottomInfo || slots["bottom-info"]) {
|
6954 | return vue.createVNode("div", {
|
6955 | "class": bem$13("bottom-info")
|
6956 | }, [slots["bottom-info"] ? slots["bottom-info"](props2.item) : bottomInfo]);
|
6957 | }
|
6958 | };
|
6959 | const renderText = () => {
|
6960 | return slots.text ? slots.text(props2.item) : props2.item.text;
|
6961 | };
|
6962 | const renderContent = () => {
|
6963 | const {
|
6964 | item,
|
6965 | color,
|
6966 | rowHeight
|
6967 | } = props2;
|
6968 | const {
|
6969 | type
|
6970 | } = item;
|
6971 | const Nodes = [renderTopInfo(), renderText(), renderBottomInfo()];
|
6972 | if (type === "selected") {
|
6973 | return vue.createVNode("div", {
|
6974 | "class": bem$13("selected-day"),
|
6975 | "style": {
|
6976 | width: rowHeight,
|
6977 | height: rowHeight,
|
6978 | background: color
|
6979 | }
|
6980 | }, [Nodes]);
|
6981 | }
|
6982 | return Nodes;
|
6983 | };
|
6984 | return () => {
|
6985 | const {
|
6986 | type,
|
6987 | className
|
6988 | } = props2.item;
|
6989 | if (type === "placeholder") {
|
6990 | return vue.createVNode("div", {
|
6991 | "class": bem$13("day"),
|
6992 | "style": style.value
|
6993 | }, null);
|
6994 | }
|
6995 | return vue.createVNode("div", {
|
6996 | "role": "gridcell",
|
6997 | "style": style.value,
|
6998 | "class": [bem$13("day", type), className],
|
6999 | "tabindex": type === "disabled" ? void 0 : -1,
|
7000 | "onClick": onClick
|
7001 | }, [renderContent()]);
|
7002 | };
|
7003 | }
|
7004 | });
|
7005 | const [name$15] = createNamespace("calendar-month");
|
7006 | const calendarMonthProps = {
|
7007 | date: makeRequiredProp(Date),
|
7008 | type: String,
|
7009 | color: String,
|
7010 | minDate: Date,
|
7011 | maxDate: Date,
|
7012 | showMark: Boolean,
|
7013 | rowHeight: numericProp,
|
7014 | formatter: Function,
|
7015 | lazyRender: Boolean,
|
7016 | currentDate: [Date, Array],
|
7017 | allowSameDay: Boolean,
|
7018 | showSubtitle: Boolean,
|
7019 | showMonthTitle: Boolean,
|
7020 | firstDayOfWeek: Number
|
7021 | };
|
7022 | var stdin_default$1f = vue.defineComponent({
|
7023 | name: name$15,
|
7024 | props: calendarMonthProps,
|
7025 | emits: ["click", "clickDisabledDate"],
|
7026 | setup(props2, {
|
7027 | emit,
|
7028 | slots
|
7029 | }) {
|
7030 | const [visible, setVisible] = useToggle();
|
7031 | const daysRef = vue.ref();
|
7032 | const monthRef = vue.ref();
|
7033 | const height2 = useHeight(monthRef);
|
7034 | const title = vue.computed(() => formatMonthTitle(props2.date));
|
7035 | const rowHeight = vue.computed(() => addUnit(props2.rowHeight));
|
7036 | const offset2 = vue.computed(() => {
|
7037 | const date = props2.date.getDate();
|
7038 | const day = props2.date.getDay();
|
7039 | const realDay = (day - date % 7 + 8) % 7;
|
7040 | if (props2.firstDayOfWeek) {
|
7041 | return (realDay + 7 - props2.firstDayOfWeek) % 7;
|
7042 | }
|
7043 | return realDay;
|
7044 | });
|
7045 | const totalDay = vue.computed(() => getMonthEndDay(props2.date.getFullYear(), props2.date.getMonth() + 1));
|
7046 | const shouldRender = vue.computed(() => visible.value || !props2.lazyRender);
|
7047 | const getTitle = () => title.value;
|
7048 | const getMultipleDayType = (day) => {
|
7049 | const isSelected = (date) => props2.currentDate.some((item) => compareDay(item, date) === 0);
|
7050 | if (isSelected(day)) {
|
7051 | const prevDay = getPrevDay(day);
|
7052 | const nextDay = getNextDay(day);
|
7053 | const prevSelected = isSelected(prevDay);
|
7054 | const nextSelected = isSelected(nextDay);
|
7055 | if (prevSelected && nextSelected) {
|
7056 | return "multiple-middle";
|
7057 | }
|
7058 | if (prevSelected) {
|
7059 | return "end";
|
7060 | }
|
7061 | if (nextSelected) {
|
7062 | return "start";
|
7063 | }
|
7064 | return "multiple-selected";
|
7065 | }
|
7066 | return "";
|
7067 | };
|
7068 | const getRangeDayType = (day) => {
|
7069 | const [startDay, endDay] = props2.currentDate;
|
7070 | if (!startDay) {
|
7071 | return "";
|
7072 | }
|
7073 | const compareToStart = compareDay(day, startDay);
|
7074 | if (!endDay) {
|
7075 | return compareToStart === 0 ? "start" : "";
|
7076 | }
|
7077 | const compareToEnd = compareDay(day, endDay);
|
7078 | if (props2.allowSameDay && compareToStart === 0 && compareToEnd === 0) {
|
7079 | return "start-end";
|
7080 | }
|
7081 | if (compareToStart === 0) {
|
7082 | return "start";
|
7083 | }
|
7084 | if (compareToEnd === 0) {
|
7085 | return "end";
|
7086 | }
|
7087 | if (compareToStart > 0 && compareToEnd < 0) {
|
7088 | return "middle";
|
7089 | }
|
7090 | return "";
|
7091 | };
|
7092 | const getDayType = (day) => {
|
7093 | const {
|
7094 | type,
|
7095 | minDate,
|
7096 | maxDate,
|
7097 | currentDate
|
7098 | } = props2;
|
7099 | if (minDate && compareDay(day, minDate) < 0 || maxDate && compareDay(day, maxDate) > 0) {
|
7100 | return "disabled";
|
7101 | }
|
7102 | if (currentDate === null) {
|
7103 | return "";
|
7104 | }
|
7105 | if (Array.isArray(currentDate)) {
|
7106 | if (type === "multiple") {
|
7107 | return getMultipleDayType(day);
|
7108 | }
|
7109 | if (type === "range") {
|
7110 | return getRangeDayType(day);
|
7111 | }
|
7112 | } else if (type === "single") {
|
7113 | return compareDay(day, currentDate) === 0 ? "selected" : "";
|
7114 | }
|
7115 | return "";
|
7116 | };
|
7117 | const getBottomInfo = (dayType) => {
|
7118 | if (props2.type === "range") {
|
7119 | if (dayType === "start" || dayType === "end") {
|
7120 | return t$g(dayType);
|
7121 | }
|
7122 | if (dayType === "start-end") {
|
7123 | return `${t$g("start")}/${t$g("end")}`;
|
7124 | }
|
7125 | }
|
7126 | };
|
7127 | const renderTitle = () => {
|
7128 | if (props2.showMonthTitle) {
|
7129 | return vue.createVNode("div", {
|
7130 | "class": bem$13("month-title")
|
7131 | }, [slots["month-title"] ? slots["month-title"]({
|
7132 | date: props2.date,
|
7133 | text: title.value
|
7134 | }) : title.value]);
|
7135 | }
|
7136 | };
|
7137 | const renderMark = () => {
|
7138 | if (props2.showMark && shouldRender.value) {
|
7139 | return vue.createVNode("div", {
|
7140 | "class": bem$13("month-mark")
|
7141 | }, [props2.date.getMonth() + 1]);
|
7142 | }
|
7143 | };
|
7144 | const placeholders = vue.computed(() => {
|
7145 | const count = Math.ceil((totalDay.value + offset2.value) / 7);
|
7146 | return Array(count).fill({
|
7147 | type: "placeholder"
|
7148 | });
|
7149 | });
|
7150 | const days = vue.computed(() => {
|
7151 | const days2 = [];
|
7152 | const year = props2.date.getFullYear();
|
7153 | const month = props2.date.getMonth();
|
7154 | for (let day = 1; day <= totalDay.value; day++) {
|
7155 | const date = new Date(year, month, day);
|
7156 | const type = getDayType(date);
|
7157 | let config = {
|
7158 | date,
|
7159 | type,
|
7160 | text: day,
|
7161 | bottomInfo: getBottomInfo(type)
|
7162 | };
|
7163 | if (props2.formatter) {
|
7164 | config = props2.formatter(config);
|
7165 | }
|
7166 | days2.push(config);
|
7167 | }
|
7168 | return days2;
|
7169 | });
|
7170 | const disabledDays = vue.computed(() => days.value.filter((day) => day.type === "disabled"));
|
7171 | const scrollToDate = (body, targetDate) => {
|
7172 | if (daysRef.value) {
|
7173 | const daysRect = useRect(daysRef.value);
|
7174 | const totalRows = placeholders.value.length;
|
7175 | const currentRow = Math.ceil((targetDate.getDate() + offset2.value) / 7);
|
7176 | const rowOffset = (currentRow - 1) * daysRect.height / totalRows;
|
7177 | setScrollTop(body, daysRect.top + rowOffset + body.scrollTop - useRect(body).top);
|
7178 | }
|
7179 | };
|
7180 | const renderDay = (item, index) => vue.createVNode(stdin_default$1g, {
|
7181 | "item": item,
|
7182 | "index": index,
|
7183 | "color": props2.color,
|
7184 | "offset": offset2.value,
|
7185 | "rowHeight": rowHeight.value,
|
7186 | "onClick": (item2) => emit("click", item2),
|
7187 | "onClickDisabledDate": (item2) => emit("clickDisabledDate", item2)
|
7188 | }, pick(slots, ["top-info", "bottom-info", "text"]));
|
7189 | const renderDays = () => vue.createVNode("div", {
|
7190 | "ref": daysRef,
|
7191 | "role": "grid",
|
7192 | "class": bem$13("days")
|
7193 | }, [renderMark(), (shouldRender.value ? days : placeholders).value.map(renderDay)]);
|
7194 | useExpose({
|
7195 | getTitle,
|
7196 | getHeight: () => height2.value,
|
7197 | setVisible,
|
7198 | scrollToDate,
|
7199 | disabledDays
|
7200 | });
|
7201 | return () => vue.createVNode("div", {
|
7202 | "class": bem$13("month"),
|
7203 | "ref": monthRef
|
7204 | }, [renderTitle(), renderDays()]);
|
7205 | }
|
7206 | });
|
7207 | const [name$14] = createNamespace("calendar-header");
|
7208 | var stdin_default$1e = vue.defineComponent({
|
7209 | name: name$14,
|
7210 | props: {
|
7211 | date: Date,
|
7212 | minDate: Date,
|
7213 | maxDate: Date,
|
7214 | title: String,
|
7215 | subtitle: String,
|
7216 | showTitle: Boolean,
|
7217 | showSubtitle: Boolean,
|
7218 | firstDayOfWeek: Number,
|
7219 | switchMode: makeStringProp("none")
|
7220 | },
|
7221 | emits: ["clickSubtitle", "panelChange"],
|
7222 | setup(props2, {
|
7223 | slots,
|
7224 | emit
|
7225 | }) {
|
7226 | const prevMonthDisabled = vue.computed(() => props2.date && props2.minDate && compareMonth(getPrevMonth(props2.date), props2.minDate) < 0);
|
7227 | const prevYearDisabled = vue.computed(() => props2.date && props2.minDate && compareMonth(getPrevYear(props2.date), props2.minDate) < 0);
|
7228 | const nextMonthDisabled = vue.computed(() => props2.date && props2.maxDate && compareMonth(getNextMonth(props2.date), props2.maxDate) > 0);
|
7229 | const nextYearDisabled = vue.computed(() => props2.date && props2.maxDate && compareMonth(getNextYear(props2.date), props2.maxDate) > 0);
|
7230 | const renderTitle = () => {
|
7231 | if (props2.showTitle) {
|
7232 | const text = props2.title || t$g("title");
|
7233 | const title = slots.title ? slots.title() : text;
|
7234 | return vue.createVNode("div", {
|
7235 | "class": bem$13("header-title")
|
7236 | }, [title]);
|
7237 | }
|
7238 | };
|
7239 | const onClickSubtitle = (event) => emit("clickSubtitle", event);
|
7240 | const onPanelChange = (date) => emit("panelChange", date);
|
7241 | const renderAction = (isNext) => {
|
7242 | const showYearAction = props2.switchMode === "year-month";
|
7243 | const monthSlot = slots[isNext ? "next-month" : "prev-month"];
|
7244 | const yearSlot = slots[isNext ? "next-year" : "prev-year"];
|
7245 | const monthDisabled = isNext ? nextMonthDisabled.value : prevMonthDisabled.value;
|
7246 | const yearDisabled = isNext ? nextYearDisabled.value : prevYearDisabled.value;
|
7247 | const monthIconName = isNext ? "arrow" : "arrow-left";
|
7248 | const yearIconName = isNext ? "arrow-double-right" : "arrow-double-left";
|
7249 | const onMonthChange = () => onPanelChange((isNext ? getNextMonth : getPrevMonth)(props2.date));
|
7250 | const onYearChange = () => onPanelChange((isNext ? getNextYear : getPrevYear)(props2.date));
|
7251 | const MonthAction = vue.createVNode("view", {
|
7252 | "class": bem$13("header-action", {
|
7253 | disabled: monthDisabled
|
7254 | }),
|
7255 | "onClick": monthDisabled ? void 0 : onMonthChange
|
7256 | }, [monthSlot ? monthSlot({
|
7257 | disabled: monthDisabled
|
7258 | }) : vue.createVNode(Icon, {
|
7259 | "class": {
|
7260 | [HAPTICS_FEEDBACK]: !monthDisabled
|
7261 | },
|
7262 | "name": monthIconName
|
7263 | }, null)]);
|
7264 | const YearAction = showYearAction && vue.createVNode("view", {
|
7265 | "class": bem$13("header-action", {
|
7266 | disabled: yearDisabled
|
7267 | }),
|
7268 | "onClick": yearDisabled ? void 0 : onYearChange
|
7269 | }, [yearSlot ? yearSlot({
|
7270 | disabled: yearDisabled
|
7271 | }) : vue.createVNode(Icon, {
|
7272 | "class": {
|
7273 | [HAPTICS_FEEDBACK]: !yearDisabled
|
7274 | },
|
7275 | "name": yearIconName
|
7276 | }, null)]);
|
7277 | return isNext ? [MonthAction, YearAction] : [YearAction, MonthAction];
|
7278 | };
|
7279 | const renderSubtitle = () => {
|
7280 | if (props2.showSubtitle) {
|
7281 | const title = slots.subtitle ? slots.subtitle({
|
7282 | date: props2.date,
|
7283 | text: props2.subtitle
|
7284 | }) : props2.subtitle;
|
7285 | const canSwitch = props2.switchMode !== "none";
|
7286 | return vue.createVNode("div", {
|
7287 | "class": bem$13("header-subtitle", {
|
7288 | "with-swicth": canSwitch
|
7289 | }),
|
7290 | "onClick": onClickSubtitle
|
7291 | }, [canSwitch ? [renderAction(), vue.createVNode("div", {
|
7292 | "class": bem$13("header-subtitle-text")
|
7293 | }, [title]), renderAction(true)] : title]);
|
7294 | }
|
7295 | };
|
7296 | const renderWeekDays = () => {
|
7297 | const {
|
7298 | firstDayOfWeek
|
7299 | } = props2;
|
7300 | const weekdays = t$g("weekdays");
|
7301 | const renderWeekDays2 = [...weekdays.slice(firstDayOfWeek, 7), ...weekdays.slice(0, firstDayOfWeek)];
|
7302 | return vue.createVNode("div", {
|
7303 | "class": bem$13("weekdays")
|
7304 | }, [renderWeekDays2.map((text) => vue.createVNode("span", {
|
7305 | "class": bem$13("weekday")
|
7306 | }, [text]))]);
|
7307 | };
|
7308 | return () => vue.createVNode("div", {
|
7309 | "class": bem$13("header")
|
7310 | }, [renderTitle(), renderSubtitle(), renderWeekDays()]);
|
7311 | }
|
7312 | });
|
7313 | const calendarProps = {
|
7314 | show: Boolean,
|
7315 | type: makeStringProp("single"),
|
7316 | switchMode: makeStringProp("none"),
|
7317 | title: String,
|
7318 | color: String,
|
7319 | round: truthProp,
|
7320 | readonly: Boolean,
|
7321 | poppable: truthProp,
|
7322 | maxRange: makeNumericProp(null),
|
7323 | position: makeStringProp("bottom"),
|
7324 | teleport: [String, Object],
|
7325 | showMark: truthProp,
|
7326 | showTitle: truthProp,
|
7327 | formatter: Function,
|
7328 | rowHeight: numericProp,
|
7329 | confirmText: String,
|
7330 | rangePrompt: String,
|
7331 | lazyRender: truthProp,
|
7332 | showConfirm: truthProp,
|
7333 | defaultDate: [Date, Array],
|
7334 | allowSameDay: Boolean,
|
7335 | showSubtitle: truthProp,
|
7336 | closeOnPopstate: truthProp,
|
7337 | showRangePrompt: truthProp,
|
7338 | confirmDisabledText: String,
|
7339 | closeOnClickOverlay: truthProp,
|
7340 | safeAreaInsetTop: Boolean,
|
7341 | safeAreaInsetBottom: truthProp,
|
7342 | minDate: {
|
7343 | type: Date,
|
7344 | validator: isDate
|
7345 | },
|
7346 | maxDate: {
|
7347 | type: Date,
|
7348 | validator: isDate
|
7349 | },
|
7350 | firstDayOfWeek: {
|
7351 | type: numericProp,
|
7352 | default: 0,
|
7353 | validator: (val) => val >= 0 && val <= 6
|
7354 | }
|
7355 | };
|
7356 | var stdin_default$1d = vue.defineComponent({
|
7357 | name: name$17,
|
7358 | props: calendarProps,
|
7359 | emits: ["select", "confirm", "unselect", "monthShow", "overRange", "update:show", "clickSubtitle", "clickDisabledDate", "panelChange"],
|
7360 | setup(props2, {
|
7361 | emit,
|
7362 | slots
|
7363 | }) {
|
7364 | const canSwitch = vue.computed(() => props2.switchMode !== "none");
|
7365 | const minDate = vue.computed(() => {
|
7366 | if (!props2.minDate && !canSwitch.value) {
|
7367 | return getToday();
|
7368 | }
|
7369 | return props2.minDate;
|
7370 | });
|
7371 | const maxDate = vue.computed(() => {
|
7372 | if (!props2.maxDate && !canSwitch.value) {
|
7373 | return getMonthByOffset(getToday(), 6);
|
7374 | }
|
7375 | return props2.maxDate;
|
7376 | });
|
7377 | const limitDateRange = (date, min = minDate.value, max = maxDate.value) => {
|
7378 | if (min && compareDay(date, min) === -1) {
|
7379 | return min;
|
7380 | }
|
7381 | if (max && compareDay(date, max) === 1) {
|
7382 | return max;
|
7383 | }
|
7384 | return date;
|
7385 | };
|
7386 | const getInitialDate = (defaultDate = props2.defaultDate) => {
|
7387 | const {
|
7388 | type,
|
7389 | allowSameDay
|
7390 | } = props2;
|
7391 | if (defaultDate === null) {
|
7392 | return defaultDate;
|
7393 | }
|
7394 | const now = getToday();
|
7395 | if (type === "range") {
|
7396 | if (!Array.isArray(defaultDate)) {
|
7397 | defaultDate = [];
|
7398 | }
|
7399 | if (defaultDate.length === 1 && compareDay(defaultDate[0], now) === 1) {
|
7400 | defaultDate = [];
|
7401 | }
|
7402 | const min = minDate.value;
|
7403 | const max = maxDate.value;
|
7404 | const start2 = limitDateRange(defaultDate[0] || now, min, max ? allowSameDay ? max : getPrevDay(max) : void 0);
|
7405 | const end2 = limitDateRange(defaultDate[1] || (allowSameDay ? now : getNextDay(now)), min ? allowSameDay ? min : getNextDay(min) : void 0);
|
7406 | return [start2, end2];
|
7407 | }
|
7408 | if (type === "multiple") {
|
7409 | if (Array.isArray(defaultDate)) {
|
7410 | return defaultDate.map((date) => limitDateRange(date));
|
7411 | }
|
7412 | return [limitDateRange(now)];
|
7413 | }
|
7414 | if (!defaultDate || Array.isArray(defaultDate)) {
|
7415 | defaultDate = now;
|
7416 | }
|
7417 | return limitDateRange(defaultDate);
|
7418 | };
|
7419 | const getInitialPanelDate = () => {
|
7420 | const date = Array.isArray(currentDate.value) ? currentDate.value[0] : currentDate.value;
|
7421 | return date ? date : limitDateRange(getToday());
|
7422 | };
|
7423 | let bodyHeight;
|
7424 | const bodyRef = vue.ref();
|
7425 | const currentDate = vue.ref(getInitialDate());
|
7426 | const currentPanelDate = vue.ref(getInitialPanelDate());
|
7427 | const currentMonthRef = vue.ref();
|
7428 | const [monthRefs, setMonthRefs] = useRefs();
|
7429 | const dayOffset = vue.computed(() => props2.firstDayOfWeek ? +props2.firstDayOfWeek % 7 : 0);
|
7430 | const months = vue.computed(() => {
|
7431 | const months2 = [];
|
7432 | if (!minDate.value || !maxDate.value) {
|
7433 | return months2;
|
7434 | }
|
7435 | const cursor = new Date(minDate.value);
|
7436 | cursor.setDate(1);
|
7437 | do {
|
7438 | months2.push(new Date(cursor));
|
7439 | cursor.setMonth(cursor.getMonth() + 1);
|
7440 | } while (compareMonth(cursor, maxDate.value) !== 1);
|
7441 | return months2;
|
7442 | });
|
7443 | const buttonDisabled = vue.computed(() => {
|
7444 | if (currentDate.value) {
|
7445 | if (props2.type === "range") {
|
7446 | return !currentDate.value[0] || !currentDate.value[1];
|
7447 | }
|
7448 | if (props2.type === "multiple") {
|
7449 | return !currentDate.value.length;
|
7450 | }
|
7451 | }
|
7452 | return !currentDate.value;
|
7453 | });
|
7454 | const getSelectedDate = () => currentDate.value;
|
7455 | const onScroll = () => {
|
7456 | const top2 = getScrollTop(bodyRef.value);
|
7457 | const bottom2 = top2 + bodyHeight;
|
7458 | const heights = months.value.map((item, index) => monthRefs.value[index].getHeight());
|
7459 | const heightSum = heights.reduce((a, b) => a + b, 0);
|
7460 | if (bottom2 > heightSum && top2 > 0) {
|
7461 | return;
|
7462 | }
|
7463 | let height2 = 0;
|
7464 | let currentMonth;
|
7465 | const visibleRange = [-1, -1];
|
7466 | for (let i = 0; i < months.value.length; i++) {
|
7467 | const month = monthRefs.value[i];
|
7468 | const visible = height2 <= bottom2 && height2 + heights[i] >= top2;
|
7469 | if (visible) {
|
7470 | visibleRange[1] = i;
|
7471 | if (!currentMonth) {
|
7472 | currentMonth = month;
|
7473 | visibleRange[0] = i;
|
7474 | }
|
7475 | if (!monthRefs.value[i].showed) {
|
7476 | monthRefs.value[i].showed = true;
|
7477 | emit("monthShow", {
|
7478 | date: month.date,
|
7479 | title: month.getTitle()
|
7480 | });
|
7481 | }
|
7482 | }
|
7483 | height2 += heights[i];
|
7484 | }
|
7485 | months.value.forEach((month, index) => {
|
7486 | const visible = index >= visibleRange[0] - 1 && index <= visibleRange[1] + 1;
|
7487 | monthRefs.value[index].setVisible(visible);
|
7488 | });
|
7489 | if (currentMonth) {
|
7490 | currentMonthRef.value = currentMonth;
|
7491 | }
|
7492 | };
|
7493 | const scrollToDate = (targetDate) => {
|
7494 | if (canSwitch.value) {
|
7495 | currentPanelDate.value = targetDate;
|
7496 | } else {
|
7497 | raf(() => {
|
7498 | months.value.some((month, index) => {
|
7499 | if (compareMonth(month, targetDate) === 0) {
|
7500 | if (bodyRef.value) {
|
7501 | monthRefs.value[index].scrollToDate(bodyRef.value, targetDate);
|
7502 | }
|
7503 | return true;
|
7504 | }
|
7505 | return false;
|
7506 | });
|
7507 | onScroll();
|
7508 | });
|
7509 | }
|
7510 | };
|
7511 | const scrollToCurrentDate = () => {
|
7512 | if (props2.poppable && !props2.show) {
|
7513 | return;
|
7514 | }
|
7515 | if (currentDate.value) {
|
7516 | const targetDate = props2.type === "single" ? currentDate.value : currentDate.value[0];
|
7517 | if (isDate(targetDate)) {
|
7518 | scrollToDate(targetDate);
|
7519 | }
|
7520 | } else if (!canSwitch.value) {
|
7521 | raf(onScroll);
|
7522 | }
|
7523 | };
|
7524 | const init = () => {
|
7525 | if (props2.poppable && !props2.show) {
|
7526 | return;
|
7527 | }
|
7528 | if (!canSwitch.value) {
|
7529 | raf(() => {
|
7530 | bodyHeight = Math.floor(useRect(bodyRef).height);
|
7531 | });
|
7532 | }
|
7533 | scrollToCurrentDate();
|
7534 | };
|
7535 | const reset = (date = getInitialDate()) => {
|
7536 | currentDate.value = date;
|
7537 | scrollToCurrentDate();
|
7538 | };
|
7539 | const checkRange = (date) => {
|
7540 | const {
|
7541 | maxRange,
|
7542 | rangePrompt,
|
7543 | showRangePrompt
|
7544 | } = props2;
|
7545 | if (maxRange && calcDateNum(date) > +maxRange) {
|
7546 | if (showRangePrompt) {
|
7547 | showToast(rangePrompt || t$g("rangePrompt", maxRange));
|
7548 | }
|
7549 | emit("overRange");
|
7550 | return false;
|
7551 | }
|
7552 | return true;
|
7553 | };
|
7554 | const onPanelChange = (date) => {
|
7555 | currentPanelDate.value = date;
|
7556 | emit("panelChange", {
|
7557 | date
|
7558 | });
|
7559 | };
|
7560 | const onConfirm = () => {
|
7561 | var _a;
|
7562 | return emit("confirm", (_a = currentDate.value) != null ? _a : cloneDates(currentDate.value));
|
7563 | };
|
7564 | const select = (date, complete) => {
|
7565 | const setCurrentDate = (date2) => {
|
7566 | currentDate.value = date2;
|
7567 | emit("select", cloneDates(date2));
|
7568 | };
|
7569 | if (complete && props2.type === "range") {
|
7570 | const valid = checkRange(date);
|
7571 | if (!valid) {
|
7572 | setCurrentDate([date[0], getDayByOffset(date[0], +props2.maxRange - 1)]);
|
7573 | return;
|
7574 | }
|
7575 | }
|
7576 | setCurrentDate(date);
|
7577 | if (complete && !props2.showConfirm) {
|
7578 | onConfirm();
|
7579 | }
|
7580 | };
|
7581 | const getDisabledDate = (disabledDays2, startDay, date) => {
|
7582 | var _a;
|
7583 | return (_a = disabledDays2.find((day) => compareDay(startDay, day.date) === -1 && compareDay(day.date, date) === -1)) == null ? void 0 : _a.date;
|
7584 | };
|
7585 | const disabledDays = vue.computed(() => monthRefs.value.reduce((arr, ref2) => {
|
7586 | var _a, _b;
|
7587 | arr.push(...(_b = (_a = ref2.disabledDays) == null ? void 0 : _a.value) != null ? _b : []);
|
7588 | return arr;
|
7589 | }, []));
|
7590 | const onClickDay = (item) => {
|
7591 | if (props2.readonly || !item.date) {
|
7592 | return;
|
7593 | }
|
7594 | const {
|
7595 | date
|
7596 | } = item;
|
7597 | const {
|
7598 | type
|
7599 | } = props2;
|
7600 | if (type === "range") {
|
7601 | if (!currentDate.value) {
|
7602 | select([date]);
|
7603 | return;
|
7604 | }
|
7605 | const [startDay, endDay] = currentDate.value;
|
7606 | if (startDay && !endDay) {
|
7607 | const compareToStart = compareDay(date, startDay);
|
7608 | if (compareToStart === 1) {
|
7609 | const disabledDay = getDisabledDate(disabledDays.value, startDay, date);
|
7610 | if (disabledDay) {
|
7611 | const endDay2 = getPrevDay(disabledDay);
|
7612 | if (compareDay(startDay, endDay2) === -1) {
|
7613 | select([startDay, endDay2]);
|
7614 | } else {
|
7615 | select([date]);
|
7616 | }
|
7617 | } else {
|
7618 | select([startDay, date], true);
|
7619 | }
|
7620 | } else if (compareToStart === -1) {
|
7621 | select([date]);
|
7622 | } else if (props2.allowSameDay) {
|
7623 | select([date, date], true);
|
7624 | }
|
7625 | } else {
|
7626 | select([date]);
|
7627 | }
|
7628 | } else if (type === "multiple") {
|
7629 | if (!currentDate.value) {
|
7630 | select([date]);
|
7631 | return;
|
7632 | }
|
7633 | const dates = currentDate.value;
|
7634 | const selectedIndex = dates.findIndex((dateItem) => compareDay(dateItem, date) === 0);
|
7635 | if (selectedIndex !== -1) {
|
7636 | const [unselectedDate] = dates.splice(selectedIndex, 1);
|
7637 | emit("unselect", cloneDate(unselectedDate));
|
7638 | } else if (props2.maxRange && dates.length >= +props2.maxRange) {
|
7639 | showToast(props2.rangePrompt || t$g("rangePrompt", props2.maxRange));
|
7640 | } else {
|
7641 | select([...dates, date]);
|
7642 | }
|
7643 | } else {
|
7644 | select(date, true);
|
7645 | }
|
7646 | };
|
7647 | const updateShow = (value) => emit("update:show", value);
|
7648 | const renderMonth = (date, index) => {
|
7649 | const showMonthTitle = index !== 0 || !props2.showSubtitle;
|
7650 | return vue.createVNode(stdin_default$1f, vue.mergeProps({
|
7651 | "ref": canSwitch.value ? currentMonthRef : setMonthRefs(index),
|
7652 | "date": date,
|
7653 | "currentDate": currentDate.value,
|
7654 | "showMonthTitle": showMonthTitle,
|
7655 | "firstDayOfWeek": dayOffset.value,
|
7656 | "lazyRender": canSwitch.value ? false : props2.lazyRender,
|
7657 | "maxDate": maxDate.value,
|
7658 | "minDate": minDate.value
|
7659 | }, pick(props2, ["type", "color", "showMark", "formatter", "rowHeight", "showSubtitle", "allowSameDay"]), {
|
7660 | "onClick": onClickDay,
|
7661 | "onClickDisabledDate": (item) => emit("clickDisabledDate", item)
|
7662 | }), pick(slots, ["top-info", "bottom-info", "month-title", "text"]));
|
7663 | };
|
7664 | const renderFooterButton = () => {
|
7665 | if (slots.footer) {
|
7666 | return slots.footer();
|
7667 | }
|
7668 | if (props2.showConfirm) {
|
7669 | const slot = slots["confirm-text"];
|
7670 | const disabled = buttonDisabled.value;
|
7671 | const text = disabled ? props2.confirmDisabledText : props2.confirmText;
|
7672 | return vue.createVNode(Button, {
|
7673 | "round": true,
|
7674 | "block": true,
|
7675 | "type": "primary",
|
7676 | "color": props2.color,
|
7677 | "class": bem$13("confirm"),
|
7678 | "disabled": disabled,
|
7679 | "nativeType": "button",
|
7680 | "onClick": onConfirm
|
7681 | }, {
|
7682 | default: () => [slot ? slot({
|
7683 | disabled
|
7684 | }) : text || t$g("confirm")]
|
7685 | });
|
7686 | }
|
7687 | };
|
7688 | const renderFooter = () => vue.createVNode("div", {
|
7689 | "class": [bem$13("footer"), {
|
7690 | "van-safe-area-bottom": props2.safeAreaInsetBottom
|
7691 | }]
|
7692 | }, [renderFooterButton()]);
|
7693 | const renderCalendar = () => {
|
7694 | var _a, _b;
|
7695 | return vue.createVNode("div", {
|
7696 | "class": bem$13()
|
7697 | }, [vue.createVNode(stdin_default$1e, {
|
7698 | "date": (_a = currentMonthRef.value) == null ? void 0 : _a.date,
|
7699 | "maxDate": maxDate.value,
|
7700 | "minDate": minDate.value,
|
7701 | "title": props2.title,
|
7702 | "subtitle": (_b = currentMonthRef.value) == null ? void 0 : _b.getTitle(),
|
7703 | "showTitle": props2.showTitle,
|
7704 | "showSubtitle": props2.showSubtitle,
|
7705 | "switchMode": props2.switchMode,
|
7706 | "firstDayOfWeek": dayOffset.value,
|
7707 | "onClickSubtitle": (event) => emit("clickSubtitle", event),
|
7708 | "onPanelChange": onPanelChange
|
7709 | }, pick(slots, ["title", "subtitle", "prev-month", "prev-year", "next-month", "next-year"])), vue.createVNode("div", {
|
7710 | "ref": bodyRef,
|
7711 | "class": bem$13("body"),
|
7712 | "onScroll": canSwitch.value ? void 0 : onScroll
|
7713 | }, [canSwitch.value ? renderMonth(currentPanelDate.value, 0) : months.value.map(renderMonth)]), renderFooter()]);
|
7714 | };
|
7715 | vue.watch(() => props2.show, init);
|
7716 | vue.watch(() => [props2.type, props2.minDate, props2.maxDate, props2.switchMode], () => reset(getInitialDate(currentDate.value)));
|
7717 | vue.watch(() => props2.defaultDate, (value) => {
|
7718 | reset(value);
|
7719 | });
|
7720 | useExpose({
|
7721 | reset,
|
7722 | scrollToDate,
|
7723 | getSelectedDate
|
7724 | });
|
7725 | onMountedOrActivated(init);
|
7726 | return () => {
|
7727 | if (props2.poppable) {
|
7728 | return vue.createVNode(Popup, {
|
7729 | "show": props2.show,
|
7730 | "class": bem$13("popup"),
|
7731 | "round": props2.round,
|
7732 | "position": props2.position,
|
7733 | "closeable": props2.showTitle || props2.showSubtitle,
|
7734 | "teleport": props2.teleport,
|
7735 | "closeOnPopstate": props2.closeOnPopstate,
|
7736 | "safeAreaInsetTop": props2.safeAreaInsetTop,
|
7737 | "closeOnClickOverlay": props2.closeOnClickOverlay,
|
7738 | "onUpdate:show": updateShow
|
7739 | }, {
|
7740 | default: renderCalendar
|
7741 | });
|
7742 | }
|
7743 | return renderCalendar();
|
7744 | };
|
7745 | }
|
7746 | });
|
7747 | const Calendar = withInstall(stdin_default$1d);
|
7748 | const [name$13, bem$12] = createNamespace("image");
|
7749 | const imageProps = {
|
7750 | src: String,
|
7751 | alt: String,
|
7752 | fit: String,
|
7753 | position: String,
|
7754 | round: Boolean,
|
7755 | block: Boolean,
|
7756 | width: numericProp,
|
7757 | height: numericProp,
|
7758 | radius: numericProp,
|
7759 | lazyLoad: Boolean,
|
7760 | iconSize: numericProp,
|
7761 | showError: truthProp,
|
7762 | errorIcon: makeStringProp("photo-fail"),
|
7763 | iconPrefix: String,
|
7764 | showLoading: truthProp,
|
7765 | loadingIcon: makeStringProp("photo"),
|
7766 | crossorigin: String,
|
7767 | referrerpolicy: String
|
7768 | };
|
7769 | var stdin_default$1c = vue.defineComponent({
|
7770 | name: name$13,
|
7771 | props: imageProps,
|
7772 | emits: ["load", "error"],
|
7773 | setup(props2, {
|
7774 | emit,
|
7775 | slots
|
7776 | }) {
|
7777 | const error = vue.ref(false);
|
7778 | const loading = vue.ref(true);
|
7779 | const imageRef = vue.ref();
|
7780 | const {
|
7781 | $Lazyload
|
7782 | } = vue.getCurrentInstance().proxy;
|
7783 | const style = vue.computed(() => {
|
7784 | const style2 = {
|
7785 | width: addUnit(props2.width),
|
7786 | height: addUnit(props2.height)
|
7787 | };
|
7788 | if (isDef(props2.radius)) {
|
7789 | style2.overflow = "hidden";
|
7790 | style2.borderRadius = addUnit(props2.radius);
|
7791 | }
|
7792 | return style2;
|
7793 | });
|
7794 | vue.watch(() => props2.src, () => {
|
7795 | error.value = false;
|
7796 | loading.value = true;
|
7797 | });
|
7798 | const onLoad = (event) => {
|
7799 | if (loading.value) {
|
7800 | loading.value = false;
|
7801 | emit("load", event);
|
7802 | }
|
7803 | };
|
7804 | const triggerLoad = () => {
|
7805 | const loadEvent = new Event("load");
|
7806 | Object.defineProperty(loadEvent, "target", {
|
7807 | value: imageRef.value,
|
7808 | enumerable: true
|
7809 | });
|
7810 | onLoad(loadEvent);
|
7811 | };
|
7812 | const onError = (event) => {
|
7813 | error.value = true;
|
7814 | loading.value = false;
|
7815 | emit("error", event);
|
7816 | };
|
7817 | const renderIcon = (name2, className, slot) => {
|
7818 | if (slot) {
|
7819 | return slot();
|
7820 | }
|
7821 | return vue.createVNode(Icon, {
|
7822 | "name": name2,
|
7823 | "size": props2.iconSize,
|
7824 | "class": className,
|
7825 | "classPrefix": props2.iconPrefix
|
7826 | }, null);
|
7827 | };
|
7828 | const renderPlaceholder = () => {
|
7829 | if (loading.value && props2.showLoading) {
|
7830 | return vue.createVNode("div", {
|
7831 | "class": bem$12("loading")
|
7832 | }, [renderIcon(props2.loadingIcon, bem$12("loading-icon"), slots.loading)]);
|
7833 | }
|
7834 | if (error.value && props2.showError) {
|
7835 | return vue.createVNode("div", {
|
7836 | "class": bem$12("error")
|
7837 | }, [renderIcon(props2.errorIcon, bem$12("error-icon"), slots.error)]);
|
7838 | }
|
7839 | };
|
7840 | const renderImage = () => {
|
7841 | if (error.value || !props2.src) {
|
7842 | return;
|
7843 | }
|
7844 | const attrs = {
|
7845 | alt: props2.alt,
|
7846 | class: bem$12("img"),
|
7847 | style: {
|
7848 | objectFit: props2.fit,
|
7849 | objectPosition: props2.position
|
7850 | },
|
7851 | crossorigin: props2.crossorigin,
|
7852 | referrerpolicy: props2.referrerpolicy
|
7853 | };
|
7854 | if (props2.lazyLoad) {
|
7855 | return vue.withDirectives(vue.createVNode("img", vue.mergeProps({
|
7856 | "ref": imageRef
|
7857 | }, attrs), null), [[vue.resolveDirective("lazy"), props2.src]]);
|
7858 | }
|
7859 | return vue.createVNode("img", vue.mergeProps({
|
7860 | "ref": imageRef,
|
7861 | "src": props2.src,
|
7862 | "onLoad": onLoad,
|
7863 | "onError": onError
|
7864 | }, attrs), null);
|
7865 | };
|
7866 | const onLazyLoaded = ({
|
7867 | el
|
7868 | }) => {
|
7869 | const check = () => {
|
7870 | if (el === imageRef.value && loading.value) {
|
7871 | triggerLoad();
|
7872 | }
|
7873 | };
|
7874 | if (imageRef.value) {
|
7875 | check();
|
7876 | } else {
|
7877 | vue.nextTick(check);
|
7878 | }
|
7879 | };
|
7880 | const onLazyLoadError = ({
|
7881 | el
|
7882 | }) => {
|
7883 | if (el === imageRef.value && !error.value) {
|
7884 | onError();
|
7885 | }
|
7886 | };
|
7887 | if ($Lazyload && inBrowser$1) {
|
7888 | $Lazyload.$on("loaded", onLazyLoaded);
|
7889 | $Lazyload.$on("error", onLazyLoadError);
|
7890 | vue.onBeforeUnmount(() => {
|
7891 | $Lazyload.$off("loaded", onLazyLoaded);
|
7892 | $Lazyload.$off("error", onLazyLoadError);
|
7893 | });
|
7894 | }
|
7895 | vue.onMounted(() => {
|
7896 | vue.nextTick(() => {
|
7897 | var _a;
|
7898 | if (((_a = imageRef.value) == null ? void 0 : _a.complete) && !props2.lazyLoad) {
|
7899 | triggerLoad();
|
7900 | }
|
7901 | });
|
7902 | });
|
7903 | return () => {
|
7904 | var _a;
|
7905 | return vue.createVNode("div", {
|
7906 | "class": bem$12({
|
7907 | round: props2.round,
|
7908 | block: props2.block
|
7909 | }),
|
7910 | "style": style.value
|
7911 | }, [renderImage(), renderPlaceholder(), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
7912 | };
|
7913 | }
|
7914 | });
|
7915 | const Image$1 = withInstall(stdin_default$1c);
|
7916 | const [name$12, bem$11] = createNamespace("card");
|
7917 | const cardProps = {
|
7918 | tag: String,
|
7919 | num: numericProp,
|
7920 | desc: String,
|
7921 | thumb: String,
|
7922 | title: String,
|
7923 | price: numericProp,
|
7924 | centered: Boolean,
|
7925 | lazyLoad: Boolean,
|
7926 | currency: makeStringProp("¥"),
|
7927 | thumbLink: String,
|
7928 | originPrice: numericProp
|
7929 | };
|
7930 | var stdin_default$1b = vue.defineComponent({
|
7931 | name: name$12,
|
7932 | props: cardProps,
|
7933 | emits: ["clickThumb"],
|
7934 | setup(props2, {
|
7935 | slots,
|
7936 | emit
|
7937 | }) {
|
7938 | const renderTitle = () => {
|
7939 | if (slots.title) {
|
7940 | return slots.title();
|
7941 | }
|
7942 | if (props2.title) {
|
7943 | return vue.createVNode("div", {
|
7944 | "class": [bem$11("title"), "van-multi-ellipsis--l2"]
|
7945 | }, [props2.title]);
|
7946 | }
|
7947 | };
|
7948 | const renderThumbTag = () => {
|
7949 | if (slots.tag || props2.tag) {
|
7950 | return vue.createVNode("div", {
|
7951 | "class": bem$11("tag")
|
7952 | }, [slots.tag ? slots.tag() : vue.createVNode(Tag, {
|
7953 | "mark": true,
|
7954 | "type": "primary"
|
7955 | }, {
|
7956 | default: () => [props2.tag]
|
7957 | })]);
|
7958 | }
|
7959 | };
|
7960 | const renderThumbImage = () => {
|
7961 | if (slots.thumb) {
|
7962 | return slots.thumb();
|
7963 | }
|
7964 | return vue.createVNode(Image$1, {
|
7965 | "src": props2.thumb,
|
7966 | "fit": "cover",
|
7967 | "width": "100%",
|
7968 | "height": "100%",
|
7969 | "lazyLoad": props2.lazyLoad
|
7970 | }, null);
|
7971 | };
|
7972 | const renderThumb = () => {
|
7973 | if (slots.thumb || props2.thumb) {
|
7974 | return vue.createVNode("a", {
|
7975 | "href": props2.thumbLink,
|
7976 | "class": bem$11("thumb"),
|
7977 | "onClick": (event) => emit("clickThumb", event)
|
7978 | }, [renderThumbImage(), renderThumbTag()]);
|
7979 | }
|
7980 | };
|
7981 | const renderDesc = () => {
|
7982 | if (slots.desc) {
|
7983 | return slots.desc();
|
7984 | }
|
7985 | if (props2.desc) {
|
7986 | return vue.createVNode("div", {
|
7987 | "class": [bem$11("desc"), "van-ellipsis"]
|
7988 | }, [props2.desc]);
|
7989 | }
|
7990 | };
|
7991 | const renderPriceText = () => {
|
7992 | const priceArr = props2.price.toString().split(".");
|
7993 | return vue.createVNode("div", null, [vue.createVNode("span", {
|
7994 | "class": bem$11("price-currency")
|
7995 | }, [props2.currency]), vue.createVNode("span", {
|
7996 | "class": bem$11("price-integer")
|
7997 | }, [priceArr[0]]), priceArr.length > 1 && vue.createVNode(vue.Fragment, null, [vue.createTextVNode("."), vue.createVNode("span", {
|
7998 | "class": bem$11("price-decimal")
|
7999 | }, [priceArr[1]])])]);
|
8000 | };
|
8001 | return () => {
|
8002 | var _a, _b, _c;
|
8003 | const showNum = slots.num || isDef(props2.num);
|
8004 | const showPrice = slots.price || isDef(props2.price);
|
8005 | const showOriginPrice = slots["origin-price"] || isDef(props2.originPrice);
|
8006 | const showBottom = showNum || showPrice || showOriginPrice || slots.bottom;
|
8007 | const Price = showPrice && vue.createVNode("div", {
|
8008 | "class": bem$11("price")
|
8009 | }, [slots.price ? slots.price() : renderPriceText()]);
|
8010 | const OriginPrice = showOriginPrice && vue.createVNode("div", {
|
8011 | "class": bem$11("origin-price")
|
8012 | }, [slots["origin-price"] ? slots["origin-price"]() : `${props2.currency} ${props2.originPrice}`]);
|
8013 | const Num = showNum && vue.createVNode("div", {
|
8014 | "class": bem$11("num")
|
8015 | }, [slots.num ? slots.num() : `x${props2.num}`]);
|
8016 | const Footer = slots.footer && vue.createVNode("div", {
|
8017 | "class": bem$11("footer")
|
8018 | }, [slots.footer()]);
|
8019 | const Bottom = showBottom && vue.createVNode("div", {
|
8020 | "class": bem$11("bottom")
|
8021 | }, [(_a = slots["price-top"]) == null ? void 0 : _a.call(slots), Price, OriginPrice, Num, (_b = slots.bottom) == null ? void 0 : _b.call(slots)]);
|
8022 | return vue.createVNode("div", {
|
8023 | "class": bem$11()
|
8024 | }, [vue.createVNode("div", {
|
8025 | "class": bem$11("header")
|
8026 | }, [renderThumb(), vue.createVNode("div", {
|
8027 | "class": bem$11("content", {
|
8028 | centered: props2.centered
|
8029 | })
|
8030 | }, [vue.createVNode("div", null, [renderTitle(), renderDesc(), (_c = slots.tags) == null ? void 0 : _c.call(slots)]), Bottom])]), Footer]);
|
8031 | };
|
8032 | }
|
8033 | });
|
8034 | const Card = withInstall(stdin_default$1b);
|
8035 | const [name$11, bem$10, t$f] = createNamespace("cascader");
|
8036 | const cascaderProps = {
|
8037 | title: String,
|
8038 | options: makeArrayProp(),
|
8039 | closeable: truthProp,
|
8040 | swipeable: truthProp,
|
8041 | closeIcon: makeStringProp("cross"),
|
8042 | showHeader: truthProp,
|
8043 | modelValue: numericProp,
|
8044 | fieldNames: Object,
|
8045 | placeholder: String,
|
8046 | activeColor: String
|
8047 | };
|
8048 | var stdin_default$1a = vue.defineComponent({
|
8049 | name: name$11,
|
8050 | props: cascaderProps,
|
8051 | emits: ["close", "change", "finish", "clickTab", "update:modelValue"],
|
8052 | setup(props2, {
|
8053 | slots,
|
8054 | emit
|
8055 | }) {
|
8056 | const tabs = vue.ref([]);
|
8057 | const activeTab = vue.ref(0);
|
8058 | const [selectedElementRefs, setSelectedElementRefs] = useRefs();
|
8059 | const {
|
8060 | text: textKey,
|
8061 | value: valueKey,
|
8062 | children: childrenKey
|
8063 | } = extend({
|
8064 | text: "text",
|
8065 | value: "value",
|
8066 | children: "children"
|
8067 | }, props2.fieldNames);
|
8068 | const getSelectedOptionsByValue = (options, value) => {
|
8069 | for (const option of options) {
|
8070 | if (option[valueKey] === value) {
|
8071 | return [option];
|
8072 | }
|
8073 | if (option[childrenKey]) {
|
8074 | const selectedOptions = getSelectedOptionsByValue(option[childrenKey], value);
|
8075 | if (selectedOptions) {
|
8076 | return [option, ...selectedOptions];
|
8077 | }
|
8078 | }
|
8079 | }
|
8080 | };
|
8081 | const updateTabs = () => {
|
8082 | const {
|
8083 | options,
|
8084 | modelValue
|
8085 | } = props2;
|
8086 | if (modelValue !== void 0) {
|
8087 | const selectedOptions = getSelectedOptionsByValue(options, modelValue);
|
8088 | if (selectedOptions) {
|
8089 | let optionsCursor = options;
|
8090 | tabs.value = selectedOptions.map((option) => {
|
8091 | const tab = {
|
8092 | options: optionsCursor,
|
8093 | selected: option
|
8094 | };
|
8095 | const next = optionsCursor.find((item) => item[valueKey] === option[valueKey]);
|
8096 | if (next) {
|
8097 | optionsCursor = next[childrenKey];
|
8098 | }
|
8099 | return tab;
|
8100 | });
|
8101 | if (optionsCursor) {
|
8102 | tabs.value.push({
|
8103 | options: optionsCursor,
|
8104 | selected: null
|
8105 | });
|
8106 | }
|
8107 | vue.nextTick(() => {
|
8108 | activeTab.value = tabs.value.length - 1;
|
8109 | });
|
8110 | return;
|
8111 | }
|
8112 | }
|
8113 | tabs.value = [{
|
8114 | options,
|
8115 | selected: null
|
8116 | }];
|
8117 | };
|
8118 | const onSelect = (option, tabIndex) => {
|
8119 | if (option.disabled) {
|
8120 | return;
|
8121 | }
|
8122 | tabs.value[tabIndex].selected = option;
|
8123 | if (tabs.value.length > tabIndex + 1) {
|
8124 | tabs.value = tabs.value.slice(0, tabIndex + 1);
|
8125 | }
|
8126 | if (option[childrenKey]) {
|
8127 | const nextTab = {
|
8128 | options: option[childrenKey],
|
8129 | selected: null
|
8130 | };
|
8131 | if (tabs.value[tabIndex + 1]) {
|
8132 | tabs.value[tabIndex + 1] = nextTab;
|
8133 | } else {
|
8134 | tabs.value.push(nextTab);
|
8135 | }
|
8136 | vue.nextTick(() => {
|
8137 | activeTab.value++;
|
8138 | });
|
8139 | }
|
8140 | const selectedOptions = tabs.value.map((tab) => tab.selected).filter(Boolean);
|
8141 | emit("update:modelValue", option[valueKey]);
|
8142 | const params = {
|
8143 | value: option[valueKey],
|
8144 | tabIndex,
|
8145 | selectedOptions
|
8146 | };
|
8147 | emit("change", params);
|
8148 | if (!option[childrenKey]) {
|
8149 | emit("finish", params);
|
8150 | }
|
8151 | };
|
8152 | const onClose = () => emit("close");
|
8153 | const onClickTab = ({
|
8154 | name: name2,
|
8155 | title
|
8156 | }) => emit("clickTab", name2, title);
|
8157 | const renderHeader = () => props2.showHeader ? vue.createVNode("div", {
|
8158 | "class": bem$10("header")
|
8159 | }, [vue.createVNode("h2", {
|
8160 | "class": bem$10("title")
|
8161 | }, [slots.title ? slots.title() : props2.title]), props2.closeable ? vue.createVNode(Icon, {
|
8162 | "name": props2.closeIcon,
|
8163 | "class": [bem$10("close-icon"), HAPTICS_FEEDBACK],
|
8164 | "onClick": onClose
|
8165 | }, null) : null]) : null;
|
8166 | const renderOption = (option, selectedOption, tabIndex) => {
|
8167 | const {
|
8168 | disabled
|
8169 | } = option;
|
8170 | const selected = !!(selectedOption && option[valueKey] === selectedOption[valueKey]);
|
8171 | const color = option.color || (selected ? props2.activeColor : void 0);
|
8172 | const Text = slots.option ? slots.option({
|
8173 | option,
|
8174 | selected
|
8175 | }) : vue.createVNode("span", null, [option[textKey]]);
|
8176 | return vue.createVNode("li", {
|
8177 | "ref": selected ? setSelectedElementRefs(tabIndex) : void 0,
|
8178 | "role": "menuitemradio",
|
8179 | "class": [bem$10("option", {
|
8180 | selected,
|
8181 | disabled
|
8182 | }), option.className],
|
8183 | "style": {
|
8184 | color
|
8185 | },
|
8186 | "tabindex": disabled ? void 0 : selected ? 0 : -1,
|
8187 | "aria-checked": selected,
|
8188 | "aria-disabled": disabled || void 0,
|
8189 | "onClick": () => onSelect(option, tabIndex)
|
8190 | }, [Text, selected ? vue.createVNode(Icon, {
|
8191 | "name": "success",
|
8192 | "class": bem$10("selected-icon")
|
8193 | }, null) : null]);
|
8194 | };
|
8195 | const renderOptions = (options, selectedOption, tabIndex) => vue.createVNode("ul", {
|
8196 | "role": "menu",
|
8197 | "class": bem$10("options")
|
8198 | }, [options.map((option) => renderOption(option, selectedOption, tabIndex))]);
|
8199 | const renderTab = (tab, tabIndex) => {
|
8200 | const {
|
8201 | options,
|
8202 | selected
|
8203 | } = tab;
|
8204 | const placeholder = props2.placeholder || t$f("select");
|
8205 | const title = selected ? selected[textKey] : placeholder;
|
8206 | return vue.createVNode(Tab, {
|
8207 | "title": title,
|
8208 | "titleClass": bem$10("tab", {
|
8209 | unselected: !selected
|
8210 | })
|
8211 | }, {
|
8212 | default: () => {
|
8213 | var _a, _b;
|
8214 | return [(_a = slots["options-top"]) == null ? void 0 : _a.call(slots, {
|
8215 | tabIndex
|
8216 | }), renderOptions(options, selected, tabIndex), (_b = slots["options-bottom"]) == null ? void 0 : _b.call(slots, {
|
8217 | tabIndex
|
8218 | })];
|
8219 | }
|
8220 | });
|
8221 | };
|
8222 | const renderTabs = () => vue.createVNode(Tabs, {
|
8223 | "active": activeTab.value,
|
8224 | "onUpdate:active": ($event) => activeTab.value = $event,
|
8225 | "shrink": true,
|
8226 | "animated": true,
|
8227 | "class": bem$10("tabs"),
|
8228 | "color": props2.activeColor,
|
8229 | "swipeable": props2.swipeable,
|
8230 | "onClickTab": onClickTab
|
8231 | }, {
|
8232 | default: () => [tabs.value.map(renderTab)]
|
8233 | });
|
8234 | const scrollIntoView = (el) => {
|
8235 | const scrollParent = el.parentElement;
|
8236 | if (scrollParent) {
|
8237 | scrollParent.scrollTop = el.offsetTop - (scrollParent.offsetHeight - el.offsetHeight) / 2;
|
8238 | }
|
8239 | };
|
8240 | updateTabs();
|
8241 | vue.watch(activeTab, (value) => {
|
8242 | const el = selectedElementRefs.value[value];
|
8243 | if (el) scrollIntoView(el);
|
8244 | });
|
8245 | vue.watch(() => props2.options, updateTabs, {
|
8246 | deep: true
|
8247 | });
|
8248 | vue.watch(() => props2.modelValue, (value) => {
|
8249 | if (value !== void 0) {
|
8250 | const values = tabs.value.map((tab) => {
|
8251 | var _a;
|
8252 | return (_a = tab.selected) == null ? void 0 : _a[valueKey];
|
8253 | });
|
8254 | if (values.includes(value)) {
|
8255 | return;
|
8256 | }
|
8257 | }
|
8258 | updateTabs();
|
8259 | });
|
8260 | return () => vue.createVNode("div", {
|
8261 | "class": bem$10()
|
8262 | }, [renderHeader(), renderTabs()]);
|
8263 | }
|
8264 | });
|
8265 | const Cascader = withInstall(stdin_default$1a);
|
8266 | const [name$10, bem$$] = createNamespace("cell-group");
|
8267 | const cellGroupProps = {
|
8268 | title: String,
|
8269 | inset: Boolean,
|
8270 | border: truthProp
|
8271 | };
|
8272 | var stdin_default$19 = vue.defineComponent({
|
8273 | name: name$10,
|
8274 | inheritAttrs: false,
|
8275 | props: cellGroupProps,
|
8276 | setup(props2, {
|
8277 | slots,
|
8278 | attrs
|
8279 | }) {
|
8280 | const renderGroup = () => {
|
8281 | var _a;
|
8282 | return vue.createVNode("div", vue.mergeProps({
|
8283 | "class": [bem$$({
|
8284 | inset: props2.inset
|
8285 | }), {
|
8286 | [BORDER_TOP_BOTTOM]: props2.border && !props2.inset
|
8287 | }]
|
8288 | }, attrs, useScopeId()), [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
8289 | };
|
8290 | const renderTitle = () => vue.createVNode("div", {
|
8291 | "class": bem$$("title", {
|
8292 | inset: props2.inset
|
8293 | })
|
8294 | }, [slots.title ? slots.title() : props2.title]);
|
8295 | return () => {
|
8296 | if (props2.title || slots.title) {
|
8297 | return vue.createVNode(vue.Fragment, null, [renderTitle(), renderGroup()]);
|
8298 | }
|
8299 | return renderGroup();
|
8300 | };
|
8301 | }
|
8302 | });
|
8303 | const CellGroup = withInstall(stdin_default$19);
|
8304 | const [name$$, bem$_] = createNamespace("circle");
|
8305 | let uid = 0;
|
8306 | const format = (rate) => Math.min(Math.max(+rate, 0), 100);
|
8307 | function getPath(clockwise, viewBoxSize) {
|
8308 | const sweepFlag = clockwise ? 1 : 0;
|
8309 | return `M ${viewBoxSize / 2} ${viewBoxSize / 2} m 0, -500 a 500, 500 0 1, ${sweepFlag} 0, 1000 a 500, 500 0 1, ${sweepFlag} 0, -1000`;
|
8310 | }
|
8311 | const circleProps = {
|
8312 | text: String,
|
8313 | size: numericProp,
|
8314 | fill: makeStringProp("none"),
|
8315 | rate: makeNumericProp(100),
|
8316 | speed: makeNumericProp(0),
|
8317 | color: [String, Object],
|
8318 | clockwise: truthProp,
|
8319 | layerColor: String,
|
8320 | currentRate: makeNumberProp(0),
|
8321 | strokeWidth: makeNumericProp(40),
|
8322 | strokeLinecap: String,
|
8323 | startPosition: makeStringProp("top")
|
8324 | };
|
8325 | var stdin_default$18 = vue.defineComponent({
|
8326 | name: name$$,
|
8327 | props: circleProps,
|
8328 | emits: ["update:currentRate"],
|
8329 | setup(props2, {
|
8330 | emit,
|
8331 | slots
|
8332 | }) {
|
8333 | const id = `van-circle-${uid++}`;
|
8334 | const viewBoxSize = vue.computed(() => +props2.strokeWidth + 1e3);
|
8335 | const path = vue.computed(() => getPath(props2.clockwise, viewBoxSize.value));
|
8336 | const svgStyle = vue.computed(() => {
|
8337 | const ROTATE_ANGLE_MAP = {
|
8338 | top: 0,
|
8339 | right: 90,
|
8340 | bottom: 180,
|
8341 | left: 270
|
8342 | };
|
8343 | const angleValue = ROTATE_ANGLE_MAP[props2.startPosition];
|
8344 | if (angleValue) {
|
8345 | return {
|
8346 | transform: `rotate(${angleValue}deg)`
|
8347 | };
|
8348 | }
|
8349 | });
|
8350 | vue.watch(() => props2.rate, (rate) => {
|
8351 | let rafId;
|
8352 | const startTime = Date.now();
|
8353 | const startRate = props2.currentRate;
|
8354 | const endRate = format(rate);
|
8355 | const duration = Math.abs((startRate - endRate) * 1e3 / +props2.speed);
|
8356 | const animate = () => {
|
8357 | const now = Date.now();
|
8358 | const progress = Math.min((now - startTime) / duration, 1);
|
8359 | const rate2 = progress * (endRate - startRate) + startRate;
|
8360 | emit("update:currentRate", format(parseFloat(rate2.toFixed(1))));
|
8361 | if (endRate > startRate ? rate2 < endRate : rate2 > endRate) {
|
8362 | rafId = raf(animate);
|
8363 | }
|
8364 | };
|
8365 | if (props2.speed) {
|
8366 | if (rafId) {
|
8367 | cancelRaf(rafId);
|
8368 | }
|
8369 | rafId = raf(animate);
|
8370 | } else {
|
8371 | emit("update:currentRate", endRate);
|
8372 | }
|
8373 | }, {
|
8374 | immediate: true
|
8375 | });
|
8376 | const renderHover = () => {
|
8377 | const PERIMETER = 3140;
|
8378 | const {
|
8379 | strokeWidth,
|
8380 | currentRate,
|
8381 | strokeLinecap
|
8382 | } = props2;
|
8383 | const offset2 = PERIMETER * currentRate / 100;
|
8384 | const color = isObject$1(props2.color) ? `url(#${id})` : props2.color;
|
8385 | const style = {
|
8386 | stroke: color,
|
8387 | strokeWidth: `${+strokeWidth + 1}px`,
|
8388 | strokeLinecap,
|
8389 | strokeDasharray: `${offset2}px ${PERIMETER}px`
|
8390 | };
|
8391 | return vue.createVNode("path", {
|
8392 | "d": path.value,
|
8393 | "style": style,
|
8394 | "class": bem$_("hover"),
|
8395 | "stroke": color
|
8396 | }, null);
|
8397 | };
|
8398 | const renderLayer = () => {
|
8399 | const style = {
|
8400 | fill: props2.fill,
|
8401 | stroke: props2.layerColor,
|
8402 | strokeWidth: `${props2.strokeWidth}px`
|
8403 | };
|
8404 | return vue.createVNode("path", {
|
8405 | "class": bem$_("layer"),
|
8406 | "style": style,
|
8407 | "d": path.value
|
8408 | }, null);
|
8409 | };
|
8410 | const renderGradient = () => {
|
8411 | const {
|
8412 | color
|
8413 | } = props2;
|
8414 | if (!isObject$1(color)) {
|
8415 | return;
|
8416 | }
|
8417 | const Stops = Object.keys(color).sort((a, b) => parseFloat(a) - parseFloat(b)).map((key, index) => vue.createVNode("stop", {
|
8418 | "key": index,
|
8419 | "offset": key,
|
8420 | "stop-color": color[key]
|
8421 | }, null));
|
8422 | return vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
|
8423 | "id": id,
|
8424 | "x1": "100%",
|
8425 | "y1": "0%",
|
8426 | "x2": "0%",
|
8427 | "y2": "0%"
|
8428 | }, [Stops])]);
|
8429 | };
|
8430 | const renderText = () => {
|
8431 | if (slots.default) {
|
8432 | return slots.default();
|
8433 | }
|
8434 | if (props2.text) {
|
8435 | return vue.createVNode("div", {
|
8436 | "class": bem$_("text")
|
8437 | }, [props2.text]);
|
8438 | }
|
8439 | };
|
8440 | return () => vue.createVNode("div", {
|
8441 | "class": bem$_(),
|
8442 | "style": getSizeStyle(props2.size)
|
8443 | }, [vue.createVNode("svg", {
|
8444 | "viewBox": `0 0 ${viewBoxSize.value} ${viewBoxSize.value}`,
|
8445 | "style": svgStyle.value
|
8446 | }, [renderGradient(), renderLayer(), renderHover()]), renderText()]);
|
8447 | }
|
8448 | });
|
8449 | const Circle = withInstall(stdin_default$18);
|
8450 | const [name$_, bem$Z] = createNamespace("row");
|
8451 | const ROW_KEY = Symbol(name$_);
|
8452 | const rowProps = {
|
8453 | tag: makeStringProp("div"),
|
8454 | wrap: truthProp,
|
8455 | align: String,
|
8456 | gutter: {
|
8457 | type: [String, Number, Array],
|
8458 | default: 0
|
8459 | },
|
8460 | justify: String
|
8461 | };
|
8462 | var stdin_default$17 = vue.defineComponent({
|
8463 | name: name$_,
|
8464 | props: rowProps,
|
8465 | setup(props2, {
|
8466 | slots
|
8467 | }) {
|
8468 | const {
|
8469 | children,
|
8470 | linkChildren
|
8471 | } = useChildren(ROW_KEY);
|
8472 | const groups = vue.computed(() => {
|
8473 | const groups2 = [[]];
|
8474 | let totalSpan = 0;
|
8475 | children.forEach((child, index) => {
|
8476 | totalSpan += Number(child.span);
|
8477 | if (totalSpan > 24) {
|
8478 | groups2.push([index]);
|
8479 | totalSpan -= 24;
|
8480 | } else {
|
8481 | groups2[groups2.length - 1].push(index);
|
8482 | }
|
8483 | });
|
8484 | return groups2;
|
8485 | });
|
8486 | const spaces = vue.computed(() => {
|
8487 | let gutter = 0;
|
8488 | if (Array.isArray(props2.gutter)) {
|
8489 | gutter = Number(props2.gutter[0]) || 0;
|
8490 | } else {
|
8491 | gutter = Number(props2.gutter);
|
8492 | }
|
8493 | const spaces2 = [];
|
8494 | if (!gutter) {
|
8495 | return spaces2;
|
8496 | }
|
8497 | groups.value.forEach((group) => {
|
8498 | const averagePadding = gutter * (group.length - 1) / group.length;
|
8499 | group.forEach((item, index) => {
|
8500 | if (index === 0) {
|
8501 | spaces2.push({
|
8502 | right: averagePadding
|
8503 | });
|
8504 | } else {
|
8505 | const left2 = gutter - spaces2[item - 1].right;
|
8506 | const right2 = averagePadding - left2;
|
8507 | spaces2.push({
|
8508 | left: left2,
|
8509 | right: right2
|
8510 | });
|
8511 | }
|
8512 | });
|
8513 | });
|
8514 | return spaces2;
|
8515 | });
|
8516 | const verticalSpaces = vue.computed(() => {
|
8517 | const {
|
8518 | gutter
|
8519 | } = props2;
|
8520 | const spaces2 = [];
|
8521 | if (Array.isArray(gutter) && gutter.length > 1) {
|
8522 | const bottom2 = Number(gutter[1]) || 0;
|
8523 | if (bottom2 <= 0) {
|
8524 | return spaces2;
|
8525 | }
|
8526 | groups.value.forEach((group, index) => {
|
8527 | if (index === groups.value.length - 1) return;
|
8528 | group.forEach(() => {
|
8529 | spaces2.push({
|
8530 | bottom: bottom2
|
8531 | });
|
8532 | });
|
8533 | });
|
8534 | }
|
8535 | return spaces2;
|
8536 | });
|
8537 | linkChildren({
|
8538 | spaces,
|
8539 | verticalSpaces
|
8540 | });
|
8541 | return () => {
|
8542 | const {
|
8543 | tag,
|
8544 | wrap,
|
8545 | align,
|
8546 | justify
|
8547 | } = props2;
|
8548 | return vue.createVNode(tag, {
|
8549 | "class": bem$Z({
|
8550 | [`align-${align}`]: align,
|
8551 | [`justify-${justify}`]: justify,
|
8552 | nowrap: !wrap
|
8553 | })
|
8554 | }, {
|
8555 | default: () => {
|
8556 | var _a;
|
8557 | return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
|
8558 | }
|
8559 | });
|
8560 | };
|
8561 | }
|
8562 | });
|
8563 | const [name$Z, bem$Y] = createNamespace("col");
|
8564 | const colProps = {
|
8565 | tag: makeStringProp("div"),
|
8566 | span: makeNumericProp(0),
|
8567 | offset: numericProp
|
8568 | };
|
8569 | var stdin_default$16 = vue.defineComponent({
|
8570 | name: name$Z,
|
8571 | props: colProps,
|
8572 | setup(props2, {
|
8573 | slots
|
8574 | }) {
|
8575 | const {
|
8576 | parent,
|
8577 | index
|
8578 | } = useParent(ROW_KEY);
|
8579 | const style = vue.computed(() => {
|
8580 | if (!parent) {
|
8581 | return;
|
8582 | }
|
8583 | const {
|
8584 | spaces,
|
8585 | verticalSpaces
|
8586 | } = parent;
|
8587 | let styles = {};
|
8588 | if (spaces && spaces.value && spaces.value[index.value]) {
|
8589 | const {
|
8590 | left: left2,
|
8591 | right: right2
|
8592 | } = spaces.value[index.value];
|
8593 | styles = {
|
8594 | paddingLeft: left2 ? `${left2}px` : null,
|
8595 | paddingRight: right2 ? `${right2}px` : null
|
8596 | };
|
8597 | }
|
8598 | const {
|
8599 | bottom: bottom2
|
8600 | } = verticalSpaces.value[index.value] || {};
|
8601 | return extend(styles, {
|
8602 | marginBottom: bottom2 ? `${bottom2}px` : null
|
8603 | });
|
8604 | });
|
8605 | return () => {
|
8606 | const {
|
8607 | tag,
|
8608 | span,
|
8609 | offset: offset2
|
8610 | } = props2;
|
8611 | return vue.createVNode(tag, {
|
8612 | "style": style.value,
|
8613 | "class": bem$Y({
|
8614 | [span]: span,
|
8615 | [`offset-${offset2}`]: offset2
|
8616 | })
|
8617 | }, {
|
8618 | default: () => {
|
8619 | var _a;
|
8620 | return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
|
8621 | }
|
8622 | });
|
8623 | };
|
8624 | }
|
8625 | });
|
8626 | const Col = withInstall(stdin_default$16);
|
8627 | const [name$Y, bem$X] = createNamespace("collapse");
|
8628 | const COLLAPSE_KEY = Symbol(name$Y);
|
8629 | const collapseProps = {
|
8630 | border: truthProp,
|
8631 | accordion: Boolean,
|
8632 | modelValue: {
|
8633 | type: [String, Number, Array],
|
8634 | default: ""
|
8635 | }
|
8636 | };
|
8637 | var stdin_default$15 = vue.defineComponent({
|
8638 | name: name$Y,
|
8639 | props: collapseProps,
|
8640 | emits: ["change", "update:modelValue"],
|
8641 | setup(props2, {
|
8642 | emit,
|
8643 | slots
|
8644 | }) {
|
8645 | const {
|
8646 | linkChildren,
|
8647 | children
|
8648 | } = useChildren(COLLAPSE_KEY);
|
8649 | const updateName = (name2) => {
|
8650 | emit("change", name2);
|
8651 | emit("update:modelValue", name2);
|
8652 | };
|
8653 | const toggle = (name2, expanded) => {
|
8654 | const {
|
8655 | accordion,
|
8656 | modelValue
|
8657 | } = props2;
|
8658 | if (accordion) {
|
8659 | updateName(name2 === modelValue ? "" : name2);
|
8660 | } else if (expanded) {
|
8661 | updateName(modelValue.concat(name2));
|
8662 | } else {
|
8663 | updateName(modelValue.filter((activeName) => activeName !== name2));
|
8664 | }
|
8665 | };
|
8666 | const toggleAll = (options = {}) => {
|
8667 | if (props2.accordion) {
|
8668 | return;
|
8669 | }
|
8670 | if (typeof options === "boolean") {
|
8671 | options = {
|
8672 | expanded: options
|
8673 | };
|
8674 | }
|
8675 | const {
|
8676 | expanded,
|
8677 | skipDisabled
|
8678 | } = options;
|
8679 | const expandedChildren = children.filter((item) => {
|
8680 | if (item.disabled && skipDisabled) {
|
8681 | return item.expanded.value;
|
8682 | }
|
8683 | return expanded != null ? expanded : !item.expanded.value;
|
8684 | });
|
8685 | const names = expandedChildren.map((item) => item.itemName.value);
|
8686 | updateName(names);
|
8687 | };
|
8688 | const isExpanded = (name2) => {
|
8689 | const {
|
8690 | accordion,
|
8691 | modelValue
|
8692 | } = props2;
|
8693 | return accordion ? modelValue === name2 : modelValue.includes(name2);
|
8694 | };
|
8695 | useExpose({
|
8696 | toggleAll
|
8697 | });
|
8698 | linkChildren({
|
8699 | toggle,
|
8700 | isExpanded
|
8701 | });
|
8702 | return () => {
|
8703 | var _a;
|
8704 | return vue.createVNode("div", {
|
8705 | "class": [bem$X(), {
|
8706 | [BORDER_TOP_BOTTOM]: props2.border
|
8707 | }]
|
8708 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
8709 | };
|
8710 | }
|
8711 | });
|
8712 | const Collapse = withInstall(stdin_default$15);
|
8713 | const [name$X, bem$W] = createNamespace("collapse-item");
|
8714 | const CELL_SLOTS = ["icon", "title", "value", "label", "right-icon"];
|
8715 | const collapseItemProps = extend({}, cellSharedProps, {
|
8716 | name: numericProp,
|
8717 | isLink: truthProp,
|
8718 | disabled: Boolean,
|
8719 | readonly: Boolean,
|
8720 | lazyRender: truthProp
|
8721 | });
|
8722 | var stdin_default$14 = vue.defineComponent({
|
8723 | name: name$X,
|
8724 | props: collapseItemProps,
|
8725 | setup(props2, {
|
8726 | slots
|
8727 | }) {
|
8728 | const wrapperRef = vue.ref();
|
8729 | const contentRef = vue.ref();
|
8730 | const {
|
8731 | parent,
|
8732 | index
|
8733 | } = useParent(COLLAPSE_KEY);
|
8734 | if (!parent) {
|
8735 | return;
|
8736 | }
|
8737 | const name2 = vue.computed(() => {
|
8738 | var _a;
|
8739 | return (_a = props2.name) != null ? _a : index.value;
|
8740 | });
|
8741 | const expanded = vue.computed(() => parent.isExpanded(name2.value));
|
8742 | const show = vue.ref(expanded.value);
|
8743 | const lazyRender = useLazyRender(() => show.value || !props2.lazyRender);
|
8744 | const onTransitionEnd = () => {
|
8745 | if (!expanded.value) {
|
8746 | show.value = false;
|
8747 | } else if (wrapperRef.value) {
|
8748 | wrapperRef.value.style.height = "";
|
8749 | }
|
8750 | };
|
8751 | vue.watch(expanded, (value, oldValue) => {
|
8752 | if (oldValue === null) {
|
8753 | return;
|
8754 | }
|
8755 | if (value) {
|
8756 | show.value = true;
|
8757 | }
|
8758 | const tick = value ? vue.nextTick : raf;
|
8759 | tick(() => {
|
8760 | if (!contentRef.value || !wrapperRef.value) {
|
8761 | return;
|
8762 | }
|
8763 | const {
|
8764 | offsetHeight
|
8765 | } = contentRef.value;
|
8766 | if (offsetHeight) {
|
8767 | const contentHeight = `${offsetHeight}px`;
|
8768 | wrapperRef.value.style.height = value ? "0" : contentHeight;
|
8769 | doubleRaf(() => {
|
8770 | if (wrapperRef.value) {
|
8771 | wrapperRef.value.style.height = value ? contentHeight : "0";
|
8772 | }
|
8773 | });
|
8774 | } else {
|
8775 | onTransitionEnd();
|
8776 | }
|
8777 | });
|
8778 | });
|
8779 | const toggle = (newValue = !expanded.value) => {
|
8780 | parent.toggle(name2.value, newValue);
|
8781 | };
|
8782 | const onClickTitle = () => {
|
8783 | if (!props2.disabled && !props2.readonly) {
|
8784 | toggle();
|
8785 | }
|
8786 | };
|
8787 | const renderTitle = () => {
|
8788 | const {
|
8789 | border,
|
8790 | disabled,
|
8791 | readonly
|
8792 | } = props2;
|
8793 | const attrs = pick(props2, Object.keys(cellSharedProps));
|
8794 | if (readonly) {
|
8795 | attrs.isLink = false;
|
8796 | }
|
8797 | if (disabled || readonly) {
|
8798 | attrs.clickable = false;
|
8799 | }
|
8800 | return vue.createVNode(Cell, vue.mergeProps({
|
8801 | "role": "button",
|
8802 | "class": bem$W("title", {
|
8803 | disabled,
|
8804 | expanded: expanded.value,
|
8805 | borderless: !border
|
8806 | }),
|
8807 | "aria-expanded": String(expanded.value),
|
8808 | "onClick": onClickTitle
|
8809 | }, attrs), pick(slots, CELL_SLOTS));
|
8810 | };
|
8811 | const renderContent = lazyRender(() => {
|
8812 | var _a;
|
8813 | return vue.withDirectives(vue.createVNode("div", {
|
8814 | "ref": wrapperRef,
|
8815 | "class": bem$W("wrapper"),
|
8816 | "onTransitionend": onTransitionEnd
|
8817 | }, [vue.createVNode("div", {
|
8818 | "ref": contentRef,
|
8819 | "class": bem$W("content")
|
8820 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]), [[vue.vShow, show.value]]);
|
8821 | });
|
8822 | useExpose({
|
8823 | toggle,
|
8824 | expanded,
|
8825 | itemName: name2
|
8826 | });
|
8827 | return () => vue.createVNode("div", {
|
8828 | "class": [bem$W({
|
8829 | border: index.value && props2.border
|
8830 | })]
|
8831 | }, [renderTitle(), renderContent()]);
|
8832 | }
|
8833 | });
|
8834 | const CollapseItem = withInstall(stdin_default$14);
|
8835 | const ConfigProvider = withInstall(stdin_default$1S);
|
8836 | const [name$W, bem$V, t$e] = createNamespace("contact-card");
|
8837 | const contactCardProps = {
|
8838 | tel: String,
|
8839 | name: String,
|
8840 | type: makeStringProp("add"),
|
8841 | addText: String,
|
8842 | editable: truthProp
|
8843 | };
|
8844 | var stdin_default$13 = vue.defineComponent({
|
8845 | name: name$W,
|
8846 | props: contactCardProps,
|
8847 | emits: ["click"],
|
8848 | setup(props2, {
|
8849 | emit
|
8850 | }) {
|
8851 | const onClick = (event) => {
|
8852 | if (props2.editable) {
|
8853 | emit("click", event);
|
8854 | }
|
8855 | };
|
8856 | const renderContent = () => {
|
8857 | if (props2.type === "add") {
|
8858 | return props2.addText || t$e("addContact");
|
8859 | }
|
8860 | return [vue.createVNode("div", null, [`${t$e("name")}:${props2.name}`]), vue.createVNode("div", null, [`${t$e("tel")}:${props2.tel}`])];
|
8861 | };
|
8862 | return () => vue.createVNode(Cell, {
|
8863 | "center": true,
|
8864 | "icon": props2.type === "edit" ? "contact" : "add-square",
|
8865 | "class": bem$V([props2.type]),
|
8866 | "border": false,
|
8867 | "isLink": props2.editable,
|
8868 | "titleClass": bem$V("title"),
|
8869 | "onClick": onClick
|
8870 | }, {
|
8871 | title: renderContent
|
8872 | });
|
8873 | }
|
8874 | });
|
8875 | const ContactCard = withInstall(stdin_default$13);
|
8876 | const [name$V, bem$U, t$d] = createNamespace("contact-edit");
|
8877 | const DEFAULT_CONTACT = {
|
8878 | tel: "",
|
8879 | name: ""
|
8880 | };
|
8881 | const contactEditProps = {
|
8882 | isEdit: Boolean,
|
8883 | isSaving: Boolean,
|
8884 | isDeleting: Boolean,
|
8885 | showSetDefault: Boolean,
|
8886 | setDefaultLabel: String,
|
8887 | contactInfo: {
|
8888 | type: Object,
|
8889 | default: () => extend({}, DEFAULT_CONTACT)
|
8890 | },
|
8891 | telValidator: {
|
8892 | type: Function,
|
8893 | default: isMobile
|
8894 | }
|
8895 | };
|
8896 | var stdin_default$12 = vue.defineComponent({
|
8897 | name: name$V,
|
8898 | props: contactEditProps,
|
8899 | emits: ["save", "delete", "changeDefault"],
|
8900 | setup(props2, {
|
8901 | emit
|
8902 | }) {
|
8903 | const contact = vue.reactive(extend({}, DEFAULT_CONTACT, props2.contactInfo));
|
8904 | const onSave = () => {
|
8905 | if (!props2.isSaving) {
|
8906 | emit("save", contact);
|
8907 | }
|
8908 | };
|
8909 | const onDelete = () => emit("delete", contact);
|
8910 | const renderButtons = () => vue.createVNode("div", {
|
8911 | "class": bem$U("buttons")
|
8912 | }, [vue.createVNode(Button, {
|
8913 | "block": true,
|
8914 | "round": true,
|
8915 | "type": "primary",
|
8916 | "text": t$d("save"),
|
8917 | "class": bem$U("button"),
|
8918 | "loading": props2.isSaving,
|
8919 | "nativeType": "submit"
|
8920 | }, null), props2.isEdit && vue.createVNode(Button, {
|
8921 | "block": true,
|
8922 | "round": true,
|
8923 | "text": t$d("delete"),
|
8924 | "class": bem$U("button"),
|
8925 | "loading": props2.isDeleting,
|
8926 | "onClick": onDelete
|
8927 | }, null)]);
|
8928 | const renderSwitch = () => vue.createVNode(Switch, {
|
8929 | "modelValue": contact.isDefault,
|
8930 | "onUpdate:modelValue": ($event) => contact.isDefault = $event,
|
8931 | "onChange": (checked) => emit("changeDefault", checked)
|
8932 | }, null);
|
8933 | const renderSetDefault = () => {
|
8934 | if (props2.showSetDefault) {
|
8935 | return vue.createVNode(Cell, {
|
8936 | "title": props2.setDefaultLabel,
|
8937 | "class": bem$U("switch-cell"),
|
8938 | "border": false
|
8939 | }, {
|
8940 | "right-icon": renderSwitch
|
8941 | });
|
8942 | }
|
8943 | };
|
8944 | vue.watch(() => props2.contactInfo, (value) => extend(contact, DEFAULT_CONTACT, value));
|
8945 | return () => vue.createVNode(Form, {
|
8946 | "class": bem$U(),
|
8947 | "onSubmit": onSave
|
8948 | }, {
|
8949 | default: () => [vue.createVNode("div", {
|
8950 | "class": bem$U("fields")
|
8951 | }, [vue.createVNode(Field, {
|
8952 | "modelValue": contact.name,
|
8953 | "onUpdate:modelValue": ($event) => contact.name = $event,
|
8954 | "clearable": true,
|
8955 | "label": t$d("name"),
|
8956 | "rules": [{
|
8957 | required: true,
|
8958 | message: t$d("nameEmpty")
|
8959 | }],
|
8960 | "maxlength": "30",
|
8961 | "placeholder": t$d("name")
|
8962 | }, null), vue.createVNode(Field, {
|
8963 | "modelValue": contact.tel,
|
8964 | "onUpdate:modelValue": ($event) => contact.tel = $event,
|
8965 | "clearable": true,
|
8966 | "type": "tel",
|
8967 | "label": t$d("tel"),
|
8968 | "rules": [{
|
8969 | validator: props2.telValidator,
|
8970 | message: t$d("telInvalid")
|
8971 | }],
|
8972 | "placeholder": t$d("tel")
|
8973 | }, null)]), renderSetDefault(), renderButtons()]
|
8974 | });
|
8975 | }
|
8976 | });
|
8977 | const ContactEdit = withInstall(stdin_default$12);
|
8978 | const [name$U, bem$T, t$c] = createNamespace("contact-list");
|
8979 | const contactListProps = {
|
8980 | list: Array,
|
8981 | addText: String,
|
8982 | modelValue: unknownProp,
|
8983 | defaultTagText: String
|
8984 | };
|
8985 | var stdin_default$11 = vue.defineComponent({
|
8986 | name: name$U,
|
8987 | props: contactListProps,
|
8988 | emits: ["add", "edit", "select", "update:modelValue"],
|
8989 | setup(props2, {
|
8990 | emit
|
8991 | }) {
|
8992 | const renderItem = (item, index) => {
|
8993 | const onClick = () => {
|
8994 | emit("update:modelValue", item.id);
|
8995 | emit("select", item, index);
|
8996 | };
|
8997 | const renderRightIcon = () => vue.createVNode(Radio, {
|
8998 | "class": bem$T("radio"),
|
8999 | "name": item.id,
|
9000 | "iconSize": 18
|
9001 | }, null);
|
9002 | const renderEditIcon = () => vue.createVNode(Icon, {
|
9003 | "name": "edit",
|
9004 | "class": bem$T("edit"),
|
9005 | "onClick": (event) => {
|
9006 | event.stopPropagation();
|
9007 | emit("edit", item, index);
|
9008 | }
|
9009 | }, null);
|
9010 | const renderContent = () => {
|
9011 | const nodes = [`${item.name},${item.tel}`];
|
9012 | if (item.isDefault && props2.defaultTagText) {
|
9013 | nodes.push(vue.createVNode(Tag, {
|
9014 | "type": "primary",
|
9015 | "round": true,
|
9016 | "class": bem$T("item-tag")
|
9017 | }, {
|
9018 | default: () => [props2.defaultTagText]
|
9019 | }));
|
9020 | }
|
9021 | return nodes;
|
9022 | };
|
9023 | return vue.createVNode(Cell, {
|
9024 | "key": item.id,
|
9025 | "isLink": true,
|
9026 | "center": true,
|
9027 | "class": bem$T("item"),
|
9028 | "titleClass": bem$T("item-title"),
|
9029 | "onClick": onClick
|
9030 | }, {
|
9031 | icon: renderEditIcon,
|
9032 | title: renderContent,
|
9033 | "right-icon": renderRightIcon
|
9034 | });
|
9035 | };
|
9036 | return () => vue.createVNode("div", {
|
9037 | "class": bem$T()
|
9038 | }, [vue.createVNode(RadioGroup, {
|
9039 | "modelValue": props2.modelValue,
|
9040 | "class": bem$T("group")
|
9041 | }, {
|
9042 | default: () => [props2.list && props2.list.map(renderItem)]
|
9043 | }), vue.createVNode("div", {
|
9044 | "class": [bem$T("bottom"), "van-safe-area-bottom"]
|
9045 | }, [vue.createVNode(Button, {
|
9046 | "round": true,
|
9047 | "block": true,
|
9048 | "type": "primary",
|
9049 | "class": bem$T("add"),
|
9050 | "text": props2.addText || t$c("addContact"),
|
9051 | "onClick": () => emit("add")
|
9052 | }, null)])]);
|
9053 | }
|
9054 | });
|
9055 | const ContactList = withInstall(stdin_default$11);
|
9056 | function parseFormat(format2, currentTime) {
|
9057 | const { days } = currentTime;
|
9058 | let { hours, minutes, seconds, milliseconds } = currentTime;
|
9059 | if (format2.includes("DD")) {
|
9060 | format2 = format2.replace("DD", padZero(days));
|
9061 | } else {
|
9062 | hours += days * 24;
|
9063 | }
|
9064 | if (format2.includes("HH")) {
|
9065 | format2 = format2.replace("HH", padZero(hours));
|
9066 | } else {
|
9067 | minutes += hours * 60;
|
9068 | }
|
9069 | if (format2.includes("mm")) {
|
9070 | format2 = format2.replace("mm", padZero(minutes));
|
9071 | } else {
|
9072 | seconds += minutes * 60;
|
9073 | }
|
9074 | if (format2.includes("ss")) {
|
9075 | format2 = format2.replace("ss", padZero(seconds));
|
9076 | } else {
|
9077 | milliseconds += seconds * 1e3;
|
9078 | }
|
9079 | if (format2.includes("S")) {
|
9080 | const ms = padZero(milliseconds, 3);
|
9081 | if (format2.includes("SSS")) {
|
9082 | format2 = format2.replace("SSS", ms);
|
9083 | } else if (format2.includes("SS")) {
|
9084 | format2 = format2.replace("SS", ms.slice(0, 2));
|
9085 | } else {
|
9086 | format2 = format2.replace("S", ms.charAt(0));
|
9087 | }
|
9088 | }
|
9089 | return format2;
|
9090 | }
|
9091 | const [name$T, bem$S] = createNamespace("count-down");
|
9092 | const countDownProps = {
|
9093 | time: makeNumericProp(0),
|
9094 | format: makeStringProp("HH:mm:ss"),
|
9095 | autoStart: truthProp,
|
9096 | millisecond: Boolean
|
9097 | };
|
9098 | var stdin_default$10 = vue.defineComponent({
|
9099 | name: name$T,
|
9100 | props: countDownProps,
|
9101 | emits: ["change", "finish"],
|
9102 | setup(props2, {
|
9103 | emit,
|
9104 | slots
|
9105 | }) {
|
9106 | const {
|
9107 | start: start2,
|
9108 | pause,
|
9109 | reset,
|
9110 | current: current2
|
9111 | } = useCountDown({
|
9112 | time: +props2.time,
|
9113 | millisecond: props2.millisecond,
|
9114 | onChange: (current22) => emit("change", current22),
|
9115 | onFinish: () => emit("finish")
|
9116 | });
|
9117 | const timeText = vue.computed(() => parseFormat(props2.format, current2.value));
|
9118 | const resetTime = () => {
|
9119 | reset(+props2.time);
|
9120 | if (props2.autoStart) {
|
9121 | start2();
|
9122 | }
|
9123 | };
|
9124 | vue.watch(() => props2.time, resetTime, {
|
9125 | immediate: true
|
9126 | });
|
9127 | useExpose({
|
9128 | start: start2,
|
9129 | pause,
|
9130 | reset: resetTime
|
9131 | });
|
9132 | return () => vue.createVNode("div", {
|
9133 | "role": "timer",
|
9134 | "class": bem$S()
|
9135 | }, [slots.default ? slots.default(current2.value) : timeText.value]);
|
9136 | }
|
9137 | });
|
9138 | const CountDown = withInstall(stdin_default$10);
|
9139 | function getDate(timeStamp) {
|
9140 | const date = new Date(timeStamp * 1e3);
|
9141 | return `${date.getFullYear()}.${padZero(date.getMonth() + 1)}.${padZero(
|
9142 | date.getDate()
|
9143 | )}`;
|
9144 | }
|
9145 | const formatDiscount = (discount) => (discount / 10).toFixed(discount % 10 === 0 ? 0 : 1);
|
9146 | const formatAmount = (amount) => (amount / 100).toFixed(amount % 100 === 0 ? 0 : amount % 10 === 0 ? 1 : 2);
|
9147 | const [name$S, bem$R, t$b] = createNamespace("coupon");
|
9148 | var stdin_default$$ = vue.defineComponent({
|
9149 | name: name$S,
|
9150 | props: {
|
9151 | chosen: Boolean,
|
9152 | coupon: makeRequiredProp(Object),
|
9153 | disabled: Boolean,
|
9154 | currency: makeStringProp("¥")
|
9155 | },
|
9156 | setup(props2) {
|
9157 | const validPeriod = vue.computed(() => {
|
9158 | const {
|
9159 | startAt,
|
9160 | endAt
|
9161 | } = props2.coupon;
|
9162 | return `${getDate(startAt)} - ${getDate(endAt)}`;
|
9163 | });
|
9164 | const faceAmount = vue.computed(() => {
|
9165 | const {
|
9166 | coupon,
|
9167 | currency
|
9168 | } = props2;
|
9169 | if (coupon.valueDesc) {
|
9170 | return [coupon.valueDesc, vue.createVNode("span", null, [coupon.unitDesc || ""])];
|
9171 | }
|
9172 | if (coupon.denominations) {
|
9173 | const denominations = formatAmount(coupon.denominations);
|
9174 | return [vue.createVNode("span", null, [currency]), ` ${denominations}`];
|
9175 | }
|
9176 | if (coupon.discount) {
|
9177 | return t$b("discount", formatDiscount(coupon.discount));
|
9178 | }
|
9179 | return "";
|
9180 | });
|
9181 | const conditionMessage = vue.computed(() => {
|
9182 | const condition = formatAmount(props2.coupon.originCondition || 0);
|
9183 | return condition === "0" ? t$b("unlimited") : t$b("condition", condition);
|
9184 | });
|
9185 | return () => {
|
9186 | const {
|
9187 | chosen,
|
9188 | coupon,
|
9189 | disabled
|
9190 | } = props2;
|
9191 | const description = disabled && coupon.reason || coupon.description;
|
9192 | return vue.createVNode("div", {
|
9193 | "class": bem$R({
|
9194 | disabled
|
9195 | })
|
9196 | }, [vue.createVNode("div", {
|
9197 | "class": bem$R("content")
|
9198 | }, [vue.createVNode("div", {
|
9199 | "class": bem$R("head")
|
9200 | }, [vue.createVNode("h2", {
|
9201 | "class": bem$R("amount")
|
9202 | }, [faceAmount.value]), vue.createVNode("p", {
|
9203 | "class": bem$R("condition")
|
9204 | }, [coupon.condition || conditionMessage.value])]), vue.createVNode("div", {
|
9205 | "class": bem$R("body")
|
9206 | }, [vue.createVNode("p", {
|
9207 | "class": bem$R("name")
|
9208 | }, [coupon.name]), vue.createVNode("p", {
|
9209 | "class": bem$R("valid")
|
9210 | }, [validPeriod.value]), !disabled && vue.createVNode(Checkbox, {
|
9211 | "class": bem$R("corner"),
|
9212 | "modelValue": chosen
|
9213 | }, null)])]), description && vue.createVNode("p", {
|
9214 | "class": bem$R("description")
|
9215 | }, [description])]);
|
9216 | };
|
9217 | }
|
9218 | });
|
9219 | const Coupon = withInstall(stdin_default$$);
|
9220 | const [name$R, bem$Q, t$a] = createNamespace("coupon-cell");
|
9221 | const couponCellProps = {
|
9222 | title: String,
|
9223 | border: truthProp,
|
9224 | editable: truthProp,
|
9225 | coupons: makeArrayProp(),
|
9226 | currency: makeStringProp("¥"),
|
9227 | chosenCoupon: {
|
9228 | type: [Number, Array],
|
9229 | default: -1
|
9230 | }
|
9231 | };
|
9232 | const getValue = (coupon) => {
|
9233 | const {
|
9234 | value,
|
9235 | denominations
|
9236 | } = coupon;
|
9237 | if (isDef(value)) {
|
9238 | return value;
|
9239 | }
|
9240 | if (isDef(denominations)) {
|
9241 | return denominations;
|
9242 | }
|
9243 | return 0;
|
9244 | };
|
9245 | function formatValue({
|
9246 | coupons,
|
9247 | chosenCoupon,
|
9248 | currency
|
9249 | }) {
|
9250 | let value = 0;
|
9251 | let isExist = false;
|
9252 | (Array.isArray(chosenCoupon) ? chosenCoupon : [chosenCoupon]).forEach((i) => {
|
9253 | const coupon = coupons[+i];
|
9254 | if (coupon) {
|
9255 | isExist = true;
|
9256 | value += getValue(coupon);
|
9257 | }
|
9258 | });
|
9259 | if (isExist) {
|
9260 | return `-${currency} ${(value / 100).toFixed(2)}`;
|
9261 | }
|
9262 | return coupons.length === 0 ? t$a("noCoupon") : t$a("count", coupons.length);
|
9263 | }
|
9264 | var stdin_default$_ = vue.defineComponent({
|
9265 | name: name$R,
|
9266 | props: couponCellProps,
|
9267 | setup(props2) {
|
9268 | return () => {
|
9269 | const selected = Array.isArray(props2.chosenCoupon) ? props2.chosenCoupon.length : props2.coupons[+props2.chosenCoupon];
|
9270 | return vue.createVNode(Cell, {
|
9271 | "class": bem$Q(),
|
9272 | "value": formatValue(props2),
|
9273 | "title": props2.title || t$a("title"),
|
9274 | "border": props2.border,
|
9275 | "isLink": props2.editable,
|
9276 | "valueClass": bem$Q("value", {
|
9277 | selected
|
9278 | })
|
9279 | }, null);
|
9280 | };
|
9281 | }
|
9282 | });
|
9283 | const CouponCell = withInstall(stdin_default$_);
|
9284 | const [name$Q, bem$P] = createNamespace("empty");
|
9285 | const emptyProps = {
|
9286 | image: makeStringProp("default"),
|
9287 | imageSize: [Number, String, Array],
|
9288 | description: String
|
9289 | };
|
9290 | var stdin_default$Z = vue.defineComponent({
|
9291 | name: name$Q,
|
9292 | props: emptyProps,
|
9293 | setup(props2, {
|
9294 | slots
|
9295 | }) {
|
9296 | const renderDescription = () => {
|
9297 | const description = slots.description ? slots.description() : props2.description;
|
9298 | if (description) {
|
9299 | return vue.createVNode("p", {
|
9300 | "class": bem$P("description")
|
9301 | }, [description]);
|
9302 | }
|
9303 | };
|
9304 | const renderBottom = () => {
|
9305 | if (slots.default) {
|
9306 | return vue.createVNode("div", {
|
9307 | "class": bem$P("bottom")
|
9308 | }, [slots.default()]);
|
9309 | }
|
9310 | };
|
9311 | const baseId = useId();
|
9312 | const getId = (num) => `${baseId}-${num}`;
|
9313 | const getUrlById = (num) => `url(#${getId(num)})`;
|
9314 | const renderStop = (color, offset2, opacity) => vue.createVNode("stop", {
|
9315 | "stop-color": color,
|
9316 | "offset": `${offset2}%`,
|
9317 | "stop-opacity": opacity
|
9318 | }, null);
|
9319 | const renderStops = (fromColor, toColor) => [renderStop(fromColor, 0), renderStop(toColor, 100)];
|
9320 | const renderShadow = (id) => [vue.createVNode("defs", null, [vue.createVNode("radialGradient", {
|
9321 | "id": getId(id),
|
9322 | "cx": "50%",
|
9323 | "cy": "54%",
|
9324 | "fx": "50%",
|
9325 | "fy": "54%",
|
9326 | "r": "297%",
|
9327 | "gradientTransform": "matrix(-.16 0 0 -.33 .58 .72)",
|
9328 | "data-allow-mismatch": "attribute"
|
9329 | }, [renderStop("#EBEDF0", 0), renderStop("#F2F3F5", 100, 0.3)])]), vue.createVNode("ellipse", {
|
9330 | "fill": getUrlById(id),
|
9331 | "opacity": ".8",
|
9332 | "cx": "80",
|
9333 | "cy": "140",
|
9334 | "rx": "46",
|
9335 | "ry": "8",
|
9336 | "data-allow-mismatch": "attribute"
|
9337 | }, null)];
|
9338 | const renderBuilding = () => [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
|
9339 | "id": getId("a"),
|
9340 | "x1": "64%",
|
9341 | "y1": "100%",
|
9342 | "x2": "64%",
|
9343 | "data-allow-mismatch": "attribute"
|
9344 | }, [renderStop("#FFF", 0, 0.5), renderStop("#F2F3F5", 100)])]), vue.createVNode("g", {
|
9345 | "opacity": ".8",
|
9346 | "data-allow-mismatch": "children"
|
9347 | }, [vue.createVNode("path", {
|
9348 | "d": "M36 131V53H16v20H2v58h34z",
|
9349 | "fill": getUrlById("a")
|
9350 | }, null), vue.createVNode("path", {
|
9351 | "d": "M123 15h22v14h9v77h-31V15z",
|
9352 | "fill": getUrlById("a")
|
9353 | }, null)])];
|
9354 | const renderCloud = () => [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
|
9355 | "id": getId("b"),
|
9356 | "x1": "64%",
|
9357 | "y1": "97%",
|
9358 | "x2": "64%",
|
9359 | "y2": "0%",
|
9360 | "data-allow-mismatch": "attribute"
|
9361 | }, [renderStop("#F2F3F5", 0, 0.3), renderStop("#F2F3F5", 100)])]), vue.createVNode("g", {
|
9362 | "opacity": ".8",
|
9363 | "data-allow-mismatch": "children"
|
9364 | }, [vue.createVNode("path", {
|
9365 | "d": "M87 6c3 0 7 3 8 6a8 8 0 1 1-1 16H80a7 7 0 0 1-8-6c0-4 3-7 6-7 0-5 4-9 9-9Z",
|
9366 | "fill": getUrlById("b")
|
9367 | }, null), vue.createVNode("path", {
|
9368 | "d": "M19 23c2 0 3 1 4 3 2 0 4 2 4 4a4 4 0 0 1-4 3v1h-7v-1l-1 1c-2 0-3-2-3-4 0-1 1-3 3-3 0-2 2-4 4-4Z",
|
9369 | "fill": getUrlById("b")
|
9370 | }, null)])];
|
9371 | const renderNetwork = () => vue.createVNode("svg", {
|
9372 | "viewBox": "0 0 160 160"
|
9373 | }, [vue.createVNode("defs", {
|
9374 | "data-allow-mismatch": "children"
|
9375 | }, [vue.createVNode("linearGradient", {
|
9376 | "id": getId(1),
|
9377 | "x1": "64%",
|
9378 | "y1": "100%",
|
9379 | "x2": "64%"
|
9380 | }, [renderStop("#FFF", 0, 0.5), renderStop("#F2F3F5", 100)]), vue.createVNode("linearGradient", {
|
9381 | "id": getId(2),
|
9382 | "x1": "50%",
|
9383 | "x2": "50%",
|
9384 | "y2": "84%"
|
9385 | }, [renderStop("#EBEDF0", 0), renderStop("#DCDEE0", 100, 0)]), vue.createVNode("linearGradient", {
|
9386 | "id": getId(3),
|
9387 | "x1": "100%",
|
9388 | "x2": "100%",
|
9389 | "y2": "100%"
|
9390 | }, [renderStops("#EAEDF0", "#DCDEE0")]), vue.createVNode("radialGradient", {
|
9391 | "id": getId(4),
|
9392 | "cx": "50%",
|
9393 | "cy": "0%",
|
9394 | "fx": "50%",
|
9395 | "fy": "0%",
|
9396 | "r": "100%",
|
9397 | "gradientTransform": "matrix(0 1 -.54 0 .5 -.5)"
|
9398 | }, [renderStop("#EBEDF0", 0), renderStop("#FFF", 100, 0)])]), vue.createVNode("g", {
|
9399 | "fill": "none"
|
9400 | }, [renderBuilding(), vue.createVNode("path", {
|
9401 | "fill": getUrlById(4),
|
9402 | "d": "M0 139h160v21H0z",
|
9403 | "data-allow-mismatch": "attribute"
|
9404 | }, null), vue.createVNode("path", {
|
9405 | "d": "M80 54a7 7 0 0 1 3 13v27l-2 2h-2a2 2 0 0 1-2-2V67a7 7 0 0 1 3-13z",
|
9406 | "fill": getUrlById(2),
|
9407 | "data-allow-mismatch": "attribute"
|
9408 | }, null), vue.createVNode("g", {
|
9409 | "opacity": ".6",
|
9410 | "stroke-linecap": "round",
|
9411 | "stroke-width": "7",
|
9412 | "data-allow-mismatch": "children"
|
9413 | }, [vue.createVNode("path", {
|
9414 | "d": "M64 47a19 19 0 0 0-5 13c0 5 2 10 5 13",
|
9415 | "stroke": getUrlById(3)
|
9416 | }, null), vue.createVNode("path", {
|
9417 | "d": "M53 36a34 34 0 0 0 0 48",
|
9418 | "stroke": getUrlById(3)
|
9419 | }, null), vue.createVNode("path", {
|
9420 | "d": "M95 73a19 19 0 0 0 6-13c0-5-2-9-6-13",
|
9421 | "stroke": getUrlById(3)
|
9422 | }, null), vue.createVNode("path", {
|
9423 | "d": "M106 84a34 34 0 0 0 0-48",
|
9424 | "stroke": getUrlById(3)
|
9425 | }, null)]), vue.createVNode("g", {
|
9426 | "transform": "translate(31 105)"
|
9427 | }, [vue.createVNode("rect", {
|
9428 | "fill": "#EBEDF0",
|
9429 | "width": "98",
|
9430 | "height": "34",
|
9431 | "rx": "2"
|
9432 | }, null), vue.createVNode("rect", {
|
9433 | "fill": "#FFF",
|
9434 | "x": "9",
|
9435 | "y": "8",
|
9436 | "width": "80",
|
9437 | "height": "18",
|
9438 | "rx": "1.1"
|
9439 | }, null), vue.createVNode("rect", {
|
9440 | "fill": "#EBEDF0",
|
9441 | "x": "15",
|
9442 | "y": "12",
|
9443 | "width": "18",
|
9444 | "height": "6",
|
9445 | "rx": "1.1"
|
9446 | }, null)])])]);
|
9447 | const renderMaterial = () => vue.createVNode("svg", {
|
9448 | "viewBox": "0 0 160 160"
|
9449 | }, [vue.createVNode("defs", {
|
9450 | "data-allow-mismatch": "children"
|
9451 | }, [vue.createVNode("linearGradient", {
|
9452 | "x1": "50%",
|
9453 | "x2": "50%",
|
9454 | "y2": "100%",
|
9455 | "id": getId(5)
|
9456 | }, [renderStops("#F2F3F5", "#DCDEE0")]), vue.createVNode("linearGradient", {
|
9457 | "x1": "95%",
|
9458 | "y1": "48%",
|
9459 | "x2": "5.5%",
|
9460 | "y2": "51%",
|
9461 | "id": getId(6)
|
9462 | }, [renderStops("#EAEDF1", "#DCDEE0")]), vue.createVNode("linearGradient", {
|
9463 | "y1": "45%",
|
9464 | "x2": "100%",
|
9465 | "y2": "54%",
|
9466 | "id": getId(7)
|
9467 | }, [renderStops("#EAEDF1", "#DCDEE0")])]), renderBuilding(), renderCloud(), vue.createVNode("g", {
|
9468 | "transform": "translate(36 50)",
|
9469 | "fill": "none"
|
9470 | }, [vue.createVNode("g", {
|
9471 | "transform": "translate(8)"
|
9472 | }, [vue.createVNode("rect", {
|
9473 | "fill": "#EBEDF0",
|
9474 | "opacity": ".6",
|
9475 | "x": "38",
|
9476 | "y": "13",
|
9477 | "width": "36",
|
9478 | "height": "53",
|
9479 | "rx": "2"
|
9480 | }, null), vue.createVNode("rect", {
|
9481 | "fill": getUrlById(5),
|
9482 | "width": "64",
|
9483 | "height": "66",
|
9484 | "rx": "2",
|
9485 | "data-allow-mismatch": "attribute"
|
9486 | }, null), vue.createVNode("rect", {
|
9487 | "fill": "#FFF",
|
9488 | "x": "6",
|
9489 | "y": "6",
|
9490 | "width": "52",
|
9491 | "height": "55",
|
9492 | "rx": "1"
|
9493 | }, null), vue.createVNode("g", {
|
9494 | "transform": "translate(15 17)",
|
9495 | "fill": getUrlById(6),
|
9496 | "data-allow-mismatch": "attribute"
|
9497 | }, [vue.createVNode("rect", {
|
9498 | "width": "34",
|
9499 | "height": "6",
|
9500 | "rx": "1"
|
9501 | }, null), vue.createVNode("path", {
|
9502 | "d": "M0 14h34v6H0z"
|
9503 | }, null), vue.createVNode("rect", {
|
9504 | "y": "28",
|
9505 | "width": "34",
|
9506 | "height": "6",
|
9507 | "rx": "1"
|
9508 | }, null)])]), vue.createVNode("rect", {
|
9509 | "fill": getUrlById(7),
|
9510 | "y": "61",
|
9511 | "width": "88",
|
9512 | "height": "28",
|
9513 | "rx": "1",
|
9514 | "data-allow-mismatch": "attribute"
|
9515 | }, null), vue.createVNode("rect", {
|
9516 | "fill": "#F7F8FA",
|
9517 | "x": "29",
|
9518 | "y": "72",
|
9519 | "width": "30",
|
9520 | "height": "6",
|
9521 | "rx": "1"
|
9522 | }, null)])]);
|
9523 | const renderError = () => vue.createVNode("svg", {
|
9524 | "viewBox": "0 0 160 160"
|
9525 | }, [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
|
9526 | "x1": "50%",
|
9527 | "x2": "50%",
|
9528 | "y2": "100%",
|
9529 | "id": getId(8),
|
9530 | "data-allow-mismatch": "attribute"
|
9531 | }, [renderStops("#EAEDF1", "#DCDEE0")])]), renderBuilding(), renderCloud(), renderShadow("c"), vue.createVNode("path", {
|
9532 | "d": "m59 60 21 21 21-21h3l9 9v3L92 93l21 21v3l-9 9h-3l-21-21-21 21h-3l-9-9v-3l21-21-21-21v-3l9-9h3Z",
|
9533 | "fill": getUrlById(8),
|
9534 | "data-allow-mismatch": "attribute"
|
9535 | }, null)]);
|
9536 | const renderSearch = () => vue.createVNode("svg", {
|
9537 | "viewBox": "0 0 160 160"
|
9538 | }, [vue.createVNode("defs", {
|
9539 | "data-allow-mismatch": "children"
|
9540 | }, [vue.createVNode("linearGradient", {
|
9541 | "x1": "50%",
|
9542 | "y1": "100%",
|
9543 | "x2": "50%",
|
9544 | "id": getId(9)
|
9545 | }, [renderStops("#EEE", "#D8D8D8")]), vue.createVNode("linearGradient", {
|
9546 | "x1": "100%",
|
9547 | "y1": "50%",
|
9548 | "y2": "50%",
|
9549 | "id": getId(10)
|
9550 | }, [renderStops("#F2F3F5", "#DCDEE0")]), vue.createVNode("linearGradient", {
|
9551 | "x1": "50%",
|
9552 | "x2": "50%",
|
9553 | "y2": "100%",
|
9554 | "id": getId(11)
|
9555 | }, [renderStops("#F2F3F5", "#DCDEE0")]), vue.createVNode("linearGradient", {
|
9556 | "x1": "50%",
|
9557 | "x2": "50%",
|
9558 | "y2": "100%",
|
9559 | "id": getId(12)
|
9560 | }, [renderStops("#FFF", "#F7F8FA")])]), renderBuilding(), renderCloud(), renderShadow("d"), vue.createVNode("g", {
|
9561 | "transform": "rotate(-45 113 -4)",
|
9562 | "fill": "none",
|
9563 | "data-allow-mismatch": "children"
|
9564 | }, [vue.createVNode("rect", {
|
9565 | "fill": getUrlById(9),
|
9566 | "x": "24",
|
9567 | "y": "52.8",
|
9568 | "width": "5.8",
|
9569 | "height": "19",
|
9570 | "rx": "1"
|
9571 | }, null), vue.createVNode("rect", {
|
9572 | "fill": getUrlById(10),
|
9573 | "x": "22.1",
|
9574 | "y": "67.3",
|
9575 | "width": "9.9",
|
9576 | "height": "28",
|
9577 | "rx": "1"
|
9578 | }, null), vue.createVNode("circle", {
|
9579 | "stroke": getUrlById(11),
|
9580 | "stroke-width": "8",
|
9581 | "cx": "27",
|
9582 | "cy": "27",
|
9583 | "r": "27"
|
9584 | }, null), vue.createVNode("circle", {
|
9585 | "fill": getUrlById(12),
|
9586 | "cx": "27",
|
9587 | "cy": "27",
|
9588 | "r": "16"
|
9589 | }, null), vue.createVNode("path", {
|
9590 | "d": "M37 7c-8 0-15 5-16 12",
|
9591 | "stroke": getUrlById(11),
|
9592 | "stroke-width": "3",
|
9593 | "opacity": ".5",
|
9594 | "stroke-linecap": "round",
|
9595 | "transform": "rotate(45 29 13)"
|
9596 | }, null)])]);
|
9597 | const renderImage = () => {
|
9598 | var _a;
|
9599 | if (slots.image) {
|
9600 | return slots.image();
|
9601 | }
|
9602 | const PRESET_IMAGES = {
|
9603 | error: renderError,
|
9604 | search: renderSearch,
|
9605 | network: renderNetwork,
|
9606 | default: renderMaterial
|
9607 | };
|
9608 | return ((_a = PRESET_IMAGES[props2.image]) == null ? void 0 : _a.call(PRESET_IMAGES)) || vue.createVNode("img", {
|
9609 | "src": props2.image
|
9610 | }, null);
|
9611 | };
|
9612 | return () => vue.createVNode("div", {
|
9613 | "class": bem$P()
|
9614 | }, [vue.createVNode("div", {
|
9615 | "class": bem$P("image"),
|
9616 | "style": getSizeStyle(props2.imageSize)
|
9617 | }, [renderImage()]), renderDescription(), renderBottom()]);
|
9618 | }
|
9619 | });
|
9620 | const Empty = withInstall(stdin_default$Z);
|
9621 | const [name$P, bem$O, t$9] = createNamespace("coupon-list");
|
9622 | const couponListProps = {
|
9623 | code: makeStringProp(""),
|
9624 | coupons: makeArrayProp(),
|
9625 | currency: makeStringProp("¥"),
|
9626 | showCount: truthProp,
|
9627 | emptyImage: String,
|
9628 | enabledTitle: String,
|
9629 | disabledTitle: String,
|
9630 | disabledCoupons: makeArrayProp(),
|
9631 | showExchangeBar: truthProp,
|
9632 | showCloseButton: truthProp,
|
9633 | closeButtonText: String,
|
9634 | inputPlaceholder: String,
|
9635 | exchangeMinLength: makeNumberProp(1),
|
9636 | exchangeButtonText: String,
|
9637 | displayedCouponIndex: makeNumberProp(-1),
|
9638 | exchangeButtonLoading: Boolean,
|
9639 | exchangeButtonDisabled: Boolean,
|
9640 | chosenCoupon: {
|
9641 | type: [Number, Array],
|
9642 | default: -1
|
9643 | }
|
9644 | };
|
9645 | var stdin_default$Y = vue.defineComponent({
|
9646 | name: name$P,
|
9647 | props: couponListProps,
|
9648 | emits: ["change", "exchange", "update:code"],
|
9649 | setup(props2, {
|
9650 | emit,
|
9651 | slots
|
9652 | }) {
|
9653 | const [couponRefs, setCouponRefs] = useRefs();
|
9654 | const root = vue.ref();
|
9655 | const barRef = vue.ref();
|
9656 | const activeTab = vue.ref(0);
|
9657 | const listHeight = vue.ref(0);
|
9658 | const currentCode = vue.ref(props2.code);
|
9659 | const buttonDisabled = vue.computed(() => !props2.exchangeButtonLoading && (props2.exchangeButtonDisabled || !currentCode.value || currentCode.value.length < props2.exchangeMinLength));
|
9660 | const updateListHeight = () => {
|
9661 | const TABS_HEIGHT = 44;
|
9662 | const rootHeight = useRect(root).height;
|
9663 | const headerHeight = useRect(barRef).height + TABS_HEIGHT;
|
9664 | listHeight.value = (rootHeight > headerHeight ? rootHeight : windowHeight.value) - headerHeight;
|
9665 | };
|
9666 | const onExchange = () => {
|
9667 | emit("exchange", currentCode.value);
|
9668 | if (!props2.code) {
|
9669 | currentCode.value = "";
|
9670 | }
|
9671 | };
|
9672 | const scrollToCoupon = (index) => {
|
9673 | vue.nextTick(() => {
|
9674 | var _a;
|
9675 | return (_a = couponRefs.value[index]) == null ? void 0 : _a.scrollIntoView();
|
9676 | });
|
9677 | };
|
9678 | const renderEmpty = () => vue.createVNode(Empty, {
|
9679 | "image": props2.emptyImage
|
9680 | }, {
|
9681 | default: () => [vue.createVNode("p", {
|
9682 | "class": bem$O("empty-tip")
|
9683 | }, [t$9("noCoupon")])]
|
9684 | });
|
9685 | const renderExchangeBar = () => {
|
9686 | if (props2.showExchangeBar) {
|
9687 | return vue.createVNode("div", {
|
9688 | "ref": barRef,
|
9689 | "class": bem$O("exchange-bar")
|
9690 | }, [vue.createVNode(Field, {
|
9691 | "modelValue": currentCode.value,
|
9692 | "onUpdate:modelValue": ($event) => currentCode.value = $event,
|
9693 | "clearable": true,
|
9694 | "border": false,
|
9695 | "class": bem$O("field"),
|
9696 | "placeholder": props2.inputPlaceholder || t$9("placeholder"),
|
9697 | "maxlength": "20"
|
9698 | }, null), vue.createVNode(Button, {
|
9699 | "plain": true,
|
9700 | "type": "primary",
|
9701 | "class": bem$O("exchange"),
|
9702 | "text": props2.exchangeButtonText || t$9("exchange"),
|
9703 | "loading": props2.exchangeButtonLoading,
|
9704 | "disabled": buttonDisabled.value,
|
9705 | "onClick": onExchange
|
9706 | }, null)]);
|
9707 | }
|
9708 | };
|
9709 | const renderCouponTab = () => {
|
9710 | const {
|
9711 | coupons,
|
9712 | chosenCoupon
|
9713 | } = props2;
|
9714 | const count = props2.showCount ? ` (${coupons.length})` : "";
|
9715 | const title = (props2.enabledTitle || t$9("enable")) + count;
|
9716 | const updateChosenCoupon = (currentValues = [], value = 0) => {
|
9717 | if (currentValues.includes(value)) {
|
9718 | return currentValues.filter((item) => item !== value);
|
9719 | }
|
9720 | return [...currentValues, value];
|
9721 | };
|
9722 | return vue.createVNode(Tab, {
|
9723 | "title": title
|
9724 | }, {
|
9725 | default: () => {
|
9726 | var _a;
|
9727 | return [vue.createVNode("div", {
|
9728 | "class": bem$O("list", {
|
9729 | "with-bottom": props2.showCloseButton
|
9730 | }),
|
9731 | "style": {
|
9732 | height: `${listHeight.value}px`
|
9733 | }
|
9734 | }, [coupons.map((coupon, index) => vue.createVNode(Coupon, {
|
9735 | "key": coupon.id,
|
9736 | "ref": setCouponRefs(index),
|
9737 | "coupon": coupon,
|
9738 | "chosen": Array.isArray(chosenCoupon) ? chosenCoupon.includes(index) : index === chosenCoupon,
|
9739 | "currency": props2.currency,
|
9740 | "onClick": () => emit("change", Array.isArray(chosenCoupon) ? updateChosenCoupon(chosenCoupon, index) : index)
|
9741 | }, null)), !coupons.length && renderEmpty(), (_a = slots["list-footer"]) == null ? void 0 : _a.call(slots)])];
|
9742 | }
|
9743 | });
|
9744 | };
|
9745 | const renderDisabledTab = () => {
|
9746 | const {
|
9747 | disabledCoupons
|
9748 | } = props2;
|
9749 | const count = props2.showCount ? ` (${disabledCoupons.length})` : "";
|
9750 | const title = (props2.disabledTitle || t$9("disabled")) + count;
|
9751 | return vue.createVNode(Tab, {
|
9752 | "title": title
|
9753 | }, {
|
9754 | default: () => {
|
9755 | var _a;
|
9756 | return [vue.createVNode("div", {
|
9757 | "class": bem$O("list", {
|
9758 | "with-bottom": props2.showCloseButton
|
9759 | }),
|
9760 | "style": {
|
9761 | height: `${listHeight.value}px`
|
9762 | }
|
9763 | }, [disabledCoupons.map((coupon) => vue.createVNode(Coupon, {
|
9764 | "disabled": true,
|
9765 | "key": coupon.id,
|
9766 | "coupon": coupon,
|
9767 | "currency": props2.currency
|
9768 | }, null)), !disabledCoupons.length && renderEmpty(), (_a = slots["disabled-list-footer"]) == null ? void 0 : _a.call(slots)])];
|
9769 | }
|
9770 | });
|
9771 | };
|
9772 | vue.watch(() => props2.code, (value) => {
|
9773 | currentCode.value = value;
|
9774 | });
|
9775 | vue.watch(windowHeight, updateListHeight);
|
9776 | vue.watch(currentCode, (value) => emit("update:code", value));
|
9777 | vue.watch(() => props2.displayedCouponIndex, scrollToCoupon);
|
9778 | vue.onMounted(() => {
|
9779 | updateListHeight();
|
9780 | scrollToCoupon(props2.displayedCouponIndex);
|
9781 | });
|
9782 | return () => vue.createVNode("div", {
|
9783 | "ref": root,
|
9784 | "class": bem$O()
|
9785 | }, [renderExchangeBar(), vue.createVNode(Tabs, {
|
9786 | "active": activeTab.value,
|
9787 | "onUpdate:active": ($event) => activeTab.value = $event,
|
9788 | "class": bem$O("tab")
|
9789 | }, {
|
9790 | default: () => [renderCouponTab(), renderDisabledTab()]
|
9791 | }), vue.createVNode("div", {
|
9792 | "class": bem$O("bottom")
|
9793 | }, [slots["list-button"] ? slots["list-button"]() : vue.withDirectives(vue.createVNode(Button, {
|
9794 | "round": true,
|
9795 | "block": true,
|
9796 | "type": "primary",
|
9797 | "class": bem$O("close"),
|
9798 | "text": props2.closeButtonText || t$9("close"),
|
9799 | "onClick": () => emit("change", Array.isArray(props2.chosenCoupon) ? [] : -1)
|
9800 | }, null), [[vue.vShow, props2.showCloseButton]])])]);
|
9801 | }
|
9802 | });
|
9803 | const CouponList = withInstall(stdin_default$Y);
|
9804 | const currentYear = ( new Date()).getFullYear();
|
9805 | const [name$O] = createNamespace("date-picker");
|
9806 | const datePickerProps = extend({}, sharedProps, {
|
9807 | columnsType: {
|
9808 | type: Array,
|
9809 | default: () => ["year", "month", "day"]
|
9810 | },
|
9811 | minDate: {
|
9812 | type: Date,
|
9813 | default: () => new Date(currentYear - 10, 0, 1),
|
9814 | validator: isDate
|
9815 | },
|
9816 | maxDate: {
|
9817 | type: Date,
|
9818 | default: () => new Date(currentYear + 10, 11, 31),
|
9819 | validator: isDate
|
9820 | }
|
9821 | });
|
9822 | var stdin_default$X = vue.defineComponent({
|
9823 | name: name$O,
|
9824 | props: datePickerProps,
|
9825 | emits: ["confirm", "cancel", "change", "update:modelValue"],
|
9826 | setup(props2, {
|
9827 | emit,
|
9828 | slots
|
9829 | }) {
|
9830 | const currentValues = vue.ref(props2.modelValue);
|
9831 | const updatedByExternalSources = vue.ref(false);
|
9832 | const pickerRef = vue.ref();
|
9833 | const computedValues = vue.computed(() => updatedByExternalSources.value ? props2.modelValue : currentValues.value);
|
9834 | const isMinYear = (year) => year === props2.minDate.getFullYear();
|
9835 | const isMaxYear = (year) => year === props2.maxDate.getFullYear();
|
9836 | const isMinMonth = (month) => month === props2.minDate.getMonth() + 1;
|
9837 | const isMaxMonth = (month) => month === props2.maxDate.getMonth() + 1;
|
9838 | const getValue2 = (type) => {
|
9839 | const {
|
9840 | minDate,
|
9841 | columnsType
|
9842 | } = props2;
|
9843 | const index = columnsType.indexOf(type);
|
9844 | const value = computedValues.value[index];
|
9845 | if (value) {
|
9846 | return +value;
|
9847 | }
|
9848 | switch (type) {
|
9849 | case "year":
|
9850 | return minDate.getFullYear();
|
9851 | case "month":
|
9852 | return minDate.getMonth() + 1;
|
9853 | case "day":
|
9854 | return minDate.getDate();
|
9855 | }
|
9856 | };
|
9857 | const genYearOptions = () => {
|
9858 | const minYear = props2.minDate.getFullYear();
|
9859 | const maxYear = props2.maxDate.getFullYear();
|
9860 | return genOptions(minYear, maxYear, "year", props2.formatter, props2.filter, computedValues.value);
|
9861 | };
|
9862 | const genMonthOptions = () => {
|
9863 | const year = getValue2("year");
|
9864 | const minMonth = isMinYear(year) ? props2.minDate.getMonth() + 1 : 1;
|
9865 | const maxMonth = isMaxYear(year) ? props2.maxDate.getMonth() + 1 : 12;
|
9866 | return genOptions(minMonth, maxMonth, "month", props2.formatter, props2.filter, computedValues.value);
|
9867 | };
|
9868 | const genDayOptions = () => {
|
9869 | const year = getValue2("year");
|
9870 | const month = getValue2("month");
|
9871 | const minDate = isMinYear(year) && isMinMonth(month) ? props2.minDate.getDate() : 1;
|
9872 | const maxDate = isMaxYear(year) && isMaxMonth(month) ? props2.maxDate.getDate() : getMonthEndDay(year, month);
|
9873 | return genOptions(minDate, maxDate, "day", props2.formatter, props2.filter, computedValues.value);
|
9874 | };
|
9875 | const confirm = () => {
|
9876 | var _a;
|
9877 | return (_a = pickerRef.value) == null ? void 0 : _a.confirm();
|
9878 | };
|
9879 | const getSelectedDate = () => currentValues.value;
|
9880 | const columns = vue.computed(() => props2.columnsType.map((type) => {
|
9881 | switch (type) {
|
9882 | case "year":
|
9883 | return genYearOptions();
|
9884 | case "month":
|
9885 | return genMonthOptions();
|
9886 | case "day":
|
9887 | return genDayOptions();
|
9888 | default:
|
9889 | return [];
|
9890 | }
|
9891 | }));
|
9892 | vue.watch(currentValues, (newValues) => {
|
9893 | if (!isSameValue(newValues, props2.modelValue)) {
|
9894 | emit("update:modelValue", newValues);
|
9895 | }
|
9896 | });
|
9897 | vue.watch(() => props2.modelValue, (newValues, oldValues) => {
|
9898 | updatedByExternalSources.value = isSameValue(oldValues, currentValues.value);
|
9899 | newValues = formatValueRange(newValues, columns.value);
|
9900 | if (!isSameValue(newValues, currentValues.value)) {
|
9901 | currentValues.value = newValues;
|
9902 | }
|
9903 | updatedByExternalSources.value = false;
|
9904 | }, {
|
9905 | immediate: true
|
9906 | });
|
9907 | const onChange = (...args) => emit("change", ...args);
|
9908 | const onCancel = (...args) => emit("cancel", ...args);
|
9909 | const onConfirm = (...args) => emit("confirm", ...args);
|
9910 | useExpose({
|
9911 | confirm,
|
9912 | getSelectedDate
|
9913 | });
|
9914 | return () => vue.createVNode(Picker, vue.mergeProps({
|
9915 | "ref": pickerRef,
|
9916 | "modelValue": currentValues.value,
|
9917 | "onUpdate:modelValue": ($event) => currentValues.value = $event,
|
9918 | "columns": columns.value,
|
9919 | "onChange": onChange,
|
9920 | "onCancel": onCancel,
|
9921 | "onConfirm": onConfirm
|
9922 | }, pick(props2, pickerInheritKeys)), slots);
|
9923 | }
|
9924 | });
|
9925 | const DatePicker = withInstall(stdin_default$X);
|
9926 | const [name$N, bem$N, t$8] = createNamespace("dialog");
|
9927 | const dialogProps = extend({}, popupSharedProps, {
|
9928 | title: String,
|
9929 | theme: String,
|
9930 | width: numericProp,
|
9931 | message: [String, Function],
|
9932 | callback: Function,
|
9933 | allowHtml: Boolean,
|
9934 | className: unknownProp,
|
9935 | transition: makeStringProp("van-dialog-bounce"),
|
9936 | messageAlign: String,
|
9937 | closeOnPopstate: truthProp,
|
9938 | showCancelButton: Boolean,
|
9939 | cancelButtonText: String,
|
9940 | cancelButtonColor: String,
|
9941 | cancelButtonDisabled: Boolean,
|
9942 | confirmButtonText: String,
|
9943 | confirmButtonColor: String,
|
9944 | confirmButtonDisabled: Boolean,
|
9945 | showConfirmButton: truthProp,
|
9946 | closeOnClickOverlay: Boolean
|
9947 | });
|
9948 | const popupInheritKeys$1 = [...popupSharedPropKeys, "transition", "closeOnPopstate"];
|
9949 | var stdin_default$W = vue.defineComponent({
|
9950 | name: name$N,
|
9951 | props: dialogProps,
|
9952 | emits: ["confirm", "cancel", "keydown", "update:show"],
|
9953 | setup(props2, {
|
9954 | emit,
|
9955 | slots
|
9956 | }) {
|
9957 | const root = vue.ref();
|
9958 | const loading = vue.reactive({
|
9959 | confirm: false,
|
9960 | cancel: false
|
9961 | });
|
9962 | const updateShow = (value) => emit("update:show", value);
|
9963 | const close = (action) => {
|
9964 | var _a;
|
9965 | updateShow(false);
|
9966 | (_a = props2.callback) == null ? void 0 : _a.call(props2, action);
|
9967 | };
|
9968 | const getActionHandler = (action) => () => {
|
9969 | if (!props2.show) {
|
9970 | return;
|
9971 | }
|
9972 | emit(action);
|
9973 | if (props2.beforeClose) {
|
9974 | loading[action] = true;
|
9975 | callInterceptor(props2.beforeClose, {
|
9976 | args: [action],
|
9977 | done() {
|
9978 | close(action);
|
9979 | loading[action] = false;
|
9980 | },
|
9981 | canceled() {
|
9982 | loading[action] = false;
|
9983 | }
|
9984 | });
|
9985 | } else {
|
9986 | close(action);
|
9987 | }
|
9988 | };
|
9989 | const onCancel = getActionHandler("cancel");
|
9990 | const onConfirm = getActionHandler("confirm");
|
9991 | const onKeydown = vue.withKeys((event) => {
|
9992 | var _a, _b;
|
9993 | if (event.target !== ((_b = (_a = root.value) == null ? void 0 : _a.popupRef) == null ? void 0 : _b.value)) {
|
9994 | return;
|
9995 | }
|
9996 | const onEventType = {
|
9997 | Enter: props2.showConfirmButton ? onConfirm : noop,
|
9998 | Escape: props2.showCancelButton ? onCancel : noop
|
9999 | };
|
10000 | onEventType[event.key]();
|
10001 | emit("keydown", event);
|
10002 | }, ["enter", "esc"]);
|
10003 | const renderTitle = () => {
|
10004 | const title = slots.title ? slots.title() : props2.title;
|
10005 | if (title) {
|
10006 | return vue.createVNode("div", {
|
10007 | "class": bem$N("header", {
|
10008 | isolated: !props2.message && !slots.default
|
10009 | })
|
10010 | }, [title]);
|
10011 | }
|
10012 | };
|
10013 | const renderMessage = (hasTitle) => {
|
10014 | const {
|
10015 | message,
|
10016 | allowHtml,
|
10017 | messageAlign
|
10018 | } = props2;
|
10019 | const classNames = bem$N("message", {
|
10020 | "has-title": hasTitle,
|
10021 | [messageAlign]: messageAlign
|
10022 | });
|
10023 | const content = isFunction(message) ? message() : message;
|
10024 | if (allowHtml && typeof content === "string") {
|
10025 | return vue.createVNode("div", {
|
10026 | "class": classNames,
|
10027 | "innerHTML": content
|
10028 | }, null);
|
10029 | }
|
10030 | return vue.createVNode("div", {
|
10031 | "class": classNames
|
10032 | }, [content]);
|
10033 | };
|
10034 | const renderContent = () => {
|
10035 | if (slots.default) {
|
10036 | return vue.createVNode("div", {
|
10037 | "class": bem$N("content")
|
10038 | }, [slots.default()]);
|
10039 | }
|
10040 | const {
|
10041 | title,
|
10042 | message,
|
10043 | allowHtml
|
10044 | } = props2;
|
10045 | if (message) {
|
10046 | const hasTitle = !!(title || slots.title);
|
10047 | return vue.createVNode("div", {
|
10048 | "key": allowHtml ? 1 : 0,
|
10049 | "class": bem$N("content", {
|
10050 | isolated: !hasTitle
|
10051 | })
|
10052 | }, [renderMessage(hasTitle)]);
|
10053 | }
|
10054 | };
|
10055 | const renderButtons = () => vue.createVNode("div", {
|
10056 | "class": [BORDER_TOP, bem$N("footer")]
|
10057 | }, [props2.showCancelButton && vue.createVNode(Button, {
|
10058 | "size": "large",
|
10059 | "text": props2.cancelButtonText || t$8("cancel"),
|
10060 | "class": bem$N("cancel"),
|
10061 | "style": {
|
10062 | color: props2.cancelButtonColor
|
10063 | },
|
10064 | "loading": loading.cancel,
|
10065 | "disabled": props2.cancelButtonDisabled,
|
10066 | "onClick": onCancel
|
10067 | }, null), props2.showConfirmButton && vue.createVNode(Button, {
|
10068 | "size": "large",
|
10069 | "text": props2.confirmButtonText || t$8("confirm"),
|
10070 | "class": [bem$N("confirm"), {
|
10071 | [BORDER_LEFT]: props2.showCancelButton
|
10072 | }],
|
10073 | "style": {
|
10074 | color: props2.confirmButtonColor
|
10075 | },
|
10076 | "loading": loading.confirm,
|
10077 | "disabled": props2.confirmButtonDisabled,
|
10078 | "onClick": onConfirm
|
10079 | }, null)]);
|
10080 | const renderRoundButtons = () => vue.createVNode(ActionBar, {
|
10081 | "class": bem$N("footer")
|
10082 | }, {
|
10083 | default: () => [props2.showCancelButton && vue.createVNode(ActionBarButton, {
|
10084 | "type": "warning",
|
10085 | "text": props2.cancelButtonText || t$8("cancel"),
|
10086 | "class": bem$N("cancel"),
|
10087 | "color": props2.cancelButtonColor,
|
10088 | "loading": loading.cancel,
|
10089 | "disabled": props2.cancelButtonDisabled,
|
10090 | "onClick": onCancel
|
10091 | }, null), props2.showConfirmButton && vue.createVNode(ActionBarButton, {
|
10092 | "type": "danger",
|
10093 | "text": props2.confirmButtonText || t$8("confirm"),
|
10094 | "class": bem$N("confirm"),
|
10095 | "color": props2.confirmButtonColor,
|
10096 | "loading": loading.confirm,
|
10097 | "disabled": props2.confirmButtonDisabled,
|
10098 | "onClick": onConfirm
|
10099 | }, null)]
|
10100 | });
|
10101 | const renderFooter = () => {
|
10102 | if (slots.footer) {
|
10103 | return slots.footer();
|
10104 | }
|
10105 | return props2.theme === "round-button" ? renderRoundButtons() : renderButtons();
|
10106 | };
|
10107 | return () => {
|
10108 | const {
|
10109 | width: width2,
|
10110 | title,
|
10111 | theme,
|
10112 | message,
|
10113 | className
|
10114 | } = props2;
|
10115 | return vue.createVNode(Popup, vue.mergeProps({
|
10116 | "ref": root,
|
10117 | "role": "dialog",
|
10118 | "class": [bem$N([theme]), className],
|
10119 | "style": {
|
10120 | width: addUnit(width2)
|
10121 | },
|
10122 | "tabindex": 0,
|
10123 | "aria-labelledby": title || message,
|
10124 | "onKeydown": onKeydown,
|
10125 | "onUpdate:show": updateShow
|
10126 | }, pick(props2, popupInheritKeys$1)), {
|
10127 | default: () => [renderTitle(), renderContent(), renderFooter()]
|
10128 | });
|
10129 | };
|
10130 | }
|
10131 | });
|
10132 | let instance$2;
|
10133 | const DEFAULT_OPTIONS$1 = {
|
10134 | title: "",
|
10135 | width: "",
|
10136 | theme: null,
|
10137 | message: "",
|
10138 | overlay: true,
|
10139 | callback: null,
|
10140 | teleport: "body",
|
10141 | className: "",
|
10142 | allowHtml: false,
|
10143 | lockScroll: true,
|
10144 | transition: void 0,
|
10145 | beforeClose: null,
|
10146 | overlayClass: "",
|
10147 | overlayStyle: void 0,
|
10148 | messageAlign: "",
|
10149 | cancelButtonText: "",
|
10150 | cancelButtonColor: null,
|
10151 | cancelButtonDisabled: false,
|
10152 | confirmButtonText: "",
|
10153 | confirmButtonColor: null,
|
10154 | confirmButtonDisabled: false,
|
10155 | showConfirmButton: true,
|
10156 | showCancelButton: false,
|
10157 | closeOnPopstate: true,
|
10158 | closeOnClickOverlay: false
|
10159 | };
|
10160 | let currentOptions$1 = extend({}, DEFAULT_OPTIONS$1);
|
10161 | function initInstance$2() {
|
10162 | const Wrapper = {
|
10163 | setup() {
|
10164 | const {
|
10165 | state,
|
10166 | toggle
|
10167 | } = usePopupState();
|
10168 | return () => vue.createVNode(stdin_default$W, vue.mergeProps(state, {
|
10169 | "onUpdate:show": toggle
|
10170 | }), null);
|
10171 | }
|
10172 | };
|
10173 | ({
|
10174 | instance: instance$2
|
10175 | } = mountComponent(Wrapper));
|
10176 | }
|
10177 | function showDialog(options) {
|
10178 | if (!inBrowser$1) {
|
10179 | return Promise.resolve(void 0);
|
10180 | }
|
10181 | return new Promise((resolve, reject) => {
|
10182 | if (!instance$2) {
|
10183 | initInstance$2();
|
10184 | }
|
10185 | instance$2.open(extend({}, currentOptions$1, options, {
|
10186 | callback: (action) => {
|
10187 | (action === "confirm" ? resolve : reject)(action);
|
10188 | }
|
10189 | }));
|
10190 | });
|
10191 | }
|
10192 | const setDialogDefaultOptions = (options) => {
|
10193 | extend(currentOptions$1, options);
|
10194 | };
|
10195 | const resetDialogDefaultOptions = () => {
|
10196 | currentOptions$1 = extend({}, DEFAULT_OPTIONS$1);
|
10197 | };
|
10198 | const showConfirmDialog = (options) => showDialog(extend({
|
10199 | showCancelButton: true
|
10200 | }, options));
|
10201 | const closeDialog = () => {
|
10202 | if (instance$2) {
|
10203 | instance$2.toggle(false);
|
10204 | }
|
10205 | };
|
10206 | const Dialog = withInstall(stdin_default$W);
|
10207 | const [name$M, bem$M] = createNamespace("divider");
|
10208 | const dividerProps = {
|
10209 | dashed: Boolean,
|
10210 | hairline: truthProp,
|
10211 | vertical: Boolean,
|
10212 | contentPosition: makeStringProp("center")
|
10213 | };
|
10214 | var stdin_default$V = vue.defineComponent({
|
10215 | name: name$M,
|
10216 | props: dividerProps,
|
10217 | setup(props2, {
|
10218 | slots
|
10219 | }) {
|
10220 | return () => {
|
10221 | var _a;
|
10222 | return vue.createVNode("div", {
|
10223 | "role": "separator",
|
10224 | "class": bem$M({
|
10225 | dashed: props2.dashed,
|
10226 | hairline: props2.hairline,
|
10227 | vertical: props2.vertical,
|
10228 | [`content-${props2.contentPosition}`]: !!slots.default && !props2.vertical
|
10229 | })
|
10230 | }, [!props2.vertical && ((_a = slots.default) == null ? void 0 : _a.call(slots))]);
|
10231 | };
|
10232 | }
|
10233 | });
|
10234 | const Divider = withInstall(stdin_default$V);
|
10235 | const [name$L, bem$L] = createNamespace("dropdown-menu");
|
10236 | const dropdownMenuProps = {
|
10237 | overlay: truthProp,
|
10238 | zIndex: numericProp,
|
10239 | duration: makeNumericProp(0.2),
|
10240 | direction: makeStringProp("down"),
|
10241 | activeColor: String,
|
10242 | autoLocate: Boolean,
|
10243 | closeOnClickOutside: truthProp,
|
10244 | closeOnClickOverlay: truthProp,
|
10245 | swipeThreshold: numericProp
|
10246 | };
|
10247 | const DROPDOWN_KEY = Symbol(name$L);
|
10248 | var stdin_default$U = vue.defineComponent({
|
10249 | name: name$L,
|
10250 | props: dropdownMenuProps,
|
10251 | setup(props2, {
|
10252 | slots
|
10253 | }) {
|
10254 | const id = useId();
|
10255 | const root = vue.ref();
|
10256 | const barRef = vue.ref();
|
10257 | const offset2 = vue.ref(0);
|
10258 | const {
|
10259 | children,
|
10260 | linkChildren
|
10261 | } = useChildren(DROPDOWN_KEY);
|
10262 | const scrollParent = useScrollParent(root);
|
10263 | const opened = vue.computed(() => children.some((item) => item.state.showWrapper));
|
10264 | const scrollable = vue.computed(() => props2.swipeThreshold && children.length > +props2.swipeThreshold);
|
10265 | const barStyle = vue.computed(() => {
|
10266 | if (opened.value && isDef(props2.zIndex)) {
|
10267 | return {
|
10268 | zIndex: +props2.zIndex + 1
|
10269 | };
|
10270 | }
|
10271 | });
|
10272 | const close = () => {
|
10273 | children.forEach((item) => {
|
10274 | item.toggle(false);
|
10275 | });
|
10276 | };
|
10277 | const onClickAway = () => {
|
10278 | if (props2.closeOnClickOutside) {
|
10279 | close();
|
10280 | }
|
10281 | };
|
10282 | const updateOffset = () => {
|
10283 | if (barRef.value) {
|
10284 | const rect = useRect(barRef);
|
10285 | if (props2.direction === "down") {
|
10286 | offset2.value = rect.bottom;
|
10287 | } else {
|
10288 | offset2.value = windowHeight.value - rect.top;
|
10289 | }
|
10290 | }
|
10291 | };
|
10292 | const onScroll = () => {
|
10293 | if (opened.value) {
|
10294 | updateOffset();
|
10295 | }
|
10296 | };
|
10297 | const toggleItem = (active) => {
|
10298 | children.forEach((item, index) => {
|
10299 | if (index === active) {
|
10300 | item.toggle();
|
10301 | } else if (item.state.showPopup) {
|
10302 | item.toggle(false, {
|
10303 | immediate: true
|
10304 | });
|
10305 | }
|
10306 | });
|
10307 | };
|
10308 | const renderTitle = (item, index) => {
|
10309 | const {
|
10310 | showPopup
|
10311 | } = item.state;
|
10312 | const {
|
10313 | disabled,
|
10314 | titleClass
|
10315 | } = item;
|
10316 | return vue.createVNode("div", {
|
10317 | "id": `${id}-${index}`,
|
10318 | "role": "button",
|
10319 | "tabindex": disabled ? void 0 : 0,
|
10320 | "data-allow-mismatch": "attribute",
|
10321 | "class": [bem$L("item", {
|
10322 | disabled,
|
10323 | grow: scrollable.value
|
10324 | }), {
|
10325 | [HAPTICS_FEEDBACK]: !disabled
|
10326 | }],
|
10327 | "onClick": () => {
|
10328 | if (!disabled) {
|
10329 | toggleItem(index);
|
10330 | }
|
10331 | }
|
10332 | }, [vue.createVNode("span", {
|
10333 | "class": [bem$L("title", {
|
10334 | down: showPopup === (props2.direction === "down"),
|
10335 | active: showPopup
|
10336 | }), titleClass],
|
10337 | "style": {
|
10338 | color: showPopup ? props2.activeColor : ""
|
10339 | }
|
10340 | }, [vue.createVNode("div", {
|
10341 | "class": "van-ellipsis"
|
10342 | }, [item.renderTitle()])])]);
|
10343 | };
|
10344 | useExpose({
|
10345 | close
|
10346 | });
|
10347 | linkChildren({
|
10348 | id,
|
10349 | props: props2,
|
10350 | offset: offset2,
|
10351 | updateOffset
|
10352 | });
|
10353 | useClickAway(root, onClickAway);
|
10354 | useEventListener("scroll", onScroll, {
|
10355 | target: scrollParent,
|
10356 | passive: true
|
10357 | });
|
10358 | return () => {
|
10359 | var _a;
|
10360 | return vue.createVNode("div", {
|
10361 | "ref": root,
|
10362 | "class": bem$L()
|
10363 | }, [vue.createVNode("div", {
|
10364 | "ref": barRef,
|
10365 | "style": barStyle.value,
|
10366 | "class": bem$L("bar", {
|
10367 | opened: opened.value,
|
10368 | scrollable: scrollable.value
|
10369 | })
|
10370 | }, [children.map(renderTitle)]), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
10371 | };
|
10372 | }
|
10373 | });
|
10374 | const [name$K, bem$K] = createNamespace("dropdown-item");
|
10375 | const dropdownItemProps = {
|
10376 | title: String,
|
10377 | options: makeArrayProp(),
|
10378 | disabled: Boolean,
|
10379 | teleport: [String, Object],
|
10380 | lazyRender: truthProp,
|
10381 | modelValue: unknownProp,
|
10382 | titleClass: unknownProp
|
10383 | };
|
10384 | var stdin_default$T = vue.defineComponent({
|
10385 | name: name$K,
|
10386 | inheritAttrs: false,
|
10387 | props: dropdownItemProps,
|
10388 | emits: ["open", "opened", "close", "closed", "change", "update:modelValue"],
|
10389 | setup(props2, {
|
10390 | emit,
|
10391 | slots,
|
10392 | attrs
|
10393 | }) {
|
10394 | const state = vue.reactive({
|
10395 | showPopup: false,
|
10396 | transition: true,
|
10397 | showWrapper: false
|
10398 | });
|
10399 | const wrapperRef = vue.ref();
|
10400 | const {
|
10401 | parent,
|
10402 | index
|
10403 | } = useParent(DROPDOWN_KEY);
|
10404 | if (!parent) {
|
10405 | return;
|
10406 | }
|
10407 | const getEmitter = (name2) => () => emit(name2);
|
10408 | const onOpen = getEmitter("open");
|
10409 | const onClose = getEmitter("close");
|
10410 | const onOpened = getEmitter("opened");
|
10411 | const onClosed = () => {
|
10412 | state.showWrapper = false;
|
10413 | emit("closed");
|
10414 | };
|
10415 | const onClickWrapper = (event) => {
|
10416 | if (props2.teleport) {
|
10417 | event.stopPropagation();
|
10418 | }
|
10419 | };
|
10420 | const toggle = (show = !state.showPopup, options = {}) => {
|
10421 | if (show === state.showPopup) {
|
10422 | return;
|
10423 | }
|
10424 | state.showPopup = show;
|
10425 | state.transition = !options.immediate;
|
10426 | if (show) {
|
10427 | parent.updateOffset();
|
10428 | state.showWrapper = true;
|
10429 | }
|
10430 | };
|
10431 | const renderTitle = () => {
|
10432 | if (slots.title) {
|
10433 | return slots.title();
|
10434 | }
|
10435 | if (props2.title) {
|
10436 | return props2.title;
|
10437 | }
|
10438 | const match = props2.options.find((option) => option.value === props2.modelValue);
|
10439 | return match ? match.text : "";
|
10440 | };
|
10441 | const renderOption = (option) => {
|
10442 | const {
|
10443 | activeColor
|
10444 | } = parent.props;
|
10445 | const {
|
10446 | disabled
|
10447 | } = option;
|
10448 | const active = option.value === props2.modelValue;
|
10449 | const onClick = () => {
|
10450 | if (disabled) {
|
10451 | return;
|
10452 | }
|
10453 | state.showPopup = false;
|
10454 | if (option.value !== props2.modelValue) {
|
10455 | emit("update:modelValue", option.value);
|
10456 | emit("change", option.value);
|
10457 | }
|
10458 | };
|
10459 | const renderIcon = () => {
|
10460 | if (active) {
|
10461 | return vue.createVNode(Icon, {
|
10462 | "class": bem$K("icon"),
|
10463 | "color": disabled ? void 0 : activeColor,
|
10464 | "name": "success"
|
10465 | }, null);
|
10466 | }
|
10467 | };
|
10468 | return vue.createVNode(Cell, {
|
10469 | "role": "menuitem",
|
10470 | "key": String(option.value),
|
10471 | "icon": option.icon,
|
10472 | "title": option.text,
|
10473 | "class": bem$K("option", {
|
10474 | active,
|
10475 | disabled
|
10476 | }),
|
10477 | "style": {
|
10478 | color: active ? activeColor : ""
|
10479 | },
|
10480 | "tabindex": active ? 0 : -1,
|
10481 | "clickable": !disabled,
|
10482 | "onClick": onClick
|
10483 | }, {
|
10484 | value: renderIcon
|
10485 | });
|
10486 | };
|
10487 | const renderContent = () => {
|
10488 | const {
|
10489 | offset: offset2
|
10490 | } = parent;
|
10491 | const {
|
10492 | autoLocate,
|
10493 | zIndex,
|
10494 | overlay,
|
10495 | duration,
|
10496 | direction,
|
10497 | closeOnClickOverlay
|
10498 | } = parent.props;
|
10499 | const style = getZIndexStyle(zIndex);
|
10500 | let offsetValue = offset2.value;
|
10501 | if (autoLocate && wrapperRef.value) {
|
10502 | const offsetParent = getContainingBlock$1(wrapperRef.value);
|
10503 | if (offsetParent) {
|
10504 | offsetValue -= useRect(offsetParent).top;
|
10505 | }
|
10506 | }
|
10507 | if (direction === "down") {
|
10508 | style.top = `${offsetValue}px`;
|
10509 | } else {
|
10510 | style.bottom = `${offsetValue}px`;
|
10511 | }
|
10512 | return vue.withDirectives(vue.createVNode("div", vue.mergeProps({
|
10513 | "ref": wrapperRef,
|
10514 | "style": style,
|
10515 | "class": bem$K([direction]),
|
10516 | "onClick": onClickWrapper
|
10517 | }, attrs), [vue.createVNode(Popup, {
|
10518 | "show": state.showPopup,
|
10519 | "onUpdate:show": ($event) => state.showPopup = $event,
|
10520 | "role": "menu",
|
10521 | "class": bem$K("content"),
|
10522 | "overlay": overlay,
|
10523 | "position": direction === "down" ? "top" : "bottom",
|
10524 | "duration": state.transition ? duration : 0,
|
10525 | "lazyRender": props2.lazyRender,
|
10526 | "overlayStyle": {
|
10527 | position: "absolute"
|
10528 | },
|
10529 | "aria-labelledby": `${parent.id}-${index.value}`,
|
10530 | "data-allow-mismatch": "attribute",
|
10531 | "closeOnClickOverlay": closeOnClickOverlay,
|
10532 | "onOpen": onOpen,
|
10533 | "onClose": onClose,
|
10534 | "onOpened": onOpened,
|
10535 | "onClosed": onClosed
|
10536 | }, {
|
10537 | default: () => {
|
10538 | var _a;
|
10539 | return [props2.options.map(renderOption), (_a = slots.default) == null ? void 0 : _a.call(slots)];
|
10540 | }
|
10541 | })]), [[vue.vShow, state.showWrapper]]);
|
10542 | };
|
10543 | useExpose({
|
10544 | state,
|
10545 | toggle,
|
10546 | renderTitle
|
10547 | });
|
10548 | return () => {
|
10549 | if (props2.teleport) {
|
10550 | return vue.createVNode(vue.Teleport, {
|
10551 | "to": props2.teleport
|
10552 | }, {
|
10553 | default: () => [renderContent()]
|
10554 | });
|
10555 | }
|
10556 | return renderContent();
|
10557 | };
|
10558 | }
|
10559 | });
|
10560 | const DropdownItem = withInstall(stdin_default$T);
|
10561 | const DropdownMenu = withInstall(stdin_default$U);
|
10562 | const floatingBubbleProps = {
|
10563 | gap: makeNumberProp(24),
|
10564 | icon: String,
|
10565 | axis: makeStringProp("y"),
|
10566 | magnetic: String,
|
10567 | offset: {
|
10568 | type: Object,
|
10569 | default: () => ({
|
10570 | x: -1,
|
10571 | y: -1
|
10572 | })
|
10573 | },
|
10574 | teleport: {
|
10575 | type: [String, Object],
|
10576 | default: "body"
|
10577 | }
|
10578 | };
|
10579 | const [name$J, bem$J] = createNamespace("floating-bubble");
|
10580 | var stdin_default$S = vue.defineComponent({
|
10581 | name: name$J,
|
10582 | inheritAttrs: false,
|
10583 | props: floatingBubbleProps,
|
10584 | emits: ["click", "update:offset", "offsetChange"],
|
10585 | setup(props2, {
|
10586 | slots,
|
10587 | emit,
|
10588 | attrs
|
10589 | }) {
|
10590 | const rootRef = vue.ref();
|
10591 | const state = vue.ref({
|
10592 | x: 0,
|
10593 | y: 0,
|
10594 | width: 0,
|
10595 | height: 0
|
10596 | });
|
10597 | const boundary = vue.computed(() => ({
|
10598 | top: props2.gap,
|
10599 | right: windowWidth.value - state.value.width - props2.gap,
|
10600 | bottom: windowHeight.value - state.value.height - props2.gap,
|
10601 | left: props2.gap
|
10602 | }));
|
10603 | const dragging = vue.ref(false);
|
10604 | let initialized = false;
|
10605 | const rootStyle = vue.computed(() => {
|
10606 | const style = {};
|
10607 | const x = addUnit(state.value.x);
|
10608 | const y = addUnit(state.value.y);
|
10609 | style.transform = `translate3d(${x}, ${y}, 0)`;
|
10610 | if (dragging.value || !initialized) {
|
10611 | style.transition = "none";
|
10612 | }
|
10613 | return style;
|
10614 | });
|
10615 | const updateState = () => {
|
10616 | if (!show.value) return;
|
10617 | const {
|
10618 | width: width2,
|
10619 | height: height2
|
10620 | } = useRect(rootRef.value);
|
10621 | const {
|
10622 | offset: offset2
|
10623 | } = props2;
|
10624 | state.value = {
|
10625 | x: offset2.x > -1 ? offset2.x : windowWidth.value - width2 - props2.gap,
|
10626 | y: offset2.y > -1 ? offset2.y : windowHeight.value - height2 - props2.gap,
|
10627 | width: width2,
|
10628 | height: height2
|
10629 | };
|
10630 | };
|
10631 | const touch = useTouch();
|
10632 | let prevX = 0;
|
10633 | let prevY = 0;
|
10634 | const onTouchStart = (e) => {
|
10635 | touch.start(e);
|
10636 | dragging.value = true;
|
10637 | prevX = state.value.x;
|
10638 | prevY = state.value.y;
|
10639 | };
|
10640 | const onTouchMove = (e) => {
|
10641 | e.preventDefault();
|
10642 | touch.move(e);
|
10643 | if (props2.axis === "lock") return;
|
10644 | if (!touch.isTap.value) {
|
10645 | if (props2.axis === "x" || props2.axis === "xy") {
|
10646 | let nextX = prevX + touch.deltaX.value;
|
10647 | if (nextX < boundary.value.left) nextX = boundary.value.left;
|
10648 | if (nextX > boundary.value.right) nextX = boundary.value.right;
|
10649 | state.value.x = nextX;
|
10650 | }
|
10651 | if (props2.axis === "y" || props2.axis === "xy") {
|
10652 | let nextY = prevY + touch.deltaY.value;
|
10653 | if (nextY < boundary.value.top) nextY = boundary.value.top;
|
10654 | if (nextY > boundary.value.bottom) nextY = boundary.value.bottom;
|
10655 | state.value.y = nextY;
|
10656 | }
|
10657 | const offset2 = pick(state.value, ["x", "y"]);
|
10658 | emit("update:offset", offset2);
|
10659 | }
|
10660 | };
|
10661 | useEventListener("touchmove", onTouchMove, {
|
10662 | target: rootRef
|
10663 | });
|
10664 | const onTouchEnd = () => {
|
10665 | dragging.value = false;
|
10666 | vue.nextTick(() => {
|
10667 | if (props2.magnetic === "x") {
|
10668 | const nextX = closest([boundary.value.left, boundary.value.right], state.value.x);
|
10669 | state.value.x = nextX;
|
10670 | }
|
10671 | if (props2.magnetic === "y") {
|
10672 | const nextY = closest([boundary.value.top, boundary.value.bottom], state.value.y);
|
10673 | state.value.y = nextY;
|
10674 | }
|
10675 | if (!touch.isTap.value) {
|
10676 | const offset2 = pick(state.value, ["x", "y"]);
|
10677 | emit("update:offset", offset2);
|
10678 | if (prevX !== offset2.x || prevY !== offset2.y) {
|
10679 | emit("offsetChange", offset2);
|
10680 | }
|
10681 | }
|
10682 | });
|
10683 | };
|
10684 | const onClick = (e) => {
|
10685 | if (touch.isTap.value) emit("click", e);
|
10686 | else e.stopPropagation();
|
10687 | };
|
10688 | vue.onMounted(() => {
|
10689 | updateState();
|
10690 | vue.nextTick(() => {
|
10691 | initialized = true;
|
10692 | });
|
10693 | });
|
10694 | vue.watch([windowWidth, windowHeight, () => props2.gap, () => props2.offset], updateState, {
|
10695 | deep: true
|
10696 | });
|
10697 | const show = vue.ref(true);
|
10698 | vue.onActivated(() => {
|
10699 | show.value = true;
|
10700 | });
|
10701 | vue.onDeactivated(() => {
|
10702 | if (props2.teleport) {
|
10703 | show.value = false;
|
10704 | }
|
10705 | });
|
10706 | return () => {
|
10707 | const Content = vue.withDirectives(vue.createVNode("div", vue.mergeProps({
|
10708 | "class": bem$J(),
|
10709 | "ref": rootRef,
|
10710 | "onTouchstartPassive": onTouchStart,
|
10711 | "onTouchend": onTouchEnd,
|
10712 | "onTouchcancel": onTouchEnd,
|
10713 | "onClickCapture": onClick,
|
10714 | "style": rootStyle.value
|
10715 | }, attrs), [slots.default ? slots.default() : vue.createVNode(stdin_default$1Q, {
|
10716 | "name": props2.icon,
|
10717 | "class": bem$J("icon")
|
10718 | }, null)]), [[vue.vShow, show.value]]);
|
10719 | return props2.teleport ? vue.createVNode(vue.Teleport, {
|
10720 | "to": props2.teleport
|
10721 | }, {
|
10722 | default: () => [Content]
|
10723 | }) : Content;
|
10724 | };
|
10725 | }
|
10726 | });
|
10727 | const FloatingBubble = withInstall(stdin_default$S);
|
10728 | const floatingPanelProps = {
|
10729 | height: makeNumericProp(0),
|
10730 | anchors: makeArrayProp(),
|
10731 | duration: makeNumericProp(0.3),
|
10732 | contentDraggable: truthProp,
|
10733 | lockScroll: Boolean,
|
10734 | safeAreaInsetBottom: truthProp
|
10735 | };
|
10736 | const [name$I, bem$I] = createNamespace("floating-panel");
|
10737 | var stdin_default$R = vue.defineComponent({
|
10738 | name: name$I,
|
10739 | props: floatingPanelProps,
|
10740 | emits: ["heightChange", "update:height"],
|
10741 | setup(props2, {
|
10742 | emit,
|
10743 | slots
|
10744 | }) {
|
10745 | const DAMP = 0.2;
|
10746 | const rootRef = vue.ref();
|
10747 | const contentRef = vue.ref();
|
10748 | const height2 = useSyncPropRef(() => +props2.height, (value) => emit("update:height", value));
|
10749 | const boundary = vue.computed(() => {
|
10750 | var _a, _b;
|
10751 | return {
|
10752 | min: (_a = props2.anchors[0]) != null ? _a : 100,
|
10753 | max: (_b = props2.anchors[props2.anchors.length - 1]) != null ? _b : Math.round(windowHeight.value * 0.6)
|
10754 | };
|
10755 | });
|
10756 | const anchors = vue.computed(() => props2.anchors.length >= 2 ? props2.anchors : [boundary.value.min, boundary.value.max]);
|
10757 | const dragging = vue.ref(false);
|
10758 | const rootStyle = vue.computed(() => ({
|
10759 | height: addUnit(boundary.value.max),
|
10760 | transform: `translateY(calc(100% + ${addUnit(-height2.value)}))`,
|
10761 | transition: !dragging.value ? `transform ${props2.duration}s cubic-bezier(0.18, 0.89, 0.32, 1.28)` : "none"
|
10762 | }));
|
10763 | const ease = (moveY) => {
|
10764 | const absDistance = Math.abs(moveY);
|
10765 | const {
|
10766 | min,
|
10767 | max
|
10768 | } = boundary.value;
|
10769 | if (absDistance > max) {
|
10770 | return -(max + (absDistance - max) * DAMP);
|
10771 | }
|
10772 | if (absDistance < min) {
|
10773 | return -(min - (min - absDistance) * DAMP);
|
10774 | }
|
10775 | return moveY;
|
10776 | };
|
10777 | let startY;
|
10778 | let maxScroll = -1;
|
10779 | const touch = useTouch();
|
10780 | const onTouchstart = (e) => {
|
10781 | touch.start(e);
|
10782 | dragging.value = true;
|
10783 | startY = -height2.value;
|
10784 | maxScroll = -1;
|
10785 | };
|
10786 | const onTouchmove = (e) => {
|
10787 | var _a;
|
10788 | touch.move(e);
|
10789 | const target = e.target;
|
10790 | if (contentRef.value === target || ((_a = contentRef.value) == null ? void 0 : _a.contains(target))) {
|
10791 | const {
|
10792 | scrollTop
|
10793 | } = contentRef.value;
|
10794 | maxScroll = Math.max(maxScroll, scrollTop);
|
10795 | if (!props2.contentDraggable) return;
|
10796 | if (-startY < boundary.value.max) {
|
10797 | preventDefault(e, true);
|
10798 | } else if (!(scrollTop <= 0 && touch.deltaY.value > 0) || maxScroll > 0) {
|
10799 | return;
|
10800 | }
|
10801 | }
|
10802 | const moveY = touch.deltaY.value + startY;
|
10803 | height2.value = -ease(moveY);
|
10804 | };
|
10805 | const onTouchend = () => {
|
10806 | maxScroll = -1;
|
10807 | dragging.value = false;
|
10808 | height2.value = closest(anchors.value, height2.value);
|
10809 | if (height2.value !== -startY) {
|
10810 | emit("heightChange", {
|
10811 | height: height2.value
|
10812 | });
|
10813 | }
|
10814 | };
|
10815 | vue.watch(boundary, () => {
|
10816 | height2.value = closest(anchors.value, height2.value);
|
10817 | }, {
|
10818 | immediate: true
|
10819 | });
|
10820 | useLockScroll(rootRef, () => props2.lockScroll || dragging.value);
|
10821 | useEventListener("touchmove", onTouchmove, {
|
10822 | target: rootRef
|
10823 | });
|
10824 | const renderHeader = () => {
|
10825 | if (slots.header) {
|
10826 | return slots.header();
|
10827 | }
|
10828 | return vue.createVNode("div", {
|
10829 | "class": bem$I("header")
|
10830 | }, [vue.createVNode("div", {
|
10831 | "class": bem$I("header-bar")
|
10832 | }, null)]);
|
10833 | };
|
10834 | return () => {
|
10835 | var _a;
|
10836 | return vue.createVNode("div", {
|
10837 | "class": [bem$I(), {
|
10838 | "van-safe-area-bottom": props2.safeAreaInsetBottom
|
10839 | }],
|
10840 | "ref": rootRef,
|
10841 | "style": rootStyle.value,
|
10842 | "onTouchstartPassive": onTouchstart,
|
10843 | "onTouchend": onTouchend,
|
10844 | "onTouchcancel": onTouchend
|
10845 | }, [renderHeader(), vue.createVNode("div", {
|
10846 | "class": bem$I("content"),
|
10847 | "ref": contentRef
|
10848 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
|
10849 | };
|
10850 | }
|
10851 | });
|
10852 | const FloatingPanel = withInstall(stdin_default$R);
|
10853 | const [name$H, bem$H] = createNamespace("grid");
|
10854 | const gridProps = {
|
10855 | square: Boolean,
|
10856 | center: truthProp,
|
10857 | border: truthProp,
|
10858 | gutter: numericProp,
|
10859 | reverse: Boolean,
|
10860 | iconSize: numericProp,
|
10861 | direction: String,
|
10862 | clickable: Boolean,
|
10863 | columnNum: makeNumericProp(4)
|
10864 | };
|
10865 | const GRID_KEY = Symbol(name$H);
|
10866 | var stdin_default$Q = vue.defineComponent({
|
10867 | name: name$H,
|
10868 | props: gridProps,
|
10869 | setup(props2, {
|
10870 | slots
|
10871 | }) {
|
10872 | const {
|
10873 | linkChildren
|
10874 | } = useChildren(GRID_KEY);
|
10875 | linkChildren({
|
10876 | props: props2
|
10877 | });
|
10878 | return () => {
|
10879 | var _a;
|
10880 | return vue.createVNode("div", {
|
10881 | "style": {
|
10882 | paddingLeft: addUnit(props2.gutter)
|
10883 | },
|
10884 | "class": [bem$H(), {
|
10885 | [BORDER_TOP]: props2.border && !props2.gutter
|
10886 | }]
|
10887 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
10888 | };
|
10889 | }
|
10890 | });
|
10891 | const Grid = withInstall(stdin_default$Q);
|
10892 | const [name$G, bem$G] = createNamespace("grid-item");
|
10893 | const gridItemProps = extend({}, routeProps, {
|
10894 | dot: Boolean,
|
10895 | text: String,
|
10896 | icon: String,
|
10897 | badge: numericProp,
|
10898 | iconColor: String,
|
10899 | iconPrefix: String,
|
10900 | badgeProps: Object
|
10901 | });
|
10902 | var stdin_default$P = vue.defineComponent({
|
10903 | name: name$G,
|
10904 | props: gridItemProps,
|
10905 | setup(props2, {
|
10906 | slots
|
10907 | }) {
|
10908 | const {
|
10909 | parent,
|
10910 | index
|
10911 | } = useParent(GRID_KEY);
|
10912 | const route2 = useRoute();
|
10913 | if (!parent) {
|
10914 | return;
|
10915 | }
|
10916 | const rootStyle = vue.computed(() => {
|
10917 | const {
|
10918 | square,
|
10919 | gutter,
|
10920 | columnNum
|
10921 | } = parent.props;
|
10922 | const percent = `${100 / +columnNum}%`;
|
10923 | const style = {
|
10924 | flexBasis: percent
|
10925 | };
|
10926 | if (square) {
|
10927 | style.paddingTop = percent;
|
10928 | } else if (gutter) {
|
10929 | const gutterValue = addUnit(gutter);
|
10930 | style.paddingRight = gutterValue;
|
10931 | if (index.value >= +columnNum) {
|
10932 | style.marginTop = gutterValue;
|
10933 | }
|
10934 | }
|
10935 | return style;
|
10936 | });
|
10937 | const contentStyle = vue.computed(() => {
|
10938 | const {
|
10939 | square,
|
10940 | gutter
|
10941 | } = parent.props;
|
10942 | if (square && gutter) {
|
10943 | const gutterValue = addUnit(gutter);
|
10944 | return {
|
10945 | right: gutterValue,
|
10946 | bottom: gutterValue,
|
10947 | height: "auto"
|
10948 | };
|
10949 | }
|
10950 | });
|
10951 | const renderIcon = () => {
|
10952 | if (slots.icon) {
|
10953 | return vue.createVNode(Badge, vue.mergeProps({
|
10954 | "dot": props2.dot,
|
10955 | "content": props2.badge
|
10956 | }, props2.badgeProps), {
|
10957 | default: slots.icon
|
10958 | });
|
10959 | }
|
10960 | if (props2.icon) {
|
10961 | return vue.createVNode(Icon, {
|
10962 | "dot": props2.dot,
|
10963 | "name": props2.icon,
|
10964 | "size": parent.props.iconSize,
|
10965 | "badge": props2.badge,
|
10966 | "class": bem$G("icon"),
|
10967 | "color": props2.iconColor,
|
10968 | "badgeProps": props2.badgeProps,
|
10969 | "classPrefix": props2.iconPrefix
|
10970 | }, null);
|
10971 | }
|
10972 | };
|
10973 | const renderText = () => {
|
10974 | if (slots.text) {
|
10975 | return slots.text();
|
10976 | }
|
10977 | if (props2.text) {
|
10978 | return vue.createVNode("span", {
|
10979 | "class": bem$G("text")
|
10980 | }, [props2.text]);
|
10981 | }
|
10982 | };
|
10983 | const renderContent = () => {
|
10984 | if (slots.default) {
|
10985 | return slots.default();
|
10986 | }
|
10987 | return [renderIcon(), renderText()];
|
10988 | };
|
10989 | return () => {
|
10990 | const {
|
10991 | center,
|
10992 | border,
|
10993 | square,
|
10994 | gutter,
|
10995 | reverse,
|
10996 | direction,
|
10997 | clickable
|
10998 | } = parent.props;
|
10999 | const classes = [bem$G("content", [direction, {
|
11000 | center,
|
11001 | square,
|
11002 | reverse,
|
11003 | clickable,
|
11004 | surround: border && gutter
|
11005 | }]), {
|
11006 | [BORDER]: border
|
11007 | }];
|
11008 | return vue.createVNode("div", {
|
11009 | "class": [bem$G({
|
11010 | square
|
11011 | })],
|
11012 | "style": rootStyle.value
|
11013 | }, [vue.createVNode("div", {
|
11014 | "role": clickable ? "button" : void 0,
|
11015 | "class": classes,
|
11016 | "style": contentStyle.value,
|
11017 | "tabindex": clickable ? 0 : void 0,
|
11018 | "onClick": route2
|
11019 | }, [renderContent()])]);
|
11020 | };
|
11021 | }
|
11022 | });
|
11023 | const GridItem = withInstall(stdin_default$P);
|
11024 | const [name$F, bem$F] = createNamespace("highlight");
|
11025 | const highlightProps = {
|
11026 | autoEscape: truthProp,
|
11027 | caseSensitive: Boolean,
|
11028 | highlightClass: String,
|
11029 | highlightTag: makeStringProp("span"),
|
11030 | keywords: makeRequiredProp([String, Array]),
|
11031 | sourceString: makeStringProp(""),
|
11032 | tag: makeStringProp("div"),
|
11033 | unhighlightClass: String,
|
11034 | unhighlightTag: makeStringProp("span")
|
11035 | };
|
11036 | var stdin_default$O = vue.defineComponent({
|
11037 | name: name$F,
|
11038 | props: highlightProps,
|
11039 | setup(props2) {
|
11040 | const highlightChunks = vue.computed(() => {
|
11041 | const {
|
11042 | autoEscape,
|
11043 | caseSensitive,
|
11044 | keywords,
|
11045 | sourceString
|
11046 | } = props2;
|
11047 | const flags = caseSensitive ? "g" : "gi";
|
11048 | const _keywords = Array.isArray(keywords) ? keywords : [keywords];
|
11049 | let chunks = _keywords.filter((keyword) => keyword).reduce((chunks2, keyword) => {
|
11050 | if (autoEscape) {
|
11051 | keyword = keyword.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
11052 | }
|
11053 | const regex = new RegExp(keyword, flags);
|
11054 | let match;
|
11055 | while (match = regex.exec(sourceString)) {
|
11056 | const start2 = match.index;
|
11057 | const end2 = regex.lastIndex;
|
11058 | if (start2 >= end2) {
|
11059 | regex.lastIndex++;
|
11060 | continue;
|
11061 | }
|
11062 | chunks2.push({
|
11063 | start: start2,
|
11064 | end: end2,
|
11065 | highlight: true
|
11066 | });
|
11067 | }
|
11068 | return chunks2;
|
11069 | }, []);
|
11070 | chunks = chunks.sort((a, b) => a.start - b.start).reduce((chunks2, currentChunk) => {
|
11071 | const prevChunk = chunks2[chunks2.length - 1];
|
11072 | if (!prevChunk || currentChunk.start > prevChunk.end) {
|
11073 | const unhighlightStart = prevChunk ? prevChunk.end : 0;
|
11074 | const unhighlightEnd = currentChunk.start;
|
11075 | if (unhighlightStart !== unhighlightEnd) {
|
11076 | chunks2.push({
|
11077 | start: unhighlightStart,
|
11078 | end: unhighlightEnd,
|
11079 | highlight: false
|
11080 | });
|
11081 | }
|
11082 | chunks2.push(currentChunk);
|
11083 | } else {
|
11084 | prevChunk.end = Math.max(prevChunk.end, currentChunk.end);
|
11085 | }
|
11086 | return chunks2;
|
11087 | }, []);
|
11088 | const lastChunk = chunks[chunks.length - 1];
|
11089 | if (!lastChunk) {
|
11090 | chunks.push({
|
11091 | start: 0,
|
11092 | end: sourceString.length,
|
11093 | highlight: false
|
11094 | });
|
11095 | }
|
11096 | if (lastChunk && lastChunk.end < sourceString.length) {
|
11097 | chunks.push({
|
11098 | start: lastChunk.end,
|
11099 | end: sourceString.length,
|
11100 | highlight: false
|
11101 | });
|
11102 | }
|
11103 | return chunks;
|
11104 | });
|
11105 | const renderContent = () => {
|
11106 | const {
|
11107 | sourceString,
|
11108 | highlightClass,
|
11109 | unhighlightClass,
|
11110 | highlightTag,
|
11111 | unhighlightTag
|
11112 | } = props2;
|
11113 | return highlightChunks.value.map((chunk) => {
|
11114 | const {
|
11115 | start: start2,
|
11116 | end: end2,
|
11117 | highlight
|
11118 | } = chunk;
|
11119 | const text = sourceString.slice(start2, end2);
|
11120 | if (highlight) {
|
11121 | return vue.createVNode(highlightTag, {
|
11122 | "class": [bem$F("tag"), highlightClass]
|
11123 | }, {
|
11124 | default: () => [text]
|
11125 | });
|
11126 | }
|
11127 | return vue.createVNode(unhighlightTag, {
|
11128 | "class": unhighlightClass
|
11129 | }, {
|
11130 | default: () => [text]
|
11131 | });
|
11132 | });
|
11133 | };
|
11134 | return () => {
|
11135 | const {
|
11136 | tag
|
11137 | } = props2;
|
11138 | return vue.createVNode(tag, {
|
11139 | "class": bem$F()
|
11140 | }, {
|
11141 | default: () => [renderContent()]
|
11142 | });
|
11143 | };
|
11144 | }
|
11145 | });
|
11146 | const Highlight = withInstall(stdin_default$O);
|
11147 | const getDistance = (touches) => Math.sqrt((touches[0].clientX - touches[1].clientX) ** 2 + (touches[0].clientY - touches[1].clientY) ** 2);
|
11148 | const getCenter = (touches) => ({
|
11149 | x: (touches[0].clientX + touches[1].clientX) / 2,
|
11150 | y: (touches[0].clientY + touches[1].clientY) / 2
|
11151 | });
|
11152 | const bem$E = createNamespace("image-preview")[1];
|
11153 | const longImageRatio = 2.6;
|
11154 | const imagePreviewItemProps = {
|
11155 | src: String,
|
11156 | show: Boolean,
|
11157 | active: Number,
|
11158 | minZoom: makeRequiredProp(numericProp),
|
11159 | maxZoom: makeRequiredProp(numericProp),
|
11160 | rootWidth: makeRequiredProp(Number),
|
11161 | rootHeight: makeRequiredProp(Number),
|
11162 | disableZoom: Boolean,
|
11163 | doubleScale: Boolean,
|
11164 | closeOnClickImage: Boolean,
|
11165 | closeOnClickOverlay: Boolean,
|
11166 | vertical: Boolean
|
11167 | };
|
11168 | var stdin_default$N = vue.defineComponent({
|
11169 | props: imagePreviewItemProps,
|
11170 | emits: ["scale", "close", "longPress"],
|
11171 | setup(props2, {
|
11172 | emit,
|
11173 | slots
|
11174 | }) {
|
11175 | const state = vue.reactive({
|
11176 | scale: 1,
|
11177 | moveX: 0,
|
11178 | moveY: 0,
|
11179 | moving: false,
|
11180 | zooming: false,
|
11181 | initializing: false,
|
11182 | imageRatio: 0
|
11183 | });
|
11184 | const touch = useTouch();
|
11185 | const imageRef = vue.ref();
|
11186 | const swipeItem = vue.ref();
|
11187 | const vertical = vue.ref(false);
|
11188 | const isLongImage = vue.ref(false);
|
11189 | let initialMoveY = 0;
|
11190 | const imageStyle = vue.computed(() => {
|
11191 | const {
|
11192 | scale,
|
11193 | moveX,
|
11194 | moveY,
|
11195 | moving,
|
11196 | zooming,
|
11197 | initializing
|
11198 | } = state;
|
11199 | const style = {
|
11200 | transitionDuration: zooming || moving || initializing ? "0s" : ".3s"
|
11201 | };
|
11202 | if (scale !== 1 || isLongImage.value) {
|
11203 | style.transform = `matrix(${scale}, 0, 0, ${scale}, ${moveX}, ${moveY})`;
|
11204 | }
|
11205 | return style;
|
11206 | });
|
11207 | const maxMoveX = vue.computed(() => {
|
11208 | if (state.imageRatio) {
|
11209 | const {
|
11210 | rootWidth,
|
11211 | rootHeight
|
11212 | } = props2;
|
11213 | const displayWidth = vertical.value ? rootHeight / state.imageRatio : rootWidth;
|
11214 | return Math.max(0, (state.scale * displayWidth - rootWidth) / 2);
|
11215 | }
|
11216 | return 0;
|
11217 | });
|
11218 | const maxMoveY = vue.computed(() => {
|
11219 | if (state.imageRatio) {
|
11220 | const {
|
11221 | rootWidth,
|
11222 | rootHeight
|
11223 | } = props2;
|
11224 | const displayHeight = vertical.value ? rootHeight : rootWidth * state.imageRatio;
|
11225 | return Math.max(0, (state.scale * displayHeight - rootHeight) / 2);
|
11226 | }
|
11227 | return 0;
|
11228 | });
|
11229 | const setScale = (scale, center) => {
|
11230 | var _a;
|
11231 | scale = clamp(scale, +props2.minZoom, +props2.maxZoom + 1);
|
11232 | if (scale !== state.scale) {
|
11233 | const ratio = scale / state.scale;
|
11234 | state.scale = scale;
|
11235 | if (center) {
|
11236 | const imageRect = useRect((_a = imageRef.value) == null ? void 0 : _a.$el);
|
11237 | const origin = {
|
11238 | x: imageRect.width * 0.5,
|
11239 | y: imageRect.height * 0.5
|
11240 | };
|
11241 | const moveX = state.moveX - (center.x - imageRect.left - origin.x) * (ratio - 1);
|
11242 | const moveY = state.moveY - (center.y - imageRect.top - origin.y) * (ratio - 1);
|
11243 | state.moveX = clamp(moveX, -maxMoveX.value, maxMoveX.value);
|
11244 | state.moveY = clamp(moveY, -maxMoveY.value, maxMoveY.value);
|
11245 | } else {
|
11246 | state.moveX = 0;
|
11247 | state.moveY = isLongImage.value ? initialMoveY : 0;
|
11248 | }
|
11249 | emit("scale", {
|
11250 | scale,
|
11251 | index: props2.active
|
11252 | });
|
11253 | }
|
11254 | };
|
11255 | const resetScale = () => {
|
11256 | setScale(1);
|
11257 | };
|
11258 | const toggleScale = () => {
|
11259 | const scale = state.scale > 1 ? 1 : 2;
|
11260 | setScale(scale, scale === 2 || isLongImage.value ? {
|
11261 | x: touch.startX.value,
|
11262 | y: touch.startY.value
|
11263 | } : void 0);
|
11264 | };
|
11265 | let fingerNum;
|
11266 | let startMoveX;
|
11267 | let startMoveY;
|
11268 | let startScale;
|
11269 | let startDistance;
|
11270 | let lastCenter;
|
11271 | let doubleTapTimer;
|
11272 | let touchStartTime;
|
11273 | let isImageMoved = false;
|
11274 | const onTouchStart = (event) => {
|
11275 | const {
|
11276 | touches
|
11277 | } = event;
|
11278 | fingerNum = touches.length;
|
11279 | if (fingerNum === 2 && props2.disableZoom) {
|
11280 | return;
|
11281 | }
|
11282 | const {
|
11283 | offsetX
|
11284 | } = touch;
|
11285 | touch.start(event);
|
11286 | startMoveX = state.moveX;
|
11287 | startMoveY = state.moveY;
|
11288 | touchStartTime = Date.now();
|
11289 | isImageMoved = false;
|
11290 | state.moving = fingerNum === 1 && (state.scale !== 1 || isLongImage.value);
|
11291 | state.zooming = fingerNum === 2 && !offsetX.value;
|
11292 | if (state.zooming) {
|
11293 | startScale = state.scale;
|
11294 | startDistance = getDistance(touches);
|
11295 | }
|
11296 | };
|
11297 | const onTouchMove = (event) => {
|
11298 | const {
|
11299 | touches
|
11300 | } = event;
|
11301 | touch.move(event);
|
11302 | if (state.moving) {
|
11303 | const {
|
11304 | deltaX,
|
11305 | deltaY
|
11306 | } = touch;
|
11307 | const moveX = deltaX.value + startMoveX;
|
11308 | const moveY = deltaY.value + startMoveY;
|
11309 | if ((props2.vertical ? touch.isVertical() && Math.abs(moveY) > maxMoveY.value : touch.isHorizontal() && Math.abs(moveX) > maxMoveX.value) && !isImageMoved) {
|
11310 | state.moving = false;
|
11311 | return;
|
11312 | }
|
11313 | isImageMoved = true;
|
11314 | preventDefault(event, true);
|
11315 | state.moveX = clamp(moveX, -maxMoveX.value, maxMoveX.value);
|
11316 | state.moveY = clamp(moveY, -maxMoveY.value, maxMoveY.value);
|
11317 | }
|
11318 | if (state.zooming) {
|
11319 | preventDefault(event, true);
|
11320 | if (touches.length === 2) {
|
11321 | const distance = getDistance(touches);
|
11322 | const scale = startScale * distance / startDistance;
|
11323 | lastCenter = getCenter(touches);
|
11324 | setScale(scale, lastCenter);
|
11325 | }
|
11326 | }
|
11327 | };
|
11328 | const checkClose = (event) => {
|
11329 | var _a;
|
11330 | const swipeItemEl = (_a = swipeItem.value) == null ? void 0 : _a.$el;
|
11331 | if (!swipeItemEl) return;
|
11332 | const imageEl = swipeItemEl.firstElementChild;
|
11333 | const isClickOverlay = event.target === swipeItemEl;
|
11334 | const isClickImage = imageEl == null ? void 0 : imageEl.contains(event.target);
|
11335 | if (!props2.closeOnClickImage && isClickImage) return;
|
11336 | if (!props2.closeOnClickOverlay && isClickOverlay) return;
|
11337 | emit("close");
|
11338 | };
|
11339 | const checkTap = (event) => {
|
11340 | if (fingerNum > 1) {
|
11341 | return;
|
11342 | }
|
11343 | const deltaTime = Date.now() - touchStartTime;
|
11344 | const TAP_TIME = 250;
|
11345 | if (touch.isTap.value) {
|
11346 | if (deltaTime < TAP_TIME) {
|
11347 | if (props2.doubleScale) {
|
11348 | if (doubleTapTimer) {
|
11349 | clearTimeout(doubleTapTimer);
|
11350 | doubleTapTimer = null;
|
11351 | toggleScale();
|
11352 | } else {
|
11353 | doubleTapTimer = setTimeout(() => {
|
11354 | checkClose(event);
|
11355 | doubleTapTimer = null;
|
11356 | }, TAP_TIME);
|
11357 | }
|
11358 | } else {
|
11359 | checkClose(event);
|
11360 | }
|
11361 | } else if (deltaTime > LONG_PRESS_START_TIME) {
|
11362 | emit("longPress");
|
11363 | }
|
11364 | }
|
11365 | };
|
11366 | const onTouchEnd = (event) => {
|
11367 | let stopPropagation2 = false;
|
11368 | if (state.moving || state.zooming) {
|
11369 | stopPropagation2 = true;
|
11370 | if (state.moving && startMoveX === state.moveX && startMoveY === state.moveY) {
|
11371 | stopPropagation2 = false;
|
11372 | }
|
11373 | if (!event.touches.length) {
|
11374 | if (state.zooming) {
|
11375 | state.moveX = clamp(state.moveX, -maxMoveX.value, maxMoveX.value);
|
11376 | state.moveY = clamp(state.moveY, -maxMoveY.value, maxMoveY.value);
|
11377 | state.zooming = false;
|
11378 | }
|
11379 | state.moving = false;
|
11380 | startMoveX = 0;
|
11381 | startMoveY = 0;
|
11382 | startScale = 1;
|
11383 | if (state.scale < 1) {
|
11384 | resetScale();
|
11385 | }
|
11386 | const maxZoom = +props2.maxZoom;
|
11387 | if (state.scale > maxZoom) {
|
11388 | setScale(maxZoom, lastCenter);
|
11389 | }
|
11390 | }
|
11391 | }
|
11392 | preventDefault(event, stopPropagation2);
|
11393 | checkTap(event);
|
11394 | touch.reset();
|
11395 | };
|
11396 | const resize = () => {
|
11397 | const {
|
11398 | rootWidth,
|
11399 | rootHeight
|
11400 | } = props2;
|
11401 | const rootRatio = rootHeight / rootWidth;
|
11402 | const {
|
11403 | imageRatio
|
11404 | } = state;
|
11405 | vertical.value = state.imageRatio > rootRatio && imageRatio < longImageRatio;
|
11406 | isLongImage.value = state.imageRatio > rootRatio && imageRatio >= longImageRatio;
|
11407 | if (isLongImage.value) {
|
11408 | initialMoveY = (imageRatio * rootWidth - rootHeight) / 2;
|
11409 | state.moveY = initialMoveY;
|
11410 | state.initializing = true;
|
11411 | raf(() => {
|
11412 | state.initializing = false;
|
11413 | });
|
11414 | }
|
11415 | resetScale();
|
11416 | };
|
11417 | const onLoad = (event) => {
|
11418 | const {
|
11419 | naturalWidth,
|
11420 | naturalHeight
|
11421 | } = event.target;
|
11422 | state.imageRatio = naturalHeight / naturalWidth;
|
11423 | resize();
|
11424 | };
|
11425 | vue.watch(() => props2.active, resetScale);
|
11426 | vue.watch(() => props2.show, (value) => {
|
11427 | if (!value) {
|
11428 | resetScale();
|
11429 | }
|
11430 | });
|
11431 | vue.watch(() => [props2.rootWidth, props2.rootHeight], resize);
|
11432 | useEventListener("touchmove", onTouchMove, {
|
11433 | target: vue.computed(() => {
|
11434 | var _a;
|
11435 | return (_a = swipeItem.value) == null ? void 0 : _a.$el;
|
11436 | })
|
11437 | });
|
11438 | useExpose({
|
11439 | resetScale
|
11440 | });
|
11441 | return () => {
|
11442 | const imageSlots = {
|
11443 | loading: () => vue.createVNode(Loading, {
|
11444 | "type": "spinner"
|
11445 | }, null)
|
11446 | };
|
11447 | return vue.createVNode(SwipeItem, {
|
11448 | "ref": swipeItem,
|
11449 | "class": bem$E("swipe-item"),
|
11450 | "onTouchstartPassive": onTouchStart,
|
11451 | "onTouchend": onTouchEnd,
|
11452 | "onTouchcancel": onTouchEnd
|
11453 | }, {
|
11454 | default: () => [slots.image ? vue.createVNode("div", {
|
11455 | "class": bem$E("image-wrap")
|
11456 | }, [slots.image({
|
11457 | src: props2.src,
|
11458 | onLoad,
|
11459 | style: imageStyle.value
|
11460 | })]) : vue.createVNode(Image$1, {
|
11461 | "ref": imageRef,
|
11462 | "src": props2.src,
|
11463 | "fit": "contain",
|
11464 | "class": bem$E("image", {
|
11465 | vertical: vertical.value
|
11466 | }),
|
11467 | "style": imageStyle.value,
|
11468 | "onLoad": onLoad
|
11469 | }, imageSlots)]
|
11470 | });
|
11471 | };
|
11472 | }
|
11473 | });
|
11474 | const [name$E, bem$D] = createNamespace("image-preview");
|
11475 | const popupProps$1 = ["show", "teleport", "transition", "overlayStyle", "closeOnPopstate"];
|
11476 | const imagePreviewProps = {
|
11477 | show: Boolean,
|
11478 | loop: truthProp,
|
11479 | images: makeArrayProp(),
|
11480 | minZoom: makeNumericProp(1 / 3),
|
11481 | maxZoom: makeNumericProp(3),
|
11482 | overlay: truthProp,
|
11483 | vertical: Boolean,
|
11484 | closeable: Boolean,
|
11485 | showIndex: truthProp,
|
11486 | className: unknownProp,
|
11487 | closeIcon: makeStringProp("clear"),
|
11488 | transition: String,
|
11489 | beforeClose: Function,
|
11490 | doubleScale: truthProp,
|
11491 | overlayClass: unknownProp,
|
11492 | overlayStyle: Object,
|
11493 | swipeDuration: makeNumericProp(300),
|
11494 | startPosition: makeNumericProp(0),
|
11495 | showIndicators: Boolean,
|
11496 | closeOnPopstate: truthProp,
|
11497 | closeOnClickImage: truthProp,
|
11498 | closeOnClickOverlay: truthProp,
|
11499 | closeIconPosition: makeStringProp("top-right"),
|
11500 | teleport: [String, Object]
|
11501 | };
|
11502 | var stdin_default$M = vue.defineComponent({
|
11503 | name: name$E,
|
11504 | props: imagePreviewProps,
|
11505 | emits: ["scale", "close", "closed", "change", "longPress", "update:show"],
|
11506 | setup(props2, {
|
11507 | emit,
|
11508 | slots
|
11509 | }) {
|
11510 | const swipeRef = vue.ref();
|
11511 | const activedPreviewItemRef = vue.ref();
|
11512 | const state = vue.reactive({
|
11513 | active: 0,
|
11514 | rootWidth: 0,
|
11515 | rootHeight: 0,
|
11516 | disableZoom: false
|
11517 | });
|
11518 | const resize = () => {
|
11519 | if (swipeRef.value) {
|
11520 | const rect = useRect(swipeRef.value.$el);
|
11521 | state.rootWidth = rect.width;
|
11522 | state.rootHeight = rect.height;
|
11523 | swipeRef.value.resize();
|
11524 | }
|
11525 | };
|
11526 | const emitScale = (args) => emit("scale", args);
|
11527 | const updateShow = (show) => emit("update:show", show);
|
11528 | const emitClose = () => {
|
11529 | callInterceptor(props2.beforeClose, {
|
11530 | args: [state.active],
|
11531 | done: () => updateShow(false)
|
11532 | });
|
11533 | };
|
11534 | const setActive = (active) => {
|
11535 | if (active !== state.active) {
|
11536 | state.active = active;
|
11537 | emit("change", active);
|
11538 | }
|
11539 | };
|
11540 | const renderIndex = () => {
|
11541 | if (props2.showIndex) {
|
11542 | return vue.createVNode("div", {
|
11543 | "class": bem$D("index")
|
11544 | }, [slots.index ? slots.index({
|
11545 | index: state.active
|
11546 | }) : `${state.active + 1} / ${props2.images.length}`]);
|
11547 | }
|
11548 | };
|
11549 | const renderCover = () => {
|
11550 | if (slots.cover) {
|
11551 | return vue.createVNode("div", {
|
11552 | "class": bem$D("cover")
|
11553 | }, [slots.cover()]);
|
11554 | }
|
11555 | };
|
11556 | const onDragStart = () => {
|
11557 | state.disableZoom = true;
|
11558 | };
|
11559 | const onDragEnd = () => {
|
11560 | state.disableZoom = false;
|
11561 | };
|
11562 | const renderImages = () => vue.createVNode(Swipe, {
|
11563 | "ref": swipeRef,
|
11564 | "lazyRender": true,
|
11565 | "loop": props2.loop,
|
11566 | "class": bem$D("swipe"),
|
11567 | "vertical": props2.vertical,
|
11568 | "duration": props2.swipeDuration,
|
11569 | "initialSwipe": props2.startPosition,
|
11570 | "showIndicators": props2.showIndicators,
|
11571 | "indicatorColor": "white",
|
11572 | "onChange": setActive,
|
11573 | "onDragEnd": onDragEnd,
|
11574 | "onDragStart": onDragStart
|
11575 | }, {
|
11576 | default: () => [props2.images.map((image, index) => vue.createVNode(stdin_default$N, {
|
11577 | "ref": (item) => {
|
11578 | if (index === state.active) {
|
11579 | activedPreviewItemRef.value = item;
|
11580 | }
|
11581 | },
|
11582 | "src": image,
|
11583 | "show": props2.show,
|
11584 | "active": state.active,
|
11585 | "maxZoom": props2.maxZoom,
|
11586 | "minZoom": props2.minZoom,
|
11587 | "rootWidth": state.rootWidth,
|
11588 | "rootHeight": state.rootHeight,
|
11589 | "disableZoom": state.disableZoom,
|
11590 | "doubleScale": props2.doubleScale,
|
11591 | "closeOnClickImage": props2.closeOnClickImage,
|
11592 | "closeOnClickOverlay": props2.closeOnClickOverlay,
|
11593 | "vertical": props2.vertical,
|
11594 | "onScale": emitScale,
|
11595 | "onClose": emitClose,
|
11596 | "onLongPress": () => emit("longPress", {
|
11597 | index
|
11598 | })
|
11599 | }, {
|
11600 | image: slots.image
|
11601 | }))]
|
11602 | });
|
11603 | const renderClose = () => {
|
11604 | if (props2.closeable) {
|
11605 | return vue.createVNode(Icon, {
|
11606 | "role": "button",
|
11607 | "name": props2.closeIcon,
|
11608 | "class": [bem$D("close-icon", props2.closeIconPosition), HAPTICS_FEEDBACK],
|
11609 | "onClick": emitClose
|
11610 | }, null);
|
11611 | }
|
11612 | };
|
11613 | const onClosed = () => emit("closed");
|
11614 | const swipeTo = (index, options) => {
|
11615 | var _a;
|
11616 | return (_a = swipeRef.value) == null ? void 0 : _a.swipeTo(index, options);
|
11617 | };
|
11618 | useExpose({
|
11619 | resetScale: () => {
|
11620 | var _a;
|
11621 | (_a = activedPreviewItemRef.value) == null ? void 0 : _a.resetScale();
|
11622 | },
|
11623 | swipeTo
|
11624 | });
|
11625 | vue.onMounted(resize);
|
11626 | vue.watch([windowWidth, windowHeight], resize);
|
11627 | vue.watch(() => props2.startPosition, (value) => setActive(+value));
|
11628 | vue.watch(() => props2.show, (value) => {
|
11629 | const {
|
11630 | images,
|
11631 | startPosition
|
11632 | } = props2;
|
11633 | if (value) {
|
11634 | setActive(+startPosition);
|
11635 | vue.nextTick(() => {
|
11636 | resize();
|
11637 | swipeTo(+startPosition, {
|
11638 | immediate: true
|
11639 | });
|
11640 | });
|
11641 | } else {
|
11642 | emit("close", {
|
11643 | index: state.active,
|
11644 | url: images[state.active]
|
11645 | });
|
11646 | }
|
11647 | });
|
11648 | return () => vue.createVNode(Popup, vue.mergeProps({
|
11649 | "class": [bem$D(), props2.className],
|
11650 | "overlayClass": [bem$D("overlay"), props2.overlayClass],
|
11651 | "onClosed": onClosed,
|
11652 | "onUpdate:show": updateShow
|
11653 | }, pick(props2, popupProps$1)), {
|
11654 | default: () => [renderClose(), renderImages(), renderIndex(), renderCover()]
|
11655 | });
|
11656 | }
|
11657 | });
|
11658 | let instance$1;
|
11659 | const defaultConfig = {
|
11660 | loop: true,
|
11661 | images: [],
|
11662 | maxZoom: 3,
|
11663 | minZoom: 1 / 3,
|
11664 | onScale: void 0,
|
11665 | onClose: void 0,
|
11666 | onChange: void 0,
|
11667 | vertical: false,
|
11668 | teleport: "body",
|
11669 | className: "",
|
11670 | showIndex: true,
|
11671 | closeable: false,
|
11672 | closeIcon: "clear",
|
11673 | transition: void 0,
|
11674 | beforeClose: void 0,
|
11675 | doubleScale: true,
|
11676 | overlayStyle: void 0,
|
11677 | overlayClass: void 0,
|
11678 | startPosition: 0,
|
11679 | swipeDuration: 300,
|
11680 | showIndicators: false,
|
11681 | closeOnPopstate: true,
|
11682 | closeOnClickOverlay: true,
|
11683 | closeIconPosition: "top-right"
|
11684 | };
|
11685 | function initInstance$1() {
|
11686 | ({
|
11687 | instance: instance$1
|
11688 | } = mountComponent({
|
11689 | setup() {
|
11690 | const {
|
11691 | state,
|
11692 | toggle
|
11693 | } = usePopupState();
|
11694 | const onClosed = () => {
|
11695 | state.images = [];
|
11696 | };
|
11697 | return () => vue.createVNode(stdin_default$M, vue.mergeProps(state, {
|
11698 | "onClosed": onClosed,
|
11699 | "onUpdate:show": toggle
|
11700 | }), null);
|
11701 | }
|
11702 | }));
|
11703 | }
|
11704 | const showImagePreview = (options, startPosition = 0) => {
|
11705 | if (!inBrowser$1) {
|
11706 | return;
|
11707 | }
|
11708 | if (!instance$1) {
|
11709 | initInstance$1();
|
11710 | }
|
11711 | options = Array.isArray(options) ? {
|
11712 | images: options,
|
11713 | startPosition
|
11714 | } : options;
|
11715 | instance$1.open(extend({}, defaultConfig, options));
|
11716 | return instance$1;
|
11717 | };
|
11718 | const ImagePreview = withInstall(stdin_default$M);
|
11719 | function genAlphabet() {
|
11720 | const charCodeOfA = "A".charCodeAt(0);
|
11721 | const indexList = Array(26).fill("").map((_, i) => String.fromCharCode(charCodeOfA + i));
|
11722 | return indexList;
|
11723 | }
|
11724 | const [name$D, bem$C] = createNamespace("index-bar");
|
11725 | const indexBarProps = {
|
11726 | sticky: truthProp,
|
11727 | zIndex: numericProp,
|
11728 | teleport: [String, Object],
|
11729 | highlightColor: String,
|
11730 | stickyOffsetTop: makeNumberProp(0),
|
11731 | indexList: {
|
11732 | type: Array,
|
11733 | default: genAlphabet
|
11734 | }
|
11735 | };
|
11736 | const INDEX_BAR_KEY = Symbol(name$D);
|
11737 | var stdin_default$L = vue.defineComponent({
|
11738 | name: name$D,
|
11739 | props: indexBarProps,
|
11740 | emits: ["select", "change"],
|
11741 | setup(props2, {
|
11742 | emit,
|
11743 | slots
|
11744 | }) {
|
11745 | const root = vue.ref();
|
11746 | const sidebar = vue.ref();
|
11747 | const activeAnchor = vue.ref("");
|
11748 | const touch = useTouch();
|
11749 | const scrollParent = useScrollParent(root);
|
11750 | const {
|
11751 | children,
|
11752 | linkChildren
|
11753 | } = useChildren(INDEX_BAR_KEY);
|
11754 | let selectActiveIndex;
|
11755 | linkChildren({
|
11756 | props: props2
|
11757 | });
|
11758 | const sidebarStyle = vue.computed(() => {
|
11759 | if (isDef(props2.zIndex)) {
|
11760 | return {
|
11761 | zIndex: +props2.zIndex + 1
|
11762 | };
|
11763 | }
|
11764 | });
|
11765 | const highlightStyle = vue.computed(() => {
|
11766 | if (props2.highlightColor) {
|
11767 | return {
|
11768 | color: props2.highlightColor
|
11769 | };
|
11770 | }
|
11771 | });
|
11772 | const getActiveAnchor = (scrollTop, rects) => {
|
11773 | for (let i = children.length - 1; i >= 0; i--) {
|
11774 | const prevHeight = i > 0 ? rects[i - 1].height : 0;
|
11775 | const reachTop = props2.sticky ? prevHeight + props2.stickyOffsetTop : 0;
|
11776 | if (scrollTop + reachTop >= rects[i].top) {
|
11777 | return i;
|
11778 | }
|
11779 | }
|
11780 | return -1;
|
11781 | };
|
11782 | const getMatchAnchor = (index) => children.find((item) => String(item.index) === index);
|
11783 | const onScroll = () => {
|
11784 | if (isHidden(root)) {
|
11785 | return;
|
11786 | }
|
11787 | const {
|
11788 | sticky,
|
11789 | indexList
|
11790 | } = props2;
|
11791 | const scrollTop = getScrollTop(scrollParent.value);
|
11792 | const scrollParentRect = useRect(scrollParent);
|
11793 | const rects = children.map((item) => item.getRect(scrollParent.value, scrollParentRect));
|
11794 | let active = -1;
|
11795 | if (selectActiveIndex) {
|
11796 | const match = getMatchAnchor(selectActiveIndex);
|
11797 | if (match) {
|
11798 | const rect = match.getRect(scrollParent.value, scrollParentRect);
|
11799 | if (props2.sticky && props2.stickyOffsetTop) {
|
11800 | active = getActiveAnchor(rect.top - props2.stickyOffsetTop, rects);
|
11801 | } else {
|
11802 | active = getActiveAnchor(rect.top, rects);
|
11803 | }
|
11804 | }
|
11805 | } else {
|
11806 | active = getActiveAnchor(scrollTop, rects);
|
11807 | }
|
11808 | activeAnchor.value = indexList[active];
|
11809 | if (sticky) {
|
11810 | children.forEach((item, index) => {
|
11811 | const {
|
11812 | state,
|
11813 | $el
|
11814 | } = item;
|
11815 | if (index === active || index === active - 1) {
|
11816 | const rect = $el.getBoundingClientRect();
|
11817 | state.left = rect.left;
|
11818 | state.width = rect.width;
|
11819 | } else {
|
11820 | state.left = null;
|
11821 | state.width = null;
|
11822 | }
|
11823 | if (index === active) {
|
11824 | state.active = true;
|
11825 | state.top = Math.max(props2.stickyOffsetTop, rects[index].top - scrollTop) + scrollParentRect.top;
|
11826 | } else if (index === active - 1 && selectActiveIndex === "") {
|
11827 | const activeItemTop = rects[active].top - scrollTop;
|
11828 | state.active = activeItemTop > 0;
|
11829 | state.top = activeItemTop + scrollParentRect.top - rects[index].height;
|
11830 | } else {
|
11831 | state.active = false;
|
11832 | }
|
11833 | });
|
11834 | }
|
11835 | selectActiveIndex = "";
|
11836 | };
|
11837 | const init = () => {
|
11838 | vue.nextTick(onScroll);
|
11839 | };
|
11840 | useEventListener("scroll", onScroll, {
|
11841 | target: scrollParent,
|
11842 | passive: true
|
11843 | });
|
11844 | vue.onMounted(init);
|
11845 | vue.watch(() => props2.indexList, init);
|
11846 | vue.watch(activeAnchor, (value) => {
|
11847 | if (value) {
|
11848 | emit("change", value);
|
11849 | }
|
11850 | });
|
11851 | const renderIndexes = () => props2.indexList.map((index) => {
|
11852 | const active = index === activeAnchor.value;
|
11853 | return vue.createVNode("span", {
|
11854 | "class": bem$C("index", {
|
11855 | active
|
11856 | }),
|
11857 | "style": active ? highlightStyle.value : void 0,
|
11858 | "data-index": index
|
11859 | }, [index]);
|
11860 | });
|
11861 | const scrollTo = (index) => {
|
11862 | selectActiveIndex = String(index);
|
11863 | const match = getMatchAnchor(selectActiveIndex);
|
11864 | if (match) {
|
11865 | const scrollTop = getScrollTop(scrollParent.value);
|
11866 | const scrollParentRect = useRect(scrollParent);
|
11867 | const {
|
11868 | offsetHeight
|
11869 | } = document.documentElement;
|
11870 | match.$el.scrollIntoView();
|
11871 | if (scrollTop === offsetHeight - scrollParentRect.height) {
|
11872 | onScroll();
|
11873 | return;
|
11874 | }
|
11875 | if (props2.sticky && props2.stickyOffsetTop) {
|
11876 | if (getRootScrollTop() === offsetHeight - scrollParentRect.height) {
|
11877 | setRootScrollTop(getRootScrollTop());
|
11878 | } else {
|
11879 | setRootScrollTop(getRootScrollTop() - props2.stickyOffsetTop);
|
11880 | }
|
11881 | }
|
11882 | emit("select", match.index);
|
11883 | }
|
11884 | };
|
11885 | const scrollToElement = (element) => {
|
11886 | const {
|
11887 | index
|
11888 | } = element.dataset;
|
11889 | if (index) {
|
11890 | scrollTo(index);
|
11891 | }
|
11892 | };
|
11893 | const onClickSidebar = (event) => {
|
11894 | scrollToElement(event.target);
|
11895 | };
|
11896 | let touchActiveIndex;
|
11897 | const onTouchMove = (event) => {
|
11898 | touch.move(event);
|
11899 | if (touch.isVertical()) {
|
11900 | preventDefault(event);
|
11901 | const {
|
11902 | clientX,
|
11903 | clientY
|
11904 | } = event.touches[0];
|
11905 | const target = document.elementFromPoint(clientX, clientY);
|
11906 | if (target) {
|
11907 | const {
|
11908 | index
|
11909 | } = target.dataset;
|
11910 | if (index && touchActiveIndex !== index) {
|
11911 | touchActiveIndex = index;
|
11912 | scrollToElement(target);
|
11913 | }
|
11914 | }
|
11915 | }
|
11916 | };
|
11917 | const renderSidebar = () => vue.createVNode("div", {
|
11918 | "ref": sidebar,
|
11919 | "class": bem$C("sidebar"),
|
11920 | "style": sidebarStyle.value,
|
11921 | "onClick": onClickSidebar,
|
11922 | "onTouchstartPassive": touch.start
|
11923 | }, [renderIndexes()]);
|
11924 | useExpose({
|
11925 | scrollTo
|
11926 | });
|
11927 | useEventListener("touchmove", onTouchMove, {
|
11928 | target: sidebar
|
11929 | });
|
11930 | return () => {
|
11931 | var _a;
|
11932 | return vue.createVNode("div", {
|
11933 | "ref": root,
|
11934 | "class": bem$C()
|
11935 | }, [props2.teleport ? vue.createVNode(vue.Teleport, {
|
11936 | "to": props2.teleport
|
11937 | }, {
|
11938 | default: () => [renderSidebar()]
|
11939 | }) : renderSidebar(), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
11940 | };
|
11941 | }
|
11942 | });
|
11943 | const [name$C, bem$B] = createNamespace("index-anchor");
|
11944 | const indexAnchorProps = {
|
11945 | index: numericProp
|
11946 | };
|
11947 | var stdin_default$K = vue.defineComponent({
|
11948 | name: name$C,
|
11949 | props: indexAnchorProps,
|
11950 | setup(props2, {
|
11951 | slots
|
11952 | }) {
|
11953 | const state = vue.reactive({
|
11954 | top: 0,
|
11955 | left: null,
|
11956 | rect: {
|
11957 | top: 0,
|
11958 | height: 0
|
11959 | },
|
11960 | width: null,
|
11961 | active: false
|
11962 | });
|
11963 | const root = vue.ref();
|
11964 | const {
|
11965 | parent
|
11966 | } = useParent(INDEX_BAR_KEY);
|
11967 | if (!parent) {
|
11968 | return;
|
11969 | }
|
11970 | const isSticky = () => state.active && parent.props.sticky;
|
11971 | const anchorStyle = vue.computed(() => {
|
11972 | const {
|
11973 | zIndex,
|
11974 | highlightColor
|
11975 | } = parent.props;
|
11976 | if (isSticky()) {
|
11977 | return extend(getZIndexStyle(zIndex), {
|
11978 | left: state.left ? `${state.left}px` : void 0,
|
11979 | width: state.width ? `${state.width}px` : void 0,
|
11980 | transform: state.top ? `translate3d(0, ${state.top}px, 0)` : void 0,
|
11981 | color: highlightColor
|
11982 | });
|
11983 | }
|
11984 | });
|
11985 | const getRect = (scrollParent, scrollParentRect) => {
|
11986 | const rootRect = useRect(root);
|
11987 | state.rect.height = rootRect.height;
|
11988 | if (scrollParent === window || scrollParent === document.body) {
|
11989 | state.rect.top = rootRect.top + getRootScrollTop();
|
11990 | } else {
|
11991 | state.rect.top = rootRect.top + getScrollTop(scrollParent) - scrollParentRect.top;
|
11992 | }
|
11993 | return state.rect;
|
11994 | };
|
11995 | useExpose({
|
11996 | state,
|
11997 | getRect
|
11998 | });
|
11999 | return () => {
|
12000 | const sticky = isSticky();
|
12001 | return vue.createVNode("div", {
|
12002 | "ref": root,
|
12003 | "style": {
|
12004 | height: sticky ? `${state.rect.height}px` : void 0
|
12005 | }
|
12006 | }, [vue.createVNode("div", {
|
12007 | "style": anchorStyle.value,
|
12008 | "class": [bem$B({
|
12009 | sticky
|
12010 | }), {
|
12011 | [BORDER_BOTTOM]: sticky
|
12012 | }]
|
12013 | }, [slots.default ? slots.default() : props2.index])]);
|
12014 | };
|
12015 | }
|
12016 | });
|
12017 | const IndexAnchor = withInstall(stdin_default$K);
|
12018 | const IndexBar = withInstall(stdin_default$L);
|
12019 | const [name$B, bem$A, t$7] = createNamespace("list");
|
12020 | const listProps = {
|
12021 | error: Boolean,
|
12022 | offset: makeNumericProp(300),
|
12023 | loading: Boolean,
|
12024 | disabled: Boolean,
|
12025 | finished: Boolean,
|
12026 | scroller: Object,
|
12027 | errorText: String,
|
12028 | direction: makeStringProp("down"),
|
12029 | loadingText: String,
|
12030 | finishedText: String,
|
12031 | immediateCheck: truthProp
|
12032 | };
|
12033 | var stdin_default$J = vue.defineComponent({
|
12034 | name: name$B,
|
12035 | props: listProps,
|
12036 | emits: ["load", "update:error", "update:loading"],
|
12037 | setup(props2, {
|
12038 | emit,
|
12039 | slots
|
12040 | }) {
|
12041 | const loading = vue.ref(props2.loading);
|
12042 | const root = vue.ref();
|
12043 | const placeholder = vue.ref();
|
12044 | const tabStatus = useTabStatus();
|
12045 | const scrollParent = useScrollParent(root);
|
12046 | const scroller = vue.computed(() => props2.scroller || scrollParent.value);
|
12047 | const check = () => {
|
12048 | vue.nextTick(() => {
|
12049 | if (loading.value || props2.finished || props2.disabled || props2.error ||
|
12050 | (tabStatus == null ? void 0 : tabStatus.value) === false) {
|
12051 | return;
|
12052 | }
|
12053 | const {
|
12054 | direction
|
12055 | } = props2;
|
12056 | const offset2 = +props2.offset;
|
12057 | const scrollParentRect = useRect(scroller);
|
12058 | if (!scrollParentRect.height || isHidden(root)) {
|
12059 | return;
|
12060 | }
|
12061 | let isReachEdge = false;
|
12062 | const placeholderRect = useRect(placeholder);
|
12063 | if (direction === "up") {
|
12064 | isReachEdge = scrollParentRect.top - placeholderRect.top <= offset2;
|
12065 | } else {
|
12066 | isReachEdge = placeholderRect.bottom - scrollParentRect.bottom <= offset2;
|
12067 | }
|
12068 | if (isReachEdge) {
|
12069 | loading.value = true;
|
12070 | emit("update:loading", true);
|
12071 | emit("load");
|
12072 | }
|
12073 | });
|
12074 | };
|
12075 | const renderFinishedText = () => {
|
12076 | if (props2.finished) {
|
12077 | const text = slots.finished ? slots.finished() : props2.finishedText;
|
12078 | if (text) {
|
12079 | return vue.createVNode("div", {
|
12080 | "class": bem$A("finished-text")
|
12081 | }, [text]);
|
12082 | }
|
12083 | }
|
12084 | };
|
12085 | const clickErrorText = () => {
|
12086 | emit("update:error", false);
|
12087 | check();
|
12088 | };
|
12089 | const renderErrorText = () => {
|
12090 | if (props2.error) {
|
12091 | const text = slots.error ? slots.error() : props2.errorText;
|
12092 | if (text) {
|
12093 | return vue.createVNode("div", {
|
12094 | "role": "button",
|
12095 | "class": bem$A("error-text"),
|
12096 | "tabindex": 0,
|
12097 | "onClick": clickErrorText
|
12098 | }, [text]);
|
12099 | }
|
12100 | }
|
12101 | };
|
12102 | const renderLoading = () => {
|
12103 | if (loading.value && !props2.finished && !props2.disabled) {
|
12104 | return vue.createVNode("div", {
|
12105 | "class": bem$A("loading")
|
12106 | }, [slots.loading ? slots.loading() : vue.createVNode(Loading, {
|
12107 | "class": bem$A("loading-icon")
|
12108 | }, {
|
12109 | default: () => [props2.loadingText || t$7("loading")]
|
12110 | })]);
|
12111 | }
|
12112 | };
|
12113 | vue.watch(() => [props2.loading, props2.finished, props2.error], check);
|
12114 | if (tabStatus) {
|
12115 | vue.watch(tabStatus, (tabActive) => {
|
12116 | if (tabActive) {
|
12117 | check();
|
12118 | }
|
12119 | });
|
12120 | }
|
12121 | vue.onUpdated(() => {
|
12122 | loading.value = props2.loading;
|
12123 | });
|
12124 | vue.onMounted(() => {
|
12125 | if (props2.immediateCheck) {
|
12126 | check();
|
12127 | }
|
12128 | });
|
12129 | useExpose({
|
12130 | check
|
12131 | });
|
12132 | useEventListener("scroll", check, {
|
12133 | target: scroller,
|
12134 | passive: true
|
12135 | });
|
12136 | return () => {
|
12137 | var _a;
|
12138 | const Content = (_a = slots.default) == null ? void 0 : _a.call(slots);
|
12139 | const Placeholder = vue.createVNode("div", {
|
12140 | "ref": placeholder,
|
12141 | "class": bem$A("placeholder")
|
12142 | }, null);
|
12143 | return vue.createVNode("div", {
|
12144 | "ref": root,
|
12145 | "role": "feed",
|
12146 | "class": bem$A(),
|
12147 | "aria-busy": loading.value
|
12148 | }, [props2.direction === "down" ? Content : Placeholder, renderLoading(), renderFinishedText(), renderErrorText(), props2.direction === "up" ? Content : Placeholder]);
|
12149 | };
|
12150 | }
|
12151 | });
|
12152 | const List = withInstall(stdin_default$J);
|
12153 | const [name$A, bem$z] = createNamespace("nav-bar");
|
12154 | const navBarProps = {
|
12155 | title: String,
|
12156 | fixed: Boolean,
|
12157 | zIndex: numericProp,
|
12158 | border: truthProp,
|
12159 | leftText: String,
|
12160 | rightText: String,
|
12161 | leftDisabled: Boolean,
|
12162 | rightDisabled: Boolean,
|
12163 | leftArrow: Boolean,
|
12164 | placeholder: Boolean,
|
12165 | safeAreaInsetTop: Boolean,
|
12166 | clickable: truthProp
|
12167 | };
|
12168 | var stdin_default$I = vue.defineComponent({
|
12169 | name: name$A,
|
12170 | props: navBarProps,
|
12171 | emits: ["clickLeft", "clickRight"],
|
12172 | setup(props2, {
|
12173 | emit,
|
12174 | slots
|
12175 | }) {
|
12176 | const navBarRef = vue.ref();
|
12177 | const renderPlaceholder = usePlaceholder(navBarRef, bem$z);
|
12178 | const onClickLeft = (event) => {
|
12179 | if (!props2.leftDisabled) {
|
12180 | emit("clickLeft", event);
|
12181 | }
|
12182 | };
|
12183 | const onClickRight = (event) => {
|
12184 | if (!props2.rightDisabled) {
|
12185 | emit("clickRight", event);
|
12186 | }
|
12187 | };
|
12188 | const renderLeft = () => {
|
12189 | if (slots.left) {
|
12190 | return slots.left();
|
12191 | }
|
12192 | return [props2.leftArrow && vue.createVNode(Icon, {
|
12193 | "class": bem$z("arrow"),
|
12194 | "name": "arrow-left"
|
12195 | }, null), props2.leftText && vue.createVNode("span", {
|
12196 | "class": bem$z("text")
|
12197 | }, [props2.leftText])];
|
12198 | };
|
12199 | const renderRight = () => {
|
12200 | if (slots.right) {
|
12201 | return slots.right();
|
12202 | }
|
12203 | return vue.createVNode("span", {
|
12204 | "class": bem$z("text")
|
12205 | }, [props2.rightText]);
|
12206 | };
|
12207 | const renderNavBar = () => {
|
12208 | const {
|
12209 | title,
|
12210 | fixed,
|
12211 | border,
|
12212 | zIndex
|
12213 | } = props2;
|
12214 | const style = getZIndexStyle(zIndex);
|
12215 | const hasLeft = props2.leftArrow || props2.leftText || slots.left;
|
12216 | const hasRight = props2.rightText || slots.right;
|
12217 | return vue.createVNode("div", {
|
12218 | "ref": navBarRef,
|
12219 | "style": style,
|
12220 | "class": [bem$z({
|
12221 | fixed
|
12222 | }), {
|
12223 | [BORDER_BOTTOM]: border,
|
12224 | "van-safe-area-top": props2.safeAreaInsetTop
|
12225 | }]
|
12226 | }, [vue.createVNode("div", {
|
12227 | "class": bem$z("content")
|
12228 | }, [hasLeft && vue.createVNode("div", {
|
12229 | "class": [bem$z("left", {
|
12230 | disabled: props2.leftDisabled
|
12231 | }), props2.clickable && !props2.leftDisabled ? HAPTICS_FEEDBACK : ""],
|
12232 | "onClick": onClickLeft
|
12233 | }, [renderLeft()]), vue.createVNode("div", {
|
12234 | "class": [bem$z("title"), "van-ellipsis"]
|
12235 | }, [slots.title ? slots.title() : title]), hasRight && vue.createVNode("div", {
|
12236 | "class": [bem$z("right", {
|
12237 | disabled: props2.rightDisabled
|
12238 | }), props2.clickable && !props2.rightDisabled ? HAPTICS_FEEDBACK : ""],
|
12239 | "onClick": onClickRight
|
12240 | }, [renderRight()])])]);
|
12241 | };
|
12242 | return () => {
|
12243 | if (props2.fixed && props2.placeholder) {
|
12244 | return renderPlaceholder(renderNavBar);
|
12245 | }
|
12246 | return renderNavBar();
|
12247 | };
|
12248 | }
|
12249 | });
|
12250 | const NavBar = withInstall(stdin_default$I);
|
12251 | const [name$z, bem$y] = createNamespace("notice-bar");
|
12252 | const noticeBarProps = {
|
12253 | text: String,
|
12254 | mode: String,
|
12255 | color: String,
|
12256 | delay: makeNumericProp(1),
|
12257 | speed: makeNumericProp(60),
|
12258 | leftIcon: String,
|
12259 | wrapable: Boolean,
|
12260 | background: String,
|
12261 | scrollable: {
|
12262 | type: Boolean,
|
12263 | default: null
|
12264 | }
|
12265 | };
|
12266 | var stdin_default$H = vue.defineComponent({
|
12267 | name: name$z,
|
12268 | props: noticeBarProps,
|
12269 | emits: ["close", "replay"],
|
12270 | setup(props2, {
|
12271 | emit,
|
12272 | slots
|
12273 | }) {
|
12274 | let wrapWidth = 0;
|
12275 | let contentWidth = 0;
|
12276 | let startTimer;
|
12277 | const wrapRef = vue.ref();
|
12278 | const contentRef = vue.ref();
|
12279 | const state = vue.reactive({
|
12280 | show: true,
|
12281 | offset: 0,
|
12282 | duration: 0
|
12283 | });
|
12284 | const renderLeftIcon = () => {
|
12285 | if (slots["left-icon"]) {
|
12286 | return slots["left-icon"]();
|
12287 | }
|
12288 | if (props2.leftIcon) {
|
12289 | return vue.createVNode(Icon, {
|
12290 | "class": bem$y("left-icon"),
|
12291 | "name": props2.leftIcon
|
12292 | }, null);
|
12293 | }
|
12294 | };
|
12295 | const getRightIconName = () => {
|
12296 | if (props2.mode === "closeable") {
|
12297 | return "cross";
|
12298 | }
|
12299 | if (props2.mode === "link") {
|
12300 | return "arrow";
|
12301 | }
|
12302 | };
|
12303 | const onClickRightIcon = (event) => {
|
12304 | if (props2.mode === "closeable") {
|
12305 | state.show = false;
|
12306 | emit("close", event);
|
12307 | }
|
12308 | };
|
12309 | const renderRightIcon = () => {
|
12310 | if (slots["right-icon"]) {
|
12311 | return slots["right-icon"]();
|
12312 | }
|
12313 | const name2 = getRightIconName();
|
12314 | if (name2) {
|
12315 | return vue.createVNode(Icon, {
|
12316 | "name": name2,
|
12317 | "class": bem$y("right-icon"),
|
12318 | "onClick": onClickRightIcon
|
12319 | }, null);
|
12320 | }
|
12321 | };
|
12322 | const onTransitionEnd = () => {
|
12323 | state.offset = wrapWidth;
|
12324 | state.duration = 0;
|
12325 | raf(() => {
|
12326 | doubleRaf(() => {
|
12327 | state.offset = -contentWidth;
|
12328 | state.duration = (contentWidth + wrapWidth) / +props2.speed;
|
12329 | emit("replay");
|
12330 | });
|
12331 | });
|
12332 | };
|
12333 | const renderMarquee = () => {
|
12334 | const ellipsis = props2.scrollable === false && !props2.wrapable;
|
12335 | const style = {
|
12336 | transform: state.offset ? `translateX(${state.offset}px)` : "",
|
12337 | transitionDuration: `${state.duration}s`
|
12338 | };
|
12339 | return vue.createVNode("div", {
|
12340 | "ref": wrapRef,
|
12341 | "role": "marquee",
|
12342 | "class": bem$y("wrap")
|
12343 | }, [vue.createVNode("div", {
|
12344 | "ref": contentRef,
|
12345 | "style": style,
|
12346 | "class": [bem$y("content"), {
|
12347 | "van-ellipsis": ellipsis
|
12348 | }],
|
12349 | "onTransitionend": onTransitionEnd
|
12350 | }, [slots.default ? slots.default() : props2.text])]);
|
12351 | };
|
12352 | const reset = () => {
|
12353 | const {
|
12354 | delay,
|
12355 | speed,
|
12356 | scrollable
|
12357 | } = props2;
|
12358 | const ms = isDef(delay) ? +delay * 1e3 : 0;
|
12359 | wrapWidth = 0;
|
12360 | contentWidth = 0;
|
12361 | state.offset = 0;
|
12362 | state.duration = 0;
|
12363 | clearTimeout(startTimer);
|
12364 | startTimer = setTimeout(() => {
|
12365 | if (!wrapRef.value || !contentRef.value || scrollable === false) {
|
12366 | return;
|
12367 | }
|
12368 | const wrapRefWidth = useRect(wrapRef).width;
|
12369 | const contentRefWidth = useRect(contentRef).width;
|
12370 | if (scrollable || contentRefWidth > wrapRefWidth) {
|
12371 | doubleRaf(() => {
|
12372 | wrapWidth = wrapRefWidth;
|
12373 | contentWidth = contentRefWidth;
|
12374 | state.offset = -contentWidth;
|
12375 | state.duration = contentWidth / +speed;
|
12376 | });
|
12377 | }
|
12378 | }, ms);
|
12379 | };
|
12380 | onPopupReopen(reset);
|
12381 | onMountedOrActivated(reset);
|
12382 | useEventListener("pageshow", reset);
|
12383 | useExpose({
|
12384 | reset
|
12385 | });
|
12386 | vue.watch(() => [props2.text, props2.scrollable], reset);
|
12387 | return () => {
|
12388 | const {
|
12389 | color,
|
12390 | wrapable,
|
12391 | background
|
12392 | } = props2;
|
12393 | return vue.withDirectives(vue.createVNode("div", {
|
12394 | "role": "alert",
|
12395 | "class": bem$y({
|
12396 | wrapable
|
12397 | }),
|
12398 | "style": {
|
12399 | color,
|
12400 | background
|
12401 | }
|
12402 | }, [renderLeftIcon(), renderMarquee(), renderRightIcon()]), [[vue.vShow, state.show]]);
|
12403 | };
|
12404 | }
|
12405 | });
|
12406 | const NoticeBar = withInstall(stdin_default$H);
|
12407 | const [name$y, bem$x] = createNamespace("notify");
|
12408 | const popupInheritProps = ["lockScroll", "position", "show", "teleport", "zIndex"];
|
12409 | const notifyProps = extend({}, popupSharedProps, {
|
12410 | type: makeStringProp("danger"),
|
12411 | color: String,
|
12412 | message: numericProp,
|
12413 | position: makeStringProp("top"),
|
12414 | className: unknownProp,
|
12415 | background: String,
|
12416 | lockScroll: Boolean
|
12417 | });
|
12418 | var stdin_default$G = vue.defineComponent({
|
12419 | name: name$y,
|
12420 | props: notifyProps,
|
12421 | emits: ["update:show"],
|
12422 | setup(props2, {
|
12423 | emit,
|
12424 | slots
|
12425 | }) {
|
12426 | const updateShow = (show) => emit("update:show", show);
|
12427 | return () => vue.createVNode(Popup, vue.mergeProps({
|
12428 | "class": [bem$x([props2.type]), props2.className],
|
12429 | "style": {
|
12430 | color: props2.color,
|
12431 | background: props2.background
|
12432 | },
|
12433 | "overlay": false,
|
12434 | "duration": 0.2,
|
12435 | "onUpdate:show": updateShow
|
12436 | }, pick(props2, popupInheritProps)), {
|
12437 | default: () => [slots.default ? slots.default() : props2.message]
|
12438 | });
|
12439 | }
|
12440 | });
|
12441 | let timer;
|
12442 | let instance;
|
12443 | const parseOptions = (message) => isObject$1(message) ? message : {
|
12444 | message
|
12445 | };
|
12446 | function initInstance() {
|
12447 | ({
|
12448 | instance
|
12449 | } = mountComponent({
|
12450 | setup() {
|
12451 | const {
|
12452 | state,
|
12453 | toggle
|
12454 | } = usePopupState();
|
12455 | return () => vue.createVNode(stdin_default$G, vue.mergeProps(state, {
|
12456 | "onUpdate:show": toggle
|
12457 | }), null);
|
12458 | }
|
12459 | }));
|
12460 | }
|
12461 | const getDefaultOptions = () => ({
|
12462 | type: "danger",
|
12463 | color: void 0,
|
12464 | message: "",
|
12465 | onClose: void 0,
|
12466 | onClick: void 0,
|
12467 | onOpened: void 0,
|
12468 | duration: 3e3,
|
12469 | position: void 0,
|
12470 | className: "",
|
12471 | lockScroll: false,
|
12472 | background: void 0
|
12473 | });
|
12474 | let currentOptions = getDefaultOptions();
|
12475 | const closeNotify = () => {
|
12476 | if (instance) {
|
12477 | instance.toggle(false);
|
12478 | }
|
12479 | };
|
12480 | function showNotify(options) {
|
12481 | if (!inBrowser$1) {
|
12482 | return;
|
12483 | }
|
12484 | if (!instance) {
|
12485 | initInstance();
|
12486 | }
|
12487 | options = extend({}, currentOptions, parseOptions(options));
|
12488 | instance.open(options);
|
12489 | clearTimeout(timer);
|
12490 | if (options.duration > 0) {
|
12491 | timer = setTimeout(closeNotify, options.duration);
|
12492 | }
|
12493 | return instance;
|
12494 | }
|
12495 | const setNotifyDefaultOptions = (options) => extend(currentOptions, options);
|
12496 | const resetNotifyDefaultOptions = () => {
|
12497 | currentOptions = getDefaultOptions();
|
12498 | };
|
12499 | const Notify = withInstall(stdin_default$G);
|
12500 | const [name$x, bem$w] = createNamespace("key");
|
12501 | const CollapseIcon = vue.createVNode("svg", {
|
12502 | "class": bem$w("collapse-icon"),
|
12503 | "viewBox": "0 0 30 24"
|
12504 | }, [vue.createVNode("path", {
|
12505 | "d": "M26 13h-2v2h2v-2zm-8-3h2V8h-2v2zm2-4h2V4h-2v2zm2 4h4V4h-2v4h-2v2zm-7 14 3-3h-6l3 3zM6 13H4v2h2v-2zm16 0H8v2h14v-2zm-12-3h2V8h-2v2zM28 0l1 1 1 1v15l-1 2H1l-1-2V2l1-1 1-1zm0 2H2v15h26V2zM6 4v2H4V4zm10 2h2V4h-2v2zM8 9v1H4V8zm8 0v1h-2V8zm-6-5v2H8V4zm4 0v2h-2V4z",
|
12506 | "fill": "currentColor"
|
12507 | }, null)]);
|
12508 | const DeleteIcon = vue.createVNode("svg", {
|
12509 | "class": bem$w("delete-icon"),
|
12510 | "viewBox": "0 0 32 22"
|
12511 | }, [vue.createVNode("path", {
|
12512 | "d": "M28 0a4 4 0 0 1 4 4v14a4 4 0 0 1-4 4H10.4a2 2 0 0 1-1.4-.6L1 13.1c-.6-.5-.9-1.3-.9-2 0-1 .3-1.7.9-2.2L9 .6a2 2 0 0 1 1.4-.6zm0 2H10.4l-8.2 8.3a1 1 0 0 0-.3.7c0 .3.1.5.3.7l8.2 8.4H28a2 2 0 0 0 2-2V4c0-1.1-.9-2-2-2zm-5 4a1 1 0 0 1 .7.3 1 1 0 0 1 0 1.4L20.4 11l3.3 3.3c.2.2.3.5.3.7 0 .3-.1.5-.3.7a1 1 0 0 1-.7.3 1 1 0 0 1-.7-.3L19 12.4l-3.4 3.3a1 1 0 0 1-.6.3 1 1 0 0 1-.7-.3 1 1 0 0 1-.3-.7c0-.2.1-.5.3-.7l3.3-3.3-3.3-3.3A1 1 0 0 1 14 7c0-.3.1-.5.3-.7A1 1 0 0 1 15 6a1 1 0 0 1 .6.3L19 9.6l3.3-3.3A1 1 0 0 1 23 6z",
|
12513 | "fill": "currentColor"
|
12514 | }, null)]);
|
12515 | var stdin_default$F = vue.defineComponent({
|
12516 | name: name$x,
|
12517 | props: {
|
12518 | type: String,
|
12519 | text: numericProp,
|
12520 | color: String,
|
12521 | wider: Boolean,
|
12522 | large: Boolean,
|
12523 | loading: Boolean
|
12524 | },
|
12525 | emits: ["press"],
|
12526 | setup(props2, {
|
12527 | emit,
|
12528 | slots
|
12529 | }) {
|
12530 | const active = vue.ref(false);
|
12531 | const touch = useTouch();
|
12532 | const onTouchStart = (event) => {
|
12533 | touch.start(event);
|
12534 | active.value = true;
|
12535 | };
|
12536 | const onTouchMove = (event) => {
|
12537 | touch.move(event);
|
12538 | if (touch.direction.value) {
|
12539 | active.value = false;
|
12540 | }
|
12541 | };
|
12542 | const onTouchEnd = (event) => {
|
12543 | if (active.value) {
|
12544 | if (!slots.default) {
|
12545 | preventDefault(event);
|
12546 | }
|
12547 | active.value = false;
|
12548 | emit("press", props2.text, props2.type);
|
12549 | }
|
12550 | };
|
12551 | const renderContent = () => {
|
12552 | if (props2.loading) {
|
12553 | return vue.createVNode(Loading, {
|
12554 | "class": bem$w("loading-icon")
|
12555 | }, null);
|
12556 | }
|
12557 | const text = slots.default ? slots.default() : props2.text;
|
12558 | switch (props2.type) {
|
12559 | case "delete":
|
12560 | return text || DeleteIcon;
|
12561 | case "extra":
|
12562 | return text || CollapseIcon;
|
12563 | default:
|
12564 | return text;
|
12565 | }
|
12566 | };
|
12567 | return () => vue.createVNode("div", {
|
12568 | "class": bem$w("wrapper", {
|
12569 | wider: props2.wider
|
12570 | }),
|
12571 | "onTouchstartPassive": onTouchStart,
|
12572 | "onTouchmovePassive": onTouchMove,
|
12573 | "onTouchend": onTouchEnd,
|
12574 | "onTouchcancel": onTouchEnd
|
12575 | }, [vue.createVNode("div", {
|
12576 | "role": "button",
|
12577 | "tabindex": 0,
|
12578 | "class": bem$w([props2.color, {
|
12579 | large: props2.large,
|
12580 | active: active.value,
|
12581 | delete: props2.type === "delete"
|
12582 | }])
|
12583 | }, [renderContent()])]);
|
12584 | }
|
12585 | });
|
12586 | const [name$w, bem$v] = createNamespace("number-keyboard");
|
12587 | const numberKeyboardProps = {
|
12588 | show: Boolean,
|
12589 | title: String,
|
12590 | theme: makeStringProp("default"),
|
12591 | zIndex: numericProp,
|
12592 | teleport: [String, Object],
|
12593 | maxlength: makeNumericProp(Infinity),
|
12594 | modelValue: makeStringProp(""),
|
12595 | transition: truthProp,
|
12596 | blurOnClose: truthProp,
|
12597 | showDeleteKey: truthProp,
|
12598 | randomKeyOrder: Boolean,
|
12599 | closeButtonText: String,
|
12600 | deleteButtonText: String,
|
12601 | closeButtonLoading: Boolean,
|
12602 | hideOnClickOutside: truthProp,
|
12603 | safeAreaInsetBottom: truthProp,
|
12604 | extraKey: {
|
12605 | type: [String, Array],
|
12606 | default: ""
|
12607 | }
|
12608 | };
|
12609 | function shuffle(array) {
|
12610 | for (let i = array.length - 1; i > 0; i--) {
|
12611 | const j = Math.floor(Math.random() * (i + 1));
|
12612 | const temp = array[i];
|
12613 | array[i] = array[j];
|
12614 | array[j] = temp;
|
12615 | }
|
12616 | return array;
|
12617 | }
|
12618 | var stdin_default$E = vue.defineComponent({
|
12619 | name: name$w,
|
12620 | inheritAttrs: false,
|
12621 | props: numberKeyboardProps,
|
12622 | emits: ["show", "hide", "blur", "input", "close", "delete", "update:modelValue"],
|
12623 | setup(props2, {
|
12624 | emit,
|
12625 | slots,
|
12626 | attrs
|
12627 | }) {
|
12628 | const root = vue.ref();
|
12629 | const genBasicKeys = () => {
|
12630 | const keys2 = Array(9).fill("").map((_, i) => ({
|
12631 | text: i + 1
|
12632 | }));
|
12633 | if (props2.randomKeyOrder) {
|
12634 | shuffle(keys2);
|
12635 | }
|
12636 | return keys2;
|
12637 | };
|
12638 | const genDefaultKeys = () => [...genBasicKeys(), {
|
12639 | text: props2.extraKey,
|
12640 | type: "extra"
|
12641 | }, {
|
12642 | text: 0
|
12643 | }, {
|
12644 | text: props2.showDeleteKey ? props2.deleteButtonText : "",
|
12645 | type: props2.showDeleteKey ? "delete" : ""
|
12646 | }];
|
12647 | const genCustomKeys = () => {
|
12648 | const keys2 = genBasicKeys();
|
12649 | const {
|
12650 | extraKey
|
12651 | } = props2;
|
12652 | const extraKeys = Array.isArray(extraKey) ? extraKey : [extraKey];
|
12653 | if (extraKeys.length === 0) {
|
12654 | keys2.push({
|
12655 | text: 0,
|
12656 | wider: true
|
12657 | });
|
12658 | } else if (extraKeys.length === 1) {
|
12659 | keys2.push({
|
12660 | text: 0,
|
12661 | wider: true
|
12662 | }, {
|
12663 | text: extraKeys[0],
|
12664 | type: "extra"
|
12665 | });
|
12666 | } else if (extraKeys.length === 2) {
|
12667 | keys2.push({
|
12668 | text: extraKeys[0],
|
12669 | type: "extra"
|
12670 | }, {
|
12671 | text: 0
|
12672 | }, {
|
12673 | text: extraKeys[1],
|
12674 | type: "extra"
|
12675 | });
|
12676 | }
|
12677 | return keys2;
|
12678 | };
|
12679 | const keys = vue.computed(() => props2.theme === "custom" ? genCustomKeys() : genDefaultKeys());
|
12680 | const onBlur = () => {
|
12681 | if (props2.show) {
|
12682 | emit("blur");
|
12683 | }
|
12684 | };
|
12685 | const onClose = () => {
|
12686 | emit("close");
|
12687 | if (props2.blurOnClose) {
|
12688 | onBlur();
|
12689 | }
|
12690 | };
|
12691 | const onAnimationEnd = () => emit(props2.show ? "show" : "hide");
|
12692 | const onPress = (text, type) => {
|
12693 | if (text === "") {
|
12694 | if (type === "extra") {
|
12695 | onBlur();
|
12696 | }
|
12697 | return;
|
12698 | }
|
12699 | const value = props2.modelValue;
|
12700 | if (type === "delete") {
|
12701 | emit("delete");
|
12702 | emit("update:modelValue", value.slice(0, value.length - 1));
|
12703 | } else if (type === "close") {
|
12704 | onClose();
|
12705 | } else if (value.length < +props2.maxlength) {
|
12706 | emit("input", text);
|
12707 | emit("update:modelValue", value + text);
|
12708 | }
|
12709 | };
|
12710 | const renderTitle = () => {
|
12711 | const {
|
12712 | title,
|
12713 | theme,
|
12714 | closeButtonText
|
12715 | } = props2;
|
12716 | const leftSlot = slots["title-left"];
|
12717 | const showClose = closeButtonText && theme === "default";
|
12718 | const showTitle = title || showClose || leftSlot;
|
12719 | if (!showTitle) {
|
12720 | return;
|
12721 | }
|
12722 | return vue.createVNode("div", {
|
12723 | "class": bem$v("header")
|
12724 | }, [leftSlot && vue.createVNode("span", {
|
12725 | "class": bem$v("title-left")
|
12726 | }, [leftSlot()]), title && vue.createVNode("h2", {
|
12727 | "class": bem$v("title")
|
12728 | }, [title]), showClose && vue.createVNode("button", {
|
12729 | "type": "button",
|
12730 | "class": [bem$v("close"), HAPTICS_FEEDBACK],
|
12731 | "onClick": onClose
|
12732 | }, [closeButtonText])]);
|
12733 | };
|
12734 | const renderKeys = () => keys.value.map((key) => {
|
12735 | const keySlots = {};
|
12736 | if (key.type === "delete") {
|
12737 | keySlots.default = slots.delete;
|
12738 | }
|
12739 | if (key.type === "extra") {
|
12740 | keySlots.default = slots["extra-key"];
|
12741 | }
|
12742 | return vue.createVNode(stdin_default$F, {
|
12743 | "key": key.text,
|
12744 | "text": key.text,
|
12745 | "type": key.type,
|
12746 | "wider": key.wider,
|
12747 | "color": key.color,
|
12748 | "onPress": onPress
|
12749 | }, keySlots);
|
12750 | });
|
12751 | const renderSidebar = () => {
|
12752 | if (props2.theme === "custom") {
|
12753 | return vue.createVNode("div", {
|
12754 | "class": bem$v("sidebar")
|
12755 | }, [props2.showDeleteKey && vue.createVNode(stdin_default$F, {
|
12756 | "large": true,
|
12757 | "text": props2.deleteButtonText,
|
12758 | "type": "delete",
|
12759 | "onPress": onPress
|
12760 | }, {
|
12761 | default: slots.delete
|
12762 | }), vue.createVNode(stdin_default$F, {
|
12763 | "large": true,
|
12764 | "text": props2.closeButtonText,
|
12765 | "type": "close",
|
12766 | "color": "blue",
|
12767 | "loading": props2.closeButtonLoading,
|
12768 | "onPress": onPress
|
12769 | }, null)]);
|
12770 | }
|
12771 | };
|
12772 | vue.watch(() => props2.show, (value) => {
|
12773 | if (!props2.transition) {
|
12774 | emit(value ? "show" : "hide");
|
12775 | }
|
12776 | });
|
12777 | if (props2.hideOnClickOutside) {
|
12778 | useClickAway(root, onBlur, {
|
12779 | eventName: "touchstart"
|
12780 | });
|
12781 | }
|
12782 | return () => {
|
12783 | const Title = renderTitle();
|
12784 | const Content = vue.createVNode(vue.Transition, {
|
12785 | "name": props2.transition ? "van-slide-up" : ""
|
12786 | }, {
|
12787 | default: () => [vue.withDirectives(vue.createVNode("div", vue.mergeProps({
|
12788 | "ref": root,
|
12789 | "style": getZIndexStyle(props2.zIndex),
|
12790 | "class": bem$v({
|
12791 | unfit: !props2.safeAreaInsetBottom,
|
12792 | "with-title": !!Title
|
12793 | }),
|
12794 | "onAnimationend": onAnimationEnd,
|
12795 | "onTouchstartPassive": stopPropagation
|
12796 | }, attrs), [Title, vue.createVNode("div", {
|
12797 | "class": bem$v("body")
|
12798 | }, [vue.createVNode("div", {
|
12799 | "class": bem$v("keys")
|
12800 | }, [renderKeys()]), renderSidebar()])]), [[vue.vShow, props2.show]])]
|
12801 | });
|
12802 | if (props2.teleport) {
|
12803 | return vue.createVNode(vue.Teleport, {
|
12804 | "to": props2.teleport
|
12805 | }, {
|
12806 | default: () => [Content]
|
12807 | });
|
12808 | }
|
12809 | return Content;
|
12810 | };
|
12811 | }
|
12812 | });
|
12813 | const NumberKeyboard = withInstall(stdin_default$E);
|
12814 | const [name$v, bem$u, t$6] = createNamespace("pagination");
|
12815 | const makePage = (number, text, active) => ({
|
12816 | number,
|
12817 | text,
|
12818 | active
|
12819 | });
|
12820 | const paginationProps = {
|
12821 | mode: makeStringProp("multi"),
|
12822 | prevText: String,
|
12823 | nextText: String,
|
12824 | pageCount: makeNumericProp(0),
|
12825 | modelValue: makeNumberProp(0),
|
12826 | totalItems: makeNumericProp(0),
|
12827 | showPageSize: makeNumericProp(5),
|
12828 | itemsPerPage: makeNumericProp(10),
|
12829 | forceEllipses: Boolean,
|
12830 | showPrevButton: truthProp,
|
12831 | showNextButton: truthProp
|
12832 | };
|
12833 | var stdin_default$D = vue.defineComponent({
|
12834 | name: name$v,
|
12835 | props: paginationProps,
|
12836 | emits: ["change", "update:modelValue"],
|
12837 | setup(props2, {
|
12838 | emit,
|
12839 | slots
|
12840 | }) {
|
12841 | const count = vue.computed(() => {
|
12842 | const {
|
12843 | pageCount,
|
12844 | totalItems,
|
12845 | itemsPerPage
|
12846 | } = props2;
|
12847 | const count2 = +pageCount || Math.ceil(+totalItems / +itemsPerPage);
|
12848 | return Math.max(1, count2);
|
12849 | });
|
12850 | const pages = vue.computed(() => {
|
12851 | const items = [];
|
12852 | const pageCount = count.value;
|
12853 | const showPageSize = +props2.showPageSize;
|
12854 | const {
|
12855 | modelValue,
|
12856 | forceEllipses
|
12857 | } = props2;
|
12858 | let startPage = 1;
|
12859 | let endPage = pageCount;
|
12860 | const isMaxSized = showPageSize < pageCount;
|
12861 | if (isMaxSized) {
|
12862 | startPage = Math.max(modelValue - Math.floor(showPageSize / 2), 1);
|
12863 | endPage = startPage + showPageSize - 1;
|
12864 | if (endPage > pageCount) {
|
12865 | endPage = pageCount;
|
12866 | startPage = endPage - showPageSize + 1;
|
12867 | }
|
12868 | }
|
12869 | for (let number = startPage; number <= endPage; number++) {
|
12870 | const page = makePage(number, number, number === modelValue);
|
12871 | items.push(page);
|
12872 | }
|
12873 | if (isMaxSized && showPageSize > 0 && forceEllipses) {
|
12874 | if (startPage > 1) {
|
12875 | const prevPages = makePage(startPage - 1, "...");
|
12876 | items.unshift(prevPages);
|
12877 | }
|
12878 | if (endPage < pageCount) {
|
12879 | const nextPages = makePage(endPage + 1, "...");
|
12880 | items.push(nextPages);
|
12881 | }
|
12882 | }
|
12883 | return items;
|
12884 | });
|
12885 | const updateModelValue = (value, emitChange) => {
|
12886 | value = clamp(value, 1, count.value);
|
12887 | if (props2.modelValue !== value) {
|
12888 | emit("update:modelValue", value);
|
12889 | if (emitChange) {
|
12890 | emit("change", value);
|
12891 | }
|
12892 | }
|
12893 | };
|
12894 | vue.watchEffect(() => updateModelValue(props2.modelValue));
|
12895 | const renderDesc = () => vue.createVNode("li", {
|
12896 | "class": bem$u("page-desc")
|
12897 | }, [slots.pageDesc ? slots.pageDesc() : `${props2.modelValue}/${count.value}`]);
|
12898 | const renderPrevButton = () => {
|
12899 | const {
|
12900 | mode,
|
12901 | modelValue,
|
12902 | showPrevButton
|
12903 | } = props2;
|
12904 | if (!showPrevButton) {
|
12905 | return;
|
12906 | }
|
12907 | const slot = slots["prev-text"];
|
12908 | const disabled = modelValue === 1;
|
12909 | return vue.createVNode("li", {
|
12910 | "class": [bem$u("item", {
|
12911 | disabled,
|
12912 | border: mode === "simple",
|
12913 | prev: true
|
12914 | }), BORDER_SURROUND]
|
12915 | }, [vue.createVNode("button", {
|
12916 | "type": "button",
|
12917 | "disabled": disabled,
|
12918 | "onClick": () => updateModelValue(modelValue - 1, true)
|
12919 | }, [slot ? slot() : props2.prevText || t$6("prev")])]);
|
12920 | };
|
12921 | const renderNextButton = () => {
|
12922 | const {
|
12923 | mode,
|
12924 | modelValue,
|
12925 | showNextButton
|
12926 | } = props2;
|
12927 | if (!showNextButton) {
|
12928 | return;
|
12929 | }
|
12930 | const slot = slots["next-text"];
|
12931 | const disabled = modelValue === count.value;
|
12932 | return vue.createVNode("li", {
|
12933 | "class": [bem$u("item", {
|
12934 | disabled,
|
12935 | border: mode === "simple",
|
12936 | next: true
|
12937 | }), BORDER_SURROUND]
|
12938 | }, [vue.createVNode("button", {
|
12939 | "type": "button",
|
12940 | "disabled": disabled,
|
12941 | "onClick": () => updateModelValue(modelValue + 1, true)
|
12942 | }, [slot ? slot() : props2.nextText || t$6("next")])]);
|
12943 | };
|
12944 | const renderPages = () => pages.value.map((page) => vue.createVNode("li", {
|
12945 | "class": [bem$u("item", {
|
12946 | active: page.active,
|
12947 | page: true
|
12948 | }), BORDER_SURROUND]
|
12949 | }, [vue.createVNode("button", {
|
12950 | "type": "button",
|
12951 | "aria-current": page.active || void 0,
|
12952 | "onClick": () => updateModelValue(page.number, true)
|
12953 | }, [slots.page ? slots.page(page) : page.text])]));
|
12954 | return () => vue.createVNode("nav", {
|
12955 | "role": "navigation",
|
12956 | "class": bem$u()
|
12957 | }, [vue.createVNode("ul", {
|
12958 | "class": bem$u("items")
|
12959 | }, [renderPrevButton(), props2.mode === "simple" ? renderDesc() : renderPages(), renderNextButton()])]);
|
12960 | }
|
12961 | });
|
12962 | const Pagination = withInstall(stdin_default$D);
|
12963 | const [name$u, bem$t] = createNamespace("password-input");
|
12964 | const passwordInputProps = {
|
12965 | info: String,
|
12966 | mask: truthProp,
|
12967 | value: makeStringProp(""),
|
12968 | gutter: numericProp,
|
12969 | length: makeNumericProp(6),
|
12970 | focused: Boolean,
|
12971 | errorInfo: String
|
12972 | };
|
12973 | var stdin_default$C = vue.defineComponent({
|
12974 | name: name$u,
|
12975 | props: passwordInputProps,
|
12976 | emits: ["focus"],
|
12977 | setup(props2, {
|
12978 | emit
|
12979 | }) {
|
12980 | const onTouchStart = (event) => {
|
12981 | event.stopPropagation();
|
12982 | emit("focus", event);
|
12983 | };
|
12984 | const renderPoints = () => {
|
12985 | const Points = [];
|
12986 | const {
|
12987 | mask,
|
12988 | value,
|
12989 | gutter,
|
12990 | focused
|
12991 | } = props2;
|
12992 | const length = +props2.length;
|
12993 | for (let i = 0; i < length; i++) {
|
12994 | const char = value[i];
|
12995 | const showBorder = i !== 0 && !gutter;
|
12996 | const showCursor = focused && i === value.length;
|
12997 | let style;
|
12998 | if (i !== 0 && gutter) {
|
12999 | style = {
|
13000 | marginLeft: addUnit(gutter)
|
13001 | };
|
13002 | }
|
13003 | Points.push(vue.createVNode("li", {
|
13004 | "class": [{
|
13005 | [BORDER_LEFT]: showBorder
|
13006 | }, bem$t("item", {
|
13007 | focus: showCursor
|
13008 | })],
|
13009 | "style": style
|
13010 | }, [mask ? vue.createVNode("i", {
|
13011 | "style": {
|
13012 | visibility: char ? "visible" : "hidden"
|
13013 | }
|
13014 | }, null) : char, showCursor && vue.createVNode("div", {
|
13015 | "class": bem$t("cursor")
|
13016 | }, null)]));
|
13017 | }
|
13018 | return Points;
|
13019 | };
|
13020 | return () => {
|
13021 | const info = props2.errorInfo || props2.info;
|
13022 | return vue.createVNode("div", {
|
13023 | "class": bem$t()
|
13024 | }, [vue.createVNode("ul", {
|
13025 | "class": [bem$t("security"), {
|
13026 | [BORDER_SURROUND]: !props2.gutter
|
13027 | }],
|
13028 | "onTouchstartPassive": onTouchStart
|
13029 | }, [renderPoints()]), info && vue.createVNode("div", {
|
13030 | "class": bem$t(props2.errorInfo ? "error-info" : "info")
|
13031 | }, [info])]);
|
13032 | };
|
13033 | }
|
13034 | });
|
13035 | const PasswordInput = withInstall(stdin_default$C);
|
13036 | const PickerGroup = withInstall(stdin_default$1A);
|
13037 | function getWindow(node) {
|
13038 | if (node == null) {
|
13039 | return window;
|
13040 | }
|
13041 | if (node.toString() !== "[object Window]") {
|
13042 | var ownerDocument = node.ownerDocument;
|
13043 | return ownerDocument ? ownerDocument.defaultView || window : window;
|
13044 | }
|
13045 | return node;
|
13046 | }
|
13047 | function isElement(node) {
|
13048 | var OwnElement = getWindow(node).Element;
|
13049 | return node instanceof OwnElement || node instanceof Element;
|
13050 | }
|
13051 | function isHTMLElement(node) {
|
13052 | var OwnElement = getWindow(node).HTMLElement;
|
13053 | return node instanceof OwnElement || node instanceof HTMLElement;
|
13054 | }
|
13055 | function isShadowRoot(node) {
|
13056 | if (typeof ShadowRoot === "undefined") {
|
13057 | return false;
|
13058 | }
|
13059 | var OwnElement = getWindow(node).ShadowRoot;
|
13060 | return node instanceof OwnElement || node instanceof ShadowRoot;
|
13061 | }
|
13062 | var round = Math.round;
|
13063 | function getUAString() {
|
13064 | var uaData = navigator.userAgentData;
|
13065 | if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
|
13066 | return uaData.brands.map(function(item) {
|
13067 | return item.brand + "/" + item.version;
|
13068 | }).join(" ");
|
13069 | }
|
13070 | return navigator.userAgent;
|
13071 | }
|
13072 | function isLayoutViewport() {
|
13073 | return !/^((?!chrome|android).)*safari/i.test(getUAString());
|
13074 | }
|
13075 | function getBoundingClientRect(element, includeScale, isFixedStrategy) {
|
13076 | if (includeScale === void 0) {
|
13077 | includeScale = false;
|
13078 | }
|
13079 | if (isFixedStrategy === void 0) {
|
13080 | isFixedStrategy = false;
|
13081 | }
|
13082 | var clientRect = element.getBoundingClientRect();
|
13083 | var scaleX = 1;
|
13084 | var scaleY = 1;
|
13085 | if (includeScale && isHTMLElement(element)) {
|
13086 | scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
|
13087 | scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
|
13088 | }
|
13089 | var _ref = isElement(element) ? getWindow(element) : window, visualViewport = _ref.visualViewport;
|
13090 | var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
|
13091 | var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
|
13092 | var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
|
13093 | var width2 = clientRect.width / scaleX;
|
13094 | var height2 = clientRect.height / scaleY;
|
13095 | return {
|
13096 | width: width2,
|
13097 | height: height2,
|
13098 | top: y,
|
13099 | right: x + width2,
|
13100 | bottom: y + height2,
|
13101 | left: x,
|
13102 | x,
|
13103 | y
|
13104 | };
|
13105 | }
|
13106 | function getWindowScroll(node) {
|
13107 | var win = getWindow(node);
|
13108 | var scrollLeft = win.pageXOffset;
|
13109 | var scrollTop = win.pageYOffset;
|
13110 | return {
|
13111 | scrollLeft,
|
13112 | scrollTop
|
13113 | };
|
13114 | }
|
13115 | function getHTMLElementScroll(element) {
|
13116 | return {
|
13117 | scrollLeft: element.scrollLeft,
|
13118 | scrollTop: element.scrollTop
|
13119 | };
|
13120 | }
|
13121 | function getNodeScroll(node) {
|
13122 | if (node === getWindow(node) || !isHTMLElement(node)) {
|
13123 | return getWindowScroll(node);
|
13124 | } else {
|
13125 | return getHTMLElementScroll(node);
|
13126 | }
|
13127 | }
|
13128 | function getNodeName(element) {
|
13129 | return element ? (element.nodeName || "").toLowerCase() : null;
|
13130 | }
|
13131 | function getDocumentElement(element) {
|
13132 | return ((isElement(element) ? element.ownerDocument : (
|
13133 |
|
13134 | element.document
|
13135 | )) || window.document).documentElement;
|
13136 | }
|
13137 | function getWindowScrollBarX(element) {
|
13138 | return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
|
13139 | }
|
13140 | function getComputedStyle(element) {
|
13141 | return getWindow(element).getComputedStyle(element);
|
13142 | }
|
13143 | function isScrollParent(element) {
|
13144 | var _getComputedStyle = getComputedStyle(element), overflow = _getComputedStyle.overflow, overflowX = _getComputedStyle.overflowX, overflowY = _getComputedStyle.overflowY;
|
13145 | return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
|
13146 | }
|
13147 | function isElementScaled(element) {
|
13148 | var rect = element.getBoundingClientRect();
|
13149 | var scaleX = round(rect.width) / element.offsetWidth || 1;
|
13150 | var scaleY = round(rect.height) / element.offsetHeight || 1;
|
13151 | return scaleX !== 1 || scaleY !== 1;
|
13152 | }
|
13153 | function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
|
13154 | if (isFixed === void 0) {
|
13155 | isFixed = false;
|
13156 | }
|
13157 | var isOffsetParentAnElement = isHTMLElement(offsetParent);
|
13158 | var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
|
13159 | var documentElement = getDocumentElement(offsetParent);
|
13160 | var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
|
13161 | var scroll = {
|
13162 | scrollLeft: 0,
|
13163 | scrollTop: 0
|
13164 | };
|
13165 | var offsets = {
|
13166 | x: 0,
|
13167 | y: 0
|
13168 | };
|
13169 | if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
13170 | if (getNodeName(offsetParent) !== "body" ||
|
13171 | isScrollParent(documentElement)) {
|
13172 | scroll = getNodeScroll(offsetParent);
|
13173 | }
|
13174 | if (isHTMLElement(offsetParent)) {
|
13175 | offsets = getBoundingClientRect(offsetParent, true);
|
13176 | offsets.x += offsetParent.clientLeft;
|
13177 | offsets.y += offsetParent.clientTop;
|
13178 | } else if (documentElement) {
|
13179 | offsets.x = getWindowScrollBarX(documentElement);
|
13180 | }
|
13181 | }
|
13182 | return {
|
13183 | x: rect.left + scroll.scrollLeft - offsets.x,
|
13184 | y: rect.top + scroll.scrollTop - offsets.y,
|
13185 | width: rect.width,
|
13186 | height: rect.height
|
13187 | };
|
13188 | }
|
13189 | function getLayoutRect(element) {
|
13190 | var clientRect = getBoundingClientRect(element);
|
13191 | var width2 = element.offsetWidth;
|
13192 | var height2 = element.offsetHeight;
|
13193 | if (Math.abs(clientRect.width - width2) <= 1) {
|
13194 | width2 = clientRect.width;
|
13195 | }
|
13196 | if (Math.abs(clientRect.height - height2) <= 1) {
|
13197 | height2 = clientRect.height;
|
13198 | }
|
13199 | return {
|
13200 | x: element.offsetLeft,
|
13201 | y: element.offsetTop,
|
13202 | width: width2,
|
13203 | height: height2
|
13204 | };
|
13205 | }
|
13206 | function getParentNode(element) {
|
13207 | if (getNodeName(element) === "html") {
|
13208 | return element;
|
13209 | }
|
13210 | return (
|
13211 |
|
13212 |
|
13213 |
|
13214 | element.assignedSlot ||
|
13215 | element.parentNode ||
|
13216 | (isShadowRoot(element) ? element.host : null) ||
|
13217 |
|
13218 | getDocumentElement(element)
|
13219 | );
|
13220 | }
|
13221 | function getScrollParent(node) {
|
13222 | if (["html", "body", "#document"].indexOf(getNodeName(node)) >= 0) {
|
13223 | return node.ownerDocument.body;
|
13224 | }
|
13225 | if (isHTMLElement(node) && isScrollParent(node)) {
|
13226 | return node;
|
13227 | }
|
13228 | return getScrollParent(getParentNode(node));
|
13229 | }
|
13230 | function listScrollParents(element, list) {
|
13231 | var _element$ownerDocumen;
|
13232 | if (list === void 0) {
|
13233 | list = [];
|
13234 | }
|
13235 | var scrollParent = getScrollParent(element);
|
13236 | var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
|
13237 | var win = getWindow(scrollParent);
|
13238 | var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
|
13239 | var updatedList = list.concat(target);
|
13240 | return isBody ? updatedList : (
|
13241 |
|
13242 | updatedList.concat(listScrollParents(getParentNode(target)))
|
13243 | );
|
13244 | }
|
13245 | function isTableElement(element) {
|
13246 | return ["table", "td", "th"].indexOf(getNodeName(element)) >= 0;
|
13247 | }
|
13248 | function getTrueOffsetParent(element) {
|
13249 | if (!isHTMLElement(element) ||
|
13250 | getComputedStyle(element).position === "fixed") {
|
13251 | return null;
|
13252 | }
|
13253 | return element.offsetParent;
|
13254 | }
|
13255 | function getContainingBlock(element) {
|
13256 | var isFirefox = /firefox/i.test(getUAString());
|
13257 | var isIE = /Trident/i.test(getUAString());
|
13258 | if (isIE && isHTMLElement(element)) {
|
13259 | var elementCss = getComputedStyle(element);
|
13260 | if (elementCss.position === "fixed") {
|
13261 | return null;
|
13262 | }
|
13263 | }
|
13264 | var currentNode = getParentNode(element);
|
13265 | if (isShadowRoot(currentNode)) {
|
13266 | currentNode = currentNode.host;
|
13267 | }
|
13268 | while (isHTMLElement(currentNode) && ["html", "body"].indexOf(getNodeName(currentNode)) < 0) {
|
13269 | var css = getComputedStyle(currentNode);
|
13270 | if (css.transform !== "none" || css.perspective !== "none" || css.contain === "paint" || ["transform", "perspective"].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === "filter" || isFirefox && css.filter && css.filter !== "none") {
|
13271 | return currentNode;
|
13272 | } else {
|
13273 | currentNode = currentNode.parentNode;
|
13274 | }
|
13275 | }
|
13276 | return null;
|
13277 | }
|
13278 | function getOffsetParent(element) {
|
13279 | var window2 = getWindow(element);
|
13280 | var offsetParent = getTrueOffsetParent(element);
|
13281 | while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === "static") {
|
13282 | offsetParent = getTrueOffsetParent(offsetParent);
|
13283 | }
|
13284 | if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle(offsetParent).position === "static")) {
|
13285 | return window2;
|
13286 | }
|
13287 | return offsetParent || getContainingBlock(element) || window2;
|
13288 | }
|
13289 | var top = "top";
|
13290 | var bottom = "bottom";
|
13291 | var right = "right";
|
13292 | var left = "left";
|
13293 | var auto = "auto";
|
13294 | var basePlacements = [top, bottom, right, left];
|
13295 | var start = "start";
|
13296 | var end = "end";
|
13297 | var placements = [].concat(basePlacements, [auto]).reduce(function(acc, placement) {
|
13298 | return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
|
13299 | }, []);
|
13300 | var beforeRead = "beforeRead";
|
13301 | var read = "read";
|
13302 | var afterRead = "afterRead";
|
13303 | var beforeMain = "beforeMain";
|
13304 | var main = "main";
|
13305 | var afterMain = "afterMain";
|
13306 | var beforeWrite = "beforeWrite";
|
13307 | var write = "write";
|
13308 | var afterWrite = "afterWrite";
|
13309 | var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
|
13310 | function order(modifiers) {
|
13311 | var map = new Map();
|
13312 | var visited = new Set();
|
13313 | var result = [];
|
13314 | modifiers.forEach(function(modifier) {
|
13315 | map.set(modifier.name, modifier);
|
13316 | });
|
13317 | function sort(modifier) {
|
13318 | visited.add(modifier.name);
|
13319 | var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
|
13320 | requires.forEach(function(dep) {
|
13321 | if (!visited.has(dep)) {
|
13322 | var depModifier = map.get(dep);
|
13323 | if (depModifier) {
|
13324 | sort(depModifier);
|
13325 | }
|
13326 | }
|
13327 | });
|
13328 | result.push(modifier);
|
13329 | }
|
13330 | modifiers.forEach(function(modifier) {
|
13331 | if (!visited.has(modifier.name)) {
|
13332 | sort(modifier);
|
13333 | }
|
13334 | });
|
13335 | return result;
|
13336 | }
|
13337 | function orderModifiers(modifiers) {
|
13338 | var orderedModifiers = order(modifiers);
|
13339 | return modifierPhases.reduce(function(acc, phase) {
|
13340 | return acc.concat(orderedModifiers.filter(function(modifier) {
|
13341 | return modifier.phase === phase;
|
13342 | }));
|
13343 | }, []);
|
13344 | }
|
13345 | function debounce(fn2) {
|
13346 | var pending;
|
13347 | return function() {
|
13348 | if (!pending) {
|
13349 | pending = new Promise(function(resolve) {
|
13350 | Promise.resolve().then(function() {
|
13351 | pending = void 0;
|
13352 | resolve(fn2());
|
13353 | });
|
13354 | });
|
13355 | }
|
13356 | return pending;
|
13357 | };
|
13358 | }
|
13359 | function mergeByName(modifiers) {
|
13360 | var merged = modifiers.reduce(function(merged2, current2) {
|
13361 | var existing = merged2[current2.name];
|
13362 | merged2[current2.name] = existing ? Object.assign({}, existing, current2, {
|
13363 | options: Object.assign({}, existing.options, current2.options),
|
13364 | data: Object.assign({}, existing.data, current2.data)
|
13365 | }) : current2;
|
13366 | return merged2;
|
13367 | }, {});
|
13368 | return Object.keys(merged).map(function(key) {
|
13369 | return merged[key];
|
13370 | });
|
13371 | }
|
13372 | function getBasePlacement(placement) {
|
13373 | return placement.split("-")[0];
|
13374 | }
|
13375 | function getVariation(placement) {
|
13376 | return placement.split("-")[1];
|
13377 | }
|
13378 | function getMainAxisFromPlacement(placement) {
|
13379 | return ["top", "bottom"].indexOf(placement) >= 0 ? "x" : "y";
|
13380 | }
|
13381 | function computeOffsets(_ref) {
|
13382 | var reference = _ref.reference, element = _ref.element, placement = _ref.placement;
|
13383 | var basePlacement = placement ? getBasePlacement(placement) : null;
|
13384 | var variation = placement ? getVariation(placement) : null;
|
13385 | var commonX = reference.x + reference.width / 2 - element.width / 2;
|
13386 | var commonY = reference.y + reference.height / 2 - element.height / 2;
|
13387 | var offsets;
|
13388 | switch (basePlacement) {
|
13389 | case top:
|
13390 | offsets = {
|
13391 | x: commonX,
|
13392 | y: reference.y - element.height
|
13393 | };
|
13394 | break;
|
13395 | case bottom:
|
13396 | offsets = {
|
13397 | x: commonX,
|
13398 | y: reference.y + reference.height
|
13399 | };
|
13400 | break;
|
13401 | case right:
|
13402 | offsets = {
|
13403 | x: reference.x + reference.width,
|
13404 | y: commonY
|
13405 | };
|
13406 | break;
|
13407 | case left:
|
13408 | offsets = {
|
13409 | x: reference.x - element.width,
|
13410 | y: commonY
|
13411 | };
|
13412 | break;
|
13413 | default:
|
13414 | offsets = {
|
13415 | x: reference.x,
|
13416 | y: reference.y
|
13417 | };
|
13418 | }
|
13419 | var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
|
13420 | if (mainAxis != null) {
|
13421 | var len = mainAxis === "y" ? "height" : "width";
|
13422 | switch (variation) {
|
13423 | case start:
|
13424 | offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
|
13425 | break;
|
13426 | case end:
|
13427 | offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
|
13428 | break;
|
13429 | }
|
13430 | }
|
13431 | return offsets;
|
13432 | }
|
13433 | var DEFAULT_OPTIONS = {
|
13434 | placement: "bottom",
|
13435 | modifiers: [],
|
13436 | strategy: "absolute"
|
13437 | };
|
13438 | function areValidElements() {
|
13439 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
13440 | args[_key] = arguments[_key];
|
13441 | }
|
13442 | return !args.some(function(element) {
|
13443 | return !(element && typeof element.getBoundingClientRect === "function");
|
13444 | });
|
13445 | }
|
13446 | function popperGenerator(generatorOptions) {
|
13447 | if (generatorOptions === void 0) {
|
13448 | generatorOptions = {};
|
13449 | }
|
13450 | var _generatorOptions = generatorOptions, _generatorOptions$def = _generatorOptions.defaultModifiers, defaultModifiers2 = _generatorOptions$def === void 0 ? [] : _generatorOptions$def, _generatorOptions$def2 = _generatorOptions.defaultOptions, defaultOptions2 = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
|
13451 | return function createPopper2(reference, popper, options) {
|
13452 | if (options === void 0) {
|
13453 | options = defaultOptions2;
|
13454 | }
|
13455 | var state = {
|
13456 | placement: "bottom",
|
13457 | orderedModifiers: [],
|
13458 | options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions2),
|
13459 | modifiersData: {},
|
13460 | elements: {
|
13461 | reference,
|
13462 | popper
|
13463 | },
|
13464 | attributes: {},
|
13465 | styles: {}
|
13466 | };
|
13467 | var effectCleanupFns = [];
|
13468 | var isDestroyed = false;
|
13469 | var instance2 = {
|
13470 | state,
|
13471 | setOptions: function setOptions(setOptionsAction) {
|
13472 | var options2 = typeof setOptionsAction === "function" ? setOptionsAction(state.options) : setOptionsAction;
|
13473 | cleanupModifierEffects();
|
13474 | state.options = Object.assign({}, defaultOptions2, state.options, options2);
|
13475 | state.scrollParents = {
|
13476 | reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
|
13477 | popper: listScrollParents(popper)
|
13478 | };
|
13479 | var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers2, state.options.modifiers)));
|
13480 | state.orderedModifiers = orderedModifiers.filter(function(m) {
|
13481 | return m.enabled;
|
13482 | });
|
13483 | runModifierEffects();
|
13484 | return instance2.update();
|
13485 | },
|
13486 |
|
13487 |
|
13488 |
|
13489 |
|
13490 |
|
13491 | forceUpdate: function forceUpdate() {
|
13492 | if (isDestroyed) {
|
13493 | return;
|
13494 | }
|
13495 | var _state$elements = state.elements, reference2 = _state$elements.reference, popper2 = _state$elements.popper;
|
13496 | if (!areValidElements(reference2, popper2)) {
|
13497 | return;
|
13498 | }
|
13499 | state.rects = {
|
13500 | reference: getCompositeRect(reference2, getOffsetParent(popper2), state.options.strategy === "fixed"),
|
13501 | popper: getLayoutRect(popper2)
|
13502 | };
|
13503 | state.reset = false;
|
13504 | state.placement = state.options.placement;
|
13505 | state.orderedModifiers.forEach(function(modifier) {
|
13506 | return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
|
13507 | });
|
13508 | for (var index = 0; index < state.orderedModifiers.length; index++) {
|
13509 | if (state.reset === true) {
|
13510 | state.reset = false;
|
13511 | index = -1;
|
13512 | continue;
|
13513 | }
|
13514 | var _state$orderedModifie = state.orderedModifiers[index], fn2 = _state$orderedModifie.fn, _state$orderedModifie2 = _state$orderedModifie.options, _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2, name2 = _state$orderedModifie.name;
|
13515 | if (typeof fn2 === "function") {
|
13516 | state = fn2({
|
13517 | state,
|
13518 | options: _options,
|
13519 | name: name2,
|
13520 | instance: instance2
|
13521 | }) || state;
|
13522 | }
|
13523 | }
|
13524 | },
|
13525 |
|
13526 |
|
13527 | update: debounce(function() {
|
13528 | return new Promise(function(resolve) {
|
13529 | instance2.forceUpdate();
|
13530 | resolve(state);
|
13531 | });
|
13532 | }),
|
13533 | destroy: function destroy() {
|
13534 | cleanupModifierEffects();
|
13535 | isDestroyed = true;
|
13536 | }
|
13537 | };
|
13538 | if (!areValidElements(reference, popper)) {
|
13539 | return instance2;
|
13540 | }
|
13541 | instance2.setOptions(options).then(function(state2) {
|
13542 | if (!isDestroyed && options.onFirstUpdate) {
|
13543 | options.onFirstUpdate(state2);
|
13544 | }
|
13545 | });
|
13546 | function runModifierEffects() {
|
13547 | state.orderedModifiers.forEach(function(_ref) {
|
13548 | var name2 = _ref.name, _ref$options = _ref.options, options2 = _ref$options === void 0 ? {} : _ref$options, effect3 = _ref.effect;
|
13549 | if (typeof effect3 === "function") {
|
13550 | var cleanupFn = effect3({
|
13551 | state,
|
13552 | name: name2,
|
13553 | instance: instance2,
|
13554 | options: options2
|
13555 | });
|
13556 | var noopFn = function noopFn2() {
|
13557 | };
|
13558 | effectCleanupFns.push(cleanupFn || noopFn);
|
13559 | }
|
13560 | });
|
13561 | }
|
13562 | function cleanupModifierEffects() {
|
13563 | effectCleanupFns.forEach(function(fn2) {
|
13564 | return fn2();
|
13565 | });
|
13566 | effectCleanupFns = [];
|
13567 | }
|
13568 | return instance2;
|
13569 | };
|
13570 | }
|
13571 | var passive = {
|
13572 | passive: true
|
13573 | };
|
13574 | function effect(_ref) {
|
13575 | var state = _ref.state, instance2 = _ref.instance, options = _ref.options;
|
13576 | var _options$scroll = options.scroll, scroll = _options$scroll === void 0 ? true : _options$scroll, _options$resize = options.resize, resize = _options$resize === void 0 ? true : _options$resize;
|
13577 | var window2 = getWindow(state.elements.popper);
|
13578 | var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
|
13579 | if (scroll) {
|
13580 | scrollParents.forEach(function(scrollParent) {
|
13581 | scrollParent.addEventListener("scroll", instance2.update, passive);
|
13582 | });
|
13583 | }
|
13584 | if (resize) {
|
13585 | window2.addEventListener("resize", instance2.update, passive);
|
13586 | }
|
13587 | return function() {
|
13588 | if (scroll) {
|
13589 | scrollParents.forEach(function(scrollParent) {
|
13590 | scrollParent.removeEventListener("scroll", instance2.update, passive);
|
13591 | });
|
13592 | }
|
13593 | if (resize) {
|
13594 | window2.removeEventListener("resize", instance2.update, passive);
|
13595 | }
|
13596 | };
|
13597 | }
|
13598 | var eventListeners_default = {
|
13599 | name: "eventListeners",
|
13600 | enabled: true,
|
13601 | phase: "write",
|
13602 | fn: function fn() {
|
13603 | },
|
13604 | effect,
|
13605 | data: {}
|
13606 | };
|
13607 | function popperOffsets(_ref) {
|
13608 | var state = _ref.state, name2 = _ref.name;
|
13609 | state.modifiersData[name2] = computeOffsets({
|
13610 | reference: state.rects.reference,
|
13611 | element: state.rects.popper,
|
13612 | strategy: "absolute",
|
13613 | placement: state.placement
|
13614 | });
|
13615 | }
|
13616 | var popperOffsets_default = {
|
13617 | name: "popperOffsets",
|
13618 | enabled: true,
|
13619 | phase: "read",
|
13620 | fn: popperOffsets,
|
13621 | data: {}
|
13622 | };
|
13623 | var unsetSides = {
|
13624 | top: "auto",
|
13625 | right: "auto",
|
13626 | bottom: "auto",
|
13627 | left: "auto"
|
13628 | };
|
13629 | function roundOffsetsByDPR(_ref, win) {
|
13630 | var x = _ref.x, y = _ref.y;
|
13631 | var dpr = win.devicePixelRatio || 1;
|
13632 | return {
|
13633 | x: round(x * dpr) / dpr || 0,
|
13634 | y: round(y * dpr) / dpr || 0
|
13635 | };
|
13636 | }
|
13637 | function mapToStyles(_ref2) {
|
13638 | var _Object$assign2;
|
13639 | var popper = _ref2.popper, popperRect = _ref2.popperRect, placement = _ref2.placement, variation = _ref2.variation, offsets = _ref2.offsets, position = _ref2.position, gpuAcceleration = _ref2.gpuAcceleration, adaptive = _ref2.adaptive, roundOffsets = _ref2.roundOffsets, isFixed = _ref2.isFixed;
|
13640 | var _offsets$x = offsets.x, x = _offsets$x === void 0 ? 0 : _offsets$x, _offsets$y = offsets.y, y = _offsets$y === void 0 ? 0 : _offsets$y;
|
13641 | var _ref3 = typeof roundOffsets === "function" ? roundOffsets({
|
13642 | x,
|
13643 | y
|
13644 | }) : {
|
13645 | x,
|
13646 | y
|
13647 | };
|
13648 | x = _ref3.x;
|
13649 | y = _ref3.y;
|
13650 | var hasX = offsets.hasOwnProperty("x");
|
13651 | var hasY = offsets.hasOwnProperty("y");
|
13652 | var sideX = left;
|
13653 | var sideY = top;
|
13654 | var win = window;
|
13655 | if (adaptive) {
|
13656 | var offsetParent = getOffsetParent(popper);
|
13657 | var heightProp = "clientHeight";
|
13658 | var widthProp = "clientWidth";
|
13659 | if (offsetParent === getWindow(popper)) {
|
13660 | offsetParent = getDocumentElement(popper);
|
13661 | if (getComputedStyle(offsetParent).position !== "static" && position === "absolute") {
|
13662 | heightProp = "scrollHeight";
|
13663 | widthProp = "scrollWidth";
|
13664 | }
|
13665 | }
|
13666 | offsetParent = offsetParent;
|
13667 | if (placement === top || (placement === left || placement === right) && variation === end) {
|
13668 | sideY = bottom;
|
13669 | var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : (
|
13670 |
|
13671 | offsetParent[heightProp]
|
13672 | );
|
13673 | y -= offsetY - popperRect.height;
|
13674 | y *= gpuAcceleration ? 1 : -1;
|
13675 | }
|
13676 | if (placement === left || (placement === top || placement === bottom) && variation === end) {
|
13677 | sideX = right;
|
13678 | var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : (
|
13679 |
|
13680 | offsetParent[widthProp]
|
13681 | );
|
13682 | x -= offsetX - popperRect.width;
|
13683 | x *= gpuAcceleration ? 1 : -1;
|
13684 | }
|
13685 | }
|
13686 | var commonStyles = Object.assign({
|
13687 | position
|
13688 | }, adaptive && unsetSides);
|
13689 | var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
|
13690 | x,
|
13691 | y
|
13692 | }, getWindow(popper)) : {
|
13693 | x,
|
13694 | y
|
13695 | };
|
13696 | x = _ref4.x;
|
13697 | y = _ref4.y;
|
13698 | if (gpuAcceleration) {
|
13699 | var _Object$assign;
|
13700 | return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? "0" : "", _Object$assign[sideX] = hasX ? "0" : "", _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
|
13701 | }
|
13702 | return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : "", _Object$assign2[sideX] = hasX ? x + "px" : "", _Object$assign2.transform = "", _Object$assign2));
|
13703 | }
|
13704 | function computeStyles(_ref5) {
|
13705 | var state = _ref5.state, options = _ref5.options;
|
13706 | var _options$gpuAccelerat = options.gpuAcceleration, gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat, _options$adaptive = options.adaptive, adaptive = _options$adaptive === void 0 ? true : _options$adaptive, _options$roundOffsets = options.roundOffsets, roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
|
13707 | var commonStyles = {
|
13708 | placement: getBasePlacement(state.placement),
|
13709 | variation: getVariation(state.placement),
|
13710 | popper: state.elements.popper,
|
13711 | popperRect: state.rects.popper,
|
13712 | gpuAcceleration,
|
13713 | isFixed: state.options.strategy === "fixed"
|
13714 | };
|
13715 | if (state.modifiersData.popperOffsets != null) {
|
13716 | state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
|
13717 | offsets: state.modifiersData.popperOffsets,
|
13718 | position: state.options.strategy,
|
13719 | adaptive,
|
13720 | roundOffsets
|
13721 | })));
|
13722 | }
|
13723 | if (state.modifiersData.arrow != null) {
|
13724 | state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
|
13725 | offsets: state.modifiersData.arrow,
|
13726 | position: "absolute",
|
13727 | adaptive: false,
|
13728 | roundOffsets
|
13729 | })));
|
13730 | }
|
13731 | state.attributes.popper = Object.assign({}, state.attributes.popper, {
|
13732 | "data-popper-placement": state.placement
|
13733 | });
|
13734 | }
|
13735 | var computeStyles_default = {
|
13736 | name: "computeStyles",
|
13737 | enabled: true,
|
13738 | phase: "beforeWrite",
|
13739 | fn: computeStyles,
|
13740 | data: {}
|
13741 | };
|
13742 | function applyStyles(_ref) {
|
13743 | var state = _ref.state;
|
13744 | Object.keys(state.elements).forEach(function(name2) {
|
13745 | var style = state.styles[name2] || {};
|
13746 | var attributes = state.attributes[name2] || {};
|
13747 | var element = state.elements[name2];
|
13748 | if (!isHTMLElement(element) || !getNodeName(element)) {
|
13749 | return;
|
13750 | }
|
13751 | Object.assign(element.style, style);
|
13752 | Object.keys(attributes).forEach(function(name22) {
|
13753 | var value = attributes[name22];
|
13754 | if (value === false) {
|
13755 | element.removeAttribute(name22);
|
13756 | } else {
|
13757 | element.setAttribute(name22, value === true ? "" : value);
|
13758 | }
|
13759 | });
|
13760 | });
|
13761 | }
|
13762 | function effect2(_ref2) {
|
13763 | var state = _ref2.state;
|
13764 | var initialStyles = {
|
13765 | popper: {
|
13766 | position: state.options.strategy,
|
13767 | left: "0",
|
13768 | top: "0",
|
13769 | margin: "0"
|
13770 | },
|
13771 | arrow: {
|
13772 | position: "absolute"
|
13773 | },
|
13774 | reference: {}
|
13775 | };
|
13776 | Object.assign(state.elements.popper.style, initialStyles.popper);
|
13777 | state.styles = initialStyles;
|
13778 | if (state.elements.arrow) {
|
13779 | Object.assign(state.elements.arrow.style, initialStyles.arrow);
|
13780 | }
|
13781 | return function() {
|
13782 | Object.keys(state.elements).forEach(function(name2) {
|
13783 | var element = state.elements[name2];
|
13784 | var attributes = state.attributes[name2] || {};
|
13785 | var styleProperties = Object.keys(state.styles.hasOwnProperty(name2) ? state.styles[name2] : initialStyles[name2]);
|
13786 | var style = styleProperties.reduce(function(style2, property) {
|
13787 | style2[property] = "";
|
13788 | return style2;
|
13789 | }, {});
|
13790 | if (!isHTMLElement(element) || !getNodeName(element)) {
|
13791 | return;
|
13792 | }
|
13793 | Object.assign(element.style, style);
|
13794 | Object.keys(attributes).forEach(function(attribute) {
|
13795 | element.removeAttribute(attribute);
|
13796 | });
|
13797 | });
|
13798 | };
|
13799 | }
|
13800 | var applyStyles_default = {
|
13801 | name: "applyStyles",
|
13802 | enabled: true,
|
13803 | phase: "write",
|
13804 | fn: applyStyles,
|
13805 | effect: effect2,
|
13806 | requires: ["computeStyles"]
|
13807 | };
|
13808 | var defaultModifiers = [eventListeners_default, popperOffsets_default, computeStyles_default, applyStyles_default];
|
13809 | var createPopper = popperGenerator({
|
13810 | defaultModifiers
|
13811 | });
|
13812 | function distanceAndSkiddingToXY(placement, rects, offset2) {
|
13813 | var basePlacement = getBasePlacement(placement);
|
13814 | var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
|
13815 | var _ref = typeof offset2 === "function" ? offset2(Object.assign({}, rects, {
|
13816 | placement
|
13817 | })) : offset2, skidding = _ref[0], distance = _ref[1];
|
13818 | skidding = skidding || 0;
|
13819 | distance = (distance || 0) * invertDistance;
|
13820 | return [left, right].indexOf(basePlacement) >= 0 ? {
|
13821 | x: distance,
|
13822 | y: skidding
|
13823 | } : {
|
13824 | x: skidding,
|
13825 | y: distance
|
13826 | };
|
13827 | }
|
13828 | function offset(_ref2) {
|
13829 | var state = _ref2.state, options = _ref2.options, name2 = _ref2.name;
|
13830 | var _options$offset = options.offset, offset2 = _options$offset === void 0 ? [0, 0] : _options$offset;
|
13831 | var data = placements.reduce(function(acc, placement) {
|
13832 | acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset2);
|
13833 | return acc;
|
13834 | }, {});
|
13835 | var _data$state$placement = data[state.placement], x = _data$state$placement.x, y = _data$state$placement.y;
|
13836 | if (state.modifiersData.popperOffsets != null) {
|
13837 | state.modifiersData.popperOffsets.x += x;
|
13838 | state.modifiersData.popperOffsets.y += y;
|
13839 | }
|
13840 | state.modifiersData[name2] = data;
|
13841 | }
|
13842 | var offset_default = {
|
13843 | name: "offset",
|
13844 | enabled: true,
|
13845 | phase: "main",
|
13846 | requires: ["popperOffsets"],
|
13847 | fn: offset
|
13848 | };
|
13849 | const [name$t, bem$s] = createNamespace("popover");
|
13850 | const popupProps = ["overlay", "duration", "teleport", "overlayStyle", "overlayClass", "closeOnClickOverlay"];
|
13851 | const popoverProps = {
|
13852 | show: Boolean,
|
13853 | theme: makeStringProp("light"),
|
13854 | overlay: Boolean,
|
13855 | actions: makeArrayProp(),
|
13856 | actionsDirection: makeStringProp("vertical"),
|
13857 | trigger: makeStringProp("click"),
|
13858 | duration: numericProp,
|
13859 | showArrow: truthProp,
|
13860 | placement: makeStringProp("bottom"),
|
13861 | iconPrefix: String,
|
13862 | overlayClass: unknownProp,
|
13863 | overlayStyle: Object,
|
13864 | closeOnClickAction: truthProp,
|
13865 | closeOnClickOverlay: truthProp,
|
13866 | closeOnClickOutside: truthProp,
|
13867 | offset: {
|
13868 | type: Array,
|
13869 | default: () => [0, 8]
|
13870 | },
|
13871 | teleport: {
|
13872 | type: [String, Object],
|
13873 | default: "body"
|
13874 | }
|
13875 | };
|
13876 | var stdin_default$B = vue.defineComponent({
|
13877 | name: name$t,
|
13878 | props: popoverProps,
|
13879 | emits: ["select", "touchstart", "update:show"],
|
13880 | setup(props2, {
|
13881 | emit,
|
13882 | slots,
|
13883 | attrs
|
13884 | }) {
|
13885 | let popper;
|
13886 | const popupRef = vue.ref();
|
13887 | const wrapperRef = vue.ref();
|
13888 | const popoverRef = vue.ref();
|
13889 | const show = useSyncPropRef(() => props2.show, (value) => emit("update:show", value));
|
13890 | const getPopoverOptions = () => ({
|
13891 | placement: props2.placement,
|
13892 | modifiers: [{
|
13893 | name: "computeStyles",
|
13894 | options: {
|
13895 | adaptive: false,
|
13896 | gpuAcceleration: false
|
13897 | }
|
13898 | }, extend({}, offset_default, {
|
13899 | options: {
|
13900 | offset: props2.offset
|
13901 | }
|
13902 | })]
|
13903 | });
|
13904 | const createPopperInstance = () => {
|
13905 | if (wrapperRef.value && popoverRef.value) {
|
13906 | return createPopper(wrapperRef.value, popoverRef.value.popupRef.value, getPopoverOptions());
|
13907 | }
|
13908 | return null;
|
13909 | };
|
13910 | const updateLocation = () => {
|
13911 | vue.nextTick(() => {
|
13912 | if (!show.value) {
|
13913 | return;
|
13914 | }
|
13915 | if (!popper) {
|
13916 | popper = createPopperInstance();
|
13917 | if (inBrowser$1) {
|
13918 | window.addEventListener("animationend", updateLocation);
|
13919 | window.addEventListener("transitionend", updateLocation);
|
13920 | }
|
13921 | } else {
|
13922 | popper.setOptions(getPopoverOptions());
|
13923 | }
|
13924 | });
|
13925 | };
|
13926 | const updateShow = (value) => {
|
13927 | show.value = value;
|
13928 | };
|
13929 | const onClickWrapper = () => {
|
13930 | if (props2.trigger === "click") {
|
13931 | show.value = !show.value;
|
13932 | }
|
13933 | };
|
13934 | const onClickAction = (action, index) => {
|
13935 | if (action.disabled) {
|
13936 | return;
|
13937 | }
|
13938 | emit("select", action, index);
|
13939 | if (props2.closeOnClickAction) {
|
13940 | show.value = false;
|
13941 | }
|
13942 | };
|
13943 | const onClickAway = () => {
|
13944 | if (show.value && props2.closeOnClickOutside && (!props2.overlay || props2.closeOnClickOverlay)) {
|
13945 | show.value = false;
|
13946 | }
|
13947 | };
|
13948 | const renderActionContent = (action, index) => {
|
13949 | if (slots.action) {
|
13950 | return slots.action({
|
13951 | action,
|
13952 | index
|
13953 | });
|
13954 | }
|
13955 | return [action.icon && vue.createVNode(Icon, {
|
13956 | "name": action.icon,
|
13957 | "classPrefix": props2.iconPrefix,
|
13958 | "class": bem$s("action-icon")
|
13959 | }, null), vue.createVNode("div", {
|
13960 | "class": [bem$s("action-text"), {
|
13961 | [BORDER_BOTTOM]: props2.actionsDirection === "vertical"
|
13962 | }]
|
13963 | }, [action.text])];
|
13964 | };
|
13965 | const renderAction = (action, index) => {
|
13966 | const {
|
13967 | icon,
|
13968 | color,
|
13969 | disabled,
|
13970 | className
|
13971 | } = action;
|
13972 | return vue.createVNode("div", {
|
13973 | "role": "menuitem",
|
13974 | "class": [bem$s("action", {
|
13975 | disabled,
|
13976 | "with-icon": icon
|
13977 | }), {
|
13978 | [BORDER_RIGHT]: props2.actionsDirection === "horizontal"
|
13979 | }, className],
|
13980 | "style": {
|
13981 | color
|
13982 | },
|
13983 | "tabindex": disabled ? void 0 : 0,
|
13984 | "aria-disabled": disabled || void 0,
|
13985 | "onClick": () => onClickAction(action, index)
|
13986 | }, [renderActionContent(action, index)]);
|
13987 | };
|
13988 | vue.onMounted(() => {
|
13989 | updateLocation();
|
13990 | vue.watchEffect(() => {
|
13991 | var _a;
|
13992 | popupRef.value = (_a = popoverRef.value) == null ? void 0 : _a.popupRef.value;
|
13993 | });
|
13994 | });
|
13995 | vue.onBeforeUnmount(() => {
|
13996 | if (popper) {
|
13997 | if (inBrowser$1) {
|
13998 | window.removeEventListener("animationend", updateLocation);
|
13999 | window.removeEventListener("transitionend", updateLocation);
|
14000 | }
|
14001 | popper.destroy();
|
14002 | popper = null;
|
14003 | }
|
14004 | });
|
14005 | vue.watch(() => [show.value, props2.offset, props2.placement], updateLocation);
|
14006 | useClickAway([wrapperRef, popupRef], onClickAway, {
|
14007 | eventName: "touchstart"
|
14008 | });
|
14009 | return () => {
|
14010 | var _a;
|
14011 | return vue.createVNode(vue.Fragment, null, [vue.createVNode("span", {
|
14012 | "ref": wrapperRef,
|
14013 | "class": bem$s("wrapper"),
|
14014 | "onClick": onClickWrapper
|
14015 | }, [(_a = slots.reference) == null ? void 0 : _a.call(slots)]), vue.createVNode(Popup, vue.mergeProps({
|
14016 | "ref": popoverRef,
|
14017 | "show": show.value,
|
14018 | "class": bem$s([props2.theme]),
|
14019 | "position": "",
|
14020 | "transition": "van-popover-zoom",
|
14021 | "lockScroll": false,
|
14022 | "onUpdate:show": updateShow
|
14023 | }, attrs, useScopeId(), pick(props2, popupProps)), {
|
14024 | default: () => [props2.showArrow && vue.createVNode("div", {
|
14025 | "class": bem$s("arrow")
|
14026 | }, null), vue.createVNode("div", {
|
14027 | "role": "menu",
|
14028 | "class": bem$s("content", props2.actionsDirection)
|
14029 | }, [slots.default ? slots.default() : props2.actions.map(renderAction)])]
|
14030 | })]);
|
14031 | };
|
14032 | }
|
14033 | });
|
14034 | const Popover = withInstall(stdin_default$B);
|
14035 | const [name$s, bem$r] = createNamespace("progress");
|
14036 | const progressProps = {
|
14037 | color: String,
|
14038 | inactive: Boolean,
|
14039 | pivotText: String,
|
14040 | textColor: String,
|
14041 | showPivot: truthProp,
|
14042 | pivotColor: String,
|
14043 | trackColor: String,
|
14044 | strokeWidth: numericProp,
|
14045 | percentage: {
|
14046 | type: numericProp,
|
14047 | default: 0,
|
14048 | validator: (value) => +value >= 0 && +value <= 100
|
14049 | }
|
14050 | };
|
14051 | var stdin_default$A = vue.defineComponent({
|
14052 | name: name$s,
|
14053 | props: progressProps,
|
14054 | setup(props2) {
|
14055 | const background = vue.computed(() => props2.inactive ? void 0 : props2.color);
|
14056 | const renderPivot = () => {
|
14057 | const {
|
14058 | textColor,
|
14059 | pivotText,
|
14060 | pivotColor,
|
14061 | percentage
|
14062 | } = props2;
|
14063 | const text = pivotText != null ? pivotText : `${percentage}%`;
|
14064 | if (props2.showPivot && text) {
|
14065 | const style = {
|
14066 | color: textColor,
|
14067 | left: `${+percentage}%`,
|
14068 | transform: `translate(-${+percentage}%,-50%)`,
|
14069 | background: pivotColor || background.value
|
14070 | };
|
14071 | return vue.createVNode("span", {
|
14072 | "style": style,
|
14073 | "class": bem$r("pivot", {
|
14074 | inactive: props2.inactive
|
14075 | })
|
14076 | }, [text]);
|
14077 | }
|
14078 | };
|
14079 | return () => {
|
14080 | const {
|
14081 | trackColor,
|
14082 | percentage,
|
14083 | strokeWidth
|
14084 | } = props2;
|
14085 | const rootStyle = {
|
14086 | background: trackColor,
|
14087 | height: addUnit(strokeWidth)
|
14088 | };
|
14089 | const portionStyle = {
|
14090 | width: `${percentage}%`,
|
14091 | background: background.value
|
14092 | };
|
14093 | return vue.createVNode("div", {
|
14094 | "class": bem$r(),
|
14095 | "style": rootStyle
|
14096 | }, [vue.createVNode("span", {
|
14097 | "class": bem$r("portion", {
|
14098 | inactive: props2.inactive
|
14099 | }),
|
14100 | "style": portionStyle
|
14101 | }, null), renderPivot()]);
|
14102 | };
|
14103 | }
|
14104 | });
|
14105 | const Progress = withInstall(stdin_default$A);
|
14106 | const [name$r, bem$q, t$5] = createNamespace("pull-refresh");
|
14107 | const DEFAULT_HEAD_HEIGHT = 50;
|
14108 | const TEXT_STATUS = ["pulling", "loosing", "success"];
|
14109 | const pullRefreshProps = {
|
14110 | disabled: Boolean,
|
14111 | modelValue: Boolean,
|
14112 | headHeight: makeNumericProp(DEFAULT_HEAD_HEIGHT),
|
14113 | successText: String,
|
14114 | pullingText: String,
|
14115 | loosingText: String,
|
14116 | loadingText: String,
|
14117 | pullDistance: numericProp,
|
14118 | successDuration: makeNumericProp(500),
|
14119 | animationDuration: makeNumericProp(300)
|
14120 | };
|
14121 | var stdin_default$z = vue.defineComponent({
|
14122 | name: name$r,
|
14123 | props: pullRefreshProps,
|
14124 | emits: ["change", "refresh", "update:modelValue"],
|
14125 | setup(props2, {
|
14126 | emit,
|
14127 | slots
|
14128 | }) {
|
14129 | let reachTop;
|
14130 | const root = vue.ref();
|
14131 | const track = vue.ref();
|
14132 | const scrollParent = useScrollParent(root);
|
14133 | const state = vue.reactive({
|
14134 | status: "normal",
|
14135 | distance: 0,
|
14136 | duration: 0
|
14137 | });
|
14138 | const touch = useTouch();
|
14139 | const getHeadStyle = () => {
|
14140 | if (props2.headHeight !== DEFAULT_HEAD_HEIGHT) {
|
14141 | return {
|
14142 | height: `${props2.headHeight}px`
|
14143 | };
|
14144 | }
|
14145 | };
|
14146 | const isTouchable = () => state.status !== "loading" && state.status !== "success" && !props2.disabled;
|
14147 | const ease = (distance) => {
|
14148 | const pullDistance = +(props2.pullDistance || props2.headHeight);
|
14149 | if (distance > pullDistance) {
|
14150 | if (distance < pullDistance * 2) {
|
14151 | distance = pullDistance + (distance - pullDistance) / 2;
|
14152 | } else {
|
14153 | distance = pullDistance * 1.5 + (distance - pullDistance * 2) / 4;
|
14154 | }
|
14155 | }
|
14156 | return Math.round(distance);
|
14157 | };
|
14158 | const setStatus = (distance, isLoading) => {
|
14159 | const pullDistance = +(props2.pullDistance || props2.headHeight);
|
14160 | state.distance = distance;
|
14161 | if (isLoading) {
|
14162 | state.status = "loading";
|
14163 | } else if (distance === 0) {
|
14164 | state.status = "normal";
|
14165 | } else if (distance < pullDistance) {
|
14166 | state.status = "pulling";
|
14167 | } else {
|
14168 | state.status = "loosing";
|
14169 | }
|
14170 | emit("change", {
|
14171 | status: state.status,
|
14172 | distance
|
14173 | });
|
14174 | };
|
14175 | const getStatusText = () => {
|
14176 | const {
|
14177 | status
|
14178 | } = state;
|
14179 | if (status === "normal") {
|
14180 | return "";
|
14181 | }
|
14182 | return props2[`${status}Text`] || t$5(status);
|
14183 | };
|
14184 | const renderStatus = () => {
|
14185 | const {
|
14186 | status,
|
14187 | distance
|
14188 | } = state;
|
14189 | if (slots[status]) {
|
14190 | return slots[status]({
|
14191 | distance
|
14192 | });
|
14193 | }
|
14194 | const nodes = [];
|
14195 | if (TEXT_STATUS.includes(status)) {
|
14196 | nodes.push(vue.createVNode("div", {
|
14197 | "class": bem$q("text")
|
14198 | }, [getStatusText()]));
|
14199 | }
|
14200 | if (status === "loading") {
|
14201 | nodes.push(vue.createVNode(Loading, {
|
14202 | "class": bem$q("loading")
|
14203 | }, {
|
14204 | default: getStatusText
|
14205 | }));
|
14206 | }
|
14207 | return nodes;
|
14208 | };
|
14209 | const showSuccessTip = () => {
|
14210 | state.status = "success";
|
14211 | setTimeout(() => {
|
14212 | setStatus(0);
|
14213 | }, +props2.successDuration);
|
14214 | };
|
14215 | const checkPosition = (event) => {
|
14216 | reachTop = getScrollTop(scrollParent.value) === 0;
|
14217 | if (reachTop) {
|
14218 | state.duration = 0;
|
14219 | touch.start(event);
|
14220 | }
|
14221 | };
|
14222 | const onTouchStart = (event) => {
|
14223 | if (isTouchable()) {
|
14224 | checkPosition(event);
|
14225 | }
|
14226 | };
|
14227 | const onTouchMove = (event) => {
|
14228 | if (isTouchable()) {
|
14229 | if (!reachTop) {
|
14230 | checkPosition(event);
|
14231 | }
|
14232 | const {
|
14233 | deltaY
|
14234 | } = touch;
|
14235 | touch.move(event);
|
14236 | if (reachTop && deltaY.value >= 0 && touch.isVertical()) {
|
14237 | preventDefault(event);
|
14238 | setStatus(ease(deltaY.value));
|
14239 | }
|
14240 | }
|
14241 | };
|
14242 | const onTouchEnd = () => {
|
14243 | if (reachTop && touch.deltaY.value && isTouchable()) {
|
14244 | state.duration = +props2.animationDuration;
|
14245 | if (state.status === "loosing") {
|
14246 | setStatus(+props2.headHeight, true);
|
14247 | emit("update:modelValue", true);
|
14248 | vue.nextTick(() => emit("refresh"));
|
14249 | } else {
|
14250 | setStatus(0);
|
14251 | }
|
14252 | }
|
14253 | };
|
14254 | vue.watch(() => props2.modelValue, (value) => {
|
14255 | state.duration = +props2.animationDuration;
|
14256 | if (value) {
|
14257 | setStatus(+props2.headHeight, true);
|
14258 | } else if (slots.success || props2.successText) {
|
14259 | showSuccessTip();
|
14260 | } else {
|
14261 | setStatus(0, false);
|
14262 | }
|
14263 | });
|
14264 | useEventListener("touchmove", onTouchMove, {
|
14265 | target: track
|
14266 | });
|
14267 | return () => {
|
14268 | var _a;
|
14269 | const trackStyle = {
|
14270 | transitionDuration: `${state.duration}ms`,
|
14271 | transform: state.distance ? `translate3d(0,${state.distance}px, 0)` : ""
|
14272 | };
|
14273 | return vue.createVNode("div", {
|
14274 | "ref": root,
|
14275 | "class": bem$q()
|
14276 | }, [vue.createVNode("div", {
|
14277 | "ref": track,
|
14278 | "class": bem$q("track"),
|
14279 | "style": trackStyle,
|
14280 | "onTouchstartPassive": onTouchStart,
|
14281 | "onTouchend": onTouchEnd,
|
14282 | "onTouchcancel": onTouchEnd
|
14283 | }, [vue.createVNode("div", {
|
14284 | "class": bem$q("head"),
|
14285 | "style": getHeadStyle()
|
14286 | }, [renderStatus()]), (_a = slots.default) == null ? void 0 : _a.call(slots)])]);
|
14287 | };
|
14288 | }
|
14289 | });
|
14290 | const PullRefresh = withInstall(stdin_default$z);
|
14291 | const [name$q, bem$p] = createNamespace("rate");
|
14292 | function getRateStatus(value, index, allowHalf, readonly) {
|
14293 | if (value >= index) {
|
14294 | return {
|
14295 | status: "full",
|
14296 | value: 1
|
14297 | };
|
14298 | }
|
14299 | if (value + 0.5 >= index && allowHalf && !readonly) {
|
14300 | return {
|
14301 | status: "half",
|
14302 | value: 0.5
|
14303 | };
|
14304 | }
|
14305 | if (value + 1 >= index && allowHalf && readonly) {
|
14306 | const cardinal = 10 ** 10;
|
14307 | return {
|
14308 | status: "half",
|
14309 | value: Math.round((value - index + 1) * cardinal) / cardinal
|
14310 | };
|
14311 | }
|
14312 | return {
|
14313 | status: "void",
|
14314 | value: 0
|
14315 | };
|
14316 | }
|
14317 | const rateProps = {
|
14318 | size: numericProp,
|
14319 | icon: makeStringProp("star"),
|
14320 | color: String,
|
14321 | count: makeNumericProp(5),
|
14322 | gutter: numericProp,
|
14323 | clearable: Boolean,
|
14324 | readonly: Boolean,
|
14325 | disabled: Boolean,
|
14326 | voidIcon: makeStringProp("star-o"),
|
14327 | allowHalf: Boolean,
|
14328 | voidColor: String,
|
14329 | touchable: truthProp,
|
14330 | iconPrefix: String,
|
14331 | modelValue: makeNumberProp(0),
|
14332 | disabledColor: String
|
14333 | };
|
14334 | var stdin_default$y = vue.defineComponent({
|
14335 | name: name$q,
|
14336 | props: rateProps,
|
14337 | emits: ["change", "update:modelValue"],
|
14338 | setup(props2, {
|
14339 | emit
|
14340 | }) {
|
14341 | const touch = useTouch();
|
14342 | const [itemRefs, setItemRefs] = useRefs();
|
14343 | const groupRef = vue.ref();
|
14344 | const unselectable = vue.computed(() => props2.readonly || props2.disabled);
|
14345 | const untouchable = vue.computed(() => unselectable.value || !props2.touchable);
|
14346 | const list = vue.computed(() => Array(+props2.count).fill("").map((_, i) => getRateStatus(props2.modelValue, i + 1, props2.allowHalf, props2.readonly)));
|
14347 | let ranges;
|
14348 | let groupRefRect;
|
14349 | let minRectTop = Number.MAX_SAFE_INTEGER;
|
14350 | let maxRectTop = Number.MIN_SAFE_INTEGER;
|
14351 | const updateRanges = () => {
|
14352 | groupRefRect = useRect(groupRef);
|
14353 | const rects = itemRefs.value.map(useRect);
|
14354 | ranges = [];
|
14355 | rects.forEach((rect, index) => {
|
14356 | minRectTop = Math.min(rect.top, minRectTop);
|
14357 | maxRectTop = Math.max(rect.top, maxRectTop);
|
14358 | if (props2.allowHalf) {
|
14359 | ranges.push({
|
14360 | score: index + 0.5,
|
14361 | left: rect.left,
|
14362 | top: rect.top,
|
14363 | height: rect.height
|
14364 | }, {
|
14365 | score: index + 1,
|
14366 | left: rect.left + rect.width / 2,
|
14367 | top: rect.top,
|
14368 | height: rect.height
|
14369 | });
|
14370 | } else {
|
14371 | ranges.push({
|
14372 | score: index + 1,
|
14373 | left: rect.left,
|
14374 | top: rect.top,
|
14375 | height: rect.height
|
14376 | });
|
14377 | }
|
14378 | });
|
14379 | };
|
14380 | const getScoreByPosition = (x, y) => {
|
14381 | for (let i = ranges.length - 1; i > 0; i--) {
|
14382 | if (y >= groupRefRect.top && y <= groupRefRect.bottom) {
|
14383 | if (x > ranges[i].left && y >= ranges[i].top && y <= ranges[i].top + ranges[i].height) {
|
14384 | return ranges[i].score;
|
14385 | }
|
14386 | } else {
|
14387 | const curTop = y < groupRefRect.top ? minRectTop : maxRectTop;
|
14388 | if (x > ranges[i].left && ranges[i].top === curTop) {
|
14389 | return ranges[i].score;
|
14390 | }
|
14391 | }
|
14392 | }
|
14393 | return props2.allowHalf ? 0.5 : 1;
|
14394 | };
|
14395 | const select = (value) => {
|
14396 | if (unselectable.value || value === props2.modelValue) return;
|
14397 | emit("update:modelValue", value);
|
14398 | emit("change", value);
|
14399 | };
|
14400 | const onTouchStart = (event) => {
|
14401 | if (untouchable.value) {
|
14402 | return;
|
14403 | }
|
14404 | touch.start(event);
|
14405 | updateRanges();
|
14406 | };
|
14407 | const onTouchMove = (event) => {
|
14408 | if (untouchable.value) {
|
14409 | return;
|
14410 | }
|
14411 | touch.move(event);
|
14412 | if (touch.isHorizontal() && !touch.isTap.value) {
|
14413 | const {
|
14414 | clientX,
|
14415 | clientY
|
14416 | } = event.touches[0];
|
14417 | preventDefault(event);
|
14418 | select(getScoreByPosition(clientX, clientY));
|
14419 | }
|
14420 | };
|
14421 | const renderStar = (item, index) => {
|
14422 | const {
|
14423 | icon,
|
14424 | size,
|
14425 | color,
|
14426 | count,
|
14427 | gutter,
|
14428 | voidIcon,
|
14429 | disabled,
|
14430 | voidColor,
|
14431 | allowHalf,
|
14432 | iconPrefix,
|
14433 | disabledColor
|
14434 | } = props2;
|
14435 | const score = index + 1;
|
14436 | const isFull = item.status === "full";
|
14437 | const isVoid = item.status === "void";
|
14438 | const renderHalf = allowHalf && item.value > 0 && item.value < 1;
|
14439 | let style;
|
14440 | if (gutter && score !== +count) {
|
14441 | style = {
|
14442 | paddingRight: addUnit(gutter)
|
14443 | };
|
14444 | }
|
14445 | const onClickItem = (event) => {
|
14446 | updateRanges();
|
14447 | let value = allowHalf ? getScoreByPosition(event.clientX, event.clientY) : score;
|
14448 | if (props2.clearable && touch.isTap.value && value === props2.modelValue) {
|
14449 | value = 0;
|
14450 | }
|
14451 | select(value);
|
14452 | };
|
14453 | return vue.createVNode("div", {
|
14454 | "key": index,
|
14455 | "ref": setItemRefs(index),
|
14456 | "role": "radio",
|
14457 | "style": style,
|
14458 | "class": bem$p("item"),
|
14459 | "tabindex": disabled ? void 0 : 0,
|
14460 | "aria-setsize": count,
|
14461 | "aria-posinset": score,
|
14462 | "aria-checked": !isVoid,
|
14463 | "onClick": onClickItem
|
14464 | }, [vue.createVNode(Icon, {
|
14465 | "size": size,
|
14466 | "name": isFull ? icon : voidIcon,
|
14467 | "class": bem$p("icon", {
|
14468 | disabled,
|
14469 | full: isFull
|
14470 | }),
|
14471 | "color": disabled ? disabledColor : isFull ? color : voidColor,
|
14472 | "classPrefix": iconPrefix
|
14473 | }, null), renderHalf && vue.createVNode(Icon, {
|
14474 | "size": size,
|
14475 | "style": {
|
14476 | width: item.value + "em"
|
14477 | },
|
14478 | "name": isVoid ? voidIcon : icon,
|
14479 | "class": bem$p("icon", ["half", {
|
14480 | disabled,
|
14481 | full: !isVoid
|
14482 | }]),
|
14483 | "color": disabled ? disabledColor : isVoid ? voidColor : color,
|
14484 | "classPrefix": iconPrefix
|
14485 | }, null)]);
|
14486 | };
|
14487 | useCustomFieldValue(() => props2.modelValue);
|
14488 | useEventListener("touchmove", onTouchMove, {
|
14489 | target: groupRef
|
14490 | });
|
14491 | return () => vue.createVNode("div", {
|
14492 | "ref": groupRef,
|
14493 | "role": "radiogroup",
|
14494 | "class": bem$p({
|
14495 | readonly: props2.readonly,
|
14496 | disabled: props2.disabled
|
14497 | }),
|
14498 | "tabindex": props2.disabled ? void 0 : 0,
|
14499 | "aria-disabled": props2.disabled,
|
14500 | "aria-readonly": props2.readonly,
|
14501 | "onTouchstartPassive": onTouchStart
|
14502 | }, [list.value.map(renderStar)]);
|
14503 | }
|
14504 | });
|
14505 | const Rate = withInstall(stdin_default$y);
|
14506 | const props = {
|
14507 | figureArr: makeArrayProp(),
|
14508 | delay: Number,
|
14509 | duration: makeNumberProp(2),
|
14510 | isStart: Boolean,
|
14511 | direction: makeStringProp("down"),
|
14512 | height: makeNumberProp(40)
|
14513 | };
|
14514 | const [name$p, bem$o] = createNamespace("rolling-text-item");
|
14515 | var stdin_default$x = vue.defineComponent({
|
14516 | name: name$p,
|
14517 | props,
|
14518 | setup(props2) {
|
14519 | const newFigureArr = vue.computed(() => props2.direction === "down" ? props2.figureArr.slice().reverse() : props2.figureArr);
|
14520 | const translatePx = vue.computed(() => {
|
14521 | const totalHeight = props2.height * (props2.figureArr.length - 1);
|
14522 | return `-${totalHeight}px`;
|
14523 | });
|
14524 | const itemStyle = vue.computed(() => ({
|
14525 | lineHeight: addUnit(props2.height)
|
14526 | }));
|
14527 | const rootStyle = vue.computed(() => ({
|
14528 | height: addUnit(props2.height),
|
14529 | "--van-translate": translatePx.value,
|
14530 | "--van-duration": props2.duration + "s",
|
14531 | "--van-delay": props2.delay + "s"
|
14532 | }));
|
14533 | return () => vue.createVNode("div", {
|
14534 | "class": bem$o([props2.direction]),
|
14535 | "style": rootStyle.value
|
14536 | }, [vue.createVNode("div", {
|
14537 | "class": bem$o("box", {
|
14538 | animate: props2.isStart
|
14539 | })
|
14540 | }, [Array.isArray(newFigureArr.value) && newFigureArr.value.map((figure) => vue.createVNode("div", {
|
14541 | "class": bem$o("item"),
|
14542 | "style": itemStyle.value
|
14543 | }, [figure]))])]);
|
14544 | }
|
14545 | });
|
14546 | const [name$o, bem$n] = createNamespace("rolling-text");
|
14547 | const rollingTextProps = {
|
14548 | startNum: makeNumberProp(0),
|
14549 | targetNum: Number,
|
14550 | textList: makeArrayProp(),
|
14551 | duration: makeNumberProp(2),
|
14552 | autoStart: truthProp,
|
14553 | direction: makeStringProp("down"),
|
14554 | stopOrder: makeStringProp("ltr"),
|
14555 | height: makeNumberProp(40)
|
14556 | };
|
14557 | const CIRCLE_NUM = 2;
|
14558 | var stdin_default$w = vue.defineComponent({
|
14559 | name: name$o,
|
14560 | props: rollingTextProps,
|
14561 | setup(props2) {
|
14562 | const isCustomType = vue.computed(() => Array.isArray(props2.textList) && props2.textList.length);
|
14563 | const itemLength = vue.computed(() => {
|
14564 | if (isCustomType.value) return props2.textList[0].length;
|
14565 | return `${Math.max(props2.startNum, props2.targetNum)}`.length;
|
14566 | });
|
14567 | const getTextArrByIdx = (idx) => {
|
14568 | const result = [];
|
14569 | for (let i = 0; i < props2.textList.length; i++) {
|
14570 | result.push(props2.textList[i][idx]);
|
14571 | }
|
14572 | return result;
|
14573 | };
|
14574 | const targetNumArr = vue.computed(() => {
|
14575 | if (isCustomType.value) return new Array(itemLength.value).fill("");
|
14576 | return padZero(props2.targetNum, itemLength.value).split("");
|
14577 | });
|
14578 | const startNumArr = vue.computed(() => padZero(props2.startNum, itemLength.value).split(""));
|
14579 | const getFigureArr = (i) => {
|
14580 | const start22 = +startNumArr.value[i];
|
14581 | const target = +targetNumArr.value[i];
|
14582 | const result = [];
|
14583 | for (let i2 = start22; i2 <= 9; i2++) {
|
14584 | result.push(i2);
|
14585 | }
|
14586 | for (let i2 = 0; i2 <= CIRCLE_NUM; i2++) {
|
14587 | for (let j = 0; j <= 9; j++) {
|
14588 | result.push(j);
|
14589 | }
|
14590 | }
|
14591 | for (let i2 = 0; i2 <= target; i2++) {
|
14592 | result.push(i2);
|
14593 | }
|
14594 | return result;
|
14595 | };
|
14596 | const getDelay = (i, len) => {
|
14597 | if (props2.stopOrder === "ltr") return 0.2 * i;
|
14598 | return 0.2 * (len - 1 - i);
|
14599 | };
|
14600 | const rolling = vue.ref(props2.autoStart);
|
14601 | const start2 = () => {
|
14602 | rolling.value = true;
|
14603 | };
|
14604 | const reset = () => {
|
14605 | rolling.value = false;
|
14606 | if (props2.autoStart) {
|
14607 | raf(() => start2());
|
14608 | }
|
14609 | };
|
14610 | vue.watch(() => props2.autoStart, (value) => {
|
14611 | if (value) {
|
14612 | start2();
|
14613 | }
|
14614 | });
|
14615 | useExpose({
|
14616 | start: start2,
|
14617 | reset
|
14618 | });
|
14619 | return () => vue.createVNode("div", {
|
14620 | "class": bem$n()
|
14621 | }, [targetNumArr.value.map((_, i) => vue.createVNode(stdin_default$x, {
|
14622 | "figureArr": isCustomType.value ? getTextArrByIdx(i) : getFigureArr(i),
|
14623 | "duration": props2.duration,
|
14624 | "direction": props2.direction,
|
14625 | "isStart": rolling.value,
|
14626 | "height": props2.height,
|
14627 | "delay": getDelay(i, itemLength.value)
|
14628 | }, null))]);
|
14629 | }
|
14630 | });
|
14631 | const RollingText = withInstall(stdin_default$w);
|
14632 | const Row = withInstall(stdin_default$17);
|
14633 | const [name$n, bem$m, t$4] = createNamespace("search");
|
14634 | const searchProps = extend({}, fieldSharedProps, {
|
14635 | label: String,
|
14636 | shape: makeStringProp("square"),
|
14637 | leftIcon: makeStringProp("search"),
|
14638 | clearable: truthProp,
|
14639 | actionText: String,
|
14640 | background: String,
|
14641 | showAction: Boolean
|
14642 | });
|
14643 | var stdin_default$v = vue.defineComponent({
|
14644 | name: name$n,
|
14645 | props: searchProps,
|
14646 | emits: ["blur", "focus", "clear", "search", "cancel", "clickInput", "clickLeftIcon", "clickRightIcon", "update:modelValue"],
|
14647 | setup(props2, {
|
14648 | emit,
|
14649 | slots,
|
14650 | attrs
|
14651 | }) {
|
14652 | const id = useId();
|
14653 | const fieldRef = vue.ref();
|
14654 | const onCancel = () => {
|
14655 | if (!slots.action) {
|
14656 | emit("update:modelValue", "");
|
14657 | emit("cancel");
|
14658 | }
|
14659 | };
|
14660 | const onKeypress = (event) => {
|
14661 | const ENTER_CODE = 13;
|
14662 | if (event.keyCode === ENTER_CODE) {
|
14663 | preventDefault(event);
|
14664 | emit("search", props2.modelValue);
|
14665 | }
|
14666 | };
|
14667 | const getInputId = () => props2.id || `${id}-input`;
|
14668 | const renderLabel = () => {
|
14669 | if (slots.label || props2.label) {
|
14670 | return vue.createVNode("label", {
|
14671 | "class": bem$m("label"),
|
14672 | "for": getInputId(),
|
14673 | "data-allow-mismatch": "attribute"
|
14674 | }, [slots.label ? slots.label() : props2.label]);
|
14675 | }
|
14676 | };
|
14677 | const renderAction = () => {
|
14678 | if (props2.showAction) {
|
14679 | const text = props2.actionText || t$4("cancel");
|
14680 | return vue.createVNode("div", {
|
14681 | "class": bem$m("action"),
|
14682 | "role": "button",
|
14683 | "tabindex": 0,
|
14684 | "onClick": onCancel
|
14685 | }, [slots.action ? slots.action() : text]);
|
14686 | }
|
14687 | };
|
14688 | const blur = () => {
|
14689 | var _a;
|
14690 | return (_a = fieldRef.value) == null ? void 0 : _a.blur();
|
14691 | };
|
14692 | const focus = () => {
|
14693 | var _a;
|
14694 | return (_a = fieldRef.value) == null ? void 0 : _a.focus();
|
14695 | };
|
14696 | const onBlur = (event) => emit("blur", event);
|
14697 | const onFocus = (event) => emit("focus", event);
|
14698 | const onClear = (event) => emit("clear", event);
|
14699 | const onClickInput = (event) => emit("clickInput", event);
|
14700 | const onClickLeftIcon = (event) => emit("clickLeftIcon", event);
|
14701 | const onClickRightIcon = (event) => emit("clickRightIcon", event);
|
14702 | const fieldPropNames = Object.keys(fieldSharedProps);
|
14703 | const renderField = () => {
|
14704 | const fieldAttrs = extend({}, attrs, pick(props2, fieldPropNames), {
|
14705 | id: getInputId()
|
14706 | });
|
14707 | const onInput = (value) => emit("update:modelValue", value);
|
14708 | return vue.createVNode(Field, vue.mergeProps({
|
14709 | "ref": fieldRef,
|
14710 | "type": "search",
|
14711 | "class": bem$m("field", {
|
14712 | "with-message": fieldAttrs.errorMessage
|
14713 | }),
|
14714 | "border": false,
|
14715 | "onBlur": onBlur,
|
14716 | "onFocus": onFocus,
|
14717 | "onClear": onClear,
|
14718 | "onKeypress": onKeypress,
|
14719 | "onClickInput": onClickInput,
|
14720 | "onClickLeftIcon": onClickLeftIcon,
|
14721 | "onClickRightIcon": onClickRightIcon,
|
14722 | "onUpdate:modelValue": onInput
|
14723 | }, fieldAttrs), pick(slots, ["left-icon", "right-icon"]));
|
14724 | };
|
14725 | useExpose({
|
14726 | focus,
|
14727 | blur
|
14728 | });
|
14729 | return () => {
|
14730 | var _a;
|
14731 | return vue.createVNode("div", {
|
14732 | "class": bem$m({
|
14733 | "show-action": props2.showAction
|
14734 | }),
|
14735 | "style": {
|
14736 | background: props2.background
|
14737 | }
|
14738 | }, [(_a = slots.left) == null ? void 0 : _a.call(slots), vue.createVNode("div", {
|
14739 | "class": bem$m("content", props2.shape)
|
14740 | }, [renderLabel(), renderField()]), renderAction()]);
|
14741 | };
|
14742 | }
|
14743 | });
|
14744 | const Search = withInstall(stdin_default$v);
|
14745 | const isImage = (name2) => name2 == null ? void 0 : name2.includes("/");
|
14746 | const popupInheritKeys = [...popupSharedPropKeys, "round", "closeOnPopstate", "safeAreaInsetBottom"];
|
14747 | const iconMap = {
|
14748 | qq: "qq",
|
14749 | link: "link-o",
|
14750 | weibo: "weibo",
|
14751 | qrcode: "qr",
|
14752 | poster: "photo-o",
|
14753 | wechat: "wechat",
|
14754 | "weapp-qrcode": "miniprogram-o",
|
14755 | "wechat-moments": "wechat-moments"
|
14756 | };
|
14757 | const [name$m, bem$l, t$3] = createNamespace("share-sheet");
|
14758 | const shareSheetProps = extend({}, popupSharedProps, {
|
14759 | title: String,
|
14760 | round: truthProp,
|
14761 | options: makeArrayProp(),
|
14762 | cancelText: String,
|
14763 | description: String,
|
14764 | closeOnPopstate: truthProp,
|
14765 | safeAreaInsetBottom: truthProp
|
14766 | });
|
14767 | var stdin_default$u = vue.defineComponent({
|
14768 | name: name$m,
|
14769 | props: shareSheetProps,
|
14770 | emits: ["cancel", "select", "update:show"],
|
14771 | setup(props2, {
|
14772 | emit,
|
14773 | slots
|
14774 | }) {
|
14775 | const updateShow = (value) => emit("update:show", value);
|
14776 | const onCancel = () => {
|
14777 | updateShow(false);
|
14778 | emit("cancel");
|
14779 | };
|
14780 | const onSelect = (option, index) => emit("select", option, index);
|
14781 | const renderHeader = () => {
|
14782 | const title = slots.title ? slots.title() : props2.title;
|
14783 | const description = slots.description ? slots.description() : props2.description;
|
14784 | if (title || description) {
|
14785 | return vue.createVNode("div", {
|
14786 | "class": bem$l("header")
|
14787 | }, [title && vue.createVNode("h2", {
|
14788 | "class": bem$l("title")
|
14789 | }, [title]), description && vue.createVNode("span", {
|
14790 | "class": bem$l("description")
|
14791 | }, [description])]);
|
14792 | }
|
14793 | };
|
14794 | const renderIcon = (icon) => {
|
14795 | if (isImage(icon)) {
|
14796 | return vue.createVNode("img", {
|
14797 | "src": icon,
|
14798 | "class": bem$l("image-icon")
|
14799 | }, null);
|
14800 | }
|
14801 | return vue.createVNode("div", {
|
14802 | "class": bem$l("icon", [icon])
|
14803 | }, [vue.createVNode(Icon, {
|
14804 | "name": iconMap[icon] || icon
|
14805 | }, null)]);
|
14806 | };
|
14807 | const renderOption = (option, index) => {
|
14808 | const {
|
14809 | name: name2,
|
14810 | icon,
|
14811 | className,
|
14812 | description
|
14813 | } = option;
|
14814 | return vue.createVNode("div", {
|
14815 | "role": "button",
|
14816 | "tabindex": 0,
|
14817 | "class": [bem$l("option"), className, HAPTICS_FEEDBACK],
|
14818 | "onClick": () => onSelect(option, index)
|
14819 | }, [renderIcon(icon), name2 && vue.createVNode("span", {
|
14820 | "class": bem$l("name")
|
14821 | }, [name2]), description && vue.createVNode("span", {
|
14822 | "class": bem$l("option-description")
|
14823 | }, [description])]);
|
14824 | };
|
14825 | const renderOptions = (options, border) => vue.createVNode("div", {
|
14826 | "class": bem$l("options", {
|
14827 | border
|
14828 | })
|
14829 | }, [options.map(renderOption)]);
|
14830 | const renderRows = () => {
|
14831 | const {
|
14832 | options
|
14833 | } = props2;
|
14834 | if (Array.isArray(options[0])) {
|
14835 | return options.map((item, index) => renderOptions(item, index !== 0));
|
14836 | }
|
14837 | return renderOptions(options);
|
14838 | };
|
14839 | const renderCancelButton = () => {
|
14840 | var _a;
|
14841 | const cancelText = (_a = props2.cancelText) != null ? _a : t$3("cancel");
|
14842 | if (slots.cancel || cancelText) {
|
14843 | return vue.createVNode("button", {
|
14844 | "type": "button",
|
14845 | "class": bem$l("cancel"),
|
14846 | "onClick": onCancel
|
14847 | }, [slots.cancel ? slots.cancel() : cancelText]);
|
14848 | }
|
14849 | };
|
14850 | return () => vue.createVNode(Popup, vue.mergeProps({
|
14851 | "class": bem$l(),
|
14852 | "position": "bottom",
|
14853 | "onUpdate:show": updateShow
|
14854 | }, pick(props2, popupInheritKeys)), {
|
14855 | default: () => [renderHeader(), renderRows(), renderCancelButton()]
|
14856 | });
|
14857 | }
|
14858 | });
|
14859 | const ShareSheet = withInstall(stdin_default$u);
|
14860 | const [name$l, bem$k] = createNamespace("sidebar");
|
14861 | const SIDEBAR_KEY = Symbol(name$l);
|
14862 | const sidebarProps = {
|
14863 | modelValue: makeNumericProp(0)
|
14864 | };
|
14865 | var stdin_default$t = vue.defineComponent({
|
14866 | name: name$l,
|
14867 | props: sidebarProps,
|
14868 | emits: ["change", "update:modelValue"],
|
14869 | setup(props2, {
|
14870 | emit,
|
14871 | slots
|
14872 | }) {
|
14873 | const {
|
14874 | linkChildren
|
14875 | } = useChildren(SIDEBAR_KEY);
|
14876 | const getActive = () => +props2.modelValue;
|
14877 | const setActive = (value) => {
|
14878 | if (value !== getActive()) {
|
14879 | emit("update:modelValue", value);
|
14880 | emit("change", value);
|
14881 | }
|
14882 | };
|
14883 | linkChildren({
|
14884 | getActive,
|
14885 | setActive
|
14886 | });
|
14887 | return () => {
|
14888 | var _a;
|
14889 | return vue.createVNode("div", {
|
14890 | "role": "tablist",
|
14891 | "class": bem$k()
|
14892 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
14893 | };
|
14894 | }
|
14895 | });
|
14896 | const Sidebar = withInstall(stdin_default$t);
|
14897 | const [name$k, bem$j] = createNamespace("sidebar-item");
|
14898 | const sidebarItemProps = extend({}, routeProps, {
|
14899 | dot: Boolean,
|
14900 | title: String,
|
14901 | badge: numericProp,
|
14902 | disabled: Boolean,
|
14903 | badgeProps: Object
|
14904 | });
|
14905 | var stdin_default$s = vue.defineComponent({
|
14906 | name: name$k,
|
14907 | props: sidebarItemProps,
|
14908 | emits: ["click"],
|
14909 | setup(props2, {
|
14910 | emit,
|
14911 | slots
|
14912 | }) {
|
14913 | const route2 = useRoute();
|
14914 | const {
|
14915 | parent,
|
14916 | index
|
14917 | } = useParent(SIDEBAR_KEY);
|
14918 | if (!parent) {
|
14919 | return;
|
14920 | }
|
14921 | const onClick = () => {
|
14922 | if (props2.disabled) {
|
14923 | return;
|
14924 | }
|
14925 | emit("click", index.value);
|
14926 | parent.setActive(index.value);
|
14927 | route2();
|
14928 | };
|
14929 | return () => {
|
14930 | const {
|
14931 | dot,
|
14932 | badge,
|
14933 | title,
|
14934 | disabled
|
14935 | } = props2;
|
14936 | const selected = index.value === parent.getActive();
|
14937 | return vue.createVNode("div", {
|
14938 | "role": "tab",
|
14939 | "class": bem$j({
|
14940 | select: selected,
|
14941 | disabled
|
14942 | }),
|
14943 | "tabindex": disabled ? void 0 : 0,
|
14944 | "aria-selected": selected,
|
14945 | "onClick": onClick
|
14946 | }, [vue.createVNode(Badge, vue.mergeProps({
|
14947 | "dot": dot,
|
14948 | "class": bem$j("text"),
|
14949 | "content": badge
|
14950 | }, props2.badgeProps), {
|
14951 | default: () => [slots.title ? slots.title() : title]
|
14952 | })]);
|
14953 | };
|
14954 | }
|
14955 | });
|
14956 | const SidebarItem = withInstall(stdin_default$s);
|
14957 | const [name$j, bem$i, t$2] = createNamespace("signature");
|
14958 | const signatureProps = {
|
14959 | tips: String,
|
14960 | type: makeStringProp("png"),
|
14961 | penColor: makeStringProp("#000"),
|
14962 | lineWidth: makeNumberProp(3),
|
14963 | clearButtonText: String,
|
14964 | backgroundColor: makeStringProp(""),
|
14965 | confirmButtonText: String
|
14966 | };
|
14967 | const hasCanvasSupport = () => {
|
14968 | var _a;
|
14969 | const canvas = document.createElement("canvas");
|
14970 | return !!((_a = canvas.getContext) == null ? void 0 : _a.call(canvas, "2d"));
|
14971 | };
|
14972 | var stdin_default$r = vue.defineComponent({
|
14973 | name: name$j,
|
14974 | props: signatureProps,
|
14975 | emits: ["submit", "clear", "start", "end", "signing"],
|
14976 | setup(props2, {
|
14977 | emit
|
14978 | }) {
|
14979 | const canvasRef = vue.ref();
|
14980 | const wrapRef = vue.ref();
|
14981 | const ctx = vue.computed(() => {
|
14982 | if (!canvasRef.value) return null;
|
14983 | return canvasRef.value.getContext("2d");
|
14984 | });
|
14985 | const isRenderCanvas = inBrowser$1 ? hasCanvasSupport() : true;
|
14986 | let canvasWidth = 0;
|
14987 | let canvasHeight = 0;
|
14988 | let canvasRect;
|
14989 | const touchStart = () => {
|
14990 | if (!ctx.value) {
|
14991 | return false;
|
14992 | }
|
14993 | ctx.value.beginPath();
|
14994 | ctx.value.lineWidth = props2.lineWidth;
|
14995 | ctx.value.strokeStyle = props2.penColor;
|
14996 | canvasRect = useRect(canvasRef);
|
14997 | emit("start");
|
14998 | };
|
14999 | const touchMove = (event) => {
|
15000 | if (!ctx.value) {
|
15001 | return false;
|
15002 | }
|
15003 | preventDefault(event);
|
15004 | const touch = event.touches[0];
|
15005 | const mouseX = touch.clientX - ((canvasRect == null ? void 0 : canvasRect.left) || 0);
|
15006 | const mouseY = touch.clientY - ((canvasRect == null ? void 0 : canvasRect.top) || 0);
|
15007 | ctx.value.lineCap = "round";
|
15008 | ctx.value.lineJoin = "round";
|
15009 | ctx.value.lineTo(mouseX, mouseY);
|
15010 | ctx.value.stroke();
|
15011 | emit("signing", event);
|
15012 | };
|
15013 | const touchEnd = (event) => {
|
15014 | preventDefault(event);
|
15015 | emit("end");
|
15016 | };
|
15017 | const isCanvasEmpty = (canvas) => {
|
15018 | const empty = document.createElement("canvas");
|
15019 | empty.width = canvas.width;
|
15020 | empty.height = canvas.height;
|
15021 | if (props2.backgroundColor) {
|
15022 | const emptyCtx = empty.getContext("2d");
|
15023 | setCanvasBgColor(emptyCtx);
|
15024 | }
|
15025 | return canvas.toDataURL() === empty.toDataURL();
|
15026 | };
|
15027 | const setCanvasBgColor = (ctx2) => {
|
15028 | if (ctx2 && props2.backgroundColor) {
|
15029 | ctx2.fillStyle = props2.backgroundColor;
|
15030 | ctx2.fillRect(0, 0, canvasWidth, canvasHeight);
|
15031 | }
|
15032 | };
|
15033 | const submit = () => {
|
15034 | var _a, _b;
|
15035 | const canvas = canvasRef.value;
|
15036 | if (!canvas) {
|
15037 | return;
|
15038 | }
|
15039 | const isEmpty = isCanvasEmpty(canvas);
|
15040 | const image = isEmpty ? "" : ((_b = (_a = {
|
15041 | jpg: () => canvas.toDataURL("image/jpeg", 0.8),
|
15042 | jpeg: () => canvas.toDataURL("image/jpeg", 0.8)
|
15043 | })[props2.type]) == null ? void 0 : _b.call(_a)) || canvas.toDataURL(`image/${props2.type}`);
|
15044 | emit("submit", {
|
15045 | image,
|
15046 | canvas
|
15047 | });
|
15048 | };
|
15049 | const clear = () => {
|
15050 | if (ctx.value) {
|
15051 | ctx.value.clearRect(0, 0, canvasWidth, canvasHeight);
|
15052 | ctx.value.closePath();
|
15053 | setCanvasBgColor(ctx.value);
|
15054 | }
|
15055 | emit("clear");
|
15056 | };
|
15057 | const initialize = () => {
|
15058 | var _a, _b, _c;
|
15059 | if (isRenderCanvas && canvasRef.value) {
|
15060 | const canvas = canvasRef.value;
|
15061 | const dpr = inBrowser$1 ? window.devicePixelRatio : 1;
|
15062 | canvasWidth = canvas.width = (((_a = wrapRef.value) == null ? void 0 : _a.offsetWidth) || 0) * dpr;
|
15063 | canvasHeight = canvas.height = (((_b = wrapRef.value) == null ? void 0 : _b.offsetHeight) || 0) * dpr;
|
15064 | (_c = ctx.value) == null ? void 0 : _c.scale(dpr, dpr);
|
15065 | setCanvasBgColor(ctx.value);
|
15066 | }
|
15067 | };
|
15068 | const resize = () => {
|
15069 | if (ctx.value) {
|
15070 | const data = ctx.value.getImageData(0, 0, canvasWidth, canvasHeight);
|
15071 | initialize();
|
15072 | ctx.value.putImageData(data, 0, 0);
|
15073 | }
|
15074 | };
|
15075 | vue.watch(windowWidth, resize);
|
15076 | vue.onMounted(initialize);
|
15077 | useExpose({
|
15078 | resize,
|
15079 | clear,
|
15080 | submit
|
15081 | });
|
15082 | return () => vue.createVNode("div", {
|
15083 | "class": bem$i()
|
15084 | }, [vue.createVNode("div", {
|
15085 | "class": bem$i("content"),
|
15086 | "ref": wrapRef
|
15087 | }, [isRenderCanvas ? vue.createVNode("canvas", {
|
15088 | "ref": canvasRef,
|
15089 | "onTouchstartPassive": touchStart,
|
15090 | "onTouchmove": touchMove,
|
15091 | "onTouchend": touchEnd
|
15092 | }, null) : vue.createVNode("p", null, [props2.tips])]), vue.createVNode("div", {
|
15093 | "class": bem$i("footer")
|
15094 | }, [vue.createVNode(Button, {
|
15095 | "size": "small",
|
15096 | "onClick": clear
|
15097 | }, {
|
15098 | default: () => [props2.clearButtonText || t$2("clear")]
|
15099 | }), vue.createVNode(Button, {
|
15100 | "type": "primary",
|
15101 | "size": "small",
|
15102 | "onClick": submit
|
15103 | }, {
|
15104 | default: () => [props2.confirmButtonText || t$2("confirm")]
|
15105 | })])]);
|
15106 | }
|
15107 | });
|
15108 | const Signature = withInstall(stdin_default$r);
|
15109 | const [name$i, bem$h] = createNamespace("skeleton-title");
|
15110 | const skeletonTitleProps = {
|
15111 | round: Boolean,
|
15112 | titleWidth: numericProp
|
15113 | };
|
15114 | var stdin_default$q = vue.defineComponent({
|
15115 | name: name$i,
|
15116 | props: skeletonTitleProps,
|
15117 | setup(props2) {
|
15118 | return () => vue.createVNode("h3", {
|
15119 | "class": bem$h([{
|
15120 | round: props2.round
|
15121 | }]),
|
15122 | "style": {
|
15123 | width: addUnit(props2.titleWidth)
|
15124 | }
|
15125 | }, null);
|
15126 | }
|
15127 | });
|
15128 | const SkeletonTitle = withInstall(stdin_default$q);
|
15129 | var stdin_default$p = SkeletonTitle;
|
15130 | const [name$h, bem$g] = createNamespace("skeleton-avatar");
|
15131 | const skeletonAvatarProps = {
|
15132 | avatarSize: numericProp,
|
15133 | avatarShape: makeStringProp("round")
|
15134 | };
|
15135 | var stdin_default$o = vue.defineComponent({
|
15136 | name: name$h,
|
15137 | props: skeletonAvatarProps,
|
15138 | setup(props2) {
|
15139 | return () => vue.createVNode("div", {
|
15140 | "class": bem$g([props2.avatarShape]),
|
15141 | "style": getSizeStyle(props2.avatarSize)
|
15142 | }, null);
|
15143 | }
|
15144 | });
|
15145 | const SkeletonAvatar = withInstall(stdin_default$o);
|
15146 | var stdin_default$n = SkeletonAvatar;
|
15147 | const DEFAULT_ROW_WIDTH = "100%";
|
15148 | const skeletonParagraphProps = {
|
15149 | round: Boolean,
|
15150 | rowWidth: {
|
15151 | type: numericProp,
|
15152 | default: DEFAULT_ROW_WIDTH
|
15153 | }
|
15154 | };
|
15155 | const [name$g, bem$f] = createNamespace("skeleton-paragraph");
|
15156 | var stdin_default$m = vue.defineComponent({
|
15157 | name: name$g,
|
15158 | props: skeletonParagraphProps,
|
15159 | setup(props2) {
|
15160 | return () => vue.createVNode("div", {
|
15161 | "class": bem$f([{
|
15162 | round: props2.round
|
15163 | }]),
|
15164 | "style": {
|
15165 | width: props2.rowWidth
|
15166 | }
|
15167 | }, null);
|
15168 | }
|
15169 | });
|
15170 | const SkeletonParagraph = withInstall(stdin_default$m);
|
15171 | var stdin_default$l = SkeletonParagraph;
|
15172 | const [name$f, bem$e] = createNamespace("skeleton");
|
15173 | const DEFAULT_LAST_ROW_WIDTH = "60%";
|
15174 | const skeletonProps = {
|
15175 | row: makeNumericProp(0),
|
15176 | round: Boolean,
|
15177 | title: Boolean,
|
15178 | titleWidth: numericProp,
|
15179 | avatar: Boolean,
|
15180 | avatarSize: numericProp,
|
15181 | avatarShape: makeStringProp("round"),
|
15182 | loading: truthProp,
|
15183 | animate: truthProp,
|
15184 | rowWidth: {
|
15185 | type: [Number, String, Array],
|
15186 | default: DEFAULT_ROW_WIDTH
|
15187 | }
|
15188 | };
|
15189 | var stdin_default$k = vue.defineComponent({
|
15190 | name: name$f,
|
15191 | inheritAttrs: false,
|
15192 | props: skeletonProps,
|
15193 | setup(props2, {
|
15194 | slots,
|
15195 | attrs
|
15196 | }) {
|
15197 | const renderAvatar = () => {
|
15198 | if (props2.avatar) {
|
15199 | return vue.createVNode(stdin_default$n, {
|
15200 | "avatarShape": props2.avatarShape,
|
15201 | "avatarSize": props2.avatarSize
|
15202 | }, null);
|
15203 | }
|
15204 | };
|
15205 | const renderTitle = () => {
|
15206 | if (props2.title) {
|
15207 | return vue.createVNode(stdin_default$p, {
|
15208 | "round": props2.round,
|
15209 | "titleWidth": props2.titleWidth
|
15210 | }, null);
|
15211 | }
|
15212 | };
|
15213 | const getRowWidth = (index) => {
|
15214 | const {
|
15215 | rowWidth
|
15216 | } = props2;
|
15217 | if (rowWidth === DEFAULT_ROW_WIDTH && index === +props2.row - 1) {
|
15218 | return DEFAULT_LAST_ROW_WIDTH;
|
15219 | }
|
15220 | if (Array.isArray(rowWidth)) {
|
15221 | return rowWidth[index];
|
15222 | }
|
15223 | return rowWidth;
|
15224 | };
|
15225 | const renderRows = () => Array(+props2.row).fill("").map((_, i) => vue.createVNode(stdin_default$l, {
|
15226 | "key": i,
|
15227 | "round": props2.round,
|
15228 | "rowWidth": addUnit(getRowWidth(i))
|
15229 | }, null));
|
15230 | const renderContents = () => {
|
15231 | if (slots.template) {
|
15232 | return slots.template();
|
15233 | }
|
15234 | return vue.createVNode(vue.Fragment, null, [renderAvatar(), vue.createVNode("div", {
|
15235 | "class": bem$e("content")
|
15236 | }, [renderTitle(), renderRows()])]);
|
15237 | };
|
15238 | return () => {
|
15239 | var _a;
|
15240 | if (!props2.loading) {
|
15241 | return (_a = slots.default) == null ? void 0 : _a.call(slots);
|
15242 | }
|
15243 | return vue.createVNode("div", vue.mergeProps({
|
15244 | "class": bem$e({
|
15245 | animate: props2.animate,
|
15246 | round: props2.round
|
15247 | })
|
15248 | }, attrs), [renderContents()]);
|
15249 | };
|
15250 | }
|
15251 | });
|
15252 | const Skeleton = withInstall(stdin_default$k);
|
15253 | const [name$e, bem$d] = createNamespace("skeleton-image");
|
15254 | const skeletonImageProps = {
|
15255 | imageSize: numericProp,
|
15256 | imageShape: makeStringProp("square")
|
15257 | };
|
15258 | var stdin_default$j = vue.defineComponent({
|
15259 | name: name$e,
|
15260 | props: skeletonImageProps,
|
15261 | setup(props2) {
|
15262 | return () => vue.createVNode("div", {
|
15263 | "class": bem$d([props2.imageShape]),
|
15264 | "style": getSizeStyle(props2.imageSize)
|
15265 | }, [vue.createVNode(Icon, {
|
15266 | "name": "photo",
|
15267 | "class": bem$d("icon")
|
15268 | }, null)]);
|
15269 | }
|
15270 | });
|
15271 | const SkeletonImage = withInstall(stdin_default$j);
|
15272 | const [name$d, bem$c] = createNamespace("slider");
|
15273 | const sliderProps = {
|
15274 | min: makeNumericProp(0),
|
15275 | max: makeNumericProp(100),
|
15276 | step: makeNumericProp(1),
|
15277 | range: Boolean,
|
15278 | reverse: Boolean,
|
15279 | disabled: Boolean,
|
15280 | readonly: Boolean,
|
15281 | vertical: Boolean,
|
15282 | barHeight: numericProp,
|
15283 | buttonSize: numericProp,
|
15284 | activeColor: String,
|
15285 | inactiveColor: String,
|
15286 | modelValue: {
|
15287 | type: [Number, Array],
|
15288 | default: 0
|
15289 | }
|
15290 | };
|
15291 | var stdin_default$i = vue.defineComponent({
|
15292 | name: name$d,
|
15293 | props: sliderProps,
|
15294 | emits: ["change", "dragEnd", "dragStart", "update:modelValue"],
|
15295 | setup(props2, {
|
15296 | emit,
|
15297 | slots
|
15298 | }) {
|
15299 | let buttonIndex;
|
15300 | let current2;
|
15301 | let startValue;
|
15302 | const root = vue.ref();
|
15303 | const slider = [vue.ref(), vue.ref()];
|
15304 | const dragStatus = vue.ref();
|
15305 | const touch = useTouch();
|
15306 | const scope = vue.computed(() => Number(props2.max) - Number(props2.min));
|
15307 | const wrapperStyle = vue.computed(() => {
|
15308 | const crossAxis = props2.vertical ? "width" : "height";
|
15309 | return {
|
15310 | background: props2.inactiveColor,
|
15311 | [crossAxis]: addUnit(props2.barHeight)
|
15312 | };
|
15313 | });
|
15314 | const isRange = (val) => props2.range && Array.isArray(val);
|
15315 | const calcMainAxis = () => {
|
15316 | const {
|
15317 | modelValue,
|
15318 | min
|
15319 | } = props2;
|
15320 | if (isRange(modelValue)) {
|
15321 | return `${(modelValue[1] - modelValue[0]) * 100 / scope.value}%`;
|
15322 | }
|
15323 | return `${(modelValue - Number(min)) * 100 / scope.value}%`;
|
15324 | };
|
15325 | const calcOffset = () => {
|
15326 | const {
|
15327 | modelValue,
|
15328 | min
|
15329 | } = props2;
|
15330 | if (isRange(modelValue)) {
|
15331 | return `${(modelValue[0] - Number(min)) * 100 / scope.value}%`;
|
15332 | }
|
15333 | return "0%";
|
15334 | };
|
15335 | const barStyle = vue.computed(() => {
|
15336 | const mainAxis = props2.vertical ? "height" : "width";
|
15337 | const style = {
|
15338 | [mainAxis]: calcMainAxis(),
|
15339 | background: props2.activeColor
|
15340 | };
|
15341 | if (dragStatus.value) {
|
15342 | style.transition = "none";
|
15343 | }
|
15344 | const getPositionKey = () => {
|
15345 | if (props2.vertical) {
|
15346 | return props2.reverse ? "bottom" : "top";
|
15347 | }
|
15348 | return props2.reverse ? "right" : "left";
|
15349 | };
|
15350 | style[getPositionKey()] = calcOffset();
|
15351 | return style;
|
15352 | });
|
15353 | const format2 = (value) => {
|
15354 | const min = +props2.min;
|
15355 | const max = +props2.max;
|
15356 | const step = +props2.step;
|
15357 | value = clamp(value, min, max);
|
15358 | const diff = Math.round((value - min) / step) * step;
|
15359 | return addNumber(min, diff);
|
15360 | };
|
15361 | const updateStartValue = () => {
|
15362 | const current22 = props2.modelValue;
|
15363 | if (isRange(current22)) {
|
15364 | startValue = current22.map(format2);
|
15365 | } else {
|
15366 | startValue = format2(current22);
|
15367 | }
|
15368 | };
|
15369 | const handleRangeValue = (value) => {
|
15370 | var _a, _b;
|
15371 | const left2 = (_a = value[0]) != null ? _a : Number(props2.min);
|
15372 | const right2 = (_b = value[1]) != null ? _b : Number(props2.max);
|
15373 | return left2 > right2 ? [right2, left2] : [left2, right2];
|
15374 | };
|
15375 | const updateValue = (value, end2) => {
|
15376 | if (isRange(value)) {
|
15377 | value = handleRangeValue(value).map(format2);
|
15378 | } else {
|
15379 | value = format2(value);
|
15380 | }
|
15381 | if (!isSameValue(value, props2.modelValue)) {
|
15382 | emit("update:modelValue", value);
|
15383 | }
|
15384 | if (end2 && !isSameValue(value, startValue)) {
|
15385 | emit("change", value);
|
15386 | }
|
15387 | };
|
15388 | const onClick = (event) => {
|
15389 | event.stopPropagation();
|
15390 | if (props2.disabled || props2.readonly) {
|
15391 | return;
|
15392 | }
|
15393 | updateStartValue();
|
15394 | const {
|
15395 | min,
|
15396 | reverse,
|
15397 | vertical,
|
15398 | modelValue
|
15399 | } = props2;
|
15400 | const rect = useRect(root);
|
15401 | const getDelta = () => {
|
15402 | if (vertical) {
|
15403 | if (reverse) {
|
15404 | return rect.bottom - event.clientY;
|
15405 | }
|
15406 | return event.clientY - rect.top;
|
15407 | }
|
15408 | if (reverse) {
|
15409 | return rect.right - event.clientX;
|
15410 | }
|
15411 | return event.clientX - rect.left;
|
15412 | };
|
15413 | const total = vertical ? rect.height : rect.width;
|
15414 | const value = Number(min) + getDelta() / total * scope.value;
|
15415 | if (isRange(modelValue)) {
|
15416 | const [left2, right2] = modelValue;
|
15417 | const middle = (left2 + right2) / 2;
|
15418 | if (value <= middle) {
|
15419 | updateValue([value, right2], true);
|
15420 | } else {
|
15421 | updateValue([left2, value], true);
|
15422 | }
|
15423 | } else {
|
15424 | updateValue(value, true);
|
15425 | }
|
15426 | };
|
15427 | const onTouchStart = (event) => {
|
15428 | if (props2.disabled || props2.readonly) {
|
15429 | return;
|
15430 | }
|
15431 | touch.start(event);
|
15432 | current2 = props2.modelValue;
|
15433 | updateStartValue();
|
15434 | dragStatus.value = "start";
|
15435 | };
|
15436 | const onTouchMove = (event) => {
|
15437 | if (props2.disabled || props2.readonly) {
|
15438 | return;
|
15439 | }
|
15440 | if (dragStatus.value === "start") {
|
15441 | emit("dragStart", event);
|
15442 | }
|
15443 | preventDefault(event, true);
|
15444 | touch.move(event);
|
15445 | dragStatus.value = "dragging";
|
15446 | const rect = useRect(root);
|
15447 | const delta = props2.vertical ? touch.deltaY.value : touch.deltaX.value;
|
15448 | const total = props2.vertical ? rect.height : rect.width;
|
15449 | let diff = delta / total * scope.value;
|
15450 | if (props2.reverse) {
|
15451 | diff = -diff;
|
15452 | }
|
15453 | if (isRange(startValue)) {
|
15454 | const index = props2.reverse ? 1 - buttonIndex : buttonIndex;
|
15455 | current2[index] = startValue[index] + diff;
|
15456 | } else {
|
15457 | current2 = startValue + diff;
|
15458 | }
|
15459 | updateValue(current2);
|
15460 | };
|
15461 | const onTouchEnd = (event) => {
|
15462 | if (props2.disabled || props2.readonly) {
|
15463 | return;
|
15464 | }
|
15465 | if (dragStatus.value === "dragging") {
|
15466 | updateValue(current2, true);
|
15467 | emit("dragEnd", event);
|
15468 | }
|
15469 | dragStatus.value = "";
|
15470 | };
|
15471 | const getButtonClassName = (index) => {
|
15472 | if (typeof index === "number") {
|
15473 | const position = ["left", "right"];
|
15474 | return bem$c(`button-wrapper`, position[index]);
|
15475 | }
|
15476 | return bem$c("button-wrapper", props2.reverse ? "left" : "right");
|
15477 | };
|
15478 | const renderButtonContent = (value, index) => {
|
15479 | const dragging = dragStatus.value === "dragging";
|
15480 | if (typeof index === "number") {
|
15481 | const slot = slots[index === 0 ? "left-button" : "right-button"];
|
15482 | let dragIndex;
|
15483 | if (dragging && Array.isArray(current2)) {
|
15484 | dragIndex = current2[0] > current2[1] ? buttonIndex ^ 1 : buttonIndex;
|
15485 | }
|
15486 | if (slot) {
|
15487 | return slot({
|
15488 | value,
|
15489 | dragging,
|
15490 | dragIndex
|
15491 | });
|
15492 | }
|
15493 | }
|
15494 | if (slots.button) {
|
15495 | return slots.button({
|
15496 | value,
|
15497 | dragging
|
15498 | });
|
15499 | }
|
15500 | return vue.createVNode("div", {
|
15501 | "class": bem$c("button"),
|
15502 | "style": getSizeStyle(props2.buttonSize)
|
15503 | }, null);
|
15504 | };
|
15505 | const renderButton = (index) => {
|
15506 | const current22 = typeof index === "number" ? props2.modelValue[index] : props2.modelValue;
|
15507 | return vue.createVNode("div", {
|
15508 | "ref": slider[index != null ? index : 0],
|
15509 | "role": "slider",
|
15510 | "class": getButtonClassName(index),
|
15511 | "tabindex": props2.disabled ? void 0 : 0,
|
15512 | "aria-valuemin": props2.min,
|
15513 | "aria-valuenow": current22,
|
15514 | "aria-valuemax": props2.max,
|
15515 | "aria-disabled": props2.disabled || void 0,
|
15516 | "aria-readonly": props2.readonly || void 0,
|
15517 | "aria-orientation": props2.vertical ? "vertical" : "horizontal",
|
15518 | "onTouchstartPassive": (event) => {
|
15519 | if (typeof index === "number") {
|
15520 | buttonIndex = index;
|
15521 | }
|
15522 | onTouchStart(event);
|
15523 | },
|
15524 | "onTouchend": onTouchEnd,
|
15525 | "onTouchcancel": onTouchEnd,
|
15526 | "onClick": stopPropagation
|
15527 | }, [renderButtonContent(current22, index)]);
|
15528 | };
|
15529 | updateValue(props2.modelValue);
|
15530 | useCustomFieldValue(() => props2.modelValue);
|
15531 | slider.forEach((item) => {
|
15532 | useEventListener("touchmove", onTouchMove, {
|
15533 | target: item
|
15534 | });
|
15535 | });
|
15536 | return () => vue.createVNode("div", {
|
15537 | "ref": root,
|
15538 | "style": wrapperStyle.value,
|
15539 | "class": bem$c({
|
15540 | vertical: props2.vertical,
|
15541 | disabled: props2.disabled
|
15542 | }),
|
15543 | "onClick": onClick
|
15544 | }, [vue.createVNode("div", {
|
15545 | "class": bem$c("bar"),
|
15546 | "style": barStyle.value
|
15547 | }, [props2.range ? [renderButton(0), renderButton(1)] : renderButton()])]);
|
15548 | }
|
15549 | });
|
15550 | const Slider = withInstall(stdin_default$i);
|
15551 | const [name$c, bem$b] = createNamespace("space");
|
15552 | const spaceProps = {
|
15553 | align: String,
|
15554 | direction: {
|
15555 | type: String,
|
15556 | default: "horizontal"
|
15557 | },
|
15558 | size: {
|
15559 | type: [Number, String, Array],
|
15560 | default: 8
|
15561 | },
|
15562 | wrap: Boolean,
|
15563 | fill: Boolean
|
15564 | };
|
15565 | function filterEmpty(children = []) {
|
15566 | const nodes = [];
|
15567 | children.forEach((child) => {
|
15568 | if (Array.isArray(child)) {
|
15569 | nodes.push(...child);
|
15570 | } else if (child.type === vue.Fragment) {
|
15571 | nodes.push(...filterEmpty(child.children));
|
15572 | } else {
|
15573 | nodes.push(child);
|
15574 | }
|
15575 | });
|
15576 | return nodes.filter((c) => {
|
15577 | var _a;
|
15578 | return !(c && (c.type === vue.Comment || c.type === vue.Fragment && ((_a = c.children) == null ? void 0 : _a.length) === 0 || c.type === vue.Text && c.children.trim() === ""));
|
15579 | });
|
15580 | }
|
15581 | var stdin_default$h = vue.defineComponent({
|
15582 | name: name$c,
|
15583 | props: spaceProps,
|
15584 | setup(props2, {
|
15585 | slots
|
15586 | }) {
|
15587 | const mergedAlign = vue.computed(() => {
|
15588 | var _a;
|
15589 | return (_a = props2.align) != null ? _a : props2.direction === "horizontal" ? "center" : "";
|
15590 | });
|
15591 | const getMargin = (size) => {
|
15592 | if (typeof size === "number") {
|
15593 | return size + "px";
|
15594 | }
|
15595 | return size;
|
15596 | };
|
15597 | const getMarginStyle = (isLast) => {
|
15598 | const style = {};
|
15599 | const marginRight = `${getMargin(Array.isArray(props2.size) ? props2.size[0] : props2.size)}`;
|
15600 | const marginBottom = `${getMargin(Array.isArray(props2.size) ? props2.size[1] : props2.size)}`;
|
15601 | if (isLast) {
|
15602 | return props2.wrap ? {
|
15603 | marginBottom
|
15604 | } : {};
|
15605 | }
|
15606 | if (props2.direction === "horizontal") {
|
15607 | style.marginRight = marginRight;
|
15608 | }
|
15609 | if (props2.direction === "vertical" || props2.wrap) {
|
15610 | style.marginBottom = marginBottom;
|
15611 | }
|
15612 | return style;
|
15613 | };
|
15614 | return () => {
|
15615 | var _a;
|
15616 | const children = filterEmpty((_a = slots.default) == null ? void 0 : _a.call(slots));
|
15617 | return vue.createVNode("div", {
|
15618 | "class": [bem$b({
|
15619 | [props2.direction]: props2.direction,
|
15620 | [`align-${mergedAlign.value}`]: mergedAlign.value,
|
15621 | wrap: props2.wrap,
|
15622 | fill: props2.fill
|
15623 | })]
|
15624 | }, [children.map((c, i) => vue.createVNode("div", {
|
15625 | "key": `item-${i}`,
|
15626 | "class": `${name$c}-item`,
|
15627 | "style": getMarginStyle(i === children.length - 1)
|
15628 | }, [c]))]);
|
15629 | };
|
15630 | }
|
15631 | });
|
15632 | const Space = withInstall(stdin_default$h);
|
15633 | const [name$b, bem$a] = createNamespace("steps");
|
15634 | const stepsProps = {
|
15635 | active: makeNumericProp(0),
|
15636 | direction: makeStringProp("horizontal"),
|
15637 | activeIcon: makeStringProp("checked"),
|
15638 | iconPrefix: String,
|
15639 | finishIcon: String,
|
15640 | activeColor: String,
|
15641 | inactiveIcon: String,
|
15642 | inactiveColor: String
|
15643 | };
|
15644 | const STEPS_KEY = Symbol(name$b);
|
15645 | var stdin_default$g = vue.defineComponent({
|
15646 | name: name$b,
|
15647 | props: stepsProps,
|
15648 | emits: ["clickStep"],
|
15649 | setup(props2, {
|
15650 | emit,
|
15651 | slots
|
15652 | }) {
|
15653 | const {
|
15654 | linkChildren
|
15655 | } = useChildren(STEPS_KEY);
|
15656 | const onClickStep = (index) => emit("clickStep", index);
|
15657 | linkChildren({
|
15658 | props: props2,
|
15659 | onClickStep
|
15660 | });
|
15661 | return () => {
|
15662 | var _a;
|
15663 | return vue.createVNode("div", {
|
15664 | "class": bem$a([props2.direction])
|
15665 | }, [vue.createVNode("div", {
|
15666 | "class": bem$a("items")
|
15667 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
|
15668 | };
|
15669 | }
|
15670 | });
|
15671 | const [name$a, bem$9] = createNamespace("step");
|
15672 | var stdin_default$f = vue.defineComponent({
|
15673 | name: name$a,
|
15674 | setup(props2, {
|
15675 | slots
|
15676 | }) {
|
15677 | const {
|
15678 | parent,
|
15679 | index
|
15680 | } = useParent(STEPS_KEY);
|
15681 | if (!parent) {
|
15682 | return;
|
15683 | }
|
15684 | const parentProps = parent.props;
|
15685 | const getStatus = () => {
|
15686 | const active = +parentProps.active;
|
15687 | if (index.value < active) {
|
15688 | return "finish";
|
15689 | }
|
15690 | return index.value === active ? "process" : "waiting";
|
15691 | };
|
15692 | const isActive = () => getStatus() === "process";
|
15693 | const lineStyle = vue.computed(() => ({
|
15694 | background: getStatus() === "finish" ? parentProps.activeColor : parentProps.inactiveColor
|
15695 | }));
|
15696 | const titleStyle = vue.computed(() => {
|
15697 | if (isActive()) {
|
15698 | return {
|
15699 | color: parentProps.activeColor
|
15700 | };
|
15701 | }
|
15702 | if (getStatus() === "waiting") {
|
15703 | return {
|
15704 | color: parentProps.inactiveColor
|
15705 | };
|
15706 | }
|
15707 | });
|
15708 | const onClickStep = () => parent.onClickStep(index.value);
|
15709 | const renderCircle = () => {
|
15710 | const {
|
15711 | iconPrefix,
|
15712 | finishIcon,
|
15713 | activeIcon,
|
15714 | activeColor,
|
15715 | inactiveIcon
|
15716 | } = parentProps;
|
15717 | if (isActive()) {
|
15718 | if (slots["active-icon"]) {
|
15719 | return slots["active-icon"]();
|
15720 | }
|
15721 | return vue.createVNode(Icon, {
|
15722 | "class": bem$9("icon", "active"),
|
15723 | "name": activeIcon,
|
15724 | "color": activeColor,
|
15725 | "classPrefix": iconPrefix
|
15726 | }, null);
|
15727 | }
|
15728 | if (getStatus() === "finish" && (finishIcon || slots["finish-icon"])) {
|
15729 | if (slots["finish-icon"]) {
|
15730 | return slots["finish-icon"]();
|
15731 | }
|
15732 | return vue.createVNode(Icon, {
|
15733 | "class": bem$9("icon", "finish"),
|
15734 | "name": finishIcon,
|
15735 | "color": activeColor,
|
15736 | "classPrefix": iconPrefix
|
15737 | }, null);
|
15738 | }
|
15739 | if (slots["inactive-icon"]) {
|
15740 | return slots["inactive-icon"]();
|
15741 | }
|
15742 | if (inactiveIcon) {
|
15743 | return vue.createVNode(Icon, {
|
15744 | "class": bem$9("icon"),
|
15745 | "name": inactiveIcon,
|
15746 | "classPrefix": iconPrefix
|
15747 | }, null);
|
15748 | }
|
15749 | return vue.createVNode("i", {
|
15750 | "class": bem$9("circle"),
|
15751 | "style": lineStyle.value
|
15752 | }, null);
|
15753 | };
|
15754 | return () => {
|
15755 | var _a;
|
15756 | const status = getStatus();
|
15757 | return vue.createVNode("div", {
|
15758 | "class": [BORDER, bem$9([parentProps.direction, {
|
15759 | [status]: status
|
15760 | }])]
|
15761 | }, [vue.createVNode("div", {
|
15762 | "class": bem$9("title", {
|
15763 | active: isActive()
|
15764 | }),
|
15765 | "style": titleStyle.value,
|
15766 | "onClick": onClickStep
|
15767 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), vue.createVNode("div", {
|
15768 | "class": bem$9("circle-container"),
|
15769 | "onClick": onClickStep
|
15770 | }, [renderCircle()]), vue.createVNode("div", {
|
15771 | "class": bem$9("line"),
|
15772 | "style": lineStyle.value
|
15773 | }, null)]);
|
15774 | };
|
15775 | }
|
15776 | });
|
15777 | const Step = withInstall(stdin_default$f);
|
15778 | const [name$9, bem$8] = createNamespace("stepper");
|
15779 | const LONG_PRESS_INTERVAL = 200;
|
15780 | const isEqual = (value1, value2) => String(value1) === String(value2);
|
15781 | const stepperProps = {
|
15782 | min: makeNumericProp(1),
|
15783 | max: makeNumericProp(Infinity),
|
15784 | name: makeNumericProp(""),
|
15785 | step: makeNumericProp(1),
|
15786 | theme: String,
|
15787 | integer: Boolean,
|
15788 | disabled: Boolean,
|
15789 | showPlus: truthProp,
|
15790 | showMinus: truthProp,
|
15791 | showInput: truthProp,
|
15792 | longPress: truthProp,
|
15793 | autoFixed: truthProp,
|
15794 | allowEmpty: Boolean,
|
15795 | modelValue: numericProp,
|
15796 | inputWidth: numericProp,
|
15797 | buttonSize: numericProp,
|
15798 | placeholder: String,
|
15799 | disablePlus: Boolean,
|
15800 | disableMinus: Boolean,
|
15801 | disableInput: Boolean,
|
15802 | beforeChange: Function,
|
15803 | defaultValue: makeNumericProp(1),
|
15804 | decimalLength: numericProp
|
15805 | };
|
15806 | var stdin_default$e = vue.defineComponent({
|
15807 | name: name$9,
|
15808 | props: stepperProps,
|
15809 | emits: ["plus", "blur", "minus", "focus", "change", "overlimit", "update:modelValue"],
|
15810 | setup(props2, {
|
15811 | emit
|
15812 | }) {
|
15813 | const format2 = (value, autoFixed = true) => {
|
15814 | const {
|
15815 | min,
|
15816 | max,
|
15817 | allowEmpty,
|
15818 | decimalLength
|
15819 | } = props2;
|
15820 | if (allowEmpty && value === "") {
|
15821 | return value;
|
15822 | }
|
15823 | value = formatNumber(String(value), !props2.integer);
|
15824 | value = value === "" ? 0 : +value;
|
15825 | value = Number.isNaN(value) ? +min : value;
|
15826 | value = autoFixed ? Math.max(Math.min(+max, value), +min) : value;
|
15827 | if (isDef(decimalLength)) {
|
15828 | value = value.toFixed(+decimalLength);
|
15829 | }
|
15830 | return value;
|
15831 | };
|
15832 | const getInitialValue = () => {
|
15833 | var _a;
|
15834 | const defaultValue = (_a = props2.modelValue) != null ? _a : props2.defaultValue;
|
15835 | const value = format2(defaultValue);
|
15836 | if (!isEqual(value, props2.modelValue)) {
|
15837 | emit("update:modelValue", value);
|
15838 | }
|
15839 | return value;
|
15840 | };
|
15841 | let actionType;
|
15842 | const inputRef = vue.ref();
|
15843 | const current2 = vue.ref(getInitialValue());
|
15844 | const minusDisabled = vue.computed(() => props2.disabled || props2.disableMinus || +current2.value <= +props2.min);
|
15845 | const plusDisabled = vue.computed(() => props2.disabled || props2.disablePlus || +current2.value >= +props2.max);
|
15846 | const inputStyle = vue.computed(() => ({
|
15847 | width: addUnit(props2.inputWidth),
|
15848 | height: addUnit(props2.buttonSize)
|
15849 | }));
|
15850 | const buttonStyle = vue.computed(() => getSizeStyle(props2.buttonSize));
|
15851 | const check = () => {
|
15852 | const value = format2(current2.value);
|
15853 | if (!isEqual(value, current2.value)) {
|
15854 | current2.value = value;
|
15855 | }
|
15856 | };
|
15857 | const setValue = (value) => {
|
15858 | if (props2.beforeChange) {
|
15859 | callInterceptor(props2.beforeChange, {
|
15860 | args: [value],
|
15861 | done() {
|
15862 | current2.value = value;
|
15863 | }
|
15864 | });
|
15865 | } else {
|
15866 | current2.value = value;
|
15867 | }
|
15868 | };
|
15869 | const onChange = () => {
|
15870 | if (actionType === "plus" && plusDisabled.value || actionType === "minus" && minusDisabled.value) {
|
15871 | emit("overlimit", actionType);
|
15872 | return;
|
15873 | }
|
15874 | const diff = actionType === "minus" ? -props2.step : +props2.step;
|
15875 | const value = format2(addNumber(+current2.value, diff));
|
15876 | setValue(value);
|
15877 | emit(actionType);
|
15878 | };
|
15879 | const onInput = (event) => {
|
15880 | const input = event.target;
|
15881 | const {
|
15882 | value
|
15883 | } = input;
|
15884 | const {
|
15885 | decimalLength
|
15886 | } = props2;
|
15887 | let formatted = formatNumber(String(value), !props2.integer);
|
15888 | if (isDef(decimalLength) && formatted.includes(".")) {
|
15889 | const pair = formatted.split(".");
|
15890 | formatted = `${pair[0]}.${pair[1].slice(0, +decimalLength)}`;
|
15891 | }
|
15892 | if (props2.beforeChange) {
|
15893 | input.value = String(current2.value);
|
15894 | } else if (!isEqual(value, formatted)) {
|
15895 | input.value = formatted;
|
15896 | }
|
15897 | const isNumeric2 = formatted === String(+formatted);
|
15898 | setValue(isNumeric2 ? +formatted : formatted);
|
15899 | };
|
15900 | const onFocus = (event) => {
|
15901 | var _a;
|
15902 | if (props2.disableInput) {
|
15903 | (_a = inputRef.value) == null ? void 0 : _a.blur();
|
15904 | } else {
|
15905 | emit("focus", event);
|
15906 | }
|
15907 | };
|
15908 | const onBlur = (event) => {
|
15909 | const input = event.target;
|
15910 | const value = format2(input.value, props2.autoFixed);
|
15911 | input.value = String(value);
|
15912 | current2.value = value;
|
15913 | vue.nextTick(() => {
|
15914 | emit("blur", event);
|
15915 | resetScroll();
|
15916 | });
|
15917 | };
|
15918 | let isLongPress;
|
15919 | let longPressTimer;
|
15920 | const longPressStep = () => {
|
15921 | longPressTimer = setTimeout(() => {
|
15922 | onChange();
|
15923 | longPressStep();
|
15924 | }, LONG_PRESS_INTERVAL);
|
15925 | };
|
15926 | const onTouchStart = () => {
|
15927 | if (props2.longPress) {
|
15928 | isLongPress = false;
|
15929 | clearTimeout(longPressTimer);
|
15930 | longPressTimer = setTimeout(() => {
|
15931 | isLongPress = true;
|
15932 | onChange();
|
15933 | longPressStep();
|
15934 | }, LONG_PRESS_START_TIME);
|
15935 | }
|
15936 | };
|
15937 | const onTouchEnd = (event) => {
|
15938 | if (props2.longPress) {
|
15939 | clearTimeout(longPressTimer);
|
15940 | if (isLongPress) {
|
15941 | preventDefault(event);
|
15942 | }
|
15943 | }
|
15944 | };
|
15945 | const onMousedown = (event) => {
|
15946 | if (props2.disableInput) {
|
15947 | preventDefault(event);
|
15948 | }
|
15949 | };
|
15950 | const createListeners = (type) => ({
|
15951 | onClick: (event) => {
|
15952 | preventDefault(event);
|
15953 | actionType = type;
|
15954 | onChange();
|
15955 | },
|
15956 | onTouchstartPassive: () => {
|
15957 | actionType = type;
|
15958 | onTouchStart();
|
15959 | },
|
15960 | onTouchend: onTouchEnd,
|
15961 | onTouchcancel: onTouchEnd
|
15962 | });
|
15963 | vue.watch(() => [props2.max, props2.min, props2.integer, props2.decimalLength], check);
|
15964 | vue.watch(() => props2.modelValue, (value) => {
|
15965 | if (!isEqual(value, current2.value)) {
|
15966 | current2.value = format2(value);
|
15967 | }
|
15968 | });
|
15969 | vue.watch(current2, (value) => {
|
15970 | emit("update:modelValue", value);
|
15971 | emit("change", value, {
|
15972 | name: props2.name
|
15973 | });
|
15974 | });
|
15975 | useCustomFieldValue(() => props2.modelValue);
|
15976 | return () => vue.createVNode("div", {
|
15977 | "role": "group",
|
15978 | "class": bem$8([props2.theme])
|
15979 | }, [vue.withDirectives(vue.createVNode("button", vue.mergeProps({
|
15980 | "type": "button",
|
15981 | "style": buttonStyle.value,
|
15982 | "class": [bem$8("minus", {
|
15983 | disabled: minusDisabled.value
|
15984 | }), {
|
15985 | [HAPTICS_FEEDBACK]: !minusDisabled.value
|
15986 | }],
|
15987 | "aria-disabled": minusDisabled.value || void 0
|
15988 | }, createListeners("minus")), null), [[vue.vShow, props2.showMinus]]), vue.withDirectives(vue.createVNode("input", {
|
15989 | "ref": inputRef,
|
15990 | "type": props2.integer ? "tel" : "text",
|
15991 | "role": "spinbutton",
|
15992 | "class": bem$8("input"),
|
15993 | "value": current2.value,
|
15994 | "style": inputStyle.value,
|
15995 | "disabled": props2.disabled,
|
15996 | "readonly": props2.disableInput,
|
15997 | "inputmode": props2.integer ? "numeric" : "decimal",
|
15998 | "placeholder": props2.placeholder,
|
15999 | "autocomplete": "off",
|
16000 | "aria-valuemax": props2.max,
|
16001 | "aria-valuemin": props2.min,
|
16002 | "aria-valuenow": current2.value,
|
16003 | "onBlur": onBlur,
|
16004 | "onInput": onInput,
|
16005 | "onFocus": onFocus,
|
16006 | "onMousedown": onMousedown
|
16007 | }, null), [[vue.vShow, props2.showInput]]), vue.withDirectives(vue.createVNode("button", vue.mergeProps({
|
16008 | "type": "button",
|
16009 | "style": buttonStyle.value,
|
16010 | "class": [bem$8("plus", {
|
16011 | disabled: plusDisabled.value
|
16012 | }), {
|
16013 | [HAPTICS_FEEDBACK]: !plusDisabled.value
|
16014 | }],
|
16015 | "aria-disabled": plusDisabled.value || void 0
|
16016 | }, createListeners("plus")), null), [[vue.vShow, props2.showPlus]])]);
|
16017 | }
|
16018 | });
|
16019 | const Stepper = withInstall(stdin_default$e);
|
16020 | const Steps = withInstall(stdin_default$g);
|
16021 | const [name$8, bem$7, t$1] = createNamespace("submit-bar");
|
16022 | const submitBarProps = {
|
16023 | tip: String,
|
16024 | label: String,
|
16025 | price: Number,
|
16026 | tipIcon: String,
|
16027 | loading: Boolean,
|
16028 | currency: makeStringProp("¥"),
|
16029 | disabled: Boolean,
|
16030 | textAlign: String,
|
16031 | buttonText: String,
|
16032 | buttonType: makeStringProp("danger"),
|
16033 | buttonColor: String,
|
16034 | suffixLabel: String,
|
16035 | placeholder: Boolean,
|
16036 | decimalLength: makeNumericProp(2),
|
16037 | safeAreaInsetBottom: truthProp
|
16038 | };
|
16039 | var stdin_default$d = vue.defineComponent({
|
16040 | name: name$8,
|
16041 | props: submitBarProps,
|
16042 | emits: ["submit"],
|
16043 | setup(props2, {
|
16044 | emit,
|
16045 | slots
|
16046 | }) {
|
16047 | const root = vue.ref();
|
16048 | const renderPlaceholder = usePlaceholder(root, bem$7);
|
16049 | const renderText = () => {
|
16050 | const {
|
16051 | price,
|
16052 | label,
|
16053 | currency,
|
16054 | textAlign,
|
16055 | suffixLabel,
|
16056 | decimalLength
|
16057 | } = props2;
|
16058 | if (typeof price === "number") {
|
16059 | const pricePair = (price / 100).toFixed(+decimalLength).split(".");
|
16060 | const decimal = decimalLength ? `.${pricePair[1]}` : "";
|
16061 | return vue.createVNode("div", {
|
16062 | "class": bem$7("text"),
|
16063 | "style": {
|
16064 | textAlign
|
16065 | }
|
16066 | }, [vue.createVNode("span", null, [label || t$1("label")]), vue.createVNode("span", {
|
16067 | "class": bem$7("price")
|
16068 | }, [currency, vue.createVNode("span", {
|
16069 | "class": bem$7("price-integer")
|
16070 | }, [pricePair[0]]), decimal]), suffixLabel && vue.createVNode("span", {
|
16071 | "class": bem$7("suffix-label")
|
16072 | }, [suffixLabel])]);
|
16073 | }
|
16074 | };
|
16075 | const renderTip = () => {
|
16076 | var _a;
|
16077 | const {
|
16078 | tip,
|
16079 | tipIcon
|
16080 | } = props2;
|
16081 | if (slots.tip || tip) {
|
16082 | return vue.createVNode("div", {
|
16083 | "class": bem$7("tip")
|
16084 | }, [tipIcon && vue.createVNode(Icon, {
|
16085 | "class": bem$7("tip-icon"),
|
16086 | "name": tipIcon
|
16087 | }, null), tip && vue.createVNode("span", {
|
16088 | "class": bem$7("tip-text")
|
16089 | }, [tip]), (_a = slots.tip) == null ? void 0 : _a.call(slots)]);
|
16090 | }
|
16091 | };
|
16092 | const onClickButton = () => emit("submit");
|
16093 | const renderButton = () => {
|
16094 | if (slots.button) {
|
16095 | return slots.button();
|
16096 | }
|
16097 | return vue.createVNode(Button, {
|
16098 | "round": true,
|
16099 | "type": props2.buttonType,
|
16100 | "text": props2.buttonText,
|
16101 | "class": bem$7("button", props2.buttonType),
|
16102 | "color": props2.buttonColor,
|
16103 | "loading": props2.loading,
|
16104 | "disabled": props2.disabled,
|
16105 | "onClick": onClickButton
|
16106 | }, null);
|
16107 | };
|
16108 | const renderSubmitBar = () => {
|
16109 | var _a, _b;
|
16110 | return vue.createVNode("div", {
|
16111 | "ref": root,
|
16112 | "class": [bem$7(), {
|
16113 | "van-safe-area-bottom": props2.safeAreaInsetBottom
|
16114 | }]
|
16115 | }, [(_a = slots.top) == null ? void 0 : _a.call(slots), renderTip(), vue.createVNode("div", {
|
16116 | "class": bem$7("bar")
|
16117 | }, [(_b = slots.default) == null ? void 0 : _b.call(slots), renderText(), renderButton()])]);
|
16118 | };
|
16119 | return () => {
|
16120 | if (props2.placeholder) {
|
16121 | return renderPlaceholder(renderSubmitBar);
|
16122 | }
|
16123 | return renderSubmitBar();
|
16124 | };
|
16125 | }
|
16126 | });
|
16127 | const SubmitBar = withInstall(stdin_default$d);
|
16128 | const [name$7, bem$6] = createNamespace("swipe-cell");
|
16129 | const swipeCellProps = {
|
16130 | name: makeNumericProp(""),
|
16131 | disabled: Boolean,
|
16132 | leftWidth: numericProp,
|
16133 | rightWidth: numericProp,
|
16134 | beforeClose: Function,
|
16135 | stopPropagation: Boolean
|
16136 | };
|
16137 | var stdin_default$c = vue.defineComponent({
|
16138 | name: name$7,
|
16139 | props: swipeCellProps,
|
16140 | emits: ["open", "close", "click"],
|
16141 | setup(props2, {
|
16142 | emit,
|
16143 | slots
|
16144 | }) {
|
16145 | let opened;
|
16146 | let lockClick2;
|
16147 | let startOffset;
|
16148 | let isInBeforeClosing;
|
16149 | const root = vue.ref();
|
16150 | const leftRef = vue.ref();
|
16151 | const rightRef = vue.ref();
|
16152 | const state = vue.reactive({
|
16153 | offset: 0,
|
16154 | dragging: false
|
16155 | });
|
16156 | const touch = useTouch();
|
16157 | const getWidthByRef = (ref2) => ref2.value ? useRect(ref2).width : 0;
|
16158 | const leftWidth = vue.computed(() => isDef(props2.leftWidth) ? +props2.leftWidth : getWidthByRef(leftRef));
|
16159 | const rightWidth = vue.computed(() => isDef(props2.rightWidth) ? +props2.rightWidth : getWidthByRef(rightRef));
|
16160 | const open = (side) => {
|
16161 | state.offset = side === "left" ? leftWidth.value : -rightWidth.value;
|
16162 | if (!opened) {
|
16163 | opened = true;
|
16164 | emit("open", {
|
16165 | name: props2.name,
|
16166 | position: side
|
16167 | });
|
16168 | }
|
16169 | };
|
16170 | const close = (position) => {
|
16171 | state.offset = 0;
|
16172 | if (opened) {
|
16173 | opened = false;
|
16174 | emit("close", {
|
16175 | name: props2.name,
|
16176 | position
|
16177 | });
|
16178 | }
|
16179 | };
|
16180 | const toggle = (side) => {
|
16181 | const offset2 = Math.abs(state.offset);
|
16182 | const THRESHOLD = 0.15;
|
16183 | const threshold = opened ? 1 - THRESHOLD : THRESHOLD;
|
16184 | const width2 = side === "left" ? leftWidth.value : rightWidth.value;
|
16185 | if (width2 && offset2 > width2 * threshold) {
|
16186 | open(side);
|
16187 | } else {
|
16188 | close(side);
|
16189 | }
|
16190 | };
|
16191 | const onTouchStart = (event) => {
|
16192 | if (!props2.disabled) {
|
16193 | startOffset = state.offset;
|
16194 | touch.start(event);
|
16195 | }
|
16196 | };
|
16197 | const onTouchMove = (event) => {
|
16198 | if (props2.disabled) {
|
16199 | return;
|
16200 | }
|
16201 | const {
|
16202 | deltaX
|
16203 | } = touch;
|
16204 | touch.move(event);
|
16205 | if (touch.isHorizontal()) {
|
16206 | lockClick2 = true;
|
16207 | state.dragging = true;
|
16208 | const isEdge = !opened || deltaX.value * startOffset < 0;
|
16209 | if (isEdge) {
|
16210 | preventDefault(event, props2.stopPropagation);
|
16211 | }
|
16212 | state.offset = clamp(deltaX.value + startOffset, -rightWidth.value, leftWidth.value);
|
16213 | }
|
16214 | };
|
16215 | const onTouchEnd = () => {
|
16216 | if (state.dragging) {
|
16217 | state.dragging = false;
|
16218 | toggle(state.offset > 0 ? "left" : "right");
|
16219 | setTimeout(() => {
|
16220 | lockClick2 = false;
|
16221 | }, 0);
|
16222 | }
|
16223 | };
|
16224 | const onClick = (position = "outside", event) => {
|
16225 | if (isInBeforeClosing) return;
|
16226 | emit("click", position);
|
16227 | if (opened && !lockClick2) {
|
16228 | isInBeforeClosing = true;
|
16229 | callInterceptor(props2.beforeClose, {
|
16230 | args: [{
|
16231 | event,
|
16232 | name: props2.name,
|
16233 | position
|
16234 | }],
|
16235 | done: () => {
|
16236 | isInBeforeClosing = false;
|
16237 | close(position);
|
16238 | },
|
16239 | canceled: () => isInBeforeClosing = false,
|
16240 | error: () => isInBeforeClosing = false
|
16241 | });
|
16242 | }
|
16243 | };
|
16244 | const getClickHandler = (position, stop) => (event) => {
|
16245 | if (stop) {
|
16246 | event.stopPropagation();
|
16247 | }
|
16248 | if (lockClick2) {
|
16249 | return;
|
16250 | }
|
16251 | onClick(position, event);
|
16252 | };
|
16253 | const renderSideContent = (side, ref2) => {
|
16254 | const contentSlot = slots[side];
|
16255 | if (contentSlot) {
|
16256 | return vue.createVNode("div", {
|
16257 | "ref": ref2,
|
16258 | "class": bem$6(side),
|
16259 | "onClick": getClickHandler(side, true)
|
16260 | }, [contentSlot()]);
|
16261 | }
|
16262 | };
|
16263 | useExpose({
|
16264 | open,
|
16265 | close
|
16266 | });
|
16267 | useClickAway(root, (event) => onClick("outside", event), {
|
16268 | eventName: "touchstart"
|
16269 | });
|
16270 | useEventListener("touchmove", onTouchMove, {
|
16271 | target: root
|
16272 | });
|
16273 | return () => {
|
16274 | var _a;
|
16275 | const wrapperStyle = {
|
16276 | transform: `translate3d(${state.offset}px, 0, 0)`,
|
16277 | transitionDuration: state.dragging ? "0s" : ".6s"
|
16278 | };
|
16279 | return vue.createVNode("div", {
|
16280 | "ref": root,
|
16281 | "class": bem$6(),
|
16282 | "onClick": getClickHandler("cell", lockClick2),
|
16283 | "onTouchstartPassive": onTouchStart,
|
16284 | "onTouchend": onTouchEnd,
|
16285 | "onTouchcancel": onTouchEnd
|
16286 | }, [vue.createVNode("div", {
|
16287 | "class": bem$6("wrapper"),
|
16288 | "style": wrapperStyle
|
16289 | }, [renderSideContent("left", leftRef), (_a = slots.default) == null ? void 0 : _a.call(slots), renderSideContent("right", rightRef)])]);
|
16290 | };
|
16291 | }
|
16292 | });
|
16293 | const SwipeCell = withInstall(stdin_default$c);
|
16294 | const [name$6, bem$5] = createNamespace("tabbar");
|
16295 | const tabbarProps = {
|
16296 | route: Boolean,
|
16297 | fixed: truthProp,
|
16298 | border: truthProp,
|
16299 | zIndex: numericProp,
|
16300 | placeholder: Boolean,
|
16301 | activeColor: String,
|
16302 | beforeChange: Function,
|
16303 | inactiveColor: String,
|
16304 | modelValue: makeNumericProp(0),
|
16305 | safeAreaInsetBottom: {
|
16306 | type: Boolean,
|
16307 | default: null
|
16308 | }
|
16309 | };
|
16310 | const TABBAR_KEY = Symbol(name$6);
|
16311 | var stdin_default$b = vue.defineComponent({
|
16312 | name: name$6,
|
16313 | props: tabbarProps,
|
16314 | emits: ["change", "update:modelValue"],
|
16315 | setup(props2, {
|
16316 | emit,
|
16317 | slots
|
16318 | }) {
|
16319 | const root = vue.ref();
|
16320 | const {
|
16321 | linkChildren
|
16322 | } = useChildren(TABBAR_KEY);
|
16323 | const renderPlaceholder = usePlaceholder(root, bem$5);
|
16324 | const enableSafeArea = () => {
|
16325 | var _a;
|
16326 | return (_a = props2.safeAreaInsetBottom) != null ? _a : props2.fixed;
|
16327 | };
|
16328 | const renderTabbar = () => {
|
16329 | var _a;
|
16330 | const {
|
16331 | fixed,
|
16332 | zIndex,
|
16333 | border
|
16334 | } = props2;
|
16335 | return vue.createVNode("div", {
|
16336 | "ref": root,
|
16337 | "role": "tablist",
|
16338 | "style": getZIndexStyle(zIndex),
|
16339 | "class": [bem$5({
|
16340 | fixed
|
16341 | }), {
|
16342 | [BORDER_TOP_BOTTOM]: border,
|
16343 | "van-safe-area-bottom": enableSafeArea()
|
16344 | }]
|
16345 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
16346 | };
|
16347 | const setActive = (active, afterChange) => {
|
16348 | callInterceptor(props2.beforeChange, {
|
16349 | args: [active],
|
16350 | done() {
|
16351 | emit("update:modelValue", active);
|
16352 | emit("change", active);
|
16353 | afterChange();
|
16354 | }
|
16355 | });
|
16356 | };
|
16357 | linkChildren({
|
16358 | props: props2,
|
16359 | setActive
|
16360 | });
|
16361 | return () => {
|
16362 | if (props2.fixed && props2.placeholder) {
|
16363 | return renderPlaceholder(renderTabbar);
|
16364 | }
|
16365 | return renderTabbar();
|
16366 | };
|
16367 | }
|
16368 | });
|
16369 | const Tabbar = withInstall(stdin_default$b);
|
16370 | const [name$5, bem$4] = createNamespace("tabbar-item");
|
16371 | const tabbarItemProps = extend({}, routeProps, {
|
16372 | dot: Boolean,
|
16373 | icon: String,
|
16374 | name: numericProp,
|
16375 | badge: numericProp,
|
16376 | badgeProps: Object,
|
16377 | iconPrefix: String
|
16378 | });
|
16379 | var stdin_default$a = vue.defineComponent({
|
16380 | name: name$5,
|
16381 | props: tabbarItemProps,
|
16382 | emits: ["click"],
|
16383 | setup(props2, {
|
16384 | emit,
|
16385 | slots
|
16386 | }) {
|
16387 | const route2 = useRoute();
|
16388 | const vm = vue.getCurrentInstance().proxy;
|
16389 | const {
|
16390 | parent,
|
16391 | index
|
16392 | } = useParent(TABBAR_KEY);
|
16393 | if (!parent) {
|
16394 | return;
|
16395 | }
|
16396 | const active = vue.computed(() => {
|
16397 | var _a;
|
16398 | const {
|
16399 | route: route22,
|
16400 | modelValue
|
16401 | } = parent.props;
|
16402 | if (route22 && "$route" in vm) {
|
16403 | const {
|
16404 | $route
|
16405 | } = vm;
|
16406 | const {
|
16407 | to
|
16408 | } = props2;
|
16409 | const config = isObject$1(to) ? to : {
|
16410 | path: to
|
16411 | };
|
16412 | return !!$route.matched.find((val) => {
|
16413 | const pathMatched = "path" in config && config.path === val.path;
|
16414 | const nameMatched = "name" in config && config.name === val.name;
|
16415 | return pathMatched || nameMatched;
|
16416 | });
|
16417 | }
|
16418 | return ((_a = props2.name) != null ? _a : index.value) === modelValue;
|
16419 | });
|
16420 | const onClick = (event) => {
|
16421 | var _a;
|
16422 | if (!active.value) {
|
16423 | parent.setActive((_a = props2.name) != null ? _a : index.value, route2);
|
16424 | }
|
16425 | emit("click", event);
|
16426 | };
|
16427 | const renderIcon = () => {
|
16428 | if (slots.icon) {
|
16429 | return slots.icon({
|
16430 | active: active.value
|
16431 | });
|
16432 | }
|
16433 | if (props2.icon) {
|
16434 | return vue.createVNode(Icon, {
|
16435 | "name": props2.icon,
|
16436 | "classPrefix": props2.iconPrefix
|
16437 | }, null);
|
16438 | }
|
16439 | };
|
16440 | return () => {
|
16441 | var _a;
|
16442 | const {
|
16443 | dot,
|
16444 | badge
|
16445 | } = props2;
|
16446 | const {
|
16447 | activeColor,
|
16448 | inactiveColor
|
16449 | } = parent.props;
|
16450 | const color = active.value ? activeColor : inactiveColor;
|
16451 | return vue.createVNode("div", {
|
16452 | "role": "tab",
|
16453 | "class": bem$4({
|
16454 | active: active.value
|
16455 | }),
|
16456 | "style": {
|
16457 | color
|
16458 | },
|
16459 | "tabindex": 0,
|
16460 | "aria-selected": active.value,
|
16461 | "onClick": onClick
|
16462 | }, [vue.createVNode(Badge, vue.mergeProps({
|
16463 | "dot": dot,
|
16464 | "class": bem$4("icon"),
|
16465 | "content": badge
|
16466 | }, props2.badgeProps), {
|
16467 | default: renderIcon
|
16468 | }), vue.createVNode("div", {
|
16469 | "class": bem$4("text")
|
16470 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots, {
|
16471 | active: active.value
|
16472 | })])]);
|
16473 | };
|
16474 | }
|
16475 | });
|
16476 | const TabbarItem = withInstall(stdin_default$a);
|
16477 | const [name$4, bem$3] = createNamespace("text-ellipsis");
|
16478 | const textEllipsisProps = {
|
16479 | rows: makeNumericProp(1),
|
16480 | dots: makeStringProp("..."),
|
16481 | content: makeStringProp(""),
|
16482 | expandText: makeStringProp(""),
|
16483 | collapseText: makeStringProp(""),
|
16484 | position: makeStringProp("end")
|
16485 | };
|
16486 | var stdin_default$9 = vue.defineComponent({
|
16487 | name: name$4,
|
16488 | props: textEllipsisProps,
|
16489 | emits: ["clickAction"],
|
16490 | setup(props2, {
|
16491 | emit,
|
16492 | slots
|
16493 | }) {
|
16494 | const text = vue.ref(props2.content);
|
16495 | const expanded = vue.ref(false);
|
16496 | const hasAction = vue.ref(false);
|
16497 | const root = vue.ref();
|
16498 | const actionRef = vue.ref();
|
16499 | let needRecalculate = false;
|
16500 | const actionText = vue.computed(() => expanded.value ? props2.collapseText : props2.expandText);
|
16501 | const pxToNum = (value) => {
|
16502 | if (!value) return 0;
|
16503 | const match = value.match(/^\d*(\.\d*)?/);
|
16504 | return match ? Number(match[0]) : 0;
|
16505 | };
|
16506 | const cloneContainer = () => {
|
16507 | if (!root.value || !root.value.isConnected) return;
|
16508 | const originStyle = window.getComputedStyle(root.value);
|
16509 | const container = document.createElement("div");
|
16510 | const styleNames = Array.prototype.slice.apply(originStyle);
|
16511 | styleNames.forEach((name2) => {
|
16512 | container.style.setProperty(name2, originStyle.getPropertyValue(name2));
|
16513 | });
|
16514 | container.style.position = "fixed";
|
16515 | container.style.zIndex = "-9999";
|
16516 | container.style.top = "-9999px";
|
16517 | container.style.height = "auto";
|
16518 | container.style.minHeight = "auto";
|
16519 | container.style.maxHeight = "auto";
|
16520 | container.innerText = props2.content;
|
16521 | document.body.appendChild(container);
|
16522 | return container;
|
16523 | };
|
16524 | const calcEllipsisText = (container, maxHeight) => {
|
16525 | var _a, _b;
|
16526 | const {
|
16527 | content,
|
16528 | position,
|
16529 | dots
|
16530 | } = props2;
|
16531 | const end2 = content.length;
|
16532 | const middle = 0 + end2 >> 1;
|
16533 | const actionHTML = slots.action ? (_b = (_a = actionRef.value) == null ? void 0 : _a.outerHTML) != null ? _b : "" : props2.expandText;
|
16534 | const calcEllipse = () => {
|
16535 | const tail = (left2, right2) => {
|
16536 | if (right2 - left2 <= 1) {
|
16537 | if (position === "end") {
|
16538 | return content.slice(0, left2) + dots;
|
16539 | }
|
16540 | return dots + content.slice(right2, end2);
|
16541 | }
|
16542 | const middle2 = Math.round((left2 + right2) / 2);
|
16543 | if (position === "end") {
|
16544 | container.innerText = content.slice(0, middle2) + dots;
|
16545 | } else {
|
16546 | container.innerText = dots + content.slice(middle2, end2);
|
16547 | }
|
16548 | container.innerHTML += actionHTML;
|
16549 | if (container.offsetHeight > maxHeight) {
|
16550 | if (position === "end") {
|
16551 | return tail(left2, middle2);
|
16552 | }
|
16553 | return tail(middle2, right2);
|
16554 | }
|
16555 | if (position === "end") {
|
16556 | return tail(middle2, right2);
|
16557 | }
|
16558 | return tail(left2, middle2);
|
16559 | };
|
16560 | return tail(0, end2);
|
16561 | };
|
16562 | const middleTail = (leftPart, rightPart) => {
|
16563 | if (leftPart[1] - leftPart[0] <= 1 && rightPart[1] - rightPart[0] <= 1) {
|
16564 | return content.slice(0, leftPart[0]) + dots + content.slice(rightPart[1], end2);
|
16565 | }
|
16566 | const leftMiddle = Math.floor((leftPart[0] + leftPart[1]) / 2);
|
16567 | const rightMiddle = Math.ceil((rightPart[0] + rightPart[1]) / 2);
|
16568 | container.innerText = props2.content.slice(0, leftMiddle) + props2.dots + props2.content.slice(rightMiddle, end2);
|
16569 | container.innerHTML += actionHTML;
|
16570 | if (container.offsetHeight >= maxHeight) {
|
16571 | return middleTail([leftPart[0], leftMiddle], [rightMiddle, rightPart[1]]);
|
16572 | }
|
16573 | return middleTail([leftMiddle, leftPart[1]], [rightPart[0], rightMiddle]);
|
16574 | };
|
16575 | return props2.position === "middle" ? middleTail([0, middle], [middle, end2]) : calcEllipse();
|
16576 | };
|
16577 | const calcEllipsised = () => {
|
16578 | const container = cloneContainer();
|
16579 | if (!container) {
|
16580 | needRecalculate = true;
|
16581 | return;
|
16582 | }
|
16583 | const {
|
16584 | paddingBottom,
|
16585 | paddingTop,
|
16586 | lineHeight
|
16587 | } = container.style;
|
16588 | const maxHeight = Math.ceil((Number(props2.rows) + 0.5) * pxToNum(lineHeight) + pxToNum(paddingTop) + pxToNum(paddingBottom));
|
16589 | if (maxHeight < container.offsetHeight) {
|
16590 | hasAction.value = true;
|
16591 | text.value = calcEllipsisText(container, maxHeight);
|
16592 | } else {
|
16593 | hasAction.value = false;
|
16594 | text.value = props2.content;
|
16595 | }
|
16596 | document.body.removeChild(container);
|
16597 | };
|
16598 | const toggle = (isExpanded = !expanded.value) => {
|
16599 | expanded.value = isExpanded;
|
16600 | };
|
16601 | const onClickAction = (event) => {
|
16602 | toggle();
|
16603 | emit("clickAction", event);
|
16604 | };
|
16605 | const renderAction = () => {
|
16606 | const action = slots.action ? slots.action({
|
16607 | expanded: expanded.value
|
16608 | }) : actionText.value;
|
16609 | return vue.createVNode("span", {
|
16610 | "ref": actionRef,
|
16611 | "class": bem$3("action"),
|
16612 | "onClick": onClickAction
|
16613 | }, [action]);
|
16614 | };
|
16615 | vue.onMounted(() => {
|
16616 | calcEllipsised();
|
16617 | if (slots.action) {
|
16618 | vue.nextTick(calcEllipsised);
|
16619 | }
|
16620 | });
|
16621 | vue.onActivated(() => {
|
16622 | if (needRecalculate) {
|
16623 | needRecalculate = false;
|
16624 | calcEllipsised();
|
16625 | }
|
16626 | });
|
16627 | vue.watch([windowWidth, () => [props2.content, props2.rows, props2.position]], calcEllipsised);
|
16628 | useExpose({
|
16629 | toggle
|
16630 | });
|
16631 | return () => vue.createVNode("div", {
|
16632 | "ref": root,
|
16633 | "class": bem$3()
|
16634 | }, [expanded.value ? props2.content : text.value, hasAction.value ? renderAction() : null]);
|
16635 | }
|
16636 | });
|
16637 | const TextEllipsis = withInstall(stdin_default$9);
|
16638 | const [name$3] = createNamespace("time-picker");
|
16639 | const validateTime = (val) => /^([01]\d|2[0-3]):([0-5]\d):([0-5]\d)$/.test(val);
|
16640 | const fullColumns = ["hour", "minute", "second"];
|
16641 | const timePickerProps = extend({}, sharedProps, {
|
16642 | minHour: makeNumericProp(0),
|
16643 | maxHour: makeNumericProp(23),
|
16644 | minMinute: makeNumericProp(0),
|
16645 | maxMinute: makeNumericProp(59),
|
16646 | minSecond: makeNumericProp(0),
|
16647 | maxSecond: makeNumericProp(59),
|
16648 | minTime: {
|
16649 | type: String,
|
16650 | validator: validateTime
|
16651 | },
|
16652 | maxTime: {
|
16653 | type: String,
|
16654 | validator: validateTime
|
16655 | },
|
16656 | columnsType: {
|
16657 | type: Array,
|
16658 | default: () => ["hour", "minute"]
|
16659 | }
|
16660 | });
|
16661 | var stdin_default$8 = vue.defineComponent({
|
16662 | name: name$3,
|
16663 | props: timePickerProps,
|
16664 | emits: ["confirm", "cancel", "change", "update:modelValue"],
|
16665 | setup(props2, {
|
16666 | emit,
|
16667 | slots
|
16668 | }) {
|
16669 | const currentValues = vue.ref(props2.modelValue);
|
16670 | const pickerRef = vue.ref();
|
16671 | const getValidTime = (time) => {
|
16672 | const timeLimitArr = time.split(":");
|
16673 | return fullColumns.map((col, i) => props2.columnsType.includes(col) ? timeLimitArr[i] : "00");
|
16674 | };
|
16675 | const confirm = () => {
|
16676 | var _a;
|
16677 | return (_a = pickerRef.value) == null ? void 0 : _a.confirm();
|
16678 | };
|
16679 | const getSelectedTime = () => currentValues.value;
|
16680 | const columns = vue.computed(() => {
|
16681 | let {
|
16682 | minHour,
|
16683 | maxHour,
|
16684 | minMinute,
|
16685 | maxMinute,
|
16686 | minSecond,
|
16687 | maxSecond
|
16688 | } = props2;
|
16689 | if (props2.minTime || props2.maxTime) {
|
16690 | const fullTime = {
|
16691 | hour: 0,
|
16692 | minute: 0,
|
16693 | second: 0
|
16694 | };
|
16695 | props2.columnsType.forEach((col, i) => {
|
16696 | var _a;
|
16697 | fullTime[col] = (_a = currentValues.value[i]) != null ? _a : 0;
|
16698 | });
|
16699 | const {
|
16700 | hour,
|
16701 | minute
|
16702 | } = fullTime;
|
16703 | if (props2.minTime) {
|
16704 | const [minH, minM, minS] = getValidTime(props2.minTime);
|
16705 | minHour = minH;
|
16706 | minMinute = +hour <= +minHour ? minM : "00";
|
16707 | minSecond = +hour <= +minHour && +minute <= +minMinute ? minS : "00";
|
16708 | }
|
16709 | if (props2.maxTime) {
|
16710 | const [maxH, maxM, maxS] = getValidTime(props2.maxTime);
|
16711 | maxHour = maxH;
|
16712 | maxMinute = +hour >= +maxHour ? maxM : "59";
|
16713 | maxSecond = +hour >= +maxHour && +minute >= +maxMinute ? maxS : "59";
|
16714 | }
|
16715 | }
|
16716 | return props2.columnsType.map((type) => {
|
16717 | const {
|
16718 | filter,
|
16719 | formatter
|
16720 | } = props2;
|
16721 | switch (type) {
|
16722 | case "hour":
|
16723 | return genOptions(+minHour, +maxHour, type, formatter, filter, currentValues.value);
|
16724 | case "minute":
|
16725 | return genOptions(+minMinute, +maxMinute, type, formatter, filter, currentValues.value);
|
16726 | case "second":
|
16727 | return genOptions(+minSecond, +maxSecond, type, formatter, filter, currentValues.value);
|
16728 | default:
|
16729 | return [];
|
16730 | }
|
16731 | });
|
16732 | });
|
16733 | vue.watch(currentValues, (newValues) => {
|
16734 | if (!isSameValue(newValues, props2.modelValue)) {
|
16735 | emit("update:modelValue", newValues);
|
16736 | }
|
16737 | });
|
16738 | vue.watch(() => props2.modelValue, (newValues) => {
|
16739 | newValues = formatValueRange(newValues, columns.value);
|
16740 | if (!isSameValue(newValues, currentValues.value)) {
|
16741 | currentValues.value = newValues;
|
16742 | }
|
16743 | }, {
|
16744 | immediate: true
|
16745 | });
|
16746 | const onChange = (...args) => emit("change", ...args);
|
16747 | const onCancel = (...args) => emit("cancel", ...args);
|
16748 | const onConfirm = (...args) => emit("confirm", ...args);
|
16749 | useExpose({
|
16750 | confirm,
|
16751 | getSelectedTime
|
16752 | });
|
16753 | return () => vue.createVNode(Picker, vue.mergeProps({
|
16754 | "ref": pickerRef,
|
16755 | "modelValue": currentValues.value,
|
16756 | "onUpdate:modelValue": ($event) => currentValues.value = $event,
|
16757 | "columns": columns.value,
|
16758 | "onChange": onChange,
|
16759 | "onCancel": onCancel,
|
16760 | "onConfirm": onConfirm
|
16761 | }, pick(props2, pickerInheritKeys)), slots);
|
16762 | }
|
16763 | });
|
16764 | const TimePicker = withInstall(stdin_default$8);
|
16765 | const [name$2, bem$2] = createNamespace("tree-select");
|
16766 | const treeSelectProps = {
|
16767 | max: makeNumericProp(Infinity),
|
16768 | items: makeArrayProp(),
|
16769 | height: makeNumericProp(300),
|
16770 | selectedIcon: makeStringProp("success"),
|
16771 | mainActiveIndex: makeNumericProp(0),
|
16772 | activeId: {
|
16773 | type: [Number, String, Array],
|
16774 | default: 0
|
16775 | }
|
16776 | };
|
16777 | var stdin_default$7 = vue.defineComponent({
|
16778 | name: name$2,
|
16779 | props: treeSelectProps,
|
16780 | emits: ["clickNav", "clickItem", "update:activeId", "update:mainActiveIndex"],
|
16781 | setup(props2, {
|
16782 | emit,
|
16783 | slots
|
16784 | }) {
|
16785 | const isActiveItem = (id) => Array.isArray(props2.activeId) ? props2.activeId.includes(id) : props2.activeId === id;
|
16786 | const renderSubItem = (item) => {
|
16787 | const onClick = () => {
|
16788 | if (item.disabled) {
|
16789 | return;
|
16790 | }
|
16791 | let activeId;
|
16792 | if (Array.isArray(props2.activeId)) {
|
16793 | activeId = props2.activeId.slice();
|
16794 | const index = activeId.indexOf(item.id);
|
16795 | if (index !== -1) {
|
16796 | activeId.splice(index, 1);
|
16797 | } else if (activeId.length < +props2.max) {
|
16798 | activeId.push(item.id);
|
16799 | }
|
16800 | } else {
|
16801 | activeId = item.id;
|
16802 | }
|
16803 | emit("update:activeId", activeId);
|
16804 | emit("clickItem", item);
|
16805 | };
|
16806 | return vue.createVNode("div", {
|
16807 | "key": item.id,
|
16808 | "class": ["van-ellipsis", bem$2("item", {
|
16809 | active: isActiveItem(item.id),
|
16810 | disabled: item.disabled
|
16811 | })],
|
16812 | "onClick": onClick
|
16813 | }, [item.text, isActiveItem(item.id) && vue.createVNode(Icon, {
|
16814 | "name": props2.selectedIcon,
|
16815 | "class": bem$2("selected")
|
16816 | }, null)]);
|
16817 | };
|
16818 | const onSidebarChange = (index) => {
|
16819 | emit("update:mainActiveIndex", index);
|
16820 | };
|
16821 | const onClickSidebarItem = (index) => emit("clickNav", index);
|
16822 | const renderSidebar = () => {
|
16823 | const Items = props2.items.map((item) => vue.createVNode(SidebarItem, {
|
16824 | "dot": item.dot,
|
16825 | "badge": item.badge,
|
16826 | "class": [bem$2("nav-item"), item.className],
|
16827 | "disabled": item.disabled,
|
16828 | "onClick": onClickSidebarItem
|
16829 | }, {
|
16830 | title: () => slots["nav-text"] ? slots["nav-text"](item) : item.text
|
16831 | }));
|
16832 | return vue.createVNode(Sidebar, {
|
16833 | "class": bem$2("nav"),
|
16834 | "modelValue": props2.mainActiveIndex,
|
16835 | "onChange": onSidebarChange
|
16836 | }, {
|
16837 | default: () => [Items]
|
16838 | });
|
16839 | };
|
16840 | const renderContent = () => {
|
16841 | if (slots.content) {
|
16842 | return slots.content();
|
16843 | }
|
16844 | const selected = props2.items[+props2.mainActiveIndex] || {};
|
16845 | if (selected.children) {
|
16846 | return selected.children.map(renderSubItem);
|
16847 | }
|
16848 | };
|
16849 | return () => vue.createVNode("div", {
|
16850 | "class": bem$2(),
|
16851 | "style": {
|
16852 | height: addUnit(props2.height)
|
16853 | }
|
16854 | }, [renderSidebar(), vue.createVNode("div", {
|
16855 | "class": bem$2("content")
|
16856 | }, [renderContent()])]);
|
16857 | }
|
16858 | });
|
16859 | const TreeSelect = withInstall(stdin_default$7);
|
16860 | const [name$1, bem$1, t] = createNamespace("uploader");
|
16861 | function readFileContent(file, resultType) {
|
16862 | return new Promise((resolve) => {
|
16863 | if (resultType === "file") {
|
16864 | resolve();
|
16865 | return;
|
16866 | }
|
16867 | const reader = new FileReader();
|
16868 | reader.onload = (event) => {
|
16869 | resolve(event.target.result);
|
16870 | };
|
16871 | if (resultType === "dataUrl") {
|
16872 | reader.readAsDataURL(file);
|
16873 | } else if (resultType === "text") {
|
16874 | reader.readAsText(file);
|
16875 | }
|
16876 | });
|
16877 | }
|
16878 | function isOversize(items, maxSize) {
|
16879 | return toArray(items).some((item) => {
|
16880 | if (item.file) {
|
16881 | if (isFunction(maxSize)) {
|
16882 | return maxSize(item.file);
|
16883 | }
|
16884 | return item.file.size > +maxSize;
|
16885 | }
|
16886 | return false;
|
16887 | });
|
16888 | }
|
16889 | function filterFiles(items, maxSize) {
|
16890 | const valid = [];
|
16891 | const invalid = [];
|
16892 | items.forEach((item) => {
|
16893 | if (isOversize(item, maxSize)) {
|
16894 | invalid.push(item);
|
16895 | } else {
|
16896 | valid.push(item);
|
16897 | }
|
16898 | });
|
16899 | return { valid, invalid };
|
16900 | }
|
16901 | const IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg|avif)/i;
|
16902 | const isImageUrl = (url) => IMAGE_REGEXP.test(url);
|
16903 | function isImageFile(item) {
|
16904 | if (item.isImage) {
|
16905 | return true;
|
16906 | }
|
16907 | if (item.file && item.file.type) {
|
16908 | return item.file.type.indexOf("image") === 0;
|
16909 | }
|
16910 | if (item.url) {
|
16911 | return isImageUrl(item.url);
|
16912 | }
|
16913 | if (typeof item.content === "string") {
|
16914 | return item.content.indexOf("data:image") === 0;
|
16915 | }
|
16916 | return false;
|
16917 | }
|
16918 | var stdin_default$6 = vue.defineComponent({
|
16919 | props: {
|
16920 | name: numericProp,
|
16921 | item: makeRequiredProp(Object),
|
16922 | index: Number,
|
16923 | imageFit: String,
|
16924 | lazyLoad: Boolean,
|
16925 | deletable: Boolean,
|
16926 | reupload: Boolean,
|
16927 | previewSize: [Number, String, Array],
|
16928 | beforeDelete: Function
|
16929 | },
|
16930 | emits: ["delete", "preview", "reupload"],
|
16931 | setup(props2, {
|
16932 | emit,
|
16933 | slots
|
16934 | }) {
|
16935 | const renderMask = () => {
|
16936 | const {
|
16937 | status,
|
16938 | message
|
16939 | } = props2.item;
|
16940 | if (status === "uploading" || status === "failed") {
|
16941 | const MaskIcon = status === "failed" ? vue.createVNode(Icon, {
|
16942 | "name": "close",
|
16943 | "class": bem$1("mask-icon")
|
16944 | }, null) : vue.createVNode(Loading, {
|
16945 | "class": bem$1("loading")
|
16946 | }, null);
|
16947 | const showMessage = isDef(message) && message !== "";
|
16948 | return vue.createVNode("div", {
|
16949 | "class": bem$1("mask")
|
16950 | }, [MaskIcon, showMessage && vue.createVNode("div", {
|
16951 | "class": bem$1("mask-message")
|
16952 | }, [message])]);
|
16953 | }
|
16954 | };
|
16955 | const onDelete = (event) => {
|
16956 | const {
|
16957 | name: name2,
|
16958 | item,
|
16959 | index,
|
16960 | beforeDelete
|
16961 | } = props2;
|
16962 | event.stopPropagation();
|
16963 | callInterceptor(beforeDelete, {
|
16964 | args: [item, {
|
16965 | name: name2,
|
16966 | index
|
16967 | }],
|
16968 | done: () => emit("delete")
|
16969 | });
|
16970 | };
|
16971 | const onPreview = () => emit("preview");
|
16972 | const onReupload = () => emit("reupload");
|
16973 | const renderDeleteIcon = () => {
|
16974 | if (props2.deletable && props2.item.status !== "uploading") {
|
16975 | const slot = slots["preview-delete"];
|
16976 | return vue.createVNode("div", {
|
16977 | "role": "button",
|
16978 | "class": bem$1("preview-delete", {
|
16979 | shadow: !slot
|
16980 | }),
|
16981 | "tabindex": 0,
|
16982 | "aria-label": t("delete"),
|
16983 | "onClick": onDelete
|
16984 | }, [slot ? slot() : vue.createVNode(Icon, {
|
16985 | "name": "cross",
|
16986 | "class": bem$1("preview-delete-icon")
|
16987 | }, null)]);
|
16988 | }
|
16989 | };
|
16990 | const renderCover = () => {
|
16991 | if (slots["preview-cover"]) {
|
16992 | const {
|
16993 | index,
|
16994 | item
|
16995 | } = props2;
|
16996 | return vue.createVNode("div", {
|
16997 | "class": bem$1("preview-cover")
|
16998 | }, [slots["preview-cover"](extend({
|
16999 | index
|
17000 | }, item))]);
|
17001 | }
|
17002 | };
|
17003 | const renderPreview = () => {
|
17004 | const {
|
17005 | item,
|
17006 | lazyLoad,
|
17007 | imageFit,
|
17008 | previewSize,
|
17009 | reupload
|
17010 | } = props2;
|
17011 | if (isImageFile(item)) {
|
17012 | return vue.createVNode(Image$1, {
|
17013 | "fit": imageFit,
|
17014 | "src": item.objectUrl || item.content || item.url,
|
17015 | "class": bem$1("preview-image"),
|
17016 | "width": Array.isArray(previewSize) ? previewSize[0] : previewSize,
|
17017 | "height": Array.isArray(previewSize) ? previewSize[1] : previewSize,
|
17018 | "lazyLoad": lazyLoad,
|
17019 | "onClick": reupload ? onReupload : onPreview
|
17020 | }, {
|
17021 | default: renderCover
|
17022 | });
|
17023 | }
|
17024 | return vue.createVNode("div", {
|
17025 | "class": bem$1("file"),
|
17026 | "style": getSizeStyle(props2.previewSize)
|
17027 | }, [vue.createVNode(Icon, {
|
17028 | "class": bem$1("file-icon"),
|
17029 | "name": "description"
|
17030 | }, null), vue.createVNode("div", {
|
17031 | "class": [bem$1("file-name"), "van-ellipsis"]
|
17032 | }, [item.file ? item.file.name : item.url]), renderCover()]);
|
17033 | };
|
17034 | return () => vue.createVNode("div", {
|
17035 | "class": bem$1("preview")
|
17036 | }, [renderPreview(), renderMask(), renderDeleteIcon()]);
|
17037 | }
|
17038 | });
|
17039 | const uploaderProps = {
|
17040 | name: makeNumericProp(""),
|
17041 | accept: makeStringProp("image/*"),
|
17042 | capture: String,
|
17043 | multiple: Boolean,
|
17044 | disabled: Boolean,
|
17045 | readonly: Boolean,
|
17046 | lazyLoad: Boolean,
|
17047 | maxCount: makeNumericProp(Infinity),
|
17048 | imageFit: makeStringProp("cover"),
|
17049 | resultType: makeStringProp("dataUrl"),
|
17050 | uploadIcon: makeStringProp("photograph"),
|
17051 | uploadText: String,
|
17052 | deletable: truthProp,
|
17053 | reupload: Boolean,
|
17054 | afterRead: Function,
|
17055 | showUpload: truthProp,
|
17056 | modelValue: makeArrayProp(),
|
17057 | beforeRead: Function,
|
17058 | beforeDelete: Function,
|
17059 | previewSize: [Number, String, Array],
|
17060 | previewImage: truthProp,
|
17061 | previewOptions: Object,
|
17062 | previewFullImage: truthProp,
|
17063 | maxSize: {
|
17064 | type: [Number, String, Function],
|
17065 | default: Infinity
|
17066 | }
|
17067 | };
|
17068 | var stdin_default$5 = vue.defineComponent({
|
17069 | name: name$1,
|
17070 | props: uploaderProps,
|
17071 | emits: ["delete", "oversize", "clickUpload", "closePreview", "clickPreview", "clickReupload", "update:modelValue"],
|
17072 | setup(props2, {
|
17073 | emit,
|
17074 | slots
|
17075 | }) {
|
17076 | const inputRef = vue.ref();
|
17077 | const urls = [];
|
17078 | const reuploadIndex = vue.ref(-1);
|
17079 | const isReuploading = vue.ref(false);
|
17080 | const getDetail = (index = props2.modelValue.length) => ({
|
17081 | name: props2.name,
|
17082 | index
|
17083 | });
|
17084 | const resetInput = () => {
|
17085 | if (inputRef.value) {
|
17086 | inputRef.value.value = "";
|
17087 | }
|
17088 | };
|
17089 | const onAfterRead = (items) => {
|
17090 | resetInput();
|
17091 | if (isOversize(items, props2.maxSize)) {
|
17092 | if (Array.isArray(items)) {
|
17093 | const result = filterFiles(items, props2.maxSize);
|
17094 | items = result.valid;
|
17095 | emit("oversize", result.invalid, getDetail());
|
17096 | if (!items.length) {
|
17097 | return;
|
17098 | }
|
17099 | } else {
|
17100 | emit("oversize", items, getDetail());
|
17101 | return;
|
17102 | }
|
17103 | }
|
17104 | items = vue.reactive(items);
|
17105 | if (reuploadIndex.value > -1) {
|
17106 | const arr = [...props2.modelValue];
|
17107 | arr.splice(reuploadIndex.value, 1, items);
|
17108 | emit("update:modelValue", arr);
|
17109 | reuploadIndex.value = -1;
|
17110 | } else {
|
17111 | emit("update:modelValue", [...props2.modelValue, ...toArray(items)]);
|
17112 | }
|
17113 | if (props2.afterRead) {
|
17114 | props2.afterRead(items, getDetail());
|
17115 | }
|
17116 | };
|
17117 | const readFile = (files) => {
|
17118 | const {
|
17119 | maxCount,
|
17120 | modelValue,
|
17121 | resultType
|
17122 | } = props2;
|
17123 | if (Array.isArray(files)) {
|
17124 | const remainCount = +maxCount - modelValue.length;
|
17125 | if (files.length > remainCount) {
|
17126 | files = files.slice(0, remainCount);
|
17127 | }
|
17128 | Promise.all(files.map((file) => readFileContent(file, resultType))).then((contents) => {
|
17129 | const fileList = files.map((file, index) => {
|
17130 | const result = {
|
17131 | file,
|
17132 | status: "",
|
17133 | message: "",
|
17134 | objectUrl: URL.createObjectURL(file)
|
17135 | };
|
17136 | if (contents[index]) {
|
17137 | result.content = contents[index];
|
17138 | }
|
17139 | return result;
|
17140 | });
|
17141 | onAfterRead(fileList);
|
17142 | });
|
17143 | } else {
|
17144 | readFileContent(files, resultType).then((content) => {
|
17145 | const result = {
|
17146 | file: files,
|
17147 | status: "",
|
17148 | message: "",
|
17149 | objectUrl: URL.createObjectURL(files)
|
17150 | };
|
17151 | if (content) {
|
17152 | result.content = content;
|
17153 | }
|
17154 | onAfterRead(result);
|
17155 | });
|
17156 | }
|
17157 | };
|
17158 | const onChange = (event) => {
|
17159 | const {
|
17160 | files
|
17161 | } = event.target;
|
17162 | if (props2.disabled || !files || !files.length) {
|
17163 | return;
|
17164 | }
|
17165 | const file = files.length === 1 ? files[0] : [].slice.call(files);
|
17166 | if (props2.beforeRead) {
|
17167 | const response = props2.beforeRead(file, getDetail());
|
17168 | if (!response) {
|
17169 | resetInput();
|
17170 | return;
|
17171 | }
|
17172 | if (isPromise(response)) {
|
17173 | response.then((data) => {
|
17174 | if (data) {
|
17175 | readFile(data);
|
17176 | } else {
|
17177 | readFile(file);
|
17178 | }
|
17179 | }).catch(resetInput);
|
17180 | return;
|
17181 | }
|
17182 | }
|
17183 | readFile(file);
|
17184 | };
|
17185 | let imagePreview;
|
17186 | const onClosePreview = () => emit("closePreview");
|
17187 | const previewImage = (item) => {
|
17188 | if (props2.previewFullImage) {
|
17189 | const imageFiles = props2.modelValue.filter(isImageFile);
|
17190 | const images = imageFiles.map((item2) => {
|
17191 | if (item2.objectUrl && !item2.url && item2.status !== "failed") {
|
17192 | item2.url = item2.objectUrl;
|
17193 | urls.push(item2.url);
|
17194 | }
|
17195 | return item2.url;
|
17196 | }).filter(Boolean);
|
17197 | imagePreview = showImagePreview(extend({
|
17198 | images,
|
17199 | startPosition: imageFiles.indexOf(item),
|
17200 | onClose: onClosePreview
|
17201 | }, props2.previewOptions));
|
17202 | }
|
17203 | };
|
17204 | const closeImagePreview = () => {
|
17205 | if (imagePreview) {
|
17206 | imagePreview.close();
|
17207 | }
|
17208 | };
|
17209 | const deleteFile = (item, index) => {
|
17210 | const fileList = props2.modelValue.slice(0);
|
17211 | fileList.splice(index, 1);
|
17212 | emit("update:modelValue", fileList);
|
17213 | emit("delete", item, getDetail(index));
|
17214 | };
|
17215 | const reuploadFile = (index) => {
|
17216 | isReuploading.value = true;
|
17217 | reuploadIndex.value = index;
|
17218 | vue.nextTick(() => chooseFile());
|
17219 | };
|
17220 | const onInputClick = () => {
|
17221 | if (!isReuploading.value) {
|
17222 | reuploadIndex.value = -1;
|
17223 | }
|
17224 | isReuploading.value = false;
|
17225 | };
|
17226 | const renderPreviewItem = (item, index) => {
|
17227 | const needPickData = ["imageFit", "deletable", "reupload", "previewSize", "beforeDelete"];
|
17228 | const previewData = extend(pick(props2, needPickData), pick(item, needPickData, true));
|
17229 | return vue.createVNode(stdin_default$6, vue.mergeProps({
|
17230 | "item": item,
|
17231 | "index": index,
|
17232 | "onClick": () => emit(props2.reupload ? "clickReupload" : "clickPreview", item, getDetail(index)),
|
17233 | "onDelete": () => deleteFile(item, index),
|
17234 | "onPreview": () => previewImage(item),
|
17235 | "onReupload": () => reuploadFile(index)
|
17236 | }, pick(props2, ["name", "lazyLoad"]), previewData), pick(slots, ["preview-cover", "preview-delete"]));
|
17237 | };
|
17238 | const renderPreviewList = () => {
|
17239 | if (props2.previewImage) {
|
17240 | return props2.modelValue.map(renderPreviewItem);
|
17241 | }
|
17242 | };
|
17243 | const onClickUpload = (event) => emit("clickUpload", event);
|
17244 | const renderUpload = () => {
|
17245 | const lessThanMax = props2.modelValue.length < +props2.maxCount;
|
17246 | const Input = props2.readonly ? null : vue.createVNode("input", {
|
17247 | "ref": inputRef,
|
17248 | "type": "file",
|
17249 | "class": bem$1("input"),
|
17250 | "accept": props2.accept,
|
17251 | "capture": props2.capture,
|
17252 | "multiple": props2.multiple && reuploadIndex.value === -1,
|
17253 | "disabled": props2.disabled,
|
17254 | "onChange": onChange,
|
17255 | "onClick": onInputClick
|
17256 | }, null);
|
17257 | if (slots.default) {
|
17258 | return vue.withDirectives(vue.createVNode("div", {
|
17259 | "class": bem$1("input-wrapper"),
|
17260 | "onClick": onClickUpload
|
17261 | }, [slots.default(), Input]), [[vue.vShow, lessThanMax]]);
|
17262 | }
|
17263 | return vue.withDirectives(vue.createVNode("div", {
|
17264 | "class": bem$1("upload", {
|
17265 | readonly: props2.readonly
|
17266 | }),
|
17267 | "style": getSizeStyle(props2.previewSize),
|
17268 | "onClick": onClickUpload
|
17269 | }, [vue.createVNode(Icon, {
|
17270 | "name": props2.uploadIcon,
|
17271 | "class": bem$1("upload-icon")
|
17272 | }, null), props2.uploadText && vue.createVNode("span", {
|
17273 | "class": bem$1("upload-text")
|
17274 | }, [props2.uploadText]), Input]), [[vue.vShow, props2.showUpload && lessThanMax]]);
|
17275 | };
|
17276 | const chooseFile = () => {
|
17277 | if (inputRef.value && !props2.disabled) {
|
17278 | inputRef.value.click();
|
17279 | }
|
17280 | };
|
17281 | vue.onBeforeUnmount(() => {
|
17282 | urls.forEach((url) => URL.revokeObjectURL(url));
|
17283 | });
|
17284 | useExpose({
|
17285 | chooseFile,
|
17286 | reuploadFile,
|
17287 | closeImagePreview
|
17288 | });
|
17289 | useCustomFieldValue(() => props2.modelValue);
|
17290 | return () => vue.createVNode("div", {
|
17291 | "class": bem$1()
|
17292 | }, [vue.createVNode("div", {
|
17293 | "class": bem$1("wrapper", {
|
17294 | disabled: props2.disabled
|
17295 | })
|
17296 | }, [renderPreviewList(), renderUpload()])]);
|
17297 | }
|
17298 | });
|
17299 | const Uploader = withInstall(stdin_default$5);
|
17300 | const [name, bem] = createNamespace("watermark");
|
17301 | const watermarkProps = {
|
17302 | gapX: makeNumberProp(0),
|
17303 | gapY: makeNumberProp(0),
|
17304 | image: String,
|
17305 | width: makeNumberProp(100),
|
17306 | height: makeNumberProp(100),
|
17307 | rotate: makeNumericProp(-22),
|
17308 | zIndex: numericProp,
|
17309 | content: String,
|
17310 | opacity: numericProp,
|
17311 | fullPage: truthProp,
|
17312 | textColor: makeStringProp("#dcdee0")
|
17313 | };
|
17314 | var stdin_default$4 = vue.defineComponent({
|
17315 | name,
|
17316 | props: watermarkProps,
|
17317 | setup(props2, {
|
17318 | slots
|
17319 | }) {
|
17320 | const svgElRef = vue.ref();
|
17321 | const watermarkUrl = vue.ref("");
|
17322 | const imageBase64 = vue.ref("");
|
17323 | const renderWatermark = () => {
|
17324 | const rotateStyle = {
|
17325 | transformOrigin: "center",
|
17326 | transform: `rotate(${props2.rotate}deg)`
|
17327 | };
|
17328 | const svgInner = () => {
|
17329 | if (props2.image && !slots.content) {
|
17330 | return vue.createVNode("image", {
|
17331 | "href": imageBase64.value,
|
17332 | "xlink:href": imageBase64.value,
|
17333 | "x": "0",
|
17334 | "y": "0",
|
17335 | "width": props2.width,
|
17336 | "height": props2.height,
|
17337 | "style": rotateStyle
|
17338 | }, null);
|
17339 | }
|
17340 | return vue.createVNode("foreignObject", {
|
17341 | "x": "0",
|
17342 | "y": "0",
|
17343 | "width": props2.width,
|
17344 | "height": props2.height
|
17345 | }, [vue.createVNode("div", {
|
17346 | "xmlns": "http://www.w3.org/1999/xhtml",
|
17347 | "style": rotateStyle
|
17348 | }, [slots.content ? slots.content() : vue.createVNode("span", {
|
17349 | "style": {
|
17350 | color: props2.textColor
|
17351 | }
|
17352 | }, [props2.content])])]);
|
17353 | };
|
17354 | const svgWidth = props2.width + props2.gapX;
|
17355 | const svgHeight = props2.height + props2.gapY;
|
17356 | return vue.createVNode("svg", {
|
17357 | "viewBox": `0 0 ${svgWidth} ${svgHeight}`,
|
17358 | "width": svgWidth,
|
17359 | "height": svgHeight,
|
17360 | "xmlns": "http://www.w3.org/2000/svg",
|
17361 | "xmlns:xlink": "http://www.w3.org/1999/xlink",
|
17362 | "style": {
|
17363 | padding: `0 ${props2.gapX}px ${props2.gapY}px 0`,
|
17364 | opacity: props2.opacity
|
17365 | }
|
17366 | }, [svgInner()]);
|
17367 | };
|
17368 | const makeImageToBase64 = (url) => {
|
17369 | const canvas = document.createElement("canvas");
|
17370 | const image = new Image();
|
17371 | image.crossOrigin = "anonymous";
|
17372 | image.referrerPolicy = "no-referrer";
|
17373 | image.onload = () => {
|
17374 | canvas.width = image.naturalWidth;
|
17375 | canvas.height = image.naturalHeight;
|
17376 | const ctx = canvas.getContext("2d");
|
17377 | ctx == null ? void 0 : ctx.drawImage(image, 0, 0);
|
17378 | imageBase64.value = canvas.toDataURL();
|
17379 | };
|
17380 | image.src = url;
|
17381 | };
|
17382 | const makeSvgToBlobUrl = (svgStr) => {
|
17383 | const svgBlob = new Blob([svgStr], {
|
17384 | type: "image/svg+xml"
|
17385 | });
|
17386 | return URL.createObjectURL(svgBlob);
|
17387 | };
|
17388 | vue.watchEffect(() => {
|
17389 | if (props2.image) {
|
17390 | makeImageToBase64(props2.image);
|
17391 | }
|
17392 | });
|
17393 | vue.watch(() => [imageBase64.value, props2.content, props2.textColor, props2.height, props2.width, props2.rotate, props2.gapX, props2.gapY], () => {
|
17394 | vue.nextTick(() => {
|
17395 | if (svgElRef.value) {
|
17396 | if (watermarkUrl.value) {
|
17397 | URL.revokeObjectURL(watermarkUrl.value);
|
17398 | }
|
17399 | watermarkUrl.value = makeSvgToBlobUrl(svgElRef.value.innerHTML);
|
17400 | }
|
17401 | });
|
17402 | }, {
|
17403 | immediate: true
|
17404 | });
|
17405 | vue.onUnmounted(() => {
|
17406 | if (watermarkUrl.value) {
|
17407 | URL.revokeObjectURL(watermarkUrl.value);
|
17408 | }
|
17409 | });
|
17410 | return () => {
|
17411 | const style = extend({
|
17412 | backgroundImage: `url(${watermarkUrl.value})`
|
17413 | }, getZIndexStyle(props2.zIndex));
|
17414 | return vue.createVNode("div", {
|
17415 | "class": bem({
|
17416 | full: props2.fullPage
|
17417 | }),
|
17418 | "style": style
|
17419 | }, [vue.createVNode("div", {
|
17420 | "class": bem("wrapper"),
|
17421 | "ref": svgElRef
|
17422 | }, [renderWatermark()])]);
|
17423 | };
|
17424 | }
|
17425 | });
|
17426 | const Watermark = withInstall(stdin_default$4);
|
17427 | class ReactiveListener {
|
17428 | constructor({
|
17429 | el,
|
17430 | src,
|
17431 | error,
|
17432 | loading,
|
17433 | bindType,
|
17434 | $parent,
|
17435 | options,
|
17436 | cors,
|
17437 | elRenderer,
|
17438 | imageCache
|
17439 | }) {
|
17440 | this.el = el;
|
17441 | this.src = src;
|
17442 | this.error = error;
|
17443 | this.loading = loading;
|
17444 | this.bindType = bindType;
|
17445 | this.attempt = 0;
|
17446 | this.cors = cors;
|
17447 | this.naturalHeight = 0;
|
17448 | this.naturalWidth = 0;
|
17449 | this.options = options;
|
17450 | this.$parent = $parent;
|
17451 | this.elRenderer = elRenderer;
|
17452 | this.imageCache = imageCache;
|
17453 | this.performanceData = {
|
17454 | loadStart: 0,
|
17455 | loadEnd: 0
|
17456 | };
|
17457 | this.filter();
|
17458 | this.initState();
|
17459 | this.render("loading", false);
|
17460 | }
|
17461 | |
17462 |
|
17463 |
|
17464 |
|
17465 | initState() {
|
17466 | if ("dataset" in this.el) {
|
17467 | this.el.dataset.src = this.src;
|
17468 | } else {
|
17469 | this.el.setAttribute("data-src", this.src);
|
17470 | }
|
17471 | this.state = {
|
17472 | loading: false,
|
17473 | error: false,
|
17474 | loaded: false,
|
17475 | rendered: false
|
17476 | };
|
17477 | }
|
17478 | |
17479 |
|
17480 |
|
17481 |
|
17482 | record(event) {
|
17483 | this.performanceData[event] = Date.now();
|
17484 | }
|
17485 | |
17486 |
|
17487 |
|
17488 |
|
17489 |
|
17490 |
|
17491 |
|
17492 | update({ src, loading, error }) {
|
17493 | const oldSrc = this.src;
|
17494 | this.src = src;
|
17495 | this.loading = loading;
|
17496 | this.error = error;
|
17497 | this.filter();
|
17498 | if (oldSrc !== this.src) {
|
17499 | this.attempt = 0;
|
17500 | this.initState();
|
17501 | }
|
17502 | }
|
17503 | |
17504 |
|
17505 |
|
17506 |
|
17507 | checkInView() {
|
17508 | const rect = useRect(this.el);
|
17509 | return rect.top < window.innerHeight * this.options.preLoad && rect.bottom > this.options.preLoadTop && rect.left < window.innerWidth * this.options.preLoad && rect.right > 0;
|
17510 | }
|
17511 | |
17512 |
|
17513 |
|
17514 | filter() {
|
17515 | Object.keys(this.options.filter).forEach((key) => {
|
17516 | this.options.filter[key](this, this.options);
|
17517 | });
|
17518 | }
|
17519 | |
17520 |
|
17521 |
|
17522 |
|
17523 |
|
17524 | renderLoading(cb) {
|
17525 | this.state.loading = true;
|
17526 | loadImageAsync(
|
17527 | {
|
17528 | src: this.loading,
|
17529 | cors: this.cors
|
17530 | },
|
17531 | () => {
|
17532 | this.render("loading", false);
|
17533 | this.state.loading = false;
|
17534 | cb();
|
17535 | },
|
17536 | () => {
|
17537 | cb();
|
17538 | this.state.loading = false;
|
17539 | }
|
17540 | );
|
17541 | }
|
17542 | |
17543 |
|
17544 |
|
17545 |
|
17546 | load(onFinish = noop) {
|
17547 | if (this.attempt > this.options.attempt - 1 && this.state.error) {
|
17548 | onFinish();
|
17549 | return;
|
17550 | }
|
17551 | if (this.state.rendered && this.state.loaded) return;
|
17552 | if (this.imageCache.has(this.src)) {
|
17553 | this.state.loaded = true;
|
17554 | this.render("loaded", true);
|
17555 | this.state.rendered = true;
|
17556 | return onFinish();
|
17557 | }
|
17558 | this.renderLoading(() => {
|
17559 | var _a, _b;
|
17560 | this.attempt++;
|
17561 | (_b = (_a = this.options.adapter).beforeLoad) == null ? void 0 : _b.call(_a, this, this.options);
|
17562 | this.record("loadStart");
|
17563 | loadImageAsync(
|
17564 | {
|
17565 | src: this.src,
|
17566 | cors: this.cors
|
17567 | },
|
17568 | (data) => {
|
17569 | this.naturalHeight = data.naturalHeight;
|
17570 | this.naturalWidth = data.naturalWidth;
|
17571 | this.state.loaded = true;
|
17572 | this.state.error = false;
|
17573 | this.record("loadEnd");
|
17574 | this.render("loaded", false);
|
17575 | this.state.rendered = true;
|
17576 | this.imageCache.add(this.src);
|
17577 | onFinish();
|
17578 | },
|
17579 | (err) => {
|
17580 | !this.options.silent && console.error(err);
|
17581 | this.state.error = true;
|
17582 | this.state.loaded = false;
|
17583 | this.render("error", false);
|
17584 | }
|
17585 | );
|
17586 | });
|
17587 | }
|
17588 | |
17589 |
|
17590 |
|
17591 |
|
17592 |
|
17593 |
|
17594 | render(state, cache) {
|
17595 | this.elRenderer(this, state, cache);
|
17596 | }
|
17597 | |
17598 |
|
17599 |
|
17600 |
|
17601 | performance() {
|
17602 | let state = "loading";
|
17603 | let time = 0;
|
17604 | if (this.state.loaded) {
|
17605 | state = "loaded";
|
17606 | time = (this.performanceData.loadEnd - this.performanceData.loadStart) / 1e3;
|
17607 | }
|
17608 | if (this.state.error) state = "error";
|
17609 | return {
|
17610 | src: this.src,
|
17611 | state,
|
17612 | time
|
17613 | };
|
17614 | }
|
17615 | |
17616 |
|
17617 |
|
17618 |
|
17619 | $destroy() {
|
17620 | this.el = null;
|
17621 | this.src = null;
|
17622 | this.error = null;
|
17623 | this.loading = null;
|
17624 | this.bindType = null;
|
17625 | this.attempt = 0;
|
17626 | }
|
17627 | }
|
17628 | const DEFAULT_URL = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
|
17629 | const DEFAULT_EVENTS = [
|
17630 | "scroll",
|
17631 | "wheel",
|
17632 | "mousewheel",
|
17633 | "resize",
|
17634 | "animationend",
|
17635 | "transitionend",
|
17636 | "touchmove"
|
17637 | ];
|
17638 | const DEFAULT_OBSERVER_OPTIONS = {
|
17639 | rootMargin: "0px",
|
17640 | threshold: 0
|
17641 | };
|
17642 | function stdin_default$3() {
|
17643 | return class Lazy {
|
17644 | constructor({
|
17645 | preLoad,
|
17646 | error,
|
17647 | throttleWait,
|
17648 | preLoadTop,
|
17649 | dispatchEvent,
|
17650 | loading,
|
17651 | attempt,
|
17652 | silent = true,
|
17653 | scale,
|
17654 | listenEvents,
|
17655 | filter,
|
17656 | adapter,
|
17657 | observer,
|
17658 | observerOptions
|
17659 | }) {
|
17660 | this.mode = modeType.event;
|
17661 | this.listeners = [];
|
17662 | this.targetIndex = 0;
|
17663 | this.targets = [];
|
17664 | this.options = {
|
17665 | silent,
|
17666 | dispatchEvent: !!dispatchEvent,
|
17667 | throttleWait: throttleWait || 200,
|
17668 | preLoad: preLoad || 1.3,
|
17669 | preLoadTop: preLoadTop || 0,
|
17670 | error: error || DEFAULT_URL,
|
17671 | loading: loading || DEFAULT_URL,
|
17672 | attempt: attempt || 3,
|
17673 | scale: scale || getDPR(scale),
|
17674 | ListenEvents: listenEvents || DEFAULT_EVENTS,
|
17675 | supportWebp: supportWebp(),
|
17676 | filter: filter || {},
|
17677 | adapter: adapter || {},
|
17678 | observer: !!observer,
|
17679 | observerOptions: observerOptions || DEFAULT_OBSERVER_OPTIONS
|
17680 | };
|
17681 | this.initEvent();
|
17682 | this.imageCache = new ImageCache({ max: 200 });
|
17683 | this.lazyLoadHandler = throttle(
|
17684 | this.lazyLoadHandler.bind(this),
|
17685 | this.options.throttleWait
|
17686 | );
|
17687 | this.setMode(this.options.observer ? modeType.observer : modeType.event);
|
17688 | }
|
17689 | |
17690 |
|
17691 |
|
17692 |
|
17693 |
|
17694 | config(options = {}) {
|
17695 | Object.assign(this.options, options);
|
17696 | }
|
17697 | |
17698 |
|
17699 |
|
17700 |
|
17701 | performance() {
|
17702 | return this.listeners.map((item) => item.performance());
|
17703 | }
|
17704 | |
17705 |
|
17706 |
|
17707 |
|
17708 |
|
17709 | addLazyBox(vm) {
|
17710 | this.listeners.push(vm);
|
17711 | if (inBrowser) {
|
17712 | this.addListenerTarget(window);
|
17713 | this.observer && this.observer.observe(vm.el);
|
17714 | if (vm.$el && vm.$el.parentNode) {
|
17715 | this.addListenerTarget(vm.$el.parentNode);
|
17716 | }
|
17717 | }
|
17718 | }
|
17719 | |
17720 |
|
17721 |
|
17722 |
|
17723 |
|
17724 |
|
17725 |
|
17726 | add(el, binding, vnode) {
|
17727 | if (this.listeners.some((item) => item.el === el)) {
|
17728 | this.update(el, binding);
|
17729 | return vue.nextTick(this.lazyLoadHandler);
|
17730 | }
|
17731 | const value = this.valueFormatter(binding.value);
|
17732 | let { src } = value;
|
17733 | vue.nextTick(() => {
|
17734 | src = getBestSelectionFromSrcset(el, this.options.scale) || src;
|
17735 | this.observer && this.observer.observe(el);
|
17736 | const container = Object.keys(binding.modifiers)[0];
|
17737 | let $parent;
|
17738 | if (container) {
|
17739 | $parent = vnode.context.$refs[container];
|
17740 | $parent = $parent ? $parent.$el || $parent : document.getElementById(container);
|
17741 | }
|
17742 | if (!$parent) {
|
17743 | $parent = getScrollParent$1(el);
|
17744 | }
|
17745 | const newListener = new ReactiveListener({
|
17746 | bindType: binding.arg,
|
17747 | $parent,
|
17748 | el,
|
17749 | src,
|
17750 | loading: value.loading,
|
17751 | error: value.error,
|
17752 | cors: value.cors,
|
17753 | elRenderer: this.elRenderer.bind(this),
|
17754 | options: this.options,
|
17755 | imageCache: this.imageCache
|
17756 | });
|
17757 | this.listeners.push(newListener);
|
17758 | if (inBrowser) {
|
17759 | this.addListenerTarget(window);
|
17760 | this.addListenerTarget($parent);
|
17761 | }
|
17762 | this.lazyLoadHandler();
|
17763 | vue.nextTick(() => this.lazyLoadHandler());
|
17764 | });
|
17765 | }
|
17766 | |
17767 |
|
17768 |
|
17769 |
|
17770 |
|
17771 |
|
17772 | update(el, binding, vnode) {
|
17773 | const value = this.valueFormatter(binding.value);
|
17774 | let { src } = value;
|
17775 | src = getBestSelectionFromSrcset(el, this.options.scale) || src;
|
17776 | const exist = this.listeners.find((item) => item.el === el);
|
17777 | if (!exist) {
|
17778 | this.add(el, binding, vnode);
|
17779 | } else {
|
17780 | exist.update({
|
17781 | src,
|
17782 | error: value.error,
|
17783 | loading: value.loading
|
17784 | });
|
17785 | }
|
17786 | if (this.observer) {
|
17787 | this.observer.unobserve(el);
|
17788 | this.observer.observe(el);
|
17789 | }
|
17790 | this.lazyLoadHandler();
|
17791 | vue.nextTick(() => this.lazyLoadHandler());
|
17792 | }
|
17793 | |
17794 |
|
17795 |
|
17796 |
|
17797 |
|
17798 | remove(el) {
|
17799 | if (!el) return;
|
17800 | this.observer && this.observer.unobserve(el);
|
17801 | const existItem = this.listeners.find((item) => item.el === el);
|
17802 | if (existItem) {
|
17803 | this.removeListenerTarget(existItem.$parent);
|
17804 | this.removeListenerTarget(window);
|
17805 | remove(this.listeners, existItem);
|
17806 | existItem.$destroy();
|
17807 | }
|
17808 | }
|
17809 | |
17810 |
|
17811 |
|
17812 |
|
17813 |
|
17814 | removeComponent(vm) {
|
17815 | if (!vm) return;
|
17816 | remove(this.listeners, vm);
|
17817 | this.observer && this.observer.unobserve(vm.el);
|
17818 | if (vm.$parent && vm.$el.parentNode) {
|
17819 | this.removeListenerTarget(vm.$el.parentNode);
|
17820 | }
|
17821 | this.removeListenerTarget(window);
|
17822 | }
|
17823 | setMode(mode) {
|
17824 | if (!hasIntersectionObserver && mode === modeType.observer) {
|
17825 | mode = modeType.event;
|
17826 | }
|
17827 | this.mode = mode;
|
17828 | if (mode === modeType.event) {
|
17829 | if (this.observer) {
|
17830 | this.listeners.forEach((listener) => {
|
17831 | this.observer.unobserve(listener.el);
|
17832 | });
|
17833 | this.observer = null;
|
17834 | }
|
17835 | this.targets.forEach((target) => {
|
17836 | this.initListen(target.el, true);
|
17837 | });
|
17838 | } else {
|
17839 | this.targets.forEach((target) => {
|
17840 | this.initListen(target.el, false);
|
17841 | });
|
17842 | this.initIntersectionObserver();
|
17843 | }
|
17844 | }
|
17845 | |
17846 |
|
17847 |
|
17848 | |
17849 |
|
17850 |
|
17851 |
|
17852 |
|
17853 | addListenerTarget(el) {
|
17854 | if (!el) return;
|
17855 | let target = this.targets.find((target2) => target2.el === el);
|
17856 | if (!target) {
|
17857 | target = {
|
17858 | el,
|
17859 | id: ++this.targetIndex,
|
17860 | childrenCount: 1,
|
17861 | listened: true
|
17862 | };
|
17863 | this.mode === modeType.event && this.initListen(target.el, true);
|
17864 | this.targets.push(target);
|
17865 | } else {
|
17866 | target.childrenCount++;
|
17867 | }
|
17868 | return this.targetIndex;
|
17869 | }
|
17870 | |
17871 |
|
17872 |
|
17873 |
|
17874 |
|
17875 | removeListenerTarget(el) {
|
17876 | this.targets.forEach((target, index) => {
|
17877 | if (target.el === el) {
|
17878 | target.childrenCount--;
|
17879 | if (!target.childrenCount) {
|
17880 | this.initListen(target.el, false);
|
17881 | this.targets.splice(index, 1);
|
17882 | target = null;
|
17883 | }
|
17884 | }
|
17885 | });
|
17886 | }
|
17887 | |
17888 |
|
17889 |
|
17890 |
|
17891 |
|
17892 |
|
17893 | initListen(el, start2) {
|
17894 | this.options.ListenEvents.forEach(
|
17895 | (evt) => (start2 ? on : off)(el, evt, this.lazyLoadHandler)
|
17896 | );
|
17897 | }
|
17898 | initEvent() {
|
17899 | this.Event = {
|
17900 | listeners: {
|
17901 | loading: [],
|
17902 | loaded: [],
|
17903 | error: []
|
17904 | }
|
17905 | };
|
17906 | this.$on = (event, func) => {
|
17907 | if (!this.Event.listeners[event]) this.Event.listeners[event] = [];
|
17908 | this.Event.listeners[event].push(func);
|
17909 | };
|
17910 | this.$once = (event, func) => {
|
17911 | const on2 = (...args) => {
|
17912 | this.$off(event, on2);
|
17913 | func.apply(this, args);
|
17914 | };
|
17915 | this.$on(event, on2);
|
17916 | };
|
17917 | this.$off = (event, func) => {
|
17918 | if (!func) {
|
17919 | if (!this.Event.listeners[event]) return;
|
17920 | this.Event.listeners[event].length = 0;
|
17921 | return;
|
17922 | }
|
17923 | remove(this.Event.listeners[event], func);
|
17924 | };
|
17925 | this.$emit = (event, context, inCache) => {
|
17926 | if (!this.Event.listeners[event]) return;
|
17927 | this.Event.listeners[event].forEach((func) => func(context, inCache));
|
17928 | };
|
17929 | }
|
17930 | |
17931 |
|
17932 |
|
17933 |
|
17934 | lazyLoadHandler() {
|
17935 | const freeList = [];
|
17936 | this.listeners.forEach((listener) => {
|
17937 | if (!listener.el || !listener.el.parentNode) {
|
17938 | freeList.push(listener);
|
17939 | }
|
17940 | const catIn = listener.checkInView();
|
17941 | if (!catIn) return;
|
17942 | listener.load();
|
17943 | });
|
17944 | freeList.forEach((item) => {
|
17945 | remove(this.listeners, item);
|
17946 | item.$destroy();
|
17947 | });
|
17948 | }
|
17949 | |
17950 |
|
17951 |
|
17952 |
|
17953 |
|
17954 | initIntersectionObserver() {
|
17955 | if (!hasIntersectionObserver) {
|
17956 | return;
|
17957 | }
|
17958 | this.observer = new IntersectionObserver(
|
17959 | this.observerHandler.bind(this),
|
17960 | this.options.observerOptions
|
17961 | );
|
17962 | if (this.listeners.length) {
|
17963 | this.listeners.forEach((listener) => {
|
17964 | this.observer.observe(listener.el);
|
17965 | });
|
17966 | }
|
17967 | }
|
17968 | |
17969 |
|
17970 |
|
17971 |
|
17972 | observerHandler(entries) {
|
17973 | entries.forEach((entry) => {
|
17974 | if (entry.isIntersecting) {
|
17975 | this.listeners.forEach((listener) => {
|
17976 | if (listener.el === entry.target) {
|
17977 | if (listener.state.loaded)
|
17978 | return this.observer.unobserve(listener.el);
|
17979 | listener.load();
|
17980 | }
|
17981 | });
|
17982 | }
|
17983 | });
|
17984 | }
|
17985 | |
17986 |
|
17987 |
|
17988 |
|
17989 |
|
17990 |
|
17991 |
|
17992 | elRenderer(listener, state, cache) {
|
17993 | if (!listener.el) return;
|
17994 | const { el, bindType } = listener;
|
17995 | let src;
|
17996 | switch (state) {
|
17997 | case "loading":
|
17998 | src = listener.loading;
|
17999 | break;
|
18000 | case "error":
|
18001 | src = listener.error;
|
18002 | break;
|
18003 | default:
|
18004 | ({ src } = listener);
|
18005 | break;
|
18006 | }
|
18007 | if (bindType) {
|
18008 | el.style[bindType] = 'url("' + src + '")';
|
18009 | } else if (el.getAttribute("src") !== src) {
|
18010 | el.setAttribute("src", src);
|
18011 | }
|
18012 | el.setAttribute("lazy", state);
|
18013 | this.$emit(state, listener, cache);
|
18014 | this.options.adapter[state] && this.options.adapter[state](listener, this.options);
|
18015 | if (this.options.dispatchEvent) {
|
18016 | const event = new CustomEvent(state, {
|
18017 | detail: listener
|
18018 | });
|
18019 | el.dispatchEvent(event);
|
18020 | }
|
18021 | }
|
18022 | |
18023 |
|
18024 |
|
18025 |
|
18026 |
|
18027 | valueFormatter(value) {
|
18028 | let src = value;
|
18029 | let { loading, error } = this.options;
|
18030 | if (isObject$1(value)) {
|
18031 | ({ src } = value);
|
18032 | loading = value.loading || this.options.loading;
|
18033 | error = value.error || this.options.error;
|
18034 | }
|
18035 | return {
|
18036 | src,
|
18037 | loading,
|
18038 | error
|
18039 | };
|
18040 | }
|
18041 | };
|
18042 | }
|
18043 | var stdin_default$2 = (lazy) => ({
|
18044 | props: {
|
18045 | tag: {
|
18046 | type: String,
|
18047 | default: "div"
|
18048 | }
|
18049 | },
|
18050 | emits: ["show"],
|
18051 | render() {
|
18052 | return vue.h(
|
18053 | this.tag,
|
18054 | this.show && this.$slots.default ? this.$slots.default() : null
|
18055 | );
|
18056 | },
|
18057 | data() {
|
18058 | return {
|
18059 | el: null,
|
18060 | state: {
|
18061 | loaded: false
|
18062 | },
|
18063 | show: false
|
18064 | };
|
18065 | },
|
18066 | mounted() {
|
18067 | this.el = this.$el;
|
18068 | lazy.addLazyBox(this);
|
18069 | lazy.lazyLoadHandler();
|
18070 | },
|
18071 | beforeUnmount() {
|
18072 | lazy.removeComponent(this);
|
18073 | },
|
18074 | methods: {
|
18075 | checkInView() {
|
18076 | const rect = useRect(this.$el);
|
18077 | return inBrowser && rect.top < window.innerHeight * lazy.options.preLoad && rect.bottom > 0 && rect.left < window.innerWidth * lazy.options.preLoad && rect.right > 0;
|
18078 | },
|
18079 | load() {
|
18080 | this.show = true;
|
18081 | this.state.loaded = true;
|
18082 | this.$emit("show", this);
|
18083 | },
|
18084 | destroy() {
|
18085 | return this.$destroy;
|
18086 | }
|
18087 | }
|
18088 | });
|
18089 | const defaultOptions = {
|
18090 | selector: "img"
|
18091 | };
|
18092 | class LazyContainer {
|
18093 | constructor({ el, binding, vnode, lazy }) {
|
18094 | this.el = null;
|
18095 | this.vnode = vnode;
|
18096 | this.binding = binding;
|
18097 | this.options = {};
|
18098 | this.lazy = lazy;
|
18099 | this.queue = [];
|
18100 | this.update({ el, binding });
|
18101 | }
|
18102 | update({ el, binding }) {
|
18103 | this.el = el;
|
18104 | this.options = Object.assign({}, defaultOptions, binding.value);
|
18105 | const imgs = this.getImgs();
|
18106 | imgs.forEach((el2) => {
|
18107 | this.lazy.add(
|
18108 | el2,
|
18109 | Object.assign({}, this.binding, {
|
18110 | value: {
|
18111 | src: "dataset" in el2 ? el2.dataset.src : el2.getAttribute("data-src"),
|
18112 | error: ("dataset" in el2 ? el2.dataset.error : el2.getAttribute("data-error")) || this.options.error,
|
18113 | loading: ("dataset" in el2 ? el2.dataset.loading : el2.getAttribute("data-loading")) || this.options.loading
|
18114 | }
|
18115 | }),
|
18116 | this.vnode
|
18117 | );
|
18118 | });
|
18119 | }
|
18120 | getImgs() {
|
18121 | return Array.from(this.el.querySelectorAll(this.options.selector));
|
18122 | }
|
18123 | clear() {
|
18124 | const imgs = this.getImgs();
|
18125 | imgs.forEach((el) => this.lazy.remove(el));
|
18126 | this.vnode = null;
|
18127 | this.binding = null;
|
18128 | this.lazy = null;
|
18129 | }
|
18130 | }
|
18131 | class LazyContainerManager {
|
18132 | constructor({ lazy }) {
|
18133 | this.lazy = lazy;
|
18134 | this.queue = [];
|
18135 | }
|
18136 | bind(el, binding, vnode) {
|
18137 | const container = new LazyContainer({
|
18138 | el,
|
18139 | binding,
|
18140 | vnode,
|
18141 | lazy: this.lazy
|
18142 | });
|
18143 | this.queue.push(container);
|
18144 | }
|
18145 | update(el, binding, vnode) {
|
18146 | const container = this.queue.find((item) => item.el === el);
|
18147 | if (!container) return;
|
18148 | container.update({ el, binding, vnode });
|
18149 | }
|
18150 | unbind(el) {
|
18151 | const container = this.queue.find((item) => item.el === el);
|
18152 | if (!container) return;
|
18153 | container.clear();
|
18154 | remove(this.queue, container);
|
18155 | }
|
18156 | }
|
18157 | var stdin_default$1 = (lazyManager) => ({
|
18158 | props: {
|
18159 | src: [String, Object],
|
18160 | tag: {
|
18161 | type: String,
|
18162 | default: "img"
|
18163 | }
|
18164 | },
|
18165 | render() {
|
18166 | var _a, _b;
|
18167 | return vue.h(
|
18168 | this.tag,
|
18169 | {
|
18170 | src: this.renderSrc
|
18171 | },
|
18172 | (_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a)
|
18173 | );
|
18174 | },
|
18175 | data() {
|
18176 | return {
|
18177 | el: null,
|
18178 | options: {
|
18179 | src: "",
|
18180 | error: "",
|
18181 | loading: "",
|
18182 | attempt: lazyManager.options.attempt
|
18183 | },
|
18184 | state: {
|
18185 | loaded: false,
|
18186 | error: false,
|
18187 | attempt: 0
|
18188 | },
|
18189 | renderSrc: ""
|
18190 | };
|
18191 | },
|
18192 | watch: {
|
18193 | src() {
|
18194 | this.init();
|
18195 | lazyManager.addLazyBox(this);
|
18196 | lazyManager.lazyLoadHandler();
|
18197 | }
|
18198 | },
|
18199 | created() {
|
18200 | this.init();
|
18201 | },
|
18202 | mounted() {
|
18203 | this.el = this.$el;
|
18204 | lazyManager.addLazyBox(this);
|
18205 | lazyManager.lazyLoadHandler();
|
18206 | },
|
18207 | beforeUnmount() {
|
18208 | lazyManager.removeComponent(this);
|
18209 | },
|
18210 | methods: {
|
18211 | init() {
|
18212 | const { src, loading, error } = lazyManager.valueFormatter(this.src);
|
18213 | this.state.loaded = false;
|
18214 | this.options.src = src;
|
18215 | this.options.error = error;
|
18216 | this.options.loading = loading;
|
18217 | this.renderSrc = this.options.loading;
|
18218 | },
|
18219 | checkInView() {
|
18220 | const rect = useRect(this.$el);
|
18221 | return rect.top < window.innerHeight * lazyManager.options.preLoad && rect.bottom > 0 && rect.left < window.innerWidth * lazyManager.options.preLoad && rect.right > 0;
|
18222 | },
|
18223 | load(onFinish = noop) {
|
18224 | if (this.state.attempt > this.options.attempt - 1 && this.state.error) {
|
18225 | onFinish();
|
18226 | return;
|
18227 | }
|
18228 | const { src } = this.options;
|
18229 | loadImageAsync(
|
18230 | { src },
|
18231 | ({ src: src2 }) => {
|
18232 | this.renderSrc = src2;
|
18233 | this.state.loaded = true;
|
18234 | },
|
18235 | () => {
|
18236 | this.state.attempt++;
|
18237 | this.renderSrc = this.options.error;
|
18238 | this.state.error = true;
|
18239 | }
|
18240 | );
|
18241 | }
|
18242 | }
|
18243 | });
|
18244 | const Lazyload = {
|
18245 | |
18246 |
|
18247 |
|
18248 |
|
18249 |
|
18250 | install(app, options = {}) {
|
18251 | const LazyClass = stdin_default$3();
|
18252 | const lazy = new LazyClass(options);
|
18253 | const lazyContainer = new LazyContainerManager({ lazy });
|
18254 | app.config.globalProperties.$Lazyload = lazy;
|
18255 | if (options.lazyComponent) {
|
18256 | app.component("LazyComponent", stdin_default$2(lazy));
|
18257 | }
|
18258 | if (options.lazyImage) {
|
18259 | app.component("LazyImage", stdin_default$1(lazy));
|
18260 | }
|
18261 | app.directive("lazy", {
|
18262 | beforeMount: lazy.add.bind(lazy),
|
18263 | updated: lazy.update.bind(lazy),
|
18264 | unmounted: lazy.remove.bind(lazy)
|
18265 | });
|
18266 | app.directive("lazy-container", {
|
18267 | beforeMount: lazyContainer.bind.bind(lazyContainer),
|
18268 | updated: lazyContainer.update.bind(lazyContainer),
|
18269 | unmounted: lazyContainer.unbind.bind(lazyContainer)
|
18270 | });
|
18271 | }
|
18272 | };
|
18273 | const version = "4.9.8";
|
18274 | function install(app) {
|
18275 | const components = [
|
18276 | ActionBar,
|
18277 | ActionBarButton,
|
18278 | ActionBarIcon,
|
18279 | ActionSheet,
|
18280 | AddressEdit,
|
18281 | AddressList,
|
18282 | Area,
|
18283 | BackTop,
|
18284 | Badge,
|
18285 | Barrage,
|
18286 | Button,
|
18287 | Calendar,
|
18288 | Card,
|
18289 | Cascader,
|
18290 | Cell,
|
18291 | CellGroup,
|
18292 | Checkbox,
|
18293 | CheckboxGroup,
|
18294 | Circle,
|
18295 | Col,
|
18296 | Collapse,
|
18297 | CollapseItem,
|
18298 | ConfigProvider,
|
18299 | ContactCard,
|
18300 | ContactEdit,
|
18301 | ContactList,
|
18302 | CountDown,
|
18303 | Coupon,
|
18304 | CouponCell,
|
18305 | CouponList,
|
18306 | DatePicker,
|
18307 | Dialog,
|
18308 | Divider,
|
18309 | DropdownItem,
|
18310 | DropdownMenu,
|
18311 | Empty,
|
18312 | Field,
|
18313 | FloatingBubble,
|
18314 | FloatingPanel,
|
18315 | Form,
|
18316 | Grid,
|
18317 | GridItem,
|
18318 | Highlight,
|
18319 | Icon,
|
18320 | Image$1,
|
18321 | ImagePreview,
|
18322 | IndexAnchor,
|
18323 | IndexBar,
|
18324 | List,
|
18325 | Loading,
|
18326 | Locale,
|
18327 | NavBar,
|
18328 | NoticeBar,
|
18329 | Notify,
|
18330 | NumberKeyboard,
|
18331 | Overlay,
|
18332 | Pagination,
|
18333 | PasswordInput,
|
18334 | Picker,
|
18335 | PickerGroup,
|
18336 | Popover,
|
18337 | Popup,
|
18338 | Progress,
|
18339 | PullRefresh,
|
18340 | Radio,
|
18341 | RadioGroup,
|
18342 | Rate,
|
18343 | RollingText,
|
18344 | Row,
|
18345 | Search,
|
18346 | ShareSheet,
|
18347 | Sidebar,
|
18348 | SidebarItem,
|
18349 | Signature,
|
18350 | Skeleton,
|
18351 | SkeletonAvatar,
|
18352 | SkeletonImage,
|
18353 | SkeletonParagraph,
|
18354 | SkeletonTitle,
|
18355 | Slider,
|
18356 | Space,
|
18357 | Step,
|
18358 | Stepper,
|
18359 | Steps,
|
18360 | Sticky,
|
18361 | SubmitBar,
|
18362 | Swipe,
|
18363 | SwipeCell,
|
18364 | SwipeItem,
|
18365 | Switch,
|
18366 | Tab,
|
18367 | Tabbar,
|
18368 | TabbarItem,
|
18369 | Tabs,
|
18370 | Tag,
|
18371 | TextEllipsis,
|
18372 | TimePicker,
|
18373 | Toast,
|
18374 | TreeSelect,
|
18375 | Uploader,
|
18376 | Watermark
|
18377 | ];
|
18378 | components.forEach((item) => {
|
18379 | if (item.install) {
|
18380 | app.use(item);
|
18381 | } else if (item.name) {
|
18382 | app.component(item.name, item);
|
18383 | }
|
18384 | });
|
18385 | }
|
18386 | var stdin_default = {
|
18387 | install,
|
18388 | version
|
18389 | };
|
18390 | exports2.ActionBar = ActionBar;
|
18391 | exports2.ActionBarButton = ActionBarButton;
|
18392 | exports2.ActionBarIcon = ActionBarIcon;
|
18393 | exports2.ActionSheet = ActionSheet;
|
18394 | exports2.AddressEdit = AddressEdit;
|
18395 | exports2.AddressList = AddressList;
|
18396 | exports2.Area = Area;
|
18397 | exports2.BackTop = BackTop;
|
18398 | exports2.Badge = Badge;
|
18399 | exports2.Barrage = Barrage;
|
18400 | exports2.Button = Button;
|
18401 | exports2.Calendar = Calendar;
|
18402 | exports2.Card = Card;
|
18403 | exports2.Cascader = Cascader;
|
18404 | exports2.Cell = Cell;
|
18405 | exports2.CellGroup = CellGroup;
|
18406 | exports2.Checkbox = Checkbox;
|
18407 | exports2.CheckboxGroup = CheckboxGroup;
|
18408 | exports2.Circle = Circle;
|
18409 | exports2.Col = Col;
|
18410 | exports2.Collapse = Collapse;
|
18411 | exports2.CollapseItem = CollapseItem;
|
18412 | exports2.ConfigProvider = ConfigProvider;
|
18413 | exports2.ContactCard = ContactCard;
|
18414 | exports2.ContactEdit = ContactEdit;
|
18415 | exports2.ContactList = ContactList;
|
18416 | exports2.CountDown = CountDown;
|
18417 | exports2.Coupon = Coupon;
|
18418 | exports2.CouponCell = CouponCell;
|
18419 | exports2.CouponList = CouponList;
|
18420 | exports2.DEFAULT_ROW_WIDTH = DEFAULT_ROW_WIDTH;
|
18421 | exports2.DatePicker = DatePicker;
|
18422 | exports2.Dialog = Dialog;
|
18423 | exports2.Divider = Divider;
|
18424 | exports2.DropdownItem = DropdownItem;
|
18425 | exports2.DropdownMenu = DropdownMenu;
|
18426 | exports2.Empty = Empty;
|
18427 | exports2.Field = Field;
|
18428 | exports2.FloatingBubble = FloatingBubble;
|
18429 | exports2.FloatingPanel = FloatingPanel;
|
18430 | exports2.Form = Form;
|
18431 | exports2.Grid = Grid;
|
18432 | exports2.GridItem = GridItem;
|
18433 | exports2.Highlight = Highlight;
|
18434 | exports2.Icon = Icon;
|
18435 | exports2.Image = Image$1;
|
18436 | exports2.ImagePreview = ImagePreview;
|
18437 | exports2.IndexAnchor = IndexAnchor;
|
18438 | exports2.IndexBar = IndexBar;
|
18439 | exports2.Lazyload = Lazyload;
|
18440 | exports2.List = List;
|
18441 | exports2.Loading = Loading;
|
18442 | exports2.Locale = Locale;
|
18443 | exports2.NavBar = NavBar;
|
18444 | exports2.NoticeBar = NoticeBar;
|
18445 | exports2.Notify = Notify;
|
18446 | exports2.NumberKeyboard = NumberKeyboard;
|
18447 | exports2.Overlay = Overlay;
|
18448 | exports2.Pagination = Pagination;
|
18449 | exports2.PasswordInput = PasswordInput;
|
18450 | exports2.Picker = Picker;
|
18451 | exports2.PickerGroup = PickerGroup;
|
18452 | exports2.Popover = Popover;
|
18453 | exports2.Popup = Popup;
|
18454 | exports2.Progress = Progress;
|
18455 | exports2.PullRefresh = PullRefresh;
|
18456 | exports2.Radio = Radio;
|
18457 | exports2.RadioGroup = RadioGroup;
|
18458 | exports2.Rate = Rate;
|
18459 | exports2.RollingText = RollingText;
|
18460 | exports2.Row = Row;
|
18461 | exports2.Search = Search;
|
18462 | exports2.ShareSheet = ShareSheet;
|
18463 | exports2.Sidebar = Sidebar;
|
18464 | exports2.SidebarItem = SidebarItem;
|
18465 | exports2.Signature = Signature;
|
18466 | exports2.Skeleton = Skeleton;
|
18467 | exports2.SkeletonAvatar = SkeletonAvatar;
|
18468 | exports2.SkeletonImage = SkeletonImage;
|
18469 | exports2.SkeletonParagraph = SkeletonParagraph;
|
18470 | exports2.SkeletonTitle = SkeletonTitle;
|
18471 | exports2.Slider = Slider;
|
18472 | exports2.Space = Space;
|
18473 | exports2.Step = Step;
|
18474 | exports2.Stepper = Stepper;
|
18475 | exports2.Steps = Steps;
|
18476 | exports2.Sticky = Sticky;
|
18477 | exports2.SubmitBar = SubmitBar;
|
18478 | exports2.Swipe = Swipe;
|
18479 | exports2.SwipeCell = SwipeCell;
|
18480 | exports2.SwipeItem = SwipeItem;
|
18481 | exports2.Switch = Switch;
|
18482 | exports2.Tab = Tab;
|
18483 | exports2.Tabbar = Tabbar;
|
18484 | exports2.TabbarItem = TabbarItem;
|
18485 | exports2.Tabs = Tabs;
|
18486 | exports2.Tag = Tag;
|
18487 | exports2.TextEllipsis = TextEllipsis;
|
18488 | exports2.TimePicker = TimePicker;
|
18489 | exports2.Toast = Toast;
|
18490 | exports2.TreeSelect = TreeSelect;
|
18491 | exports2.Uploader = Uploader;
|
18492 | exports2.Watermark = Watermark;
|
18493 | exports2.actionBarButtonProps = actionBarButtonProps;
|
18494 | exports2.actionBarIconProps = actionBarIconProps;
|
18495 | exports2.actionBarProps = actionBarProps;
|
18496 | exports2.actionSheetProps = actionSheetProps;
|
18497 | exports2.addressEditProps = addressEditProps;
|
18498 | exports2.addressListProps = addressListProps;
|
18499 | exports2.allowMultipleToast = allowMultipleToast;
|
18500 | exports2.areaProps = areaProps;
|
18501 | exports2.backTopProps = backTopProps;
|
18502 | exports2.badgeProps = badgeProps;
|
18503 | exports2.barrageProps = barrageProps;
|
18504 | exports2.buttonProps = buttonProps;
|
18505 | exports2.calendarProps = calendarProps;
|
18506 | exports2.cardProps = cardProps;
|
18507 | exports2.cascaderProps = cascaderProps;
|
18508 | exports2.cellGroupProps = cellGroupProps;
|
18509 | exports2.cellProps = cellProps;
|
18510 | exports2.checkboxGroupProps = checkboxGroupProps;
|
18511 | exports2.checkboxProps = checkboxProps;
|
18512 | exports2.circleProps = circleProps;
|
18513 | exports2.closeDialog = closeDialog;
|
18514 | exports2.closeNotify = closeNotify;
|
18515 | exports2.closeToast = closeToast;
|
18516 | exports2.colProps = colProps;
|
18517 | exports2.collapseItemProps = collapseItemProps;
|
18518 | exports2.collapseProps = collapseProps;
|
18519 | exports2.configProviderProps = configProviderProps;
|
18520 | exports2.contactCardProps = contactCardProps;
|
18521 | exports2.contactEditProps = contactEditProps;
|
18522 | exports2.contactListProps = contactListProps;
|
18523 | exports2.countDownProps = countDownProps;
|
18524 | exports2.couponCellProps = couponCellProps;
|
18525 | exports2.couponListProps = couponListProps;
|
18526 | exports2.datePickerProps = datePickerProps;
|
18527 | exports2.default = stdin_default;
|
18528 | exports2.dialogProps = dialogProps;
|
18529 | exports2.dividerProps = dividerProps;
|
18530 | exports2.dropdownItemProps = dropdownItemProps;
|
18531 | exports2.dropdownMenuProps = dropdownMenuProps;
|
18532 | exports2.emptyProps = emptyProps;
|
18533 | exports2.fieldProps = fieldProps;
|
18534 | exports2.floatingBubbleProps = floatingBubbleProps;
|
18535 | exports2.floatingPanelProps = floatingPanelProps;
|
18536 | exports2.formProps = formProps;
|
18537 | exports2.gridItemProps = gridItemProps;
|
18538 | exports2.gridProps = gridProps;
|
18539 | exports2.highlightProps = highlightProps;
|
18540 | exports2.iconProps = iconProps;
|
18541 | exports2.imagePreviewProps = imagePreviewProps;
|
18542 | exports2.imageProps = imageProps;
|
18543 | exports2.indexAnchorProps = indexAnchorProps;
|
18544 | exports2.indexBarProps = indexBarProps;
|
18545 | exports2.install = install;
|
18546 | exports2.listProps = listProps;
|
18547 | exports2.loadingProps = loadingProps;
|
18548 | exports2.navBarProps = navBarProps;
|
18549 | exports2.noticeBarProps = noticeBarProps;
|
18550 | exports2.notifyProps = notifyProps;
|
18551 | exports2.numberKeyboardProps = numberKeyboardProps;
|
18552 | exports2.overlayProps = overlayProps;
|
18553 | exports2.paginationProps = paginationProps;
|
18554 | exports2.passwordInputProps = passwordInputProps;
|
18555 | exports2.pickerGroupProps = pickerGroupProps;
|
18556 | exports2.pickerProps = pickerProps;
|
18557 | exports2.popoverProps = popoverProps;
|
18558 | exports2.popupProps = popupProps$2;
|
18559 | exports2.progressProps = progressProps;
|
18560 | exports2.pullRefreshProps = pullRefreshProps;
|
18561 | exports2.radioGroupProps = radioGroupProps;
|
18562 | exports2.radioProps = radioProps;
|
18563 | exports2.rateProps = rateProps;
|
18564 | exports2.resetDialogDefaultOptions = resetDialogDefaultOptions;
|
18565 | exports2.resetNotifyDefaultOptions = resetNotifyDefaultOptions;
|
18566 | exports2.resetToastDefaultOptions = resetToastDefaultOptions;
|
18567 | exports2.rollingTextProps = rollingTextProps;
|
18568 | exports2.rowProps = rowProps;
|
18569 | exports2.searchProps = searchProps;
|
18570 | exports2.setDialogDefaultOptions = setDialogDefaultOptions;
|
18571 | exports2.setNotifyDefaultOptions = setNotifyDefaultOptions;
|
18572 | exports2.setToastDefaultOptions = setToastDefaultOptions;
|
18573 | exports2.shareSheetProps = shareSheetProps;
|
18574 | exports2.showConfirmDialog = showConfirmDialog;
|
18575 | exports2.showDialog = showDialog;
|
18576 | exports2.showFailToast = showFailToast;
|
18577 | exports2.showImagePreview = showImagePreview;
|
18578 | exports2.showLoadingToast = showLoadingToast;
|
18579 | exports2.showNotify = showNotify;
|
18580 | exports2.showSuccessToast = showSuccessToast;
|
18581 | exports2.showToast = showToast;
|
18582 | exports2.sidebarItemProps = sidebarItemProps;
|
18583 | exports2.sidebarProps = sidebarProps;
|
18584 | exports2.skeletonAvatarProps = skeletonAvatarProps;
|
18585 | exports2.skeletonImageProps = skeletonImageProps;
|
18586 | exports2.skeletonParagraphProps = skeletonParagraphProps;
|
18587 | exports2.skeletonProps = skeletonProps;
|
18588 | exports2.skeletonTitleProps = skeletonTitleProps;
|
18589 | exports2.sliderProps = sliderProps;
|
18590 | exports2.spaceProps = spaceProps;
|
18591 | exports2.stepperProps = stepperProps;
|
18592 | exports2.stepsProps = stepsProps;
|
18593 | exports2.stickyProps = stickyProps;
|
18594 | exports2.submitBarProps = submitBarProps;
|
18595 | exports2.swipeCellProps = swipeCellProps;
|
18596 | exports2.swipeProps = swipeProps;
|
18597 | exports2.switchProps = switchProps;
|
18598 | exports2.tabProps = tabProps;
|
18599 | exports2.tabbarItemProps = tabbarItemProps;
|
18600 | exports2.tabbarProps = tabbarProps;
|
18601 | exports2.tabsProps = tabsProps;
|
18602 | exports2.tagProps = tagProps;
|
18603 | exports2.textEllipsisProps = textEllipsisProps;
|
18604 | exports2.timePickerProps = timePickerProps;
|
18605 | exports2.toastProps = toastProps;
|
18606 | exports2.treeSelectProps = treeSelectProps;
|
18607 | exports2.uploaderProps = uploaderProps;
|
18608 | exports2.useCurrentLang = useCurrentLang;
|
18609 | exports2.version = version;
|
18610 | exports2.watermarkProps = watermarkProps;
|
18611 | Object.defineProperties(exports2, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
18612 | });
|