1 | "use strict";
|
2 | Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
3 | const vue = require("vue");
|
4 | const use = require("@vant/use");
|
5 | const shared = require("@vue/shared");
|
6 | const popperjs = require("@vant/popperjs");
|
7 | function noop() {
|
8 | }
|
9 | const extend = Object.assign;
|
10 | const inBrowser = typeof window !== "undefined";
|
11 | const isObject = (val) => val !== null && typeof val === "object";
|
12 | const isDef = (val) => val !== void 0 && val !== null;
|
13 | const isFunction = (val) => typeof val === "function";
|
14 | const isPromise = (val) => isObject(val) && isFunction(val.then) && isFunction(val.catch);
|
15 | const isDate = (val) => Object.prototype.toString.call(val) === "[object Date]" && !Number.isNaN(val.getTime());
|
16 | function isMobile(value) {
|
17 | value = value.replace(/[^-|\d]/g, "");
|
18 | return /^((\+86)|(86))?(1)\d{10}$/.test(value) || /^0[0-9-]{10,13}$/.test(value);
|
19 | }
|
20 | const isNumeric = (val) => typeof val === "number" || /^\d+(\.\d+)?$/.test(val);
|
21 | const isIOS$1 = () => inBrowser ? /ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase()) : false;
|
22 | function get(object, path) {
|
23 | const keys = path.split(".");
|
24 | let result = object;
|
25 | keys.forEach((key) => {
|
26 | var _a;
|
27 | result = isObject(result) ? (_a = result[key]) != null ? _a : "" : "";
|
28 | });
|
29 | return result;
|
30 | }
|
31 | function pick(obj, keys, ignoreUndefined) {
|
32 | return keys.reduce(
|
33 | (ret, key) => {
|
34 | if (!ignoreUndefined || obj[key] !== void 0) {
|
35 | ret[key] = obj[key];
|
36 | }
|
37 | return ret;
|
38 | },
|
39 | {}
|
40 | );
|
41 | }
|
42 | const isSameValue = (newValue, oldValue) => JSON.stringify(newValue) === JSON.stringify(oldValue);
|
43 | const toArray = (item) => Array.isArray(item) ? item : [item];
|
44 | const flat = (arr) => arr.reduce((acc, val) => acc.concat(val), []);
|
45 | const unknownProp = null;
|
46 | const numericProp = [Number, String];
|
47 | const truthProp = {
|
48 | type: Boolean,
|
49 | default: true
|
50 | };
|
51 | const makeRequiredProp = (type) => ({
|
52 | type,
|
53 | required: true
|
54 | });
|
55 | const makeArrayProp = () => ({
|
56 | type: Array,
|
57 | default: () => []
|
58 | });
|
59 | const makeNumberProp = (defaultVal) => ({
|
60 | type: Number,
|
61 | default: defaultVal
|
62 | });
|
63 | const makeNumericProp = (defaultVal) => ({
|
64 | type: numericProp,
|
65 | default: defaultVal
|
66 | });
|
67 | const makeStringProp = (defaultVal) => ({
|
68 | type: String,
|
69 | default: defaultVal
|
70 | });
|
71 | function getScrollTop(el) {
|
72 | const top = "scrollTop" in el ? el.scrollTop : el.pageYOffset;
|
73 | return Math.max(top, 0);
|
74 | }
|
75 | function setScrollTop(el, value) {
|
76 | if ("scrollTop" in el) {
|
77 | el.scrollTop = value;
|
78 | } else {
|
79 | el.scrollTo(el.scrollX, value);
|
80 | }
|
81 | }
|
82 | function getRootScrollTop() {
|
83 | return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
|
84 | }
|
85 | function setRootScrollTop(value) {
|
86 | setScrollTop(window, value);
|
87 | setScrollTop(document.body, value);
|
88 | }
|
89 | function getElementTop(el, scroller) {
|
90 | if (el === window) {
|
91 | return 0;
|
92 | }
|
93 | const scrollTop = scroller ? getScrollTop(scroller) : getRootScrollTop();
|
94 | return use.useRect(el).top + scrollTop;
|
95 | }
|
96 | const isIOS = isIOS$1();
|
97 | function resetScroll() {
|
98 | if (isIOS) {
|
99 | setRootScrollTop(getRootScrollTop());
|
100 | }
|
101 | }
|
102 | const stopPropagation = (event) => event.stopPropagation();
|
103 | function preventDefault(event, isStopPropagation) {
|
104 | if (typeof event.cancelable !== "boolean" || event.cancelable) {
|
105 | event.preventDefault();
|
106 | }
|
107 | if (isStopPropagation) {
|
108 | stopPropagation(event);
|
109 | }
|
110 | }
|
111 | function isHidden(elementRef) {
|
112 | const el = vue.unref(elementRef);
|
113 | if (!el) {
|
114 | return false;
|
115 | }
|
116 | const style = window.getComputedStyle(el);
|
117 | const hidden = style.display === "none";
|
118 | const parentHidden = el.offsetParent === null && style.position !== "fixed";
|
119 | return hidden || parentHidden;
|
120 | }
|
121 | const { width: windowWidth, height: windowHeight } = use.useWindowSize();
|
122 | function isContainingBlock(el) {
|
123 | const css = window.getComputedStyle(el);
|
124 | return css.transform !== "none" || css.perspective !== "none" || ["transform", "perspective", "filter"].some(
|
125 | (value) => (css.willChange || "").includes(value)
|
126 | );
|
127 | }
|
128 | function getContainingBlock(el) {
|
129 | let node = el.parentElement;
|
130 | while (node) {
|
131 | if (node && node.tagName !== "HTML" && node.tagName !== "BODY" && isContainingBlock(node)) {
|
132 | return node;
|
133 | }
|
134 | node = node.parentElement;
|
135 | }
|
136 | return null;
|
137 | }
|
138 | function addUnit(value) {
|
139 | if (isDef(value)) {
|
140 | return isNumeric(value) ? `${value}px` : String(value);
|
141 | }
|
142 | return void 0;
|
143 | }
|
144 | function getSizeStyle(originSize) {
|
145 | if (isDef(originSize)) {
|
146 | if (Array.isArray(originSize)) {
|
147 | return {
|
148 | width: addUnit(originSize[0]),
|
149 | height: addUnit(originSize[1])
|
150 | };
|
151 | }
|
152 | const size = addUnit(originSize);
|
153 | return {
|
154 | width: size,
|
155 | height: size
|
156 | };
|
157 | }
|
158 | }
|
159 | function getZIndexStyle(zIndex) {
|
160 | const style = {};
|
161 | if (zIndex !== void 0) {
|
162 | style.zIndex = +zIndex;
|
163 | }
|
164 | return style;
|
165 | }
|
166 | let rootFontSize;
|
167 | function getRootFontSize() {
|
168 | if (!rootFontSize) {
|
169 | const doc = document.documentElement;
|
170 | const fontSize = doc.style.fontSize || window.getComputedStyle(doc).fontSize;
|
171 | rootFontSize = parseFloat(fontSize);
|
172 | }
|
173 | return rootFontSize;
|
174 | }
|
175 | function convertRem(value) {
|
176 | value = value.replace(/rem/g, "");
|
177 | return +value * getRootFontSize();
|
178 | }
|
179 | function convertVw(value) {
|
180 | value = value.replace(/vw/g, "");
|
181 | return +value * windowWidth.value / 100;
|
182 | }
|
183 | function convertVh(value) {
|
184 | value = value.replace(/vh/g, "");
|
185 | return +value * windowHeight.value / 100;
|
186 | }
|
187 | function unitToPx(value) {
|
188 | if (typeof value === "number") {
|
189 | return value;
|
190 | }
|
191 | if (inBrowser) {
|
192 | if (value.includes("rem")) {
|
193 | return convertRem(value);
|
194 | }
|
195 | if (value.includes("vw")) {
|
196 | return convertVw(value);
|
197 | }
|
198 | if (value.includes("vh")) {
|
199 | return convertVh(value);
|
200 | }
|
201 | }
|
202 | return parseFloat(value);
|
203 | }
|
204 | const camelizeRE = /-(\w)/g;
|
205 | const camelize = (str) => str.replace(camelizeRE, (_, c) => c.toUpperCase());
|
206 | const kebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase().replace(/^-/, "");
|
207 | function padZero(num, targetLength = 2) {
|
208 | let str = num + "";
|
209 | while (str.length < targetLength) {
|
210 | str = "0" + str;
|
211 | }
|
212 | return str;
|
213 | }
|
214 | const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
|
215 | function trimExtraChar(value, char, regExp) {
|
216 | const index = value.indexOf(char);
|
217 | if (index === -1) {
|
218 | return value;
|
219 | }
|
220 | if (char === "-" && index !== 0) {
|
221 | return value.slice(0, index);
|
222 | }
|
223 | return value.slice(0, index + 1) + value.slice(index).replace(regExp, "");
|
224 | }
|
225 | function formatNumber(value, allowDot = true, allowMinus = true) {
|
226 | if (allowDot) {
|
227 | value = trimExtraChar(value, ".", /\./g);
|
228 | } else {
|
229 | value = value.split(".")[0];
|
230 | }
|
231 | if (allowMinus) {
|
232 | value = trimExtraChar(value, "-", /-/g);
|
233 | } else {
|
234 | value = value.replace(/-/, "");
|
235 | }
|
236 | const regExp = allowDot ? /[^-0-9.]/g : /[^-0-9]/g;
|
237 | return value.replace(regExp, "");
|
238 | }
|
239 | function addNumber(num1, num2) {
|
240 | const cardinal = 10 ** 10;
|
241 | return Math.round((num1 + num2) * cardinal) / cardinal;
|
242 | }
|
243 | const { hasOwnProperty } = Object.prototype;
|
244 | function assignKey(to, from, key) {
|
245 | const val = from[key];
|
246 | if (!isDef(val)) {
|
247 | return;
|
248 | }
|
249 | if (!hasOwnProperty.call(to, key) || !isObject(val)) {
|
250 | to[key] = val;
|
251 | } else {
|
252 | to[key] = deepAssign(Object(to[key]), val);
|
253 | }
|
254 | }
|
255 | function deepAssign(to, from) {
|
256 | Object.keys(from).forEach((key) => {
|
257 | assignKey(to, from, key);
|
258 | });
|
259 | return to;
|
260 | }
|
261 | var stdin_default$1W = {
|
262 | name: "姓名",
|
263 | tel: "电话",
|
264 | save: "保存",
|
265 | clear: "清空",
|
266 | cancel: "取消",
|
267 | confirm: "确认",
|
268 | delete: "删除",
|
269 | loading: "加载中...",
|
270 | noCoupon: "暂无优惠券",
|
271 | nameEmpty: "请填写姓名",
|
272 | addContact: "添加联系人",
|
273 | telInvalid: "请填写正确的电话",
|
274 | vanCalendar: {
|
275 | end: "结束",
|
276 | start: "开始",
|
277 | title: "日期选择",
|
278 | weekdays: ["日", "一", "二", "三", "四", "五", "六"],
|
279 | monthTitle: (year, month) => `${year}年${month}月`,
|
280 | rangePrompt: (maxRange) => `最多选择 ${maxRange} 天`
|
281 | },
|
282 | vanCascader: {
|
283 | select: "请选择"
|
284 | },
|
285 | vanPagination: {
|
286 | prev: "上一页",
|
287 | next: "下一页"
|
288 | },
|
289 | vanPullRefresh: {
|
290 | pulling: "下拉即可刷新...",
|
291 | loosing: "释放即可刷新..."
|
292 | },
|
293 | vanSubmitBar: {
|
294 | label: "合计:"
|
295 | },
|
296 | vanCoupon: {
|
297 | unlimited: "无门槛",
|
298 | discount: (discount) => `${discount}折`,
|
299 | condition: (condition) => `满${condition}元可用`
|
300 | },
|
301 | vanCouponCell: {
|
302 | title: "优惠券",
|
303 | count: (count) => `${count}张可用`
|
304 | },
|
305 | vanCouponList: {
|
306 | exchange: "兑换",
|
307 | close: "不使用",
|
308 | enable: "可用",
|
309 | disabled: "不可用",
|
310 | placeholder: "输入优惠码"
|
311 | },
|
312 | vanAddressEdit: {
|
313 | area: "地区",
|
314 | areaEmpty: "请选择地区",
|
315 | addressEmpty: "请填写详细地址",
|
316 | addressDetail: "详细地址",
|
317 | defaultAddress: "设为默认收货地址"
|
318 | },
|
319 | vanAddressList: {
|
320 | add: "新增地址"
|
321 | }
|
322 | };
|
323 | const lang = vue.ref("zh-CN");
|
324 | const messages = vue.reactive({
|
325 | "zh-CN": stdin_default$1W
|
326 | });
|
327 | const Locale = {
|
328 | messages() {
|
329 | return messages[lang.value];
|
330 | },
|
331 | use(newLang, newMessages) {
|
332 | lang.value = newLang;
|
333 | this.add({ [newLang]: newMessages });
|
334 | },
|
335 | add(newMessages = {}) {
|
336 | deepAssign(messages, newMessages);
|
337 | }
|
338 | };
|
339 | const useCurrentLang = () => lang;
|
340 | var stdin_default$1V = Locale;
|
341 | function createTranslate(name2) {
|
342 | const prefix = camelize(name2) + ".";
|
343 | return (path, ...args) => {
|
344 | const messages2 = stdin_default$1V.messages();
|
345 | const message = get(messages2, prefix + path) || get(messages2, path);
|
346 | return isFunction(message) ? message(...args) : message;
|
347 | };
|
348 | }
|
349 | function genBem(name2, mods) {
|
350 | if (!mods) {
|
351 | return "";
|
352 | }
|
353 | if (typeof mods === "string") {
|
354 | return ` ${name2}--${mods}`;
|
355 | }
|
356 | if (Array.isArray(mods)) {
|
357 | return mods.reduce(
|
358 | (ret, item) => ret + genBem(name2, item),
|
359 | ""
|
360 | );
|
361 | }
|
362 | return Object.keys(mods).reduce(
|
363 | (ret, key) => ret + (mods[key] ? genBem(name2, key) : ""),
|
364 | ""
|
365 | );
|
366 | }
|
367 | function createBEM(name2) {
|
368 | return (el, mods) => {
|
369 | if (el && typeof el !== "string") {
|
370 | mods = el;
|
371 | el = "";
|
372 | }
|
373 | el = el ? `${name2}__${el}` : name2;
|
374 | return `${el}${genBem(el, mods)}`;
|
375 | };
|
376 | }
|
377 | function createNamespace(name2) {
|
378 | const prefixedName = `van-${name2}`;
|
379 | return [
|
380 | prefixedName,
|
381 | createBEM(prefixedName),
|
382 | createTranslate(prefixedName)
|
383 | ];
|
384 | }
|
385 | const BORDER = "van-hairline";
|
386 | const BORDER_TOP = `${BORDER}--top`;
|
387 | const BORDER_LEFT = `${BORDER}--left`;
|
388 | const BORDER_RIGHT = `${BORDER}--right`;
|
389 | const BORDER_BOTTOM = `${BORDER}--bottom`;
|
390 | const BORDER_SURROUND = `${BORDER}--surround`;
|
391 | const BORDER_TOP_BOTTOM = `${BORDER}--top-bottom`;
|
392 | const BORDER_UNSET_TOP_BOTTOM = `${BORDER}-unset--top-bottom`;
|
393 | const HAPTICS_FEEDBACK = "van-haptics-feedback";
|
394 | const FORM_KEY = Symbol("van-form");
|
395 | const LONG_PRESS_START_TIME = 500;
|
396 | const TAP_OFFSET = 5;
|
397 | function callInterceptor(interceptor, {
|
398 | args = [],
|
399 | done,
|
400 | canceled,
|
401 | error
|
402 | }) {
|
403 | if (interceptor) {
|
404 | const returnVal = interceptor.apply(null, args);
|
405 | if (isPromise(returnVal)) {
|
406 | returnVal.then((value) => {
|
407 | if (value) {
|
408 | done();
|
409 | } else if (canceled) {
|
410 | canceled();
|
411 | }
|
412 | }).catch(error || noop);
|
413 | } else if (returnVal) {
|
414 | done();
|
415 | } else if (canceled) {
|
416 | canceled();
|
417 | }
|
418 | } else {
|
419 | done();
|
420 | }
|
421 | }
|
422 | function withInstall(options) {
|
423 | options.install = (app) => {
|
424 | const { name: name2 } = options;
|
425 | if (name2) {
|
426 | app.component(name2, options);
|
427 | app.component(camelize(`-${name2}`), options);
|
428 | }
|
429 | };
|
430 | return options;
|
431 | }
|
432 | function closest(arr, target) {
|
433 | return arr.reduce(
|
434 | (pre, cur) => Math.abs(pre - target) < Math.abs(cur - target) ? pre : cur
|
435 | );
|
436 | }
|
437 | const POPUP_TOGGLE_KEY = Symbol();
|
438 | function onPopupReopen(callback) {
|
439 | const popupToggleStatus = vue.inject(POPUP_TOGGLE_KEY, null);
|
440 | if (popupToggleStatus) {
|
441 | vue.watch(popupToggleStatus, (show) => {
|
442 | if (show) {
|
443 | callback();
|
444 | }
|
445 | });
|
446 | }
|
447 | }
|
448 | const useHeight = (element, withSafeArea) => {
|
449 | const height = vue.ref();
|
450 | const setHeight = () => {
|
451 | height.value = use.useRect(element).height;
|
452 | };
|
453 | vue.onMounted(() => {
|
454 | vue.nextTick(setHeight);
|
455 | if (withSafeArea) {
|
456 | for (let i = 1; i <= 3; i++) {
|
457 | setTimeout(setHeight, 100 * i);
|
458 | }
|
459 | }
|
460 | });
|
461 | onPopupReopen(() => vue.nextTick(setHeight));
|
462 | vue.watch([windowWidth, windowHeight], setHeight);
|
463 | return height;
|
464 | };
|
465 | function usePlaceholder(contentRef, bem2) {
|
466 | const height = useHeight(contentRef, true);
|
467 | return (renderContent) => vue.createVNode("div", {
|
468 | "class": bem2("placeholder"),
|
469 | "style": {
|
470 | height: height.value ? `${height.value}px` : void 0
|
471 | }
|
472 | }, [renderContent()]);
|
473 | }
|
474 | const [name$1K, bem$1F] = createNamespace("action-bar");
|
475 | const ACTION_BAR_KEY = Symbol(name$1K);
|
476 | const actionBarProps = {
|
477 | placeholder: Boolean,
|
478 | safeAreaInsetBottom: truthProp
|
479 | };
|
480 | var stdin_default$1U = vue.defineComponent({
|
481 | name: name$1K,
|
482 | props: actionBarProps,
|
483 | setup(props2, {
|
484 | slots
|
485 | }) {
|
486 | const root = vue.ref();
|
487 | const renderPlaceholder = usePlaceholder(root, bem$1F);
|
488 | const {
|
489 | linkChildren
|
490 | } = use.useChildren(ACTION_BAR_KEY);
|
491 | linkChildren();
|
492 | const renderActionBar = () => {
|
493 | var _a;
|
494 | return vue.createVNode("div", {
|
495 | "ref": root,
|
496 | "class": [bem$1F(), {
|
497 | "van-safe-area-bottom": props2.safeAreaInsetBottom
|
498 | }]
|
499 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
500 | };
|
501 | return () => {
|
502 | if (props2.placeholder) {
|
503 | return renderPlaceholder(renderActionBar);
|
504 | }
|
505 | return renderActionBar();
|
506 | };
|
507 | }
|
508 | });
|
509 | const ActionBar = withInstall(stdin_default$1U);
|
510 | function useExpose(apis) {
|
511 | const instance2 = vue.getCurrentInstance();
|
512 | if (instance2) {
|
513 | extend(instance2.proxy, apis);
|
514 | }
|
515 | }
|
516 | const routeProps = {
|
517 | to: [String, Object],
|
518 | url: String,
|
519 | replace: Boolean
|
520 | };
|
521 | function route({
|
522 | to,
|
523 | url,
|
524 | replace,
|
525 | $router: router
|
526 | }) {
|
527 | if (to && router) {
|
528 | router[replace ? "replace" : "push"](to);
|
529 | } else if (url) {
|
530 | replace ? location.replace(url) : location.href = url;
|
531 | }
|
532 | }
|
533 | function useRoute() {
|
534 | const vm = vue.getCurrentInstance().proxy;
|
535 | return () => route(vm);
|
536 | }
|
537 | const [name$1J, bem$1E] = createNamespace("badge");
|
538 | const badgeProps = {
|
539 | dot: Boolean,
|
540 | max: numericProp,
|
541 | tag: makeStringProp("div"),
|
542 | color: String,
|
543 | offset: Array,
|
544 | content: numericProp,
|
545 | showZero: truthProp,
|
546 | position: makeStringProp("top-right")
|
547 | };
|
548 | var stdin_default$1T = vue.defineComponent({
|
549 | name: name$1J,
|
550 | props: badgeProps,
|
551 | setup(props2, {
|
552 | slots
|
553 | }) {
|
554 | const hasContent = () => {
|
555 | if (slots.content) {
|
556 | return true;
|
557 | }
|
558 | const {
|
559 | content,
|
560 | showZero
|
561 | } = props2;
|
562 | return isDef(content) && content !== "" && (showZero || content !== 0 && content !== "0");
|
563 | };
|
564 | const renderContent = () => {
|
565 | const {
|
566 | dot,
|
567 | max,
|
568 | content
|
569 | } = props2;
|
570 | if (!dot && hasContent()) {
|
571 | if (slots.content) {
|
572 | return slots.content();
|
573 | }
|
574 | if (isDef(max) && isNumeric(content) && +content > +max) {
|
575 | return `${max}+`;
|
576 | }
|
577 | return content;
|
578 | }
|
579 | };
|
580 | const getOffsetWithMinusString = (val) => val.startsWith("-") ? val.replace("-", "") : `-${val}`;
|
581 | const style = vue.computed(() => {
|
582 | const style2 = {
|
583 | background: props2.color
|
584 | };
|
585 | if (props2.offset) {
|
586 | const [x, y] = props2.offset;
|
587 | const {
|
588 | position
|
589 | } = props2;
|
590 | const [offsetY, offsetX] = position.split("-");
|
591 | if (slots.default) {
|
592 | if (typeof y === "number") {
|
593 | style2[offsetY] = addUnit(offsetY === "top" ? y : -y);
|
594 | } else {
|
595 | style2[offsetY] = offsetY === "top" ? addUnit(y) : getOffsetWithMinusString(y);
|
596 | }
|
597 | if (typeof x === "number") {
|
598 | style2[offsetX] = addUnit(offsetX === "left" ? x : -x);
|
599 | } else {
|
600 | style2[offsetX] = offsetX === "left" ? addUnit(x) : getOffsetWithMinusString(x);
|
601 | }
|
602 | } else {
|
603 | style2.marginTop = addUnit(y);
|
604 | style2.marginLeft = addUnit(x);
|
605 | }
|
606 | }
|
607 | return style2;
|
608 | });
|
609 | const renderBadge = () => {
|
610 | if (hasContent() || props2.dot) {
|
611 | return vue.createVNode("div", {
|
612 | "class": bem$1E([props2.position, {
|
613 | dot: props2.dot,
|
614 | fixed: !!slots.default
|
615 | }]),
|
616 | "style": style.value
|
617 | }, [renderContent()]);
|
618 | }
|
619 | };
|
620 | return () => {
|
621 | if (slots.default) {
|
622 | const {
|
623 | tag
|
624 | } = props2;
|
625 | return vue.createVNode(tag, {
|
626 | "class": bem$1E("wrapper")
|
627 | }, {
|
628 | default: () => [slots.default(), renderBadge()]
|
629 | });
|
630 | }
|
631 | return renderBadge();
|
632 | };
|
633 | }
|
634 | });
|
635 | const Badge = withInstall(stdin_default$1T);
|
636 | let globalZIndex = 2e3;
|
637 | const useGlobalZIndex = () => ++globalZIndex;
|
638 | const setGlobalZIndex = (val) => {
|
639 | globalZIndex = val;
|
640 | };
|
641 | const [name$1I, bem$1D] = createNamespace("config-provider");
|
642 | const CONFIG_PROVIDER_KEY = Symbol(name$1I);
|
643 | const configProviderProps = {
|
644 | tag: makeStringProp("div"),
|
645 | theme: makeStringProp("light"),
|
646 | zIndex: Number,
|
647 | themeVars: Object,
|
648 | themeVarsDark: Object,
|
649 | themeVarsLight: Object,
|
650 | themeVarsScope: makeStringProp("local"),
|
651 | iconPrefix: String
|
652 | };
|
653 | function insertDash(str) {
|
654 | return str.replace(/([a-zA-Z])(\d)/g, "$1-$2");
|
655 | }
|
656 | function mapThemeVarsToCSSVars(themeVars) {
|
657 | const cssVars = {};
|
658 | Object.keys(themeVars).forEach((key) => {
|
659 | const formattedKey = insertDash(kebabCase(key));
|
660 | cssVars[`--van-${formattedKey}`] = themeVars[key];
|
661 | });
|
662 | return cssVars;
|
663 | }
|
664 | function syncThemeVarsOnRoot(newStyle = {}, oldStyle = {}) {
|
665 | Object.keys(newStyle).forEach((key) => {
|
666 | if (newStyle[key] !== oldStyle[key]) {
|
667 | document.documentElement.style.setProperty(key, newStyle[key]);
|
668 | }
|
669 | });
|
670 | Object.keys(oldStyle).forEach((key) => {
|
671 | if (!newStyle[key]) {
|
672 | document.documentElement.style.removeProperty(key);
|
673 | }
|
674 | });
|
675 | }
|
676 | var stdin_default$1S = vue.defineComponent({
|
677 | name: name$1I,
|
678 | props: configProviderProps,
|
679 | setup(props2, {
|
680 | slots
|
681 | }) {
|
682 | const style = vue.computed(() => mapThemeVarsToCSSVars(extend({}, props2.themeVars, props2.theme === "dark" ? props2.themeVarsDark : props2.themeVarsLight)));
|
683 | if (inBrowser) {
|
684 | const addTheme = () => {
|
685 | document.documentElement.classList.add(`van-theme-${props2.theme}`);
|
686 | };
|
687 | const removeTheme = (theme = props2.theme) => {
|
688 | document.documentElement.classList.remove(`van-theme-${theme}`);
|
689 | };
|
690 | vue.watch(() => props2.theme, (newVal, oldVal) => {
|
691 | if (oldVal) {
|
692 | removeTheme(oldVal);
|
693 | }
|
694 | addTheme();
|
695 | }, {
|
696 | immediate: true
|
697 | });
|
698 | vue.onActivated(addTheme);
|
699 | vue.onDeactivated(removeTheme);
|
700 | vue.onBeforeUnmount(removeTheme);
|
701 | vue.watch(style, (newStyle, oldStyle) => {
|
702 | if (props2.themeVarsScope === "global") {
|
703 | syncThemeVarsOnRoot(newStyle, oldStyle);
|
704 | }
|
705 | });
|
706 | vue.watch(() => props2.themeVarsScope, (newScope, oldScope) => {
|
707 | if (oldScope === "global") {
|
708 | syncThemeVarsOnRoot({}, style.value);
|
709 | }
|
710 | if (newScope === "global") {
|
711 | syncThemeVarsOnRoot(style.value, {});
|
712 | }
|
713 | });
|
714 | if (props2.themeVarsScope === "global") {
|
715 | syncThemeVarsOnRoot(style.value, {});
|
716 | }
|
717 | }
|
718 | vue.provide(CONFIG_PROVIDER_KEY, props2);
|
719 | vue.watchEffect(() => {
|
720 | if (props2.zIndex !== void 0) {
|
721 | setGlobalZIndex(props2.zIndex);
|
722 | }
|
723 | });
|
724 | return () => vue.createVNode(props2.tag, {
|
725 | "class": bem$1D(),
|
726 | "style": props2.themeVarsScope === "local" ? style.value : void 0
|
727 | }, {
|
728 | default: () => {
|
729 | var _a;
|
730 | return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
|
731 | }
|
732 | });
|
733 | }
|
734 | });
|
735 | const [name$1H, bem$1C] = createNamespace("icon");
|
736 | const isImage$1 = (name2) => name2 == null ? void 0 : name2.includes("/");
|
737 | const iconProps = {
|
738 | dot: Boolean,
|
739 | tag: makeStringProp("i"),
|
740 | name: String,
|
741 | size: numericProp,
|
742 | badge: numericProp,
|
743 | color: String,
|
744 | badgeProps: Object,
|
745 | classPrefix: String
|
746 | };
|
747 | var stdin_default$1R = vue.defineComponent({
|
748 | name: name$1H,
|
749 | props: iconProps,
|
750 | setup(props2, {
|
751 | slots
|
752 | }) {
|
753 | const config = vue.inject(CONFIG_PROVIDER_KEY, null);
|
754 | const classPrefix = vue.computed(() => props2.classPrefix || (config == null ? void 0 : config.iconPrefix) || bem$1C());
|
755 | return () => {
|
756 | const {
|
757 | tag,
|
758 | dot,
|
759 | name: name2,
|
760 | size,
|
761 | badge,
|
762 | color
|
763 | } = props2;
|
764 | const isImageIcon = isImage$1(name2);
|
765 | return vue.createVNode(Badge, vue.mergeProps({
|
766 | "dot": dot,
|
767 | "tag": tag,
|
768 | "class": [classPrefix.value, isImageIcon ? "" : `${classPrefix.value}-${name2}`],
|
769 | "style": {
|
770 | color,
|
771 | fontSize: addUnit(size)
|
772 | },
|
773 | "content": badge
|
774 | }, props2.badgeProps), {
|
775 | default: () => {
|
776 | var _a;
|
777 | return [(_a = slots.default) == null ? void 0 : _a.call(slots), isImageIcon && vue.createVNode("img", {
|
778 | "class": bem$1C("image"),
|
779 | "src": name2
|
780 | }, null)];
|
781 | }
|
782 | });
|
783 | };
|
784 | }
|
785 | });
|
786 | const Icon = withInstall(stdin_default$1R);
|
787 | var stdin_default$1Q = Icon;
|
788 | const [name$1G, bem$1B] = createNamespace("loading");
|
789 | const SpinIcon = Array(12).fill(null).map((_, index) => vue.createVNode("i", {
|
790 | "class": bem$1B("line", String(index + 1))
|
791 | }, null));
|
792 | const CircularIcon = vue.createVNode("svg", {
|
793 | "class": bem$1B("circular"),
|
794 | "viewBox": "25 25 50 50"
|
795 | }, [vue.createVNode("circle", {
|
796 | "cx": "50",
|
797 | "cy": "50",
|
798 | "r": "20",
|
799 | "fill": "none"
|
800 | }, null)]);
|
801 | const loadingProps = {
|
802 | size: numericProp,
|
803 | type: makeStringProp("circular"),
|
804 | color: String,
|
805 | vertical: Boolean,
|
806 | textSize: numericProp,
|
807 | textColor: String
|
808 | };
|
809 | var stdin_default$1P = vue.defineComponent({
|
810 | name: name$1G,
|
811 | props: loadingProps,
|
812 | setup(props2, {
|
813 | slots
|
814 | }) {
|
815 | const spinnerStyle = vue.computed(() => extend({
|
816 | color: props2.color
|
817 | }, getSizeStyle(props2.size)));
|
818 | const renderIcon = () => {
|
819 | const DefaultIcon = props2.type === "spinner" ? SpinIcon : CircularIcon;
|
820 | return vue.createVNode("span", {
|
821 | "class": bem$1B("spinner", props2.type),
|
822 | "style": spinnerStyle.value
|
823 | }, [slots.icon ? slots.icon() : DefaultIcon]);
|
824 | };
|
825 | const renderText = () => {
|
826 | var _a;
|
827 | if (slots.default) {
|
828 | return vue.createVNode("span", {
|
829 | "class": bem$1B("text"),
|
830 | "style": {
|
831 | fontSize: addUnit(props2.textSize),
|
832 | color: (_a = props2.textColor) != null ? _a : props2.color
|
833 | }
|
834 | }, [slots.default()]);
|
835 | }
|
836 | };
|
837 | return () => {
|
838 | const {
|
839 | type,
|
840 | vertical
|
841 | } = props2;
|
842 | return vue.createVNode("div", {
|
843 | "class": bem$1B([type, {
|
844 | vertical
|
845 | }]),
|
846 | "aria-live": "polite",
|
847 | "aria-busy": true
|
848 | }, [renderIcon(), renderText()]);
|
849 | };
|
850 | }
|
851 | });
|
852 | const Loading = withInstall(stdin_default$1P);
|
853 | const [name$1F, bem$1A] = createNamespace("button");
|
854 | const buttonProps = extend({}, routeProps, {
|
855 | tag: makeStringProp("button"),
|
856 | text: String,
|
857 | icon: String,
|
858 | type: makeStringProp("default"),
|
859 | size: makeStringProp("normal"),
|
860 | color: String,
|
861 | block: Boolean,
|
862 | plain: Boolean,
|
863 | round: Boolean,
|
864 | square: Boolean,
|
865 | loading: Boolean,
|
866 | hairline: Boolean,
|
867 | disabled: Boolean,
|
868 | iconPrefix: String,
|
869 | nativeType: makeStringProp("button"),
|
870 | loadingSize: numericProp,
|
871 | loadingText: String,
|
872 | loadingType: String,
|
873 | iconPosition: makeStringProp("left")
|
874 | });
|
875 | var stdin_default$1O = vue.defineComponent({
|
876 | name: name$1F,
|
877 | props: buttonProps,
|
878 | emits: ["click"],
|
879 | setup(props2, {
|
880 | emit,
|
881 | slots
|
882 | }) {
|
883 | const route2 = useRoute();
|
884 | const renderLoadingIcon = () => {
|
885 | if (slots.loading) {
|
886 | return slots.loading();
|
887 | }
|
888 | return vue.createVNode(Loading, {
|
889 | "size": props2.loadingSize,
|
890 | "type": props2.loadingType,
|
891 | "class": bem$1A("loading")
|
892 | }, null);
|
893 | };
|
894 | const renderIcon = () => {
|
895 | if (props2.loading) {
|
896 | return renderLoadingIcon();
|
897 | }
|
898 | if (slots.icon) {
|
899 | return vue.createVNode("div", {
|
900 | "class": bem$1A("icon")
|
901 | }, [slots.icon()]);
|
902 | }
|
903 | if (props2.icon) {
|
904 | return vue.createVNode(Icon, {
|
905 | "name": props2.icon,
|
906 | "class": bem$1A("icon"),
|
907 | "classPrefix": props2.iconPrefix
|
908 | }, null);
|
909 | }
|
910 | };
|
911 | const renderText = () => {
|
912 | let text;
|
913 | if (props2.loading) {
|
914 | text = props2.loadingText;
|
915 | } else {
|
916 | text = slots.default ? slots.default() : props2.text;
|
917 | }
|
918 | if (text) {
|
919 | return vue.createVNode("span", {
|
920 | "class": bem$1A("text")
|
921 | }, [text]);
|
922 | }
|
923 | };
|
924 | const getStyle = () => {
|
925 | const {
|
926 | color,
|
927 | plain
|
928 | } = props2;
|
929 | if (color) {
|
930 | const style = {
|
931 | color: plain ? color : "white"
|
932 | };
|
933 | if (!plain) {
|
934 | style.background = color;
|
935 | }
|
936 | if (color.includes("gradient")) {
|
937 | style.border = 0;
|
938 | } else {
|
939 | style.borderColor = color;
|
940 | }
|
941 | return style;
|
942 | }
|
943 | };
|
944 | const onClick = (event) => {
|
945 | if (props2.loading) {
|
946 | preventDefault(event);
|
947 | } else if (!props2.disabled) {
|
948 | emit("click", event);
|
949 | route2();
|
950 | }
|
951 | };
|
952 | return () => {
|
953 | const {
|
954 | tag,
|
955 | type,
|
956 | size,
|
957 | block,
|
958 | round,
|
959 | plain,
|
960 | square,
|
961 | loading,
|
962 | disabled,
|
963 | hairline,
|
964 | nativeType,
|
965 | iconPosition
|
966 | } = props2;
|
967 | const classes = [bem$1A([type, size, {
|
968 | plain,
|
969 | block,
|
970 | round,
|
971 | square,
|
972 | loading,
|
973 | disabled,
|
974 | hairline
|
975 | }]), {
|
976 | [BORDER_SURROUND]: hairline
|
977 | }];
|
978 | return vue.createVNode(tag, {
|
979 | "type": nativeType,
|
980 | "class": classes,
|
981 | "style": getStyle(),
|
982 | "disabled": disabled,
|
983 | "onClick": onClick
|
984 | }, {
|
985 | default: () => [vue.createVNode("div", {
|
986 | "class": bem$1A("content")
|
987 | }, [iconPosition === "left" && renderIcon(), renderText(), iconPosition === "right" && renderIcon()])]
|
988 | });
|
989 | };
|
990 | }
|
991 | });
|
992 | const Button = withInstall(stdin_default$1O);
|
993 | const [name$1E, bem$1z] = createNamespace("action-bar-button");
|
994 | const actionBarButtonProps = extend({}, routeProps, {
|
995 | type: String,
|
996 | text: String,
|
997 | icon: String,
|
998 | color: String,
|
999 | loading: Boolean,
|
1000 | disabled: Boolean
|
1001 | });
|
1002 | var stdin_default$1N = vue.defineComponent({
|
1003 | name: name$1E,
|
1004 | props: actionBarButtonProps,
|
1005 | setup(props2, {
|
1006 | slots
|
1007 | }) {
|
1008 | const route2 = useRoute();
|
1009 | const {
|
1010 | parent,
|
1011 | index
|
1012 | } = use.useParent(ACTION_BAR_KEY);
|
1013 | const isFirst = vue.computed(() => {
|
1014 | if (parent) {
|
1015 | const prev = parent.children[index.value - 1];
|
1016 | return !(prev && "isButton" in prev);
|
1017 | }
|
1018 | });
|
1019 | const isLast = vue.computed(() => {
|
1020 | if (parent) {
|
1021 | const next = parent.children[index.value + 1];
|
1022 | return !(next && "isButton" in next);
|
1023 | }
|
1024 | });
|
1025 | useExpose({
|
1026 | isButton: true
|
1027 | });
|
1028 | return () => {
|
1029 | const {
|
1030 | type,
|
1031 | icon,
|
1032 | text,
|
1033 | color,
|
1034 | loading,
|
1035 | disabled
|
1036 | } = props2;
|
1037 | return vue.createVNode(Button, {
|
1038 | "class": bem$1z([type, {
|
1039 | last: isLast.value,
|
1040 | first: isFirst.value
|
1041 | }]),
|
1042 | "size": "large",
|
1043 | "type": type,
|
1044 | "icon": icon,
|
1045 | "color": color,
|
1046 | "loading": loading,
|
1047 | "disabled": disabled,
|
1048 | "onClick": route2
|
1049 | }, {
|
1050 | default: () => [slots.default ? slots.default() : text]
|
1051 | });
|
1052 | };
|
1053 | }
|
1054 | });
|
1055 | const ActionBarButton = withInstall(stdin_default$1N);
|
1056 | const [name$1D, bem$1y] = createNamespace("action-bar-icon");
|
1057 | const actionBarIconProps = extend({}, routeProps, {
|
1058 | dot: Boolean,
|
1059 | text: String,
|
1060 | icon: String,
|
1061 | color: String,
|
1062 | badge: numericProp,
|
1063 | iconClass: unknownProp,
|
1064 | badgeProps: Object,
|
1065 | iconPrefix: String
|
1066 | });
|
1067 | var stdin_default$1M = vue.defineComponent({
|
1068 | name: name$1D,
|
1069 | props: actionBarIconProps,
|
1070 | setup(props2, {
|
1071 | slots
|
1072 | }) {
|
1073 | const route2 = useRoute();
|
1074 | use.useParent(ACTION_BAR_KEY);
|
1075 | const renderIcon = () => {
|
1076 | const {
|
1077 | dot,
|
1078 | badge,
|
1079 | icon,
|
1080 | color,
|
1081 | iconClass,
|
1082 | badgeProps: badgeProps2,
|
1083 | iconPrefix
|
1084 | } = props2;
|
1085 | if (slots.icon) {
|
1086 | return vue.createVNode(Badge, vue.mergeProps({
|
1087 | "dot": dot,
|
1088 | "class": bem$1y("icon"),
|
1089 | "content": badge
|
1090 | }, badgeProps2), {
|
1091 | default: slots.icon
|
1092 | });
|
1093 | }
|
1094 | return vue.createVNode(Icon, {
|
1095 | "tag": "div",
|
1096 | "dot": dot,
|
1097 | "name": icon,
|
1098 | "badge": badge,
|
1099 | "color": color,
|
1100 | "class": [bem$1y("icon"), iconClass],
|
1101 | "badgeProps": badgeProps2,
|
1102 | "classPrefix": iconPrefix
|
1103 | }, null);
|
1104 | };
|
1105 | return () => vue.createVNode("div", {
|
1106 | "role": "button",
|
1107 | "class": bem$1y(),
|
1108 | "tabindex": 0,
|
1109 | "onClick": route2
|
1110 | }, [renderIcon(), slots.default ? slots.default() : props2.text]);
|
1111 | }
|
1112 | });
|
1113 | const ActionBarIcon = withInstall(stdin_default$1M);
|
1114 | const popupSharedProps = {
|
1115 |
|
1116 | show: Boolean,
|
1117 |
|
1118 | zIndex: numericProp,
|
1119 |
|
1120 | overlay: truthProp,
|
1121 |
|
1122 | duration: numericProp,
|
1123 |
|
1124 | teleport: [String, Object],
|
1125 |
|
1126 | lockScroll: truthProp,
|
1127 |
|
1128 | lazyRender: truthProp,
|
1129 |
|
1130 | beforeClose: Function,
|
1131 |
|
1132 | overlayStyle: Object,
|
1133 |
|
1134 | overlayClass: unknownProp,
|
1135 |
|
1136 | transitionAppear: Boolean,
|
1137 |
|
1138 | closeOnClickOverlay: truthProp
|
1139 | };
|
1140 | const popupSharedPropKeys = Object.keys(
|
1141 | popupSharedProps
|
1142 | );
|
1143 | function getDirection(x, y) {
|
1144 | if (x > y) {
|
1145 | return "horizontal";
|
1146 | }
|
1147 | if (y > x) {
|
1148 | return "vertical";
|
1149 | }
|
1150 | return "";
|
1151 | }
|
1152 | function useTouch() {
|
1153 | const startX = vue.ref(0);
|
1154 | const startY = vue.ref(0);
|
1155 | const deltaX = vue.ref(0);
|
1156 | const deltaY = vue.ref(0);
|
1157 | const offsetX = vue.ref(0);
|
1158 | const offsetY = vue.ref(0);
|
1159 | const direction = vue.ref("");
|
1160 | const isTap = vue.ref(true);
|
1161 | const isVertical = () => direction.value === "vertical";
|
1162 | const isHorizontal = () => direction.value === "horizontal";
|
1163 | const reset = () => {
|
1164 | deltaX.value = 0;
|
1165 | deltaY.value = 0;
|
1166 | offsetX.value = 0;
|
1167 | offsetY.value = 0;
|
1168 | direction.value = "";
|
1169 | isTap.value = true;
|
1170 | };
|
1171 | const start = (event) => {
|
1172 | reset();
|
1173 | startX.value = event.touches[0].clientX;
|
1174 | startY.value = event.touches[0].clientY;
|
1175 | };
|
1176 | const move = (event) => {
|
1177 | const touch = event.touches[0];
|
1178 | deltaX.value = (touch.clientX < 0 ? 0 : touch.clientX) - startX.value;
|
1179 | deltaY.value = touch.clientY - startY.value;
|
1180 | offsetX.value = Math.abs(deltaX.value);
|
1181 | offsetY.value = Math.abs(deltaY.value);
|
1182 | const LOCK_DIRECTION_DISTANCE = 10;
|
1183 | if (!direction.value || offsetX.value < LOCK_DIRECTION_DISTANCE && offsetY.value < LOCK_DIRECTION_DISTANCE) {
|
1184 | direction.value = getDirection(offsetX.value, offsetY.value);
|
1185 | }
|
1186 | if (isTap.value && (offsetX.value > TAP_OFFSET || offsetY.value > TAP_OFFSET)) {
|
1187 | isTap.value = false;
|
1188 | }
|
1189 | };
|
1190 | return {
|
1191 | move,
|
1192 | start,
|
1193 | reset,
|
1194 | startX,
|
1195 | startY,
|
1196 | deltaX,
|
1197 | deltaY,
|
1198 | offsetX,
|
1199 | offsetY,
|
1200 | direction,
|
1201 | isVertical,
|
1202 | isHorizontal,
|
1203 | isTap
|
1204 | };
|
1205 | }
|
1206 | let totalLockCount = 0;
|
1207 | const BODY_LOCK_CLASS = "van-overflow-hidden";
|
1208 | function useLockScroll(rootRef, shouldLock) {
|
1209 | const touch = useTouch();
|
1210 | const DIRECTION_UP = "01";
|
1211 | const DIRECTION_DOWN = "10";
|
1212 | const onTouchMove = (event) => {
|
1213 | touch.move(event);
|
1214 | const direction = touch.deltaY.value > 0 ? DIRECTION_DOWN : DIRECTION_UP;
|
1215 | const el = use.getScrollParent(
|
1216 | event.target,
|
1217 | rootRef.value
|
1218 | );
|
1219 | const { scrollHeight, offsetHeight, scrollTop } = el;
|
1220 | let status = "11";
|
1221 | if (scrollTop === 0) {
|
1222 | status = offsetHeight >= scrollHeight ? "00" : "01";
|
1223 | } else if (scrollTop + offsetHeight >= scrollHeight) {
|
1224 | status = "10";
|
1225 | }
|
1226 | if (status !== "11" && touch.isVertical() && !(parseInt(status, 2) & parseInt(direction, 2))) {
|
1227 | preventDefault(event, true);
|
1228 | }
|
1229 | };
|
1230 | const lock = () => {
|
1231 | document.addEventListener("touchstart", touch.start);
|
1232 | document.addEventListener("touchmove", onTouchMove, { passive: false });
|
1233 | if (!totalLockCount) {
|
1234 | document.body.classList.add(BODY_LOCK_CLASS);
|
1235 | }
|
1236 | totalLockCount++;
|
1237 | };
|
1238 | const unlock = () => {
|
1239 | if (totalLockCount) {
|
1240 | document.removeEventListener("touchstart", touch.start);
|
1241 | document.removeEventListener("touchmove", onTouchMove);
|
1242 | totalLockCount--;
|
1243 | if (!totalLockCount) {
|
1244 | document.body.classList.remove(BODY_LOCK_CLASS);
|
1245 | }
|
1246 | }
|
1247 | };
|
1248 | const init = () => shouldLock() && lock();
|
1249 | const destroy = () => shouldLock() && unlock();
|
1250 | use.onMountedOrActivated(init);
|
1251 | vue.onDeactivated(destroy);
|
1252 | vue.onBeforeUnmount(destroy);
|
1253 | vue.watch(shouldLock, (value) => {
|
1254 | value ? lock() : unlock();
|
1255 | });
|
1256 | }
|
1257 | function useLazyRender(show) {
|
1258 | const inited = vue.ref(false);
|
1259 | vue.watch(
|
1260 | show,
|
1261 | (value) => {
|
1262 | if (value) {
|
1263 | inited.value = value;
|
1264 | }
|
1265 | },
|
1266 | { immediate: true }
|
1267 | );
|
1268 | return (render) => () => inited.value ? render() : null;
|
1269 | }
|
1270 | const useScopeId = () => {
|
1271 | var _a;
|
1272 | const { scopeId } = ((_a = vue.getCurrentInstance()) == null ? void 0 : _a.vnode) || {};
|
1273 | return scopeId ? { [scopeId]: "" } : null;
|
1274 | };
|
1275 | const [name$1C, bem$1x] = createNamespace("overlay");
|
1276 | const overlayProps = {
|
1277 | show: Boolean,
|
1278 | zIndex: numericProp,
|
1279 | duration: numericProp,
|
1280 | className: unknownProp,
|
1281 | lockScroll: truthProp,
|
1282 | lazyRender: truthProp,
|
1283 | customStyle: Object,
|
1284 | teleport: [String, Object]
|
1285 | };
|
1286 | var stdin_default$1L = vue.defineComponent({
|
1287 | name: name$1C,
|
1288 | props: overlayProps,
|
1289 | setup(props2, {
|
1290 | slots
|
1291 | }) {
|
1292 | const root = vue.ref();
|
1293 | const lazyRender = useLazyRender(() => props2.show || !props2.lazyRender);
|
1294 | const onTouchMove = (event) => {
|
1295 | if (props2.lockScroll) {
|
1296 | preventDefault(event, true);
|
1297 | }
|
1298 | };
|
1299 | const renderOverlay = lazyRender(() => {
|
1300 | var _a;
|
1301 | const style = extend(getZIndexStyle(props2.zIndex), props2.customStyle);
|
1302 | if (isDef(props2.duration)) {
|
1303 | style.animationDuration = `${props2.duration}s`;
|
1304 | }
|
1305 | return vue.withDirectives(vue.createVNode("div", {
|
1306 | "ref": root,
|
1307 | "style": style,
|
1308 | "class": [bem$1x(), props2.className]
|
1309 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), [[vue.vShow, props2.show]]);
|
1310 | });
|
1311 | use.useEventListener("touchmove", onTouchMove, {
|
1312 | target: root
|
1313 | });
|
1314 | return () => {
|
1315 | const Content = vue.createVNode(vue.Transition, {
|
1316 | "name": "van-fade",
|
1317 | "appear": true
|
1318 | }, {
|
1319 | default: renderOverlay
|
1320 | });
|
1321 | if (props2.teleport) {
|
1322 | return vue.createVNode(vue.Teleport, {
|
1323 | "to": props2.teleport
|
1324 | }, {
|
1325 | default: () => [Content]
|
1326 | });
|
1327 | }
|
1328 | return Content;
|
1329 | };
|
1330 | }
|
1331 | });
|
1332 | const Overlay = withInstall(stdin_default$1L);
|
1333 | const popupProps$2 = extend({}, popupSharedProps, {
|
1334 | round: Boolean,
|
1335 | position: makeStringProp("center"),
|
1336 | closeIcon: makeStringProp("cross"),
|
1337 | closeable: Boolean,
|
1338 | transition: String,
|
1339 | iconPrefix: String,
|
1340 | closeOnPopstate: Boolean,
|
1341 | closeIconPosition: makeStringProp("top-right"),
|
1342 | safeAreaInsetTop: Boolean,
|
1343 | safeAreaInsetBottom: Boolean
|
1344 | });
|
1345 | const [name$1B, bem$1w] = createNamespace("popup");
|
1346 | var stdin_default$1K = vue.defineComponent({
|
1347 | name: name$1B,
|
1348 | inheritAttrs: false,
|
1349 | props: popupProps$2,
|
1350 | emits: ["open", "close", "opened", "closed", "keydown", "update:show", "clickOverlay", "clickCloseIcon"],
|
1351 | setup(props2, {
|
1352 | emit,
|
1353 | attrs,
|
1354 | slots
|
1355 | }) {
|
1356 | let opened;
|
1357 | let shouldReopen;
|
1358 | const zIndex = vue.ref();
|
1359 | const popupRef = vue.ref();
|
1360 | const lazyRender = useLazyRender(() => props2.show || !props2.lazyRender);
|
1361 | const style = vue.computed(() => {
|
1362 | const style2 = {
|
1363 | zIndex: zIndex.value
|
1364 | };
|
1365 | if (isDef(props2.duration)) {
|
1366 | const key = props2.position === "center" ? "animationDuration" : "transitionDuration";
|
1367 | style2[key] = `${props2.duration}s`;
|
1368 | }
|
1369 | return style2;
|
1370 | });
|
1371 | const open = () => {
|
1372 | if (!opened) {
|
1373 | opened = true;
|
1374 | zIndex.value = props2.zIndex !== void 0 ? +props2.zIndex : useGlobalZIndex();
|
1375 | emit("open");
|
1376 | }
|
1377 | };
|
1378 | const close = () => {
|
1379 | if (opened) {
|
1380 | callInterceptor(props2.beforeClose, {
|
1381 | done() {
|
1382 | opened = false;
|
1383 | emit("close");
|
1384 | emit("update:show", false);
|
1385 | }
|
1386 | });
|
1387 | }
|
1388 | };
|
1389 | const onClickOverlay = (event) => {
|
1390 | emit("clickOverlay", event);
|
1391 | if (props2.closeOnClickOverlay) {
|
1392 | close();
|
1393 | }
|
1394 | };
|
1395 | const renderOverlay = () => {
|
1396 | if (props2.overlay) {
|
1397 | return vue.createVNode(Overlay, vue.mergeProps({
|
1398 | "show": props2.show,
|
1399 | "class": props2.overlayClass,
|
1400 | "zIndex": zIndex.value,
|
1401 | "duration": props2.duration,
|
1402 | "customStyle": props2.overlayStyle,
|
1403 | "role": props2.closeOnClickOverlay ? "button" : void 0,
|
1404 | "tabindex": props2.closeOnClickOverlay ? 0 : void 0
|
1405 | }, useScopeId(), {
|
1406 | "onClick": onClickOverlay
|
1407 | }), {
|
1408 | default: slots["overlay-content"]
|
1409 | });
|
1410 | }
|
1411 | };
|
1412 | const onClickCloseIcon = (event) => {
|
1413 | emit("clickCloseIcon", event);
|
1414 | close();
|
1415 | };
|
1416 | const renderCloseIcon = () => {
|
1417 | if (props2.closeable) {
|
1418 | return vue.createVNode(Icon, {
|
1419 | "role": "button",
|
1420 | "tabindex": 0,
|
1421 | "name": props2.closeIcon,
|
1422 | "class": [bem$1w("close-icon", props2.closeIconPosition), HAPTICS_FEEDBACK],
|
1423 | "classPrefix": props2.iconPrefix,
|
1424 | "onClick": onClickCloseIcon
|
1425 | }, null);
|
1426 | }
|
1427 | };
|
1428 | let timer2;
|
1429 | const onOpened = () => {
|
1430 | if (timer2) clearTimeout(timer2);
|
1431 | timer2 = setTimeout(() => {
|
1432 | emit("opened");
|
1433 | });
|
1434 | };
|
1435 | const onClosed = () => emit("closed");
|
1436 | const onKeydown = (event) => emit("keydown", event);
|
1437 | const renderPopup = lazyRender(() => {
|
1438 | var _a;
|
1439 | const {
|
1440 | round,
|
1441 | position,
|
1442 | safeAreaInsetTop,
|
1443 | safeAreaInsetBottom
|
1444 | } = props2;
|
1445 | return vue.withDirectives(vue.createVNode("div", vue.mergeProps({
|
1446 | "ref": popupRef,
|
1447 | "style": style.value,
|
1448 | "role": "dialog",
|
1449 | "tabindex": 0,
|
1450 | "class": [bem$1w({
|
1451 | round,
|
1452 | [position]: position
|
1453 | }), {
|
1454 | "van-safe-area-top": safeAreaInsetTop,
|
1455 | "van-safe-area-bottom": safeAreaInsetBottom
|
1456 | }],
|
1457 | "onKeydown": onKeydown
|
1458 | }, attrs, useScopeId()), [(_a = slots.default) == null ? void 0 : _a.call(slots), renderCloseIcon()]), [[vue.vShow, props2.show]]);
|
1459 | });
|
1460 | const renderTransition = () => {
|
1461 | const {
|
1462 | position,
|
1463 | transition,
|
1464 | transitionAppear
|
1465 | } = props2;
|
1466 | const name2 = position === "center" ? "van-fade" : `van-popup-slide-${position}`;
|
1467 | return vue.createVNode(vue.Transition, {
|
1468 | "name": transition || name2,
|
1469 | "appear": transitionAppear,
|
1470 | "onAfterEnter": onOpened,
|
1471 | "onAfterLeave": onClosed
|
1472 | }, {
|
1473 | default: renderPopup
|
1474 | });
|
1475 | };
|
1476 | vue.watch(() => props2.show, (show) => {
|
1477 | if (show && !opened) {
|
1478 | open();
|
1479 | if (attrs.tabindex === 0) {
|
1480 | vue.nextTick(() => {
|
1481 | var _a;
|
1482 | (_a = popupRef.value) == null ? void 0 : _a.focus();
|
1483 | });
|
1484 | }
|
1485 | }
|
1486 | if (!show && opened) {
|
1487 | opened = false;
|
1488 | emit("close");
|
1489 | }
|
1490 | });
|
1491 | useExpose({
|
1492 | popupRef
|
1493 | });
|
1494 | useLockScroll(popupRef, () => props2.show && props2.lockScroll);
|
1495 | use.useEventListener("popstate", () => {
|
1496 | if (props2.closeOnPopstate) {
|
1497 | close();
|
1498 | shouldReopen = false;
|
1499 | }
|
1500 | });
|
1501 | vue.onMounted(() => {
|
1502 | if (props2.show) {
|
1503 | open();
|
1504 | }
|
1505 | });
|
1506 | vue.onActivated(() => {
|
1507 | if (shouldReopen) {
|
1508 | emit("update:show", true);
|
1509 | shouldReopen = false;
|
1510 | }
|
1511 | });
|
1512 | vue.onDeactivated(() => {
|
1513 | if (props2.show && props2.teleport) {
|
1514 | close();
|
1515 | shouldReopen = true;
|
1516 | }
|
1517 | });
|
1518 | vue.provide(POPUP_TOGGLE_KEY, () => props2.show);
|
1519 | return () => {
|
1520 | if (props2.teleport) {
|
1521 | return vue.createVNode(vue.Teleport, {
|
1522 | "to": props2.teleport
|
1523 | }, {
|
1524 | default: () => [renderOverlay(), renderTransition()]
|
1525 | });
|
1526 | }
|
1527 | return vue.createVNode(vue.Fragment, null, [renderOverlay(), renderTransition()]);
|
1528 | };
|
1529 | }
|
1530 | });
|
1531 | const Popup = withInstall(stdin_default$1K);
|
1532 | const [name$1A, bem$1v] = createNamespace("action-sheet");
|
1533 | const actionSheetProps = extend({}, popupSharedProps, {
|
1534 | title: String,
|
1535 | round: truthProp,
|
1536 | actions: makeArrayProp(),
|
1537 | closeIcon: makeStringProp("cross"),
|
1538 | closeable: truthProp,
|
1539 | cancelText: String,
|
1540 | description: String,
|
1541 | closeOnPopstate: truthProp,
|
1542 | closeOnClickAction: Boolean,
|
1543 | safeAreaInsetBottom: truthProp
|
1544 | });
|
1545 | const popupInheritKeys$2 = [...popupSharedPropKeys, "round", "closeOnPopstate", "safeAreaInsetBottom"];
|
1546 | var stdin_default$1J = vue.defineComponent({
|
1547 | name: name$1A,
|
1548 | props: actionSheetProps,
|
1549 | emits: ["select", "cancel", "update:show"],
|
1550 | setup(props2, {
|
1551 | slots,
|
1552 | emit
|
1553 | }) {
|
1554 | const updateShow = (show) => emit("update:show", show);
|
1555 | const onCancel = () => {
|
1556 | updateShow(false);
|
1557 | emit("cancel");
|
1558 | };
|
1559 | const renderHeader = () => {
|
1560 | if (props2.title) {
|
1561 | return vue.createVNode("div", {
|
1562 | "class": bem$1v("header")
|
1563 | }, [props2.title, props2.closeable && vue.createVNode(Icon, {
|
1564 | "name": props2.closeIcon,
|
1565 | "class": [bem$1v("close"), HAPTICS_FEEDBACK],
|
1566 | "onClick": onCancel
|
1567 | }, null)]);
|
1568 | }
|
1569 | };
|
1570 | const renderCancel = () => {
|
1571 | if (slots.cancel || props2.cancelText) {
|
1572 | return [vue.createVNode("div", {
|
1573 | "class": bem$1v("gap")
|
1574 | }, null), vue.createVNode("button", {
|
1575 | "type": "button",
|
1576 | "class": bem$1v("cancel"),
|
1577 | "onClick": onCancel
|
1578 | }, [slots.cancel ? slots.cancel() : props2.cancelText])];
|
1579 | }
|
1580 | };
|
1581 | const renderIcon = (action) => {
|
1582 | if (action.icon) {
|
1583 | return vue.createVNode(Icon, {
|
1584 | "class": bem$1v("item-icon"),
|
1585 | "name": action.icon
|
1586 | }, null);
|
1587 | }
|
1588 | };
|
1589 | const renderActionContent = (action, index) => {
|
1590 | if (action.loading) {
|
1591 | return vue.createVNode(Loading, {
|
1592 | "class": bem$1v("loading-icon")
|
1593 | }, null);
|
1594 | }
|
1595 | if (slots.action) {
|
1596 | return slots.action({
|
1597 | action,
|
1598 | index
|
1599 | });
|
1600 | }
|
1601 | return [vue.createVNode("span", {
|
1602 | "class": bem$1v("name")
|
1603 | }, [action.name]), action.subname && vue.createVNode("div", {
|
1604 | "class": bem$1v("subname")
|
1605 | }, [action.subname])];
|
1606 | };
|
1607 | const renderAction = (action, index) => {
|
1608 | const {
|
1609 | color,
|
1610 | loading,
|
1611 | callback,
|
1612 | disabled,
|
1613 | className
|
1614 | } = action;
|
1615 | const onClick = () => {
|
1616 | if (disabled || loading) {
|
1617 | return;
|
1618 | }
|
1619 | if (callback) {
|
1620 | callback(action);
|
1621 | }
|
1622 | if (props2.closeOnClickAction) {
|
1623 | updateShow(false);
|
1624 | }
|
1625 | vue.nextTick(() => emit("select", action, index));
|
1626 | };
|
1627 | return vue.createVNode("button", {
|
1628 | "type": "button",
|
1629 | "style": {
|
1630 | color
|
1631 | },
|
1632 | "class": [bem$1v("item", {
|
1633 | loading,
|
1634 | disabled
|
1635 | }), className],
|
1636 | "onClick": onClick
|
1637 | }, [renderIcon(action), renderActionContent(action, index)]);
|
1638 | };
|
1639 | const renderDescription = () => {
|
1640 | if (props2.description || slots.description) {
|
1641 | const content = slots.description ? slots.description() : props2.description;
|
1642 | return vue.createVNode("div", {
|
1643 | "class": bem$1v("description")
|
1644 | }, [content]);
|
1645 | }
|
1646 | };
|
1647 | return () => vue.createVNode(Popup, vue.mergeProps({
|
1648 | "class": bem$1v(),
|
1649 | "position": "bottom",
|
1650 | "onUpdate:show": updateShow
|
1651 | }, pick(props2, popupInheritKeys$2)), {
|
1652 | default: () => {
|
1653 | var _a;
|
1654 | return [renderHeader(), renderDescription(), vue.createVNode("div", {
|
1655 | "class": bem$1v("content")
|
1656 | }, [props2.actions.map(renderAction), (_a = slots.default) == null ? void 0 : _a.call(slots)]), renderCancel()];
|
1657 | }
|
1658 | });
|
1659 | }
|
1660 | });
|
1661 | const ActionSheet = withInstall(stdin_default$1J);
|
1662 | const [name$1z, bem$1u, t$k] = createNamespace("picker");
|
1663 | const getFirstEnabledOption = (options) => options.find((option) => !option.disabled) || options[0];
|
1664 | function getColumnsType(columns, fields) {
|
1665 | const firstColumn = columns[0];
|
1666 | if (firstColumn) {
|
1667 | if (Array.isArray(firstColumn)) {
|
1668 | return "multiple";
|
1669 | }
|
1670 | if (fields.children in firstColumn) {
|
1671 | return "cascade";
|
1672 | }
|
1673 | }
|
1674 | return "default";
|
1675 | }
|
1676 | function findIndexOfEnabledOption(options, index) {
|
1677 | index = clamp(index, 0, options.length);
|
1678 | for (let i = index; i < options.length; i++) {
|
1679 | if (!options[i].disabled) return i;
|
1680 | }
|
1681 | for (let i = index - 1; i >= 0; i--) {
|
1682 | if (!options[i].disabled) return i;
|
1683 | }
|
1684 | return 0;
|
1685 | }
|
1686 | const isOptionExist = (options, value, fields) => value !== void 0 && !!options.find((option) => option[fields.value] === value);
|
1687 | function findOptionByValue(options, value, fields) {
|
1688 | const index = options.findIndex((option) => option[fields.value] === value);
|
1689 | const enabledIndex = findIndexOfEnabledOption(options, index);
|
1690 | return options[enabledIndex];
|
1691 | }
|
1692 | function formatCascadeColumns(columns, fields, selectedValues) {
|
1693 | const formatted = [];
|
1694 | let cursor = {
|
1695 | [fields.children]: columns
|
1696 | };
|
1697 | let columnIndex = 0;
|
1698 | while (cursor && cursor[fields.children]) {
|
1699 | const options = cursor[fields.children];
|
1700 | const value = selectedValues.value[columnIndex];
|
1701 | cursor = isDef(value) ? findOptionByValue(options, value, fields) : void 0;
|
1702 | if (!cursor && options.length) {
|
1703 | const firstValue = getFirstEnabledOption(options)[fields.value];
|
1704 | cursor = findOptionByValue(options, firstValue, fields);
|
1705 | }
|
1706 | columnIndex++;
|
1707 | formatted.push(options);
|
1708 | }
|
1709 | return formatted;
|
1710 | }
|
1711 | function getElementTranslateY(element) {
|
1712 | const { transform } = window.getComputedStyle(element);
|
1713 | const translateY = transform.slice(7, transform.length - 1).split(", ")[5];
|
1714 | return Number(translateY);
|
1715 | }
|
1716 | function assignDefaultFields(fields) {
|
1717 | return extend(
|
1718 | {
|
1719 | text: "text",
|
1720 | value: "value",
|
1721 | children: "children"
|
1722 | },
|
1723 | fields
|
1724 | );
|
1725 | }
|
1726 | const DEFAULT_DURATION = 200;
|
1727 | const MOMENTUM_TIME = 300;
|
1728 | const MOMENTUM_DISTANCE = 15;
|
1729 | const [name$1y, bem$1t] = createNamespace("picker-column");
|
1730 | const PICKER_KEY = Symbol(name$1y);
|
1731 | var stdin_default$1I = vue.defineComponent({
|
1732 | name: name$1y,
|
1733 | props: {
|
1734 | value: numericProp,
|
1735 | fields: makeRequiredProp(Object),
|
1736 | options: makeArrayProp(),
|
1737 | readonly: Boolean,
|
1738 | allowHtml: Boolean,
|
1739 | optionHeight: makeRequiredProp(Number),
|
1740 | swipeDuration: makeRequiredProp(numericProp),
|
1741 | visibleOptionNum: makeRequiredProp(numericProp)
|
1742 | },
|
1743 | emits: ["change", "clickOption", "scrollInto"],
|
1744 | setup(props2, {
|
1745 | emit,
|
1746 | slots
|
1747 | }) {
|
1748 | let moving;
|
1749 | let startOffset;
|
1750 | let touchStartTime;
|
1751 | let momentumOffset;
|
1752 | let transitionEndTrigger;
|
1753 | const root = vue.ref();
|
1754 | const wrapper = vue.ref();
|
1755 | const currentOffset = vue.ref(0);
|
1756 | const currentDuration = vue.ref(0);
|
1757 | const touch = useTouch();
|
1758 | const count = () => props2.options.length;
|
1759 | const baseOffset = () => props2.optionHeight * (+props2.visibleOptionNum - 1) / 2;
|
1760 | const updateValueByIndex = (index) => {
|
1761 | let enabledIndex = findIndexOfEnabledOption(props2.options, index);
|
1762 | const offset = -enabledIndex * props2.optionHeight;
|
1763 | const trigger = () => {
|
1764 | if (enabledIndex > count() - 1) {
|
1765 | enabledIndex = findIndexOfEnabledOption(props2.options, index);
|
1766 | }
|
1767 | const value = props2.options[enabledIndex][props2.fields.value];
|
1768 | if (value !== props2.value) {
|
1769 | emit("change", value);
|
1770 | }
|
1771 | };
|
1772 | if (moving && offset !== currentOffset.value) {
|
1773 | transitionEndTrigger = trigger;
|
1774 | } else {
|
1775 | trigger();
|
1776 | }
|
1777 | currentOffset.value = offset;
|
1778 | };
|
1779 | const isReadonly = () => props2.readonly || !props2.options.length;
|
1780 | const onClickOption = (index) => {
|
1781 | if (moving || isReadonly()) {
|
1782 | return;
|
1783 | }
|
1784 | transitionEndTrigger = null;
|
1785 | currentDuration.value = DEFAULT_DURATION;
|
1786 | updateValueByIndex(index);
|
1787 | emit("clickOption", props2.options[index]);
|
1788 | };
|
1789 | const getIndexByOffset = (offset) => clamp(Math.round(-offset / props2.optionHeight), 0, count() - 1);
|
1790 | const currentIndex = vue.computed(() => getIndexByOffset(currentOffset.value));
|
1791 | const momentum = (distance, duration) => {
|
1792 | const speed = Math.abs(distance / duration);
|
1793 | distance = currentOffset.value + speed / 3e-3 * (distance < 0 ? -1 : 1);
|
1794 | const index = getIndexByOffset(distance);
|
1795 | currentDuration.value = +props2.swipeDuration;
|
1796 | updateValueByIndex(index);
|
1797 | };
|
1798 | const stopMomentum = () => {
|
1799 | moving = false;
|
1800 | currentDuration.value = 0;
|
1801 | if (transitionEndTrigger) {
|
1802 | transitionEndTrigger();
|
1803 | transitionEndTrigger = null;
|
1804 | }
|
1805 | };
|
1806 | const onTouchStart = (event) => {
|
1807 | if (isReadonly()) {
|
1808 | return;
|
1809 | }
|
1810 | touch.start(event);
|
1811 | if (moving) {
|
1812 | const translateY = getElementTranslateY(wrapper.value);
|
1813 | currentOffset.value = Math.min(0, translateY - baseOffset());
|
1814 | }
|
1815 | currentDuration.value = 0;
|
1816 | startOffset = currentOffset.value;
|
1817 | touchStartTime = Date.now();
|
1818 | momentumOffset = startOffset;
|
1819 | transitionEndTrigger = null;
|
1820 | };
|
1821 | const onTouchMove = (event) => {
|
1822 | if (isReadonly()) {
|
1823 | return;
|
1824 | }
|
1825 | touch.move(event);
|
1826 | if (touch.isVertical()) {
|
1827 | moving = true;
|
1828 | preventDefault(event, true);
|
1829 | }
|
1830 | const newOffset = clamp(startOffset + touch.deltaY.value, -(count() * props2.optionHeight), props2.optionHeight);
|
1831 | const newIndex = getIndexByOffset(newOffset);
|
1832 | if (newIndex !== currentIndex.value) {
|
1833 | emit("scrollInto", props2.options[newIndex]);
|
1834 | }
|
1835 | currentOffset.value = newOffset;
|
1836 | const now = Date.now();
|
1837 | if (now - touchStartTime > MOMENTUM_TIME) {
|
1838 | touchStartTime = now;
|
1839 | momentumOffset = newOffset;
|
1840 | }
|
1841 | };
|
1842 | const onTouchEnd = () => {
|
1843 | if (isReadonly()) {
|
1844 | return;
|
1845 | }
|
1846 | const distance = currentOffset.value - momentumOffset;
|
1847 | const duration = Date.now() - touchStartTime;
|
1848 | const startMomentum = duration < MOMENTUM_TIME && Math.abs(distance) > MOMENTUM_DISTANCE;
|
1849 | if (startMomentum) {
|
1850 | momentum(distance, duration);
|
1851 | return;
|
1852 | }
|
1853 | const index = getIndexByOffset(currentOffset.value);
|
1854 | currentDuration.value = DEFAULT_DURATION;
|
1855 | updateValueByIndex(index);
|
1856 | setTimeout(() => {
|
1857 | moving = false;
|
1858 | }, 0);
|
1859 | };
|
1860 | const renderOptions = () => {
|
1861 | const optionStyle = {
|
1862 | height: `${props2.optionHeight}px`
|
1863 | };
|
1864 | return props2.options.map((option, index) => {
|
1865 | const text = option[props2.fields.text];
|
1866 | const {
|
1867 | disabled
|
1868 | } = option;
|
1869 | const value = option[props2.fields.value];
|
1870 | const data = {
|
1871 | role: "button",
|
1872 | style: optionStyle,
|
1873 | tabindex: disabled ? -1 : 0,
|
1874 | class: [bem$1t("item", {
|
1875 | disabled,
|
1876 | selected: value === props2.value
|
1877 | }), option.className],
|
1878 | onClick: () => onClickOption(index)
|
1879 | };
|
1880 | const childData = {
|
1881 | class: "van-ellipsis",
|
1882 | [props2.allowHtml ? "innerHTML" : "textContent"]: text
|
1883 | };
|
1884 | return vue.createVNode("li", data, [slots.option ? slots.option(option, index) : vue.createVNode("div", childData, null)]);
|
1885 | });
|
1886 | };
|
1887 | use.useParent(PICKER_KEY);
|
1888 | useExpose({
|
1889 | stopMomentum
|
1890 | });
|
1891 | vue.watchEffect(() => {
|
1892 | const index = moving ? Math.floor(-currentOffset.value / props2.optionHeight) : props2.options.findIndex((option) => option[props2.fields.value] === props2.value);
|
1893 | const enabledIndex = findIndexOfEnabledOption(props2.options, index);
|
1894 | const offset = -enabledIndex * props2.optionHeight;
|
1895 | if (moving && enabledIndex < index) stopMomentum();
|
1896 | currentOffset.value = offset;
|
1897 | });
|
1898 | use.useEventListener("touchmove", onTouchMove, {
|
1899 | target: root
|
1900 | });
|
1901 | return () => vue.createVNode("div", {
|
1902 | "ref": root,
|
1903 | "class": bem$1t(),
|
1904 | "onTouchstartPassive": onTouchStart,
|
1905 | "onTouchend": onTouchEnd,
|
1906 | "onTouchcancel": onTouchEnd
|
1907 | }, [vue.createVNode("ul", {
|
1908 | "ref": wrapper,
|
1909 | "style": {
|
1910 | transform: `translate3d(0, ${currentOffset.value + baseOffset()}px, 0)`,
|
1911 | transitionDuration: `${currentDuration.value}ms`,
|
1912 | transitionProperty: currentDuration.value ? "all" : "none"
|
1913 | },
|
1914 | "class": bem$1t("wrapper"),
|
1915 | "onTransitionend": stopMomentum
|
1916 | }, [renderOptions()])]);
|
1917 | }
|
1918 | });
|
1919 | const [name$1x] = createNamespace("picker-toolbar");
|
1920 | const pickerToolbarProps = {
|
1921 | title: String,
|
1922 | cancelButtonText: String,
|
1923 | confirmButtonText: String
|
1924 | };
|
1925 | const pickerToolbarSlots = ["cancel", "confirm", "title", "toolbar"];
|
1926 | const pickerToolbarPropKeys = Object.keys(pickerToolbarProps);
|
1927 | var stdin_default$1H = vue.defineComponent({
|
1928 | name: name$1x,
|
1929 | props: pickerToolbarProps,
|
1930 | emits: ["confirm", "cancel"],
|
1931 | setup(props2, {
|
1932 | emit,
|
1933 | slots
|
1934 | }) {
|
1935 | const renderTitle = () => {
|
1936 | if (slots.title) {
|
1937 | return slots.title();
|
1938 | }
|
1939 | if (props2.title) {
|
1940 | return vue.createVNode("div", {
|
1941 | "class": [bem$1u("title"), "van-ellipsis"]
|
1942 | }, [props2.title]);
|
1943 | }
|
1944 | };
|
1945 | const onCancel = () => emit("cancel");
|
1946 | const onConfirm = () => emit("confirm");
|
1947 | const renderCancel = () => {
|
1948 | var _a;
|
1949 | const text = (_a = props2.cancelButtonText) != null ? _a : t$k("cancel");
|
1950 | if (!slots.cancel && !text) {
|
1951 | return;
|
1952 | }
|
1953 | return vue.createVNode("button", {
|
1954 | "type": "button",
|
1955 | "class": [bem$1u("cancel"), HAPTICS_FEEDBACK],
|
1956 | "onClick": onCancel
|
1957 | }, [slots.cancel ? slots.cancel() : text]);
|
1958 | };
|
1959 | const renderConfirm = () => {
|
1960 | var _a;
|
1961 | const text = (_a = props2.confirmButtonText) != null ? _a : t$k("confirm");
|
1962 | if (!slots.confirm && !text) {
|
1963 | return;
|
1964 | }
|
1965 | return vue.createVNode("button", {
|
1966 | "type": "button",
|
1967 | "class": [bem$1u("confirm"), HAPTICS_FEEDBACK],
|
1968 | "onClick": onConfirm
|
1969 | }, [slots.confirm ? slots.confirm() : text]);
|
1970 | };
|
1971 | return () => vue.createVNode("div", {
|
1972 | "class": bem$1u("toolbar")
|
1973 | }, [slots.toolbar ? slots.toolbar() : [renderCancel(), renderTitle(), renderConfirm()]]);
|
1974 | }
|
1975 | });
|
1976 | const useSyncPropRef = (getProp, setProp) => {
|
1977 | const propRef = vue.ref(getProp());
|
1978 | vue.watch(getProp, (value) => {
|
1979 | if (value !== propRef.value) {
|
1980 | propRef.value = value;
|
1981 | }
|
1982 | });
|
1983 | vue.watch(propRef, (value) => {
|
1984 | if (value !== getProp()) {
|
1985 | setProp(value);
|
1986 | }
|
1987 | });
|
1988 | return propRef;
|
1989 | };
|
1990 | function scrollLeftTo(scroller, to, duration) {
|
1991 | let rafId;
|
1992 | let count = 0;
|
1993 | const from = scroller.scrollLeft;
|
1994 | const frames = duration === 0 ? 1 : Math.round(duration * 1e3 / 16);
|
1995 | let scrollLeft = from;
|
1996 | function cancel() {
|
1997 | use.cancelRaf(rafId);
|
1998 | }
|
1999 | function animate() {
|
2000 | scrollLeft += (to - from) / frames;
|
2001 | scroller.scrollLeft = scrollLeft;
|
2002 | if (++count < frames) {
|
2003 | rafId = use.raf(animate);
|
2004 | }
|
2005 | }
|
2006 | animate();
|
2007 | return cancel;
|
2008 | }
|
2009 | function scrollTopTo(scroller, to, duration, callback) {
|
2010 | let rafId;
|
2011 | let current2 = getScrollTop(scroller);
|
2012 | const isDown = current2 < to;
|
2013 | const frames = duration === 0 ? 1 : Math.round(duration * 1e3 / 16);
|
2014 | const step = (to - current2) / frames;
|
2015 | function cancel() {
|
2016 | use.cancelRaf(rafId);
|
2017 | }
|
2018 | function animate() {
|
2019 | current2 += step;
|
2020 | if (isDown && current2 > to || !isDown && current2 < to) {
|
2021 | current2 = to;
|
2022 | }
|
2023 | setScrollTop(scroller, current2);
|
2024 | if (isDown && current2 < to || !isDown && current2 > to) {
|
2025 | rafId = use.raf(animate);
|
2026 | } else if (callback) {
|
2027 | rafId = use.raf(callback);
|
2028 | }
|
2029 | }
|
2030 | animate();
|
2031 | return cancel;
|
2032 | }
|
2033 | let current = 0;
|
2034 | function useId() {
|
2035 | const vm = vue.getCurrentInstance();
|
2036 | const { name: name2 = "unknown" } = (vm == null ? void 0 : vm.type) || {};
|
2037 | if (process.env.NODE_ENV === "test") {
|
2038 | return name2;
|
2039 | }
|
2040 | return `${name2}-${++current}`;
|
2041 | }
|
2042 | function useRefs() {
|
2043 | const refs = vue.ref([]);
|
2044 | const cache = [];
|
2045 | vue.onBeforeUpdate(() => {
|
2046 | refs.value = [];
|
2047 | });
|
2048 | const setRefs = (index) => {
|
2049 | if (!cache[index]) {
|
2050 | cache[index] = (el) => {
|
2051 | refs.value[index] = el;
|
2052 | };
|
2053 | }
|
2054 | return cache[index];
|
2055 | };
|
2056 | return [refs, setRefs];
|
2057 | }
|
2058 | function useVisibilityChange(target, onChange) {
|
2059 | if (!inBrowser || !window.IntersectionObserver) {
|
2060 | return;
|
2061 | }
|
2062 | const observer = new IntersectionObserver(
|
2063 | (entries) => {
|
2064 | onChange(entries[0].intersectionRatio > 0);
|
2065 | },
|
2066 | { root: document.body }
|
2067 | );
|
2068 | const observe = () => {
|
2069 | if (target.value) {
|
2070 | observer.observe(target.value);
|
2071 | }
|
2072 | };
|
2073 | const unobserve = () => {
|
2074 | if (target.value) {
|
2075 | observer.unobserve(target.value);
|
2076 | }
|
2077 | };
|
2078 | vue.onDeactivated(unobserve);
|
2079 | vue.onBeforeUnmount(unobserve);
|
2080 | use.onMountedOrActivated(observe);
|
2081 | }
|
2082 | const [name$1w, bem$1s] = createNamespace("sticky");
|
2083 | const stickyProps = {
|
2084 | zIndex: numericProp,
|
2085 | position: makeStringProp("top"),
|
2086 | container: Object,
|
2087 | offsetTop: makeNumericProp(0),
|
2088 | offsetBottom: makeNumericProp(0)
|
2089 | };
|
2090 | var stdin_default$1G = vue.defineComponent({
|
2091 | name: name$1w,
|
2092 | props: stickyProps,
|
2093 | emits: ["scroll", "change"],
|
2094 | setup(props2, {
|
2095 | emit,
|
2096 | slots
|
2097 | }) {
|
2098 | const root = vue.ref();
|
2099 | const scrollParent = use.useScrollParent(root);
|
2100 | const state = vue.reactive({
|
2101 | fixed: false,
|
2102 | width: 0,
|
2103 |
|
2104 | height: 0,
|
2105 |
|
2106 | transform: 0
|
2107 | });
|
2108 | const isReset = vue.ref(false);
|
2109 | const offset = vue.computed(() => unitToPx(props2.position === "top" ? props2.offsetTop : props2.offsetBottom));
|
2110 | const rootStyle = vue.computed(() => {
|
2111 | if (isReset.value) {
|
2112 | return;
|
2113 | }
|
2114 | const {
|
2115 | fixed,
|
2116 | height,
|
2117 | width
|
2118 | } = state;
|
2119 | if (fixed) {
|
2120 | return {
|
2121 | width: `${width}px`,
|
2122 | height: `${height}px`
|
2123 | };
|
2124 | }
|
2125 | });
|
2126 | const stickyStyle = vue.computed(() => {
|
2127 | if (!state.fixed || isReset.value) {
|
2128 | return;
|
2129 | }
|
2130 | const style = extend(getZIndexStyle(props2.zIndex), {
|
2131 | width: `${state.width}px`,
|
2132 | height: `${state.height}px`,
|
2133 | [props2.position]: `${offset.value}px`
|
2134 | });
|
2135 | if (state.transform) {
|
2136 | style.transform = `translate3d(0, ${state.transform}px, 0)`;
|
2137 | }
|
2138 | return style;
|
2139 | });
|
2140 | const emitScroll = (scrollTop) => emit("scroll", {
|
2141 | scrollTop,
|
2142 | isFixed: state.fixed
|
2143 | });
|
2144 | const onScroll = () => {
|
2145 | if (!root.value || isHidden(root)) {
|
2146 | return;
|
2147 | }
|
2148 | const {
|
2149 | container,
|
2150 | position
|
2151 | } = props2;
|
2152 | const rootRect = use.useRect(root);
|
2153 | const scrollTop = getScrollTop(window);
|
2154 | state.width = rootRect.width;
|
2155 | state.height = rootRect.height;
|
2156 | if (position === "top") {
|
2157 | if (container) {
|
2158 | const containerRect = use.useRect(container);
|
2159 | const difference = containerRect.bottom - offset.value - state.height;
|
2160 | state.fixed = offset.value > rootRect.top && containerRect.bottom > 0;
|
2161 | state.transform = difference < 0 ? difference : 0;
|
2162 | } else {
|
2163 | state.fixed = offset.value > rootRect.top;
|
2164 | }
|
2165 | } else {
|
2166 | const {
|
2167 | clientHeight
|
2168 | } = document.documentElement;
|
2169 | if (container) {
|
2170 | const containerRect = use.useRect(container);
|
2171 | const difference = clientHeight - containerRect.top - offset.value - state.height;
|
2172 | state.fixed = clientHeight - offset.value < rootRect.bottom && clientHeight > containerRect.top;
|
2173 | state.transform = difference < 0 ? -difference : 0;
|
2174 | } else {
|
2175 | state.fixed = clientHeight - offset.value < rootRect.bottom;
|
2176 | }
|
2177 | }
|
2178 | emitScroll(scrollTop);
|
2179 | };
|
2180 | vue.watch(() => state.fixed, (value) => emit("change", value));
|
2181 | use.useEventListener("scroll", onScroll, {
|
2182 | target: scrollParent,
|
2183 | passive: true
|
2184 | });
|
2185 | useVisibilityChange(root, onScroll);
|
2186 | vue.watch([windowWidth, windowHeight], () => {
|
2187 | if (!root.value || isHidden(root) || !state.fixed) {
|
2188 | return;
|
2189 | }
|
2190 | isReset.value = true;
|
2191 | vue.nextTick(() => {
|
2192 | const rootRect = use.useRect(root);
|
2193 | state.width = rootRect.width;
|
2194 | state.height = rootRect.height;
|
2195 | isReset.value = false;
|
2196 | });
|
2197 | });
|
2198 | return () => {
|
2199 | var _a;
|
2200 | return vue.createVNode("div", {
|
2201 | "ref": root,
|
2202 | "style": rootStyle.value
|
2203 | }, [vue.createVNode("div", {
|
2204 | "class": bem$1s({
|
2205 | fixed: state.fixed && !isReset.value
|
2206 | }),
|
2207 | "style": stickyStyle.value
|
2208 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
|
2209 | };
|
2210 | }
|
2211 | });
|
2212 | const Sticky = withInstall(stdin_default$1G);
|
2213 | const [name$1v, bem$1r] = createNamespace("swipe");
|
2214 | const swipeProps = {
|
2215 | loop: truthProp,
|
2216 | width: numericProp,
|
2217 | height: numericProp,
|
2218 | vertical: Boolean,
|
2219 | autoplay: makeNumericProp(0),
|
2220 | duration: makeNumericProp(500),
|
2221 | touchable: truthProp,
|
2222 | lazyRender: Boolean,
|
2223 | initialSwipe: makeNumericProp(0),
|
2224 | indicatorColor: String,
|
2225 | showIndicators: truthProp,
|
2226 | stopPropagation: truthProp
|
2227 | };
|
2228 | const SWIPE_KEY = Symbol(name$1v);
|
2229 | var stdin_default$1F = vue.defineComponent({
|
2230 | name: name$1v,
|
2231 | props: swipeProps,
|
2232 | emits: ["change", "dragStart", "dragEnd"],
|
2233 | setup(props2, {
|
2234 | emit,
|
2235 | slots
|
2236 | }) {
|
2237 | const root = vue.ref();
|
2238 | const track = vue.ref();
|
2239 | const state = vue.reactive({
|
2240 | rect: null,
|
2241 | width: 0,
|
2242 | height: 0,
|
2243 | offset: 0,
|
2244 | active: 0,
|
2245 | swiping: false
|
2246 | });
|
2247 | let dragging = false;
|
2248 | const touch = useTouch();
|
2249 | const {
|
2250 | children,
|
2251 | linkChildren
|
2252 | } = use.useChildren(SWIPE_KEY);
|
2253 | const count = vue.computed(() => children.length);
|
2254 | const size = vue.computed(() => state[props2.vertical ? "height" : "width"]);
|
2255 | const delta = vue.computed(() => props2.vertical ? touch.deltaY.value : touch.deltaX.value);
|
2256 | const minOffset = vue.computed(() => {
|
2257 | if (state.rect) {
|
2258 | const base = props2.vertical ? state.rect.height : state.rect.width;
|
2259 | return base - size.value * count.value;
|
2260 | }
|
2261 | return 0;
|
2262 | });
|
2263 | const maxCount = vue.computed(() => size.value ? Math.ceil(Math.abs(minOffset.value) / size.value) : count.value);
|
2264 | const trackSize = vue.computed(() => count.value * size.value);
|
2265 | const activeIndicator = vue.computed(() => (state.active + count.value) % count.value);
|
2266 | const isCorrectDirection = vue.computed(() => {
|
2267 | const expect = props2.vertical ? "vertical" : "horizontal";
|
2268 | return touch.direction.value === expect;
|
2269 | });
|
2270 | const trackStyle = vue.computed(() => {
|
2271 | const style = {
|
2272 | transitionDuration: `${state.swiping ? 0 : props2.duration}ms`,
|
2273 | transform: `translate${props2.vertical ? "Y" : "X"}(${+state.offset.toFixed(2)}px)`
|
2274 | };
|
2275 | if (size.value) {
|
2276 | const mainAxis = props2.vertical ? "height" : "width";
|
2277 | const crossAxis = props2.vertical ? "width" : "height";
|
2278 | style[mainAxis] = `${trackSize.value}px`;
|
2279 | style[crossAxis] = props2[crossAxis] ? `${props2[crossAxis]}px` : "";
|
2280 | }
|
2281 | return style;
|
2282 | });
|
2283 | const getTargetActive = (pace) => {
|
2284 | const {
|
2285 | active
|
2286 | } = state;
|
2287 | if (pace) {
|
2288 | if (props2.loop) {
|
2289 | return clamp(active + pace, -1, count.value);
|
2290 | }
|
2291 | return clamp(active + pace, 0, maxCount.value);
|
2292 | }
|
2293 | return active;
|
2294 | };
|
2295 | const getTargetOffset = (targetActive, offset = 0) => {
|
2296 | let currentPosition = targetActive * size.value;
|
2297 | if (!props2.loop) {
|
2298 | currentPosition = Math.min(currentPosition, -minOffset.value);
|
2299 | }
|
2300 | let targetOffset = offset - currentPosition;
|
2301 | if (!props2.loop) {
|
2302 | targetOffset = clamp(targetOffset, minOffset.value, 0);
|
2303 | }
|
2304 | return targetOffset;
|
2305 | };
|
2306 | const move = ({
|
2307 | pace = 0,
|
2308 | offset = 0,
|
2309 | emitChange
|
2310 | }) => {
|
2311 | if (count.value <= 1) {
|
2312 | return;
|
2313 | }
|
2314 | const {
|
2315 | active
|
2316 | } = state;
|
2317 | const targetActive = getTargetActive(pace);
|
2318 | const targetOffset = getTargetOffset(targetActive, offset);
|
2319 | if (props2.loop) {
|
2320 | if (children[0] && targetOffset !== minOffset.value) {
|
2321 | const outRightBound = targetOffset < minOffset.value;
|
2322 | children[0].setOffset(outRightBound ? trackSize.value : 0);
|
2323 | }
|
2324 | if (children[count.value - 1] && targetOffset !== 0) {
|
2325 | const outLeftBound = targetOffset > 0;
|
2326 | children[count.value - 1].setOffset(outLeftBound ? -trackSize.value : 0);
|
2327 | }
|
2328 | }
|
2329 | state.active = targetActive;
|
2330 | state.offset = targetOffset;
|
2331 | if (emitChange && targetActive !== active) {
|
2332 | emit("change", activeIndicator.value);
|
2333 | }
|
2334 | };
|
2335 | const correctPosition = () => {
|
2336 | state.swiping = true;
|
2337 | if (state.active <= -1) {
|
2338 | move({
|
2339 | pace: count.value
|
2340 | });
|
2341 | } else if (state.active >= count.value) {
|
2342 | move({
|
2343 | pace: -count.value
|
2344 | });
|
2345 | }
|
2346 | };
|
2347 | const prev = () => {
|
2348 | correctPosition();
|
2349 | touch.reset();
|
2350 | use.doubleRaf(() => {
|
2351 | state.swiping = false;
|
2352 | move({
|
2353 | pace: -1,
|
2354 | emitChange: true
|
2355 | });
|
2356 | });
|
2357 | };
|
2358 | const next = () => {
|
2359 | correctPosition();
|
2360 | touch.reset();
|
2361 | use.doubleRaf(() => {
|
2362 | state.swiping = false;
|
2363 | move({
|
2364 | pace: 1,
|
2365 | emitChange: true
|
2366 | });
|
2367 | });
|
2368 | };
|
2369 | let autoplayTimer;
|
2370 | const stopAutoplay = () => clearTimeout(autoplayTimer);
|
2371 | const autoplay = () => {
|
2372 | stopAutoplay();
|
2373 | if (+props2.autoplay > 0 && count.value > 1) {
|
2374 | autoplayTimer = setTimeout(() => {
|
2375 | next();
|
2376 | autoplay();
|
2377 | }, +props2.autoplay);
|
2378 | }
|
2379 | };
|
2380 | const initialize = (active = +props2.initialSwipe) => {
|
2381 | if (!root.value) {
|
2382 | return;
|
2383 | }
|
2384 | const cb = () => {
|
2385 | var _a, _b;
|
2386 | if (!isHidden(root)) {
|
2387 | const rect = {
|
2388 | width: root.value.offsetWidth,
|
2389 | height: root.value.offsetHeight
|
2390 | };
|
2391 | state.rect = rect;
|
2392 | state.width = +((_a = props2.width) != null ? _a : rect.width);
|
2393 | state.height = +((_b = props2.height) != null ? _b : rect.height);
|
2394 | }
|
2395 | if (count.value) {
|
2396 | active = Math.min(count.value - 1, active);
|
2397 | if (active === -1) {
|
2398 | active = count.value - 1;
|
2399 | }
|
2400 | }
|
2401 | state.active = active;
|
2402 | state.swiping = true;
|
2403 | state.offset = getTargetOffset(active);
|
2404 | children.forEach((swipe) => {
|
2405 | swipe.setOffset(0);
|
2406 | });
|
2407 | autoplay();
|
2408 | };
|
2409 | if (isHidden(root)) {
|
2410 | vue.nextTick().then(cb);
|
2411 | } else {
|
2412 | cb();
|
2413 | }
|
2414 | };
|
2415 | const resize = () => initialize(state.active);
|
2416 | let touchStartTime;
|
2417 | const onTouchStart = (event) => {
|
2418 | if (!props2.touchable ||
|
2419 | event.touches.length > 1) return;
|
2420 | touch.start(event);
|
2421 | dragging = false;
|
2422 | touchStartTime = Date.now();
|
2423 | stopAutoplay();
|
2424 | correctPosition();
|
2425 | };
|
2426 | const onTouchMove = (event) => {
|
2427 | if (props2.touchable && state.swiping) {
|
2428 | touch.move(event);
|
2429 | if (isCorrectDirection.value) {
|
2430 | const isEdgeTouch = !props2.loop && (state.active === 0 && delta.value > 0 || state.active === count.value - 1 && delta.value < 0);
|
2431 | if (!isEdgeTouch) {
|
2432 | preventDefault(event, props2.stopPropagation);
|
2433 | move({
|
2434 | offset: delta.value
|
2435 | });
|
2436 | if (!dragging) {
|
2437 | emit("dragStart", {
|
2438 | index: activeIndicator.value
|
2439 | });
|
2440 | dragging = true;
|
2441 | }
|
2442 | }
|
2443 | }
|
2444 | }
|
2445 | };
|
2446 | const onTouchEnd = () => {
|
2447 | if (!props2.touchable || !state.swiping) {
|
2448 | return;
|
2449 | }
|
2450 | const duration = Date.now() - touchStartTime;
|
2451 | const speed = delta.value / duration;
|
2452 | const shouldSwipe = Math.abs(speed) > 0.25 || Math.abs(delta.value) > size.value / 2;
|
2453 | if (shouldSwipe && isCorrectDirection.value) {
|
2454 | const offset = props2.vertical ? touch.offsetY.value : touch.offsetX.value;
|
2455 | let pace = 0;
|
2456 | if (props2.loop) {
|
2457 | pace = offset > 0 ? delta.value > 0 ? -1 : 1 : 0;
|
2458 | } else {
|
2459 | pace = -Math[delta.value > 0 ? "ceil" : "floor"](delta.value / size.value);
|
2460 | }
|
2461 | move({
|
2462 | pace,
|
2463 | emitChange: true
|
2464 | });
|
2465 | } else if (delta.value) {
|
2466 | move({
|
2467 | pace: 0
|
2468 | });
|
2469 | }
|
2470 | dragging = false;
|
2471 | state.swiping = false;
|
2472 | emit("dragEnd", {
|
2473 | index: activeIndicator.value
|
2474 | });
|
2475 | autoplay();
|
2476 | };
|
2477 | const swipeTo = (index, options = {}) => {
|
2478 | correctPosition();
|
2479 | touch.reset();
|
2480 | use.doubleRaf(() => {
|
2481 | let targetIndex;
|
2482 | if (props2.loop && index === count.value) {
|
2483 | targetIndex = state.active === 0 ? 0 : index;
|
2484 | } else {
|
2485 | targetIndex = index % count.value;
|
2486 | }
|
2487 | if (options.immediate) {
|
2488 | use.doubleRaf(() => {
|
2489 | state.swiping = false;
|
2490 | });
|
2491 | } else {
|
2492 | state.swiping = false;
|
2493 | }
|
2494 | move({
|
2495 | pace: targetIndex - state.active,
|
2496 | emitChange: true
|
2497 | });
|
2498 | });
|
2499 | };
|
2500 | const renderDot = (_, index) => {
|
2501 | const active = index === activeIndicator.value;
|
2502 | const style = active ? {
|
2503 | backgroundColor: props2.indicatorColor
|
2504 | } : void 0;
|
2505 | return vue.createVNode("i", {
|
2506 | "style": style,
|
2507 | "class": bem$1r("indicator", {
|
2508 | active
|
2509 | })
|
2510 | }, null);
|
2511 | };
|
2512 | const renderIndicator = () => {
|
2513 | if (slots.indicator) {
|
2514 | return slots.indicator({
|
2515 | active: activeIndicator.value,
|
2516 | total: count.value
|
2517 | });
|
2518 | }
|
2519 | if (props2.showIndicators && count.value > 1) {
|
2520 | return vue.createVNode("div", {
|
2521 | "class": bem$1r("indicators", {
|
2522 | vertical: props2.vertical
|
2523 | })
|
2524 | }, [Array(count.value).fill("").map(renderDot)]);
|
2525 | }
|
2526 | };
|
2527 | useExpose({
|
2528 | prev,
|
2529 | next,
|
2530 | state,
|
2531 | resize,
|
2532 | swipeTo
|
2533 | });
|
2534 | linkChildren({
|
2535 | size,
|
2536 | props: props2,
|
2537 | count,
|
2538 | activeIndicator
|
2539 | });
|
2540 | vue.watch(() => props2.initialSwipe, (value) => initialize(+value));
|
2541 | vue.watch(count, () => initialize(state.active));
|
2542 | vue.watch(() => props2.autoplay, autoplay);
|
2543 | vue.watch([windowWidth, windowHeight, () => props2.width, () => props2.height], resize);
|
2544 | vue.watch(use.usePageVisibility(), (visible) => {
|
2545 | if (visible === "visible") {
|
2546 | autoplay();
|
2547 | } else {
|
2548 | stopAutoplay();
|
2549 | }
|
2550 | });
|
2551 | vue.onMounted(initialize);
|
2552 | vue.onActivated(() => initialize(state.active));
|
2553 | onPopupReopen(() => initialize(state.active));
|
2554 | vue.onDeactivated(stopAutoplay);
|
2555 | vue.onBeforeUnmount(stopAutoplay);
|
2556 | use.useEventListener("touchmove", onTouchMove, {
|
2557 | target: track
|
2558 | });
|
2559 | return () => {
|
2560 | var _a;
|
2561 | return vue.createVNode("div", {
|
2562 | "ref": root,
|
2563 | "class": bem$1r()
|
2564 | }, [vue.createVNode("div", {
|
2565 | "ref": track,
|
2566 | "style": trackStyle.value,
|
2567 | "class": bem$1r("track", {
|
2568 | vertical: props2.vertical
|
2569 | }),
|
2570 | "onTouchstartPassive": onTouchStart,
|
2571 | "onTouchend": onTouchEnd,
|
2572 | "onTouchcancel": onTouchEnd
|
2573 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), renderIndicator()]);
|
2574 | };
|
2575 | }
|
2576 | });
|
2577 | const Swipe = withInstall(stdin_default$1F);
|
2578 | const [name$1u, bem$1q] = createNamespace("tabs");
|
2579 | var stdin_default$1E = vue.defineComponent({
|
2580 | name: name$1u,
|
2581 | props: {
|
2582 | count: makeRequiredProp(Number),
|
2583 | inited: Boolean,
|
2584 | animated: Boolean,
|
2585 | duration: makeRequiredProp(numericProp),
|
2586 | swipeable: Boolean,
|
2587 | lazyRender: Boolean,
|
2588 | currentIndex: makeRequiredProp(Number)
|
2589 | },
|
2590 | emits: ["change"],
|
2591 | setup(props2, {
|
2592 | emit,
|
2593 | slots
|
2594 | }) {
|
2595 | const swipeRef = vue.ref();
|
2596 | const onChange = (index) => emit("change", index);
|
2597 | const renderChildren = () => {
|
2598 | var _a;
|
2599 | const Content = (_a = slots.default) == null ? void 0 : _a.call(slots);
|
2600 | if (props2.animated || props2.swipeable) {
|
2601 | return vue.createVNode(Swipe, {
|
2602 | "ref": swipeRef,
|
2603 | "loop": false,
|
2604 | "class": bem$1q("track"),
|
2605 | "duration": +props2.duration * 1e3,
|
2606 | "touchable": props2.swipeable,
|
2607 | "lazyRender": props2.lazyRender,
|
2608 | "showIndicators": false,
|
2609 | "onChange": onChange
|
2610 | }, {
|
2611 | default: () => [Content]
|
2612 | });
|
2613 | }
|
2614 | return Content;
|
2615 | };
|
2616 | const swipeToCurrentTab = (index) => {
|
2617 | const swipe = swipeRef.value;
|
2618 | if (swipe && swipe.state.active !== index) {
|
2619 | swipe.swipeTo(index, {
|
2620 | immediate: !props2.inited
|
2621 | });
|
2622 | }
|
2623 | };
|
2624 | vue.watch(() => props2.currentIndex, swipeToCurrentTab);
|
2625 | vue.onMounted(() => {
|
2626 | swipeToCurrentTab(props2.currentIndex);
|
2627 | });
|
2628 | useExpose({
|
2629 | swipeRef
|
2630 | });
|
2631 | return () => vue.createVNode("div", {
|
2632 | "class": bem$1q("content", {
|
2633 | animated: props2.animated || props2.swipeable
|
2634 | })
|
2635 | }, [renderChildren()]);
|
2636 | }
|
2637 | });
|
2638 | const [name$1t, bem$1p] = createNamespace("tabs");
|
2639 | const tabsProps = {
|
2640 | type: makeStringProp("line"),
|
2641 | color: String,
|
2642 | border: Boolean,
|
2643 | sticky: Boolean,
|
2644 | shrink: Boolean,
|
2645 | active: makeNumericProp(0),
|
2646 | duration: makeNumericProp(0.3),
|
2647 | animated: Boolean,
|
2648 | ellipsis: truthProp,
|
2649 | swipeable: Boolean,
|
2650 | scrollspy: Boolean,
|
2651 | offsetTop: makeNumericProp(0),
|
2652 | background: String,
|
2653 | lazyRender: truthProp,
|
2654 | showHeader: truthProp,
|
2655 | lineWidth: numericProp,
|
2656 | lineHeight: numericProp,
|
2657 | beforeChange: Function,
|
2658 | swipeThreshold: makeNumericProp(5),
|
2659 | titleActiveColor: String,
|
2660 | titleInactiveColor: String
|
2661 | };
|
2662 | const TABS_KEY = Symbol(name$1t);
|
2663 | var stdin_default$1D = vue.defineComponent({
|
2664 | name: name$1t,
|
2665 | props: tabsProps,
|
2666 | emits: ["change", "scroll", "rendered", "clickTab", "update:active"],
|
2667 | setup(props2, {
|
2668 | emit,
|
2669 | slots
|
2670 | }) {
|
2671 | let tabHeight;
|
2672 | let lockScroll;
|
2673 | let stickyFixed;
|
2674 | let cancelScrollLeftToRaf;
|
2675 | let cancelScrollTopToRaf;
|
2676 | const root = vue.ref();
|
2677 | const navRef = vue.ref();
|
2678 | const wrapRef = vue.ref();
|
2679 | const contentRef = vue.ref();
|
2680 | const id = useId();
|
2681 | const scroller = use.useScrollParent(root);
|
2682 | const [titleRefs, setTitleRefs] = useRefs();
|
2683 | const {
|
2684 | children,
|
2685 | linkChildren
|
2686 | } = use.useChildren(TABS_KEY);
|
2687 | const state = vue.reactive({
|
2688 | inited: false,
|
2689 | position: "",
|
2690 | lineStyle: {},
|
2691 | currentIndex: -1
|
2692 | });
|
2693 | const scrollable = vue.computed(() => children.length > +props2.swipeThreshold || !props2.ellipsis || props2.shrink);
|
2694 | const navStyle = vue.computed(() => ({
|
2695 | borderColor: props2.color,
|
2696 | background: props2.background
|
2697 | }));
|
2698 | const getTabName = (tab, index) => {
|
2699 | var _a;
|
2700 | return (_a = tab.name) != null ? _a : index;
|
2701 | };
|
2702 | const currentName = vue.computed(() => {
|
2703 | const activeTab = children[state.currentIndex];
|
2704 | if (activeTab) {
|
2705 | return getTabName(activeTab, state.currentIndex);
|
2706 | }
|
2707 | });
|
2708 | const offsetTopPx = vue.computed(() => unitToPx(props2.offsetTop));
|
2709 | const scrollOffset = vue.computed(() => {
|
2710 | if (props2.sticky) {
|
2711 | return offsetTopPx.value + tabHeight;
|
2712 | }
|
2713 | return 0;
|
2714 | });
|
2715 | const scrollIntoView = (immediate) => {
|
2716 | const nav = navRef.value;
|
2717 | const titles = titleRefs.value;
|
2718 | if (!scrollable.value || !nav || !titles || !titles[state.currentIndex]) {
|
2719 | return;
|
2720 | }
|
2721 | const title = titles[state.currentIndex].$el;
|
2722 | const to = title.offsetLeft - (nav.offsetWidth - title.offsetWidth) / 2;
|
2723 | if (cancelScrollLeftToRaf) cancelScrollLeftToRaf();
|
2724 | cancelScrollLeftToRaf = scrollLeftTo(nav, to, immediate ? 0 : +props2.duration);
|
2725 | };
|
2726 | const setLine = () => {
|
2727 | const shouldAnimate = state.inited;
|
2728 | vue.nextTick(() => {
|
2729 | const titles = titleRefs.value;
|
2730 | if (!titles || !titles[state.currentIndex] || props2.type !== "line" || isHidden(root.value)) {
|
2731 | return;
|
2732 | }
|
2733 | const title = titles[state.currentIndex].$el;
|
2734 | const {
|
2735 | lineWidth,
|
2736 | lineHeight
|
2737 | } = props2;
|
2738 | const left = title.offsetLeft + title.offsetWidth / 2;
|
2739 | const lineStyle = {
|
2740 | width: addUnit(lineWidth),
|
2741 | backgroundColor: props2.color,
|
2742 | transform: `translateX(${left}px) translateX(-50%)`
|
2743 | };
|
2744 | if (shouldAnimate) {
|
2745 | lineStyle.transitionDuration = `${props2.duration}s`;
|
2746 | }
|
2747 | if (isDef(lineHeight)) {
|
2748 | const height = addUnit(lineHeight);
|
2749 | lineStyle.height = height;
|
2750 | lineStyle.borderRadius = height;
|
2751 | }
|
2752 | state.lineStyle = lineStyle;
|
2753 | });
|
2754 | };
|
2755 | const findAvailableTab = (index) => {
|
2756 | const diff = index < state.currentIndex ? -1 : 1;
|
2757 | while (index >= 0 && index < children.length) {
|
2758 | if (!children[index].disabled) {
|
2759 | return index;
|
2760 | }
|
2761 | index += diff;
|
2762 | }
|
2763 | };
|
2764 | const setCurrentIndex = (currentIndex, skipScrollIntoView) => {
|
2765 | const newIndex = findAvailableTab(currentIndex);
|
2766 | if (!isDef(newIndex)) {
|
2767 | return;
|
2768 | }
|
2769 | const newTab = children[newIndex];
|
2770 | const newName = getTabName(newTab, newIndex);
|
2771 | const shouldEmitChange = state.currentIndex !== null;
|
2772 | if (state.currentIndex !== newIndex) {
|
2773 | state.currentIndex = newIndex;
|
2774 | if (!skipScrollIntoView) {
|
2775 | scrollIntoView();
|
2776 | }
|
2777 | setLine();
|
2778 | }
|
2779 | if (newName !== props2.active) {
|
2780 | emit("update:active", newName);
|
2781 | if (shouldEmitChange) {
|
2782 | emit("change", newName, newTab.title);
|
2783 | }
|
2784 | }
|
2785 | if (stickyFixed && !props2.scrollspy) {
|
2786 | setRootScrollTop(Math.ceil(getElementTop(root.value) - offsetTopPx.value));
|
2787 | }
|
2788 | };
|
2789 | const setCurrentIndexByName = (name2, skipScrollIntoView) => {
|
2790 | const matched = children.find((tab, index2) => getTabName(tab, index2) === name2);
|
2791 | const index = matched ? children.indexOf(matched) : 0;
|
2792 | setCurrentIndex(index, skipScrollIntoView);
|
2793 | };
|
2794 | const scrollToCurrentContent = (immediate = false) => {
|
2795 | if (props2.scrollspy) {
|
2796 | const target = children[state.currentIndex].$el;
|
2797 | if (target && scroller.value) {
|
2798 | const to = getElementTop(target, scroller.value) - scrollOffset.value;
|
2799 | lockScroll = true;
|
2800 | if (cancelScrollTopToRaf) cancelScrollTopToRaf();
|
2801 | cancelScrollTopToRaf = scrollTopTo(scroller.value, to, immediate ? 0 : +props2.duration, () => {
|
2802 | lockScroll = false;
|
2803 | });
|
2804 | }
|
2805 | }
|
2806 | };
|
2807 | const onClickTab = (item, index, event) => {
|
2808 | const {
|
2809 | title,
|
2810 | disabled
|
2811 | } = children[index];
|
2812 | const name2 = getTabName(children[index], index);
|
2813 | if (!disabled) {
|
2814 | callInterceptor(props2.beforeChange, {
|
2815 | args: [name2],
|
2816 | done: () => {
|
2817 | setCurrentIndex(index);
|
2818 | scrollToCurrentContent();
|
2819 | }
|
2820 | });
|
2821 | route(item);
|
2822 | }
|
2823 | emit("clickTab", {
|
2824 | name: name2,
|
2825 | title,
|
2826 | event,
|
2827 | disabled
|
2828 | });
|
2829 | };
|
2830 | const onStickyScroll = (params) => {
|
2831 | stickyFixed = params.isFixed;
|
2832 | emit("scroll", params);
|
2833 | };
|
2834 | const scrollTo = (name2) => {
|
2835 | vue.nextTick(() => {
|
2836 | setCurrentIndexByName(name2);
|
2837 | scrollToCurrentContent(true);
|
2838 | });
|
2839 | };
|
2840 | const getCurrentIndexOnScroll = () => {
|
2841 | for (let index = 0; index < children.length; index++) {
|
2842 | const {
|
2843 | top
|
2844 | } = use.useRect(children[index].$el);
|
2845 | if (top > scrollOffset.value) {
|
2846 | return index === 0 ? 0 : index - 1;
|
2847 | }
|
2848 | }
|
2849 | return children.length - 1;
|
2850 | };
|
2851 | const onScroll = () => {
|
2852 | if (props2.scrollspy && !lockScroll) {
|
2853 | const index = getCurrentIndexOnScroll();
|
2854 | setCurrentIndex(index);
|
2855 | }
|
2856 | };
|
2857 | const renderLine = () => {
|
2858 | if (props2.type === "line" && children.length) {
|
2859 | return vue.createVNode("div", {
|
2860 | "class": bem$1p("line"),
|
2861 | "style": state.lineStyle
|
2862 | }, null);
|
2863 | }
|
2864 | };
|
2865 | const renderHeader = () => {
|
2866 | var _a, _b, _c;
|
2867 | const {
|
2868 | type,
|
2869 | border,
|
2870 | sticky
|
2871 | } = props2;
|
2872 | const Header = [vue.createVNode("div", {
|
2873 | "ref": sticky ? void 0 : wrapRef,
|
2874 | "class": [bem$1p("wrap"), {
|
2875 | [BORDER_TOP_BOTTOM]: type === "line" && border
|
2876 | }]
|
2877 | }, [vue.createVNode("div", {
|
2878 | "ref": navRef,
|
2879 | "role": "tablist",
|
2880 | "class": bem$1p("nav", [type, {
|
2881 | shrink: props2.shrink,
|
2882 | complete: scrollable.value
|
2883 | }]),
|
2884 | "style": navStyle.value,
|
2885 | "aria-orientation": "horizontal"
|
2886 | }, [(_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)];
|
2887 | if (sticky) {
|
2888 | return vue.createVNode("div", {
|
2889 | "ref": wrapRef
|
2890 | }, [Header]);
|
2891 | }
|
2892 | return Header;
|
2893 | };
|
2894 | const resize = () => {
|
2895 | setLine();
|
2896 | vue.nextTick(() => {
|
2897 | var _a, _b;
|
2898 | scrollIntoView(true);
|
2899 | (_b = (_a = contentRef.value) == null ? void 0 : _a.swipeRef.value) == null ? void 0 : _b.resize();
|
2900 | });
|
2901 | };
|
2902 | vue.watch(() => [props2.color, props2.duration, props2.lineWidth, props2.lineHeight], setLine);
|
2903 | vue.watch(windowWidth, resize);
|
2904 | vue.watch(() => props2.active, (value) => {
|
2905 | if (value !== currentName.value) {
|
2906 | setCurrentIndexByName(value);
|
2907 | }
|
2908 | });
|
2909 | vue.watch(() => children.length, () => {
|
2910 | if (state.inited) {
|
2911 | setCurrentIndexByName(props2.active);
|
2912 | setLine();
|
2913 | vue.nextTick(() => {
|
2914 | scrollIntoView(true);
|
2915 | });
|
2916 | }
|
2917 | });
|
2918 | const init = () => {
|
2919 | setCurrentIndexByName(props2.active, true);
|
2920 | vue.nextTick(() => {
|
2921 | state.inited = true;
|
2922 | if (wrapRef.value) {
|
2923 | tabHeight = use.useRect(wrapRef.value).height;
|
2924 | }
|
2925 | scrollIntoView(true);
|
2926 | });
|
2927 | };
|
2928 | const onRendered = (name2, title) => emit("rendered", name2, title);
|
2929 | useExpose({
|
2930 | resize,
|
2931 | scrollTo
|
2932 | });
|
2933 | vue.onActivated(setLine);
|
2934 | onPopupReopen(setLine);
|
2935 | use.onMountedOrActivated(init);
|
2936 | useVisibilityChange(root, setLine);
|
2937 | use.useEventListener("scroll", onScroll, {
|
2938 | target: scroller,
|
2939 | passive: true
|
2940 | });
|
2941 | linkChildren({
|
2942 | id,
|
2943 | props: props2,
|
2944 | setLine,
|
2945 | scrollable,
|
2946 | onRendered,
|
2947 | currentName,
|
2948 | setTitleRefs,
|
2949 | scrollIntoView
|
2950 | });
|
2951 | return () => vue.createVNode("div", {
|
2952 | "ref": root,
|
2953 | "class": bem$1p([props2.type])
|
2954 | }, [props2.showHeader ? props2.sticky ? vue.createVNode(Sticky, {
|
2955 | "container": root.value,
|
2956 | "offsetTop": offsetTopPx.value,
|
2957 | "onScroll": onStickyScroll
|
2958 | }, {
|
2959 | default: () => [renderHeader()]
|
2960 | }) : renderHeader() : null, vue.createVNode(stdin_default$1E, {
|
2961 | "ref": contentRef,
|
2962 | "count": children.length,
|
2963 | "inited": state.inited,
|
2964 | "animated": props2.animated,
|
2965 | "duration": props2.duration,
|
2966 | "swipeable": props2.swipeable,
|
2967 | "lazyRender": props2.lazyRender,
|
2968 | "currentIndex": state.currentIndex,
|
2969 | "onChange": setCurrentIndex
|
2970 | }, {
|
2971 | default: () => {
|
2972 | var _a;
|
2973 | return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
|
2974 | }
|
2975 | })]);
|
2976 | }
|
2977 | });
|
2978 | const TAB_STATUS_KEY = Symbol();
|
2979 | const useTabStatus = () => vue.inject(TAB_STATUS_KEY, null);
|
2980 | const [name$1s, bem$1o] = createNamespace("tab");
|
2981 | const TabTitle = vue.defineComponent({
|
2982 | name: name$1s,
|
2983 | props: {
|
2984 | id: String,
|
2985 | dot: Boolean,
|
2986 | type: String,
|
2987 | color: String,
|
2988 | title: String,
|
2989 | badge: numericProp,
|
2990 | shrink: Boolean,
|
2991 | isActive: Boolean,
|
2992 | disabled: Boolean,
|
2993 | controls: String,
|
2994 | scrollable: Boolean,
|
2995 | activeColor: String,
|
2996 | inactiveColor: String,
|
2997 | showZeroBadge: truthProp
|
2998 | },
|
2999 | setup(props2, {
|
3000 | slots
|
3001 | }) {
|
3002 | const style = vue.computed(() => {
|
3003 | const style2 = {};
|
3004 | const {
|
3005 | type,
|
3006 | color,
|
3007 | disabled,
|
3008 | isActive,
|
3009 | activeColor,
|
3010 | inactiveColor
|
3011 | } = props2;
|
3012 | const isCard = type === "card";
|
3013 | if (color && isCard) {
|
3014 | style2.borderColor = color;
|
3015 | if (!disabled) {
|
3016 | if (isActive) {
|
3017 | style2.backgroundColor = color;
|
3018 | } else {
|
3019 | style2.color = color;
|
3020 | }
|
3021 | }
|
3022 | }
|
3023 | const titleColor = isActive ? activeColor : inactiveColor;
|
3024 | if (titleColor) {
|
3025 | style2.color = titleColor;
|
3026 | }
|
3027 | return style2;
|
3028 | });
|
3029 | const renderText = () => {
|
3030 | const Text = vue.createVNode("span", {
|
3031 | "class": bem$1o("text", {
|
3032 | ellipsis: !props2.scrollable
|
3033 | })
|
3034 | }, [slots.title ? slots.title() : props2.title]);
|
3035 | if (props2.dot || isDef(props2.badge) && props2.badge !== "") {
|
3036 | return vue.createVNode(Badge, {
|
3037 | "dot": props2.dot,
|
3038 | "content": props2.badge,
|
3039 | "showZero": props2.showZeroBadge
|
3040 | }, {
|
3041 | default: () => [Text]
|
3042 | });
|
3043 | }
|
3044 | return Text;
|
3045 | };
|
3046 | return () => vue.createVNode("div", {
|
3047 | "id": props2.id,
|
3048 | "role": "tab",
|
3049 | "class": [bem$1o([props2.type, {
|
3050 | grow: props2.scrollable && !props2.shrink,
|
3051 | shrink: props2.shrink,
|
3052 | active: props2.isActive,
|
3053 | disabled: props2.disabled
|
3054 | }])],
|
3055 | "style": style.value,
|
3056 | "tabindex": props2.disabled ? void 0 : props2.isActive ? 0 : -1,
|
3057 | "aria-selected": props2.isActive,
|
3058 | "aria-disabled": props2.disabled || void 0,
|
3059 | "aria-controls": props2.controls,
|
3060 | "data-allow-mismatch": "attribute"
|
3061 | }, [renderText()]);
|
3062 | }
|
3063 | });
|
3064 | const [name$1r, bem$1n] = createNamespace("swipe-item");
|
3065 | var stdin_default$1C = vue.defineComponent({
|
3066 | name: name$1r,
|
3067 | setup(props2, {
|
3068 | slots
|
3069 | }) {
|
3070 | let rendered;
|
3071 | const state = vue.reactive({
|
3072 | offset: 0,
|
3073 | inited: false,
|
3074 | mounted: false
|
3075 | });
|
3076 | const {
|
3077 | parent,
|
3078 | index
|
3079 | } = use.useParent(SWIPE_KEY);
|
3080 | if (!parent) {
|
3081 | if (process.env.NODE_ENV !== "production") {
|
3082 | console.error("[Vant] <SwipeItem> must be a child component of <Swipe>.");
|
3083 | }
|
3084 | return;
|
3085 | }
|
3086 | const style = vue.computed(() => {
|
3087 | const style2 = {};
|
3088 | const {
|
3089 | vertical
|
3090 | } = parent.props;
|
3091 | if (parent.size.value) {
|
3092 | style2[vertical ? "height" : "width"] = `${parent.size.value}px`;
|
3093 | }
|
3094 | if (state.offset) {
|
3095 | style2.transform = `translate${vertical ? "Y" : "X"}(${state.offset}px)`;
|
3096 | }
|
3097 | return style2;
|
3098 | });
|
3099 | const shouldRender = vue.computed(() => {
|
3100 | const {
|
3101 | loop,
|
3102 | lazyRender
|
3103 | } = parent.props;
|
3104 | if (!lazyRender || rendered) {
|
3105 | return true;
|
3106 | }
|
3107 | if (!state.mounted) {
|
3108 | return false;
|
3109 | }
|
3110 | const active = parent.activeIndicator.value;
|
3111 | const maxActive = parent.count.value - 1;
|
3112 | const prevActive = active === 0 && loop ? maxActive : active - 1;
|
3113 | const nextActive = active === maxActive && loop ? 0 : active + 1;
|
3114 | rendered = index.value === active || index.value === prevActive || index.value === nextActive;
|
3115 | return rendered;
|
3116 | });
|
3117 | const setOffset = (offset) => {
|
3118 | state.offset = offset;
|
3119 | };
|
3120 | vue.onMounted(() => {
|
3121 | vue.nextTick(() => {
|
3122 | state.mounted = true;
|
3123 | });
|
3124 | });
|
3125 | useExpose({
|
3126 | setOffset
|
3127 | });
|
3128 | return () => {
|
3129 | var _a;
|
3130 | return vue.createVNode("div", {
|
3131 | "class": bem$1n(),
|
3132 | "style": style.value
|
3133 | }, [shouldRender.value ? (_a = slots.default) == null ? void 0 : _a.call(slots) : null]);
|
3134 | };
|
3135 | }
|
3136 | });
|
3137 | const SwipeItem = withInstall(stdin_default$1C);
|
3138 | const [name$1q, bem$1m] = createNamespace("tab");
|
3139 | const tabProps = extend({}, routeProps, {
|
3140 | dot: Boolean,
|
3141 | name: numericProp,
|
3142 | badge: numericProp,
|
3143 | title: String,
|
3144 | disabled: Boolean,
|
3145 | titleClass: unknownProp,
|
3146 | titleStyle: [String, Object],
|
3147 | showZeroBadge: truthProp
|
3148 | });
|
3149 | var stdin_default$1B = vue.defineComponent({
|
3150 | name: name$1q,
|
3151 | props: tabProps,
|
3152 | setup(props2, {
|
3153 | slots
|
3154 | }) {
|
3155 | const id = useId();
|
3156 | const inited = vue.ref(false);
|
3157 | const instance2 = vue.getCurrentInstance();
|
3158 | const {
|
3159 | parent,
|
3160 | index
|
3161 | } = use.useParent(TABS_KEY);
|
3162 | if (!parent) {
|
3163 | if (process.env.NODE_ENV !== "production") {
|
3164 | console.error("[Vant] <Tab> must be a child component of <Tabs>.");
|
3165 | }
|
3166 | return;
|
3167 | }
|
3168 | const getName = () => {
|
3169 | var _a;
|
3170 | return (_a = props2.name) != null ? _a : index.value;
|
3171 | };
|
3172 | const init = () => {
|
3173 | inited.value = true;
|
3174 | if (parent.props.lazyRender) {
|
3175 | vue.nextTick(() => {
|
3176 | parent.onRendered(getName(), props2.title);
|
3177 | });
|
3178 | }
|
3179 | };
|
3180 | const active = vue.computed(() => {
|
3181 | const isActive = getName() === parent.currentName.value;
|
3182 | if (isActive && !inited.value) {
|
3183 | init();
|
3184 | }
|
3185 | return isActive;
|
3186 | });
|
3187 | const parsedClass = vue.ref("");
|
3188 | const parsedStyle = vue.ref("");
|
3189 | vue.watchEffect(() => {
|
3190 | const {
|
3191 | titleClass,
|
3192 | titleStyle
|
3193 | } = props2;
|
3194 | parsedClass.value = titleClass ? shared.normalizeClass(titleClass) : "";
|
3195 | parsedStyle.value = titleStyle && typeof titleStyle !== "string" ? shared.stringifyStyle(shared.normalizeStyle(titleStyle)) : titleStyle;
|
3196 | });
|
3197 | const renderTitle = (onClickTab) => vue.createVNode(TabTitle, vue.mergeProps({
|
3198 | "key": id,
|
3199 | "id": `${parent.id}-${index.value}`,
|
3200 | "ref": parent.setTitleRefs(index.value),
|
3201 | "style": parsedStyle.value,
|
3202 | "class": parsedClass.value,
|
3203 | "isActive": active.value,
|
3204 | "controls": id,
|
3205 | "scrollable": parent.scrollable.value,
|
3206 | "activeColor": parent.props.titleActiveColor,
|
3207 | "inactiveColor": parent.props.titleInactiveColor,
|
3208 | "onClick": (event) => onClickTab(instance2.proxy, index.value, event)
|
3209 | }, pick(parent.props, ["type", "color", "shrink"]), pick(props2, ["dot", "badge", "title", "disabled", "showZeroBadge"])), {
|
3210 | title: slots.title
|
3211 | });
|
3212 | const hasInactiveClass = vue.ref(!active.value);
|
3213 | vue.watch(active, (val) => {
|
3214 | if (val) {
|
3215 | hasInactiveClass.value = false;
|
3216 | } else {
|
3217 | use.doubleRaf(() => {
|
3218 | hasInactiveClass.value = true;
|
3219 | });
|
3220 | }
|
3221 | });
|
3222 | vue.watch(() => props2.title, () => {
|
3223 | parent.setLine();
|
3224 | parent.scrollIntoView();
|
3225 | });
|
3226 | vue.provide(TAB_STATUS_KEY, active);
|
3227 | useExpose({
|
3228 | id,
|
3229 | renderTitle
|
3230 | });
|
3231 | return () => {
|
3232 | var _a;
|
3233 | const label = `${parent.id}-${index.value}`;
|
3234 | const {
|
3235 | animated,
|
3236 | swipeable,
|
3237 | scrollspy,
|
3238 | lazyRender
|
3239 | } = parent.props;
|
3240 | if (!slots.default && !animated) {
|
3241 | return;
|
3242 | }
|
3243 | const show = scrollspy || active.value;
|
3244 | if (animated || swipeable) {
|
3245 | return vue.createVNode(SwipeItem, {
|
3246 | "id": id,
|
3247 | "role": "tabpanel",
|
3248 | "class": bem$1m("panel-wrapper", {
|
3249 | inactive: hasInactiveClass.value
|
3250 | }),
|
3251 | "tabindex": active.value ? 0 : -1,
|
3252 | "aria-hidden": !active.value,
|
3253 | "aria-labelledby": label,
|
3254 | "data-allow-mismatch": "attribute"
|
3255 | }, {
|
3256 | default: () => {
|
3257 | var _a2;
|
3258 | return [vue.createVNode("div", {
|
3259 | "class": bem$1m("panel")
|
3260 | }, [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)])];
|
3261 | }
|
3262 | });
|
3263 | }
|
3264 | const shouldRender = inited.value || scrollspy || !lazyRender;
|
3265 | const Content = shouldRender ? (_a = slots.default) == null ? void 0 : _a.call(slots) : null;
|
3266 | return vue.withDirectives(vue.createVNode("div", {
|
3267 | "id": id,
|
3268 | "role": "tabpanel",
|
3269 | "class": bem$1m("panel"),
|
3270 | "tabindex": show ? 0 : -1,
|
3271 | "aria-labelledby": label,
|
3272 | "data-allow-mismatch": "attribute"
|
3273 | }, [Content]), [[vue.vShow, show]]);
|
3274 | };
|
3275 | }
|
3276 | });
|
3277 | const Tab = withInstall(stdin_default$1B);
|
3278 | const Tabs = withInstall(stdin_default$1D);
|
3279 | const [name$1p, bem$1l] = createNamespace("picker-group");
|
3280 | const PICKER_GROUP_KEY = Symbol(name$1p);
|
3281 | const pickerGroupProps = extend({
|
3282 | tabs: makeArrayProp(),
|
3283 | activeTab: makeNumericProp(0),
|
3284 | nextStepText: String,
|
3285 | showToolbar: truthProp
|
3286 | }, pickerToolbarProps);
|
3287 | var stdin_default$1A = vue.defineComponent({
|
3288 | name: name$1p,
|
3289 | props: pickerGroupProps,
|
3290 | emits: ["confirm", "cancel", "update:activeTab"],
|
3291 | setup(props2, {
|
3292 | emit,
|
3293 | slots
|
3294 | }) {
|
3295 | const activeTab = useSyncPropRef(() => props2.activeTab, (value) => emit("update:activeTab", value));
|
3296 | const {
|
3297 | children,
|
3298 | linkChildren
|
3299 | } = use.useChildren(PICKER_GROUP_KEY);
|
3300 | linkChildren();
|
3301 | const showNextButton = () => +activeTab.value < props2.tabs.length - 1 && props2.nextStepText;
|
3302 | const onConfirm = () => {
|
3303 | if (showNextButton()) {
|
3304 | activeTab.value = +activeTab.value + 1;
|
3305 | } else {
|
3306 | emit("confirm", children.map((item) => item.confirm()));
|
3307 | }
|
3308 | };
|
3309 | const onCancel = () => emit("cancel");
|
3310 | return () => {
|
3311 | var _a, _b;
|
3312 | let childNodes = (_b = (_a = slots.default) == null ? void 0 : _a.call(slots)) == null ? void 0 : _b.filter((node) => node.type !== vue.Comment).map((node) => {
|
3313 | if (node.type === vue.Fragment) {
|
3314 | return node.children;
|
3315 | }
|
3316 | return node;
|
3317 | });
|
3318 | if (childNodes) {
|
3319 | childNodes = flat(childNodes);
|
3320 | }
|
3321 | const confirmButtonText = showNextButton() ? props2.nextStepText : props2.confirmButtonText;
|
3322 | return vue.createVNode("div", {
|
3323 | "class": bem$1l()
|
3324 | }, [props2.showToolbar ? vue.createVNode(stdin_default$1H, {
|
3325 | "title": props2.title,
|
3326 | "cancelButtonText": props2.cancelButtonText,
|
3327 | "confirmButtonText": confirmButtonText,
|
3328 | "onConfirm": onConfirm,
|
3329 | "onCancel": onCancel
|
3330 | }, pick(slots, pickerToolbarSlots)) : null, vue.createVNode(Tabs, {
|
3331 | "active": activeTab.value,
|
3332 | "onUpdate:active": ($event) => activeTab.value = $event,
|
3333 | "class": bem$1l("tabs"),
|
3334 | "shrink": true,
|
3335 | "animated": true,
|
3336 | "lazyRender": false
|
3337 | }, {
|
3338 | default: () => [props2.tabs.map((title, index) => vue.createVNode(Tab, {
|
3339 | "title": title,
|
3340 | "titleClass": bem$1l("tab-title")
|
3341 | }, {
|
3342 | default: () => [childNodes == null ? void 0 : childNodes[index]]
|
3343 | }))]
|
3344 | })]);
|
3345 | };
|
3346 | }
|
3347 | });
|
3348 | const pickerSharedProps = extend({
|
3349 | loading: Boolean,
|
3350 | readonly: Boolean,
|
3351 | allowHtml: Boolean,
|
3352 | optionHeight: makeNumericProp(44),
|
3353 | showToolbar: truthProp,
|
3354 | swipeDuration: makeNumericProp(1e3),
|
3355 | visibleOptionNum: makeNumericProp(6)
|
3356 | }, pickerToolbarProps);
|
3357 | const pickerProps = extend({}, pickerSharedProps, {
|
3358 | columns: makeArrayProp(),
|
3359 | modelValue: makeArrayProp(),
|
3360 | toolbarPosition: makeStringProp("top"),
|
3361 | columnsFieldNames: Object
|
3362 | });
|
3363 | var stdin_default$1z = vue.defineComponent({
|
3364 | name: name$1z,
|
3365 | props: pickerProps,
|
3366 | emits: ["confirm", "cancel", "change", "scrollInto", "clickOption", "update:modelValue"],
|
3367 | setup(props2, {
|
3368 | emit,
|
3369 | slots
|
3370 | }) {
|
3371 | const columnsRef = vue.ref();
|
3372 | const selectedValues = vue.ref(props2.modelValue.slice(0));
|
3373 | const {
|
3374 | parent
|
3375 | } = use.useParent(PICKER_GROUP_KEY);
|
3376 | const {
|
3377 | children,
|
3378 | linkChildren
|
3379 | } = use.useChildren(PICKER_KEY);
|
3380 | linkChildren();
|
3381 | const fields = vue.computed(() => assignDefaultFields(props2.columnsFieldNames));
|
3382 | const optionHeight = vue.computed(() => unitToPx(props2.optionHeight));
|
3383 | const columnsType = vue.computed(() => getColumnsType(props2.columns, fields.value));
|
3384 | const currentColumns = vue.computed(() => {
|
3385 | const {
|
3386 | columns
|
3387 | } = props2;
|
3388 | switch (columnsType.value) {
|
3389 | case "multiple":
|
3390 | return columns;
|
3391 | case "cascade":
|
3392 | return formatCascadeColumns(columns, fields.value, selectedValues);
|
3393 | default:
|
3394 | return [columns];
|
3395 | }
|
3396 | });
|
3397 | const hasOptions = vue.computed(() => currentColumns.value.some((options) => options.length));
|
3398 | const selectedOptions = vue.computed(() => currentColumns.value.map((options, index) => findOptionByValue(options, selectedValues.value[index], fields.value)));
|
3399 | const selectedIndexes = vue.computed(() => currentColumns.value.map((options, index) => options.findIndex((option) => option[fields.value.value] === selectedValues.value[index])));
|
3400 | const setValue = (index, value) => {
|
3401 | if (selectedValues.value[index] !== value) {
|
3402 | const newValues = selectedValues.value.slice(0);
|
3403 | newValues[index] = value;
|
3404 | selectedValues.value = newValues;
|
3405 | }
|
3406 | };
|
3407 | const getEventParams = () => ({
|
3408 | selectedValues: selectedValues.value.slice(0),
|
3409 | selectedOptions: selectedOptions.value,
|
3410 | selectedIndexes: selectedIndexes.value
|
3411 | });
|
3412 | const onChange = (value, columnIndex) => {
|
3413 | setValue(columnIndex, value);
|
3414 | if (columnsType.value === "cascade") {
|
3415 | selectedValues.value.forEach((value2, index) => {
|
3416 | const options = currentColumns.value[index];
|
3417 | if (!isOptionExist(options, value2, fields.value)) {
|
3418 | setValue(index, options.length ? options[0][fields.value.value] : void 0);
|
3419 | }
|
3420 | });
|
3421 | }
|
3422 | vue.nextTick(() => {
|
3423 | emit("change", extend({
|
3424 | columnIndex
|
3425 | }, getEventParams()));
|
3426 | });
|
3427 | };
|
3428 | const onClickOption = (currentOption, columnIndex) => {
|
3429 | const params = {
|
3430 | columnIndex,
|
3431 | currentOption
|
3432 | };
|
3433 | emit("clickOption", extend(getEventParams(), params));
|
3434 | emit("scrollInto", params);
|
3435 | };
|
3436 | const confirm = () => {
|
3437 | children.forEach((child) => child.stopMomentum());
|
3438 | const params = getEventParams();
|
3439 | vue.nextTick(() => {
|
3440 | emit("confirm", params);
|
3441 | });
|
3442 | return params;
|
3443 | };
|
3444 | const cancel = () => emit("cancel", getEventParams());
|
3445 | const renderColumnItems = () => currentColumns.value.map((options, columnIndex) => vue.createVNode(stdin_default$1I, {
|
3446 | "value": selectedValues.value[columnIndex],
|
3447 | "fields": fields.value,
|
3448 | "options": options,
|
3449 | "readonly": props2.readonly,
|
3450 | "allowHtml": props2.allowHtml,
|
3451 | "optionHeight": optionHeight.value,
|
3452 | "swipeDuration": props2.swipeDuration,
|
3453 | "visibleOptionNum": props2.visibleOptionNum,
|
3454 | "onChange": (value) => onChange(value, columnIndex),
|
3455 | "onClickOption": (option) => onClickOption(option, columnIndex),
|
3456 | "onScrollInto": (option) => {
|
3457 | emit("scrollInto", {
|
3458 | currentOption: option,
|
3459 | columnIndex
|
3460 | });
|
3461 | }
|
3462 | }, {
|
3463 | option: slots.option
|
3464 | }));
|
3465 | const renderMask = (wrapHeight) => {
|
3466 | if (hasOptions.value) {
|
3467 | const frameStyle = {
|
3468 | height: `${optionHeight.value}px`
|
3469 | };
|
3470 | const maskStyle = {
|
3471 | backgroundSize: `100% ${(wrapHeight - optionHeight.value) / 2}px`
|
3472 | };
|
3473 | return [vue.createVNode("div", {
|
3474 | "class": bem$1u("mask"),
|
3475 | "style": maskStyle
|
3476 | }, null), vue.createVNode("div", {
|
3477 | "class": [BORDER_UNSET_TOP_BOTTOM, bem$1u("frame")],
|
3478 | "style": frameStyle
|
3479 | }, null)];
|
3480 | }
|
3481 | };
|
3482 | const renderColumns = () => {
|
3483 | const wrapHeight = optionHeight.value * +props2.visibleOptionNum;
|
3484 | const columnsStyle = {
|
3485 | height: `${wrapHeight}px`
|
3486 | };
|
3487 | return vue.createVNode("div", {
|
3488 | "ref": columnsRef,
|
3489 | "class": bem$1u("columns"),
|
3490 | "style": columnsStyle
|
3491 | }, [renderColumnItems(), renderMask(wrapHeight)]);
|
3492 | };
|
3493 | const renderToolbar = () => {
|
3494 | if (props2.showToolbar && !parent) {
|
3495 | return vue.createVNode(stdin_default$1H, vue.mergeProps(pick(props2, pickerToolbarPropKeys), {
|
3496 | "onConfirm": confirm,
|
3497 | "onCancel": cancel
|
3498 | }), pick(slots, pickerToolbarSlots));
|
3499 | }
|
3500 | };
|
3501 | vue.watch(currentColumns, (columns) => {
|
3502 | columns.forEach((options, index) => {
|
3503 | if (options.length && !isOptionExist(options, selectedValues.value[index], fields.value)) {
|
3504 | setValue(index, getFirstEnabledOption(options)[fields.value.value]);
|
3505 | }
|
3506 | });
|
3507 | }, {
|
3508 | immediate: true
|
3509 | });
|
3510 | let lastEmittedModelValue;
|
3511 | vue.watch(() => props2.modelValue, (newValues) => {
|
3512 | if (!isSameValue(newValues, selectedValues.value) && !isSameValue(newValues, lastEmittedModelValue)) {
|
3513 | selectedValues.value = newValues.slice(0);
|
3514 | lastEmittedModelValue = newValues.slice(0);
|
3515 | }
|
3516 | }, {
|
3517 | deep: true
|
3518 | });
|
3519 | vue.watch(selectedValues, (newValues) => {
|
3520 | if (!isSameValue(newValues, props2.modelValue)) {
|
3521 | lastEmittedModelValue = newValues.slice(0);
|
3522 | emit("update:modelValue", lastEmittedModelValue);
|
3523 | }
|
3524 | }, {
|
3525 | immediate: true
|
3526 | });
|
3527 | use.useEventListener("touchmove", preventDefault, {
|
3528 | target: columnsRef
|
3529 | });
|
3530 | const getSelectedOptions = () => selectedOptions.value;
|
3531 | useExpose({
|
3532 | confirm,
|
3533 | getSelectedOptions
|
3534 | });
|
3535 | return () => {
|
3536 | var _a, _b;
|
3537 | return vue.createVNode("div", {
|
3538 | "class": bem$1u()
|
3539 | }, [props2.toolbarPosition === "top" ? renderToolbar() : null, props2.loading ? vue.createVNode(Loading, {
|
3540 | "class": bem$1u("loading")
|
3541 | }, 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]);
|
3542 | };
|
3543 | }
|
3544 | });
|
3545 | const AREA_EMPTY_CODE = "000000";
|
3546 | const INHERIT_SLOTS = [
|
3547 | "title",
|
3548 | "cancel",
|
3549 | "confirm",
|
3550 | "toolbar",
|
3551 | "columns-top",
|
3552 | "columns-bottom"
|
3553 | ];
|
3554 | const INHERIT_PROPS = [
|
3555 | "title",
|
3556 | "loading",
|
3557 | "readonly",
|
3558 | "optionHeight",
|
3559 | "swipeDuration",
|
3560 | "visibleOptionNum",
|
3561 | "cancelButtonText",
|
3562 | "confirmButtonText"
|
3563 | ];
|
3564 | const makeOption = (text = "", value = AREA_EMPTY_CODE, children = void 0) => ({
|
3565 | text,
|
3566 | value,
|
3567 | children
|
3568 | });
|
3569 | function formatDataForCascade({
|
3570 | areaList,
|
3571 | columnsNum,
|
3572 | columnsPlaceholder: placeholder
|
3573 | }) {
|
3574 | const {
|
3575 | city_list: city = {},
|
3576 | county_list: county = {},
|
3577 | province_list: province = {}
|
3578 | } = areaList;
|
3579 | const showCity = +columnsNum > 1;
|
3580 | const showCounty = +columnsNum > 2;
|
3581 | const getProvinceChildren = () => {
|
3582 | if (showCity) {
|
3583 | return placeholder.length > 1 ? [
|
3584 | makeOption(
|
3585 | placeholder[1],
|
3586 | AREA_EMPTY_CODE,
|
3587 | showCounty ? [] : void 0
|
3588 | )
|
3589 | ] : [];
|
3590 | }
|
3591 | };
|
3592 | const provinceMap = new Map();
|
3593 | Object.keys(province).forEach((code) => {
|
3594 | provinceMap.set(
|
3595 | code.slice(0, 2),
|
3596 | makeOption(province[code], code, getProvinceChildren())
|
3597 | );
|
3598 | });
|
3599 | const cityMap = new Map();
|
3600 | if (showCity) {
|
3601 | const getCityChildren = () => {
|
3602 | if (showCounty) {
|
3603 | return placeholder.length > 2 ? [makeOption(placeholder[2])] : [];
|
3604 | }
|
3605 | };
|
3606 | Object.keys(city).forEach((code) => {
|
3607 | const option = makeOption(city[code], code, getCityChildren());
|
3608 | cityMap.set(code.slice(0, 4), option);
|
3609 | const province2 = provinceMap.get(code.slice(0, 2));
|
3610 | if (province2) {
|
3611 | province2.children.push(option);
|
3612 | }
|
3613 | });
|
3614 | }
|
3615 | if (showCounty) {
|
3616 | Object.keys(county).forEach((code) => {
|
3617 | const city2 = cityMap.get(code.slice(0, 4));
|
3618 | if (city2) {
|
3619 | city2.children.push(makeOption(county[code], code));
|
3620 | }
|
3621 | });
|
3622 | }
|
3623 | const options = Array.from(provinceMap.values());
|
3624 | if (placeholder.length) {
|
3625 | const county2 = showCounty ? [makeOption(placeholder[2])] : void 0;
|
3626 | const city2 = showCity ? [makeOption(placeholder[1], AREA_EMPTY_CODE, county2)] : void 0;
|
3627 | options.unshift(makeOption(placeholder[0], AREA_EMPTY_CODE, city2));
|
3628 | }
|
3629 | return options;
|
3630 | }
|
3631 | const Picker = withInstall(stdin_default$1z);
|
3632 | const [name$1o, bem$1k] = createNamespace("area");
|
3633 | const areaProps = extend({}, pick(pickerSharedProps, INHERIT_PROPS), {
|
3634 | modelValue: String,
|
3635 | columnsNum: makeNumericProp(3),
|
3636 | columnsPlaceholder: makeArrayProp(),
|
3637 | areaList: {
|
3638 | type: Object,
|
3639 | default: () => ({})
|
3640 | }
|
3641 | });
|
3642 | var stdin_default$1y = vue.defineComponent({
|
3643 | name: name$1o,
|
3644 | props: areaProps,
|
3645 | emits: ["change", "confirm", "cancel", "update:modelValue"],
|
3646 | setup(props2, {
|
3647 | emit,
|
3648 | slots
|
3649 | }) {
|
3650 | const codes = vue.ref([]);
|
3651 | const picker = vue.ref();
|
3652 | const columns = vue.computed(() => formatDataForCascade(props2));
|
3653 | const onChange = (...args) => emit("change", ...args);
|
3654 | const onCancel = (...args) => emit("cancel", ...args);
|
3655 | const onConfirm = (...args) => emit("confirm", ...args);
|
3656 | vue.watch(codes, (newCodes) => {
|
3657 | const lastCode = newCodes.length ? newCodes[newCodes.length - 1] : "";
|
3658 | if (lastCode && lastCode !== props2.modelValue) {
|
3659 | emit("update:modelValue", lastCode);
|
3660 | }
|
3661 | }, {
|
3662 | deep: true
|
3663 | });
|
3664 | vue.watch(() => props2.modelValue, (newCode) => {
|
3665 | if (newCode) {
|
3666 | const lastCode = codes.value.length ? codes.value[codes.value.length - 1] : "";
|
3667 | if (newCode !== lastCode) {
|
3668 | codes.value = [`${newCode.slice(0, 2)}0000`, `${newCode.slice(0, 4)}00`, newCode].slice(0, +props2.columnsNum);
|
3669 | }
|
3670 | } else {
|
3671 | codes.value = [];
|
3672 | }
|
3673 | }, {
|
3674 | immediate: true
|
3675 | });
|
3676 | useExpose({
|
3677 | confirm: () => {
|
3678 | var _a;
|
3679 | return (_a = picker.value) == null ? void 0 : _a.confirm();
|
3680 | },
|
3681 | getSelectedOptions: () => {
|
3682 | var _a;
|
3683 | return ((_a = picker.value) == null ? void 0 : _a.getSelectedOptions()) || [];
|
3684 | }
|
3685 | });
|
3686 | return () => vue.createVNode(Picker, vue.mergeProps({
|
3687 | "ref": picker,
|
3688 | "modelValue": codes.value,
|
3689 | "onUpdate:modelValue": ($event) => codes.value = $event,
|
3690 | "class": bem$1k(),
|
3691 | "columns": columns.value,
|
3692 | "onChange": onChange,
|
3693 | "onCancel": onCancel,
|
3694 | "onConfirm": onConfirm
|
3695 | }, pick(props2, INHERIT_PROPS)), pick(slots, INHERIT_SLOTS));
|
3696 | }
|
3697 | });
|
3698 | const Area = withInstall(stdin_default$1y);
|
3699 | const [name$1n, bem$1j] = createNamespace("cell");
|
3700 | const cellSharedProps = {
|
3701 | tag: makeStringProp("div"),
|
3702 | icon: String,
|
3703 | size: String,
|
3704 | title: numericProp,
|
3705 | value: numericProp,
|
3706 | label: numericProp,
|
3707 | center: Boolean,
|
3708 | isLink: Boolean,
|
3709 | border: truthProp,
|
3710 | iconPrefix: String,
|
3711 | valueClass: unknownProp,
|
3712 | labelClass: unknownProp,
|
3713 | titleClass: unknownProp,
|
3714 | titleStyle: null,
|
3715 | arrowDirection: String,
|
3716 | required: {
|
3717 | type: [Boolean, String],
|
3718 | default: null
|
3719 | },
|
3720 | clickable: {
|
3721 | type: Boolean,
|
3722 | default: null
|
3723 | }
|
3724 | };
|
3725 | const cellProps = extend({}, cellSharedProps, routeProps);
|
3726 | var stdin_default$1x = vue.defineComponent({
|
3727 | name: name$1n,
|
3728 | props: cellProps,
|
3729 | setup(props2, {
|
3730 | slots
|
3731 | }) {
|
3732 | const route2 = useRoute();
|
3733 | const renderLabel = () => {
|
3734 | const showLabel = slots.label || isDef(props2.label);
|
3735 | if (showLabel) {
|
3736 | return vue.createVNode("div", {
|
3737 | "class": [bem$1j("label"), props2.labelClass]
|
3738 | }, [slots.label ? slots.label() : props2.label]);
|
3739 | }
|
3740 | };
|
3741 | const renderTitle = () => {
|
3742 | var _a;
|
3743 | if (slots.title || isDef(props2.title)) {
|
3744 | const titleSlot = (_a = slots.title) == null ? void 0 : _a.call(slots);
|
3745 | if (Array.isArray(titleSlot) && titleSlot.length === 0) {
|
3746 | return;
|
3747 | }
|
3748 | return vue.createVNode("div", {
|
3749 | "class": [bem$1j("title"), props2.titleClass],
|
3750 | "style": props2.titleStyle
|
3751 | }, [titleSlot || vue.createVNode("span", null, [props2.title]), renderLabel()]);
|
3752 | }
|
3753 | };
|
3754 | const renderValue = () => {
|
3755 | const slot = slots.value || slots.default;
|
3756 | const hasValue = slot || isDef(props2.value);
|
3757 | if (hasValue) {
|
3758 | return vue.createVNode("div", {
|
3759 | "class": [bem$1j("value"), props2.valueClass]
|
3760 | }, [slot ? slot() : vue.createVNode("span", null, [props2.value])]);
|
3761 | }
|
3762 | };
|
3763 | const renderLeftIcon = () => {
|
3764 | if (slots.icon) {
|
3765 | return slots.icon();
|
3766 | }
|
3767 | if (props2.icon) {
|
3768 | return vue.createVNode(Icon, {
|
3769 | "name": props2.icon,
|
3770 | "class": bem$1j("left-icon"),
|
3771 | "classPrefix": props2.iconPrefix
|
3772 | }, null);
|
3773 | }
|
3774 | };
|
3775 | const renderRightIcon = () => {
|
3776 | if (slots["right-icon"]) {
|
3777 | return slots["right-icon"]();
|
3778 | }
|
3779 | if (props2.isLink) {
|
3780 | const name2 = props2.arrowDirection && props2.arrowDirection !== "right" ? `arrow-${props2.arrowDirection}` : "arrow";
|
3781 | return vue.createVNode(Icon, {
|
3782 | "name": name2,
|
3783 | "class": bem$1j("right-icon")
|
3784 | }, null);
|
3785 | }
|
3786 | };
|
3787 | return () => {
|
3788 | var _a;
|
3789 | const {
|
3790 | tag,
|
3791 | size,
|
3792 | center,
|
3793 | border,
|
3794 | isLink,
|
3795 | required
|
3796 | } = props2;
|
3797 | const clickable = (_a = props2.clickable) != null ? _a : isLink;
|
3798 | const classes = {
|
3799 | center,
|
3800 | required: !!required,
|
3801 | clickable,
|
3802 | borderless: !border
|
3803 | };
|
3804 | if (size) {
|
3805 | classes[size] = !!size;
|
3806 | }
|
3807 | return vue.createVNode(tag, {
|
3808 | "class": bem$1j(classes),
|
3809 | "role": clickable ? "button" : void 0,
|
3810 | "tabindex": clickable ? 0 : void 0,
|
3811 | "onClick": route2
|
3812 | }, {
|
3813 | default: () => {
|
3814 | var _a2;
|
3815 | return [renderLeftIcon(), renderTitle(), renderValue(), renderRightIcon(), (_a2 = slots.extra) == null ? void 0 : _a2.call(slots)];
|
3816 | }
|
3817 | });
|
3818 | };
|
3819 | }
|
3820 | });
|
3821 | const Cell = withInstall(stdin_default$1x);
|
3822 | const [name$1m, bem$1i] = createNamespace("form");
|
3823 | const formProps = {
|
3824 | colon: Boolean,
|
3825 | disabled: Boolean,
|
3826 | readonly: Boolean,
|
3827 | required: [Boolean, String],
|
3828 | showError: Boolean,
|
3829 | labelWidth: numericProp,
|
3830 | labelAlign: String,
|
3831 | inputAlign: String,
|
3832 | scrollToError: Boolean,
|
3833 | scrollToErrorPosition: String,
|
3834 | validateFirst: Boolean,
|
3835 | submitOnEnter: truthProp,
|
3836 | showErrorMessage: truthProp,
|
3837 | errorMessageAlign: String,
|
3838 | validateTrigger: {
|
3839 | type: [String, Array],
|
3840 | default: "onBlur"
|
3841 | }
|
3842 | };
|
3843 | var stdin_default$1w = vue.defineComponent({
|
3844 | name: name$1m,
|
3845 | props: formProps,
|
3846 | emits: ["submit", "failed"],
|
3847 | setup(props2, {
|
3848 | emit,
|
3849 | slots
|
3850 | }) {
|
3851 | const {
|
3852 | children,
|
3853 | linkChildren
|
3854 | } = use.useChildren(FORM_KEY);
|
3855 | const getFieldsByNames = (names) => {
|
3856 | if (names) {
|
3857 | return children.filter((field) => names.includes(field.name));
|
3858 | }
|
3859 | return children;
|
3860 | };
|
3861 | const validateSeq = (names) => new Promise((resolve, reject) => {
|
3862 | const errors = [];
|
3863 | const fields = getFieldsByNames(names);
|
3864 | fields.reduce((promise, field) => promise.then(() => {
|
3865 | if (!errors.length) {
|
3866 | return field.validate().then((error) => {
|
3867 | if (error) {
|
3868 | errors.push(error);
|
3869 | }
|
3870 | });
|
3871 | }
|
3872 | }), Promise.resolve()).then(() => {
|
3873 | if (errors.length) {
|
3874 | reject(errors);
|
3875 | } else {
|
3876 | resolve();
|
3877 | }
|
3878 | });
|
3879 | });
|
3880 | const validateAll = (names) => new Promise((resolve, reject) => {
|
3881 | const fields = getFieldsByNames(names);
|
3882 | Promise.all(fields.map((item) => item.validate())).then((errors) => {
|
3883 | errors = errors.filter(Boolean);
|
3884 | if (errors.length) {
|
3885 | reject(errors);
|
3886 | } else {
|
3887 | resolve();
|
3888 | }
|
3889 | });
|
3890 | });
|
3891 | const validateField = (name2) => {
|
3892 | const matched = children.find((item) => item.name === name2);
|
3893 | if (matched) {
|
3894 | return new Promise((resolve, reject) => {
|
3895 | matched.validate().then((error) => {
|
3896 | if (error) {
|
3897 | reject(error);
|
3898 | } else {
|
3899 | resolve();
|
3900 | }
|
3901 | });
|
3902 | });
|
3903 | }
|
3904 | return Promise.reject();
|
3905 | };
|
3906 | const validate = (name2) => {
|
3907 | if (typeof name2 === "string") {
|
3908 | return validateField(name2);
|
3909 | }
|
3910 | return props2.validateFirst ? validateSeq(name2) : validateAll(name2);
|
3911 | };
|
3912 | const resetValidation = (name2) => {
|
3913 | if (typeof name2 === "string") {
|
3914 | name2 = [name2];
|
3915 | }
|
3916 | const fields = getFieldsByNames(name2);
|
3917 | fields.forEach((item) => {
|
3918 | item.resetValidation();
|
3919 | });
|
3920 | };
|
3921 | const getValidationStatus = () => children.reduce((form, field) => {
|
3922 | form[field.name] = field.getValidationStatus();
|
3923 | return form;
|
3924 | }, {});
|
3925 | const scrollToField = (name2, options) => {
|
3926 | children.some((item) => {
|
3927 | if (item.name === name2) {
|
3928 | item.$el.scrollIntoView(options);
|
3929 | return true;
|
3930 | }
|
3931 | return false;
|
3932 | });
|
3933 | };
|
3934 | const getValues = () => children.reduce((form, field) => {
|
3935 | if (field.name !== void 0) {
|
3936 | form[field.name] = field.formValue.value;
|
3937 | }
|
3938 | return form;
|
3939 | }, {});
|
3940 | const submit = () => {
|
3941 | const values = getValues();
|
3942 | validate().then(() => emit("submit", values)).catch((errors) => {
|
3943 | emit("failed", {
|
3944 | values,
|
3945 | errors
|
3946 | });
|
3947 | const {
|
3948 | scrollToError,
|
3949 | scrollToErrorPosition
|
3950 | } = props2;
|
3951 | if (scrollToError && errors[0].name) {
|
3952 | scrollToField(errors[0].name, scrollToErrorPosition ? {
|
3953 | block: scrollToErrorPosition
|
3954 | } : void 0);
|
3955 | }
|
3956 | });
|
3957 | };
|
3958 | const onSubmit = (event) => {
|
3959 | preventDefault(event);
|
3960 | submit();
|
3961 | };
|
3962 | linkChildren({
|
3963 | props: props2
|
3964 | });
|
3965 | useExpose({
|
3966 | submit,
|
3967 | validate,
|
3968 | getValues,
|
3969 | scrollToField,
|
3970 | resetValidation,
|
3971 | getValidationStatus
|
3972 | });
|
3973 | return () => {
|
3974 | var _a;
|
3975 | return vue.createVNode("form", {
|
3976 | "class": bem$1i(),
|
3977 | "onSubmit": onSubmit
|
3978 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
3979 | };
|
3980 | }
|
3981 | });
|
3982 | const Form = withInstall(stdin_default$1w);
|
3983 | function isEmptyValue(value) {
|
3984 | if (Array.isArray(value)) {
|
3985 | return !value.length;
|
3986 | }
|
3987 | if (value === 0) {
|
3988 | return false;
|
3989 | }
|
3990 | return !value;
|
3991 | }
|
3992 | function runSyncRule(value, rule) {
|
3993 | if (isEmptyValue(value)) {
|
3994 | if (rule.required) {
|
3995 | return false;
|
3996 | }
|
3997 | if (rule.validateEmpty === false) {
|
3998 | return true;
|
3999 | }
|
4000 | }
|
4001 | if (rule.pattern && !rule.pattern.test(String(value))) {
|
4002 | return false;
|
4003 | }
|
4004 | return true;
|
4005 | }
|
4006 | function runRuleValidator(value, rule) {
|
4007 | return new Promise((resolve) => {
|
4008 | const returnVal = rule.validator(value, rule);
|
4009 | if (isPromise(returnVal)) {
|
4010 | returnVal.then(resolve);
|
4011 | return;
|
4012 | }
|
4013 | resolve(returnVal);
|
4014 | });
|
4015 | }
|
4016 | function getRuleMessage(value, rule) {
|
4017 | const { message } = rule;
|
4018 | if (isFunction(message)) {
|
4019 | return message(value, rule);
|
4020 | }
|
4021 | return message || "";
|
4022 | }
|
4023 | function startComposing({ target }) {
|
4024 | target.composing = true;
|
4025 | }
|
4026 | function endComposing({ target }) {
|
4027 | if (target.composing) {
|
4028 | target.composing = false;
|
4029 | target.dispatchEvent(new Event("input"));
|
4030 | }
|
4031 | }
|
4032 | function resizeTextarea(input, autosize) {
|
4033 | const scrollTop = getRootScrollTop();
|
4034 | input.style.height = "auto";
|
4035 | let height = input.scrollHeight;
|
4036 | if (isObject(autosize)) {
|
4037 | const { maxHeight, minHeight } = autosize;
|
4038 | if (maxHeight !== void 0) {
|
4039 | height = Math.min(height, maxHeight);
|
4040 | }
|
4041 | if (minHeight !== void 0) {
|
4042 | height = Math.max(height, minHeight);
|
4043 | }
|
4044 | }
|
4045 | if (height) {
|
4046 | input.style.height = `${height}px`;
|
4047 | setRootScrollTop(scrollTop);
|
4048 | }
|
4049 | }
|
4050 | function mapInputType(type) {
|
4051 | if (type === "number") {
|
4052 | return {
|
4053 | type: "text",
|
4054 | inputmode: "decimal"
|
4055 | };
|
4056 | }
|
4057 | if (type === "digit") {
|
4058 | return {
|
4059 | type: "tel",
|
4060 | inputmode: "numeric"
|
4061 | };
|
4062 | }
|
4063 | return { type };
|
4064 | }
|
4065 | function getStringLength(str) {
|
4066 | return [...str].length;
|
4067 | }
|
4068 | function cutString(str, maxlength) {
|
4069 | return [...str].slice(0, maxlength).join("");
|
4070 | }
|
4071 | const [name$1l, bem$1h] = createNamespace("field");
|
4072 | const fieldSharedProps = {
|
4073 | id: String,
|
4074 | name: String,
|
4075 | leftIcon: String,
|
4076 | rightIcon: String,
|
4077 | autofocus: Boolean,
|
4078 | clearable: Boolean,
|
4079 | maxlength: numericProp,
|
4080 | max: Number,
|
4081 | min: Number,
|
4082 | formatter: Function,
|
4083 | clearIcon: makeStringProp("clear"),
|
4084 | modelValue: makeNumericProp(""),
|
4085 | inputAlign: String,
|
4086 | placeholder: String,
|
4087 | autocomplete: String,
|
4088 | autocapitalize: String,
|
4089 | autocorrect: String,
|
4090 | errorMessage: String,
|
4091 | enterkeyhint: String,
|
4092 | clearTrigger: makeStringProp("focus"),
|
4093 | formatTrigger: makeStringProp("onChange"),
|
4094 | spellcheck: {
|
4095 | type: Boolean,
|
4096 | default: null
|
4097 | },
|
4098 | error: {
|
4099 | type: Boolean,
|
4100 | default: null
|
4101 | },
|
4102 | disabled: {
|
4103 | type: Boolean,
|
4104 | default: null
|
4105 | },
|
4106 | readonly: {
|
4107 | type: Boolean,
|
4108 | default: null
|
4109 | }
|
4110 | };
|
4111 | const fieldProps = extend({}, cellSharedProps, fieldSharedProps, {
|
4112 | rows: numericProp,
|
4113 | type: makeStringProp("text"),
|
4114 | rules: Array,
|
4115 | autosize: [Boolean, Object],
|
4116 | labelWidth: numericProp,
|
4117 | labelClass: unknownProp,
|
4118 | labelAlign: String,
|
4119 | showWordLimit: Boolean,
|
4120 | errorMessageAlign: String,
|
4121 | colon: {
|
4122 | type: Boolean,
|
4123 | default: null
|
4124 | }
|
4125 | });
|
4126 | var stdin_default$1v = vue.defineComponent({
|
4127 | name: name$1l,
|
4128 | props: fieldProps,
|
4129 | emits: ["blur", "focus", "clear", "keypress", "clickInput", "endValidate", "startValidate", "clickLeftIcon", "clickRightIcon", "update:modelValue"],
|
4130 | setup(props2, {
|
4131 | emit,
|
4132 | slots
|
4133 | }) {
|
4134 | const id = useId();
|
4135 | const state = vue.reactive({
|
4136 | status: "unvalidated",
|
4137 | focused: false,
|
4138 | validateMessage: ""
|
4139 | });
|
4140 | const inputRef = vue.ref();
|
4141 | const clearIconRef = vue.ref();
|
4142 | const customValue = vue.ref();
|
4143 | const {
|
4144 | parent: form
|
4145 | } = use.useParent(FORM_KEY);
|
4146 | const getModelValue = () => {
|
4147 | var _a;
|
4148 | return String((_a = props2.modelValue) != null ? _a : "");
|
4149 | };
|
4150 | const getProp = (key) => {
|
4151 | if (isDef(props2[key])) {
|
4152 | return props2[key];
|
4153 | }
|
4154 | if (form && isDef(form.props[key])) {
|
4155 | return form.props[key];
|
4156 | }
|
4157 | };
|
4158 | const showClear = vue.computed(() => {
|
4159 | const readonly = getProp("readonly");
|
4160 | if (props2.clearable && !readonly) {
|
4161 | const hasValue = getModelValue() !== "";
|
4162 | const trigger = props2.clearTrigger === "always" || props2.clearTrigger === "focus" && state.focused;
|
4163 | return hasValue && trigger;
|
4164 | }
|
4165 | return false;
|
4166 | });
|
4167 | const formValue = vue.computed(() => {
|
4168 | if (customValue.value && slots.input) {
|
4169 | return customValue.value();
|
4170 | }
|
4171 | return props2.modelValue;
|
4172 | });
|
4173 | const showRequiredMark = vue.computed(() => {
|
4174 | var _a;
|
4175 | const required = getProp("required");
|
4176 | if (required === "auto") {
|
4177 | return (_a = props2.rules) == null ? void 0 : _a.some((rule) => rule.required);
|
4178 | }
|
4179 | return required;
|
4180 | });
|
4181 | const runRules = (rules) => rules.reduce((promise, rule) => promise.then(() => {
|
4182 | if (state.status === "failed") {
|
4183 | return;
|
4184 | }
|
4185 | let {
|
4186 | value
|
4187 | } = formValue;
|
4188 | if (rule.formatter) {
|
4189 | value = rule.formatter(value, rule);
|
4190 | }
|
4191 | if (!runSyncRule(value, rule)) {
|
4192 | state.status = "failed";
|
4193 | state.validateMessage = getRuleMessage(value, rule);
|
4194 | return;
|
4195 | }
|
4196 | if (rule.validator) {
|
4197 | if (isEmptyValue(value) && rule.validateEmpty === false) {
|
4198 | return;
|
4199 | }
|
4200 | return runRuleValidator(value, rule).then((result) => {
|
4201 | if (result && typeof result === "string") {
|
4202 | state.status = "failed";
|
4203 | state.validateMessage = result;
|
4204 | } else if (result === false) {
|
4205 | state.status = "failed";
|
4206 | state.validateMessage = getRuleMessage(value, rule);
|
4207 | }
|
4208 | });
|
4209 | }
|
4210 | }), Promise.resolve());
|
4211 | const resetValidation = () => {
|
4212 | state.status = "unvalidated";
|
4213 | state.validateMessage = "";
|
4214 | };
|
4215 | const endValidate = () => emit("endValidate", {
|
4216 | status: state.status,
|
4217 | message: state.validateMessage
|
4218 | });
|
4219 | const validate = (rules = props2.rules) => new Promise((resolve) => {
|
4220 | resetValidation();
|
4221 | if (rules) {
|
4222 | emit("startValidate");
|
4223 | runRules(rules).then(() => {
|
4224 | if (state.status === "failed") {
|
4225 | resolve({
|
4226 | name: props2.name,
|
4227 | message: state.validateMessage
|
4228 | });
|
4229 | endValidate();
|
4230 | } else {
|
4231 | state.status = "passed";
|
4232 | resolve();
|
4233 | endValidate();
|
4234 | }
|
4235 | });
|
4236 | } else {
|
4237 | resolve();
|
4238 | }
|
4239 | });
|
4240 | const validateWithTrigger = (trigger) => {
|
4241 | if (form && props2.rules) {
|
4242 | const {
|
4243 | validateTrigger
|
4244 | } = form.props;
|
4245 | const defaultTrigger = toArray(validateTrigger).includes(trigger);
|
4246 | const rules = props2.rules.filter((rule) => {
|
4247 | if (rule.trigger) {
|
4248 | return toArray(rule.trigger).includes(trigger);
|
4249 | }
|
4250 | return defaultTrigger;
|
4251 | });
|
4252 | if (rules.length) {
|
4253 | validate(rules);
|
4254 | }
|
4255 | }
|
4256 | };
|
4257 | const limitValueLength = (value) => {
|
4258 | var _a;
|
4259 | const {
|
4260 | maxlength
|
4261 | } = props2;
|
4262 | if (isDef(maxlength) && getStringLength(value) > +maxlength) {
|
4263 | const modelValue = getModelValue();
|
4264 | if (modelValue && getStringLength(modelValue) === +maxlength) {
|
4265 | return modelValue;
|
4266 | }
|
4267 | const selectionEnd = (_a = inputRef.value) == null ? void 0 : _a.selectionEnd;
|
4268 | if (state.focused && selectionEnd) {
|
4269 | const valueArr = [...value];
|
4270 | const exceededLength = valueArr.length - +maxlength;
|
4271 | valueArr.splice(selectionEnd - exceededLength, exceededLength);
|
4272 | return valueArr.join("");
|
4273 | }
|
4274 | return cutString(value, +maxlength);
|
4275 | }
|
4276 | return value;
|
4277 | };
|
4278 | const updateValue = (value, trigger = "onChange") => {
|
4279 | var _a, _b;
|
4280 | const originalValue = value;
|
4281 | value = limitValueLength(value);
|
4282 | const limitDiffLen = getStringLength(originalValue) - getStringLength(value);
|
4283 | if (props2.type === "number" || props2.type === "digit") {
|
4284 | const isNumber = props2.type === "number";
|
4285 | value = formatNumber(value, isNumber, isNumber);
|
4286 | if (trigger === "onBlur" && value !== "" && (props2.min !== void 0 || props2.max !== void 0)) {
|
4287 | const adjustedValue = clamp(+value, (_a = props2.min) != null ? _a : -Infinity, (_b = props2.max) != null ? _b : Infinity);
|
4288 | value = adjustedValue.toString();
|
4289 | }
|
4290 | }
|
4291 | let formatterDiffLen = 0;
|
4292 | if (props2.formatter && trigger === props2.formatTrigger) {
|
4293 | const {
|
4294 | formatter,
|
4295 | maxlength
|
4296 | } = props2;
|
4297 | value = formatter(value);
|
4298 | if (isDef(maxlength) && getStringLength(value) > +maxlength) {
|
4299 | value = cutString(value, +maxlength);
|
4300 | }
|
4301 | if (inputRef.value && state.focused) {
|
4302 | const {
|
4303 | selectionEnd
|
4304 | } = inputRef.value;
|
4305 | const bcoVal = cutString(originalValue, selectionEnd);
|
4306 | formatterDiffLen = getStringLength(formatter(bcoVal)) - getStringLength(bcoVal);
|
4307 | }
|
4308 | }
|
4309 | if (inputRef.value && inputRef.value.value !== value) {
|
4310 | if (state.focused) {
|
4311 | let {
|
4312 | selectionStart,
|
4313 | selectionEnd
|
4314 | } = inputRef.value;
|
4315 | inputRef.value.value = value;
|
4316 | if (isDef(selectionStart) && isDef(selectionEnd)) {
|
4317 | const valueLen = getStringLength(value);
|
4318 | if (limitDiffLen) {
|
4319 | selectionStart -= limitDiffLen;
|
4320 | selectionEnd -= limitDiffLen;
|
4321 | } else if (formatterDiffLen) {
|
4322 | selectionStart += formatterDiffLen;
|
4323 | selectionEnd += formatterDiffLen;
|
4324 | }
|
4325 | inputRef.value.setSelectionRange(Math.min(selectionStart, valueLen), Math.min(selectionEnd, valueLen));
|
4326 | }
|
4327 | } else {
|
4328 | inputRef.value.value = value;
|
4329 | }
|
4330 | }
|
4331 | if (value !== props2.modelValue) {
|
4332 | emit("update:modelValue", value);
|
4333 | }
|
4334 | };
|
4335 | const onInput = (event) => {
|
4336 | if (!event.target.composing) {
|
4337 | updateValue(event.target.value);
|
4338 | }
|
4339 | };
|
4340 | const blur = () => {
|
4341 | var _a;
|
4342 | return (_a = inputRef.value) == null ? void 0 : _a.blur();
|
4343 | };
|
4344 | const focus = () => {
|
4345 | var _a;
|
4346 | return (_a = inputRef.value) == null ? void 0 : _a.focus();
|
4347 | };
|
4348 | const adjustTextareaSize = () => {
|
4349 | const input = inputRef.value;
|
4350 | if (props2.type === "textarea" && props2.autosize && input) {
|
4351 | resizeTextarea(input, props2.autosize);
|
4352 | }
|
4353 | };
|
4354 | const onFocus = (event) => {
|
4355 | state.focused = true;
|
4356 | emit("focus", event);
|
4357 | vue.nextTick(adjustTextareaSize);
|
4358 | if (getProp("readonly")) {
|
4359 | blur();
|
4360 | }
|
4361 | };
|
4362 | const onBlur = (event) => {
|
4363 | state.focused = false;
|
4364 | updateValue(getModelValue(), "onBlur");
|
4365 | emit("blur", event);
|
4366 | if (getProp("readonly")) {
|
4367 | return;
|
4368 | }
|
4369 | validateWithTrigger("onBlur");
|
4370 | vue.nextTick(adjustTextareaSize);
|
4371 | resetScroll();
|
4372 | };
|
4373 | const onClickInput = (event) => emit("clickInput", event);
|
4374 | const onClickLeftIcon = (event) => emit("clickLeftIcon", event);
|
4375 | const onClickRightIcon = (event) => emit("clickRightIcon", event);
|
4376 | const onClear = (event) => {
|
4377 | preventDefault(event);
|
4378 | emit("update:modelValue", "");
|
4379 | emit("clear", event);
|
4380 | };
|
4381 | const showError = vue.computed(() => {
|
4382 | if (typeof props2.error === "boolean") {
|
4383 | return props2.error;
|
4384 | }
|
4385 | if (form && form.props.showError && state.status === "failed") {
|
4386 | return true;
|
4387 | }
|
4388 | });
|
4389 | const labelStyle = vue.computed(() => {
|
4390 | const labelWidth = getProp("labelWidth");
|
4391 | const labelAlign = getProp("labelAlign");
|
4392 | if (labelWidth && labelAlign !== "top") {
|
4393 | return {
|
4394 | width: addUnit(labelWidth)
|
4395 | };
|
4396 | }
|
4397 | });
|
4398 | const onKeypress = (event) => {
|
4399 | const ENTER_CODE = 13;
|
4400 | if (event.keyCode === ENTER_CODE) {
|
4401 | const submitOnEnter = form && form.props.submitOnEnter;
|
4402 | if (!submitOnEnter && props2.type !== "textarea") {
|
4403 | preventDefault(event);
|
4404 | }
|
4405 | if (props2.type === "search") {
|
4406 | blur();
|
4407 | }
|
4408 | }
|
4409 | emit("keypress", event);
|
4410 | };
|
4411 | const getInputId = () => props2.id || `${id}-input`;
|
4412 | const getValidationStatus = () => state.status;
|
4413 | const renderInput = () => {
|
4414 | const controlClass = bem$1h("control", [getProp("inputAlign"), {
|
4415 | error: showError.value,
|
4416 | custom: !!slots.input,
|
4417 | "min-height": props2.type === "textarea" && !props2.autosize
|
4418 | }]);
|
4419 | if (slots.input) {
|
4420 | return vue.createVNode("div", {
|
4421 | "class": controlClass,
|
4422 | "onClick": onClickInput
|
4423 | }, [slots.input()]);
|
4424 | }
|
4425 | const inputAttrs = {
|
4426 | id: getInputId(),
|
4427 | ref: inputRef,
|
4428 | name: props2.name,
|
4429 | rows: props2.rows !== void 0 ? +props2.rows : void 0,
|
4430 | class: controlClass,
|
4431 | disabled: getProp("disabled"),
|
4432 | readonly: getProp("readonly"),
|
4433 | autofocus: props2.autofocus,
|
4434 | placeholder: props2.placeholder,
|
4435 | autocomplete: props2.autocomplete,
|
4436 | autocapitalize: props2.autocapitalize,
|
4437 | autocorrect: props2.autocorrect,
|
4438 | enterkeyhint: props2.enterkeyhint,
|
4439 | spellcheck: props2.spellcheck,
|
4440 | "aria-labelledby": props2.label ? `${id}-label` : void 0,
|
4441 | "data-allow-mismatch": "attribute",
|
4442 | onBlur,
|
4443 | onFocus,
|
4444 | onInput,
|
4445 | onClick: onClickInput,
|
4446 | onChange: endComposing,
|
4447 | onKeypress,
|
4448 | onCompositionend: endComposing,
|
4449 | onCompositionstart: startComposing
|
4450 | };
|
4451 | if (props2.type === "textarea") {
|
4452 | return vue.createVNode("textarea", inputAttrs, null);
|
4453 | }
|
4454 | return vue.createVNode("input", vue.mergeProps(mapInputType(props2.type), inputAttrs), null);
|
4455 | };
|
4456 | const renderLeftIcon = () => {
|
4457 | const leftIconSlot = slots["left-icon"];
|
4458 | if (props2.leftIcon || leftIconSlot) {
|
4459 | return vue.createVNode("div", {
|
4460 | "class": bem$1h("left-icon"),
|
4461 | "onClick": onClickLeftIcon
|
4462 | }, [leftIconSlot ? leftIconSlot() : vue.createVNode(Icon, {
|
4463 | "name": props2.leftIcon,
|
4464 | "classPrefix": props2.iconPrefix
|
4465 | }, null)]);
|
4466 | }
|
4467 | };
|
4468 | const renderRightIcon = () => {
|
4469 | const rightIconSlot = slots["right-icon"];
|
4470 | if (props2.rightIcon || rightIconSlot) {
|
4471 | return vue.createVNode("div", {
|
4472 | "class": bem$1h("right-icon"),
|
4473 | "onClick": onClickRightIcon
|
4474 | }, [rightIconSlot ? rightIconSlot() : vue.createVNode(Icon, {
|
4475 | "name": props2.rightIcon,
|
4476 | "classPrefix": props2.iconPrefix
|
4477 | }, null)]);
|
4478 | }
|
4479 | };
|
4480 | const renderWordLimit = () => {
|
4481 | if (props2.showWordLimit && props2.maxlength) {
|
4482 | const count = getStringLength(getModelValue());
|
4483 | return vue.createVNode("div", {
|
4484 | "class": bem$1h("word-limit")
|
4485 | }, [vue.createVNode("span", {
|
4486 | "class": bem$1h("word-num")
|
4487 | }, [count]), vue.createTextVNode("/"), props2.maxlength]);
|
4488 | }
|
4489 | };
|
4490 | const renderMessage = () => {
|
4491 | if (form && form.props.showErrorMessage === false) {
|
4492 | return;
|
4493 | }
|
4494 | const message = props2.errorMessage || state.validateMessage;
|
4495 | if (message) {
|
4496 | const slot = slots["error-message"];
|
4497 | const errorMessageAlign = getProp("errorMessageAlign");
|
4498 | return vue.createVNode("div", {
|
4499 | "class": bem$1h("error-message", errorMessageAlign)
|
4500 | }, [slot ? slot({
|
4501 | message
|
4502 | }) : message]);
|
4503 | }
|
4504 | };
|
4505 | const renderLabel = () => {
|
4506 | const labelWidth = getProp("labelWidth");
|
4507 | const labelAlign = getProp("labelAlign");
|
4508 | const colon = getProp("colon") ? ":" : "";
|
4509 | if (slots.label) {
|
4510 | return [slots.label(), colon];
|
4511 | }
|
4512 | if (props2.label) {
|
4513 | return vue.createVNode("label", {
|
4514 | "id": `${id}-label`,
|
4515 | "for": slots.input ? void 0 : getInputId(),
|
4516 | "data-allow-mismatch": "attribute",
|
4517 | "onClick": (event) => {
|
4518 | preventDefault(event);
|
4519 | focus();
|
4520 | },
|
4521 | "style": labelAlign === "top" && labelWidth ? {
|
4522 | width: addUnit(labelWidth)
|
4523 | } : void 0
|
4524 | }, [props2.label + colon]);
|
4525 | }
|
4526 | };
|
4527 | const renderFieldBody = () => [vue.createVNode("div", {
|
4528 | "class": bem$1h("body")
|
4529 | }, [renderInput(), showClear.value && vue.createVNode(Icon, {
|
4530 | "ref": clearIconRef,
|
4531 | "name": props2.clearIcon,
|
4532 | "class": bem$1h("clear")
|
4533 | }, null), renderRightIcon(), slots.button && vue.createVNode("div", {
|
4534 | "class": bem$1h("button")
|
4535 | }, [slots.button()])]), renderWordLimit(), renderMessage()];
|
4536 | useExpose({
|
4537 | blur,
|
4538 | focus,
|
4539 | validate,
|
4540 | formValue,
|
4541 | resetValidation,
|
4542 | getValidationStatus
|
4543 | });
|
4544 | vue.provide(use.CUSTOM_FIELD_INJECTION_KEY, {
|
4545 | customValue,
|
4546 | resetValidation,
|
4547 | validateWithTrigger
|
4548 | });
|
4549 | vue.watch(() => props2.modelValue, () => {
|
4550 | updateValue(getModelValue());
|
4551 | resetValidation();
|
4552 | validateWithTrigger("onChange");
|
4553 | vue.nextTick(adjustTextareaSize);
|
4554 | });
|
4555 | vue.onMounted(() => {
|
4556 | updateValue(getModelValue(), props2.formatTrigger);
|
4557 | vue.nextTick(adjustTextareaSize);
|
4558 | });
|
4559 | use.useEventListener("touchstart", onClear, {
|
4560 | target: vue.computed(() => {
|
4561 | var _a;
|
4562 | return (_a = clearIconRef.value) == null ? void 0 : _a.$el;
|
4563 | })
|
4564 | });
|
4565 | return () => {
|
4566 | const disabled = getProp("disabled");
|
4567 | const labelAlign = getProp("labelAlign");
|
4568 | const LeftIcon = renderLeftIcon();
|
4569 | const renderTitle = () => {
|
4570 | const Label = renderLabel();
|
4571 | if (labelAlign === "top") {
|
4572 | return [LeftIcon, Label].filter(Boolean);
|
4573 | }
|
4574 | return Label || [];
|
4575 | };
|
4576 | return vue.createVNode(Cell, {
|
4577 | "size": props2.size,
|
4578 | "class": bem$1h({
|
4579 | error: showError.value,
|
4580 | disabled,
|
4581 | [`label-${labelAlign}`]: labelAlign
|
4582 | }),
|
4583 | "center": props2.center,
|
4584 | "border": props2.border,
|
4585 | "isLink": props2.isLink,
|
4586 | "clickable": props2.clickable,
|
4587 | "titleStyle": labelStyle.value,
|
4588 | "valueClass": bem$1h("value"),
|
4589 | "titleClass": [bem$1h("label", [labelAlign, {
|
4590 | required: showRequiredMark.value
|
4591 | }]), props2.labelClass],
|
4592 | "arrowDirection": props2.arrowDirection
|
4593 | }, {
|
4594 | icon: LeftIcon && labelAlign !== "top" ? () => LeftIcon : null,
|
4595 | title: renderTitle,
|
4596 | value: renderFieldBody,
|
4597 | extra: slots.extra
|
4598 | });
|
4599 | };
|
4600 | }
|
4601 | });
|
4602 | const Field = withInstall(stdin_default$1v);
|
4603 | let lockCount = 0;
|
4604 | function lockClick(lock) {
|
4605 | if (lock) {
|
4606 | if (!lockCount) {
|
4607 | document.body.classList.add("van-toast--unclickable");
|
4608 | }
|
4609 | lockCount++;
|
4610 | } else if (lockCount) {
|
4611 | lockCount--;
|
4612 | if (!lockCount) {
|
4613 | document.body.classList.remove("van-toast--unclickable");
|
4614 | }
|
4615 | }
|
4616 | }
|
4617 | const [name$1k, bem$1g] = createNamespace("toast");
|
4618 | const popupInheritProps$1 = ["show", "overlay", "teleport", "transition", "overlayClass", "overlayStyle", "closeOnClickOverlay", "zIndex"];
|
4619 | const toastProps = {
|
4620 | icon: String,
|
4621 | show: Boolean,
|
4622 | type: makeStringProp("text"),
|
4623 | overlay: Boolean,
|
4624 | message: numericProp,
|
4625 | iconSize: numericProp,
|
4626 | duration: makeNumberProp(2e3),
|
4627 | position: makeStringProp("middle"),
|
4628 | teleport: [String, Object],
|
4629 | wordBreak: String,
|
4630 | className: unknownProp,
|
4631 | iconPrefix: String,
|
4632 | transition: makeStringProp("van-fade"),
|
4633 | loadingType: String,
|
4634 | forbidClick: Boolean,
|
4635 | overlayClass: unknownProp,
|
4636 | overlayStyle: Object,
|
4637 | closeOnClick: Boolean,
|
4638 | closeOnClickOverlay: Boolean,
|
4639 | zIndex: numericProp
|
4640 | };
|
4641 | var stdin_default$1u = vue.defineComponent({
|
4642 | name: name$1k,
|
4643 | props: toastProps,
|
4644 | emits: ["update:show"],
|
4645 | setup(props2, {
|
4646 | emit,
|
4647 | slots
|
4648 | }) {
|
4649 | let timer2;
|
4650 | let clickable = false;
|
4651 | const toggleClickable = () => {
|
4652 | const newValue = props2.show && props2.forbidClick;
|
4653 | if (clickable !== newValue) {
|
4654 | clickable = newValue;
|
4655 | lockClick(clickable);
|
4656 | }
|
4657 | };
|
4658 | const updateShow = (show) => emit("update:show", show);
|
4659 | const onClick = () => {
|
4660 | if (props2.closeOnClick) {
|
4661 | updateShow(false);
|
4662 | }
|
4663 | };
|
4664 | const clearTimer = () => clearTimeout(timer2);
|
4665 | const renderIcon = () => {
|
4666 | const {
|
4667 | icon,
|
4668 | type,
|
4669 | iconSize,
|
4670 | iconPrefix,
|
4671 | loadingType
|
4672 | } = props2;
|
4673 | const hasIcon = icon || type === "success" || type === "fail";
|
4674 | if (hasIcon) {
|
4675 | return vue.createVNode(Icon, {
|
4676 | "name": icon || type,
|
4677 | "size": iconSize,
|
4678 | "class": bem$1g("icon"),
|
4679 | "classPrefix": iconPrefix
|
4680 | }, null);
|
4681 | }
|
4682 | if (type === "loading") {
|
4683 | return vue.createVNode(Loading, {
|
4684 | "class": bem$1g("loading"),
|
4685 | "size": iconSize,
|
4686 | "type": loadingType
|
4687 | }, null);
|
4688 | }
|
4689 | };
|
4690 | const renderMessage = () => {
|
4691 | const {
|
4692 | type,
|
4693 | message
|
4694 | } = props2;
|
4695 | if (slots.message) {
|
4696 | return vue.createVNode("div", {
|
4697 | "class": bem$1g("text")
|
4698 | }, [slots.message()]);
|
4699 | }
|
4700 | if (isDef(message) && message !== "") {
|
4701 | return type === "html" ? vue.createVNode("div", {
|
4702 | "key": 0,
|
4703 | "class": bem$1g("text"),
|
4704 | "innerHTML": String(message)
|
4705 | }, null) : vue.createVNode("div", {
|
4706 | "class": bem$1g("text")
|
4707 | }, [message]);
|
4708 | }
|
4709 | };
|
4710 | vue.watch(() => [props2.show, props2.forbidClick], toggleClickable);
|
4711 | vue.watch(() => [props2.show, props2.type, props2.message, props2.duration], () => {
|
4712 | clearTimer();
|
4713 | if (props2.show && props2.duration > 0) {
|
4714 | timer2 = setTimeout(() => {
|
4715 | updateShow(false);
|
4716 | }, props2.duration);
|
4717 | }
|
4718 | });
|
4719 | vue.onMounted(toggleClickable);
|
4720 | vue.onUnmounted(toggleClickable);
|
4721 | return () => vue.createVNode(Popup, vue.mergeProps({
|
4722 | "class": [bem$1g([props2.position, props2.wordBreak === "normal" ? "break-normal" : props2.wordBreak, {
|
4723 | [props2.type]: !props2.icon
|
4724 | }]), props2.className],
|
4725 | "lockScroll": false,
|
4726 | "onClick": onClick,
|
4727 | "onClosed": clearTimer,
|
4728 | "onUpdate:show": updateShow
|
4729 | }, pick(props2, popupInheritProps$1)), {
|
4730 | default: () => [renderIcon(), renderMessage()]
|
4731 | });
|
4732 | }
|
4733 | });
|
4734 | function usePopupState() {
|
4735 | const state = vue.reactive({
|
4736 | show: false
|
4737 | });
|
4738 | const toggle = (show) => {
|
4739 | state.show = show;
|
4740 | };
|
4741 | const open = (props2) => {
|
4742 | extend(state, props2, { transitionAppear: true });
|
4743 | toggle(true);
|
4744 | };
|
4745 | const close = () => toggle(false);
|
4746 | useExpose({ open, close, toggle });
|
4747 | return {
|
4748 | open,
|
4749 | close,
|
4750 | state,
|
4751 | toggle
|
4752 | };
|
4753 | }
|
4754 | function mountComponent(RootComponent) {
|
4755 | const app = vue.createApp(RootComponent);
|
4756 | const root = document.createElement("div");
|
4757 | document.body.appendChild(root);
|
4758 | return {
|
4759 | instance: app.mount(root),
|
4760 | unmount() {
|
4761 | app.unmount();
|
4762 | document.body.removeChild(root);
|
4763 | }
|
4764 | };
|
4765 | }
|
4766 | const defaultOptions$1 = {
|
4767 | icon: "",
|
4768 | type: "text",
|
4769 | message: "",
|
4770 | className: "",
|
4771 | overlay: false,
|
4772 | onClose: void 0,
|
4773 | onOpened: void 0,
|
4774 | duration: 2e3,
|
4775 | teleport: "body",
|
4776 | iconSize: void 0,
|
4777 | iconPrefix: void 0,
|
4778 | position: "middle",
|
4779 | transition: "van-fade",
|
4780 | forbidClick: false,
|
4781 | loadingType: void 0,
|
4782 | overlayClass: "",
|
4783 | overlayStyle: void 0,
|
4784 | closeOnClick: false,
|
4785 | closeOnClickOverlay: false
|
4786 | };
|
4787 | let queue = [];
|
4788 | let allowMultiple = false;
|
4789 | let currentOptions$2 = extend({}, defaultOptions$1);
|
4790 | const defaultOptionsMap = new Map();
|
4791 | function parseOptions$1(message) {
|
4792 | if (isObject(message)) {
|
4793 | return message;
|
4794 | }
|
4795 | return {
|
4796 | message
|
4797 | };
|
4798 | }
|
4799 | function createInstance() {
|
4800 | const {
|
4801 | instance: instance2,
|
4802 | unmount
|
4803 | } = mountComponent({
|
4804 | setup() {
|
4805 | const message = vue.ref("");
|
4806 | const {
|
4807 | open,
|
4808 | state,
|
4809 | close,
|
4810 | toggle
|
4811 | } = usePopupState();
|
4812 | const onClosed = () => {
|
4813 | if (allowMultiple) {
|
4814 | queue = queue.filter((item) => item !== instance2);
|
4815 | unmount();
|
4816 | }
|
4817 | };
|
4818 | const render = () => {
|
4819 | const attrs = {
|
4820 | onClosed,
|
4821 | "onUpdate:show": toggle
|
4822 | };
|
4823 | return vue.createVNode(stdin_default$1u, vue.mergeProps(state, attrs), null);
|
4824 | };
|
4825 | vue.watch(message, (val) => {
|
4826 | state.message = val;
|
4827 | });
|
4828 | vue.getCurrentInstance().render = render;
|
4829 | return {
|
4830 | open,
|
4831 | close,
|
4832 | message
|
4833 | };
|
4834 | }
|
4835 | });
|
4836 | return instance2;
|
4837 | }
|
4838 | function getInstance() {
|
4839 | if (!queue.length || allowMultiple) {
|
4840 | const instance2 = createInstance();
|
4841 | queue.push(instance2);
|
4842 | }
|
4843 | return queue[queue.length - 1];
|
4844 | }
|
4845 | function showToast(options = {}) {
|
4846 | if (!inBrowser) {
|
4847 | return {};
|
4848 | }
|
4849 | const toast = getInstance();
|
4850 | const parsedOptions = parseOptions$1(options);
|
4851 | toast.open(extend({}, currentOptions$2, defaultOptionsMap.get(parsedOptions.type || currentOptions$2.type), parsedOptions));
|
4852 | return toast;
|
4853 | }
|
4854 | const createMethod = (type) => (options) => showToast(extend({
|
4855 | type
|
4856 | }, parseOptions$1(options)));
|
4857 | const showLoadingToast = createMethod("loading");
|
4858 | const showSuccessToast = createMethod("success");
|
4859 | const showFailToast = createMethod("fail");
|
4860 | const closeToast = (all) => {
|
4861 | var _a;
|
4862 | if (queue.length) {
|
4863 | if (all) {
|
4864 | queue.forEach((toast) => {
|
4865 | toast.close();
|
4866 | });
|
4867 | queue = [];
|
4868 | } else if (!allowMultiple) {
|
4869 | queue[0].close();
|
4870 | } else {
|
4871 | (_a = queue.shift()) == null ? void 0 : _a.close();
|
4872 | }
|
4873 | }
|
4874 | };
|
4875 | function setToastDefaultOptions(type, options) {
|
4876 | if (typeof type === "string") {
|
4877 | defaultOptionsMap.set(type, options);
|
4878 | } else {
|
4879 | extend(currentOptions$2, type);
|
4880 | }
|
4881 | }
|
4882 | const resetToastDefaultOptions = (type) => {
|
4883 | if (typeof type === "string") {
|
4884 | defaultOptionsMap.delete(type);
|
4885 | } else {
|
4886 | currentOptions$2 = extend({}, defaultOptions$1);
|
4887 | defaultOptionsMap.clear();
|
4888 | }
|
4889 | };
|
4890 | const allowMultipleToast = (value = true) => {
|
4891 | allowMultiple = value;
|
4892 | };
|
4893 | const Toast = withInstall(stdin_default$1u);
|
4894 | const [name$1j, bem$1f] = createNamespace("switch");
|
4895 | const switchProps = {
|
4896 | size: numericProp,
|
4897 | loading: Boolean,
|
4898 | disabled: Boolean,
|
4899 | modelValue: unknownProp,
|
4900 | activeColor: String,
|
4901 | inactiveColor: String,
|
4902 | activeValue: {
|
4903 | type: unknownProp,
|
4904 | default: true
|
4905 | },
|
4906 | inactiveValue: {
|
4907 | type: unknownProp,
|
4908 | default: false
|
4909 | }
|
4910 | };
|
4911 | var stdin_default$1t = vue.defineComponent({
|
4912 | name: name$1j,
|
4913 | props: switchProps,
|
4914 | emits: ["change", "update:modelValue"],
|
4915 | setup(props2, {
|
4916 | emit,
|
4917 | slots
|
4918 | }) {
|
4919 | const isChecked = () => props2.modelValue === props2.activeValue;
|
4920 | const onClick = () => {
|
4921 | if (!props2.disabled && !props2.loading) {
|
4922 | const newValue = isChecked() ? props2.inactiveValue : props2.activeValue;
|
4923 | emit("update:modelValue", newValue);
|
4924 | emit("change", newValue);
|
4925 | }
|
4926 | };
|
4927 | const renderLoading = () => {
|
4928 | if (props2.loading) {
|
4929 | const color = isChecked() ? props2.activeColor : props2.inactiveColor;
|
4930 | return vue.createVNode(Loading, {
|
4931 | "class": bem$1f("loading"),
|
4932 | "color": color
|
4933 | }, null);
|
4934 | }
|
4935 | if (slots.node) {
|
4936 | return slots.node();
|
4937 | }
|
4938 | };
|
4939 | use.useCustomFieldValue(() => props2.modelValue);
|
4940 | return () => {
|
4941 | var _a;
|
4942 | const {
|
4943 | size,
|
4944 | loading,
|
4945 | disabled,
|
4946 | activeColor,
|
4947 | inactiveColor
|
4948 | } = props2;
|
4949 | const checked = isChecked();
|
4950 | const style = {
|
4951 | fontSize: addUnit(size),
|
4952 | backgroundColor: checked ? activeColor : inactiveColor
|
4953 | };
|
4954 | return vue.createVNode("div", {
|
4955 | "role": "switch",
|
4956 | "class": bem$1f({
|
4957 | on: checked,
|
4958 | loading,
|
4959 | disabled
|
4960 | }),
|
4961 | "style": style,
|
4962 | "tabindex": disabled ? void 0 : 0,
|
4963 | "aria-checked": checked,
|
4964 | "onClick": onClick
|
4965 | }, [vue.createVNode("div", {
|
4966 | "class": bem$1f("node")
|
4967 | }, [renderLoading()]), (_a = slots.background) == null ? void 0 : _a.call(slots)]);
|
4968 | };
|
4969 | }
|
4970 | });
|
4971 | const Switch = withInstall(stdin_default$1t);
|
4972 | const [name$1i, bem$1e] = createNamespace("address-edit-detail");
|
4973 | const t$j = createNamespace("address-edit")[2];
|
4974 | var stdin_default$1s = vue.defineComponent({
|
4975 | name: name$1i,
|
4976 | props: {
|
4977 | show: Boolean,
|
4978 | rows: numericProp,
|
4979 | value: String,
|
4980 | rules: Array,
|
4981 | focused: Boolean,
|
4982 | maxlength: numericProp,
|
4983 | searchResult: Array,
|
4984 | showSearchResult: Boolean
|
4985 | },
|
4986 | emits: ["blur", "focus", "input", "selectSearch"],
|
4987 | setup(props2, {
|
4988 | emit
|
4989 | }) {
|
4990 | const field = vue.ref();
|
4991 | const showSearchResult = () => props2.focused && props2.searchResult && props2.showSearchResult;
|
4992 | const onSelect = (express) => {
|
4993 | emit("selectSearch", express);
|
4994 | emit("input", `${express.address || ""} ${express.name || ""}`.trim());
|
4995 | };
|
4996 | const renderSearchResult = () => {
|
4997 | if (!showSearchResult()) {
|
4998 | return;
|
4999 | }
|
5000 | const {
|
5001 | searchResult
|
5002 | } = props2;
|
5003 | return searchResult.map((express) => vue.createVNode(Cell, {
|
5004 | "clickable": true,
|
5005 | "key": (express.name || "") + (express.address || ""),
|
5006 | "icon": "location-o",
|
5007 | "title": express.name,
|
5008 | "label": express.address,
|
5009 | "class": bem$1e("search-item"),
|
5010 | "border": false,
|
5011 | "onClick": () => onSelect(express)
|
5012 | }, null));
|
5013 | };
|
5014 | const onBlur = (event) => emit("blur", event);
|
5015 | const onFocus = (event) => emit("focus", event);
|
5016 | const onInput = (value) => emit("input", value);
|
5017 | return () => {
|
5018 | if (props2.show) {
|
5019 | return vue.createVNode(vue.Fragment, null, [vue.createVNode(Field, {
|
5020 | "autosize": true,
|
5021 | "clearable": true,
|
5022 | "ref": field,
|
5023 | "class": bem$1e(),
|
5024 | "rows": props2.rows,
|
5025 | "type": "textarea",
|
5026 | "rules": props2.rules,
|
5027 | "label": t$j("addressDetail"),
|
5028 | "border": !showSearchResult(),
|
5029 | "maxlength": props2.maxlength,
|
5030 | "modelValue": props2.value,
|
5031 | "placeholder": t$j("addressDetail"),
|
5032 | "onBlur": onBlur,
|
5033 | "onFocus": onFocus,
|
5034 | "onUpdate:modelValue": onInput
|
5035 | }, null), renderSearchResult()]);
|
5036 | }
|
5037 | };
|
5038 | }
|
5039 | });
|
5040 | const [name$1h, bem$1d, t$i] = createNamespace("address-edit");
|
5041 | const DEFAULT_DATA = {
|
5042 | name: "",
|
5043 | tel: "",
|
5044 | city: "",
|
5045 | county: "",
|
5046 | country: "",
|
5047 | province: "",
|
5048 | areaCode: "",
|
5049 | isDefault: false,
|
5050 | addressDetail: ""
|
5051 | };
|
5052 | const addressEditProps = {
|
5053 | areaList: Object,
|
5054 | isSaving: Boolean,
|
5055 | isDeleting: Boolean,
|
5056 | validator: Function,
|
5057 | showArea: truthProp,
|
5058 | showDetail: truthProp,
|
5059 | showDelete: Boolean,
|
5060 | disableArea: Boolean,
|
5061 | searchResult: Array,
|
5062 | telMaxlength: numericProp,
|
5063 | showSetDefault: Boolean,
|
5064 | saveButtonText: String,
|
5065 | areaPlaceholder: String,
|
5066 | deleteButtonText: String,
|
5067 | showSearchResult: Boolean,
|
5068 | detailRows: makeNumericProp(1),
|
5069 | detailMaxlength: makeNumericProp(200),
|
5070 | areaColumnsPlaceholder: makeArrayProp(),
|
5071 | addressInfo: {
|
5072 | type: Object,
|
5073 | default: () => extend({}, DEFAULT_DATA)
|
5074 | },
|
5075 | telValidator: {
|
5076 | type: Function,
|
5077 | default: isMobile
|
5078 | }
|
5079 | };
|
5080 | var stdin_default$1r = vue.defineComponent({
|
5081 | name: name$1h,
|
5082 | props: addressEditProps,
|
5083 | emits: ["save", "focus", "change", "delete", "clickArea", "changeArea", "changeDetail", "selectSearch", "changeDefault"],
|
5084 | setup(props2, {
|
5085 | emit,
|
5086 | slots
|
5087 | }) {
|
5088 | const areaRef = vue.ref();
|
5089 | const data = vue.reactive({});
|
5090 | const showAreaPopup = vue.ref(false);
|
5091 | const detailFocused = vue.ref(false);
|
5092 | const areaListLoaded = vue.computed(() => isObject(props2.areaList) && Object.keys(props2.areaList).length);
|
5093 | const areaText = vue.computed(() => {
|
5094 | const {
|
5095 | province,
|
5096 | city,
|
5097 | county,
|
5098 | areaCode
|
5099 | } = data;
|
5100 | if (areaCode) {
|
5101 | const arr = [province, city, county];
|
5102 | if (province && province === city) {
|
5103 | arr.splice(1, 1);
|
5104 | }
|
5105 | return arr.filter(Boolean).join("/");
|
5106 | }
|
5107 | return "";
|
5108 | });
|
5109 | const hideBottomFields = vue.computed(() => {
|
5110 | var _a;
|
5111 | return ((_a = props2.searchResult) == null ? void 0 : _a.length) && detailFocused.value;
|
5112 | });
|
5113 | const onFocus = (key) => {
|
5114 | detailFocused.value = key === "addressDetail";
|
5115 | emit("focus", key);
|
5116 | };
|
5117 | const onChange = (key, value) => {
|
5118 | emit("change", {
|
5119 | key,
|
5120 | value
|
5121 | });
|
5122 | };
|
5123 | const rules = vue.computed(() => {
|
5124 | const {
|
5125 | validator,
|
5126 | telValidator
|
5127 | } = props2;
|
5128 | const makeRule = (name2, emptyMessage) => ({
|
5129 | validator: (value) => {
|
5130 | if (validator) {
|
5131 | const message = validator(name2, value);
|
5132 | if (message) {
|
5133 | return message;
|
5134 | }
|
5135 | }
|
5136 | if (!value) {
|
5137 | return emptyMessage;
|
5138 | }
|
5139 | return true;
|
5140 | }
|
5141 | });
|
5142 | return {
|
5143 | name: [makeRule("name", t$i("nameEmpty"))],
|
5144 | tel: [makeRule("tel", t$i("telInvalid")), {
|
5145 | validator: telValidator,
|
5146 | message: t$i("telInvalid")
|
5147 | }],
|
5148 | areaCode: [makeRule("areaCode", t$i("areaEmpty"))],
|
5149 | addressDetail: [makeRule("addressDetail", t$i("addressEmpty"))]
|
5150 | };
|
5151 | });
|
5152 | const onSave = () => emit("save", data);
|
5153 | const onChangeDetail = (val) => {
|
5154 | data.addressDetail = val;
|
5155 | emit("changeDetail", val);
|
5156 | };
|
5157 | const assignAreaText = (options) => {
|
5158 | data.province = options[0].text;
|
5159 | data.city = options[1].text;
|
5160 | data.county = options[2].text;
|
5161 | };
|
5162 | const onAreaConfirm = ({
|
5163 | selectedValues,
|
5164 | selectedOptions
|
5165 | }) => {
|
5166 | if (selectedValues.some((value) => value === AREA_EMPTY_CODE)) {
|
5167 | showToast(t$i("areaEmpty"));
|
5168 | } else {
|
5169 | showAreaPopup.value = false;
|
5170 | assignAreaText(selectedOptions);
|
5171 | emit("changeArea", selectedOptions);
|
5172 | }
|
5173 | };
|
5174 | const onDelete = () => emit("delete", data);
|
5175 | const setAreaCode = (code) => {
|
5176 | data.areaCode = code || "";
|
5177 | };
|
5178 | const onDetailBlur = () => {
|
5179 | setTimeout(() => {
|
5180 | detailFocused.value = false;
|
5181 | });
|
5182 | };
|
5183 | const setAddressDetail = (value) => {
|
5184 | data.addressDetail = value;
|
5185 | };
|
5186 | const renderSetDefaultCell = () => {
|
5187 | if (props2.showSetDefault) {
|
5188 | const slots2 = {
|
5189 | "right-icon": () => vue.createVNode(Switch, {
|
5190 | "modelValue": data.isDefault,
|
5191 | "onUpdate:modelValue": ($event) => data.isDefault = $event,
|
5192 | "onChange": (event) => emit("changeDefault", event)
|
5193 | }, null)
|
5194 | };
|
5195 | return vue.withDirectives(vue.createVNode(Cell, {
|
5196 | "center": true,
|
5197 | "border": false,
|
5198 | "title": t$i("defaultAddress"),
|
5199 | "class": bem$1d("default")
|
5200 | }, slots2), [[vue.vShow, !hideBottomFields.value]]);
|
5201 | }
|
5202 | };
|
5203 | useExpose({
|
5204 | setAreaCode,
|
5205 | setAddressDetail
|
5206 | });
|
5207 | vue.watch(() => props2.addressInfo, (value) => {
|
5208 | extend(data, DEFAULT_DATA, value);
|
5209 | vue.nextTick(() => {
|
5210 | var _a;
|
5211 | const options = (_a = areaRef.value) == null ? void 0 : _a.getSelectedOptions();
|
5212 | if (options && options.every((option) => option && option.value !== AREA_EMPTY_CODE)) {
|
5213 | assignAreaText(options);
|
5214 | }
|
5215 | });
|
5216 | }, {
|
5217 | deep: true,
|
5218 | immediate: true
|
5219 | });
|
5220 | return () => {
|
5221 | const {
|
5222 | disableArea
|
5223 | } = props2;
|
5224 | return vue.createVNode(Form, {
|
5225 | "class": bem$1d(),
|
5226 | "onSubmit": onSave
|
5227 | }, {
|
5228 | default: () => {
|
5229 | var _a;
|
5230 | return [vue.createVNode("div", {
|
5231 | "class": bem$1d("fields")
|
5232 | }, [vue.createVNode(Field, {
|
5233 | "modelValue": data.name,
|
5234 | "onUpdate:modelValue": [($event) => data.name = $event, (val) => onChange("name", val)],
|
5235 | "clearable": true,
|
5236 | "label": t$i("name"),
|
5237 | "rules": rules.value.name,
|
5238 | "placeholder": t$i("name"),
|
5239 | "onFocus": () => onFocus("name")
|
5240 | }, null), vue.createVNode(Field, {
|
5241 | "modelValue": data.tel,
|
5242 | "onUpdate:modelValue": [($event) => data.tel = $event, (val) => onChange("tel", val)],
|
5243 | "clearable": true,
|
5244 | "type": "tel",
|
5245 | "label": t$i("tel"),
|
5246 | "rules": rules.value.tel,
|
5247 | "maxlength": props2.telMaxlength,
|
5248 | "placeholder": t$i("tel"),
|
5249 | "onFocus": () => onFocus("tel")
|
5250 | }, null), vue.withDirectives(vue.createVNode(Field, {
|
5251 | "readonly": true,
|
5252 | "label": t$i("area"),
|
5253 | "is-link": !disableArea,
|
5254 | "modelValue": areaText.value,
|
5255 | "rules": props2.showArea ? rules.value.areaCode : void 0,
|
5256 | "placeholder": props2.areaPlaceholder || t$i("area"),
|
5257 | "onFocus": () => onFocus("areaCode"),
|
5258 | "onClick": () => {
|
5259 | emit("clickArea");
|
5260 | showAreaPopup.value = !disableArea;
|
5261 | }
|
5262 | }, null), [[vue.vShow, props2.showArea]]), vue.createVNode(stdin_default$1s, {
|
5263 | "show": props2.showDetail,
|
5264 | "rows": props2.detailRows,
|
5265 | "rules": rules.value.addressDetail,
|
5266 | "value": data.addressDetail,
|
5267 | "focused": detailFocused.value,
|
5268 | "maxlength": props2.detailMaxlength,
|
5269 | "searchResult": props2.searchResult,
|
5270 | "showSearchResult": props2.showSearchResult,
|
5271 | "onBlur": onDetailBlur,
|
5272 | "onFocus": () => onFocus("addressDetail"),
|
5273 | "onInput": onChangeDetail,
|
5274 | "onSelectSearch": (event) => emit("selectSearch", event)
|
5275 | }, null), (_a = slots.default) == null ? void 0 : _a.call(slots)]), renderSetDefaultCell(), vue.withDirectives(vue.createVNode("div", {
|
5276 | "class": bem$1d("buttons")
|
5277 | }, [vue.createVNode(Button, {
|
5278 | "block": true,
|
5279 | "round": true,
|
5280 | "type": "primary",
|
5281 | "text": props2.saveButtonText || t$i("save"),
|
5282 | "class": bem$1d("button"),
|
5283 | "loading": props2.isSaving,
|
5284 | "nativeType": "submit"
|
5285 | }, null), props2.showDelete && vue.createVNode(Button, {
|
5286 | "block": true,
|
5287 | "round": true,
|
5288 | "class": bem$1d("button"),
|
5289 | "loading": props2.isDeleting,
|
5290 | "text": props2.deleteButtonText || t$i("delete"),
|
5291 | "onClick": onDelete
|
5292 | }, null)]), [[vue.vShow, !hideBottomFields.value]]), vue.createVNode(Popup, {
|
5293 | "show": showAreaPopup.value,
|
5294 | "onUpdate:show": ($event) => showAreaPopup.value = $event,
|
5295 | "round": true,
|
5296 | "teleport": "body",
|
5297 | "position": "bottom",
|
5298 | "lazyRender": false
|
5299 | }, {
|
5300 | default: () => [vue.createVNode(Area, {
|
5301 | "modelValue": data.areaCode,
|
5302 | "onUpdate:modelValue": ($event) => data.areaCode = $event,
|
5303 | "ref": areaRef,
|
5304 | "loading": !areaListLoaded.value,
|
5305 | "areaList": props2.areaList,
|
5306 | "columnsPlaceholder": props2.areaColumnsPlaceholder,
|
5307 | "onConfirm": onAreaConfirm,
|
5308 | "onCancel": () => {
|
5309 | showAreaPopup.value = false;
|
5310 | }
|
5311 | }, null)]
|
5312 | })];
|
5313 | }
|
5314 | });
|
5315 | };
|
5316 | }
|
5317 | });
|
5318 | const AddressEdit = withInstall(stdin_default$1r);
|
5319 | const [name$1g, bem$1c] = createNamespace("radio-group");
|
5320 | const radioGroupProps = {
|
5321 | shape: String,
|
5322 | disabled: Boolean,
|
5323 | iconSize: numericProp,
|
5324 | direction: String,
|
5325 | modelValue: unknownProp,
|
5326 | checkedColor: String
|
5327 | };
|
5328 | const RADIO_KEY = Symbol(name$1g);
|
5329 | var stdin_default$1q = vue.defineComponent({
|
5330 | name: name$1g,
|
5331 | props: radioGroupProps,
|
5332 | emits: ["change", "update:modelValue"],
|
5333 | setup(props2, {
|
5334 | emit,
|
5335 | slots
|
5336 | }) {
|
5337 | const {
|
5338 | linkChildren
|
5339 | } = use.useChildren(RADIO_KEY);
|
5340 | const updateValue = (value) => emit("update:modelValue", value);
|
5341 | vue.watch(() => props2.modelValue, (value) => emit("change", value));
|
5342 | linkChildren({
|
5343 | props: props2,
|
5344 | updateValue
|
5345 | });
|
5346 | use.useCustomFieldValue(() => props2.modelValue);
|
5347 | return () => {
|
5348 | var _a;
|
5349 | return vue.createVNode("div", {
|
5350 | "class": bem$1c([props2.direction]),
|
5351 | "role": "radiogroup"
|
5352 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
5353 | };
|
5354 | }
|
5355 | });
|
5356 | const RadioGroup = withInstall(stdin_default$1q);
|
5357 | const [name$1f, bem$1b] = createNamespace("checkbox-group");
|
5358 | const checkboxGroupProps = {
|
5359 | max: numericProp,
|
5360 | shape: makeStringProp("round"),
|
5361 | disabled: Boolean,
|
5362 | iconSize: numericProp,
|
5363 | direction: String,
|
5364 | modelValue: makeArrayProp(),
|
5365 | checkedColor: String
|
5366 | };
|
5367 | const CHECKBOX_GROUP_KEY = Symbol(name$1f);
|
5368 | var stdin_default$1p = vue.defineComponent({
|
5369 | name: name$1f,
|
5370 | props: checkboxGroupProps,
|
5371 | emits: ["change", "update:modelValue"],
|
5372 | setup(props2, {
|
5373 | emit,
|
5374 | slots
|
5375 | }) {
|
5376 | const {
|
5377 | children,
|
5378 | linkChildren
|
5379 | } = use.useChildren(CHECKBOX_GROUP_KEY);
|
5380 | const updateValue = (value) => emit("update:modelValue", value);
|
5381 | const toggleAll = (options = {}) => {
|
5382 | if (typeof options === "boolean") {
|
5383 | options = {
|
5384 | checked: options
|
5385 | };
|
5386 | }
|
5387 | const {
|
5388 | checked,
|
5389 | skipDisabled
|
5390 | } = options;
|
5391 | const checkedChildren = children.filter((item) => {
|
5392 | if (!item.props.bindGroup) {
|
5393 | return false;
|
5394 | }
|
5395 | if (item.props.disabled && skipDisabled) {
|
5396 | return item.checked.value;
|
5397 | }
|
5398 | return checked != null ? checked : !item.checked.value;
|
5399 | });
|
5400 | const names = checkedChildren.map((item) => item.name);
|
5401 | updateValue(names);
|
5402 | };
|
5403 | vue.watch(() => props2.modelValue, (value) => emit("change", value));
|
5404 | useExpose({
|
5405 | toggleAll
|
5406 | });
|
5407 | use.useCustomFieldValue(() => props2.modelValue);
|
5408 | linkChildren({
|
5409 | props: props2,
|
5410 | updateValue
|
5411 | });
|
5412 | return () => {
|
5413 | var _a;
|
5414 | return vue.createVNode("div", {
|
5415 | "class": bem$1b([props2.direction])
|
5416 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
5417 | };
|
5418 | }
|
5419 | });
|
5420 | const CheckboxGroup = withInstall(stdin_default$1p);
|
5421 | const [name$1e, bem$1a] = createNamespace("tag");
|
5422 | const tagProps = {
|
5423 | size: String,
|
5424 | mark: Boolean,
|
5425 | show: truthProp,
|
5426 | type: makeStringProp("default"),
|
5427 | color: String,
|
5428 | plain: Boolean,
|
5429 | round: Boolean,
|
5430 | textColor: String,
|
5431 | closeable: Boolean
|
5432 | };
|
5433 | var stdin_default$1o = vue.defineComponent({
|
5434 | name: name$1e,
|
5435 | props: tagProps,
|
5436 | emits: ["close"],
|
5437 | setup(props2, {
|
5438 | slots,
|
5439 | emit
|
5440 | }) {
|
5441 | const onClose = (event) => {
|
5442 | event.stopPropagation();
|
5443 | emit("close", event);
|
5444 | };
|
5445 | const getStyle = () => {
|
5446 | if (props2.plain) {
|
5447 | return {
|
5448 | color: props2.textColor || props2.color,
|
5449 | borderColor: props2.color
|
5450 | };
|
5451 | }
|
5452 | return {
|
5453 | color: props2.textColor,
|
5454 | background: props2.color
|
5455 | };
|
5456 | };
|
5457 | const renderTag = () => {
|
5458 | var _a;
|
5459 | const {
|
5460 | type,
|
5461 | mark,
|
5462 | plain,
|
5463 | round,
|
5464 | size,
|
5465 | closeable
|
5466 | } = props2;
|
5467 | const classes = {
|
5468 | mark,
|
5469 | plain,
|
5470 | round
|
5471 | };
|
5472 | if (size) {
|
5473 | classes[size] = size;
|
5474 | }
|
5475 | const CloseIcon = closeable && vue.createVNode(Icon, {
|
5476 | "name": "cross",
|
5477 | "class": [bem$1a("close"), HAPTICS_FEEDBACK],
|
5478 | "onClick": onClose
|
5479 | }, null);
|
5480 | return vue.createVNode("span", {
|
5481 | "style": getStyle(),
|
5482 | "class": bem$1a([classes, type])
|
5483 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots), CloseIcon]);
|
5484 | };
|
5485 | return () => vue.createVNode(vue.Transition, {
|
5486 | "name": props2.closeable ? "van-fade" : void 0
|
5487 | }, {
|
5488 | default: () => [props2.show ? renderTag() : null]
|
5489 | });
|
5490 | }
|
5491 | });
|
5492 | const Tag = withInstall(stdin_default$1o);
|
5493 | const checkerProps = {
|
5494 | name: unknownProp,
|
5495 | disabled: Boolean,
|
5496 | iconSize: numericProp,
|
5497 | modelValue: unknownProp,
|
5498 | checkedColor: String,
|
5499 | labelPosition: String,
|
5500 | labelDisabled: Boolean
|
5501 | };
|
5502 | var stdin_default$1n = vue.defineComponent({
|
5503 | props: extend({}, checkerProps, {
|
5504 | bem: makeRequiredProp(Function),
|
5505 | role: String,
|
5506 | shape: String,
|
5507 | parent: Object,
|
5508 | checked: Boolean,
|
5509 | bindGroup: truthProp,
|
5510 | indeterminate: {
|
5511 | type: Boolean,
|
5512 | default: null
|
5513 | }
|
5514 | }),
|
5515 | emits: ["click", "toggle"],
|
5516 | setup(props2, {
|
5517 | emit,
|
5518 | slots
|
5519 | }) {
|
5520 | const iconRef = vue.ref();
|
5521 | const getParentProp = (name2) => {
|
5522 | if (props2.parent && props2.bindGroup) {
|
5523 | return props2.parent.props[name2];
|
5524 | }
|
5525 | };
|
5526 | const disabled = vue.computed(() => {
|
5527 | if (props2.parent && props2.bindGroup) {
|
5528 | const disabled2 = getParentProp("disabled") || props2.disabled;
|
5529 | if (props2.role === "checkbox") {
|
5530 | const checkedCount = getParentProp("modelValue").length;
|
5531 | const max = getParentProp("max");
|
5532 | const overlimit = max && checkedCount >= +max;
|
5533 | return disabled2 || overlimit && !props2.checked;
|
5534 | }
|
5535 | return disabled2;
|
5536 | }
|
5537 | return props2.disabled;
|
5538 | });
|
5539 | const direction = vue.computed(() => getParentProp("direction"));
|
5540 | const iconStyle = vue.computed(() => {
|
5541 | const checkedColor = props2.checkedColor || getParentProp("checkedColor");
|
5542 | if (checkedColor && props2.checked && !disabled.value) {
|
5543 | return {
|
5544 | borderColor: checkedColor,
|
5545 | backgroundColor: checkedColor
|
5546 | };
|
5547 | }
|
5548 | });
|
5549 | const shape = vue.computed(() => {
|
5550 | return props2.shape || getParentProp("shape") || "round";
|
5551 | });
|
5552 | const onClick = (event) => {
|
5553 | const {
|
5554 | target
|
5555 | } = event;
|
5556 | const icon = iconRef.value;
|
5557 | const iconClicked = icon === target || (icon == null ? void 0 : icon.contains(target));
|
5558 | if (!disabled.value && (iconClicked || !props2.labelDisabled)) {
|
5559 | emit("toggle");
|
5560 | }
|
5561 | emit("click", event);
|
5562 | };
|
5563 | const renderIcon = () => {
|
5564 | var _a, _b;
|
5565 | const {
|
5566 | bem: bem2,
|
5567 | checked,
|
5568 | indeterminate
|
5569 | } = props2;
|
5570 | const iconSize = props2.iconSize || getParentProp("iconSize");
|
5571 | return vue.createVNode("div", {
|
5572 | "ref": iconRef,
|
5573 | "class": bem2("icon", [shape.value, {
|
5574 | disabled: disabled.value,
|
5575 | checked,
|
5576 | indeterminate
|
5577 | }]),
|
5578 | "style": shape.value !== "dot" ? {
|
5579 | fontSize: addUnit(iconSize)
|
5580 | } : {
|
5581 | width: addUnit(iconSize),
|
5582 | height: addUnit(iconSize),
|
5583 | borderColor: (_a = iconStyle.value) == null ? void 0 : _a.borderColor
|
5584 | }
|
5585 | }, [slots.icon ? slots.icon({
|
5586 | checked,
|
5587 | disabled: disabled.value
|
5588 | }) : shape.value !== "dot" ? vue.createVNode(Icon, {
|
5589 | "name": indeterminate ? "minus" : "success",
|
5590 | "style": iconStyle.value
|
5591 | }, null) : vue.createVNode("div", {
|
5592 | "class": bem2("icon--dot__icon"),
|
5593 | "style": {
|
5594 | backgroundColor: (_b = iconStyle.value) == null ? void 0 : _b.backgroundColor
|
5595 | }
|
5596 | }, null)]);
|
5597 | };
|
5598 | const renderLabel = () => {
|
5599 | const {
|
5600 | checked
|
5601 | } = props2;
|
5602 | if (slots.default) {
|
5603 | return vue.createVNode("span", {
|
5604 | "class": props2.bem("label", [props2.labelPosition, {
|
5605 | disabled: disabled.value
|
5606 | }])
|
5607 | }, [slots.default({
|
5608 | checked,
|
5609 | disabled: disabled.value
|
5610 | })]);
|
5611 | }
|
5612 | };
|
5613 | return () => {
|
5614 | const nodes = props2.labelPosition === "left" ? [renderLabel(), renderIcon()] : [renderIcon(), renderLabel()];
|
5615 | return vue.createVNode("div", {
|
5616 | "role": props2.role,
|
5617 | "class": props2.bem([{
|
5618 | disabled: disabled.value,
|
5619 | "label-disabled": props2.labelDisabled
|
5620 | }, direction.value]),
|
5621 | "tabindex": disabled.value ? void 0 : 0,
|
5622 | "aria-checked": props2.checked,
|
5623 | "onClick": onClick
|
5624 | }, [nodes]);
|
5625 | };
|
5626 | }
|
5627 | });
|
5628 | const radioProps = extend({}, checkerProps, {
|
5629 | shape: String
|
5630 | });
|
5631 | const [name$1d, bem$19] = createNamespace("radio");
|
5632 | var stdin_default$1m = vue.defineComponent({
|
5633 | name: name$1d,
|
5634 | props: radioProps,
|
5635 | emits: ["update:modelValue"],
|
5636 | setup(props2, {
|
5637 | emit,
|
5638 | slots
|
5639 | }) {
|
5640 | const {
|
5641 | parent
|
5642 | } = use.useParent(RADIO_KEY);
|
5643 | const checked = () => {
|
5644 | const value = parent ? parent.props.modelValue : props2.modelValue;
|
5645 | return value === props2.name;
|
5646 | };
|
5647 | const toggle = () => {
|
5648 | if (parent) {
|
5649 | parent.updateValue(props2.name);
|
5650 | } else {
|
5651 | emit("update:modelValue", props2.name);
|
5652 | }
|
5653 | };
|
5654 | return () => vue.createVNode(stdin_default$1n, vue.mergeProps({
|
5655 | "bem": bem$19,
|
5656 | "role": "radio",
|
5657 | "parent": parent,
|
5658 | "checked": checked(),
|
5659 | "onToggle": toggle
|
5660 | }, props2), pick(slots, ["default", "icon"]));
|
5661 | }
|
5662 | });
|
5663 | const Radio = withInstall(stdin_default$1m);
|
5664 | const [name$1c, bem$18] = createNamespace("checkbox");
|
5665 | const checkboxProps = extend({}, checkerProps, {
|
5666 | shape: String,
|
5667 | bindGroup: truthProp,
|
5668 | indeterminate: {
|
5669 | type: Boolean,
|
5670 | default: null
|
5671 | }
|
5672 | });
|
5673 | var stdin_default$1l = vue.defineComponent({
|
5674 | name: name$1c,
|
5675 | props: checkboxProps,
|
5676 | emits: ["change", "update:modelValue"],
|
5677 | setup(props2, {
|
5678 | emit,
|
5679 | slots
|
5680 | }) {
|
5681 | const {
|
5682 | parent
|
5683 | } = use.useParent(CHECKBOX_GROUP_KEY);
|
5684 | const setParentValue = (checked2) => {
|
5685 | const {
|
5686 | name: name2
|
5687 | } = props2;
|
5688 | const {
|
5689 | max,
|
5690 | modelValue
|
5691 | } = parent.props;
|
5692 | const value = modelValue.slice();
|
5693 | if (checked2) {
|
5694 | const overlimit = max && value.length >= +max;
|
5695 | if (!overlimit && !value.includes(name2)) {
|
5696 | value.push(name2);
|
5697 | if (props2.bindGroup) {
|
5698 | parent.updateValue(value);
|
5699 | }
|
5700 | }
|
5701 | } else {
|
5702 | const index = value.indexOf(name2);
|
5703 | if (index !== -1) {
|
5704 | value.splice(index, 1);
|
5705 | if (props2.bindGroup) {
|
5706 | parent.updateValue(value);
|
5707 | }
|
5708 | }
|
5709 | }
|
5710 | };
|
5711 | const checked = vue.computed(() => {
|
5712 | if (parent && props2.bindGroup) {
|
5713 | return parent.props.modelValue.indexOf(props2.name) !== -1;
|
5714 | }
|
5715 | return !!props2.modelValue;
|
5716 | });
|
5717 | const toggle = (newValue = !checked.value) => {
|
5718 | if (parent && props2.bindGroup) {
|
5719 | setParentValue(newValue);
|
5720 | } else {
|
5721 | emit("update:modelValue", newValue);
|
5722 | }
|
5723 | if (props2.indeterminate !== null) emit("change", newValue);
|
5724 | };
|
5725 | vue.watch(() => props2.modelValue, (value) => {
|
5726 | if (props2.indeterminate === null) emit("change", value);
|
5727 | });
|
5728 | useExpose({
|
5729 | toggle,
|
5730 | props: props2,
|
5731 | checked
|
5732 | });
|
5733 | use.useCustomFieldValue(() => props2.modelValue);
|
5734 | return () => vue.createVNode(stdin_default$1n, vue.mergeProps({
|
5735 | "bem": bem$18,
|
5736 | "role": "checkbox",
|
5737 | "parent": parent,
|
5738 | "checked": checked.value,
|
5739 | "onToggle": toggle
|
5740 | }, props2), pick(slots, ["default", "icon"]));
|
5741 | }
|
5742 | });
|
5743 | const Checkbox = withInstall(stdin_default$1l);
|
5744 | const [name$1b, bem$17] = createNamespace("address-item");
|
5745 | var stdin_default$1k = vue.defineComponent({
|
5746 | name: name$1b,
|
5747 | props: {
|
5748 | address: makeRequiredProp(Object),
|
5749 | disabled: Boolean,
|
5750 | switchable: Boolean,
|
5751 | singleChoice: Boolean,
|
5752 | defaultTagText: String,
|
5753 | rightIcon: makeStringProp("edit")
|
5754 | },
|
5755 | emits: ["edit", "click", "select"],
|
5756 | setup(props2, {
|
5757 | slots,
|
5758 | emit
|
5759 | }) {
|
5760 | const onClick = (event) => {
|
5761 | if (props2.switchable) {
|
5762 | emit("select");
|
5763 | }
|
5764 | emit("click", event);
|
5765 | };
|
5766 | const renderRightIcon = () => vue.createVNode(Icon, {
|
5767 | "name": props2.rightIcon,
|
5768 | "class": bem$17("edit"),
|
5769 | "onClick": (event) => {
|
5770 | event.stopPropagation();
|
5771 | emit("edit");
|
5772 | emit("click", event);
|
5773 | }
|
5774 | }, null);
|
5775 | const renderTag = () => {
|
5776 | if (slots.tag) {
|
5777 | return slots.tag(props2.address);
|
5778 | }
|
5779 | if (props2.address.isDefault && props2.defaultTagText) {
|
5780 | return vue.createVNode(Tag, {
|
5781 | "type": "primary",
|
5782 | "round": true,
|
5783 | "class": bem$17("tag")
|
5784 | }, {
|
5785 | default: () => [props2.defaultTagText]
|
5786 | });
|
5787 | }
|
5788 | };
|
5789 | const renderContent = () => {
|
5790 | const {
|
5791 | address,
|
5792 | disabled,
|
5793 | switchable,
|
5794 | singleChoice
|
5795 | } = props2;
|
5796 | const Info = [vue.createVNode("div", {
|
5797 | "class": bem$17("name")
|
5798 | }, [`${address.name} ${address.tel}`, renderTag()]), vue.createVNode("div", {
|
5799 | "class": bem$17("address")
|
5800 | }, [address.address])];
|
5801 | if (switchable && !disabled) {
|
5802 | if (singleChoice) {
|
5803 | return vue.createVNode(Radio, {
|
5804 | "name": address.id,
|
5805 | "iconSize": 18
|
5806 | }, {
|
5807 | default: () => [Info]
|
5808 | });
|
5809 | } else {
|
5810 | return vue.createVNode(Checkbox, {
|
5811 | "name": address.id,
|
5812 | "iconSize": 18
|
5813 | }, {
|
5814 | default: () => [Info]
|
5815 | });
|
5816 | }
|
5817 | }
|
5818 | return Info;
|
5819 | };
|
5820 | return () => {
|
5821 | var _a;
|
5822 | const {
|
5823 | disabled
|
5824 | } = props2;
|
5825 | return vue.createVNode("div", {
|
5826 | "class": bem$17({
|
5827 | disabled
|
5828 | }),
|
5829 | "onClick": onClick
|
5830 | }, [vue.createVNode(Cell, {
|
5831 | "border": false,
|
5832 | "titleClass": bem$17("title")
|
5833 | }, {
|
5834 | title: renderContent,
|
5835 | "right-icon": renderRightIcon
|
5836 | }), (_a = slots.bottom) == null ? void 0 : _a.call(slots, extend({}, props2.address, {
|
5837 | disabled
|
5838 | }))]);
|
5839 | };
|
5840 | }
|
5841 | });
|
5842 | const [name$1a, bem$16, t$h] = createNamespace("address-list");
|
5843 | const addressListProps = {
|
5844 | list: makeArrayProp(),
|
5845 | modelValue: [...numericProp, Array],
|
5846 | switchable: truthProp,
|
5847 | disabledText: String,
|
5848 | disabledList: makeArrayProp(),
|
5849 | showAddButton: truthProp,
|
5850 | addButtonText: String,
|
5851 | defaultTagText: String,
|
5852 | rightIcon: makeStringProp("edit")
|
5853 | };
|
5854 | var stdin_default$1j = vue.defineComponent({
|
5855 | name: name$1a,
|
5856 | props: addressListProps,
|
5857 | emits: ["add", "edit", "select", "clickItem", "editDisabled", "selectDisabled", "update:modelValue"],
|
5858 | setup(props2, {
|
5859 | slots,
|
5860 | emit
|
5861 | }) {
|
5862 | const singleChoice = vue.computed(() => !Array.isArray(props2.modelValue));
|
5863 | const renderItem = (item, index, disabled) => {
|
5864 | const onEdit = () => emit(disabled ? "editDisabled" : "edit", item, index);
|
5865 | const onClick = (event) => emit("clickItem", item, index, {
|
5866 | event
|
5867 | });
|
5868 | const onSelect = () => {
|
5869 | emit(disabled ? "selectDisabled" : "select", item, index);
|
5870 | if (!disabled) {
|
5871 | if (singleChoice.value) {
|
5872 | emit("update:modelValue", item.id);
|
5873 | } else {
|
5874 | const value = props2.modelValue;
|
5875 | if (value.includes(item.id)) {
|
5876 | emit("update:modelValue", value.filter((id) => id !== item.id));
|
5877 | } else {
|
5878 | emit("update:modelValue", [...value, item.id]);
|
5879 | }
|
5880 | }
|
5881 | }
|
5882 | };
|
5883 | return vue.createVNode(stdin_default$1k, {
|
5884 | "key": item.id,
|
5885 | "address": item,
|
5886 | "disabled": disabled,
|
5887 | "switchable": props2.switchable,
|
5888 | "singleChoice": singleChoice.value,
|
5889 | "defaultTagText": props2.defaultTagText,
|
5890 | "rightIcon": props2.rightIcon,
|
5891 | "onEdit": onEdit,
|
5892 | "onClick": onClick,
|
5893 | "onSelect": onSelect
|
5894 | }, {
|
5895 | bottom: slots["item-bottom"],
|
5896 | tag: slots.tag
|
5897 | });
|
5898 | };
|
5899 | const renderList = (list, disabled) => {
|
5900 | if (list) {
|
5901 | return list.map((item, index) => renderItem(item, index, disabled));
|
5902 | }
|
5903 | };
|
5904 | const renderBottom = () => props2.showAddButton ? vue.createVNode("div", {
|
5905 | "class": [bem$16("bottom"), "van-safe-area-bottom"]
|
5906 | }, [vue.createVNode(Button, {
|
5907 | "round": true,
|
5908 | "block": true,
|
5909 | "type": "primary",
|
5910 | "text": props2.addButtonText || t$h("add"),
|
5911 | "class": bem$16("add"),
|
5912 | "onClick": () => emit("add")
|
5913 | }, null)]) : void 0;
|
5914 | return () => {
|
5915 | var _a, _b;
|
5916 | const List2 = renderList(props2.list);
|
5917 | const DisabledList = renderList(props2.disabledList, true);
|
5918 | const DisabledText = props2.disabledText && vue.createVNode("div", {
|
5919 | "class": bem$16("disabled-text")
|
5920 | }, [props2.disabledText]);
|
5921 | return vue.createVNode("div", {
|
5922 | "class": bem$16()
|
5923 | }, [(_a = slots.top) == null ? void 0 : _a.call(slots), !singleChoice.value && Array.isArray(props2.modelValue) ? vue.createVNode(CheckboxGroup, {
|
5924 | "modelValue": props2.modelValue
|
5925 | }, {
|
5926 | default: () => [List2]
|
5927 | }) : vue.createVNode(RadioGroup, {
|
5928 | "modelValue": props2.modelValue
|
5929 | }, {
|
5930 | default: () => [List2]
|
5931 | }), DisabledText, DisabledList, (_b = slots.default) == null ? void 0 : _b.call(slots), renderBottom()]);
|
5932 | };
|
5933 | }
|
5934 | });
|
5935 | const AddressList = withInstall(stdin_default$1j);
|
5936 | const hasIntersectionObserver = use.inBrowser && "IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype;
|
5937 | const modeType = {
|
5938 | event: "event",
|
5939 | observer: "observer"
|
5940 | };
|
5941 | function remove(arr, item) {
|
5942 | if (!arr.length) return;
|
5943 | const index = arr.indexOf(item);
|
5944 | if (index > -1) return arr.splice(index, 1);
|
5945 | }
|
5946 | function getBestSelectionFromSrcset(el, scale) {
|
5947 | if (el.tagName !== "IMG" || !el.getAttribute("data-srcset")) return;
|
5948 | let options = el.getAttribute("data-srcset");
|
5949 | const container = el.parentNode;
|
5950 | const containerWidth = container.offsetWidth * scale;
|
5951 | let spaceIndex;
|
5952 | let tmpSrc;
|
5953 | let tmpWidth;
|
5954 | options = options.trim().split(",");
|
5955 | const result = options.map((item) => {
|
5956 | item = item.trim();
|
5957 | spaceIndex = item.lastIndexOf(" ");
|
5958 | if (spaceIndex === -1) {
|
5959 | tmpSrc = item;
|
5960 | tmpWidth = 999998;
|
5961 | } else {
|
5962 | tmpSrc = item.substr(0, spaceIndex);
|
5963 | tmpWidth = parseInt(
|
5964 | item.substr(spaceIndex + 1, item.length - spaceIndex - 2),
|
5965 | 10
|
5966 | );
|
5967 | }
|
5968 | return [tmpWidth, tmpSrc];
|
5969 | });
|
5970 | result.sort((a, b) => {
|
5971 | if (a[0] < b[0]) {
|
5972 | return 1;
|
5973 | }
|
5974 | if (a[0] > b[0]) {
|
5975 | return -1;
|
5976 | }
|
5977 | if (a[0] === b[0]) {
|
5978 | if (b[1].indexOf(".webp", b[1].length - 5) !== -1) {
|
5979 | return 1;
|
5980 | }
|
5981 | if (a[1].indexOf(".webp", a[1].length - 5) !== -1) {
|
5982 | return -1;
|
5983 | }
|
5984 | }
|
5985 | return 0;
|
5986 | });
|
5987 | let bestSelectedSrc = "";
|
5988 | let tmpOption;
|
5989 | for (let i = 0; i < result.length; i++) {
|
5990 | tmpOption = result[i];
|
5991 | bestSelectedSrc = tmpOption[1];
|
5992 | const next = result[i + 1];
|
5993 | if (next && next[0] < containerWidth) {
|
5994 | bestSelectedSrc = tmpOption[1];
|
5995 | break;
|
5996 | } else if (!next) {
|
5997 | bestSelectedSrc = tmpOption[1];
|
5998 | break;
|
5999 | }
|
6000 | }
|
6001 | return bestSelectedSrc;
|
6002 | }
|
6003 | const getDPR = (scale = 1) => use.inBrowser ? window.devicePixelRatio || scale : scale;
|
6004 | function supportWebp() {
|
6005 | if (!use.inBrowser) return false;
|
6006 | let support = true;
|
6007 | try {
|
6008 | const elem = document.createElement("canvas");
|
6009 | if (elem.getContext && elem.getContext("2d")) {
|
6010 | support = elem.toDataURL("image/webp").indexOf("data:image/webp") === 0;
|
6011 | }
|
6012 | } catch (err) {
|
6013 | support = false;
|
6014 | }
|
6015 | return support;
|
6016 | }
|
6017 | function throttle(action, delay) {
|
6018 | let timeout = null;
|
6019 | let lastRun = 0;
|
6020 | return function(...args) {
|
6021 | if (timeout) {
|
6022 | return;
|
6023 | }
|
6024 | const elapsed = Date.now() - lastRun;
|
6025 | const runCallback = () => {
|
6026 | lastRun = Date.now();
|
6027 | timeout = false;
|
6028 | action.apply(this, args);
|
6029 | };
|
6030 | if (elapsed >= delay) {
|
6031 | runCallback();
|
6032 | } else {
|
6033 | timeout = setTimeout(runCallback, delay);
|
6034 | }
|
6035 | };
|
6036 | }
|
6037 | function on(el, type, func) {
|
6038 | el.addEventListener(type, func, {
|
6039 | capture: false,
|
6040 | passive: true
|
6041 | });
|
6042 | }
|
6043 | function off(el, type, func) {
|
6044 | el.removeEventListener(type, func, false);
|
6045 | }
|
6046 | const loadImageAsync = (item, resolve, reject) => {
|
6047 | const image = new Image();
|
6048 | if (!item || !item.src) {
|
6049 | return reject(new Error("image src is required"));
|
6050 | }
|
6051 | image.src = item.src;
|
6052 | if (item.cors) {
|
6053 | image.crossOrigin = item.cors;
|
6054 | }
|
6055 | image.onload = () => resolve({
|
6056 | naturalHeight: image.naturalHeight,
|
6057 | naturalWidth: image.naturalWidth,
|
6058 | src: image.src
|
6059 | });
|
6060 | image.onerror = (e) => reject(e);
|
6061 | };
|
6062 | class ImageCache {
|
6063 | constructor({ max }) {
|
6064 | this.options = {
|
6065 | max: max || 100
|
6066 | };
|
6067 | this.caches = [];
|
6068 | }
|
6069 | has(key) {
|
6070 | return this.caches.indexOf(key) > -1;
|
6071 | }
|
6072 | add(key) {
|
6073 | if (this.has(key)) return;
|
6074 | this.caches.push(key);
|
6075 | if (this.caches.length > this.options.max) {
|
6076 | this.free();
|
6077 | }
|
6078 | }
|
6079 | free() {
|
6080 | this.caches.shift();
|
6081 | }
|
6082 | }
|
6083 | const [name$19, bem$15] = createNamespace("back-top");
|
6084 | const backTopProps = {
|
6085 | right: numericProp,
|
6086 | bottom: numericProp,
|
6087 | zIndex: numericProp,
|
6088 | target: [String, Object],
|
6089 | offset: makeNumericProp(200),
|
6090 | immediate: Boolean,
|
6091 | teleport: {
|
6092 | type: [String, Object],
|
6093 | default: "body"
|
6094 | }
|
6095 | };
|
6096 | var stdin_default$1i = vue.defineComponent({
|
6097 | name: name$19,
|
6098 | inheritAttrs: false,
|
6099 | props: backTopProps,
|
6100 | emits: ["click"],
|
6101 | setup(props2, {
|
6102 | emit,
|
6103 | slots,
|
6104 | attrs
|
6105 | }) {
|
6106 | let shouldReshow = false;
|
6107 | const show = vue.ref(false);
|
6108 | const root = vue.ref();
|
6109 | const scrollParent = vue.ref();
|
6110 | const style = vue.computed(() => extend(getZIndexStyle(props2.zIndex), {
|
6111 | right: addUnit(props2.right),
|
6112 | bottom: addUnit(props2.bottom)
|
6113 | }));
|
6114 | const onClick = (event) => {
|
6115 | var _a;
|
6116 | emit("click", event);
|
6117 | (_a = scrollParent.value) == null ? void 0 : _a.scrollTo({
|
6118 | top: 0,
|
6119 | behavior: props2.immediate ? "auto" : "smooth"
|
6120 | });
|
6121 | };
|
6122 | const scroll = () => {
|
6123 | show.value = scrollParent.value ? getScrollTop(scrollParent.value) >= +props2.offset : false;
|
6124 | };
|
6125 | const getTarget = () => {
|
6126 | const {
|
6127 | target
|
6128 | } = props2;
|
6129 | if (typeof target === "string") {
|
6130 | const el = document.querySelector(target);
|
6131 | if (el) {
|
6132 | return el;
|
6133 | }
|
6134 | if (process.env.NODE_ENV !== "production") {
|
6135 | console.error(`[Vant] BackTop: target element "${target}" was not found, the BackTop component will not be rendered.`);
|
6136 | }
|
6137 | } else {
|
6138 | return target;
|
6139 | }
|
6140 | };
|
6141 | const updateTarget = () => {
|
6142 | if (inBrowser) {
|
6143 | vue.nextTick(() => {
|
6144 | scrollParent.value = props2.target ? getTarget() : use.getScrollParent(root.value);
|
6145 | scroll();
|
6146 | });
|
6147 | }
|
6148 | };
|
6149 | use.useEventListener("scroll", throttle(scroll, 100), {
|
6150 | target: scrollParent
|
6151 | });
|
6152 | vue.onMounted(updateTarget);
|
6153 | vue.onActivated(() => {
|
6154 | if (shouldReshow) {
|
6155 | show.value = true;
|
6156 | shouldReshow = false;
|
6157 | }
|
6158 | });
|
6159 | vue.onDeactivated(() => {
|
6160 | if (show.value && props2.teleport) {
|
6161 | show.value = false;
|
6162 | shouldReshow = true;
|
6163 | }
|
6164 | });
|
6165 | vue.watch(() => props2.target, updateTarget);
|
6166 | return () => {
|
6167 | const Content = vue.createVNode("div", vue.mergeProps({
|
6168 | "ref": !props2.teleport ? root : void 0,
|
6169 | "class": bem$15({
|
6170 | active: show.value
|
6171 | }),
|
6172 | "style": style.value,
|
6173 | "onClick": onClick
|
6174 | }, attrs), [slots.default ? slots.default() : vue.createVNode(Icon, {
|
6175 | "name": "back-top",
|
6176 | "class": bem$15("icon")
|
6177 | }, null)]);
|
6178 | if (props2.teleport) {
|
6179 | return [vue.createVNode("div", {
|
6180 | "ref": root,
|
6181 | "class": bem$15("placeholder")
|
6182 | }, null), vue.createVNode(vue.Teleport, {
|
6183 | "to": props2.teleport
|
6184 | }, {
|
6185 | default: () => [Content]
|
6186 | })];
|
6187 | }
|
6188 | return Content;
|
6189 | };
|
6190 | }
|
6191 | });
|
6192 | const BackTop = withInstall(stdin_default$1i);
|
6193 | var __async = (__this, __arguments, generator) => {
|
6194 | return new Promise((resolve, reject) => {
|
6195 | var fulfilled = (value) => {
|
6196 | try {
|
6197 | step(generator.next(value));
|
6198 | } catch (e) {
|
6199 | reject(e);
|
6200 | }
|
6201 | };
|
6202 | var rejected = (value) => {
|
6203 | try {
|
6204 | step(generator.throw(value));
|
6205 | } catch (e) {
|
6206 | reject(e);
|
6207 | }
|
6208 | };
|
6209 | var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
6210 | step((generator = generator.apply(__this, __arguments)).next());
|
6211 | });
|
6212 | };
|
6213 | const barrageProps = {
|
6214 | top: makeNumericProp(10),
|
6215 | rows: makeNumericProp(4),
|
6216 | duration: makeNumericProp(4e3),
|
6217 | autoPlay: truthProp,
|
6218 | delay: makeNumberProp(300),
|
6219 | modelValue: makeArrayProp()
|
6220 | };
|
6221 | const [name$18, bem$14] = createNamespace("barrage");
|
6222 | var stdin_default$1h = vue.defineComponent({
|
6223 | name: name$18,
|
6224 | props: barrageProps,
|
6225 | emits: ["update:modelValue"],
|
6226 | setup(props2, {
|
6227 | emit,
|
6228 | slots
|
6229 | }) {
|
6230 | const barrageWrapper = vue.ref();
|
6231 | const className = bem$14("item");
|
6232 | const total = vue.ref(0);
|
6233 | const barrageItems = [];
|
6234 | const createBarrageItem = (text, delay = props2.delay) => {
|
6235 | const item = document.createElement("span");
|
6236 | item.className = className;
|
6237 | item.innerText = String(text);
|
6238 | item.style.animationDuration = `${props2.duration}ms`;
|
6239 | item.style.animationDelay = `${delay}ms`;
|
6240 | item.style.animationName = "van-barrage";
|
6241 | item.style.animationTimingFunction = "linear";
|
6242 | return item;
|
6243 | };
|
6244 | const isInitBarrage = vue.ref(true);
|
6245 | const isPlay = vue.ref(props2.autoPlay);
|
6246 | const appendBarrageItem = ({
|
6247 | id,
|
6248 | text
|
6249 | }, i) => {
|
6250 | var _a;
|
6251 | const item = createBarrageItem(text, isInitBarrage.value ? i * props2.delay : void 0);
|
6252 | if (!props2.autoPlay && isPlay.value === false) {
|
6253 | item.style.animationPlayState = "paused";
|
6254 | }
|
6255 | (_a = barrageWrapper.value) == null ? void 0 : _a.append(item);
|
6256 | total.value++;
|
6257 | const top = (total.value - 1) % +props2.rows * item.offsetHeight + +props2.top;
|
6258 | item.style.top = `${top}px`;
|
6259 | item.dataset.id = String(id);
|
6260 | barrageItems.push(item);
|
6261 | item.addEventListener("animationend", () => {
|
6262 | emit("update:modelValue", [...props2.modelValue].filter((v) => String(v.id) !== item.dataset.id));
|
6263 | });
|
6264 | };
|
6265 | const updateBarrages = (newValue, oldValue) => {
|
6266 | const map = new Map(oldValue.map((item) => [item.id, item]));
|
6267 | newValue.forEach((item, i) => {
|
6268 | if (map.has(item.id)) {
|
6269 | map.delete(item.id);
|
6270 | } else {
|
6271 | appendBarrageItem(item, i);
|
6272 | }
|
6273 | });
|
6274 | map.forEach((item) => {
|
6275 | const index = barrageItems.findIndex((span) => span.dataset.id === String(item.id));
|
6276 | if (index > -1) {
|
6277 | barrageItems[index].remove();
|
6278 | barrageItems.splice(index, 1);
|
6279 | }
|
6280 | });
|
6281 | isInitBarrage.value = false;
|
6282 | };
|
6283 | vue.watch(() => props2.modelValue.slice(), (newValue, oldValue) => updateBarrages(newValue != null ? newValue : [], oldValue != null ? oldValue : []), {
|
6284 | deep: true
|
6285 | });
|
6286 | const rootStyle = vue.ref({});
|
6287 | vue.onMounted(() => __async(this, null, function* () {
|
6288 | var _a;
|
6289 | rootStyle.value["--move-distance"] = `-${(_a = barrageWrapper.value) == null ? void 0 : _a.offsetWidth}px`;
|
6290 | yield vue.nextTick();
|
6291 | updateBarrages(props2.modelValue, []);
|
6292 | }));
|
6293 | const play = () => {
|
6294 | isPlay.value = true;
|
6295 | barrageItems.forEach((item) => {
|
6296 | item.style.animationPlayState = "running";
|
6297 | });
|
6298 | };
|
6299 | const pause = () => {
|
6300 | isPlay.value = false;
|
6301 | barrageItems.forEach((item) => {
|
6302 | item.style.animationPlayState = "paused";
|
6303 | });
|
6304 | };
|
6305 | useExpose({
|
6306 | play,
|
6307 | pause
|
6308 | });
|
6309 | return () => {
|
6310 | var _a;
|
6311 | return vue.createVNode("div", {
|
6312 | "class": bem$14(),
|
6313 | "ref": barrageWrapper,
|
6314 | "style": rootStyle.value
|
6315 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
6316 | };
|
6317 | }
|
6318 | });
|
6319 | const Barrage = withInstall(stdin_default$1h);
|
6320 | const [name$17, bem$13, t$g] = createNamespace("calendar");
|
6321 | const formatMonthTitle = (date) => t$g("monthTitle", date.getFullYear(), date.getMonth() + 1);
|
6322 | function compareMonth(date1, date2) {
|
6323 | const year1 = date1.getFullYear();
|
6324 | const year2 = date2.getFullYear();
|
6325 | if (year1 === year2) {
|
6326 | const month1 = date1.getMonth();
|
6327 | const month2 = date2.getMonth();
|
6328 | return month1 === month2 ? 0 : month1 > month2 ? 1 : -1;
|
6329 | }
|
6330 | return year1 > year2 ? 1 : -1;
|
6331 | }
|
6332 | function compareDay(day1, day2) {
|
6333 | const compareMonthResult = compareMonth(day1, day2);
|
6334 | if (compareMonthResult === 0) {
|
6335 | const date1 = day1.getDate();
|
6336 | const date2 = day2.getDate();
|
6337 | return date1 === date2 ? 0 : date1 > date2 ? 1 : -1;
|
6338 | }
|
6339 | return compareMonthResult;
|
6340 | }
|
6341 | const cloneDate = (date) => new Date(date);
|
6342 | const cloneDates = (dates) => Array.isArray(dates) ? dates.map(cloneDate) : cloneDate(dates);
|
6343 | function getDayByOffset(date, offset) {
|
6344 | const cloned = cloneDate(date);
|
6345 | cloned.setDate(cloned.getDate() + offset);
|
6346 | return cloned;
|
6347 | }
|
6348 | function getMonthByOffset(date, offset) {
|
6349 | const cloned = cloneDate(date);
|
6350 | cloned.setMonth(cloned.getMonth() + offset);
|
6351 | if (cloned.getDate() !== date.getDate()) {
|
6352 | cloned.setDate(0);
|
6353 | }
|
6354 | return cloned;
|
6355 | }
|
6356 | function getYearByOffset(date, offset) {
|
6357 | const cloned = cloneDate(date);
|
6358 | cloned.setFullYear(cloned.getFullYear() + offset);
|
6359 | if (cloned.getDate() !== date.getDate()) {
|
6360 | cloned.setDate(0);
|
6361 | }
|
6362 | return cloned;
|
6363 | }
|
6364 | const getPrevDay = (date) => getDayByOffset(date, -1);
|
6365 | const getNextDay = (date) => getDayByOffset(date, 1);
|
6366 | const getPrevMonth = (date) => getMonthByOffset(date, -1);
|
6367 | const getNextMonth = (date) => getMonthByOffset(date, 1);
|
6368 | const getPrevYear = (date) => getYearByOffset(date, -1);
|
6369 | const getNextYear = (date) => getYearByOffset(date, 1);
|
6370 | const getToday = () => {
|
6371 | const today = new Date();
|
6372 | today.setHours(0, 0, 0, 0);
|
6373 | return today;
|
6374 | };
|
6375 | function calcDateNum(date) {
|
6376 | const day1 = date[0].getTime();
|
6377 | const day2 = date[1].getTime();
|
6378 | return (day2 - day1) / (1e3 * 60 * 60 * 24) + 1;
|
6379 | }
|
6380 | const sharedProps = extend({}, pickerSharedProps, {
|
6381 | modelValue: makeArrayProp(),
|
6382 | filter: Function,
|
6383 | formatter: {
|
6384 | type: Function,
|
6385 | default: (type, option) => option
|
6386 | }
|
6387 | });
|
6388 | const pickerInheritKeys = Object.keys(pickerSharedProps);
|
6389 | function times(n, iteratee) {
|
6390 | if (n < 0) {
|
6391 | return [];
|
6392 | }
|
6393 | const result = Array(n);
|
6394 | let index = -1;
|
6395 | while (++index < n) {
|
6396 | result[index] = iteratee(index);
|
6397 | }
|
6398 | return result;
|
6399 | }
|
6400 | const getMonthEndDay = (year, month) => 32 - new Date(year, month - 1, 32).getDate();
|
6401 | const genOptions = (min, max, type, formatter, filter, values) => {
|
6402 | const options = times(max - min + 1, (index) => {
|
6403 | const value = padZero(min + index);
|
6404 | return formatter(type, {
|
6405 | text: value,
|
6406 | value
|
6407 | });
|
6408 | });
|
6409 | return filter ? filter(type, options, values) : options;
|
6410 | };
|
6411 | const formatValueRange = (values, columns) => values.map((value, index) => {
|
6412 | const column = columns[index];
|
6413 | if (column.length) {
|
6414 | const minValue = +column[0].value;
|
6415 | const maxValue = +column[column.length - 1].value;
|
6416 | return padZero(clamp(+value, minValue, maxValue));
|
6417 | }
|
6418 | return value;
|
6419 | });
|
6420 | const [name$16] = createNamespace("calendar-day");
|
6421 | var stdin_default$1g = vue.defineComponent({
|
6422 | name: name$16,
|
6423 | props: {
|
6424 | item: makeRequiredProp(Object),
|
6425 | color: String,
|
6426 | index: Number,
|
6427 | offset: makeNumberProp(0),
|
6428 | rowHeight: String
|
6429 | },
|
6430 | emits: ["click", "clickDisabledDate"],
|
6431 | setup(props2, {
|
6432 | emit,
|
6433 | slots
|
6434 | }) {
|
6435 | const style = vue.computed(() => {
|
6436 | var _a;
|
6437 | const {
|
6438 | item,
|
6439 | index,
|
6440 | color,
|
6441 | offset,
|
6442 | rowHeight
|
6443 | } = props2;
|
6444 | const style2 = {
|
6445 | height: rowHeight
|
6446 | };
|
6447 | if (item.type === "placeholder") {
|
6448 | style2.width = "100%";
|
6449 | return style2;
|
6450 | }
|
6451 | if (index === 0) {
|
6452 | style2.marginLeft = `${100 * offset / 7}%`;
|
6453 | }
|
6454 | if (color) {
|
6455 | switch (item.type) {
|
6456 | case "end":
|
6457 | case "start":
|
6458 | case "start-end":
|
6459 | case "multiple-middle":
|
6460 | case "multiple-selected":
|
6461 | style2.background = color;
|
6462 | break;
|
6463 | case "middle":
|
6464 | style2.color = color;
|
6465 | break;
|
6466 | }
|
6467 | }
|
6468 | if (offset + (((_a = item.date) == null ? void 0 : _a.getDate()) || 1) > 28) {
|
6469 | style2.marginBottom = 0;
|
6470 | }
|
6471 | return style2;
|
6472 | });
|
6473 | const onClick = () => {
|
6474 | if (props2.item.type !== "disabled") {
|
6475 | emit("click", props2.item);
|
6476 | } else {
|
6477 | emit("clickDisabledDate", props2.item);
|
6478 | }
|
6479 | };
|
6480 | const renderTopInfo = () => {
|
6481 | const {
|
6482 | topInfo
|
6483 | } = props2.item;
|
6484 | if (topInfo || slots["top-info"]) {
|
6485 | return vue.createVNode("div", {
|
6486 | "class": bem$13("top-info")
|
6487 | }, [slots["top-info"] ? slots["top-info"](props2.item) : topInfo]);
|
6488 | }
|
6489 | };
|
6490 | const renderBottomInfo = () => {
|
6491 | const {
|
6492 | bottomInfo
|
6493 | } = props2.item;
|
6494 | if (bottomInfo || slots["bottom-info"]) {
|
6495 | return vue.createVNode("div", {
|
6496 | "class": bem$13("bottom-info")
|
6497 | }, [slots["bottom-info"] ? slots["bottom-info"](props2.item) : bottomInfo]);
|
6498 | }
|
6499 | };
|
6500 | const renderText = () => {
|
6501 | return slots.text ? slots.text(props2.item) : props2.item.text;
|
6502 | };
|
6503 | const renderContent = () => {
|
6504 | const {
|
6505 | item,
|
6506 | color,
|
6507 | rowHeight
|
6508 | } = props2;
|
6509 | const {
|
6510 | type
|
6511 | } = item;
|
6512 | const Nodes = [renderTopInfo(), renderText(), renderBottomInfo()];
|
6513 | if (type === "selected") {
|
6514 | return vue.createVNode("div", {
|
6515 | "class": bem$13("selected-day"),
|
6516 | "style": {
|
6517 | width: rowHeight,
|
6518 | height: rowHeight,
|
6519 | background: color
|
6520 | }
|
6521 | }, [Nodes]);
|
6522 | }
|
6523 | return Nodes;
|
6524 | };
|
6525 | return () => {
|
6526 | const {
|
6527 | type,
|
6528 | className
|
6529 | } = props2.item;
|
6530 | if (type === "placeholder") {
|
6531 | return vue.createVNode("div", {
|
6532 | "class": bem$13("day"),
|
6533 | "style": style.value
|
6534 | }, null);
|
6535 | }
|
6536 | return vue.createVNode("div", {
|
6537 | "role": "gridcell",
|
6538 | "style": style.value,
|
6539 | "class": [bem$13("day", type), className],
|
6540 | "tabindex": type === "disabled" ? void 0 : -1,
|
6541 | "onClick": onClick
|
6542 | }, [renderContent()]);
|
6543 | };
|
6544 | }
|
6545 | });
|
6546 | const [name$15] = createNamespace("calendar-month");
|
6547 | const calendarMonthProps = {
|
6548 | date: makeRequiredProp(Date),
|
6549 | type: String,
|
6550 | color: String,
|
6551 | minDate: Date,
|
6552 | maxDate: Date,
|
6553 | showMark: Boolean,
|
6554 | rowHeight: numericProp,
|
6555 | formatter: Function,
|
6556 | lazyRender: Boolean,
|
6557 | currentDate: [Date, Array],
|
6558 | allowSameDay: Boolean,
|
6559 | showSubtitle: Boolean,
|
6560 | showMonthTitle: Boolean,
|
6561 | firstDayOfWeek: Number
|
6562 | };
|
6563 | var stdin_default$1f = vue.defineComponent({
|
6564 | name: name$15,
|
6565 | props: calendarMonthProps,
|
6566 | emits: ["click", "clickDisabledDate"],
|
6567 | setup(props2, {
|
6568 | emit,
|
6569 | slots
|
6570 | }) {
|
6571 | const [visible, setVisible] = use.useToggle();
|
6572 | const daysRef = vue.ref();
|
6573 | const monthRef = vue.ref();
|
6574 | const height = useHeight(monthRef);
|
6575 | const title = vue.computed(() => formatMonthTitle(props2.date));
|
6576 | const rowHeight = vue.computed(() => addUnit(props2.rowHeight));
|
6577 | const offset = vue.computed(() => {
|
6578 | const date = props2.date.getDate();
|
6579 | const day = props2.date.getDay();
|
6580 | const realDay = (day - date % 7 + 8) % 7;
|
6581 | if (props2.firstDayOfWeek) {
|
6582 | return (realDay + 7 - props2.firstDayOfWeek) % 7;
|
6583 | }
|
6584 | return realDay;
|
6585 | });
|
6586 | const totalDay = vue.computed(() => getMonthEndDay(props2.date.getFullYear(), props2.date.getMonth() + 1));
|
6587 | const shouldRender = vue.computed(() => visible.value || !props2.lazyRender);
|
6588 | const getTitle = () => title.value;
|
6589 | const getMultipleDayType = (day) => {
|
6590 | const isSelected = (date) => props2.currentDate.some((item) => compareDay(item, date) === 0);
|
6591 | if (isSelected(day)) {
|
6592 | const prevDay = getPrevDay(day);
|
6593 | const nextDay = getNextDay(day);
|
6594 | const prevSelected = isSelected(prevDay);
|
6595 | const nextSelected = isSelected(nextDay);
|
6596 | if (prevSelected && nextSelected) {
|
6597 | return "multiple-middle";
|
6598 | }
|
6599 | if (prevSelected) {
|
6600 | return "end";
|
6601 | }
|
6602 | if (nextSelected) {
|
6603 | return "start";
|
6604 | }
|
6605 | return "multiple-selected";
|
6606 | }
|
6607 | return "";
|
6608 | };
|
6609 | const getRangeDayType = (day) => {
|
6610 | const [startDay, endDay] = props2.currentDate;
|
6611 | if (!startDay) {
|
6612 | return "";
|
6613 | }
|
6614 | const compareToStart = compareDay(day, startDay);
|
6615 | if (!endDay) {
|
6616 | return compareToStart === 0 ? "start" : "";
|
6617 | }
|
6618 | const compareToEnd = compareDay(day, endDay);
|
6619 | if (props2.allowSameDay && compareToStart === 0 && compareToEnd === 0) {
|
6620 | return "start-end";
|
6621 | }
|
6622 | if (compareToStart === 0) {
|
6623 | return "start";
|
6624 | }
|
6625 | if (compareToEnd === 0) {
|
6626 | return "end";
|
6627 | }
|
6628 | if (compareToStart > 0 && compareToEnd < 0) {
|
6629 | return "middle";
|
6630 | }
|
6631 | return "";
|
6632 | };
|
6633 | const getDayType = (day) => {
|
6634 | const {
|
6635 | type,
|
6636 | minDate,
|
6637 | maxDate,
|
6638 | currentDate
|
6639 | } = props2;
|
6640 | if (minDate && compareDay(day, minDate) < 0 || maxDate && compareDay(day, maxDate) > 0) {
|
6641 | return "disabled";
|
6642 | }
|
6643 | if (currentDate === null) {
|
6644 | return "";
|
6645 | }
|
6646 | if (Array.isArray(currentDate)) {
|
6647 | if (type === "multiple") {
|
6648 | return getMultipleDayType(day);
|
6649 | }
|
6650 | if (type === "range") {
|
6651 | return getRangeDayType(day);
|
6652 | }
|
6653 | } else if (type === "single") {
|
6654 | return compareDay(day, currentDate) === 0 ? "selected" : "";
|
6655 | }
|
6656 | return "";
|
6657 | };
|
6658 | const getBottomInfo = (dayType) => {
|
6659 | if (props2.type === "range") {
|
6660 | if (dayType === "start" || dayType === "end") {
|
6661 | return t$g(dayType);
|
6662 | }
|
6663 | if (dayType === "start-end") {
|
6664 | return `${t$g("start")}/${t$g("end")}`;
|
6665 | }
|
6666 | }
|
6667 | };
|
6668 | const renderTitle = () => {
|
6669 | if (props2.showMonthTitle) {
|
6670 | return vue.createVNode("div", {
|
6671 | "class": bem$13("month-title")
|
6672 | }, [slots["month-title"] ? slots["month-title"]({
|
6673 | date: props2.date,
|
6674 | text: title.value
|
6675 | }) : title.value]);
|
6676 | }
|
6677 | };
|
6678 | const renderMark = () => {
|
6679 | if (props2.showMark && shouldRender.value) {
|
6680 | return vue.createVNode("div", {
|
6681 | "class": bem$13("month-mark")
|
6682 | }, [props2.date.getMonth() + 1]);
|
6683 | }
|
6684 | };
|
6685 | const placeholders = vue.computed(() => {
|
6686 | const count = Math.ceil((totalDay.value + offset.value) / 7);
|
6687 | return Array(count).fill({
|
6688 | type: "placeholder"
|
6689 | });
|
6690 | });
|
6691 | const days = vue.computed(() => {
|
6692 | const days2 = [];
|
6693 | const year = props2.date.getFullYear();
|
6694 | const month = props2.date.getMonth();
|
6695 | for (let day = 1; day <= totalDay.value; day++) {
|
6696 | const date = new Date(year, month, day);
|
6697 | const type = getDayType(date);
|
6698 | let config = {
|
6699 | date,
|
6700 | type,
|
6701 | text: day,
|
6702 | bottomInfo: getBottomInfo(type)
|
6703 | };
|
6704 | if (props2.formatter) {
|
6705 | config = props2.formatter(config);
|
6706 | }
|
6707 | days2.push(config);
|
6708 | }
|
6709 | return days2;
|
6710 | });
|
6711 | const disabledDays = vue.computed(() => days.value.filter((day) => day.type === "disabled"));
|
6712 | const scrollToDate = (body, targetDate) => {
|
6713 | if (daysRef.value) {
|
6714 | const daysRect = use.useRect(daysRef.value);
|
6715 | const totalRows = placeholders.value.length;
|
6716 | const currentRow = Math.ceil((targetDate.getDate() + offset.value) / 7);
|
6717 | const rowOffset = (currentRow - 1) * daysRect.height / totalRows;
|
6718 | setScrollTop(body, daysRect.top + rowOffset + body.scrollTop - use.useRect(body).top);
|
6719 | }
|
6720 | };
|
6721 | const renderDay = (item, index) => vue.createVNode(stdin_default$1g, {
|
6722 | "item": item,
|
6723 | "index": index,
|
6724 | "color": props2.color,
|
6725 | "offset": offset.value,
|
6726 | "rowHeight": rowHeight.value,
|
6727 | "onClick": (item2) => emit("click", item2),
|
6728 | "onClickDisabledDate": (item2) => emit("clickDisabledDate", item2)
|
6729 | }, pick(slots, ["top-info", "bottom-info", "text"]));
|
6730 | const renderDays = () => vue.createVNode("div", {
|
6731 | "ref": daysRef,
|
6732 | "role": "grid",
|
6733 | "class": bem$13("days")
|
6734 | }, [renderMark(), (shouldRender.value ? days : placeholders).value.map(renderDay)]);
|
6735 | useExpose({
|
6736 | getTitle,
|
6737 | getHeight: () => height.value,
|
6738 | setVisible,
|
6739 | scrollToDate,
|
6740 | disabledDays
|
6741 | });
|
6742 | return () => vue.createVNode("div", {
|
6743 | "class": bem$13("month"),
|
6744 | "ref": monthRef
|
6745 | }, [renderTitle(), renderDays()]);
|
6746 | }
|
6747 | });
|
6748 | const [name$14] = createNamespace("calendar-header");
|
6749 | var stdin_default$1e = vue.defineComponent({
|
6750 | name: name$14,
|
6751 | props: {
|
6752 | date: Date,
|
6753 | minDate: Date,
|
6754 | maxDate: Date,
|
6755 | title: String,
|
6756 | subtitle: String,
|
6757 | showTitle: Boolean,
|
6758 | showSubtitle: Boolean,
|
6759 | firstDayOfWeek: Number,
|
6760 | switchMode: makeStringProp("none")
|
6761 | },
|
6762 | emits: ["clickSubtitle", "panelChange"],
|
6763 | setup(props2, {
|
6764 | slots,
|
6765 | emit
|
6766 | }) {
|
6767 | const prevMonthDisabled = vue.computed(() => props2.date && props2.minDate && compareMonth(getPrevMonth(props2.date), props2.minDate) < 0);
|
6768 | const prevYearDisabled = vue.computed(() => props2.date && props2.minDate && compareMonth(getPrevYear(props2.date), props2.minDate) < 0);
|
6769 | const nextMonthDisabled = vue.computed(() => props2.date && props2.maxDate && compareMonth(getNextMonth(props2.date), props2.maxDate) > 0);
|
6770 | const nextYearDisabled = vue.computed(() => props2.date && props2.maxDate && compareMonth(getNextYear(props2.date), props2.maxDate) > 0);
|
6771 | const renderTitle = () => {
|
6772 | if (props2.showTitle) {
|
6773 | const text = props2.title || t$g("title");
|
6774 | const title = slots.title ? slots.title() : text;
|
6775 | return vue.createVNode("div", {
|
6776 | "class": bem$13("header-title")
|
6777 | }, [title]);
|
6778 | }
|
6779 | };
|
6780 | const onClickSubtitle = (event) => emit("clickSubtitle", event);
|
6781 | const onPanelChange = (date) => emit("panelChange", date);
|
6782 | const renderAction = (isNext) => {
|
6783 | const showYearAction = props2.switchMode === "year-month";
|
6784 | const monthSlot = slots[isNext ? "next-month" : "prev-month"];
|
6785 | const yearSlot = slots[isNext ? "next-year" : "prev-year"];
|
6786 | const monthDisabled = isNext ? nextMonthDisabled.value : prevMonthDisabled.value;
|
6787 | const yearDisabled = isNext ? nextYearDisabled.value : prevYearDisabled.value;
|
6788 | const monthIconName = isNext ? "arrow" : "arrow-left";
|
6789 | const yearIconName = isNext ? "arrow-double-right" : "arrow-double-left";
|
6790 | const onMonthChange = () => onPanelChange((isNext ? getNextMonth : getPrevMonth)(props2.date));
|
6791 | const onYearChange = () => onPanelChange((isNext ? getNextYear : getPrevYear)(props2.date));
|
6792 | const MonthAction = vue.createVNode("view", {
|
6793 | "class": bem$13("header-action", {
|
6794 | disabled: monthDisabled
|
6795 | }),
|
6796 | "onClick": monthDisabled ? void 0 : onMonthChange
|
6797 | }, [monthSlot ? monthSlot({
|
6798 | disabled: monthDisabled
|
6799 | }) : vue.createVNode(Icon, {
|
6800 | "class": {
|
6801 | [HAPTICS_FEEDBACK]: !monthDisabled
|
6802 | },
|
6803 | "name": monthIconName
|
6804 | }, null)]);
|
6805 | const YearAction = showYearAction && vue.createVNode("view", {
|
6806 | "class": bem$13("header-action", {
|
6807 | disabled: yearDisabled
|
6808 | }),
|
6809 | "onClick": yearDisabled ? void 0 : onYearChange
|
6810 | }, [yearSlot ? yearSlot({
|
6811 | disabled: yearDisabled
|
6812 | }) : vue.createVNode(Icon, {
|
6813 | "class": {
|
6814 | [HAPTICS_FEEDBACK]: !yearDisabled
|
6815 | },
|
6816 | "name": yearIconName
|
6817 | }, null)]);
|
6818 | return isNext ? [MonthAction, YearAction] : [YearAction, MonthAction];
|
6819 | };
|
6820 | const renderSubtitle = () => {
|
6821 | if (props2.showSubtitle) {
|
6822 | const title = slots.subtitle ? slots.subtitle({
|
6823 | date: props2.date,
|
6824 | text: props2.subtitle
|
6825 | }) : props2.subtitle;
|
6826 | const canSwitch = props2.switchMode !== "none";
|
6827 | return vue.createVNode("div", {
|
6828 | "class": bem$13("header-subtitle", {
|
6829 | "with-swicth": canSwitch
|
6830 | }),
|
6831 | "onClick": onClickSubtitle
|
6832 | }, [canSwitch ? [renderAction(), vue.createVNode("div", {
|
6833 | "class": bem$13("header-subtitle-text")
|
6834 | }, [title]), renderAction(true)] : title]);
|
6835 | }
|
6836 | };
|
6837 | const renderWeekDays = () => {
|
6838 | const {
|
6839 | firstDayOfWeek
|
6840 | } = props2;
|
6841 | const weekdays = t$g("weekdays");
|
6842 | const renderWeekDays2 = [...weekdays.slice(firstDayOfWeek, 7), ...weekdays.slice(0, firstDayOfWeek)];
|
6843 | return vue.createVNode("div", {
|
6844 | "class": bem$13("weekdays")
|
6845 | }, [renderWeekDays2.map((text) => vue.createVNode("span", {
|
6846 | "class": bem$13("weekday")
|
6847 | }, [text]))]);
|
6848 | };
|
6849 | return () => vue.createVNode("div", {
|
6850 | "class": bem$13("header")
|
6851 | }, [renderTitle(), renderSubtitle(), renderWeekDays()]);
|
6852 | }
|
6853 | });
|
6854 | const calendarProps = {
|
6855 | show: Boolean,
|
6856 | type: makeStringProp("single"),
|
6857 | switchMode: makeStringProp("none"),
|
6858 | title: String,
|
6859 | color: String,
|
6860 | round: truthProp,
|
6861 | readonly: Boolean,
|
6862 | poppable: truthProp,
|
6863 | maxRange: makeNumericProp(null),
|
6864 | position: makeStringProp("bottom"),
|
6865 | teleport: [String, Object],
|
6866 | showMark: truthProp,
|
6867 | showTitle: truthProp,
|
6868 | formatter: Function,
|
6869 | rowHeight: numericProp,
|
6870 | confirmText: String,
|
6871 | rangePrompt: String,
|
6872 | lazyRender: truthProp,
|
6873 | showConfirm: truthProp,
|
6874 | defaultDate: [Date, Array],
|
6875 | allowSameDay: Boolean,
|
6876 | showSubtitle: truthProp,
|
6877 | closeOnPopstate: truthProp,
|
6878 | showRangePrompt: truthProp,
|
6879 | confirmDisabledText: String,
|
6880 | closeOnClickOverlay: truthProp,
|
6881 | safeAreaInsetTop: Boolean,
|
6882 | safeAreaInsetBottom: truthProp,
|
6883 | minDate: {
|
6884 | type: Date,
|
6885 | validator: isDate
|
6886 | },
|
6887 | maxDate: {
|
6888 | type: Date,
|
6889 | validator: isDate
|
6890 | },
|
6891 | firstDayOfWeek: {
|
6892 | type: numericProp,
|
6893 | default: 0,
|
6894 | validator: (val) => val >= 0 && val <= 6
|
6895 | }
|
6896 | };
|
6897 | var stdin_default$1d = vue.defineComponent({
|
6898 | name: name$17,
|
6899 | props: calendarProps,
|
6900 | emits: ["select", "confirm", "unselect", "monthShow", "overRange", "update:show", "clickSubtitle", "clickDisabledDate", "panelChange"],
|
6901 | setup(props2, {
|
6902 | emit,
|
6903 | slots
|
6904 | }) {
|
6905 | const canSwitch = vue.computed(() => props2.switchMode !== "none");
|
6906 | const minDate = vue.computed(() => {
|
6907 | if (!props2.minDate && !canSwitch.value) {
|
6908 | return getToday();
|
6909 | }
|
6910 | return props2.minDate;
|
6911 | });
|
6912 | const maxDate = vue.computed(() => {
|
6913 | if (!props2.maxDate && !canSwitch.value) {
|
6914 | return getMonthByOffset(getToday(), 6);
|
6915 | }
|
6916 | return props2.maxDate;
|
6917 | });
|
6918 | const limitDateRange = (date, min = minDate.value, max = maxDate.value) => {
|
6919 | if (min && compareDay(date, min) === -1) {
|
6920 | return min;
|
6921 | }
|
6922 | if (max && compareDay(date, max) === 1) {
|
6923 | return max;
|
6924 | }
|
6925 | return date;
|
6926 | };
|
6927 | const getInitialDate = (defaultDate = props2.defaultDate) => {
|
6928 | const {
|
6929 | type,
|
6930 | allowSameDay
|
6931 | } = props2;
|
6932 | if (defaultDate === null) {
|
6933 | return defaultDate;
|
6934 | }
|
6935 | const now = getToday();
|
6936 | if (type === "range") {
|
6937 | if (!Array.isArray(defaultDate)) {
|
6938 | defaultDate = [];
|
6939 | }
|
6940 | if (defaultDate.length === 1 && compareDay(defaultDate[0], now) === 1) {
|
6941 | defaultDate = [];
|
6942 | }
|
6943 | const min = minDate.value;
|
6944 | const max = maxDate.value;
|
6945 | const start = limitDateRange(defaultDate[0] || now, min, max ? allowSameDay ? max : getPrevDay(max) : void 0);
|
6946 | const end = limitDateRange(defaultDate[1] || (allowSameDay ? now : getNextDay(now)), min ? allowSameDay ? min : getNextDay(min) : void 0);
|
6947 | return [start, end];
|
6948 | }
|
6949 | if (type === "multiple") {
|
6950 | if (Array.isArray(defaultDate)) {
|
6951 | return defaultDate.map((date) => limitDateRange(date));
|
6952 | }
|
6953 | return [limitDateRange(now)];
|
6954 | }
|
6955 | if (!defaultDate || Array.isArray(defaultDate)) {
|
6956 | defaultDate = now;
|
6957 | }
|
6958 | return limitDateRange(defaultDate);
|
6959 | };
|
6960 | const getInitialPanelDate = () => {
|
6961 | const date = Array.isArray(currentDate.value) ? currentDate.value[0] : currentDate.value;
|
6962 | return date ? date : limitDateRange(getToday());
|
6963 | };
|
6964 | let bodyHeight;
|
6965 | const bodyRef = vue.ref();
|
6966 | const currentDate = vue.ref(getInitialDate());
|
6967 | const currentPanelDate = vue.ref(getInitialPanelDate());
|
6968 | const currentMonthRef = vue.ref();
|
6969 | const [monthRefs, setMonthRefs] = useRefs();
|
6970 | const dayOffset = vue.computed(() => props2.firstDayOfWeek ? +props2.firstDayOfWeek % 7 : 0);
|
6971 | const months = vue.computed(() => {
|
6972 | const months2 = [];
|
6973 | if (!minDate.value || !maxDate.value) {
|
6974 | return months2;
|
6975 | }
|
6976 | const cursor = new Date(minDate.value);
|
6977 | cursor.setDate(1);
|
6978 | do {
|
6979 | months2.push(new Date(cursor));
|
6980 | cursor.setMonth(cursor.getMonth() + 1);
|
6981 | } while (compareMonth(cursor, maxDate.value) !== 1);
|
6982 | return months2;
|
6983 | });
|
6984 | const buttonDisabled = vue.computed(() => {
|
6985 | if (currentDate.value) {
|
6986 | if (props2.type === "range") {
|
6987 | return !currentDate.value[0] || !currentDate.value[1];
|
6988 | }
|
6989 | if (props2.type === "multiple") {
|
6990 | return !currentDate.value.length;
|
6991 | }
|
6992 | }
|
6993 | return !currentDate.value;
|
6994 | });
|
6995 | const getSelectedDate = () => currentDate.value;
|
6996 | const onScroll = () => {
|
6997 | const top = getScrollTop(bodyRef.value);
|
6998 | const bottom = top + bodyHeight;
|
6999 | const heights = months.value.map((item, index) => monthRefs.value[index].getHeight());
|
7000 | const heightSum = heights.reduce((a, b) => a + b, 0);
|
7001 | if (bottom > heightSum && top > 0) {
|
7002 | return;
|
7003 | }
|
7004 | let height = 0;
|
7005 | let currentMonth;
|
7006 | const visibleRange = [-1, -1];
|
7007 | for (let i = 0; i < months.value.length; i++) {
|
7008 | const month = monthRefs.value[i];
|
7009 | const visible = height <= bottom && height + heights[i] >= top;
|
7010 | if (visible) {
|
7011 | visibleRange[1] = i;
|
7012 | if (!currentMonth) {
|
7013 | currentMonth = month;
|
7014 | visibleRange[0] = i;
|
7015 | }
|
7016 | if (!monthRefs.value[i].showed) {
|
7017 | monthRefs.value[i].showed = true;
|
7018 | emit("monthShow", {
|
7019 | date: month.date,
|
7020 | title: month.getTitle()
|
7021 | });
|
7022 | }
|
7023 | }
|
7024 | height += heights[i];
|
7025 | }
|
7026 | months.value.forEach((month, index) => {
|
7027 | const visible = index >= visibleRange[0] - 1 && index <= visibleRange[1] + 1;
|
7028 | monthRefs.value[index].setVisible(visible);
|
7029 | });
|
7030 | if (currentMonth) {
|
7031 | currentMonthRef.value = currentMonth;
|
7032 | }
|
7033 | };
|
7034 | const scrollToDate = (targetDate) => {
|
7035 | if (canSwitch.value) {
|
7036 | currentPanelDate.value = targetDate;
|
7037 | } else {
|
7038 | use.raf(() => {
|
7039 | months.value.some((month, index) => {
|
7040 | if (compareMonth(month, targetDate) === 0) {
|
7041 | if (bodyRef.value) {
|
7042 | monthRefs.value[index].scrollToDate(bodyRef.value, targetDate);
|
7043 | }
|
7044 | return true;
|
7045 | }
|
7046 | return false;
|
7047 | });
|
7048 | onScroll();
|
7049 | });
|
7050 | }
|
7051 | };
|
7052 | const scrollToCurrentDate = () => {
|
7053 | if (props2.poppable && !props2.show) {
|
7054 | return;
|
7055 | }
|
7056 | if (currentDate.value) {
|
7057 | const targetDate = props2.type === "single" ? currentDate.value : currentDate.value[0];
|
7058 | if (isDate(targetDate)) {
|
7059 | scrollToDate(targetDate);
|
7060 | }
|
7061 | } else if (!canSwitch.value) {
|
7062 | use.raf(onScroll);
|
7063 | }
|
7064 | };
|
7065 | const init = () => {
|
7066 | if (props2.poppable && !props2.show) {
|
7067 | return;
|
7068 | }
|
7069 | if (!canSwitch.value) {
|
7070 | use.raf(() => {
|
7071 | bodyHeight = Math.floor(use.useRect(bodyRef).height);
|
7072 | });
|
7073 | }
|
7074 | scrollToCurrentDate();
|
7075 | };
|
7076 | const reset = (date = getInitialDate()) => {
|
7077 | currentDate.value = date;
|
7078 | scrollToCurrentDate();
|
7079 | };
|
7080 | const checkRange = (date) => {
|
7081 | const {
|
7082 | maxRange,
|
7083 | rangePrompt,
|
7084 | showRangePrompt
|
7085 | } = props2;
|
7086 | if (maxRange && calcDateNum(date) > +maxRange) {
|
7087 | if (showRangePrompt) {
|
7088 | showToast(rangePrompt || t$g("rangePrompt", maxRange));
|
7089 | }
|
7090 | emit("overRange");
|
7091 | return false;
|
7092 | }
|
7093 | return true;
|
7094 | };
|
7095 | const onPanelChange = (date) => {
|
7096 | currentPanelDate.value = date;
|
7097 | emit("panelChange", {
|
7098 | date
|
7099 | });
|
7100 | };
|
7101 | const onConfirm = () => {
|
7102 | var _a;
|
7103 | return emit("confirm", (_a = currentDate.value) != null ? _a : cloneDates(currentDate.value));
|
7104 | };
|
7105 | const select = (date, complete) => {
|
7106 | const setCurrentDate = (date2) => {
|
7107 | currentDate.value = date2;
|
7108 | emit("select", cloneDates(date2));
|
7109 | };
|
7110 | if (complete && props2.type === "range") {
|
7111 | const valid = checkRange(date);
|
7112 | if (!valid) {
|
7113 | setCurrentDate([date[0], getDayByOffset(date[0], +props2.maxRange - 1)]);
|
7114 | return;
|
7115 | }
|
7116 | }
|
7117 | setCurrentDate(date);
|
7118 | if (complete && !props2.showConfirm) {
|
7119 | onConfirm();
|
7120 | }
|
7121 | };
|
7122 | const getDisabledDate = (disabledDays2, startDay, date) => {
|
7123 | var _a;
|
7124 | return (_a = disabledDays2.find((day) => compareDay(startDay, day.date) === -1 && compareDay(day.date, date) === -1)) == null ? void 0 : _a.date;
|
7125 | };
|
7126 | const disabledDays = vue.computed(() => monthRefs.value.reduce((arr, ref2) => {
|
7127 | var _a, _b;
|
7128 | arr.push(...(_b = (_a = ref2.disabledDays) == null ? void 0 : _a.value) != null ? _b : []);
|
7129 | return arr;
|
7130 | }, []));
|
7131 | const onClickDay = (item) => {
|
7132 | if (props2.readonly || !item.date) {
|
7133 | return;
|
7134 | }
|
7135 | const {
|
7136 | date
|
7137 | } = item;
|
7138 | const {
|
7139 | type
|
7140 | } = props2;
|
7141 | if (type === "range") {
|
7142 | if (!currentDate.value) {
|
7143 | select([date]);
|
7144 | return;
|
7145 | }
|
7146 | const [startDay, endDay] = currentDate.value;
|
7147 | if (startDay && !endDay) {
|
7148 | const compareToStart = compareDay(date, startDay);
|
7149 | if (compareToStart === 1) {
|
7150 | const disabledDay = getDisabledDate(disabledDays.value, startDay, date);
|
7151 | if (disabledDay) {
|
7152 | const endDay2 = getPrevDay(disabledDay);
|
7153 | if (compareDay(startDay, endDay2) === -1) {
|
7154 | select([startDay, endDay2]);
|
7155 | } else {
|
7156 | select([date]);
|
7157 | }
|
7158 | } else {
|
7159 | select([startDay, date], true);
|
7160 | }
|
7161 | } else if (compareToStart === -1) {
|
7162 | select([date]);
|
7163 | } else if (props2.allowSameDay) {
|
7164 | select([date, date], true);
|
7165 | }
|
7166 | } else {
|
7167 | select([date]);
|
7168 | }
|
7169 | } else if (type === "multiple") {
|
7170 | if (!currentDate.value) {
|
7171 | select([date]);
|
7172 | return;
|
7173 | }
|
7174 | const dates = currentDate.value;
|
7175 | const selectedIndex = dates.findIndex((dateItem) => compareDay(dateItem, date) === 0);
|
7176 | if (selectedIndex !== -1) {
|
7177 | const [unselectedDate] = dates.splice(selectedIndex, 1);
|
7178 | emit("unselect", cloneDate(unselectedDate));
|
7179 | } else if (props2.maxRange && dates.length >= +props2.maxRange) {
|
7180 | showToast(props2.rangePrompt || t$g("rangePrompt", props2.maxRange));
|
7181 | } else {
|
7182 | select([...dates, date]);
|
7183 | }
|
7184 | } else {
|
7185 | select(date, true);
|
7186 | }
|
7187 | };
|
7188 | const updateShow = (value) => emit("update:show", value);
|
7189 | const renderMonth = (date, index) => {
|
7190 | const showMonthTitle = index !== 0 || !props2.showSubtitle;
|
7191 | return vue.createVNode(stdin_default$1f, vue.mergeProps({
|
7192 | "ref": canSwitch.value ? currentMonthRef : setMonthRefs(index),
|
7193 | "date": date,
|
7194 | "currentDate": currentDate.value,
|
7195 | "showMonthTitle": showMonthTitle,
|
7196 | "firstDayOfWeek": dayOffset.value,
|
7197 | "lazyRender": canSwitch.value ? false : props2.lazyRender,
|
7198 | "maxDate": maxDate.value,
|
7199 | "minDate": minDate.value
|
7200 | }, pick(props2, ["type", "color", "showMark", "formatter", "rowHeight", "showSubtitle", "allowSameDay"]), {
|
7201 | "onClick": onClickDay,
|
7202 | "onClickDisabledDate": (item) => emit("clickDisabledDate", item)
|
7203 | }), pick(slots, ["top-info", "bottom-info", "month-title", "text"]));
|
7204 | };
|
7205 | const renderFooterButton = () => {
|
7206 | if (slots.footer) {
|
7207 | return slots.footer();
|
7208 | }
|
7209 | if (props2.showConfirm) {
|
7210 | const slot = slots["confirm-text"];
|
7211 | const disabled = buttonDisabled.value;
|
7212 | const text = disabled ? props2.confirmDisabledText : props2.confirmText;
|
7213 | return vue.createVNode(Button, {
|
7214 | "round": true,
|
7215 | "block": true,
|
7216 | "type": "primary",
|
7217 | "color": props2.color,
|
7218 | "class": bem$13("confirm"),
|
7219 | "disabled": disabled,
|
7220 | "nativeType": "button",
|
7221 | "onClick": onConfirm
|
7222 | }, {
|
7223 | default: () => [slot ? slot({
|
7224 | disabled
|
7225 | }) : text || t$g("confirm")]
|
7226 | });
|
7227 | }
|
7228 | };
|
7229 | const renderFooter = () => vue.createVNode("div", {
|
7230 | "class": [bem$13("footer"), {
|
7231 | "van-safe-area-bottom": props2.safeAreaInsetBottom
|
7232 | }]
|
7233 | }, [renderFooterButton()]);
|
7234 | const renderCalendar = () => {
|
7235 | var _a, _b;
|
7236 | return vue.createVNode("div", {
|
7237 | "class": bem$13()
|
7238 | }, [vue.createVNode(stdin_default$1e, {
|
7239 | "date": (_a = currentMonthRef.value) == null ? void 0 : _a.date,
|
7240 | "maxDate": maxDate.value,
|
7241 | "minDate": minDate.value,
|
7242 | "title": props2.title,
|
7243 | "subtitle": (_b = currentMonthRef.value) == null ? void 0 : _b.getTitle(),
|
7244 | "showTitle": props2.showTitle,
|
7245 | "showSubtitle": props2.showSubtitle,
|
7246 | "switchMode": props2.switchMode,
|
7247 | "firstDayOfWeek": dayOffset.value,
|
7248 | "onClickSubtitle": (event) => emit("clickSubtitle", event),
|
7249 | "onPanelChange": onPanelChange
|
7250 | }, pick(slots, ["title", "subtitle", "prev-month", "prev-year", "next-month", "next-year"])), vue.createVNode("div", {
|
7251 | "ref": bodyRef,
|
7252 | "class": bem$13("body"),
|
7253 | "onScroll": canSwitch.value ? void 0 : onScroll
|
7254 | }, [canSwitch.value ? renderMonth(currentPanelDate.value, 0) : months.value.map(renderMonth)]), renderFooter()]);
|
7255 | };
|
7256 | vue.watch(() => props2.show, init);
|
7257 | vue.watch(() => [props2.type, props2.minDate, props2.maxDate, props2.switchMode], () => reset(getInitialDate(currentDate.value)));
|
7258 | vue.watch(() => props2.defaultDate, (value) => {
|
7259 | reset(value);
|
7260 | });
|
7261 | useExpose({
|
7262 | reset,
|
7263 | scrollToDate,
|
7264 | getSelectedDate
|
7265 | });
|
7266 | use.onMountedOrActivated(init);
|
7267 | return () => {
|
7268 | if (props2.poppable) {
|
7269 | return vue.createVNode(Popup, {
|
7270 | "show": props2.show,
|
7271 | "class": bem$13("popup"),
|
7272 | "round": props2.round,
|
7273 | "position": props2.position,
|
7274 | "closeable": props2.showTitle || props2.showSubtitle,
|
7275 | "teleport": props2.teleport,
|
7276 | "closeOnPopstate": props2.closeOnPopstate,
|
7277 | "safeAreaInsetTop": props2.safeAreaInsetTop,
|
7278 | "closeOnClickOverlay": props2.closeOnClickOverlay,
|
7279 | "onUpdate:show": updateShow
|
7280 | }, {
|
7281 | default: renderCalendar
|
7282 | });
|
7283 | }
|
7284 | return renderCalendar();
|
7285 | };
|
7286 | }
|
7287 | });
|
7288 | const Calendar = withInstall(stdin_default$1d);
|
7289 | const [name$13, bem$12] = createNamespace("image");
|
7290 | const imageProps = {
|
7291 | src: String,
|
7292 | alt: String,
|
7293 | fit: String,
|
7294 | position: String,
|
7295 | round: Boolean,
|
7296 | block: Boolean,
|
7297 | width: numericProp,
|
7298 | height: numericProp,
|
7299 | radius: numericProp,
|
7300 | lazyLoad: Boolean,
|
7301 | iconSize: numericProp,
|
7302 | showError: truthProp,
|
7303 | errorIcon: makeStringProp("photo-fail"),
|
7304 | iconPrefix: String,
|
7305 | showLoading: truthProp,
|
7306 | loadingIcon: makeStringProp("photo"),
|
7307 | crossorigin: String,
|
7308 | referrerpolicy: String
|
7309 | };
|
7310 | var stdin_default$1c = vue.defineComponent({
|
7311 | name: name$13,
|
7312 | props: imageProps,
|
7313 | emits: ["load", "error"],
|
7314 | setup(props2, {
|
7315 | emit,
|
7316 | slots
|
7317 | }) {
|
7318 | const error = vue.ref(false);
|
7319 | const loading = vue.ref(true);
|
7320 | const imageRef = vue.ref();
|
7321 | const {
|
7322 | $Lazyload
|
7323 | } = vue.getCurrentInstance().proxy;
|
7324 | const style = vue.computed(() => {
|
7325 | const style2 = {
|
7326 | width: addUnit(props2.width),
|
7327 | height: addUnit(props2.height)
|
7328 | };
|
7329 | if (isDef(props2.radius)) {
|
7330 | style2.overflow = "hidden";
|
7331 | style2.borderRadius = addUnit(props2.radius);
|
7332 | }
|
7333 | return style2;
|
7334 | });
|
7335 | vue.watch(() => props2.src, () => {
|
7336 | error.value = false;
|
7337 | loading.value = true;
|
7338 | });
|
7339 | const onLoad = (event) => {
|
7340 | if (loading.value) {
|
7341 | loading.value = false;
|
7342 | emit("load", event);
|
7343 | }
|
7344 | };
|
7345 | const triggerLoad = () => {
|
7346 | const loadEvent = new Event("load");
|
7347 | Object.defineProperty(loadEvent, "target", {
|
7348 | value: imageRef.value,
|
7349 | enumerable: true
|
7350 | });
|
7351 | onLoad(loadEvent);
|
7352 | };
|
7353 | const onError = (event) => {
|
7354 | error.value = true;
|
7355 | loading.value = false;
|
7356 | emit("error", event);
|
7357 | };
|
7358 | const renderIcon = (name2, className, slot) => {
|
7359 | if (slot) {
|
7360 | return slot();
|
7361 | }
|
7362 | return vue.createVNode(Icon, {
|
7363 | "name": name2,
|
7364 | "size": props2.iconSize,
|
7365 | "class": className,
|
7366 | "classPrefix": props2.iconPrefix
|
7367 | }, null);
|
7368 | };
|
7369 | const renderPlaceholder = () => {
|
7370 | if (loading.value && props2.showLoading) {
|
7371 | return vue.createVNode("div", {
|
7372 | "class": bem$12("loading")
|
7373 | }, [renderIcon(props2.loadingIcon, bem$12("loading-icon"), slots.loading)]);
|
7374 | }
|
7375 | if (error.value && props2.showError) {
|
7376 | return vue.createVNode("div", {
|
7377 | "class": bem$12("error")
|
7378 | }, [renderIcon(props2.errorIcon, bem$12("error-icon"), slots.error)]);
|
7379 | }
|
7380 | };
|
7381 | const renderImage = () => {
|
7382 | if (error.value || !props2.src) {
|
7383 | return;
|
7384 | }
|
7385 | const attrs = {
|
7386 | alt: props2.alt,
|
7387 | class: bem$12("img"),
|
7388 | style: {
|
7389 | objectFit: props2.fit,
|
7390 | objectPosition: props2.position
|
7391 | },
|
7392 | crossorigin: props2.crossorigin,
|
7393 | referrerpolicy: props2.referrerpolicy
|
7394 | };
|
7395 | if (props2.lazyLoad) {
|
7396 | return vue.withDirectives(vue.createVNode("img", vue.mergeProps({
|
7397 | "ref": imageRef
|
7398 | }, attrs), null), [[vue.resolveDirective("lazy"), props2.src]]);
|
7399 | }
|
7400 | return vue.createVNode("img", vue.mergeProps({
|
7401 | "ref": imageRef,
|
7402 | "src": props2.src,
|
7403 | "onLoad": onLoad,
|
7404 | "onError": onError
|
7405 | }, attrs), null);
|
7406 | };
|
7407 | const onLazyLoaded = ({
|
7408 | el
|
7409 | }) => {
|
7410 | const check = () => {
|
7411 | if (el === imageRef.value && loading.value) {
|
7412 | triggerLoad();
|
7413 | }
|
7414 | };
|
7415 | if (imageRef.value) {
|
7416 | check();
|
7417 | } else {
|
7418 | vue.nextTick(check);
|
7419 | }
|
7420 | };
|
7421 | const onLazyLoadError = ({
|
7422 | el
|
7423 | }) => {
|
7424 | if (el === imageRef.value && !error.value) {
|
7425 | onError();
|
7426 | }
|
7427 | };
|
7428 | if ($Lazyload && inBrowser) {
|
7429 | $Lazyload.$on("loaded", onLazyLoaded);
|
7430 | $Lazyload.$on("error", onLazyLoadError);
|
7431 | vue.onBeforeUnmount(() => {
|
7432 | $Lazyload.$off("loaded", onLazyLoaded);
|
7433 | $Lazyload.$off("error", onLazyLoadError);
|
7434 | });
|
7435 | }
|
7436 | vue.onMounted(() => {
|
7437 | vue.nextTick(() => {
|
7438 | var _a;
|
7439 | if (((_a = imageRef.value) == null ? void 0 : _a.complete) && !props2.lazyLoad) {
|
7440 | triggerLoad();
|
7441 | }
|
7442 | });
|
7443 | });
|
7444 | return () => {
|
7445 | var _a;
|
7446 | return vue.createVNode("div", {
|
7447 | "class": bem$12({
|
7448 | round: props2.round,
|
7449 | block: props2.block
|
7450 | }),
|
7451 | "style": style.value
|
7452 | }, [renderImage(), renderPlaceholder(), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
7453 | };
|
7454 | }
|
7455 | });
|
7456 | const Image$1 = withInstall(stdin_default$1c);
|
7457 | const [name$12, bem$11] = createNamespace("card");
|
7458 | const cardProps = {
|
7459 | tag: String,
|
7460 | num: numericProp,
|
7461 | desc: String,
|
7462 | thumb: String,
|
7463 | title: String,
|
7464 | price: numericProp,
|
7465 | centered: Boolean,
|
7466 | lazyLoad: Boolean,
|
7467 | currency: makeStringProp("¥"),
|
7468 | thumbLink: String,
|
7469 | originPrice: numericProp
|
7470 | };
|
7471 | var stdin_default$1b = vue.defineComponent({
|
7472 | name: name$12,
|
7473 | props: cardProps,
|
7474 | emits: ["clickThumb"],
|
7475 | setup(props2, {
|
7476 | slots,
|
7477 | emit
|
7478 | }) {
|
7479 | const renderTitle = () => {
|
7480 | if (slots.title) {
|
7481 | return slots.title();
|
7482 | }
|
7483 | if (props2.title) {
|
7484 | return vue.createVNode("div", {
|
7485 | "class": [bem$11("title"), "van-multi-ellipsis--l2"]
|
7486 | }, [props2.title]);
|
7487 | }
|
7488 | };
|
7489 | const renderThumbTag = () => {
|
7490 | if (slots.tag || props2.tag) {
|
7491 | return vue.createVNode("div", {
|
7492 | "class": bem$11("tag")
|
7493 | }, [slots.tag ? slots.tag() : vue.createVNode(Tag, {
|
7494 | "mark": true,
|
7495 | "type": "primary"
|
7496 | }, {
|
7497 | default: () => [props2.tag]
|
7498 | })]);
|
7499 | }
|
7500 | };
|
7501 | const renderThumbImage = () => {
|
7502 | if (slots.thumb) {
|
7503 | return slots.thumb();
|
7504 | }
|
7505 | return vue.createVNode(Image$1, {
|
7506 | "src": props2.thumb,
|
7507 | "fit": "cover",
|
7508 | "width": "100%",
|
7509 | "height": "100%",
|
7510 | "lazyLoad": props2.lazyLoad
|
7511 | }, null);
|
7512 | };
|
7513 | const renderThumb = () => {
|
7514 | if (slots.thumb || props2.thumb) {
|
7515 | return vue.createVNode("a", {
|
7516 | "href": props2.thumbLink,
|
7517 | "class": bem$11("thumb"),
|
7518 | "onClick": (event) => emit("clickThumb", event)
|
7519 | }, [renderThumbImage(), renderThumbTag()]);
|
7520 | }
|
7521 | };
|
7522 | const renderDesc = () => {
|
7523 | if (slots.desc) {
|
7524 | return slots.desc();
|
7525 | }
|
7526 | if (props2.desc) {
|
7527 | return vue.createVNode("div", {
|
7528 | "class": [bem$11("desc"), "van-ellipsis"]
|
7529 | }, [props2.desc]);
|
7530 | }
|
7531 | };
|
7532 | const renderPriceText = () => {
|
7533 | const priceArr = props2.price.toString().split(".");
|
7534 | return vue.createVNode("div", null, [vue.createVNode("span", {
|
7535 | "class": bem$11("price-currency")
|
7536 | }, [props2.currency]), vue.createVNode("span", {
|
7537 | "class": bem$11("price-integer")
|
7538 | }, [priceArr[0]]), priceArr.length > 1 && vue.createVNode(vue.Fragment, null, [vue.createTextVNode("."), vue.createVNode("span", {
|
7539 | "class": bem$11("price-decimal")
|
7540 | }, [priceArr[1]])])]);
|
7541 | };
|
7542 | return () => {
|
7543 | var _a, _b, _c;
|
7544 | const showNum = slots.num || isDef(props2.num);
|
7545 | const showPrice = slots.price || isDef(props2.price);
|
7546 | const showOriginPrice = slots["origin-price"] || isDef(props2.originPrice);
|
7547 | const showBottom = showNum || showPrice || showOriginPrice || slots.bottom;
|
7548 | const Price = showPrice && vue.createVNode("div", {
|
7549 | "class": bem$11("price")
|
7550 | }, [slots.price ? slots.price() : renderPriceText()]);
|
7551 | const OriginPrice = showOriginPrice && vue.createVNode("div", {
|
7552 | "class": bem$11("origin-price")
|
7553 | }, [slots["origin-price"] ? slots["origin-price"]() : `${props2.currency} ${props2.originPrice}`]);
|
7554 | const Num = showNum && vue.createVNode("div", {
|
7555 | "class": bem$11("num")
|
7556 | }, [slots.num ? slots.num() : `x${props2.num}`]);
|
7557 | const Footer = slots.footer && vue.createVNode("div", {
|
7558 | "class": bem$11("footer")
|
7559 | }, [slots.footer()]);
|
7560 | const Bottom = showBottom && vue.createVNode("div", {
|
7561 | "class": bem$11("bottom")
|
7562 | }, [(_a = slots["price-top"]) == null ? void 0 : _a.call(slots), Price, OriginPrice, Num, (_b = slots.bottom) == null ? void 0 : _b.call(slots)]);
|
7563 | return vue.createVNode("div", {
|
7564 | "class": bem$11()
|
7565 | }, [vue.createVNode("div", {
|
7566 | "class": bem$11("header")
|
7567 | }, [renderThumb(), vue.createVNode("div", {
|
7568 | "class": bem$11("content", {
|
7569 | centered: props2.centered
|
7570 | })
|
7571 | }, [vue.createVNode("div", null, [renderTitle(), renderDesc(), (_c = slots.tags) == null ? void 0 : _c.call(slots)]), Bottom])]), Footer]);
|
7572 | };
|
7573 | }
|
7574 | });
|
7575 | const Card = withInstall(stdin_default$1b);
|
7576 | const [name$11, bem$10, t$f] = createNamespace("cascader");
|
7577 | const cascaderProps = {
|
7578 | title: String,
|
7579 | options: makeArrayProp(),
|
7580 | closeable: truthProp,
|
7581 | swipeable: truthProp,
|
7582 | closeIcon: makeStringProp("cross"),
|
7583 | showHeader: truthProp,
|
7584 | modelValue: numericProp,
|
7585 | fieldNames: Object,
|
7586 | placeholder: String,
|
7587 | activeColor: String
|
7588 | };
|
7589 | var stdin_default$1a = vue.defineComponent({
|
7590 | name: name$11,
|
7591 | props: cascaderProps,
|
7592 | emits: ["close", "change", "finish", "clickTab", "update:modelValue"],
|
7593 | setup(props2, {
|
7594 | slots,
|
7595 | emit
|
7596 | }) {
|
7597 | const tabs = vue.ref([]);
|
7598 | const activeTab = vue.ref(0);
|
7599 | const [selectedElementRefs, setSelectedElementRefs] = useRefs();
|
7600 | const {
|
7601 | text: textKey,
|
7602 | value: valueKey,
|
7603 | children: childrenKey
|
7604 | } = extend({
|
7605 | text: "text",
|
7606 | value: "value",
|
7607 | children: "children"
|
7608 | }, props2.fieldNames);
|
7609 | const getSelectedOptionsByValue = (options, value) => {
|
7610 | for (const option of options) {
|
7611 | if (option[valueKey] === value) {
|
7612 | return [option];
|
7613 | }
|
7614 | if (option[childrenKey]) {
|
7615 | const selectedOptions = getSelectedOptionsByValue(option[childrenKey], value);
|
7616 | if (selectedOptions) {
|
7617 | return [option, ...selectedOptions];
|
7618 | }
|
7619 | }
|
7620 | }
|
7621 | };
|
7622 | const updateTabs = () => {
|
7623 | const {
|
7624 | options,
|
7625 | modelValue
|
7626 | } = props2;
|
7627 | if (modelValue !== void 0) {
|
7628 | const selectedOptions = getSelectedOptionsByValue(options, modelValue);
|
7629 | if (selectedOptions) {
|
7630 | let optionsCursor = options;
|
7631 | tabs.value = selectedOptions.map((option) => {
|
7632 | const tab = {
|
7633 | options: optionsCursor,
|
7634 | selected: option
|
7635 | };
|
7636 | const next = optionsCursor.find((item) => item[valueKey] === option[valueKey]);
|
7637 | if (next) {
|
7638 | optionsCursor = next[childrenKey];
|
7639 | }
|
7640 | return tab;
|
7641 | });
|
7642 | if (optionsCursor) {
|
7643 | tabs.value.push({
|
7644 | options: optionsCursor,
|
7645 | selected: null
|
7646 | });
|
7647 | }
|
7648 | vue.nextTick(() => {
|
7649 | activeTab.value = tabs.value.length - 1;
|
7650 | });
|
7651 | return;
|
7652 | }
|
7653 | }
|
7654 | tabs.value = [{
|
7655 | options,
|
7656 | selected: null
|
7657 | }];
|
7658 | };
|
7659 | const onSelect = (option, tabIndex) => {
|
7660 | if (option.disabled) {
|
7661 | return;
|
7662 | }
|
7663 | tabs.value[tabIndex].selected = option;
|
7664 | if (tabs.value.length > tabIndex + 1) {
|
7665 | tabs.value = tabs.value.slice(0, tabIndex + 1);
|
7666 | }
|
7667 | if (option[childrenKey]) {
|
7668 | const nextTab = {
|
7669 | options: option[childrenKey],
|
7670 | selected: null
|
7671 | };
|
7672 | if (tabs.value[tabIndex + 1]) {
|
7673 | tabs.value[tabIndex + 1] = nextTab;
|
7674 | } else {
|
7675 | tabs.value.push(nextTab);
|
7676 | }
|
7677 | vue.nextTick(() => {
|
7678 | activeTab.value++;
|
7679 | });
|
7680 | }
|
7681 | const selectedOptions = tabs.value.map((tab) => tab.selected).filter(Boolean);
|
7682 | emit("update:modelValue", option[valueKey]);
|
7683 | const params = {
|
7684 | value: option[valueKey],
|
7685 | tabIndex,
|
7686 | selectedOptions
|
7687 | };
|
7688 | emit("change", params);
|
7689 | if (!option[childrenKey]) {
|
7690 | emit("finish", params);
|
7691 | }
|
7692 | };
|
7693 | const onClose = () => emit("close");
|
7694 | const onClickTab = ({
|
7695 | name: name2,
|
7696 | title
|
7697 | }) => emit("clickTab", name2, title);
|
7698 | const renderHeader = () => props2.showHeader ? vue.createVNode("div", {
|
7699 | "class": bem$10("header")
|
7700 | }, [vue.createVNode("h2", {
|
7701 | "class": bem$10("title")
|
7702 | }, [slots.title ? slots.title() : props2.title]), props2.closeable ? vue.createVNode(Icon, {
|
7703 | "name": props2.closeIcon,
|
7704 | "class": [bem$10("close-icon"), HAPTICS_FEEDBACK],
|
7705 | "onClick": onClose
|
7706 | }, null) : null]) : null;
|
7707 | const renderOption = (option, selectedOption, tabIndex) => {
|
7708 | const {
|
7709 | disabled
|
7710 | } = option;
|
7711 | const selected = !!(selectedOption && option[valueKey] === selectedOption[valueKey]);
|
7712 | const color = option.color || (selected ? props2.activeColor : void 0);
|
7713 | const Text = slots.option ? slots.option({
|
7714 | option,
|
7715 | selected
|
7716 | }) : vue.createVNode("span", null, [option[textKey]]);
|
7717 | return vue.createVNode("li", {
|
7718 | "ref": selected ? setSelectedElementRefs(tabIndex) : void 0,
|
7719 | "role": "menuitemradio",
|
7720 | "class": [bem$10("option", {
|
7721 | selected,
|
7722 | disabled
|
7723 | }), option.className],
|
7724 | "style": {
|
7725 | color
|
7726 | },
|
7727 | "tabindex": disabled ? void 0 : selected ? 0 : -1,
|
7728 | "aria-checked": selected,
|
7729 | "aria-disabled": disabled || void 0,
|
7730 | "onClick": () => onSelect(option, tabIndex)
|
7731 | }, [Text, selected ? vue.createVNode(Icon, {
|
7732 | "name": "success",
|
7733 | "class": bem$10("selected-icon")
|
7734 | }, null) : null]);
|
7735 | };
|
7736 | const renderOptions = (options, selectedOption, tabIndex) => vue.createVNode("ul", {
|
7737 | "role": "menu",
|
7738 | "class": bem$10("options")
|
7739 | }, [options.map((option) => renderOption(option, selectedOption, tabIndex))]);
|
7740 | const renderTab = (tab, tabIndex) => {
|
7741 | const {
|
7742 | options,
|
7743 | selected
|
7744 | } = tab;
|
7745 | const placeholder = props2.placeholder || t$f("select");
|
7746 | const title = selected ? selected[textKey] : placeholder;
|
7747 | return vue.createVNode(Tab, {
|
7748 | "title": title,
|
7749 | "titleClass": bem$10("tab", {
|
7750 | unselected: !selected
|
7751 | })
|
7752 | }, {
|
7753 | default: () => {
|
7754 | var _a, _b;
|
7755 | return [(_a = slots["options-top"]) == null ? void 0 : _a.call(slots, {
|
7756 | tabIndex
|
7757 | }), renderOptions(options, selected, tabIndex), (_b = slots["options-bottom"]) == null ? void 0 : _b.call(slots, {
|
7758 | tabIndex
|
7759 | })];
|
7760 | }
|
7761 | });
|
7762 | };
|
7763 | const renderTabs = () => vue.createVNode(Tabs, {
|
7764 | "active": activeTab.value,
|
7765 | "onUpdate:active": ($event) => activeTab.value = $event,
|
7766 | "shrink": true,
|
7767 | "animated": true,
|
7768 | "class": bem$10("tabs"),
|
7769 | "color": props2.activeColor,
|
7770 | "swipeable": props2.swipeable,
|
7771 | "onClickTab": onClickTab
|
7772 | }, {
|
7773 | default: () => [tabs.value.map(renderTab)]
|
7774 | });
|
7775 | const scrollIntoView = (el) => {
|
7776 | const scrollParent = el.parentElement;
|
7777 | if (scrollParent) {
|
7778 | scrollParent.scrollTop = el.offsetTop - (scrollParent.offsetHeight - el.offsetHeight) / 2;
|
7779 | }
|
7780 | };
|
7781 | updateTabs();
|
7782 | vue.watch(activeTab, (value) => {
|
7783 | const el = selectedElementRefs.value[value];
|
7784 | if (el) scrollIntoView(el);
|
7785 | });
|
7786 | vue.watch(() => props2.options, updateTabs, {
|
7787 | deep: true
|
7788 | });
|
7789 | vue.watch(() => props2.modelValue, (value) => {
|
7790 | if (value !== void 0) {
|
7791 | const values = tabs.value.map((tab) => {
|
7792 | var _a;
|
7793 | return (_a = tab.selected) == null ? void 0 : _a[valueKey];
|
7794 | });
|
7795 | if (values.includes(value)) {
|
7796 | return;
|
7797 | }
|
7798 | }
|
7799 | updateTabs();
|
7800 | });
|
7801 | return () => vue.createVNode("div", {
|
7802 | "class": bem$10()
|
7803 | }, [renderHeader(), renderTabs()]);
|
7804 | }
|
7805 | });
|
7806 | const Cascader = withInstall(stdin_default$1a);
|
7807 | const [name$10, bem$$] = createNamespace("cell-group");
|
7808 | const cellGroupProps = {
|
7809 | title: String,
|
7810 | inset: Boolean,
|
7811 | border: truthProp
|
7812 | };
|
7813 | var stdin_default$19 = vue.defineComponent({
|
7814 | name: name$10,
|
7815 | inheritAttrs: false,
|
7816 | props: cellGroupProps,
|
7817 | setup(props2, {
|
7818 | slots,
|
7819 | attrs
|
7820 | }) {
|
7821 | const renderGroup = () => {
|
7822 | var _a;
|
7823 | return vue.createVNode("div", vue.mergeProps({
|
7824 | "class": [bem$$({
|
7825 | inset: props2.inset
|
7826 | }), {
|
7827 | [BORDER_TOP_BOTTOM]: props2.border && !props2.inset
|
7828 | }]
|
7829 | }, attrs, useScopeId()), [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
7830 | };
|
7831 | const renderTitle = () => vue.createVNode("div", {
|
7832 | "class": bem$$("title", {
|
7833 | inset: props2.inset
|
7834 | })
|
7835 | }, [slots.title ? slots.title() : props2.title]);
|
7836 | return () => {
|
7837 | if (props2.title || slots.title) {
|
7838 | return vue.createVNode(vue.Fragment, null, [renderTitle(), renderGroup()]);
|
7839 | }
|
7840 | return renderGroup();
|
7841 | };
|
7842 | }
|
7843 | });
|
7844 | const CellGroup = withInstall(stdin_default$19);
|
7845 | const [name$$, bem$_] = createNamespace("circle");
|
7846 | let uid = 0;
|
7847 | const format = (rate) => Math.min(Math.max(+rate, 0), 100);
|
7848 | function getPath(clockwise, viewBoxSize) {
|
7849 | const sweepFlag = clockwise ? 1 : 0;
|
7850 | 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`;
|
7851 | }
|
7852 | const circleProps = {
|
7853 | text: String,
|
7854 | size: numericProp,
|
7855 | fill: makeStringProp("none"),
|
7856 | rate: makeNumericProp(100),
|
7857 | speed: makeNumericProp(0),
|
7858 | color: [String, Object],
|
7859 | clockwise: truthProp,
|
7860 | layerColor: String,
|
7861 | currentRate: makeNumberProp(0),
|
7862 | strokeWidth: makeNumericProp(40),
|
7863 | strokeLinecap: String,
|
7864 | startPosition: makeStringProp("top")
|
7865 | };
|
7866 | var stdin_default$18 = vue.defineComponent({
|
7867 | name: name$$,
|
7868 | props: circleProps,
|
7869 | emits: ["update:currentRate"],
|
7870 | setup(props2, {
|
7871 | emit,
|
7872 | slots
|
7873 | }) {
|
7874 | const id = `van-circle-${uid++}`;
|
7875 | const viewBoxSize = vue.computed(() => +props2.strokeWidth + 1e3);
|
7876 | const path = vue.computed(() => getPath(props2.clockwise, viewBoxSize.value));
|
7877 | const svgStyle = vue.computed(() => {
|
7878 | const ROTATE_ANGLE_MAP = {
|
7879 | top: 0,
|
7880 | right: 90,
|
7881 | bottom: 180,
|
7882 | left: 270
|
7883 | };
|
7884 | const angleValue = ROTATE_ANGLE_MAP[props2.startPosition];
|
7885 | if (angleValue) {
|
7886 | return {
|
7887 | transform: `rotate(${angleValue}deg)`
|
7888 | };
|
7889 | }
|
7890 | });
|
7891 | vue.watch(() => props2.rate, (rate) => {
|
7892 | let rafId;
|
7893 | const startTime = Date.now();
|
7894 | const startRate = props2.currentRate;
|
7895 | const endRate = format(rate);
|
7896 | const duration = Math.abs((startRate - endRate) * 1e3 / +props2.speed);
|
7897 | const animate = () => {
|
7898 | const now = Date.now();
|
7899 | const progress = Math.min((now - startTime) / duration, 1);
|
7900 | const rate2 = progress * (endRate - startRate) + startRate;
|
7901 | emit("update:currentRate", format(parseFloat(rate2.toFixed(1))));
|
7902 | if (endRate > startRate ? rate2 < endRate : rate2 > endRate) {
|
7903 | rafId = use.raf(animate);
|
7904 | }
|
7905 | };
|
7906 | if (props2.speed) {
|
7907 | if (rafId) {
|
7908 | use.cancelRaf(rafId);
|
7909 | }
|
7910 | rafId = use.raf(animate);
|
7911 | } else {
|
7912 | emit("update:currentRate", endRate);
|
7913 | }
|
7914 | }, {
|
7915 | immediate: true
|
7916 | });
|
7917 | const renderHover = () => {
|
7918 | const PERIMETER = 3140;
|
7919 | const {
|
7920 | strokeWidth,
|
7921 | currentRate,
|
7922 | strokeLinecap
|
7923 | } = props2;
|
7924 | const offset = PERIMETER * currentRate / 100;
|
7925 | const color = isObject(props2.color) ? `url(#${id})` : props2.color;
|
7926 | const style = {
|
7927 | stroke: color,
|
7928 | strokeWidth: `${+strokeWidth + 1}px`,
|
7929 | strokeLinecap,
|
7930 | strokeDasharray: `${offset}px ${PERIMETER}px`
|
7931 | };
|
7932 | return vue.createVNode("path", {
|
7933 | "d": path.value,
|
7934 | "style": style,
|
7935 | "class": bem$_("hover"),
|
7936 | "stroke": color
|
7937 | }, null);
|
7938 | };
|
7939 | const renderLayer = () => {
|
7940 | const style = {
|
7941 | fill: props2.fill,
|
7942 | stroke: props2.layerColor,
|
7943 | strokeWidth: `${props2.strokeWidth}px`
|
7944 | };
|
7945 | return vue.createVNode("path", {
|
7946 | "class": bem$_("layer"),
|
7947 | "style": style,
|
7948 | "d": path.value
|
7949 | }, null);
|
7950 | };
|
7951 | const renderGradient = () => {
|
7952 | const {
|
7953 | color
|
7954 | } = props2;
|
7955 | if (!isObject(color)) {
|
7956 | return;
|
7957 | }
|
7958 | const Stops = Object.keys(color).sort((a, b) => parseFloat(a) - parseFloat(b)).map((key, index) => vue.createVNode("stop", {
|
7959 | "key": index,
|
7960 | "offset": key,
|
7961 | "stop-color": color[key]
|
7962 | }, null));
|
7963 | return vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
|
7964 | "id": id,
|
7965 | "x1": "100%",
|
7966 | "y1": "0%",
|
7967 | "x2": "0%",
|
7968 | "y2": "0%"
|
7969 | }, [Stops])]);
|
7970 | };
|
7971 | const renderText = () => {
|
7972 | if (slots.default) {
|
7973 | return slots.default();
|
7974 | }
|
7975 | if (props2.text) {
|
7976 | return vue.createVNode("div", {
|
7977 | "class": bem$_("text")
|
7978 | }, [props2.text]);
|
7979 | }
|
7980 | };
|
7981 | return () => vue.createVNode("div", {
|
7982 | "class": bem$_(),
|
7983 | "style": getSizeStyle(props2.size)
|
7984 | }, [vue.createVNode("svg", {
|
7985 | "viewBox": `0 0 ${viewBoxSize.value} ${viewBoxSize.value}`,
|
7986 | "style": svgStyle.value
|
7987 | }, [renderGradient(), renderLayer(), renderHover()]), renderText()]);
|
7988 | }
|
7989 | });
|
7990 | const Circle = withInstall(stdin_default$18);
|
7991 | const [name$_, bem$Z] = createNamespace("row");
|
7992 | const ROW_KEY = Symbol(name$_);
|
7993 | const rowProps = {
|
7994 | tag: makeStringProp("div"),
|
7995 | wrap: truthProp,
|
7996 | align: String,
|
7997 | gutter: {
|
7998 | type: [String, Number, Array],
|
7999 | default: 0
|
8000 | },
|
8001 | justify: String
|
8002 | };
|
8003 | var stdin_default$17 = vue.defineComponent({
|
8004 | name: name$_,
|
8005 | props: rowProps,
|
8006 | setup(props2, {
|
8007 | slots
|
8008 | }) {
|
8009 | const {
|
8010 | children,
|
8011 | linkChildren
|
8012 | } = use.useChildren(ROW_KEY);
|
8013 | const groups = vue.computed(() => {
|
8014 | const groups2 = [[]];
|
8015 | let totalSpan = 0;
|
8016 | children.forEach((child, index) => {
|
8017 | totalSpan += Number(child.span);
|
8018 | if (totalSpan > 24) {
|
8019 | groups2.push([index]);
|
8020 | totalSpan -= 24;
|
8021 | } else {
|
8022 | groups2[groups2.length - 1].push(index);
|
8023 | }
|
8024 | });
|
8025 | return groups2;
|
8026 | });
|
8027 | const spaces = vue.computed(() => {
|
8028 | let gutter = 0;
|
8029 | if (Array.isArray(props2.gutter)) {
|
8030 | gutter = Number(props2.gutter[0]) || 0;
|
8031 | } else {
|
8032 | gutter = Number(props2.gutter);
|
8033 | }
|
8034 | const spaces2 = [];
|
8035 | if (!gutter) {
|
8036 | return spaces2;
|
8037 | }
|
8038 | groups.value.forEach((group) => {
|
8039 | const averagePadding = gutter * (group.length - 1) / group.length;
|
8040 | group.forEach((item, index) => {
|
8041 | if (index === 0) {
|
8042 | spaces2.push({
|
8043 | right: averagePadding
|
8044 | });
|
8045 | } else {
|
8046 | const left = gutter - spaces2[item - 1].right;
|
8047 | const right = averagePadding - left;
|
8048 | spaces2.push({
|
8049 | left,
|
8050 | right
|
8051 | });
|
8052 | }
|
8053 | });
|
8054 | });
|
8055 | return spaces2;
|
8056 | });
|
8057 | const verticalSpaces = vue.computed(() => {
|
8058 | const {
|
8059 | gutter
|
8060 | } = props2;
|
8061 | const spaces2 = [];
|
8062 | if (Array.isArray(gutter) && gutter.length > 1) {
|
8063 | const bottom = Number(gutter[1]) || 0;
|
8064 | if (bottom <= 0) {
|
8065 | return spaces2;
|
8066 | }
|
8067 | groups.value.forEach((group, index) => {
|
8068 | if (index === groups.value.length - 1) return;
|
8069 | group.forEach(() => {
|
8070 | spaces2.push({
|
8071 | bottom
|
8072 | });
|
8073 | });
|
8074 | });
|
8075 | }
|
8076 | return spaces2;
|
8077 | });
|
8078 | linkChildren({
|
8079 | spaces,
|
8080 | verticalSpaces
|
8081 | });
|
8082 | return () => {
|
8083 | const {
|
8084 | tag,
|
8085 | wrap,
|
8086 | align,
|
8087 | justify
|
8088 | } = props2;
|
8089 | return vue.createVNode(tag, {
|
8090 | "class": bem$Z({
|
8091 | [`align-${align}`]: align,
|
8092 | [`justify-${justify}`]: justify,
|
8093 | nowrap: !wrap
|
8094 | })
|
8095 | }, {
|
8096 | default: () => {
|
8097 | var _a;
|
8098 | return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
|
8099 | }
|
8100 | });
|
8101 | };
|
8102 | }
|
8103 | });
|
8104 | const [name$Z, bem$Y] = createNamespace("col");
|
8105 | const colProps = {
|
8106 | tag: makeStringProp("div"),
|
8107 | span: makeNumericProp(0),
|
8108 | offset: numericProp
|
8109 | };
|
8110 | var stdin_default$16 = vue.defineComponent({
|
8111 | name: name$Z,
|
8112 | props: colProps,
|
8113 | setup(props2, {
|
8114 | slots
|
8115 | }) {
|
8116 | const {
|
8117 | parent,
|
8118 | index
|
8119 | } = use.useParent(ROW_KEY);
|
8120 | const style = vue.computed(() => {
|
8121 | if (!parent) {
|
8122 | return;
|
8123 | }
|
8124 | const {
|
8125 | spaces,
|
8126 | verticalSpaces
|
8127 | } = parent;
|
8128 | let styles = {};
|
8129 | if (spaces && spaces.value && spaces.value[index.value]) {
|
8130 | const {
|
8131 | left,
|
8132 | right
|
8133 | } = spaces.value[index.value];
|
8134 | styles = {
|
8135 | paddingLeft: left ? `${left}px` : null,
|
8136 | paddingRight: right ? `${right}px` : null
|
8137 | };
|
8138 | }
|
8139 | const {
|
8140 | bottom
|
8141 | } = verticalSpaces.value[index.value] || {};
|
8142 | return extend(styles, {
|
8143 | marginBottom: bottom ? `${bottom}px` : null
|
8144 | });
|
8145 | });
|
8146 | return () => {
|
8147 | const {
|
8148 | tag,
|
8149 | span,
|
8150 | offset
|
8151 | } = props2;
|
8152 | return vue.createVNode(tag, {
|
8153 | "style": style.value,
|
8154 | "class": bem$Y({
|
8155 | [span]: span,
|
8156 | [`offset-${offset}`]: offset
|
8157 | })
|
8158 | }, {
|
8159 | default: () => {
|
8160 | var _a;
|
8161 | return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
|
8162 | }
|
8163 | });
|
8164 | };
|
8165 | }
|
8166 | });
|
8167 | const Col = withInstall(stdin_default$16);
|
8168 | const [name$Y, bem$X] = createNamespace("collapse");
|
8169 | const COLLAPSE_KEY = Symbol(name$Y);
|
8170 | const collapseProps = {
|
8171 | border: truthProp,
|
8172 | accordion: Boolean,
|
8173 | modelValue: {
|
8174 | type: [String, Number, Array],
|
8175 | default: ""
|
8176 | }
|
8177 | };
|
8178 | function validateModelValue(modelValue, accordion) {
|
8179 | if (accordion && Array.isArray(modelValue)) {
|
8180 | console.error('[Vant] Collapse: "v-model" should not be Array in accordion mode');
|
8181 | return false;
|
8182 | }
|
8183 | if (!accordion && !Array.isArray(modelValue)) {
|
8184 | console.error('[Vant] Collapse: "v-model" should be Array in non-accordion mode');
|
8185 | return false;
|
8186 | }
|
8187 | return true;
|
8188 | }
|
8189 | var stdin_default$15 = vue.defineComponent({
|
8190 | name: name$Y,
|
8191 | props: collapseProps,
|
8192 | emits: ["change", "update:modelValue"],
|
8193 | setup(props2, {
|
8194 | emit,
|
8195 | slots
|
8196 | }) {
|
8197 | const {
|
8198 | linkChildren,
|
8199 | children
|
8200 | } = use.useChildren(COLLAPSE_KEY);
|
8201 | const updateName = (name2) => {
|
8202 | emit("change", name2);
|
8203 | emit("update:modelValue", name2);
|
8204 | };
|
8205 | const toggle = (name2, expanded) => {
|
8206 | const {
|
8207 | accordion,
|
8208 | modelValue
|
8209 | } = props2;
|
8210 | if (accordion) {
|
8211 | updateName(name2 === modelValue ? "" : name2);
|
8212 | } else if (expanded) {
|
8213 | updateName(modelValue.concat(name2));
|
8214 | } else {
|
8215 | updateName(modelValue.filter((activeName) => activeName !== name2));
|
8216 | }
|
8217 | };
|
8218 | const toggleAll = (options = {}) => {
|
8219 | if (props2.accordion) {
|
8220 | return;
|
8221 | }
|
8222 | if (typeof options === "boolean") {
|
8223 | options = {
|
8224 | expanded: options
|
8225 | };
|
8226 | }
|
8227 | const {
|
8228 | expanded,
|
8229 | skipDisabled
|
8230 | } = options;
|
8231 | const expandedChildren = children.filter((item) => {
|
8232 | if (item.disabled && skipDisabled) {
|
8233 | return item.expanded.value;
|
8234 | }
|
8235 | return expanded != null ? expanded : !item.expanded.value;
|
8236 | });
|
8237 | const names = expandedChildren.map((item) => item.itemName.value);
|
8238 | updateName(names);
|
8239 | };
|
8240 | const isExpanded = (name2) => {
|
8241 | const {
|
8242 | accordion,
|
8243 | modelValue
|
8244 | } = props2;
|
8245 | if (process.env.NODE_ENV !== "production" && !validateModelValue(modelValue, accordion)) {
|
8246 | return false;
|
8247 | }
|
8248 | return accordion ? modelValue === name2 : modelValue.includes(name2);
|
8249 | };
|
8250 | useExpose({
|
8251 | toggleAll
|
8252 | });
|
8253 | linkChildren({
|
8254 | toggle,
|
8255 | isExpanded
|
8256 | });
|
8257 | return () => {
|
8258 | var _a;
|
8259 | return vue.createVNode("div", {
|
8260 | "class": [bem$X(), {
|
8261 | [BORDER_TOP_BOTTOM]: props2.border
|
8262 | }]
|
8263 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
8264 | };
|
8265 | }
|
8266 | });
|
8267 | const Collapse = withInstall(stdin_default$15);
|
8268 | const [name$X, bem$W] = createNamespace("collapse-item");
|
8269 | const CELL_SLOTS = ["icon", "title", "value", "label", "right-icon"];
|
8270 | const collapseItemProps = extend({}, cellSharedProps, {
|
8271 | name: numericProp,
|
8272 | isLink: truthProp,
|
8273 | disabled: Boolean,
|
8274 | readonly: Boolean,
|
8275 | lazyRender: truthProp
|
8276 | });
|
8277 | var stdin_default$14 = vue.defineComponent({
|
8278 | name: name$X,
|
8279 | props: collapseItemProps,
|
8280 | setup(props2, {
|
8281 | slots
|
8282 | }) {
|
8283 | const wrapperRef = vue.ref();
|
8284 | const contentRef = vue.ref();
|
8285 | const {
|
8286 | parent,
|
8287 | index
|
8288 | } = use.useParent(COLLAPSE_KEY);
|
8289 | if (!parent) {
|
8290 | if (process.env.NODE_ENV !== "production") {
|
8291 | console.error("[Vant] <CollapseItem> must be a child component of <Collapse>.");
|
8292 | }
|
8293 | return;
|
8294 | }
|
8295 | const name2 = vue.computed(() => {
|
8296 | var _a;
|
8297 | return (_a = props2.name) != null ? _a : index.value;
|
8298 | });
|
8299 | const expanded = vue.computed(() => parent.isExpanded(name2.value));
|
8300 | const show = vue.ref(expanded.value);
|
8301 | const lazyRender = useLazyRender(() => show.value || !props2.lazyRender);
|
8302 | const onTransitionEnd = () => {
|
8303 | if (!expanded.value) {
|
8304 | show.value = false;
|
8305 | } else if (wrapperRef.value) {
|
8306 | wrapperRef.value.style.height = "";
|
8307 | }
|
8308 | };
|
8309 | vue.watch(expanded, (value, oldValue) => {
|
8310 | if (oldValue === null) {
|
8311 | return;
|
8312 | }
|
8313 | if (value) {
|
8314 | show.value = true;
|
8315 | }
|
8316 | const tick = value ? vue.nextTick : use.raf;
|
8317 | tick(() => {
|
8318 | if (!contentRef.value || !wrapperRef.value) {
|
8319 | return;
|
8320 | }
|
8321 | const {
|
8322 | offsetHeight
|
8323 | } = contentRef.value;
|
8324 | if (offsetHeight) {
|
8325 | const contentHeight = `${offsetHeight}px`;
|
8326 | wrapperRef.value.style.height = value ? "0" : contentHeight;
|
8327 | use.doubleRaf(() => {
|
8328 | if (wrapperRef.value) {
|
8329 | wrapperRef.value.style.height = value ? contentHeight : "0";
|
8330 | }
|
8331 | });
|
8332 | } else {
|
8333 | onTransitionEnd();
|
8334 | }
|
8335 | });
|
8336 | });
|
8337 | const toggle = (newValue = !expanded.value) => {
|
8338 | parent.toggle(name2.value, newValue);
|
8339 | };
|
8340 | const onClickTitle = () => {
|
8341 | if (!props2.disabled && !props2.readonly) {
|
8342 | toggle();
|
8343 | }
|
8344 | };
|
8345 | const renderTitle = () => {
|
8346 | const {
|
8347 | border,
|
8348 | disabled,
|
8349 | readonly
|
8350 | } = props2;
|
8351 | const attrs = pick(props2, Object.keys(cellSharedProps));
|
8352 | if (readonly) {
|
8353 | attrs.isLink = false;
|
8354 | }
|
8355 | if (disabled || readonly) {
|
8356 | attrs.clickable = false;
|
8357 | }
|
8358 | return vue.createVNode(Cell, vue.mergeProps({
|
8359 | "role": "button",
|
8360 | "class": bem$W("title", {
|
8361 | disabled,
|
8362 | expanded: expanded.value,
|
8363 | borderless: !border
|
8364 | }),
|
8365 | "aria-expanded": String(expanded.value),
|
8366 | "onClick": onClickTitle
|
8367 | }, attrs), pick(slots, CELL_SLOTS));
|
8368 | };
|
8369 | const renderContent = lazyRender(() => {
|
8370 | var _a;
|
8371 | return vue.withDirectives(vue.createVNode("div", {
|
8372 | "ref": wrapperRef,
|
8373 | "class": bem$W("wrapper"),
|
8374 | "onTransitionend": onTransitionEnd
|
8375 | }, [vue.createVNode("div", {
|
8376 | "ref": contentRef,
|
8377 | "class": bem$W("content")
|
8378 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]), [[vue.vShow, show.value]]);
|
8379 | });
|
8380 | useExpose({
|
8381 | toggle,
|
8382 | expanded,
|
8383 | itemName: name2
|
8384 | });
|
8385 | return () => vue.createVNode("div", {
|
8386 | "class": [bem$W({
|
8387 | border: index.value && props2.border
|
8388 | })]
|
8389 | }, [renderTitle(), renderContent()]);
|
8390 | }
|
8391 | });
|
8392 | const CollapseItem = withInstall(stdin_default$14);
|
8393 | const ConfigProvider = withInstall(stdin_default$1S);
|
8394 | const [name$W, bem$V, t$e] = createNamespace("contact-card");
|
8395 | const contactCardProps = {
|
8396 | tel: String,
|
8397 | name: String,
|
8398 | type: makeStringProp("add"),
|
8399 | addText: String,
|
8400 | editable: truthProp
|
8401 | };
|
8402 | var stdin_default$13 = vue.defineComponent({
|
8403 | name: name$W,
|
8404 | props: contactCardProps,
|
8405 | emits: ["click"],
|
8406 | setup(props2, {
|
8407 | emit
|
8408 | }) {
|
8409 | const onClick = (event) => {
|
8410 | if (props2.editable) {
|
8411 | emit("click", event);
|
8412 | }
|
8413 | };
|
8414 | const renderContent = () => {
|
8415 | if (props2.type === "add") {
|
8416 | return props2.addText || t$e("addContact");
|
8417 | }
|
8418 | return [vue.createVNode("div", null, [`${t$e("name")}:${props2.name}`]), vue.createVNode("div", null, [`${t$e("tel")}:${props2.tel}`])];
|
8419 | };
|
8420 | return () => vue.createVNode(Cell, {
|
8421 | "center": true,
|
8422 | "icon": props2.type === "edit" ? "contact" : "add-square",
|
8423 | "class": bem$V([props2.type]),
|
8424 | "border": false,
|
8425 | "isLink": props2.editable,
|
8426 | "titleClass": bem$V("title"),
|
8427 | "onClick": onClick
|
8428 | }, {
|
8429 | title: renderContent
|
8430 | });
|
8431 | }
|
8432 | });
|
8433 | const ContactCard = withInstall(stdin_default$13);
|
8434 | const [name$V, bem$U, t$d] = createNamespace("contact-edit");
|
8435 | const DEFAULT_CONTACT = {
|
8436 | tel: "",
|
8437 | name: ""
|
8438 | };
|
8439 | const contactEditProps = {
|
8440 | isEdit: Boolean,
|
8441 | isSaving: Boolean,
|
8442 | isDeleting: Boolean,
|
8443 | showSetDefault: Boolean,
|
8444 | setDefaultLabel: String,
|
8445 | contactInfo: {
|
8446 | type: Object,
|
8447 | default: () => extend({}, DEFAULT_CONTACT)
|
8448 | },
|
8449 | telValidator: {
|
8450 | type: Function,
|
8451 | default: isMobile
|
8452 | }
|
8453 | };
|
8454 | var stdin_default$12 = vue.defineComponent({
|
8455 | name: name$V,
|
8456 | props: contactEditProps,
|
8457 | emits: ["save", "delete", "changeDefault"],
|
8458 | setup(props2, {
|
8459 | emit
|
8460 | }) {
|
8461 | const contact = vue.reactive(extend({}, DEFAULT_CONTACT, props2.contactInfo));
|
8462 | const onSave = () => {
|
8463 | if (!props2.isSaving) {
|
8464 | emit("save", contact);
|
8465 | }
|
8466 | };
|
8467 | const onDelete = () => emit("delete", contact);
|
8468 | const renderButtons = () => vue.createVNode("div", {
|
8469 | "class": bem$U("buttons")
|
8470 | }, [vue.createVNode(Button, {
|
8471 | "block": true,
|
8472 | "round": true,
|
8473 | "type": "primary",
|
8474 | "text": t$d("save"),
|
8475 | "class": bem$U("button"),
|
8476 | "loading": props2.isSaving,
|
8477 | "nativeType": "submit"
|
8478 | }, null), props2.isEdit && vue.createVNode(Button, {
|
8479 | "block": true,
|
8480 | "round": true,
|
8481 | "text": t$d("delete"),
|
8482 | "class": bem$U("button"),
|
8483 | "loading": props2.isDeleting,
|
8484 | "onClick": onDelete
|
8485 | }, null)]);
|
8486 | const renderSwitch = () => vue.createVNode(Switch, {
|
8487 | "modelValue": contact.isDefault,
|
8488 | "onUpdate:modelValue": ($event) => contact.isDefault = $event,
|
8489 | "onChange": (checked) => emit("changeDefault", checked)
|
8490 | }, null);
|
8491 | const renderSetDefault = () => {
|
8492 | if (props2.showSetDefault) {
|
8493 | return vue.createVNode(Cell, {
|
8494 | "title": props2.setDefaultLabel,
|
8495 | "class": bem$U("switch-cell"),
|
8496 | "border": false
|
8497 | }, {
|
8498 | "right-icon": renderSwitch
|
8499 | });
|
8500 | }
|
8501 | };
|
8502 | vue.watch(() => props2.contactInfo, (value) => extend(contact, DEFAULT_CONTACT, value));
|
8503 | return () => vue.createVNode(Form, {
|
8504 | "class": bem$U(),
|
8505 | "onSubmit": onSave
|
8506 | }, {
|
8507 | default: () => [vue.createVNode("div", {
|
8508 | "class": bem$U("fields")
|
8509 | }, [vue.createVNode(Field, {
|
8510 | "modelValue": contact.name,
|
8511 | "onUpdate:modelValue": ($event) => contact.name = $event,
|
8512 | "clearable": true,
|
8513 | "label": t$d("name"),
|
8514 | "rules": [{
|
8515 | required: true,
|
8516 | message: t$d("nameEmpty")
|
8517 | }],
|
8518 | "maxlength": "30",
|
8519 | "placeholder": t$d("name")
|
8520 | }, null), vue.createVNode(Field, {
|
8521 | "modelValue": contact.tel,
|
8522 | "onUpdate:modelValue": ($event) => contact.tel = $event,
|
8523 | "clearable": true,
|
8524 | "type": "tel",
|
8525 | "label": t$d("tel"),
|
8526 | "rules": [{
|
8527 | validator: props2.telValidator,
|
8528 | message: t$d("telInvalid")
|
8529 | }],
|
8530 | "placeholder": t$d("tel")
|
8531 | }, null)]), renderSetDefault(), renderButtons()]
|
8532 | });
|
8533 | }
|
8534 | });
|
8535 | const ContactEdit = withInstall(stdin_default$12);
|
8536 | const [name$U, bem$T, t$c] = createNamespace("contact-list");
|
8537 | const contactListProps = {
|
8538 | list: Array,
|
8539 | addText: String,
|
8540 | modelValue: unknownProp,
|
8541 | defaultTagText: String
|
8542 | };
|
8543 | var stdin_default$11 = vue.defineComponent({
|
8544 | name: name$U,
|
8545 | props: contactListProps,
|
8546 | emits: ["add", "edit", "select", "update:modelValue"],
|
8547 | setup(props2, {
|
8548 | emit
|
8549 | }) {
|
8550 | const renderItem = (item, index) => {
|
8551 | const onClick = () => {
|
8552 | emit("update:modelValue", item.id);
|
8553 | emit("select", item, index);
|
8554 | };
|
8555 | const renderRightIcon = () => vue.createVNode(Radio, {
|
8556 | "class": bem$T("radio"),
|
8557 | "name": item.id,
|
8558 | "iconSize": 18
|
8559 | }, null);
|
8560 | const renderEditIcon = () => vue.createVNode(Icon, {
|
8561 | "name": "edit",
|
8562 | "class": bem$T("edit"),
|
8563 | "onClick": (event) => {
|
8564 | event.stopPropagation();
|
8565 | emit("edit", item, index);
|
8566 | }
|
8567 | }, null);
|
8568 | const renderContent = () => {
|
8569 | const nodes = [`${item.name},${item.tel}`];
|
8570 | if (item.isDefault && props2.defaultTagText) {
|
8571 | nodes.push(vue.createVNode(Tag, {
|
8572 | "type": "primary",
|
8573 | "round": true,
|
8574 | "class": bem$T("item-tag")
|
8575 | }, {
|
8576 | default: () => [props2.defaultTagText]
|
8577 | }));
|
8578 | }
|
8579 | return nodes;
|
8580 | };
|
8581 | return vue.createVNode(Cell, {
|
8582 | "key": item.id,
|
8583 | "isLink": true,
|
8584 | "center": true,
|
8585 | "class": bem$T("item"),
|
8586 | "titleClass": bem$T("item-title"),
|
8587 | "onClick": onClick
|
8588 | }, {
|
8589 | icon: renderEditIcon,
|
8590 | title: renderContent,
|
8591 | "right-icon": renderRightIcon
|
8592 | });
|
8593 | };
|
8594 | return () => vue.createVNode("div", {
|
8595 | "class": bem$T()
|
8596 | }, [vue.createVNode(RadioGroup, {
|
8597 | "modelValue": props2.modelValue,
|
8598 | "class": bem$T("group")
|
8599 | }, {
|
8600 | default: () => [props2.list && props2.list.map(renderItem)]
|
8601 | }), vue.createVNode("div", {
|
8602 | "class": [bem$T("bottom"), "van-safe-area-bottom"]
|
8603 | }, [vue.createVNode(Button, {
|
8604 | "round": true,
|
8605 | "block": true,
|
8606 | "type": "primary",
|
8607 | "class": bem$T("add"),
|
8608 | "text": props2.addText || t$c("addContact"),
|
8609 | "onClick": () => emit("add")
|
8610 | }, null)])]);
|
8611 | }
|
8612 | });
|
8613 | const ContactList = withInstall(stdin_default$11);
|
8614 | function parseFormat(format2, currentTime) {
|
8615 | const { days } = currentTime;
|
8616 | let { hours, minutes, seconds, milliseconds } = currentTime;
|
8617 | if (format2.includes("DD")) {
|
8618 | format2 = format2.replace("DD", padZero(days));
|
8619 | } else {
|
8620 | hours += days * 24;
|
8621 | }
|
8622 | if (format2.includes("HH")) {
|
8623 | format2 = format2.replace("HH", padZero(hours));
|
8624 | } else {
|
8625 | minutes += hours * 60;
|
8626 | }
|
8627 | if (format2.includes("mm")) {
|
8628 | format2 = format2.replace("mm", padZero(minutes));
|
8629 | } else {
|
8630 | seconds += minutes * 60;
|
8631 | }
|
8632 | if (format2.includes("ss")) {
|
8633 | format2 = format2.replace("ss", padZero(seconds));
|
8634 | } else {
|
8635 | milliseconds += seconds * 1e3;
|
8636 | }
|
8637 | if (format2.includes("S")) {
|
8638 | const ms = padZero(milliseconds, 3);
|
8639 | if (format2.includes("SSS")) {
|
8640 | format2 = format2.replace("SSS", ms);
|
8641 | } else if (format2.includes("SS")) {
|
8642 | format2 = format2.replace("SS", ms.slice(0, 2));
|
8643 | } else {
|
8644 | format2 = format2.replace("S", ms.charAt(0));
|
8645 | }
|
8646 | }
|
8647 | return format2;
|
8648 | }
|
8649 | const [name$T, bem$S] = createNamespace("count-down");
|
8650 | const countDownProps = {
|
8651 | time: makeNumericProp(0),
|
8652 | format: makeStringProp("HH:mm:ss"),
|
8653 | autoStart: truthProp,
|
8654 | millisecond: Boolean
|
8655 | };
|
8656 | var stdin_default$10 = vue.defineComponent({
|
8657 | name: name$T,
|
8658 | props: countDownProps,
|
8659 | emits: ["change", "finish"],
|
8660 | setup(props2, {
|
8661 | emit,
|
8662 | slots
|
8663 | }) {
|
8664 | const {
|
8665 | start,
|
8666 | pause,
|
8667 | reset,
|
8668 | current: current2
|
8669 | } = use.useCountDown({
|
8670 | time: +props2.time,
|
8671 | millisecond: props2.millisecond,
|
8672 | onChange: (current22) => emit("change", current22),
|
8673 | onFinish: () => emit("finish")
|
8674 | });
|
8675 | const timeText = vue.computed(() => parseFormat(props2.format, current2.value));
|
8676 | const resetTime = () => {
|
8677 | reset(+props2.time);
|
8678 | if (props2.autoStart) {
|
8679 | start();
|
8680 | }
|
8681 | };
|
8682 | vue.watch(() => props2.time, resetTime, {
|
8683 | immediate: true
|
8684 | });
|
8685 | useExpose({
|
8686 | start,
|
8687 | pause,
|
8688 | reset: resetTime
|
8689 | });
|
8690 | return () => vue.createVNode("div", {
|
8691 | "role": "timer",
|
8692 | "class": bem$S()
|
8693 | }, [slots.default ? slots.default(current2.value) : timeText.value]);
|
8694 | }
|
8695 | });
|
8696 | const CountDown = withInstall(stdin_default$10);
|
8697 | function getDate(timeStamp) {
|
8698 | const date = new Date(timeStamp * 1e3);
|
8699 | return `${date.getFullYear()}.${padZero(date.getMonth() + 1)}.${padZero(
|
8700 | date.getDate()
|
8701 | )}`;
|
8702 | }
|
8703 | const formatDiscount = (discount) => (discount / 10).toFixed(discount % 10 === 0 ? 0 : 1);
|
8704 | const formatAmount = (amount) => (amount / 100).toFixed(amount % 100 === 0 ? 0 : amount % 10 === 0 ? 1 : 2);
|
8705 | const [name$S, bem$R, t$b] = createNamespace("coupon");
|
8706 | var stdin_default$$ = vue.defineComponent({
|
8707 | name: name$S,
|
8708 | props: {
|
8709 | chosen: Boolean,
|
8710 | coupon: makeRequiredProp(Object),
|
8711 | disabled: Boolean,
|
8712 | currency: makeStringProp("¥")
|
8713 | },
|
8714 | setup(props2) {
|
8715 | const validPeriod = vue.computed(() => {
|
8716 | const {
|
8717 | startAt,
|
8718 | endAt
|
8719 | } = props2.coupon;
|
8720 | return `${getDate(startAt)} - ${getDate(endAt)}`;
|
8721 | });
|
8722 | const faceAmount = vue.computed(() => {
|
8723 | const {
|
8724 | coupon,
|
8725 | currency
|
8726 | } = props2;
|
8727 | if (coupon.valueDesc) {
|
8728 | return [coupon.valueDesc, vue.createVNode("span", null, [coupon.unitDesc || ""])];
|
8729 | }
|
8730 | if (coupon.denominations) {
|
8731 | const denominations = formatAmount(coupon.denominations);
|
8732 | return [vue.createVNode("span", null, [currency]), ` ${denominations}`];
|
8733 | }
|
8734 | if (coupon.discount) {
|
8735 | return t$b("discount", formatDiscount(coupon.discount));
|
8736 | }
|
8737 | return "";
|
8738 | });
|
8739 | const conditionMessage = vue.computed(() => {
|
8740 | const condition = formatAmount(props2.coupon.originCondition || 0);
|
8741 | return condition === "0" ? t$b("unlimited") : t$b("condition", condition);
|
8742 | });
|
8743 | return () => {
|
8744 | const {
|
8745 | chosen,
|
8746 | coupon,
|
8747 | disabled
|
8748 | } = props2;
|
8749 | const description = disabled && coupon.reason || coupon.description;
|
8750 | return vue.createVNode("div", {
|
8751 | "class": bem$R({
|
8752 | disabled
|
8753 | })
|
8754 | }, [vue.createVNode("div", {
|
8755 | "class": bem$R("content")
|
8756 | }, [vue.createVNode("div", {
|
8757 | "class": bem$R("head")
|
8758 | }, [vue.createVNode("h2", {
|
8759 | "class": bem$R("amount")
|
8760 | }, [faceAmount.value]), vue.createVNode("p", {
|
8761 | "class": bem$R("condition")
|
8762 | }, [coupon.condition || conditionMessage.value])]), vue.createVNode("div", {
|
8763 | "class": bem$R("body")
|
8764 | }, [vue.createVNode("p", {
|
8765 | "class": bem$R("name")
|
8766 | }, [coupon.name]), vue.createVNode("p", {
|
8767 | "class": bem$R("valid")
|
8768 | }, [validPeriod.value]), !disabled && vue.createVNode(Checkbox, {
|
8769 | "class": bem$R("corner"),
|
8770 | "modelValue": chosen
|
8771 | }, null)])]), description && vue.createVNode("p", {
|
8772 | "class": bem$R("description")
|
8773 | }, [description])]);
|
8774 | };
|
8775 | }
|
8776 | });
|
8777 | const Coupon = withInstall(stdin_default$$);
|
8778 | const [name$R, bem$Q, t$a] = createNamespace("coupon-cell");
|
8779 | const couponCellProps = {
|
8780 | title: String,
|
8781 | border: truthProp,
|
8782 | editable: truthProp,
|
8783 | coupons: makeArrayProp(),
|
8784 | currency: makeStringProp("¥"),
|
8785 | chosenCoupon: {
|
8786 | type: [Number, Array],
|
8787 | default: -1
|
8788 | }
|
8789 | };
|
8790 | const getValue = (coupon) => {
|
8791 | const {
|
8792 | value,
|
8793 | denominations
|
8794 | } = coupon;
|
8795 | if (isDef(value)) {
|
8796 | return value;
|
8797 | }
|
8798 | if (isDef(denominations)) {
|
8799 | return denominations;
|
8800 | }
|
8801 | return 0;
|
8802 | };
|
8803 | function formatValue({
|
8804 | coupons,
|
8805 | chosenCoupon,
|
8806 | currency
|
8807 | }) {
|
8808 | let value = 0;
|
8809 | let isExist = false;
|
8810 | (Array.isArray(chosenCoupon) ? chosenCoupon : [chosenCoupon]).forEach((i) => {
|
8811 | const coupon = coupons[+i];
|
8812 | if (coupon) {
|
8813 | isExist = true;
|
8814 | value += getValue(coupon);
|
8815 | }
|
8816 | });
|
8817 | if (isExist) {
|
8818 | return `-${currency} ${(value / 100).toFixed(2)}`;
|
8819 | }
|
8820 | return coupons.length === 0 ? t$a("noCoupon") : t$a("count", coupons.length);
|
8821 | }
|
8822 | var stdin_default$_ = vue.defineComponent({
|
8823 | name: name$R,
|
8824 | props: couponCellProps,
|
8825 | setup(props2) {
|
8826 | return () => {
|
8827 | const selected = Array.isArray(props2.chosenCoupon) ? props2.chosenCoupon.length : props2.coupons[+props2.chosenCoupon];
|
8828 | return vue.createVNode(Cell, {
|
8829 | "class": bem$Q(),
|
8830 | "value": formatValue(props2),
|
8831 | "title": props2.title || t$a("title"),
|
8832 | "border": props2.border,
|
8833 | "isLink": props2.editable,
|
8834 | "valueClass": bem$Q("value", {
|
8835 | selected
|
8836 | })
|
8837 | }, null);
|
8838 | };
|
8839 | }
|
8840 | });
|
8841 | const CouponCell = withInstall(stdin_default$_);
|
8842 | const [name$Q, bem$P] = createNamespace("empty");
|
8843 | const emptyProps = {
|
8844 | image: makeStringProp("default"),
|
8845 | imageSize: [Number, String, Array],
|
8846 | description: String
|
8847 | };
|
8848 | var stdin_default$Z = vue.defineComponent({
|
8849 | name: name$Q,
|
8850 | props: emptyProps,
|
8851 | setup(props2, {
|
8852 | slots
|
8853 | }) {
|
8854 | const renderDescription = () => {
|
8855 | const description = slots.description ? slots.description() : props2.description;
|
8856 | if (description) {
|
8857 | return vue.createVNode("p", {
|
8858 | "class": bem$P("description")
|
8859 | }, [description]);
|
8860 | }
|
8861 | };
|
8862 | const renderBottom = () => {
|
8863 | if (slots.default) {
|
8864 | return vue.createVNode("div", {
|
8865 | "class": bem$P("bottom")
|
8866 | }, [slots.default()]);
|
8867 | }
|
8868 | };
|
8869 | const baseId = useId();
|
8870 | const getId = (num) => `${baseId}-${num}`;
|
8871 | const getUrlById = (num) => `url(#${getId(num)})`;
|
8872 | const renderStop = (color, offset, opacity) => vue.createVNode("stop", {
|
8873 | "stop-color": color,
|
8874 | "offset": `${offset}%`,
|
8875 | "stop-opacity": opacity
|
8876 | }, null);
|
8877 | const renderStops = (fromColor, toColor) => [renderStop(fromColor, 0), renderStop(toColor, 100)];
|
8878 | const renderShadow = (id) => [vue.createVNode("defs", null, [vue.createVNode("radialGradient", {
|
8879 | "id": getId(id),
|
8880 | "cx": "50%",
|
8881 | "cy": "54%",
|
8882 | "fx": "50%",
|
8883 | "fy": "54%",
|
8884 | "r": "297%",
|
8885 | "gradientTransform": "matrix(-.16 0 0 -.33 .58 .72)",
|
8886 | "data-allow-mismatch": "attribute"
|
8887 | }, [renderStop("#EBEDF0", 0), renderStop("#F2F3F5", 100, 0.3)])]), vue.createVNode("ellipse", {
|
8888 | "fill": getUrlById(id),
|
8889 | "opacity": ".8",
|
8890 | "cx": "80",
|
8891 | "cy": "140",
|
8892 | "rx": "46",
|
8893 | "ry": "8",
|
8894 | "data-allow-mismatch": "attribute"
|
8895 | }, null)];
|
8896 | const renderBuilding = () => [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
|
8897 | "id": getId("a"),
|
8898 | "x1": "64%",
|
8899 | "y1": "100%",
|
8900 | "x2": "64%",
|
8901 | "data-allow-mismatch": "attribute"
|
8902 | }, [renderStop("#FFF", 0, 0.5), renderStop("#F2F3F5", 100)])]), vue.createVNode("g", {
|
8903 | "opacity": ".8",
|
8904 | "data-allow-mismatch": "children"
|
8905 | }, [vue.createVNode("path", {
|
8906 | "d": "M36 131V53H16v20H2v58h34z",
|
8907 | "fill": getUrlById("a")
|
8908 | }, null), vue.createVNode("path", {
|
8909 | "d": "M123 15h22v14h9v77h-31V15z",
|
8910 | "fill": getUrlById("a")
|
8911 | }, null)])];
|
8912 | const renderCloud = () => [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
|
8913 | "id": getId("b"),
|
8914 | "x1": "64%",
|
8915 | "y1": "97%",
|
8916 | "x2": "64%",
|
8917 | "y2": "0%",
|
8918 | "data-allow-mismatch": "attribute"
|
8919 | }, [renderStop("#F2F3F5", 0, 0.3), renderStop("#F2F3F5", 100)])]), vue.createVNode("g", {
|
8920 | "opacity": ".8",
|
8921 | "data-allow-mismatch": "children"
|
8922 | }, [vue.createVNode("path", {
|
8923 | "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",
|
8924 | "fill": getUrlById("b")
|
8925 | }, null), vue.createVNode("path", {
|
8926 | "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",
|
8927 | "fill": getUrlById("b")
|
8928 | }, null)])];
|
8929 | const renderNetwork = () => vue.createVNode("svg", {
|
8930 | "viewBox": "0 0 160 160"
|
8931 | }, [vue.createVNode("defs", {
|
8932 | "data-allow-mismatch": "children"
|
8933 | }, [vue.createVNode("linearGradient", {
|
8934 | "id": getId(1),
|
8935 | "x1": "64%",
|
8936 | "y1": "100%",
|
8937 | "x2": "64%"
|
8938 | }, [renderStop("#FFF", 0, 0.5), renderStop("#F2F3F5", 100)]), vue.createVNode("linearGradient", {
|
8939 | "id": getId(2),
|
8940 | "x1": "50%",
|
8941 | "x2": "50%",
|
8942 | "y2": "84%"
|
8943 | }, [renderStop("#EBEDF0", 0), renderStop("#DCDEE0", 100, 0)]), vue.createVNode("linearGradient", {
|
8944 | "id": getId(3),
|
8945 | "x1": "100%",
|
8946 | "x2": "100%",
|
8947 | "y2": "100%"
|
8948 | }, [renderStops("#EAEDF0", "#DCDEE0")]), vue.createVNode("radialGradient", {
|
8949 | "id": getId(4),
|
8950 | "cx": "50%",
|
8951 | "cy": "0%",
|
8952 | "fx": "50%",
|
8953 | "fy": "0%",
|
8954 | "r": "100%",
|
8955 | "gradientTransform": "matrix(0 1 -.54 0 .5 -.5)"
|
8956 | }, [renderStop("#EBEDF0", 0), renderStop("#FFF", 100, 0)])]), vue.createVNode("g", {
|
8957 | "fill": "none"
|
8958 | }, [renderBuilding(), vue.createVNode("path", {
|
8959 | "fill": getUrlById(4),
|
8960 | "d": "M0 139h160v21H0z",
|
8961 | "data-allow-mismatch": "attribute"
|
8962 | }, null), vue.createVNode("path", {
|
8963 | "d": "M80 54a7 7 0 0 1 3 13v27l-2 2h-2a2 2 0 0 1-2-2V67a7 7 0 0 1 3-13z",
|
8964 | "fill": getUrlById(2),
|
8965 | "data-allow-mismatch": "attribute"
|
8966 | }, null), vue.createVNode("g", {
|
8967 | "opacity": ".6",
|
8968 | "stroke-linecap": "round",
|
8969 | "stroke-width": "7",
|
8970 | "data-allow-mismatch": "children"
|
8971 | }, [vue.createVNode("path", {
|
8972 | "d": "M64 47a19 19 0 0 0-5 13c0 5 2 10 5 13",
|
8973 | "stroke": getUrlById(3)
|
8974 | }, null), vue.createVNode("path", {
|
8975 | "d": "M53 36a34 34 0 0 0 0 48",
|
8976 | "stroke": getUrlById(3)
|
8977 | }, null), vue.createVNode("path", {
|
8978 | "d": "M95 73a19 19 0 0 0 6-13c0-5-2-9-6-13",
|
8979 | "stroke": getUrlById(3)
|
8980 | }, null), vue.createVNode("path", {
|
8981 | "d": "M106 84a34 34 0 0 0 0-48",
|
8982 | "stroke": getUrlById(3)
|
8983 | }, null)]), vue.createVNode("g", {
|
8984 | "transform": "translate(31 105)"
|
8985 | }, [vue.createVNode("rect", {
|
8986 | "fill": "#EBEDF0",
|
8987 | "width": "98",
|
8988 | "height": "34",
|
8989 | "rx": "2"
|
8990 | }, null), vue.createVNode("rect", {
|
8991 | "fill": "#FFF",
|
8992 | "x": "9",
|
8993 | "y": "8",
|
8994 | "width": "80",
|
8995 | "height": "18",
|
8996 | "rx": "1.1"
|
8997 | }, null), vue.createVNode("rect", {
|
8998 | "fill": "#EBEDF0",
|
8999 | "x": "15",
|
9000 | "y": "12",
|
9001 | "width": "18",
|
9002 | "height": "6",
|
9003 | "rx": "1.1"
|
9004 | }, null)])])]);
|
9005 | const renderMaterial = () => vue.createVNode("svg", {
|
9006 | "viewBox": "0 0 160 160"
|
9007 | }, [vue.createVNode("defs", {
|
9008 | "data-allow-mismatch": "children"
|
9009 | }, [vue.createVNode("linearGradient", {
|
9010 | "x1": "50%",
|
9011 | "x2": "50%",
|
9012 | "y2": "100%",
|
9013 | "id": getId(5)
|
9014 | }, [renderStops("#F2F3F5", "#DCDEE0")]), vue.createVNode("linearGradient", {
|
9015 | "x1": "95%",
|
9016 | "y1": "48%",
|
9017 | "x2": "5.5%",
|
9018 | "y2": "51%",
|
9019 | "id": getId(6)
|
9020 | }, [renderStops("#EAEDF1", "#DCDEE0")]), vue.createVNode("linearGradient", {
|
9021 | "y1": "45%",
|
9022 | "x2": "100%",
|
9023 | "y2": "54%",
|
9024 | "id": getId(7)
|
9025 | }, [renderStops("#EAEDF1", "#DCDEE0")])]), renderBuilding(), renderCloud(), vue.createVNode("g", {
|
9026 | "transform": "translate(36 50)",
|
9027 | "fill": "none"
|
9028 | }, [vue.createVNode("g", {
|
9029 | "transform": "translate(8)"
|
9030 | }, [vue.createVNode("rect", {
|
9031 | "fill": "#EBEDF0",
|
9032 | "opacity": ".6",
|
9033 | "x": "38",
|
9034 | "y": "13",
|
9035 | "width": "36",
|
9036 | "height": "53",
|
9037 | "rx": "2"
|
9038 | }, null), vue.createVNode("rect", {
|
9039 | "fill": getUrlById(5),
|
9040 | "width": "64",
|
9041 | "height": "66",
|
9042 | "rx": "2",
|
9043 | "data-allow-mismatch": "attribute"
|
9044 | }, null), vue.createVNode("rect", {
|
9045 | "fill": "#FFF",
|
9046 | "x": "6",
|
9047 | "y": "6",
|
9048 | "width": "52",
|
9049 | "height": "55",
|
9050 | "rx": "1"
|
9051 | }, null), vue.createVNode("g", {
|
9052 | "transform": "translate(15 17)",
|
9053 | "fill": getUrlById(6),
|
9054 | "data-allow-mismatch": "attribute"
|
9055 | }, [vue.createVNode("rect", {
|
9056 | "width": "34",
|
9057 | "height": "6",
|
9058 | "rx": "1"
|
9059 | }, null), vue.createVNode("path", {
|
9060 | "d": "M0 14h34v6H0z"
|
9061 | }, null), vue.createVNode("rect", {
|
9062 | "y": "28",
|
9063 | "width": "34",
|
9064 | "height": "6",
|
9065 | "rx": "1"
|
9066 | }, null)])]), vue.createVNode("rect", {
|
9067 | "fill": getUrlById(7),
|
9068 | "y": "61",
|
9069 | "width": "88",
|
9070 | "height": "28",
|
9071 | "rx": "1",
|
9072 | "data-allow-mismatch": "attribute"
|
9073 | }, null), vue.createVNode("rect", {
|
9074 | "fill": "#F7F8FA",
|
9075 | "x": "29",
|
9076 | "y": "72",
|
9077 | "width": "30",
|
9078 | "height": "6",
|
9079 | "rx": "1"
|
9080 | }, null)])]);
|
9081 | const renderError = () => vue.createVNode("svg", {
|
9082 | "viewBox": "0 0 160 160"
|
9083 | }, [vue.createVNode("defs", null, [vue.createVNode("linearGradient", {
|
9084 | "x1": "50%",
|
9085 | "x2": "50%",
|
9086 | "y2": "100%",
|
9087 | "id": getId(8),
|
9088 | "data-allow-mismatch": "attribute"
|
9089 | }, [renderStops("#EAEDF1", "#DCDEE0")])]), renderBuilding(), renderCloud(), renderShadow("c"), vue.createVNode("path", {
|
9090 | "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",
|
9091 | "fill": getUrlById(8),
|
9092 | "data-allow-mismatch": "attribute"
|
9093 | }, null)]);
|
9094 | const renderSearch = () => vue.createVNode("svg", {
|
9095 | "viewBox": "0 0 160 160"
|
9096 | }, [vue.createVNode("defs", {
|
9097 | "data-allow-mismatch": "children"
|
9098 | }, [vue.createVNode("linearGradient", {
|
9099 | "x1": "50%",
|
9100 | "y1": "100%",
|
9101 | "x2": "50%",
|
9102 | "id": getId(9)
|
9103 | }, [renderStops("#EEE", "#D8D8D8")]), vue.createVNode("linearGradient", {
|
9104 | "x1": "100%",
|
9105 | "y1": "50%",
|
9106 | "y2": "50%",
|
9107 | "id": getId(10)
|
9108 | }, [renderStops("#F2F3F5", "#DCDEE0")]), vue.createVNode("linearGradient", {
|
9109 | "x1": "50%",
|
9110 | "x2": "50%",
|
9111 | "y2": "100%",
|
9112 | "id": getId(11)
|
9113 | }, [renderStops("#F2F3F5", "#DCDEE0")]), vue.createVNode("linearGradient", {
|
9114 | "x1": "50%",
|
9115 | "x2": "50%",
|
9116 | "y2": "100%",
|
9117 | "id": getId(12)
|
9118 | }, [renderStops("#FFF", "#F7F8FA")])]), renderBuilding(), renderCloud(), renderShadow("d"), vue.createVNode("g", {
|
9119 | "transform": "rotate(-45 113 -4)",
|
9120 | "fill": "none",
|
9121 | "data-allow-mismatch": "children"
|
9122 | }, [vue.createVNode("rect", {
|
9123 | "fill": getUrlById(9),
|
9124 | "x": "24",
|
9125 | "y": "52.8",
|
9126 | "width": "5.8",
|
9127 | "height": "19",
|
9128 | "rx": "1"
|
9129 | }, null), vue.createVNode("rect", {
|
9130 | "fill": getUrlById(10),
|
9131 | "x": "22.1",
|
9132 | "y": "67.3",
|
9133 | "width": "9.9",
|
9134 | "height": "28",
|
9135 | "rx": "1"
|
9136 | }, null), vue.createVNode("circle", {
|
9137 | "stroke": getUrlById(11),
|
9138 | "stroke-width": "8",
|
9139 | "cx": "27",
|
9140 | "cy": "27",
|
9141 | "r": "27"
|
9142 | }, null), vue.createVNode("circle", {
|
9143 | "fill": getUrlById(12),
|
9144 | "cx": "27",
|
9145 | "cy": "27",
|
9146 | "r": "16"
|
9147 | }, null), vue.createVNode("path", {
|
9148 | "d": "M37 7c-8 0-15 5-16 12",
|
9149 | "stroke": getUrlById(11),
|
9150 | "stroke-width": "3",
|
9151 | "opacity": ".5",
|
9152 | "stroke-linecap": "round",
|
9153 | "transform": "rotate(45 29 13)"
|
9154 | }, null)])]);
|
9155 | const renderImage = () => {
|
9156 | var _a;
|
9157 | if (slots.image) {
|
9158 | return slots.image();
|
9159 | }
|
9160 | const PRESET_IMAGES = {
|
9161 | error: renderError,
|
9162 | search: renderSearch,
|
9163 | network: renderNetwork,
|
9164 | default: renderMaterial
|
9165 | };
|
9166 | return ((_a = PRESET_IMAGES[props2.image]) == null ? void 0 : _a.call(PRESET_IMAGES)) || vue.createVNode("img", {
|
9167 | "src": props2.image
|
9168 | }, null);
|
9169 | };
|
9170 | return () => vue.createVNode("div", {
|
9171 | "class": bem$P()
|
9172 | }, [vue.createVNode("div", {
|
9173 | "class": bem$P("image"),
|
9174 | "style": getSizeStyle(props2.imageSize)
|
9175 | }, [renderImage()]), renderDescription(), renderBottom()]);
|
9176 | }
|
9177 | });
|
9178 | const Empty = withInstall(stdin_default$Z);
|
9179 | const [name$P, bem$O, t$9] = createNamespace("coupon-list");
|
9180 | const couponListProps = {
|
9181 | code: makeStringProp(""),
|
9182 | coupons: makeArrayProp(),
|
9183 | currency: makeStringProp("¥"),
|
9184 | showCount: truthProp,
|
9185 | emptyImage: String,
|
9186 | enabledTitle: String,
|
9187 | disabledTitle: String,
|
9188 | disabledCoupons: makeArrayProp(),
|
9189 | showExchangeBar: truthProp,
|
9190 | showCloseButton: truthProp,
|
9191 | closeButtonText: String,
|
9192 | inputPlaceholder: String,
|
9193 | exchangeMinLength: makeNumberProp(1),
|
9194 | exchangeButtonText: String,
|
9195 | displayedCouponIndex: makeNumberProp(-1),
|
9196 | exchangeButtonLoading: Boolean,
|
9197 | exchangeButtonDisabled: Boolean,
|
9198 | chosenCoupon: {
|
9199 | type: [Number, Array],
|
9200 | default: -1
|
9201 | }
|
9202 | };
|
9203 | var stdin_default$Y = vue.defineComponent({
|
9204 | name: name$P,
|
9205 | props: couponListProps,
|
9206 | emits: ["change", "exchange", "update:code"],
|
9207 | setup(props2, {
|
9208 | emit,
|
9209 | slots
|
9210 | }) {
|
9211 | const [couponRefs, setCouponRefs] = useRefs();
|
9212 | const root = vue.ref();
|
9213 | const barRef = vue.ref();
|
9214 | const activeTab = vue.ref(0);
|
9215 | const listHeight = vue.ref(0);
|
9216 | const currentCode = vue.ref(props2.code);
|
9217 | const buttonDisabled = vue.computed(() => !props2.exchangeButtonLoading && (props2.exchangeButtonDisabled || !currentCode.value || currentCode.value.length < props2.exchangeMinLength));
|
9218 | const updateListHeight = () => {
|
9219 | const TABS_HEIGHT = 44;
|
9220 | const rootHeight = use.useRect(root).height;
|
9221 | const headerHeight = use.useRect(barRef).height + TABS_HEIGHT;
|
9222 | listHeight.value = (rootHeight > headerHeight ? rootHeight : windowHeight.value) - headerHeight;
|
9223 | };
|
9224 | const onExchange = () => {
|
9225 | emit("exchange", currentCode.value);
|
9226 | if (!props2.code) {
|
9227 | currentCode.value = "";
|
9228 | }
|
9229 | };
|
9230 | const scrollToCoupon = (index) => {
|
9231 | vue.nextTick(() => {
|
9232 | var _a;
|
9233 | return (_a = couponRefs.value[index]) == null ? void 0 : _a.scrollIntoView();
|
9234 | });
|
9235 | };
|
9236 | const renderEmpty = () => vue.createVNode(Empty, {
|
9237 | "image": props2.emptyImage
|
9238 | }, {
|
9239 | default: () => [vue.createVNode("p", {
|
9240 | "class": bem$O("empty-tip")
|
9241 | }, [t$9("noCoupon")])]
|
9242 | });
|
9243 | const renderExchangeBar = () => {
|
9244 | if (props2.showExchangeBar) {
|
9245 | return vue.createVNode("div", {
|
9246 | "ref": barRef,
|
9247 | "class": bem$O("exchange-bar")
|
9248 | }, [vue.createVNode(Field, {
|
9249 | "modelValue": currentCode.value,
|
9250 | "onUpdate:modelValue": ($event) => currentCode.value = $event,
|
9251 | "clearable": true,
|
9252 | "border": false,
|
9253 | "class": bem$O("field"),
|
9254 | "placeholder": props2.inputPlaceholder || t$9("placeholder"),
|
9255 | "maxlength": "20"
|
9256 | }, null), vue.createVNode(Button, {
|
9257 | "plain": true,
|
9258 | "type": "primary",
|
9259 | "class": bem$O("exchange"),
|
9260 | "text": props2.exchangeButtonText || t$9("exchange"),
|
9261 | "loading": props2.exchangeButtonLoading,
|
9262 | "disabled": buttonDisabled.value,
|
9263 | "onClick": onExchange
|
9264 | }, null)]);
|
9265 | }
|
9266 | };
|
9267 | const renderCouponTab = () => {
|
9268 | const {
|
9269 | coupons,
|
9270 | chosenCoupon
|
9271 | } = props2;
|
9272 | const count = props2.showCount ? ` (${coupons.length})` : "";
|
9273 | const title = (props2.enabledTitle || t$9("enable")) + count;
|
9274 | const updateChosenCoupon = (currentValues = [], value = 0) => {
|
9275 | if (currentValues.includes(value)) {
|
9276 | return currentValues.filter((item) => item !== value);
|
9277 | }
|
9278 | return [...currentValues, value];
|
9279 | };
|
9280 | return vue.createVNode(Tab, {
|
9281 | "title": title
|
9282 | }, {
|
9283 | default: () => {
|
9284 | var _a;
|
9285 | return [vue.createVNode("div", {
|
9286 | "class": bem$O("list", {
|
9287 | "with-bottom": props2.showCloseButton
|
9288 | }),
|
9289 | "style": {
|
9290 | height: `${listHeight.value}px`
|
9291 | }
|
9292 | }, [coupons.map((coupon, index) => vue.createVNode(Coupon, {
|
9293 | "key": coupon.id,
|
9294 | "ref": setCouponRefs(index),
|
9295 | "coupon": coupon,
|
9296 | "chosen": Array.isArray(chosenCoupon) ? chosenCoupon.includes(index) : index === chosenCoupon,
|
9297 | "currency": props2.currency,
|
9298 | "onClick": () => emit("change", Array.isArray(chosenCoupon) ? updateChosenCoupon(chosenCoupon, index) : index)
|
9299 | }, null)), !coupons.length && renderEmpty(), (_a = slots["list-footer"]) == null ? void 0 : _a.call(slots)])];
|
9300 | }
|
9301 | });
|
9302 | };
|
9303 | const renderDisabledTab = () => {
|
9304 | const {
|
9305 | disabledCoupons
|
9306 | } = props2;
|
9307 | const count = props2.showCount ? ` (${disabledCoupons.length})` : "";
|
9308 | const title = (props2.disabledTitle || t$9("disabled")) + count;
|
9309 | return vue.createVNode(Tab, {
|
9310 | "title": title
|
9311 | }, {
|
9312 | default: () => {
|
9313 | var _a;
|
9314 | return [vue.createVNode("div", {
|
9315 | "class": bem$O("list", {
|
9316 | "with-bottom": props2.showCloseButton
|
9317 | }),
|
9318 | "style": {
|
9319 | height: `${listHeight.value}px`
|
9320 | }
|
9321 | }, [disabledCoupons.map((coupon) => vue.createVNode(Coupon, {
|
9322 | "disabled": true,
|
9323 | "key": coupon.id,
|
9324 | "coupon": coupon,
|
9325 | "currency": props2.currency
|
9326 | }, null)), !disabledCoupons.length && renderEmpty(), (_a = slots["disabled-list-footer"]) == null ? void 0 : _a.call(slots)])];
|
9327 | }
|
9328 | });
|
9329 | };
|
9330 | vue.watch(() => props2.code, (value) => {
|
9331 | currentCode.value = value;
|
9332 | });
|
9333 | vue.watch(windowHeight, updateListHeight);
|
9334 | vue.watch(currentCode, (value) => emit("update:code", value));
|
9335 | vue.watch(() => props2.displayedCouponIndex, scrollToCoupon);
|
9336 | vue.onMounted(() => {
|
9337 | updateListHeight();
|
9338 | scrollToCoupon(props2.displayedCouponIndex);
|
9339 | });
|
9340 | return () => vue.createVNode("div", {
|
9341 | "ref": root,
|
9342 | "class": bem$O()
|
9343 | }, [renderExchangeBar(), vue.createVNode(Tabs, {
|
9344 | "active": activeTab.value,
|
9345 | "onUpdate:active": ($event) => activeTab.value = $event,
|
9346 | "class": bem$O("tab")
|
9347 | }, {
|
9348 | default: () => [renderCouponTab(), renderDisabledTab()]
|
9349 | }), vue.createVNode("div", {
|
9350 | "class": bem$O("bottom")
|
9351 | }, [slots["list-button"] ? slots["list-button"]() : vue.withDirectives(vue.createVNode(Button, {
|
9352 | "round": true,
|
9353 | "block": true,
|
9354 | "type": "primary",
|
9355 | "class": bem$O("close"),
|
9356 | "text": props2.closeButtonText || t$9("close"),
|
9357 | "onClick": () => emit("change", Array.isArray(props2.chosenCoupon) ? [] : -1)
|
9358 | }, null), [[vue.vShow, props2.showCloseButton]])])]);
|
9359 | }
|
9360 | });
|
9361 | const CouponList = withInstall(stdin_default$Y);
|
9362 | const currentYear = ( new Date()).getFullYear();
|
9363 | const [name$O] = createNamespace("date-picker");
|
9364 | const datePickerProps = extend({}, sharedProps, {
|
9365 | columnsType: {
|
9366 | type: Array,
|
9367 | default: () => ["year", "month", "day"]
|
9368 | },
|
9369 | minDate: {
|
9370 | type: Date,
|
9371 | default: () => new Date(currentYear - 10, 0, 1),
|
9372 | validator: isDate
|
9373 | },
|
9374 | maxDate: {
|
9375 | type: Date,
|
9376 | default: () => new Date(currentYear + 10, 11, 31),
|
9377 | validator: isDate
|
9378 | }
|
9379 | });
|
9380 | var stdin_default$X = vue.defineComponent({
|
9381 | name: name$O,
|
9382 | props: datePickerProps,
|
9383 | emits: ["confirm", "cancel", "change", "update:modelValue"],
|
9384 | setup(props2, {
|
9385 | emit,
|
9386 | slots
|
9387 | }) {
|
9388 | const currentValues = vue.ref(props2.modelValue);
|
9389 | const updatedByExternalSources = vue.ref(false);
|
9390 | const pickerRef = vue.ref();
|
9391 | const computedValues = vue.computed(() => updatedByExternalSources.value ? props2.modelValue : currentValues.value);
|
9392 | const isMinYear = (year) => year === props2.minDate.getFullYear();
|
9393 | const isMaxYear = (year) => year === props2.maxDate.getFullYear();
|
9394 | const isMinMonth = (month) => month === props2.minDate.getMonth() + 1;
|
9395 | const isMaxMonth = (month) => month === props2.maxDate.getMonth() + 1;
|
9396 | const getValue2 = (type) => {
|
9397 | const {
|
9398 | minDate,
|
9399 | columnsType
|
9400 | } = props2;
|
9401 | const index = columnsType.indexOf(type);
|
9402 | const value = computedValues.value[index];
|
9403 | if (value) {
|
9404 | return +value;
|
9405 | }
|
9406 | switch (type) {
|
9407 | case "year":
|
9408 | return minDate.getFullYear();
|
9409 | case "month":
|
9410 | return minDate.getMonth() + 1;
|
9411 | case "day":
|
9412 | return minDate.getDate();
|
9413 | }
|
9414 | };
|
9415 | const genYearOptions = () => {
|
9416 | const minYear = props2.minDate.getFullYear();
|
9417 | const maxYear = props2.maxDate.getFullYear();
|
9418 | return genOptions(minYear, maxYear, "year", props2.formatter, props2.filter, computedValues.value);
|
9419 | };
|
9420 | const genMonthOptions = () => {
|
9421 | const year = getValue2("year");
|
9422 | const minMonth = isMinYear(year) ? props2.minDate.getMonth() + 1 : 1;
|
9423 | const maxMonth = isMaxYear(year) ? props2.maxDate.getMonth() + 1 : 12;
|
9424 | return genOptions(minMonth, maxMonth, "month", props2.formatter, props2.filter, computedValues.value);
|
9425 | };
|
9426 | const genDayOptions = () => {
|
9427 | const year = getValue2("year");
|
9428 | const month = getValue2("month");
|
9429 | const minDate = isMinYear(year) && isMinMonth(month) ? props2.minDate.getDate() : 1;
|
9430 | const maxDate = isMaxYear(year) && isMaxMonth(month) ? props2.maxDate.getDate() : getMonthEndDay(year, month);
|
9431 | return genOptions(minDate, maxDate, "day", props2.formatter, props2.filter, computedValues.value);
|
9432 | };
|
9433 | const confirm = () => {
|
9434 | var _a;
|
9435 | return (_a = pickerRef.value) == null ? void 0 : _a.confirm();
|
9436 | };
|
9437 | const getSelectedDate = () => currentValues.value;
|
9438 | const columns = vue.computed(() => props2.columnsType.map((type) => {
|
9439 | switch (type) {
|
9440 | case "year":
|
9441 | return genYearOptions();
|
9442 | case "month":
|
9443 | return genMonthOptions();
|
9444 | case "day":
|
9445 | return genDayOptions();
|
9446 | default:
|
9447 | if (process.env.NODE_ENV !== "production") {
|
9448 | throw new Error(`[Vant] DatePicker: unsupported columns type: ${type}`);
|
9449 | }
|
9450 | return [];
|
9451 | }
|
9452 | }));
|
9453 | vue.watch(currentValues, (newValues) => {
|
9454 | if (!isSameValue(newValues, props2.modelValue)) {
|
9455 | emit("update:modelValue", newValues);
|
9456 | }
|
9457 | });
|
9458 | vue.watch(() => props2.modelValue, (newValues, oldValues) => {
|
9459 | updatedByExternalSources.value = isSameValue(oldValues, currentValues.value);
|
9460 | newValues = formatValueRange(newValues, columns.value);
|
9461 | if (!isSameValue(newValues, currentValues.value)) {
|
9462 | currentValues.value = newValues;
|
9463 | }
|
9464 | updatedByExternalSources.value = false;
|
9465 | }, {
|
9466 | immediate: true
|
9467 | });
|
9468 | const onChange = (...args) => emit("change", ...args);
|
9469 | const onCancel = (...args) => emit("cancel", ...args);
|
9470 | const onConfirm = (...args) => emit("confirm", ...args);
|
9471 | useExpose({
|
9472 | confirm,
|
9473 | getSelectedDate
|
9474 | });
|
9475 | return () => vue.createVNode(Picker, vue.mergeProps({
|
9476 | "ref": pickerRef,
|
9477 | "modelValue": currentValues.value,
|
9478 | "onUpdate:modelValue": ($event) => currentValues.value = $event,
|
9479 | "columns": columns.value,
|
9480 | "onChange": onChange,
|
9481 | "onCancel": onCancel,
|
9482 | "onConfirm": onConfirm
|
9483 | }, pick(props2, pickerInheritKeys)), slots);
|
9484 | }
|
9485 | });
|
9486 | const DatePicker = withInstall(stdin_default$X);
|
9487 | const [name$N, bem$N, t$8] = createNamespace("dialog");
|
9488 | const dialogProps = extend({}, popupSharedProps, {
|
9489 | title: String,
|
9490 | theme: String,
|
9491 | width: numericProp,
|
9492 | message: [String, Function],
|
9493 | callback: Function,
|
9494 | allowHtml: Boolean,
|
9495 | className: unknownProp,
|
9496 | transition: makeStringProp("van-dialog-bounce"),
|
9497 | messageAlign: String,
|
9498 | closeOnPopstate: truthProp,
|
9499 | showCancelButton: Boolean,
|
9500 | cancelButtonText: String,
|
9501 | cancelButtonColor: String,
|
9502 | cancelButtonDisabled: Boolean,
|
9503 | confirmButtonText: String,
|
9504 | confirmButtonColor: String,
|
9505 | confirmButtonDisabled: Boolean,
|
9506 | showConfirmButton: truthProp,
|
9507 | closeOnClickOverlay: Boolean
|
9508 | });
|
9509 | const popupInheritKeys$1 = [...popupSharedPropKeys, "transition", "closeOnPopstate"];
|
9510 | var stdin_default$W = vue.defineComponent({
|
9511 | name: name$N,
|
9512 | props: dialogProps,
|
9513 | emits: ["confirm", "cancel", "keydown", "update:show"],
|
9514 | setup(props2, {
|
9515 | emit,
|
9516 | slots
|
9517 | }) {
|
9518 | const root = vue.ref();
|
9519 | const loading = vue.reactive({
|
9520 | confirm: false,
|
9521 | cancel: false
|
9522 | });
|
9523 | const updateShow = (value) => emit("update:show", value);
|
9524 | const close = (action) => {
|
9525 | var _a;
|
9526 | updateShow(false);
|
9527 | (_a = props2.callback) == null ? void 0 : _a.call(props2, action);
|
9528 | };
|
9529 | const getActionHandler = (action) => () => {
|
9530 | if (!props2.show) {
|
9531 | return;
|
9532 | }
|
9533 | emit(action);
|
9534 | if (props2.beforeClose) {
|
9535 | loading[action] = true;
|
9536 | callInterceptor(props2.beforeClose, {
|
9537 | args: [action],
|
9538 | done() {
|
9539 | close(action);
|
9540 | loading[action] = false;
|
9541 | },
|
9542 | canceled() {
|
9543 | loading[action] = false;
|
9544 | }
|
9545 | });
|
9546 | } else {
|
9547 | close(action);
|
9548 | }
|
9549 | };
|
9550 | const onCancel = getActionHandler("cancel");
|
9551 | const onConfirm = getActionHandler("confirm");
|
9552 | const onKeydown = vue.withKeys((event) => {
|
9553 | var _a, _b;
|
9554 | if (event.target !== ((_b = (_a = root.value) == null ? void 0 : _a.popupRef) == null ? void 0 : _b.value)) {
|
9555 | return;
|
9556 | }
|
9557 | const onEventType = {
|
9558 | Enter: props2.showConfirmButton ? onConfirm : noop,
|
9559 | Escape: props2.showCancelButton ? onCancel : noop
|
9560 | };
|
9561 | onEventType[event.key]();
|
9562 | emit("keydown", event);
|
9563 | }, ["enter", "esc"]);
|
9564 | const renderTitle = () => {
|
9565 | const title = slots.title ? slots.title() : props2.title;
|
9566 | if (title) {
|
9567 | return vue.createVNode("div", {
|
9568 | "class": bem$N("header", {
|
9569 | isolated: !props2.message && !slots.default
|
9570 | })
|
9571 | }, [title]);
|
9572 | }
|
9573 | };
|
9574 | const renderMessage = (hasTitle) => {
|
9575 | const {
|
9576 | message,
|
9577 | allowHtml,
|
9578 | messageAlign
|
9579 | } = props2;
|
9580 | const classNames = bem$N("message", {
|
9581 | "has-title": hasTitle,
|
9582 | [messageAlign]: messageAlign
|
9583 | });
|
9584 | const content = isFunction(message) ? message() : message;
|
9585 | if (allowHtml && typeof content === "string") {
|
9586 | return vue.createVNode("div", {
|
9587 | "class": classNames,
|
9588 | "innerHTML": content
|
9589 | }, null);
|
9590 | }
|
9591 | return vue.createVNode("div", {
|
9592 | "class": classNames
|
9593 | }, [content]);
|
9594 | };
|
9595 | const renderContent = () => {
|
9596 | if (slots.default) {
|
9597 | return vue.createVNode("div", {
|
9598 | "class": bem$N("content")
|
9599 | }, [slots.default()]);
|
9600 | }
|
9601 | const {
|
9602 | title,
|
9603 | message,
|
9604 | allowHtml
|
9605 | } = props2;
|
9606 | if (message) {
|
9607 | const hasTitle = !!(title || slots.title);
|
9608 | return vue.createVNode("div", {
|
9609 | "key": allowHtml ? 1 : 0,
|
9610 | "class": bem$N("content", {
|
9611 | isolated: !hasTitle
|
9612 | })
|
9613 | }, [renderMessage(hasTitle)]);
|
9614 | }
|
9615 | };
|
9616 | const renderButtons = () => vue.createVNode("div", {
|
9617 | "class": [BORDER_TOP, bem$N("footer")]
|
9618 | }, [props2.showCancelButton && vue.createVNode(Button, {
|
9619 | "size": "large",
|
9620 | "text": props2.cancelButtonText || t$8("cancel"),
|
9621 | "class": bem$N("cancel"),
|
9622 | "style": {
|
9623 | color: props2.cancelButtonColor
|
9624 | },
|
9625 | "loading": loading.cancel,
|
9626 | "disabled": props2.cancelButtonDisabled,
|
9627 | "onClick": onCancel
|
9628 | }, null), props2.showConfirmButton && vue.createVNode(Button, {
|
9629 | "size": "large",
|
9630 | "text": props2.confirmButtonText || t$8("confirm"),
|
9631 | "class": [bem$N("confirm"), {
|
9632 | [BORDER_LEFT]: props2.showCancelButton
|
9633 | }],
|
9634 | "style": {
|
9635 | color: props2.confirmButtonColor
|
9636 | },
|
9637 | "loading": loading.confirm,
|
9638 | "disabled": props2.confirmButtonDisabled,
|
9639 | "onClick": onConfirm
|
9640 | }, null)]);
|
9641 | const renderRoundButtons = () => vue.createVNode(ActionBar, {
|
9642 | "class": bem$N("footer")
|
9643 | }, {
|
9644 | default: () => [props2.showCancelButton && vue.createVNode(ActionBarButton, {
|
9645 | "type": "warning",
|
9646 | "text": props2.cancelButtonText || t$8("cancel"),
|
9647 | "class": bem$N("cancel"),
|
9648 | "color": props2.cancelButtonColor,
|
9649 | "loading": loading.cancel,
|
9650 | "disabled": props2.cancelButtonDisabled,
|
9651 | "onClick": onCancel
|
9652 | }, null), props2.showConfirmButton && vue.createVNode(ActionBarButton, {
|
9653 | "type": "danger",
|
9654 | "text": props2.confirmButtonText || t$8("confirm"),
|
9655 | "class": bem$N("confirm"),
|
9656 | "color": props2.confirmButtonColor,
|
9657 | "loading": loading.confirm,
|
9658 | "disabled": props2.confirmButtonDisabled,
|
9659 | "onClick": onConfirm
|
9660 | }, null)]
|
9661 | });
|
9662 | const renderFooter = () => {
|
9663 | if (slots.footer) {
|
9664 | return slots.footer();
|
9665 | }
|
9666 | return props2.theme === "round-button" ? renderRoundButtons() : renderButtons();
|
9667 | };
|
9668 | return () => {
|
9669 | const {
|
9670 | width,
|
9671 | title,
|
9672 | theme,
|
9673 | message,
|
9674 | className
|
9675 | } = props2;
|
9676 | return vue.createVNode(Popup, vue.mergeProps({
|
9677 | "ref": root,
|
9678 | "role": "dialog",
|
9679 | "class": [bem$N([theme]), className],
|
9680 | "style": {
|
9681 | width: addUnit(width)
|
9682 | },
|
9683 | "tabindex": 0,
|
9684 | "aria-labelledby": title || message,
|
9685 | "onKeydown": onKeydown,
|
9686 | "onUpdate:show": updateShow
|
9687 | }, pick(props2, popupInheritKeys$1)), {
|
9688 | default: () => [renderTitle(), renderContent(), renderFooter()]
|
9689 | });
|
9690 | };
|
9691 | }
|
9692 | });
|
9693 | let instance$2;
|
9694 | const DEFAULT_OPTIONS = {
|
9695 | title: "",
|
9696 | width: "",
|
9697 | theme: null,
|
9698 | message: "",
|
9699 | overlay: true,
|
9700 | callback: null,
|
9701 | teleport: "body",
|
9702 | className: "",
|
9703 | allowHtml: false,
|
9704 | lockScroll: true,
|
9705 | transition: void 0,
|
9706 | beforeClose: null,
|
9707 | overlayClass: "",
|
9708 | overlayStyle: void 0,
|
9709 | messageAlign: "",
|
9710 | cancelButtonText: "",
|
9711 | cancelButtonColor: null,
|
9712 | cancelButtonDisabled: false,
|
9713 | confirmButtonText: "",
|
9714 | confirmButtonColor: null,
|
9715 | confirmButtonDisabled: false,
|
9716 | showConfirmButton: true,
|
9717 | showCancelButton: false,
|
9718 | closeOnPopstate: true,
|
9719 | closeOnClickOverlay: false
|
9720 | };
|
9721 | let currentOptions$1 = extend({}, DEFAULT_OPTIONS);
|
9722 | function initInstance$2() {
|
9723 | const Wrapper = {
|
9724 | setup() {
|
9725 | const {
|
9726 | state,
|
9727 | toggle
|
9728 | } = usePopupState();
|
9729 | return () => vue.createVNode(stdin_default$W, vue.mergeProps(state, {
|
9730 | "onUpdate:show": toggle
|
9731 | }), null);
|
9732 | }
|
9733 | };
|
9734 | ({
|
9735 | instance: instance$2
|
9736 | } = mountComponent(Wrapper));
|
9737 | }
|
9738 | function showDialog(options) {
|
9739 | if (!inBrowser) {
|
9740 | return Promise.resolve(void 0);
|
9741 | }
|
9742 | return new Promise((resolve, reject) => {
|
9743 | if (!instance$2) {
|
9744 | initInstance$2();
|
9745 | }
|
9746 | instance$2.open(extend({}, currentOptions$1, options, {
|
9747 | callback: (action) => {
|
9748 | (action === "confirm" ? resolve : reject)(action);
|
9749 | }
|
9750 | }));
|
9751 | });
|
9752 | }
|
9753 | const setDialogDefaultOptions = (options) => {
|
9754 | extend(currentOptions$1, options);
|
9755 | };
|
9756 | const resetDialogDefaultOptions = () => {
|
9757 | currentOptions$1 = extend({}, DEFAULT_OPTIONS);
|
9758 | };
|
9759 | const showConfirmDialog = (options) => showDialog(extend({
|
9760 | showCancelButton: true
|
9761 | }, options));
|
9762 | const closeDialog = () => {
|
9763 | if (instance$2) {
|
9764 | instance$2.toggle(false);
|
9765 | }
|
9766 | };
|
9767 | const Dialog = withInstall(stdin_default$W);
|
9768 | const [name$M, bem$M] = createNamespace("divider");
|
9769 | const dividerProps = {
|
9770 | dashed: Boolean,
|
9771 | hairline: truthProp,
|
9772 | vertical: Boolean,
|
9773 | contentPosition: makeStringProp("center")
|
9774 | };
|
9775 | var stdin_default$V = vue.defineComponent({
|
9776 | name: name$M,
|
9777 | props: dividerProps,
|
9778 | setup(props2, {
|
9779 | slots
|
9780 | }) {
|
9781 | return () => {
|
9782 | var _a;
|
9783 | return vue.createVNode("div", {
|
9784 | "role": "separator",
|
9785 | "class": bem$M({
|
9786 | dashed: props2.dashed,
|
9787 | hairline: props2.hairline,
|
9788 | vertical: props2.vertical,
|
9789 | [`content-${props2.contentPosition}`]: !!slots.default && !props2.vertical
|
9790 | })
|
9791 | }, [!props2.vertical && ((_a = slots.default) == null ? void 0 : _a.call(slots))]);
|
9792 | };
|
9793 | }
|
9794 | });
|
9795 | const Divider = withInstall(stdin_default$V);
|
9796 | const [name$L, bem$L] = createNamespace("dropdown-menu");
|
9797 | const dropdownMenuProps = {
|
9798 | overlay: truthProp,
|
9799 | zIndex: numericProp,
|
9800 | duration: makeNumericProp(0.2),
|
9801 | direction: makeStringProp("down"),
|
9802 | activeColor: String,
|
9803 | autoLocate: Boolean,
|
9804 | closeOnClickOutside: truthProp,
|
9805 | closeOnClickOverlay: truthProp,
|
9806 | swipeThreshold: numericProp
|
9807 | };
|
9808 | const DROPDOWN_KEY = Symbol(name$L);
|
9809 | var stdin_default$U = vue.defineComponent({
|
9810 | name: name$L,
|
9811 | props: dropdownMenuProps,
|
9812 | setup(props2, {
|
9813 | slots
|
9814 | }) {
|
9815 | const id = useId();
|
9816 | const root = vue.ref();
|
9817 | const barRef = vue.ref();
|
9818 | const offset = vue.ref(0);
|
9819 | const {
|
9820 | children,
|
9821 | linkChildren
|
9822 | } = use.useChildren(DROPDOWN_KEY);
|
9823 | const scrollParent = use.useScrollParent(root);
|
9824 | const opened = vue.computed(() => children.some((item) => item.state.showWrapper));
|
9825 | const scrollable = vue.computed(() => props2.swipeThreshold && children.length > +props2.swipeThreshold);
|
9826 | const barStyle = vue.computed(() => {
|
9827 | if (opened.value && isDef(props2.zIndex)) {
|
9828 | return {
|
9829 | zIndex: +props2.zIndex + 1
|
9830 | };
|
9831 | }
|
9832 | });
|
9833 | const close = () => {
|
9834 | children.forEach((item) => {
|
9835 | item.toggle(false);
|
9836 | });
|
9837 | };
|
9838 | const onClickAway = () => {
|
9839 | if (props2.closeOnClickOutside) {
|
9840 | close();
|
9841 | }
|
9842 | };
|
9843 | const updateOffset = () => {
|
9844 | if (barRef.value) {
|
9845 | const rect = use.useRect(barRef);
|
9846 | if (props2.direction === "down") {
|
9847 | offset.value = rect.bottom;
|
9848 | } else {
|
9849 | offset.value = windowHeight.value - rect.top;
|
9850 | }
|
9851 | }
|
9852 | };
|
9853 | const onScroll = () => {
|
9854 | if (opened.value) {
|
9855 | updateOffset();
|
9856 | }
|
9857 | };
|
9858 | const toggleItem = (active) => {
|
9859 | children.forEach((item, index) => {
|
9860 | if (index === active) {
|
9861 | item.toggle();
|
9862 | } else if (item.state.showPopup) {
|
9863 | item.toggle(false, {
|
9864 | immediate: true
|
9865 | });
|
9866 | }
|
9867 | });
|
9868 | };
|
9869 | const renderTitle = (item, index) => {
|
9870 | const {
|
9871 | showPopup
|
9872 | } = item.state;
|
9873 | const {
|
9874 | disabled,
|
9875 | titleClass
|
9876 | } = item;
|
9877 | return vue.createVNode("div", {
|
9878 | "id": `${id}-${index}`,
|
9879 | "role": "button",
|
9880 | "tabindex": disabled ? void 0 : 0,
|
9881 | "data-allow-mismatch": "attribute",
|
9882 | "class": [bem$L("item", {
|
9883 | disabled,
|
9884 | grow: scrollable.value
|
9885 | }), {
|
9886 | [HAPTICS_FEEDBACK]: !disabled
|
9887 | }],
|
9888 | "onClick": () => {
|
9889 | if (!disabled) {
|
9890 | toggleItem(index);
|
9891 | }
|
9892 | }
|
9893 | }, [vue.createVNode("span", {
|
9894 | "class": [bem$L("title", {
|
9895 | down: showPopup === (props2.direction === "down"),
|
9896 | active: showPopup
|
9897 | }), titleClass],
|
9898 | "style": {
|
9899 | color: showPopup ? props2.activeColor : ""
|
9900 | }
|
9901 | }, [vue.createVNode("div", {
|
9902 | "class": "van-ellipsis"
|
9903 | }, [item.renderTitle()])])]);
|
9904 | };
|
9905 | useExpose({
|
9906 | close
|
9907 | });
|
9908 | linkChildren({
|
9909 | id,
|
9910 | props: props2,
|
9911 | offset,
|
9912 | updateOffset
|
9913 | });
|
9914 | use.useClickAway(root, onClickAway);
|
9915 | use.useEventListener("scroll", onScroll, {
|
9916 | target: scrollParent,
|
9917 | passive: true
|
9918 | });
|
9919 | return () => {
|
9920 | var _a;
|
9921 | return vue.createVNode("div", {
|
9922 | "ref": root,
|
9923 | "class": bem$L()
|
9924 | }, [vue.createVNode("div", {
|
9925 | "ref": barRef,
|
9926 | "style": barStyle.value,
|
9927 | "class": bem$L("bar", {
|
9928 | opened: opened.value,
|
9929 | scrollable: scrollable.value
|
9930 | })
|
9931 | }, [children.map(renderTitle)]), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
9932 | };
|
9933 | }
|
9934 | });
|
9935 | const [name$K, bem$K] = createNamespace("dropdown-item");
|
9936 | const dropdownItemProps = {
|
9937 | title: String,
|
9938 | options: makeArrayProp(),
|
9939 | disabled: Boolean,
|
9940 | teleport: [String, Object],
|
9941 | lazyRender: truthProp,
|
9942 | modelValue: unknownProp,
|
9943 | titleClass: unknownProp
|
9944 | };
|
9945 | var stdin_default$T = vue.defineComponent({
|
9946 | name: name$K,
|
9947 | inheritAttrs: false,
|
9948 | props: dropdownItemProps,
|
9949 | emits: ["open", "opened", "close", "closed", "change", "update:modelValue"],
|
9950 | setup(props2, {
|
9951 | emit,
|
9952 | slots,
|
9953 | attrs
|
9954 | }) {
|
9955 | const state = vue.reactive({
|
9956 | showPopup: false,
|
9957 | transition: true,
|
9958 | showWrapper: false
|
9959 | });
|
9960 | const wrapperRef = vue.ref();
|
9961 | const {
|
9962 | parent,
|
9963 | index
|
9964 | } = use.useParent(DROPDOWN_KEY);
|
9965 | if (!parent) {
|
9966 | if (process.env.NODE_ENV !== "production") {
|
9967 | console.error("[Vant] <DropdownItem> must be a child component of <DropdownMenu>.");
|
9968 | }
|
9969 | return;
|
9970 | }
|
9971 | const getEmitter = (name2) => () => emit(name2);
|
9972 | const onOpen = getEmitter("open");
|
9973 | const onClose = getEmitter("close");
|
9974 | const onOpened = getEmitter("opened");
|
9975 | const onClosed = () => {
|
9976 | state.showWrapper = false;
|
9977 | emit("closed");
|
9978 | };
|
9979 | const onClickWrapper = (event) => {
|
9980 | if (props2.teleport) {
|
9981 | event.stopPropagation();
|
9982 | }
|
9983 | };
|
9984 | const toggle = (show = !state.showPopup, options = {}) => {
|
9985 | if (show === state.showPopup) {
|
9986 | return;
|
9987 | }
|
9988 | state.showPopup = show;
|
9989 | state.transition = !options.immediate;
|
9990 | if (show) {
|
9991 | parent.updateOffset();
|
9992 | state.showWrapper = true;
|
9993 | }
|
9994 | };
|
9995 | const renderTitle = () => {
|
9996 | if (slots.title) {
|
9997 | return slots.title();
|
9998 | }
|
9999 | if (props2.title) {
|
10000 | return props2.title;
|
10001 | }
|
10002 | const match = props2.options.find((option) => option.value === props2.modelValue);
|
10003 | return match ? match.text : "";
|
10004 | };
|
10005 | const renderOption = (option) => {
|
10006 | const {
|
10007 | activeColor
|
10008 | } = parent.props;
|
10009 | const {
|
10010 | disabled
|
10011 | } = option;
|
10012 | const active = option.value === props2.modelValue;
|
10013 | const onClick = () => {
|
10014 | if (disabled) {
|
10015 | return;
|
10016 | }
|
10017 | state.showPopup = false;
|
10018 | if (option.value !== props2.modelValue) {
|
10019 | emit("update:modelValue", option.value);
|
10020 | emit("change", option.value);
|
10021 | }
|
10022 | };
|
10023 | const renderIcon = () => {
|
10024 | if (active) {
|
10025 | return vue.createVNode(Icon, {
|
10026 | "class": bem$K("icon"),
|
10027 | "color": disabled ? void 0 : activeColor,
|
10028 | "name": "success"
|
10029 | }, null);
|
10030 | }
|
10031 | };
|
10032 | return vue.createVNode(Cell, {
|
10033 | "role": "menuitem",
|
10034 | "key": String(option.value),
|
10035 | "icon": option.icon,
|
10036 | "title": option.text,
|
10037 | "class": bem$K("option", {
|
10038 | active,
|
10039 | disabled
|
10040 | }),
|
10041 | "style": {
|
10042 | color: active ? activeColor : ""
|
10043 | },
|
10044 | "tabindex": active ? 0 : -1,
|
10045 | "clickable": !disabled,
|
10046 | "onClick": onClick
|
10047 | }, {
|
10048 | value: renderIcon
|
10049 | });
|
10050 | };
|
10051 | const renderContent = () => {
|
10052 | const {
|
10053 | offset
|
10054 | } = parent;
|
10055 | const {
|
10056 | autoLocate,
|
10057 | zIndex,
|
10058 | overlay,
|
10059 | duration,
|
10060 | direction,
|
10061 | closeOnClickOverlay
|
10062 | } = parent.props;
|
10063 | const style = getZIndexStyle(zIndex);
|
10064 | let offsetValue = offset.value;
|
10065 | if (autoLocate && wrapperRef.value) {
|
10066 | const offsetParent = getContainingBlock(wrapperRef.value);
|
10067 | if (offsetParent) {
|
10068 | offsetValue -= use.useRect(offsetParent).top;
|
10069 | }
|
10070 | }
|
10071 | if (direction === "down") {
|
10072 | style.top = `${offsetValue}px`;
|
10073 | } else {
|
10074 | style.bottom = `${offsetValue}px`;
|
10075 | }
|
10076 | return vue.withDirectives(vue.createVNode("div", vue.mergeProps({
|
10077 | "ref": wrapperRef,
|
10078 | "style": style,
|
10079 | "class": bem$K([direction]),
|
10080 | "onClick": onClickWrapper
|
10081 | }, attrs), [vue.createVNode(Popup, {
|
10082 | "show": state.showPopup,
|
10083 | "onUpdate:show": ($event) => state.showPopup = $event,
|
10084 | "role": "menu",
|
10085 | "class": bem$K("content"),
|
10086 | "overlay": overlay,
|
10087 | "position": direction === "down" ? "top" : "bottom",
|
10088 | "duration": state.transition ? duration : 0,
|
10089 | "lazyRender": props2.lazyRender,
|
10090 | "overlayStyle": {
|
10091 | position: "absolute"
|
10092 | },
|
10093 | "aria-labelledby": `${parent.id}-${index.value}`,
|
10094 | "data-allow-mismatch": "attribute",
|
10095 | "closeOnClickOverlay": closeOnClickOverlay,
|
10096 | "onOpen": onOpen,
|
10097 | "onClose": onClose,
|
10098 | "onOpened": onOpened,
|
10099 | "onClosed": onClosed
|
10100 | }, {
|
10101 | default: () => {
|
10102 | var _a;
|
10103 | return [props2.options.map(renderOption), (_a = slots.default) == null ? void 0 : _a.call(slots)];
|
10104 | }
|
10105 | })]), [[vue.vShow, state.showWrapper]]);
|
10106 | };
|
10107 | useExpose({
|
10108 | state,
|
10109 | toggle,
|
10110 | renderTitle
|
10111 | });
|
10112 | return () => {
|
10113 | if (props2.teleport) {
|
10114 | return vue.createVNode(vue.Teleport, {
|
10115 | "to": props2.teleport
|
10116 | }, {
|
10117 | default: () => [renderContent()]
|
10118 | });
|
10119 | }
|
10120 | return renderContent();
|
10121 | };
|
10122 | }
|
10123 | });
|
10124 | const DropdownItem = withInstall(stdin_default$T);
|
10125 | const DropdownMenu = withInstall(stdin_default$U);
|
10126 | const floatingBubbleProps = {
|
10127 | gap: makeNumberProp(24),
|
10128 | icon: String,
|
10129 | axis: makeStringProp("y"),
|
10130 | magnetic: String,
|
10131 | offset: {
|
10132 | type: Object,
|
10133 | default: () => ({
|
10134 | x: -1,
|
10135 | y: -1
|
10136 | })
|
10137 | },
|
10138 | teleport: {
|
10139 | type: [String, Object],
|
10140 | default: "body"
|
10141 | }
|
10142 | };
|
10143 | const [name$J, bem$J] = createNamespace("floating-bubble");
|
10144 | var stdin_default$S = vue.defineComponent({
|
10145 | name: name$J,
|
10146 | inheritAttrs: false,
|
10147 | props: floatingBubbleProps,
|
10148 | emits: ["click", "update:offset", "offsetChange"],
|
10149 | setup(props2, {
|
10150 | slots,
|
10151 | emit,
|
10152 | attrs
|
10153 | }) {
|
10154 | const rootRef = vue.ref();
|
10155 | const state = vue.ref({
|
10156 | x: 0,
|
10157 | y: 0,
|
10158 | width: 0,
|
10159 | height: 0
|
10160 | });
|
10161 | const boundary = vue.computed(() => ({
|
10162 | top: props2.gap,
|
10163 | right: windowWidth.value - state.value.width - props2.gap,
|
10164 | bottom: windowHeight.value - state.value.height - props2.gap,
|
10165 | left: props2.gap
|
10166 | }));
|
10167 | const dragging = vue.ref(false);
|
10168 | let initialized = false;
|
10169 | const rootStyle = vue.computed(() => {
|
10170 | const style = {};
|
10171 | const x = addUnit(state.value.x);
|
10172 | const y = addUnit(state.value.y);
|
10173 | style.transform = `translate3d(${x}, ${y}, 0)`;
|
10174 | if (dragging.value || !initialized) {
|
10175 | style.transition = "none";
|
10176 | }
|
10177 | return style;
|
10178 | });
|
10179 | const updateState = () => {
|
10180 | if (!show.value) return;
|
10181 | const {
|
10182 | width,
|
10183 | height
|
10184 | } = use.useRect(rootRef.value);
|
10185 | const {
|
10186 | offset
|
10187 | } = props2;
|
10188 | state.value = {
|
10189 | x: offset.x > -1 ? offset.x : windowWidth.value - width - props2.gap,
|
10190 | y: offset.y > -1 ? offset.y : windowHeight.value - height - props2.gap,
|
10191 | width,
|
10192 | height
|
10193 | };
|
10194 | };
|
10195 | const touch = useTouch();
|
10196 | let prevX = 0;
|
10197 | let prevY = 0;
|
10198 | const onTouchStart = (e) => {
|
10199 | touch.start(e);
|
10200 | dragging.value = true;
|
10201 | prevX = state.value.x;
|
10202 | prevY = state.value.y;
|
10203 | };
|
10204 | const onTouchMove = (e) => {
|
10205 | e.preventDefault();
|
10206 | touch.move(e);
|
10207 | if (props2.axis === "lock") return;
|
10208 | if (!touch.isTap.value) {
|
10209 | if (props2.axis === "x" || props2.axis === "xy") {
|
10210 | let nextX = prevX + touch.deltaX.value;
|
10211 | if (nextX < boundary.value.left) nextX = boundary.value.left;
|
10212 | if (nextX > boundary.value.right) nextX = boundary.value.right;
|
10213 | state.value.x = nextX;
|
10214 | }
|
10215 | if (props2.axis === "y" || props2.axis === "xy") {
|
10216 | let nextY = prevY + touch.deltaY.value;
|
10217 | if (nextY < boundary.value.top) nextY = boundary.value.top;
|
10218 | if (nextY > boundary.value.bottom) nextY = boundary.value.bottom;
|
10219 | state.value.y = nextY;
|
10220 | }
|
10221 | const offset = pick(state.value, ["x", "y"]);
|
10222 | emit("update:offset", offset);
|
10223 | }
|
10224 | };
|
10225 | use.useEventListener("touchmove", onTouchMove, {
|
10226 | target: rootRef
|
10227 | });
|
10228 | const onTouchEnd = () => {
|
10229 | dragging.value = false;
|
10230 | vue.nextTick(() => {
|
10231 | if (props2.magnetic === "x") {
|
10232 | const nextX = closest([boundary.value.left, boundary.value.right], state.value.x);
|
10233 | state.value.x = nextX;
|
10234 | }
|
10235 | if (props2.magnetic === "y") {
|
10236 | const nextY = closest([boundary.value.top, boundary.value.bottom], state.value.y);
|
10237 | state.value.y = nextY;
|
10238 | }
|
10239 | if (!touch.isTap.value) {
|
10240 | const offset = pick(state.value, ["x", "y"]);
|
10241 | emit("update:offset", offset);
|
10242 | if (prevX !== offset.x || prevY !== offset.y) {
|
10243 | emit("offsetChange", offset);
|
10244 | }
|
10245 | }
|
10246 | });
|
10247 | };
|
10248 | const onClick = (e) => {
|
10249 | if (touch.isTap.value) emit("click", e);
|
10250 | else e.stopPropagation();
|
10251 | };
|
10252 | vue.onMounted(() => {
|
10253 | updateState();
|
10254 | vue.nextTick(() => {
|
10255 | initialized = true;
|
10256 | });
|
10257 | });
|
10258 | vue.watch([windowWidth, windowHeight, () => props2.gap, () => props2.offset], updateState, {
|
10259 | deep: true
|
10260 | });
|
10261 | const show = vue.ref(true);
|
10262 | vue.onActivated(() => {
|
10263 | show.value = true;
|
10264 | });
|
10265 | vue.onDeactivated(() => {
|
10266 | if (props2.teleport) {
|
10267 | show.value = false;
|
10268 | }
|
10269 | });
|
10270 | return () => {
|
10271 | const Content = vue.withDirectives(vue.createVNode("div", vue.mergeProps({
|
10272 | "class": bem$J(),
|
10273 | "ref": rootRef,
|
10274 | "onTouchstartPassive": onTouchStart,
|
10275 | "onTouchend": onTouchEnd,
|
10276 | "onTouchcancel": onTouchEnd,
|
10277 | "onClickCapture": onClick,
|
10278 | "style": rootStyle.value
|
10279 | }, attrs), [slots.default ? slots.default() : vue.createVNode(stdin_default$1Q, {
|
10280 | "name": props2.icon,
|
10281 | "class": bem$J("icon")
|
10282 | }, null)]), [[vue.vShow, show.value]]);
|
10283 | return props2.teleport ? vue.createVNode(vue.Teleport, {
|
10284 | "to": props2.teleport
|
10285 | }, {
|
10286 | default: () => [Content]
|
10287 | }) : Content;
|
10288 | };
|
10289 | }
|
10290 | });
|
10291 | const FloatingBubble = withInstall(stdin_default$S);
|
10292 | const floatingPanelProps = {
|
10293 | height: makeNumericProp(0),
|
10294 | anchors: makeArrayProp(),
|
10295 | duration: makeNumericProp(0.3),
|
10296 | contentDraggable: truthProp,
|
10297 | lockScroll: Boolean,
|
10298 | safeAreaInsetBottom: truthProp
|
10299 | };
|
10300 | const [name$I, bem$I] = createNamespace("floating-panel");
|
10301 | var stdin_default$R = vue.defineComponent({
|
10302 | name: name$I,
|
10303 | props: floatingPanelProps,
|
10304 | emits: ["heightChange", "update:height"],
|
10305 | setup(props2, {
|
10306 | emit,
|
10307 | slots
|
10308 | }) {
|
10309 | const DAMP = 0.2;
|
10310 | const rootRef = vue.ref();
|
10311 | const contentRef = vue.ref();
|
10312 | const height = useSyncPropRef(() => +props2.height, (value) => emit("update:height", value));
|
10313 | const boundary = vue.computed(() => {
|
10314 | var _a, _b;
|
10315 | return {
|
10316 | min: (_a = props2.anchors[0]) != null ? _a : 100,
|
10317 | max: (_b = props2.anchors[props2.anchors.length - 1]) != null ? _b : Math.round(windowHeight.value * 0.6)
|
10318 | };
|
10319 | });
|
10320 | const anchors = vue.computed(() => props2.anchors.length >= 2 ? props2.anchors : [boundary.value.min, boundary.value.max]);
|
10321 | const dragging = vue.ref(false);
|
10322 | const rootStyle = vue.computed(() => ({
|
10323 | height: addUnit(boundary.value.max),
|
10324 | transform: `translateY(calc(100% + ${addUnit(-height.value)}))`,
|
10325 | transition: !dragging.value ? `transform ${props2.duration}s cubic-bezier(0.18, 0.89, 0.32, 1.28)` : "none"
|
10326 | }));
|
10327 | const ease = (moveY) => {
|
10328 | const absDistance = Math.abs(moveY);
|
10329 | const {
|
10330 | min,
|
10331 | max
|
10332 | } = boundary.value;
|
10333 | if (absDistance > max) {
|
10334 | return -(max + (absDistance - max) * DAMP);
|
10335 | }
|
10336 | if (absDistance < min) {
|
10337 | return -(min - (min - absDistance) * DAMP);
|
10338 | }
|
10339 | return moveY;
|
10340 | };
|
10341 | let startY;
|
10342 | let maxScroll = -1;
|
10343 | const touch = useTouch();
|
10344 | const onTouchstart = (e) => {
|
10345 | touch.start(e);
|
10346 | dragging.value = true;
|
10347 | startY = -height.value;
|
10348 | maxScroll = -1;
|
10349 | };
|
10350 | const onTouchmove = (e) => {
|
10351 | var _a;
|
10352 | touch.move(e);
|
10353 | const target = e.target;
|
10354 | if (contentRef.value === target || ((_a = contentRef.value) == null ? void 0 : _a.contains(target))) {
|
10355 | const {
|
10356 | scrollTop
|
10357 | } = contentRef.value;
|
10358 | maxScroll = Math.max(maxScroll, scrollTop);
|
10359 | if (!props2.contentDraggable) return;
|
10360 | if (-startY < boundary.value.max) {
|
10361 | preventDefault(e, true);
|
10362 | } else if (!(scrollTop <= 0 && touch.deltaY.value > 0) || maxScroll > 0) {
|
10363 | return;
|
10364 | }
|
10365 | }
|
10366 | const moveY = touch.deltaY.value + startY;
|
10367 | height.value = -ease(moveY);
|
10368 | };
|
10369 | const onTouchend = () => {
|
10370 | maxScroll = -1;
|
10371 | dragging.value = false;
|
10372 | height.value = closest(anchors.value, height.value);
|
10373 | if (height.value !== -startY) {
|
10374 | emit("heightChange", {
|
10375 | height: height.value
|
10376 | });
|
10377 | }
|
10378 | };
|
10379 | vue.watch(boundary, () => {
|
10380 | height.value = closest(anchors.value, height.value);
|
10381 | }, {
|
10382 | immediate: true
|
10383 | });
|
10384 | useLockScroll(rootRef, () => props2.lockScroll || dragging.value);
|
10385 | use.useEventListener("touchmove", onTouchmove, {
|
10386 | target: rootRef
|
10387 | });
|
10388 | const renderHeader = () => {
|
10389 | if (slots.header) {
|
10390 | return slots.header();
|
10391 | }
|
10392 | return vue.createVNode("div", {
|
10393 | "class": bem$I("header")
|
10394 | }, [vue.createVNode("div", {
|
10395 | "class": bem$I("header-bar")
|
10396 | }, null)]);
|
10397 | };
|
10398 | return () => {
|
10399 | var _a;
|
10400 | return vue.createVNode("div", {
|
10401 | "class": [bem$I(), {
|
10402 | "van-safe-area-bottom": props2.safeAreaInsetBottom
|
10403 | }],
|
10404 | "ref": rootRef,
|
10405 | "style": rootStyle.value,
|
10406 | "onTouchstartPassive": onTouchstart,
|
10407 | "onTouchend": onTouchend,
|
10408 | "onTouchcancel": onTouchend
|
10409 | }, [renderHeader(), vue.createVNode("div", {
|
10410 | "class": bem$I("content"),
|
10411 | "ref": contentRef
|
10412 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
|
10413 | };
|
10414 | }
|
10415 | });
|
10416 | const FloatingPanel = withInstall(stdin_default$R);
|
10417 | const [name$H, bem$H] = createNamespace("grid");
|
10418 | const gridProps = {
|
10419 | square: Boolean,
|
10420 | center: truthProp,
|
10421 | border: truthProp,
|
10422 | gutter: numericProp,
|
10423 | reverse: Boolean,
|
10424 | iconSize: numericProp,
|
10425 | direction: String,
|
10426 | clickable: Boolean,
|
10427 | columnNum: makeNumericProp(4)
|
10428 | };
|
10429 | const GRID_KEY = Symbol(name$H);
|
10430 | var stdin_default$Q = vue.defineComponent({
|
10431 | name: name$H,
|
10432 | props: gridProps,
|
10433 | setup(props2, {
|
10434 | slots
|
10435 | }) {
|
10436 | const {
|
10437 | linkChildren
|
10438 | } = use.useChildren(GRID_KEY);
|
10439 | linkChildren({
|
10440 | props: props2
|
10441 | });
|
10442 | return () => {
|
10443 | var _a;
|
10444 | return vue.createVNode("div", {
|
10445 | "style": {
|
10446 | paddingLeft: addUnit(props2.gutter)
|
10447 | },
|
10448 | "class": [bem$H(), {
|
10449 | [BORDER_TOP]: props2.border && !props2.gutter
|
10450 | }]
|
10451 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
10452 | };
|
10453 | }
|
10454 | });
|
10455 | const Grid = withInstall(stdin_default$Q);
|
10456 | const [name$G, bem$G] = createNamespace("grid-item");
|
10457 | const gridItemProps = extend({}, routeProps, {
|
10458 | dot: Boolean,
|
10459 | text: String,
|
10460 | icon: String,
|
10461 | badge: numericProp,
|
10462 | iconColor: String,
|
10463 | iconPrefix: String,
|
10464 | badgeProps: Object
|
10465 | });
|
10466 | var stdin_default$P = vue.defineComponent({
|
10467 | name: name$G,
|
10468 | props: gridItemProps,
|
10469 | setup(props2, {
|
10470 | slots
|
10471 | }) {
|
10472 | const {
|
10473 | parent,
|
10474 | index
|
10475 | } = use.useParent(GRID_KEY);
|
10476 | const route2 = useRoute();
|
10477 | if (!parent) {
|
10478 | if (process.env.NODE_ENV !== "production") {
|
10479 | console.error("[Vant] <GridItem> must be a child component of <Grid>.");
|
10480 | }
|
10481 | return;
|
10482 | }
|
10483 | const rootStyle = vue.computed(() => {
|
10484 | const {
|
10485 | square,
|
10486 | gutter,
|
10487 | columnNum
|
10488 | } = parent.props;
|
10489 | const percent = `${100 / +columnNum}%`;
|
10490 | const style = {
|
10491 | flexBasis: percent
|
10492 | };
|
10493 | if (square) {
|
10494 | style.paddingTop = percent;
|
10495 | } else if (gutter) {
|
10496 | const gutterValue = addUnit(gutter);
|
10497 | style.paddingRight = gutterValue;
|
10498 | if (index.value >= +columnNum) {
|
10499 | style.marginTop = gutterValue;
|
10500 | }
|
10501 | }
|
10502 | return style;
|
10503 | });
|
10504 | const contentStyle = vue.computed(() => {
|
10505 | const {
|
10506 | square,
|
10507 | gutter
|
10508 | } = parent.props;
|
10509 | if (square && gutter) {
|
10510 | const gutterValue = addUnit(gutter);
|
10511 | return {
|
10512 | right: gutterValue,
|
10513 | bottom: gutterValue,
|
10514 | height: "auto"
|
10515 | };
|
10516 | }
|
10517 | });
|
10518 | const renderIcon = () => {
|
10519 | if (slots.icon) {
|
10520 | return vue.createVNode(Badge, vue.mergeProps({
|
10521 | "dot": props2.dot,
|
10522 | "content": props2.badge
|
10523 | }, props2.badgeProps), {
|
10524 | default: slots.icon
|
10525 | });
|
10526 | }
|
10527 | if (props2.icon) {
|
10528 | return vue.createVNode(Icon, {
|
10529 | "dot": props2.dot,
|
10530 | "name": props2.icon,
|
10531 | "size": parent.props.iconSize,
|
10532 | "badge": props2.badge,
|
10533 | "class": bem$G("icon"),
|
10534 | "color": props2.iconColor,
|
10535 | "badgeProps": props2.badgeProps,
|
10536 | "classPrefix": props2.iconPrefix
|
10537 | }, null);
|
10538 | }
|
10539 | };
|
10540 | const renderText = () => {
|
10541 | if (slots.text) {
|
10542 | return slots.text();
|
10543 | }
|
10544 | if (props2.text) {
|
10545 | return vue.createVNode("span", {
|
10546 | "class": bem$G("text")
|
10547 | }, [props2.text]);
|
10548 | }
|
10549 | };
|
10550 | const renderContent = () => {
|
10551 | if (slots.default) {
|
10552 | return slots.default();
|
10553 | }
|
10554 | return [renderIcon(), renderText()];
|
10555 | };
|
10556 | return () => {
|
10557 | const {
|
10558 | center,
|
10559 | border,
|
10560 | square,
|
10561 | gutter,
|
10562 | reverse,
|
10563 | direction,
|
10564 | clickable
|
10565 | } = parent.props;
|
10566 | const classes = [bem$G("content", [direction, {
|
10567 | center,
|
10568 | square,
|
10569 | reverse,
|
10570 | clickable,
|
10571 | surround: border && gutter
|
10572 | }]), {
|
10573 | [BORDER]: border
|
10574 | }];
|
10575 | return vue.createVNode("div", {
|
10576 | "class": [bem$G({
|
10577 | square
|
10578 | })],
|
10579 | "style": rootStyle.value
|
10580 | }, [vue.createVNode("div", {
|
10581 | "role": clickable ? "button" : void 0,
|
10582 | "class": classes,
|
10583 | "style": contentStyle.value,
|
10584 | "tabindex": clickable ? 0 : void 0,
|
10585 | "onClick": route2
|
10586 | }, [renderContent()])]);
|
10587 | };
|
10588 | }
|
10589 | });
|
10590 | const GridItem = withInstall(stdin_default$P);
|
10591 | const [name$F, bem$F] = createNamespace("highlight");
|
10592 | const highlightProps = {
|
10593 | autoEscape: truthProp,
|
10594 | caseSensitive: Boolean,
|
10595 | highlightClass: String,
|
10596 | highlightTag: makeStringProp("span"),
|
10597 | keywords: makeRequiredProp([String, Array]),
|
10598 | sourceString: makeStringProp(""),
|
10599 | tag: makeStringProp("div"),
|
10600 | unhighlightClass: String,
|
10601 | unhighlightTag: makeStringProp("span")
|
10602 | };
|
10603 | var stdin_default$O = vue.defineComponent({
|
10604 | name: name$F,
|
10605 | props: highlightProps,
|
10606 | setup(props2) {
|
10607 | const highlightChunks = vue.computed(() => {
|
10608 | const {
|
10609 | autoEscape,
|
10610 | caseSensitive,
|
10611 | keywords,
|
10612 | sourceString
|
10613 | } = props2;
|
10614 | const flags = caseSensitive ? "g" : "gi";
|
10615 | const _keywords = Array.isArray(keywords) ? keywords : [keywords];
|
10616 | let chunks = _keywords.filter((keyword) => keyword).reduce((chunks2, keyword) => {
|
10617 | if (autoEscape) {
|
10618 | keyword = keyword.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
10619 | }
|
10620 | const regex = new RegExp(keyword, flags);
|
10621 | let match;
|
10622 | while (match = regex.exec(sourceString)) {
|
10623 | const start = match.index;
|
10624 | const end = regex.lastIndex;
|
10625 | if (start >= end) {
|
10626 | regex.lastIndex++;
|
10627 | continue;
|
10628 | }
|
10629 | chunks2.push({
|
10630 | start,
|
10631 | end,
|
10632 | highlight: true
|
10633 | });
|
10634 | }
|
10635 | return chunks2;
|
10636 | }, []);
|
10637 | chunks = chunks.sort((a, b) => a.start - b.start).reduce((chunks2, currentChunk) => {
|
10638 | const prevChunk = chunks2[chunks2.length - 1];
|
10639 | if (!prevChunk || currentChunk.start > prevChunk.end) {
|
10640 | const unhighlightStart = prevChunk ? prevChunk.end : 0;
|
10641 | const unhighlightEnd = currentChunk.start;
|
10642 | if (unhighlightStart !== unhighlightEnd) {
|
10643 | chunks2.push({
|
10644 | start: unhighlightStart,
|
10645 | end: unhighlightEnd,
|
10646 | highlight: false
|
10647 | });
|
10648 | }
|
10649 | chunks2.push(currentChunk);
|
10650 | } else {
|
10651 | prevChunk.end = Math.max(prevChunk.end, currentChunk.end);
|
10652 | }
|
10653 | return chunks2;
|
10654 | }, []);
|
10655 | const lastChunk = chunks[chunks.length - 1];
|
10656 | if (!lastChunk) {
|
10657 | chunks.push({
|
10658 | start: 0,
|
10659 | end: sourceString.length,
|
10660 | highlight: false
|
10661 | });
|
10662 | }
|
10663 | if (lastChunk && lastChunk.end < sourceString.length) {
|
10664 | chunks.push({
|
10665 | start: lastChunk.end,
|
10666 | end: sourceString.length,
|
10667 | highlight: false
|
10668 | });
|
10669 | }
|
10670 | return chunks;
|
10671 | });
|
10672 | const renderContent = () => {
|
10673 | const {
|
10674 | sourceString,
|
10675 | highlightClass,
|
10676 | unhighlightClass,
|
10677 | highlightTag,
|
10678 | unhighlightTag
|
10679 | } = props2;
|
10680 | return highlightChunks.value.map((chunk) => {
|
10681 | const {
|
10682 | start,
|
10683 | end,
|
10684 | highlight
|
10685 | } = chunk;
|
10686 | const text = sourceString.slice(start, end);
|
10687 | if (highlight) {
|
10688 | return vue.createVNode(highlightTag, {
|
10689 | "class": [bem$F("tag"), highlightClass]
|
10690 | }, {
|
10691 | default: () => [text]
|
10692 | });
|
10693 | }
|
10694 | return vue.createVNode(unhighlightTag, {
|
10695 | "class": unhighlightClass
|
10696 | }, {
|
10697 | default: () => [text]
|
10698 | });
|
10699 | });
|
10700 | };
|
10701 | return () => {
|
10702 | const {
|
10703 | tag
|
10704 | } = props2;
|
10705 | return vue.createVNode(tag, {
|
10706 | "class": bem$F()
|
10707 | }, {
|
10708 | default: () => [renderContent()]
|
10709 | });
|
10710 | };
|
10711 | }
|
10712 | });
|
10713 | const Highlight = withInstall(stdin_default$O);
|
10714 | const getDistance = (touches) => Math.sqrt((touches[0].clientX - touches[1].clientX) ** 2 + (touches[0].clientY - touches[1].clientY) ** 2);
|
10715 | const getCenter = (touches) => ({
|
10716 | x: (touches[0].clientX + touches[1].clientX) / 2,
|
10717 | y: (touches[0].clientY + touches[1].clientY) / 2
|
10718 | });
|
10719 | const bem$E = createNamespace("image-preview")[1];
|
10720 | const longImageRatio = 2.6;
|
10721 | const imagePreviewItemProps = {
|
10722 | src: String,
|
10723 | show: Boolean,
|
10724 | active: Number,
|
10725 | minZoom: makeRequiredProp(numericProp),
|
10726 | maxZoom: makeRequiredProp(numericProp),
|
10727 | rootWidth: makeRequiredProp(Number),
|
10728 | rootHeight: makeRequiredProp(Number),
|
10729 | disableZoom: Boolean,
|
10730 | doubleScale: Boolean,
|
10731 | closeOnClickImage: Boolean,
|
10732 | closeOnClickOverlay: Boolean,
|
10733 | vertical: Boolean
|
10734 | };
|
10735 | var stdin_default$N = vue.defineComponent({
|
10736 | props: imagePreviewItemProps,
|
10737 | emits: ["scale", "close", "longPress"],
|
10738 | setup(props2, {
|
10739 | emit,
|
10740 | slots
|
10741 | }) {
|
10742 | const state = vue.reactive({
|
10743 | scale: 1,
|
10744 | moveX: 0,
|
10745 | moveY: 0,
|
10746 | moving: false,
|
10747 | zooming: false,
|
10748 | initializing: false,
|
10749 | imageRatio: 0
|
10750 | });
|
10751 | const touch = useTouch();
|
10752 | const imageRef = vue.ref();
|
10753 | const swipeItem = vue.ref();
|
10754 | const vertical = vue.ref(false);
|
10755 | const isLongImage = vue.ref(false);
|
10756 | let initialMoveY = 0;
|
10757 | const imageStyle = vue.computed(() => {
|
10758 | const {
|
10759 | scale,
|
10760 | moveX,
|
10761 | moveY,
|
10762 | moving,
|
10763 | zooming,
|
10764 | initializing
|
10765 | } = state;
|
10766 | const style = {
|
10767 | transitionDuration: zooming || moving || initializing ? "0s" : ".3s"
|
10768 | };
|
10769 | if (scale !== 1 || isLongImage.value) {
|
10770 | style.transform = `matrix(${scale}, 0, 0, ${scale}, ${moveX}, ${moveY})`;
|
10771 | }
|
10772 | return style;
|
10773 | });
|
10774 | const maxMoveX = vue.computed(() => {
|
10775 | if (state.imageRatio) {
|
10776 | const {
|
10777 | rootWidth,
|
10778 | rootHeight
|
10779 | } = props2;
|
10780 | const displayWidth = vertical.value ? rootHeight / state.imageRatio : rootWidth;
|
10781 | return Math.max(0, (state.scale * displayWidth - rootWidth) / 2);
|
10782 | }
|
10783 | return 0;
|
10784 | });
|
10785 | const maxMoveY = vue.computed(() => {
|
10786 | if (state.imageRatio) {
|
10787 | const {
|
10788 | rootWidth,
|
10789 | rootHeight
|
10790 | } = props2;
|
10791 | const displayHeight = vertical.value ? rootHeight : rootWidth * state.imageRatio;
|
10792 | return Math.max(0, (state.scale * displayHeight - rootHeight) / 2);
|
10793 | }
|
10794 | return 0;
|
10795 | });
|
10796 | const setScale = (scale, center) => {
|
10797 | var _a;
|
10798 | scale = clamp(scale, +props2.minZoom, +props2.maxZoom + 1);
|
10799 | if (scale !== state.scale) {
|
10800 | const ratio = scale / state.scale;
|
10801 | state.scale = scale;
|
10802 | if (center) {
|
10803 | const imageRect = use.useRect((_a = imageRef.value) == null ? void 0 : _a.$el);
|
10804 | const origin = {
|
10805 | x: imageRect.width * 0.5,
|
10806 | y: imageRect.height * 0.5
|
10807 | };
|
10808 | const moveX = state.moveX - (center.x - imageRect.left - origin.x) * (ratio - 1);
|
10809 | const moveY = state.moveY - (center.y - imageRect.top - origin.y) * (ratio - 1);
|
10810 | state.moveX = clamp(moveX, -maxMoveX.value, maxMoveX.value);
|
10811 | state.moveY = clamp(moveY, -maxMoveY.value, maxMoveY.value);
|
10812 | } else {
|
10813 | state.moveX = 0;
|
10814 | state.moveY = isLongImage.value ? initialMoveY : 0;
|
10815 | }
|
10816 | emit("scale", {
|
10817 | scale,
|
10818 | index: props2.active
|
10819 | });
|
10820 | }
|
10821 | };
|
10822 | const resetScale = () => {
|
10823 | setScale(1);
|
10824 | };
|
10825 | const toggleScale = () => {
|
10826 | const scale = state.scale > 1 ? 1 : 2;
|
10827 | setScale(scale, scale === 2 || isLongImage.value ? {
|
10828 | x: touch.startX.value,
|
10829 | y: touch.startY.value
|
10830 | } : void 0);
|
10831 | };
|
10832 | let fingerNum;
|
10833 | let startMoveX;
|
10834 | let startMoveY;
|
10835 | let startScale;
|
10836 | let startDistance;
|
10837 | let lastCenter;
|
10838 | let doubleTapTimer;
|
10839 | let touchStartTime;
|
10840 | let isImageMoved = false;
|
10841 | const onTouchStart = (event) => {
|
10842 | const {
|
10843 | touches
|
10844 | } = event;
|
10845 | fingerNum = touches.length;
|
10846 | if (fingerNum === 2 && props2.disableZoom) {
|
10847 | return;
|
10848 | }
|
10849 | const {
|
10850 | offsetX
|
10851 | } = touch;
|
10852 | touch.start(event);
|
10853 | startMoveX = state.moveX;
|
10854 | startMoveY = state.moveY;
|
10855 | touchStartTime = Date.now();
|
10856 | isImageMoved = false;
|
10857 | state.moving = fingerNum === 1 && (state.scale !== 1 || isLongImage.value);
|
10858 | state.zooming = fingerNum === 2 && !offsetX.value;
|
10859 | if (state.zooming) {
|
10860 | startScale = state.scale;
|
10861 | startDistance = getDistance(touches);
|
10862 | }
|
10863 | };
|
10864 | const onTouchMove = (event) => {
|
10865 | const {
|
10866 | touches
|
10867 | } = event;
|
10868 | touch.move(event);
|
10869 | if (state.moving) {
|
10870 | const {
|
10871 | deltaX,
|
10872 | deltaY
|
10873 | } = touch;
|
10874 | const moveX = deltaX.value + startMoveX;
|
10875 | const moveY = deltaY.value + startMoveY;
|
10876 | if ((props2.vertical ? touch.isVertical() && Math.abs(moveY) > maxMoveY.value : touch.isHorizontal() && Math.abs(moveX) > maxMoveX.value) && !isImageMoved) {
|
10877 | state.moving = false;
|
10878 | return;
|
10879 | }
|
10880 | isImageMoved = true;
|
10881 | preventDefault(event, true);
|
10882 | state.moveX = clamp(moveX, -maxMoveX.value, maxMoveX.value);
|
10883 | state.moveY = clamp(moveY, -maxMoveY.value, maxMoveY.value);
|
10884 | }
|
10885 | if (state.zooming) {
|
10886 | preventDefault(event, true);
|
10887 | if (touches.length === 2) {
|
10888 | const distance = getDistance(touches);
|
10889 | const scale = startScale * distance / startDistance;
|
10890 | lastCenter = getCenter(touches);
|
10891 | setScale(scale, lastCenter);
|
10892 | }
|
10893 | }
|
10894 | };
|
10895 | const checkClose = (event) => {
|
10896 | var _a;
|
10897 | const swipeItemEl = (_a = swipeItem.value) == null ? void 0 : _a.$el;
|
10898 | if (!swipeItemEl) return;
|
10899 | const imageEl = swipeItemEl.firstElementChild;
|
10900 | const isClickOverlay = event.target === swipeItemEl;
|
10901 | const isClickImage = imageEl == null ? void 0 : imageEl.contains(event.target);
|
10902 | if (!props2.closeOnClickImage && isClickImage) return;
|
10903 | if (!props2.closeOnClickOverlay && isClickOverlay) return;
|
10904 | emit("close");
|
10905 | };
|
10906 | const checkTap = (event) => {
|
10907 | if (fingerNum > 1) {
|
10908 | return;
|
10909 | }
|
10910 | const deltaTime = Date.now() - touchStartTime;
|
10911 | const TAP_TIME = 250;
|
10912 | if (touch.isTap.value) {
|
10913 | if (deltaTime < TAP_TIME) {
|
10914 | if (props2.doubleScale) {
|
10915 | if (doubleTapTimer) {
|
10916 | clearTimeout(doubleTapTimer);
|
10917 | doubleTapTimer = null;
|
10918 | toggleScale();
|
10919 | } else {
|
10920 | doubleTapTimer = setTimeout(() => {
|
10921 | checkClose(event);
|
10922 | doubleTapTimer = null;
|
10923 | }, TAP_TIME);
|
10924 | }
|
10925 | } else {
|
10926 | checkClose(event);
|
10927 | }
|
10928 | } else if (deltaTime > LONG_PRESS_START_TIME) {
|
10929 | emit("longPress");
|
10930 | }
|
10931 | }
|
10932 | };
|
10933 | const onTouchEnd = (event) => {
|
10934 | let stopPropagation2 = false;
|
10935 | if (state.moving || state.zooming) {
|
10936 | stopPropagation2 = true;
|
10937 | if (state.moving && startMoveX === state.moveX && startMoveY === state.moveY) {
|
10938 | stopPropagation2 = false;
|
10939 | }
|
10940 | if (!event.touches.length) {
|
10941 | if (state.zooming) {
|
10942 | state.moveX = clamp(state.moveX, -maxMoveX.value, maxMoveX.value);
|
10943 | state.moveY = clamp(state.moveY, -maxMoveY.value, maxMoveY.value);
|
10944 | state.zooming = false;
|
10945 | }
|
10946 | state.moving = false;
|
10947 | startMoveX = 0;
|
10948 | startMoveY = 0;
|
10949 | startScale = 1;
|
10950 | if (state.scale < 1) {
|
10951 | resetScale();
|
10952 | }
|
10953 | const maxZoom = +props2.maxZoom;
|
10954 | if (state.scale > maxZoom) {
|
10955 | setScale(maxZoom, lastCenter);
|
10956 | }
|
10957 | }
|
10958 | }
|
10959 | preventDefault(event, stopPropagation2);
|
10960 | checkTap(event);
|
10961 | touch.reset();
|
10962 | };
|
10963 | const resize = () => {
|
10964 | const {
|
10965 | rootWidth,
|
10966 | rootHeight
|
10967 | } = props2;
|
10968 | const rootRatio = rootHeight / rootWidth;
|
10969 | const {
|
10970 | imageRatio
|
10971 | } = state;
|
10972 | vertical.value = state.imageRatio > rootRatio && imageRatio < longImageRatio;
|
10973 | isLongImage.value = state.imageRatio > rootRatio && imageRatio >= longImageRatio;
|
10974 | if (isLongImage.value) {
|
10975 | initialMoveY = (imageRatio * rootWidth - rootHeight) / 2;
|
10976 | state.moveY = initialMoveY;
|
10977 | state.initializing = true;
|
10978 | use.raf(() => {
|
10979 | state.initializing = false;
|
10980 | });
|
10981 | }
|
10982 | resetScale();
|
10983 | };
|
10984 | const onLoad = (event) => {
|
10985 | const {
|
10986 | naturalWidth,
|
10987 | naturalHeight
|
10988 | } = event.target;
|
10989 | state.imageRatio = naturalHeight / naturalWidth;
|
10990 | resize();
|
10991 | };
|
10992 | vue.watch(() => props2.active, resetScale);
|
10993 | vue.watch(() => props2.show, (value) => {
|
10994 | if (!value) {
|
10995 | resetScale();
|
10996 | }
|
10997 | });
|
10998 | vue.watch(() => [props2.rootWidth, props2.rootHeight], resize);
|
10999 | use.useEventListener("touchmove", onTouchMove, {
|
11000 | target: vue.computed(() => {
|
11001 | var _a;
|
11002 | return (_a = swipeItem.value) == null ? void 0 : _a.$el;
|
11003 | })
|
11004 | });
|
11005 | useExpose({
|
11006 | resetScale
|
11007 | });
|
11008 | return () => {
|
11009 | const imageSlots = {
|
11010 | loading: () => vue.createVNode(Loading, {
|
11011 | "type": "spinner"
|
11012 | }, null)
|
11013 | };
|
11014 | return vue.createVNode(SwipeItem, {
|
11015 | "ref": swipeItem,
|
11016 | "class": bem$E("swipe-item"),
|
11017 | "onTouchstartPassive": onTouchStart,
|
11018 | "onTouchend": onTouchEnd,
|
11019 | "onTouchcancel": onTouchEnd
|
11020 | }, {
|
11021 | default: () => [slots.image ? vue.createVNode("div", {
|
11022 | "class": bem$E("image-wrap")
|
11023 | }, [slots.image({
|
11024 | src: props2.src,
|
11025 | onLoad,
|
11026 | style: imageStyle.value
|
11027 | })]) : vue.createVNode(Image$1, {
|
11028 | "ref": imageRef,
|
11029 | "src": props2.src,
|
11030 | "fit": "contain",
|
11031 | "class": bem$E("image", {
|
11032 | vertical: vertical.value
|
11033 | }),
|
11034 | "style": imageStyle.value,
|
11035 | "onLoad": onLoad
|
11036 | }, imageSlots)]
|
11037 | });
|
11038 | };
|
11039 | }
|
11040 | });
|
11041 | const [name$E, bem$D] = createNamespace("image-preview");
|
11042 | const popupProps$1 = ["show", "teleport", "transition", "overlayStyle", "closeOnPopstate"];
|
11043 | const imagePreviewProps = {
|
11044 | show: Boolean,
|
11045 | loop: truthProp,
|
11046 | images: makeArrayProp(),
|
11047 | minZoom: makeNumericProp(1 / 3),
|
11048 | maxZoom: makeNumericProp(3),
|
11049 | overlay: truthProp,
|
11050 | vertical: Boolean,
|
11051 | closeable: Boolean,
|
11052 | showIndex: truthProp,
|
11053 | className: unknownProp,
|
11054 | closeIcon: makeStringProp("clear"),
|
11055 | transition: String,
|
11056 | beforeClose: Function,
|
11057 | doubleScale: truthProp,
|
11058 | overlayClass: unknownProp,
|
11059 | overlayStyle: Object,
|
11060 | swipeDuration: makeNumericProp(300),
|
11061 | startPosition: makeNumericProp(0),
|
11062 | showIndicators: Boolean,
|
11063 | closeOnPopstate: truthProp,
|
11064 | closeOnClickImage: truthProp,
|
11065 | closeOnClickOverlay: truthProp,
|
11066 | closeIconPosition: makeStringProp("top-right"),
|
11067 | teleport: [String, Object]
|
11068 | };
|
11069 | var stdin_default$M = vue.defineComponent({
|
11070 | name: name$E,
|
11071 | props: imagePreviewProps,
|
11072 | emits: ["scale", "close", "closed", "change", "longPress", "update:show"],
|
11073 | setup(props2, {
|
11074 | emit,
|
11075 | slots
|
11076 | }) {
|
11077 | const swipeRef = vue.ref();
|
11078 | const activedPreviewItemRef = vue.ref();
|
11079 | const state = vue.reactive({
|
11080 | active: 0,
|
11081 | rootWidth: 0,
|
11082 | rootHeight: 0,
|
11083 | disableZoom: false
|
11084 | });
|
11085 | const resize = () => {
|
11086 | if (swipeRef.value) {
|
11087 | const rect = use.useRect(swipeRef.value.$el);
|
11088 | state.rootWidth = rect.width;
|
11089 | state.rootHeight = rect.height;
|
11090 | swipeRef.value.resize();
|
11091 | }
|
11092 | };
|
11093 | const emitScale = (args) => emit("scale", args);
|
11094 | const updateShow = (show) => emit("update:show", show);
|
11095 | const emitClose = () => {
|
11096 | callInterceptor(props2.beforeClose, {
|
11097 | args: [state.active],
|
11098 | done: () => updateShow(false)
|
11099 | });
|
11100 | };
|
11101 | const setActive = (active) => {
|
11102 | if (active !== state.active) {
|
11103 | state.active = active;
|
11104 | emit("change", active);
|
11105 | }
|
11106 | };
|
11107 | const renderIndex = () => {
|
11108 | if (props2.showIndex) {
|
11109 | return vue.createVNode("div", {
|
11110 | "class": bem$D("index")
|
11111 | }, [slots.index ? slots.index({
|
11112 | index: state.active
|
11113 | }) : `${state.active + 1} / ${props2.images.length}`]);
|
11114 | }
|
11115 | };
|
11116 | const renderCover = () => {
|
11117 | if (slots.cover) {
|
11118 | return vue.createVNode("div", {
|
11119 | "class": bem$D("cover")
|
11120 | }, [slots.cover()]);
|
11121 | }
|
11122 | };
|
11123 | const onDragStart = () => {
|
11124 | state.disableZoom = true;
|
11125 | };
|
11126 | const onDragEnd = () => {
|
11127 | state.disableZoom = false;
|
11128 | };
|
11129 | const renderImages = () => vue.createVNode(Swipe, {
|
11130 | "ref": swipeRef,
|
11131 | "lazyRender": true,
|
11132 | "loop": props2.loop,
|
11133 | "class": bem$D("swipe"),
|
11134 | "vertical": props2.vertical,
|
11135 | "duration": props2.swipeDuration,
|
11136 | "initialSwipe": props2.startPosition,
|
11137 | "showIndicators": props2.showIndicators,
|
11138 | "indicatorColor": "white",
|
11139 | "onChange": setActive,
|
11140 | "onDragEnd": onDragEnd,
|
11141 | "onDragStart": onDragStart
|
11142 | }, {
|
11143 | default: () => [props2.images.map((image, index) => vue.createVNode(stdin_default$N, {
|
11144 | "ref": (item) => {
|
11145 | if (index === state.active) {
|
11146 | activedPreviewItemRef.value = item;
|
11147 | }
|
11148 | },
|
11149 | "src": image,
|
11150 | "show": props2.show,
|
11151 | "active": state.active,
|
11152 | "maxZoom": props2.maxZoom,
|
11153 | "minZoom": props2.minZoom,
|
11154 | "rootWidth": state.rootWidth,
|
11155 | "rootHeight": state.rootHeight,
|
11156 | "disableZoom": state.disableZoom,
|
11157 | "doubleScale": props2.doubleScale,
|
11158 | "closeOnClickImage": props2.closeOnClickImage,
|
11159 | "closeOnClickOverlay": props2.closeOnClickOverlay,
|
11160 | "vertical": props2.vertical,
|
11161 | "onScale": emitScale,
|
11162 | "onClose": emitClose,
|
11163 | "onLongPress": () => emit("longPress", {
|
11164 | index
|
11165 | })
|
11166 | }, {
|
11167 | image: slots.image
|
11168 | }))]
|
11169 | });
|
11170 | const renderClose = () => {
|
11171 | if (props2.closeable) {
|
11172 | return vue.createVNode(Icon, {
|
11173 | "role": "button",
|
11174 | "name": props2.closeIcon,
|
11175 | "class": [bem$D("close-icon", props2.closeIconPosition), HAPTICS_FEEDBACK],
|
11176 | "onClick": emitClose
|
11177 | }, null);
|
11178 | }
|
11179 | };
|
11180 | const onClosed = () => emit("closed");
|
11181 | const swipeTo = (index, options) => {
|
11182 | var _a;
|
11183 | return (_a = swipeRef.value) == null ? void 0 : _a.swipeTo(index, options);
|
11184 | };
|
11185 | useExpose({
|
11186 | resetScale: () => {
|
11187 | var _a;
|
11188 | (_a = activedPreviewItemRef.value) == null ? void 0 : _a.resetScale();
|
11189 | },
|
11190 | swipeTo
|
11191 | });
|
11192 | vue.onMounted(resize);
|
11193 | vue.watch([windowWidth, windowHeight], resize);
|
11194 | vue.watch(() => props2.startPosition, (value) => setActive(+value));
|
11195 | vue.watch(() => props2.show, (value) => {
|
11196 | const {
|
11197 | images,
|
11198 | startPosition
|
11199 | } = props2;
|
11200 | if (value) {
|
11201 | setActive(+startPosition);
|
11202 | vue.nextTick(() => {
|
11203 | resize();
|
11204 | swipeTo(+startPosition, {
|
11205 | immediate: true
|
11206 | });
|
11207 | });
|
11208 | } else {
|
11209 | emit("close", {
|
11210 | index: state.active,
|
11211 | url: images[state.active]
|
11212 | });
|
11213 | }
|
11214 | });
|
11215 | return () => vue.createVNode(Popup, vue.mergeProps({
|
11216 | "class": [bem$D(), props2.className],
|
11217 | "overlayClass": [bem$D("overlay"), props2.overlayClass],
|
11218 | "onClosed": onClosed,
|
11219 | "onUpdate:show": updateShow
|
11220 | }, pick(props2, popupProps$1)), {
|
11221 | default: () => [renderClose(), renderImages(), renderIndex(), renderCover()]
|
11222 | });
|
11223 | }
|
11224 | });
|
11225 | let instance$1;
|
11226 | const defaultConfig = {
|
11227 | loop: true,
|
11228 | images: [],
|
11229 | maxZoom: 3,
|
11230 | minZoom: 1 / 3,
|
11231 | onScale: void 0,
|
11232 | onClose: void 0,
|
11233 | onChange: void 0,
|
11234 | vertical: false,
|
11235 | teleport: "body",
|
11236 | className: "",
|
11237 | showIndex: true,
|
11238 | closeable: false,
|
11239 | closeIcon: "clear",
|
11240 | transition: void 0,
|
11241 | beforeClose: void 0,
|
11242 | doubleScale: true,
|
11243 | overlayStyle: void 0,
|
11244 | overlayClass: void 0,
|
11245 | startPosition: 0,
|
11246 | swipeDuration: 300,
|
11247 | showIndicators: false,
|
11248 | closeOnPopstate: true,
|
11249 | closeOnClickOverlay: true,
|
11250 | closeIconPosition: "top-right"
|
11251 | };
|
11252 | function initInstance$1() {
|
11253 | ({
|
11254 | instance: instance$1
|
11255 | } = mountComponent({
|
11256 | setup() {
|
11257 | const {
|
11258 | state,
|
11259 | toggle
|
11260 | } = usePopupState();
|
11261 | const onClosed = () => {
|
11262 | state.images = [];
|
11263 | };
|
11264 | return () => vue.createVNode(stdin_default$M, vue.mergeProps(state, {
|
11265 | "onClosed": onClosed,
|
11266 | "onUpdate:show": toggle
|
11267 | }), null);
|
11268 | }
|
11269 | }));
|
11270 | }
|
11271 | const showImagePreview = (options, startPosition = 0) => {
|
11272 | if (!inBrowser) {
|
11273 | return;
|
11274 | }
|
11275 | if (!instance$1) {
|
11276 | initInstance$1();
|
11277 | }
|
11278 | options = Array.isArray(options) ? {
|
11279 | images: options,
|
11280 | startPosition
|
11281 | } : options;
|
11282 | instance$1.open(extend({}, defaultConfig, options));
|
11283 | return instance$1;
|
11284 | };
|
11285 | const ImagePreview = withInstall(stdin_default$M);
|
11286 | function genAlphabet() {
|
11287 | const charCodeOfA = "A".charCodeAt(0);
|
11288 | const indexList = Array(26).fill("").map((_, i) => String.fromCharCode(charCodeOfA + i));
|
11289 | return indexList;
|
11290 | }
|
11291 | const [name$D, bem$C] = createNamespace("index-bar");
|
11292 | const indexBarProps = {
|
11293 | sticky: truthProp,
|
11294 | zIndex: numericProp,
|
11295 | teleport: [String, Object],
|
11296 | highlightColor: String,
|
11297 | stickyOffsetTop: makeNumberProp(0),
|
11298 | indexList: {
|
11299 | type: Array,
|
11300 | default: genAlphabet
|
11301 | }
|
11302 | };
|
11303 | const INDEX_BAR_KEY = Symbol(name$D);
|
11304 | var stdin_default$L = vue.defineComponent({
|
11305 | name: name$D,
|
11306 | props: indexBarProps,
|
11307 | emits: ["select", "change"],
|
11308 | setup(props2, {
|
11309 | emit,
|
11310 | slots
|
11311 | }) {
|
11312 | const root = vue.ref();
|
11313 | const sidebar = vue.ref();
|
11314 | const activeAnchor = vue.ref("");
|
11315 | const touch = useTouch();
|
11316 | const scrollParent = use.useScrollParent(root);
|
11317 | const {
|
11318 | children,
|
11319 | linkChildren
|
11320 | } = use.useChildren(INDEX_BAR_KEY);
|
11321 | let selectActiveIndex;
|
11322 | linkChildren({
|
11323 | props: props2
|
11324 | });
|
11325 | const sidebarStyle = vue.computed(() => {
|
11326 | if (isDef(props2.zIndex)) {
|
11327 | return {
|
11328 | zIndex: +props2.zIndex + 1
|
11329 | };
|
11330 | }
|
11331 | });
|
11332 | const highlightStyle = vue.computed(() => {
|
11333 | if (props2.highlightColor) {
|
11334 | return {
|
11335 | color: props2.highlightColor
|
11336 | };
|
11337 | }
|
11338 | });
|
11339 | const getActiveAnchor = (scrollTop, rects) => {
|
11340 | for (let i = children.length - 1; i >= 0; i--) {
|
11341 | const prevHeight = i > 0 ? rects[i - 1].height : 0;
|
11342 | const reachTop = props2.sticky ? prevHeight + props2.stickyOffsetTop : 0;
|
11343 | if (scrollTop + reachTop >= rects[i].top) {
|
11344 | return i;
|
11345 | }
|
11346 | }
|
11347 | return -1;
|
11348 | };
|
11349 | const getMatchAnchor = (index) => children.find((item) => String(item.index) === index);
|
11350 | const onScroll = () => {
|
11351 | if (isHidden(root)) {
|
11352 | return;
|
11353 | }
|
11354 | const {
|
11355 | sticky,
|
11356 | indexList
|
11357 | } = props2;
|
11358 | const scrollTop = getScrollTop(scrollParent.value);
|
11359 | const scrollParentRect = use.useRect(scrollParent);
|
11360 | const rects = children.map((item) => item.getRect(scrollParent.value, scrollParentRect));
|
11361 | let active = -1;
|
11362 | if (selectActiveIndex) {
|
11363 | const match = getMatchAnchor(selectActiveIndex);
|
11364 | if (match) {
|
11365 | const rect = match.getRect(scrollParent.value, scrollParentRect);
|
11366 | if (props2.sticky && props2.stickyOffsetTop) {
|
11367 | active = getActiveAnchor(rect.top - props2.stickyOffsetTop, rects);
|
11368 | } else {
|
11369 | active = getActiveAnchor(rect.top, rects);
|
11370 | }
|
11371 | }
|
11372 | } else {
|
11373 | active = getActiveAnchor(scrollTop, rects);
|
11374 | }
|
11375 | activeAnchor.value = indexList[active];
|
11376 | if (sticky) {
|
11377 | children.forEach((item, index) => {
|
11378 | const {
|
11379 | state,
|
11380 | $el
|
11381 | } = item;
|
11382 | if (index === active || index === active - 1) {
|
11383 | const rect = $el.getBoundingClientRect();
|
11384 | state.left = rect.left;
|
11385 | state.width = rect.width;
|
11386 | } else {
|
11387 | state.left = null;
|
11388 | state.width = null;
|
11389 | }
|
11390 | if (index === active) {
|
11391 | state.active = true;
|
11392 | state.top = Math.max(props2.stickyOffsetTop, rects[index].top - scrollTop) + scrollParentRect.top;
|
11393 | } else if (index === active - 1 && selectActiveIndex === "") {
|
11394 | const activeItemTop = rects[active].top - scrollTop;
|
11395 | state.active = activeItemTop > 0;
|
11396 | state.top = activeItemTop + scrollParentRect.top - rects[index].height;
|
11397 | } else {
|
11398 | state.active = false;
|
11399 | }
|
11400 | });
|
11401 | }
|
11402 | selectActiveIndex = "";
|
11403 | };
|
11404 | const init = () => {
|
11405 | vue.nextTick(onScroll);
|
11406 | };
|
11407 | use.useEventListener("scroll", onScroll, {
|
11408 | target: scrollParent,
|
11409 | passive: true
|
11410 | });
|
11411 | vue.onMounted(init);
|
11412 | vue.watch(() => props2.indexList, init);
|
11413 | vue.watch(activeAnchor, (value) => {
|
11414 | if (value) {
|
11415 | emit("change", value);
|
11416 | }
|
11417 | });
|
11418 | const renderIndexes = () => props2.indexList.map((index) => {
|
11419 | const active = index === activeAnchor.value;
|
11420 | return vue.createVNode("span", {
|
11421 | "class": bem$C("index", {
|
11422 | active
|
11423 | }),
|
11424 | "style": active ? highlightStyle.value : void 0,
|
11425 | "data-index": index
|
11426 | }, [index]);
|
11427 | });
|
11428 | const scrollTo = (index) => {
|
11429 | selectActiveIndex = String(index);
|
11430 | const match = getMatchAnchor(selectActiveIndex);
|
11431 | if (match) {
|
11432 | const scrollTop = getScrollTop(scrollParent.value);
|
11433 | const scrollParentRect = use.useRect(scrollParent);
|
11434 | const {
|
11435 | offsetHeight
|
11436 | } = document.documentElement;
|
11437 | match.$el.scrollIntoView();
|
11438 | if (scrollTop === offsetHeight - scrollParentRect.height) {
|
11439 | onScroll();
|
11440 | return;
|
11441 | }
|
11442 | if (props2.sticky && props2.stickyOffsetTop) {
|
11443 | if (getRootScrollTop() === offsetHeight - scrollParentRect.height) {
|
11444 | setRootScrollTop(getRootScrollTop());
|
11445 | } else {
|
11446 | setRootScrollTop(getRootScrollTop() - props2.stickyOffsetTop);
|
11447 | }
|
11448 | }
|
11449 | emit("select", match.index);
|
11450 | }
|
11451 | };
|
11452 | const scrollToElement = (element) => {
|
11453 | const {
|
11454 | index
|
11455 | } = element.dataset;
|
11456 | if (index) {
|
11457 | scrollTo(index);
|
11458 | }
|
11459 | };
|
11460 | const onClickSidebar = (event) => {
|
11461 | scrollToElement(event.target);
|
11462 | };
|
11463 | let touchActiveIndex;
|
11464 | const onTouchMove = (event) => {
|
11465 | touch.move(event);
|
11466 | if (touch.isVertical()) {
|
11467 | preventDefault(event);
|
11468 | const {
|
11469 | clientX,
|
11470 | clientY
|
11471 | } = event.touches[0];
|
11472 | const target = document.elementFromPoint(clientX, clientY);
|
11473 | if (target) {
|
11474 | const {
|
11475 | index
|
11476 | } = target.dataset;
|
11477 | if (index && touchActiveIndex !== index) {
|
11478 | touchActiveIndex = index;
|
11479 | scrollToElement(target);
|
11480 | }
|
11481 | }
|
11482 | }
|
11483 | };
|
11484 | const renderSidebar = () => vue.createVNode("div", {
|
11485 | "ref": sidebar,
|
11486 | "class": bem$C("sidebar"),
|
11487 | "style": sidebarStyle.value,
|
11488 | "onClick": onClickSidebar,
|
11489 | "onTouchstartPassive": touch.start
|
11490 | }, [renderIndexes()]);
|
11491 | useExpose({
|
11492 | scrollTo
|
11493 | });
|
11494 | use.useEventListener("touchmove", onTouchMove, {
|
11495 | target: sidebar
|
11496 | });
|
11497 | return () => {
|
11498 | var _a;
|
11499 | return vue.createVNode("div", {
|
11500 | "ref": root,
|
11501 | "class": bem$C()
|
11502 | }, [props2.teleport ? vue.createVNode(vue.Teleport, {
|
11503 | "to": props2.teleport
|
11504 | }, {
|
11505 | default: () => [renderSidebar()]
|
11506 | }) : renderSidebar(), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
11507 | };
|
11508 | }
|
11509 | });
|
11510 | const [name$C, bem$B] = createNamespace("index-anchor");
|
11511 | const indexAnchorProps = {
|
11512 | index: numericProp
|
11513 | };
|
11514 | var stdin_default$K = vue.defineComponent({
|
11515 | name: name$C,
|
11516 | props: indexAnchorProps,
|
11517 | setup(props2, {
|
11518 | slots
|
11519 | }) {
|
11520 | const state = vue.reactive({
|
11521 | top: 0,
|
11522 | left: null,
|
11523 | rect: {
|
11524 | top: 0,
|
11525 | height: 0
|
11526 | },
|
11527 | width: null,
|
11528 | active: false
|
11529 | });
|
11530 | const root = vue.ref();
|
11531 | const {
|
11532 | parent
|
11533 | } = use.useParent(INDEX_BAR_KEY);
|
11534 | if (!parent) {
|
11535 | if (process.env.NODE_ENV !== "production") {
|
11536 | console.error("[Vant] <IndexAnchor> must be a child component of <IndexBar>.");
|
11537 | }
|
11538 | return;
|
11539 | }
|
11540 | const isSticky = () => state.active && parent.props.sticky;
|
11541 | const anchorStyle = vue.computed(() => {
|
11542 | const {
|
11543 | zIndex,
|
11544 | highlightColor
|
11545 | } = parent.props;
|
11546 | if (isSticky()) {
|
11547 | return extend(getZIndexStyle(zIndex), {
|
11548 | left: state.left ? `${state.left}px` : void 0,
|
11549 | width: state.width ? `${state.width}px` : void 0,
|
11550 | transform: state.top ? `translate3d(0, ${state.top}px, 0)` : void 0,
|
11551 | color: highlightColor
|
11552 | });
|
11553 | }
|
11554 | });
|
11555 | const getRect = (scrollParent, scrollParentRect) => {
|
11556 | const rootRect = use.useRect(root);
|
11557 | state.rect.height = rootRect.height;
|
11558 | if (scrollParent === window || scrollParent === document.body) {
|
11559 | state.rect.top = rootRect.top + getRootScrollTop();
|
11560 | } else {
|
11561 | state.rect.top = rootRect.top + getScrollTop(scrollParent) - scrollParentRect.top;
|
11562 | }
|
11563 | return state.rect;
|
11564 | };
|
11565 | useExpose({
|
11566 | state,
|
11567 | getRect
|
11568 | });
|
11569 | return () => {
|
11570 | const sticky = isSticky();
|
11571 | return vue.createVNode("div", {
|
11572 | "ref": root,
|
11573 | "style": {
|
11574 | height: sticky ? `${state.rect.height}px` : void 0
|
11575 | }
|
11576 | }, [vue.createVNode("div", {
|
11577 | "style": anchorStyle.value,
|
11578 | "class": [bem$B({
|
11579 | sticky
|
11580 | }), {
|
11581 | [BORDER_BOTTOM]: sticky
|
11582 | }]
|
11583 | }, [slots.default ? slots.default() : props2.index])]);
|
11584 | };
|
11585 | }
|
11586 | });
|
11587 | const IndexAnchor = withInstall(stdin_default$K);
|
11588 | const IndexBar = withInstall(stdin_default$L);
|
11589 | const [name$B, bem$A, t$7] = createNamespace("list");
|
11590 | const listProps = {
|
11591 | error: Boolean,
|
11592 | offset: makeNumericProp(300),
|
11593 | loading: Boolean,
|
11594 | disabled: Boolean,
|
11595 | finished: Boolean,
|
11596 | scroller: Object,
|
11597 | errorText: String,
|
11598 | direction: makeStringProp("down"),
|
11599 | loadingText: String,
|
11600 | finishedText: String,
|
11601 | immediateCheck: truthProp
|
11602 | };
|
11603 | var stdin_default$J = vue.defineComponent({
|
11604 | name: name$B,
|
11605 | props: listProps,
|
11606 | emits: ["load", "update:error", "update:loading"],
|
11607 | setup(props2, {
|
11608 | emit,
|
11609 | slots
|
11610 | }) {
|
11611 | const loading = vue.ref(props2.loading);
|
11612 | const root = vue.ref();
|
11613 | const placeholder = vue.ref();
|
11614 | const tabStatus = useTabStatus();
|
11615 | const scrollParent = use.useScrollParent(root);
|
11616 | const scroller = vue.computed(() => props2.scroller || scrollParent.value);
|
11617 | const check = () => {
|
11618 | vue.nextTick(() => {
|
11619 | if (loading.value || props2.finished || props2.disabled || props2.error ||
|
11620 | (tabStatus == null ? void 0 : tabStatus.value) === false) {
|
11621 | return;
|
11622 | }
|
11623 | const {
|
11624 | direction
|
11625 | } = props2;
|
11626 | const offset = +props2.offset;
|
11627 | const scrollParentRect = use.useRect(scroller);
|
11628 | if (!scrollParentRect.height || isHidden(root)) {
|
11629 | return;
|
11630 | }
|
11631 | let isReachEdge = false;
|
11632 | const placeholderRect = use.useRect(placeholder);
|
11633 | if (direction === "up") {
|
11634 | isReachEdge = scrollParentRect.top - placeholderRect.top <= offset;
|
11635 | } else {
|
11636 | isReachEdge = placeholderRect.bottom - scrollParentRect.bottom <= offset;
|
11637 | }
|
11638 | if (isReachEdge) {
|
11639 | loading.value = true;
|
11640 | emit("update:loading", true);
|
11641 | emit("load");
|
11642 | }
|
11643 | });
|
11644 | };
|
11645 | const renderFinishedText = () => {
|
11646 | if (props2.finished) {
|
11647 | const text = slots.finished ? slots.finished() : props2.finishedText;
|
11648 | if (text) {
|
11649 | return vue.createVNode("div", {
|
11650 | "class": bem$A("finished-text")
|
11651 | }, [text]);
|
11652 | }
|
11653 | }
|
11654 | };
|
11655 | const clickErrorText = () => {
|
11656 | emit("update:error", false);
|
11657 | check();
|
11658 | };
|
11659 | const renderErrorText = () => {
|
11660 | if (props2.error) {
|
11661 | const text = slots.error ? slots.error() : props2.errorText;
|
11662 | if (text) {
|
11663 | return vue.createVNode("div", {
|
11664 | "role": "button",
|
11665 | "class": bem$A("error-text"),
|
11666 | "tabindex": 0,
|
11667 | "onClick": clickErrorText
|
11668 | }, [text]);
|
11669 | }
|
11670 | }
|
11671 | };
|
11672 | const renderLoading = () => {
|
11673 | if (loading.value && !props2.finished && !props2.disabled) {
|
11674 | return vue.createVNode("div", {
|
11675 | "class": bem$A("loading")
|
11676 | }, [slots.loading ? slots.loading() : vue.createVNode(Loading, {
|
11677 | "class": bem$A("loading-icon")
|
11678 | }, {
|
11679 | default: () => [props2.loadingText || t$7("loading")]
|
11680 | })]);
|
11681 | }
|
11682 | };
|
11683 | vue.watch(() => [props2.loading, props2.finished, props2.error], check);
|
11684 | if (tabStatus) {
|
11685 | vue.watch(tabStatus, (tabActive) => {
|
11686 | if (tabActive) {
|
11687 | check();
|
11688 | }
|
11689 | });
|
11690 | }
|
11691 | vue.onUpdated(() => {
|
11692 | loading.value = props2.loading;
|
11693 | });
|
11694 | vue.onMounted(() => {
|
11695 | if (props2.immediateCheck) {
|
11696 | check();
|
11697 | }
|
11698 | });
|
11699 | useExpose({
|
11700 | check
|
11701 | });
|
11702 | use.useEventListener("scroll", check, {
|
11703 | target: scroller,
|
11704 | passive: true
|
11705 | });
|
11706 | return () => {
|
11707 | var _a;
|
11708 | const Content = (_a = slots.default) == null ? void 0 : _a.call(slots);
|
11709 | const Placeholder = vue.createVNode("div", {
|
11710 | "ref": placeholder,
|
11711 | "class": bem$A("placeholder")
|
11712 | }, null);
|
11713 | return vue.createVNode("div", {
|
11714 | "ref": root,
|
11715 | "role": "feed",
|
11716 | "class": bem$A(),
|
11717 | "aria-busy": loading.value
|
11718 | }, [props2.direction === "down" ? Content : Placeholder, renderLoading(), renderFinishedText(), renderErrorText(), props2.direction === "up" ? Content : Placeholder]);
|
11719 | };
|
11720 | }
|
11721 | });
|
11722 | const List = withInstall(stdin_default$J);
|
11723 | const [name$A, bem$z] = createNamespace("nav-bar");
|
11724 | const navBarProps = {
|
11725 | title: String,
|
11726 | fixed: Boolean,
|
11727 | zIndex: numericProp,
|
11728 | border: truthProp,
|
11729 | leftText: String,
|
11730 | rightText: String,
|
11731 | leftDisabled: Boolean,
|
11732 | rightDisabled: Boolean,
|
11733 | leftArrow: Boolean,
|
11734 | placeholder: Boolean,
|
11735 | safeAreaInsetTop: Boolean,
|
11736 | clickable: truthProp
|
11737 | };
|
11738 | var stdin_default$I = vue.defineComponent({
|
11739 | name: name$A,
|
11740 | props: navBarProps,
|
11741 | emits: ["clickLeft", "clickRight"],
|
11742 | setup(props2, {
|
11743 | emit,
|
11744 | slots
|
11745 | }) {
|
11746 | const navBarRef = vue.ref();
|
11747 | const renderPlaceholder = usePlaceholder(navBarRef, bem$z);
|
11748 | const onClickLeft = (event) => {
|
11749 | if (!props2.leftDisabled) {
|
11750 | emit("clickLeft", event);
|
11751 | }
|
11752 | };
|
11753 | const onClickRight = (event) => {
|
11754 | if (!props2.rightDisabled) {
|
11755 | emit("clickRight", event);
|
11756 | }
|
11757 | };
|
11758 | const renderLeft = () => {
|
11759 | if (slots.left) {
|
11760 | return slots.left();
|
11761 | }
|
11762 | return [props2.leftArrow && vue.createVNode(Icon, {
|
11763 | "class": bem$z("arrow"),
|
11764 | "name": "arrow-left"
|
11765 | }, null), props2.leftText && vue.createVNode("span", {
|
11766 | "class": bem$z("text")
|
11767 | }, [props2.leftText])];
|
11768 | };
|
11769 | const renderRight = () => {
|
11770 | if (slots.right) {
|
11771 | return slots.right();
|
11772 | }
|
11773 | return vue.createVNode("span", {
|
11774 | "class": bem$z("text")
|
11775 | }, [props2.rightText]);
|
11776 | };
|
11777 | const renderNavBar = () => {
|
11778 | const {
|
11779 | title,
|
11780 | fixed,
|
11781 | border,
|
11782 | zIndex
|
11783 | } = props2;
|
11784 | const style = getZIndexStyle(zIndex);
|
11785 | const hasLeft = props2.leftArrow || props2.leftText || slots.left;
|
11786 | const hasRight = props2.rightText || slots.right;
|
11787 | return vue.createVNode("div", {
|
11788 | "ref": navBarRef,
|
11789 | "style": style,
|
11790 | "class": [bem$z({
|
11791 | fixed
|
11792 | }), {
|
11793 | [BORDER_BOTTOM]: border,
|
11794 | "van-safe-area-top": props2.safeAreaInsetTop
|
11795 | }]
|
11796 | }, [vue.createVNode("div", {
|
11797 | "class": bem$z("content")
|
11798 | }, [hasLeft && vue.createVNode("div", {
|
11799 | "class": [bem$z("left", {
|
11800 | disabled: props2.leftDisabled
|
11801 | }), props2.clickable && !props2.leftDisabled ? HAPTICS_FEEDBACK : ""],
|
11802 | "onClick": onClickLeft
|
11803 | }, [renderLeft()]), vue.createVNode("div", {
|
11804 | "class": [bem$z("title"), "van-ellipsis"]
|
11805 | }, [slots.title ? slots.title() : title]), hasRight && vue.createVNode("div", {
|
11806 | "class": [bem$z("right", {
|
11807 | disabled: props2.rightDisabled
|
11808 | }), props2.clickable && !props2.rightDisabled ? HAPTICS_FEEDBACK : ""],
|
11809 | "onClick": onClickRight
|
11810 | }, [renderRight()])])]);
|
11811 | };
|
11812 | return () => {
|
11813 | if (props2.fixed && props2.placeholder) {
|
11814 | return renderPlaceholder(renderNavBar);
|
11815 | }
|
11816 | return renderNavBar();
|
11817 | };
|
11818 | }
|
11819 | });
|
11820 | const NavBar = withInstall(stdin_default$I);
|
11821 | const [name$z, bem$y] = createNamespace("notice-bar");
|
11822 | const noticeBarProps = {
|
11823 | text: String,
|
11824 | mode: String,
|
11825 | color: String,
|
11826 | delay: makeNumericProp(1),
|
11827 | speed: makeNumericProp(60),
|
11828 | leftIcon: String,
|
11829 | wrapable: Boolean,
|
11830 | background: String,
|
11831 | scrollable: {
|
11832 | type: Boolean,
|
11833 | default: null
|
11834 | }
|
11835 | };
|
11836 | var stdin_default$H = vue.defineComponent({
|
11837 | name: name$z,
|
11838 | props: noticeBarProps,
|
11839 | emits: ["close", "replay"],
|
11840 | setup(props2, {
|
11841 | emit,
|
11842 | slots
|
11843 | }) {
|
11844 | let wrapWidth = 0;
|
11845 | let contentWidth = 0;
|
11846 | let startTimer;
|
11847 | const wrapRef = vue.ref();
|
11848 | const contentRef = vue.ref();
|
11849 | const state = vue.reactive({
|
11850 | show: true,
|
11851 | offset: 0,
|
11852 | duration: 0
|
11853 | });
|
11854 | const renderLeftIcon = () => {
|
11855 | if (slots["left-icon"]) {
|
11856 | return slots["left-icon"]();
|
11857 | }
|
11858 | if (props2.leftIcon) {
|
11859 | return vue.createVNode(Icon, {
|
11860 | "class": bem$y("left-icon"),
|
11861 | "name": props2.leftIcon
|
11862 | }, null);
|
11863 | }
|
11864 | };
|
11865 | const getRightIconName = () => {
|
11866 | if (props2.mode === "closeable") {
|
11867 | return "cross";
|
11868 | }
|
11869 | if (props2.mode === "link") {
|
11870 | return "arrow";
|
11871 | }
|
11872 | };
|
11873 | const onClickRightIcon = (event) => {
|
11874 | if (props2.mode === "closeable") {
|
11875 | state.show = false;
|
11876 | emit("close", event);
|
11877 | }
|
11878 | };
|
11879 | const renderRightIcon = () => {
|
11880 | if (slots["right-icon"]) {
|
11881 | return slots["right-icon"]();
|
11882 | }
|
11883 | const name2 = getRightIconName();
|
11884 | if (name2) {
|
11885 | return vue.createVNode(Icon, {
|
11886 | "name": name2,
|
11887 | "class": bem$y("right-icon"),
|
11888 | "onClick": onClickRightIcon
|
11889 | }, null);
|
11890 | }
|
11891 | };
|
11892 | const onTransitionEnd = () => {
|
11893 | state.offset = wrapWidth;
|
11894 | state.duration = 0;
|
11895 | use.raf(() => {
|
11896 | use.doubleRaf(() => {
|
11897 | state.offset = -contentWidth;
|
11898 | state.duration = (contentWidth + wrapWidth) / +props2.speed;
|
11899 | emit("replay");
|
11900 | });
|
11901 | });
|
11902 | };
|
11903 | const renderMarquee = () => {
|
11904 | const ellipsis = props2.scrollable === false && !props2.wrapable;
|
11905 | const style = {
|
11906 | transform: state.offset ? `translateX(${state.offset}px)` : "",
|
11907 | transitionDuration: `${state.duration}s`
|
11908 | };
|
11909 | return vue.createVNode("div", {
|
11910 | "ref": wrapRef,
|
11911 | "role": "marquee",
|
11912 | "class": bem$y("wrap")
|
11913 | }, [vue.createVNode("div", {
|
11914 | "ref": contentRef,
|
11915 | "style": style,
|
11916 | "class": [bem$y("content"), {
|
11917 | "van-ellipsis": ellipsis
|
11918 | }],
|
11919 | "onTransitionend": onTransitionEnd
|
11920 | }, [slots.default ? slots.default() : props2.text])]);
|
11921 | };
|
11922 | const reset = () => {
|
11923 | const {
|
11924 | delay,
|
11925 | speed,
|
11926 | scrollable
|
11927 | } = props2;
|
11928 | const ms = isDef(delay) ? +delay * 1e3 : 0;
|
11929 | wrapWidth = 0;
|
11930 | contentWidth = 0;
|
11931 | state.offset = 0;
|
11932 | state.duration = 0;
|
11933 | clearTimeout(startTimer);
|
11934 | startTimer = setTimeout(() => {
|
11935 | if (!wrapRef.value || !contentRef.value || scrollable === false) {
|
11936 | return;
|
11937 | }
|
11938 | const wrapRefWidth = use.useRect(wrapRef).width;
|
11939 | const contentRefWidth = use.useRect(contentRef).width;
|
11940 | if (scrollable || contentRefWidth > wrapRefWidth) {
|
11941 | use.doubleRaf(() => {
|
11942 | wrapWidth = wrapRefWidth;
|
11943 | contentWidth = contentRefWidth;
|
11944 | state.offset = -contentWidth;
|
11945 | state.duration = contentWidth / +speed;
|
11946 | });
|
11947 | }
|
11948 | }, ms);
|
11949 | };
|
11950 | onPopupReopen(reset);
|
11951 | use.onMountedOrActivated(reset);
|
11952 | use.useEventListener("pageshow", reset);
|
11953 | useExpose({
|
11954 | reset
|
11955 | });
|
11956 | vue.watch(() => [props2.text, props2.scrollable], reset);
|
11957 | return () => {
|
11958 | const {
|
11959 | color,
|
11960 | wrapable,
|
11961 | background
|
11962 | } = props2;
|
11963 | return vue.withDirectives(vue.createVNode("div", {
|
11964 | "role": "alert",
|
11965 | "class": bem$y({
|
11966 | wrapable
|
11967 | }),
|
11968 | "style": {
|
11969 | color,
|
11970 | background
|
11971 | }
|
11972 | }, [renderLeftIcon(), renderMarquee(), renderRightIcon()]), [[vue.vShow, state.show]]);
|
11973 | };
|
11974 | }
|
11975 | });
|
11976 | const NoticeBar = withInstall(stdin_default$H);
|
11977 | const [name$y, bem$x] = createNamespace("notify");
|
11978 | const popupInheritProps = ["lockScroll", "position", "show", "teleport", "zIndex"];
|
11979 | const notifyProps = extend({}, popupSharedProps, {
|
11980 | type: makeStringProp("danger"),
|
11981 | color: String,
|
11982 | message: numericProp,
|
11983 | position: makeStringProp("top"),
|
11984 | className: unknownProp,
|
11985 | background: String,
|
11986 | lockScroll: Boolean
|
11987 | });
|
11988 | var stdin_default$G = vue.defineComponent({
|
11989 | name: name$y,
|
11990 | props: notifyProps,
|
11991 | emits: ["update:show"],
|
11992 | setup(props2, {
|
11993 | emit,
|
11994 | slots
|
11995 | }) {
|
11996 | const updateShow = (show) => emit("update:show", show);
|
11997 | return () => vue.createVNode(Popup, vue.mergeProps({
|
11998 | "class": [bem$x([props2.type]), props2.className],
|
11999 | "style": {
|
12000 | color: props2.color,
|
12001 | background: props2.background
|
12002 | },
|
12003 | "overlay": false,
|
12004 | "duration": 0.2,
|
12005 | "onUpdate:show": updateShow
|
12006 | }, pick(props2, popupInheritProps)), {
|
12007 | default: () => [slots.default ? slots.default() : props2.message]
|
12008 | });
|
12009 | }
|
12010 | });
|
12011 | let timer;
|
12012 | let instance;
|
12013 | const parseOptions = (message) => isObject(message) ? message : {
|
12014 | message
|
12015 | };
|
12016 | function initInstance() {
|
12017 | ({
|
12018 | instance
|
12019 | } = mountComponent({
|
12020 | setup() {
|
12021 | const {
|
12022 | state,
|
12023 | toggle
|
12024 | } = usePopupState();
|
12025 | return () => vue.createVNode(stdin_default$G, vue.mergeProps(state, {
|
12026 | "onUpdate:show": toggle
|
12027 | }), null);
|
12028 | }
|
12029 | }));
|
12030 | }
|
12031 | const getDefaultOptions = () => ({
|
12032 | type: "danger",
|
12033 | color: void 0,
|
12034 | message: "",
|
12035 | onClose: void 0,
|
12036 | onClick: void 0,
|
12037 | onOpened: void 0,
|
12038 | duration: 3e3,
|
12039 | position: void 0,
|
12040 | className: "",
|
12041 | lockScroll: false,
|
12042 | background: void 0
|
12043 | });
|
12044 | let currentOptions = getDefaultOptions();
|
12045 | const closeNotify = () => {
|
12046 | if (instance) {
|
12047 | instance.toggle(false);
|
12048 | }
|
12049 | };
|
12050 | function showNotify(options) {
|
12051 | if (!inBrowser) {
|
12052 | return;
|
12053 | }
|
12054 | if (!instance) {
|
12055 | initInstance();
|
12056 | }
|
12057 | options = extend({}, currentOptions, parseOptions(options));
|
12058 | instance.open(options);
|
12059 | clearTimeout(timer);
|
12060 | if (options.duration > 0) {
|
12061 | timer = setTimeout(closeNotify, options.duration);
|
12062 | }
|
12063 | return instance;
|
12064 | }
|
12065 | const setNotifyDefaultOptions = (options) => extend(currentOptions, options);
|
12066 | const resetNotifyDefaultOptions = () => {
|
12067 | currentOptions = getDefaultOptions();
|
12068 | };
|
12069 | const Notify = withInstall(stdin_default$G);
|
12070 | const [name$x, bem$w] = createNamespace("key");
|
12071 | const CollapseIcon = vue.createVNode("svg", {
|
12072 | "class": bem$w("collapse-icon"),
|
12073 | "viewBox": "0 0 30 24"
|
12074 | }, [vue.createVNode("path", {
|
12075 | "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",
|
12076 | "fill": "currentColor"
|
12077 | }, null)]);
|
12078 | const DeleteIcon = vue.createVNode("svg", {
|
12079 | "class": bem$w("delete-icon"),
|
12080 | "viewBox": "0 0 32 22"
|
12081 | }, [vue.createVNode("path", {
|
12082 | "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",
|
12083 | "fill": "currentColor"
|
12084 | }, null)]);
|
12085 | var stdin_default$F = vue.defineComponent({
|
12086 | name: name$x,
|
12087 | props: {
|
12088 | type: String,
|
12089 | text: numericProp,
|
12090 | color: String,
|
12091 | wider: Boolean,
|
12092 | large: Boolean,
|
12093 | loading: Boolean
|
12094 | },
|
12095 | emits: ["press"],
|
12096 | setup(props2, {
|
12097 | emit,
|
12098 | slots
|
12099 | }) {
|
12100 | const active = vue.ref(false);
|
12101 | const touch = useTouch();
|
12102 | const onTouchStart = (event) => {
|
12103 | touch.start(event);
|
12104 | active.value = true;
|
12105 | };
|
12106 | const onTouchMove = (event) => {
|
12107 | touch.move(event);
|
12108 | if (touch.direction.value) {
|
12109 | active.value = false;
|
12110 | }
|
12111 | };
|
12112 | const onTouchEnd = (event) => {
|
12113 | if (active.value) {
|
12114 | if (!slots.default) {
|
12115 | preventDefault(event);
|
12116 | }
|
12117 | active.value = false;
|
12118 | emit("press", props2.text, props2.type);
|
12119 | }
|
12120 | };
|
12121 | const renderContent = () => {
|
12122 | if (props2.loading) {
|
12123 | return vue.createVNode(Loading, {
|
12124 | "class": bem$w("loading-icon")
|
12125 | }, null);
|
12126 | }
|
12127 | const text = slots.default ? slots.default() : props2.text;
|
12128 | switch (props2.type) {
|
12129 | case "delete":
|
12130 | return text || DeleteIcon;
|
12131 | case "extra":
|
12132 | return text || CollapseIcon;
|
12133 | default:
|
12134 | return text;
|
12135 | }
|
12136 | };
|
12137 | return () => vue.createVNode("div", {
|
12138 | "class": bem$w("wrapper", {
|
12139 | wider: props2.wider
|
12140 | }),
|
12141 | "onTouchstartPassive": onTouchStart,
|
12142 | "onTouchmovePassive": onTouchMove,
|
12143 | "onTouchend": onTouchEnd,
|
12144 | "onTouchcancel": onTouchEnd
|
12145 | }, [vue.createVNode("div", {
|
12146 | "role": "button",
|
12147 | "tabindex": 0,
|
12148 | "class": bem$w([props2.color, {
|
12149 | large: props2.large,
|
12150 | active: active.value,
|
12151 | delete: props2.type === "delete"
|
12152 | }])
|
12153 | }, [renderContent()])]);
|
12154 | }
|
12155 | });
|
12156 | const [name$w, bem$v] = createNamespace("number-keyboard");
|
12157 | const numberKeyboardProps = {
|
12158 | show: Boolean,
|
12159 | title: String,
|
12160 | theme: makeStringProp("default"),
|
12161 | zIndex: numericProp,
|
12162 | teleport: [String, Object],
|
12163 | maxlength: makeNumericProp(Infinity),
|
12164 | modelValue: makeStringProp(""),
|
12165 | transition: truthProp,
|
12166 | blurOnClose: truthProp,
|
12167 | showDeleteKey: truthProp,
|
12168 | randomKeyOrder: Boolean,
|
12169 | closeButtonText: String,
|
12170 | deleteButtonText: String,
|
12171 | closeButtonLoading: Boolean,
|
12172 | hideOnClickOutside: truthProp,
|
12173 | safeAreaInsetBottom: truthProp,
|
12174 | extraKey: {
|
12175 | type: [String, Array],
|
12176 | default: ""
|
12177 | }
|
12178 | };
|
12179 | function shuffle(array) {
|
12180 | for (let i = array.length - 1; i > 0; i--) {
|
12181 | const j = Math.floor(Math.random() * (i + 1));
|
12182 | const temp = array[i];
|
12183 | array[i] = array[j];
|
12184 | array[j] = temp;
|
12185 | }
|
12186 | return array;
|
12187 | }
|
12188 | var stdin_default$E = vue.defineComponent({
|
12189 | name: name$w,
|
12190 | inheritAttrs: false,
|
12191 | props: numberKeyboardProps,
|
12192 | emits: ["show", "hide", "blur", "input", "close", "delete", "update:modelValue"],
|
12193 | setup(props2, {
|
12194 | emit,
|
12195 | slots,
|
12196 | attrs
|
12197 | }) {
|
12198 | const root = vue.ref();
|
12199 | const genBasicKeys = () => {
|
12200 | const keys2 = Array(9).fill("").map((_, i) => ({
|
12201 | text: i + 1
|
12202 | }));
|
12203 | if (props2.randomKeyOrder) {
|
12204 | shuffle(keys2);
|
12205 | }
|
12206 | return keys2;
|
12207 | };
|
12208 | const genDefaultKeys = () => [...genBasicKeys(), {
|
12209 | text: props2.extraKey,
|
12210 | type: "extra"
|
12211 | }, {
|
12212 | text: 0
|
12213 | }, {
|
12214 | text: props2.showDeleteKey ? props2.deleteButtonText : "",
|
12215 | type: props2.showDeleteKey ? "delete" : ""
|
12216 | }];
|
12217 | const genCustomKeys = () => {
|
12218 | const keys2 = genBasicKeys();
|
12219 | const {
|
12220 | extraKey
|
12221 | } = props2;
|
12222 | const extraKeys = Array.isArray(extraKey) ? extraKey : [extraKey];
|
12223 | if (extraKeys.length === 0) {
|
12224 | keys2.push({
|
12225 | text: 0,
|
12226 | wider: true
|
12227 | });
|
12228 | } else if (extraKeys.length === 1) {
|
12229 | keys2.push({
|
12230 | text: 0,
|
12231 | wider: true
|
12232 | }, {
|
12233 | text: extraKeys[0],
|
12234 | type: "extra"
|
12235 | });
|
12236 | } else if (extraKeys.length === 2) {
|
12237 | keys2.push({
|
12238 | text: extraKeys[0],
|
12239 | type: "extra"
|
12240 | }, {
|
12241 | text: 0
|
12242 | }, {
|
12243 | text: extraKeys[1],
|
12244 | type: "extra"
|
12245 | });
|
12246 | }
|
12247 | return keys2;
|
12248 | };
|
12249 | const keys = vue.computed(() => props2.theme === "custom" ? genCustomKeys() : genDefaultKeys());
|
12250 | const onBlur = () => {
|
12251 | if (props2.show) {
|
12252 | emit("blur");
|
12253 | }
|
12254 | };
|
12255 | const onClose = () => {
|
12256 | emit("close");
|
12257 | if (props2.blurOnClose) {
|
12258 | onBlur();
|
12259 | }
|
12260 | };
|
12261 | const onAnimationEnd = () => emit(props2.show ? "show" : "hide");
|
12262 | const onPress = (text, type) => {
|
12263 | if (text === "") {
|
12264 | if (type === "extra") {
|
12265 | onBlur();
|
12266 | }
|
12267 | return;
|
12268 | }
|
12269 | const value = props2.modelValue;
|
12270 | if (type === "delete") {
|
12271 | emit("delete");
|
12272 | emit("update:modelValue", value.slice(0, value.length - 1));
|
12273 | } else if (type === "close") {
|
12274 | onClose();
|
12275 | } else if (value.length < +props2.maxlength) {
|
12276 | emit("input", text);
|
12277 | emit("update:modelValue", value + text);
|
12278 | }
|
12279 | };
|
12280 | const renderTitle = () => {
|
12281 | const {
|
12282 | title,
|
12283 | theme,
|
12284 | closeButtonText
|
12285 | } = props2;
|
12286 | const leftSlot = slots["title-left"];
|
12287 | const showClose = closeButtonText && theme === "default";
|
12288 | const showTitle = title || showClose || leftSlot;
|
12289 | if (!showTitle) {
|
12290 | return;
|
12291 | }
|
12292 | return vue.createVNode("div", {
|
12293 | "class": bem$v("header")
|
12294 | }, [leftSlot && vue.createVNode("span", {
|
12295 | "class": bem$v("title-left")
|
12296 | }, [leftSlot()]), title && vue.createVNode("h2", {
|
12297 | "class": bem$v("title")
|
12298 | }, [title]), showClose && vue.createVNode("button", {
|
12299 | "type": "button",
|
12300 | "class": [bem$v("close"), HAPTICS_FEEDBACK],
|
12301 | "onClick": onClose
|
12302 | }, [closeButtonText])]);
|
12303 | };
|
12304 | const renderKeys = () => keys.value.map((key) => {
|
12305 | const keySlots = {};
|
12306 | if (key.type === "delete") {
|
12307 | keySlots.default = slots.delete;
|
12308 | }
|
12309 | if (key.type === "extra") {
|
12310 | keySlots.default = slots["extra-key"];
|
12311 | }
|
12312 | return vue.createVNode(stdin_default$F, {
|
12313 | "key": key.text,
|
12314 | "text": key.text,
|
12315 | "type": key.type,
|
12316 | "wider": key.wider,
|
12317 | "color": key.color,
|
12318 | "onPress": onPress
|
12319 | }, keySlots);
|
12320 | });
|
12321 | const renderSidebar = () => {
|
12322 | if (props2.theme === "custom") {
|
12323 | return vue.createVNode("div", {
|
12324 | "class": bem$v("sidebar")
|
12325 | }, [props2.showDeleteKey && vue.createVNode(stdin_default$F, {
|
12326 | "large": true,
|
12327 | "text": props2.deleteButtonText,
|
12328 | "type": "delete",
|
12329 | "onPress": onPress
|
12330 | }, {
|
12331 | default: slots.delete
|
12332 | }), vue.createVNode(stdin_default$F, {
|
12333 | "large": true,
|
12334 | "text": props2.closeButtonText,
|
12335 | "type": "close",
|
12336 | "color": "blue",
|
12337 | "loading": props2.closeButtonLoading,
|
12338 | "onPress": onPress
|
12339 | }, null)]);
|
12340 | }
|
12341 | };
|
12342 | vue.watch(() => props2.show, (value) => {
|
12343 | if (!props2.transition) {
|
12344 | emit(value ? "show" : "hide");
|
12345 | }
|
12346 | });
|
12347 | if (props2.hideOnClickOutside) {
|
12348 | use.useClickAway(root, onBlur, {
|
12349 | eventName: "touchstart"
|
12350 | });
|
12351 | }
|
12352 | return () => {
|
12353 | const Title = renderTitle();
|
12354 | const Content = vue.createVNode(vue.Transition, {
|
12355 | "name": props2.transition ? "van-slide-up" : ""
|
12356 | }, {
|
12357 | default: () => [vue.withDirectives(vue.createVNode("div", vue.mergeProps({
|
12358 | "ref": root,
|
12359 | "style": getZIndexStyle(props2.zIndex),
|
12360 | "class": bem$v({
|
12361 | unfit: !props2.safeAreaInsetBottom,
|
12362 | "with-title": !!Title
|
12363 | }),
|
12364 | "onAnimationend": onAnimationEnd,
|
12365 | "onTouchstartPassive": stopPropagation
|
12366 | }, attrs), [Title, vue.createVNode("div", {
|
12367 | "class": bem$v("body")
|
12368 | }, [vue.createVNode("div", {
|
12369 | "class": bem$v("keys")
|
12370 | }, [renderKeys()]), renderSidebar()])]), [[vue.vShow, props2.show]])]
|
12371 | });
|
12372 | if (props2.teleport) {
|
12373 | return vue.createVNode(vue.Teleport, {
|
12374 | "to": props2.teleport
|
12375 | }, {
|
12376 | default: () => [Content]
|
12377 | });
|
12378 | }
|
12379 | return Content;
|
12380 | };
|
12381 | }
|
12382 | });
|
12383 | const NumberKeyboard = withInstall(stdin_default$E);
|
12384 | const [name$v, bem$u, t$6] = createNamespace("pagination");
|
12385 | const makePage = (number, text, active) => ({
|
12386 | number,
|
12387 | text,
|
12388 | active
|
12389 | });
|
12390 | const paginationProps = {
|
12391 | mode: makeStringProp("multi"),
|
12392 | prevText: String,
|
12393 | nextText: String,
|
12394 | pageCount: makeNumericProp(0),
|
12395 | modelValue: makeNumberProp(0),
|
12396 | totalItems: makeNumericProp(0),
|
12397 | showPageSize: makeNumericProp(5),
|
12398 | itemsPerPage: makeNumericProp(10),
|
12399 | forceEllipses: Boolean,
|
12400 | showPrevButton: truthProp,
|
12401 | showNextButton: truthProp
|
12402 | };
|
12403 | var stdin_default$D = vue.defineComponent({
|
12404 | name: name$v,
|
12405 | props: paginationProps,
|
12406 | emits: ["change", "update:modelValue"],
|
12407 | setup(props2, {
|
12408 | emit,
|
12409 | slots
|
12410 | }) {
|
12411 | const count = vue.computed(() => {
|
12412 | const {
|
12413 | pageCount,
|
12414 | totalItems,
|
12415 | itemsPerPage
|
12416 | } = props2;
|
12417 | const count2 = +pageCount || Math.ceil(+totalItems / +itemsPerPage);
|
12418 | return Math.max(1, count2);
|
12419 | });
|
12420 | const pages = vue.computed(() => {
|
12421 | const items = [];
|
12422 | const pageCount = count.value;
|
12423 | const showPageSize = +props2.showPageSize;
|
12424 | const {
|
12425 | modelValue,
|
12426 | forceEllipses
|
12427 | } = props2;
|
12428 | let startPage = 1;
|
12429 | let endPage = pageCount;
|
12430 | const isMaxSized = showPageSize < pageCount;
|
12431 | if (isMaxSized) {
|
12432 | startPage = Math.max(modelValue - Math.floor(showPageSize / 2), 1);
|
12433 | endPage = startPage + showPageSize - 1;
|
12434 | if (endPage > pageCount) {
|
12435 | endPage = pageCount;
|
12436 | startPage = endPage - showPageSize + 1;
|
12437 | }
|
12438 | }
|
12439 | for (let number = startPage; number <= endPage; number++) {
|
12440 | const page = makePage(number, number, number === modelValue);
|
12441 | items.push(page);
|
12442 | }
|
12443 | if (isMaxSized && showPageSize > 0 && forceEllipses) {
|
12444 | if (startPage > 1) {
|
12445 | const prevPages = makePage(startPage - 1, "...");
|
12446 | items.unshift(prevPages);
|
12447 | }
|
12448 | if (endPage < pageCount) {
|
12449 | const nextPages = makePage(endPage + 1, "...");
|
12450 | items.push(nextPages);
|
12451 | }
|
12452 | }
|
12453 | return items;
|
12454 | });
|
12455 | const updateModelValue = (value, emitChange) => {
|
12456 | value = clamp(value, 1, count.value);
|
12457 | if (props2.modelValue !== value) {
|
12458 | emit("update:modelValue", value);
|
12459 | if (emitChange) {
|
12460 | emit("change", value);
|
12461 | }
|
12462 | }
|
12463 | };
|
12464 | vue.watchEffect(() => updateModelValue(props2.modelValue));
|
12465 | const renderDesc = () => vue.createVNode("li", {
|
12466 | "class": bem$u("page-desc")
|
12467 | }, [slots.pageDesc ? slots.pageDesc() : `${props2.modelValue}/${count.value}`]);
|
12468 | const renderPrevButton = () => {
|
12469 | const {
|
12470 | mode,
|
12471 | modelValue,
|
12472 | showPrevButton
|
12473 | } = props2;
|
12474 | if (!showPrevButton) {
|
12475 | return;
|
12476 | }
|
12477 | const slot = slots["prev-text"];
|
12478 | const disabled = modelValue === 1;
|
12479 | return vue.createVNode("li", {
|
12480 | "class": [bem$u("item", {
|
12481 | disabled,
|
12482 | border: mode === "simple",
|
12483 | prev: true
|
12484 | }), BORDER_SURROUND]
|
12485 | }, [vue.createVNode("button", {
|
12486 | "type": "button",
|
12487 | "disabled": disabled,
|
12488 | "onClick": () => updateModelValue(modelValue - 1, true)
|
12489 | }, [slot ? slot() : props2.prevText || t$6("prev")])]);
|
12490 | };
|
12491 | const renderNextButton = () => {
|
12492 | const {
|
12493 | mode,
|
12494 | modelValue,
|
12495 | showNextButton
|
12496 | } = props2;
|
12497 | if (!showNextButton) {
|
12498 | return;
|
12499 | }
|
12500 | const slot = slots["next-text"];
|
12501 | const disabled = modelValue === count.value;
|
12502 | return vue.createVNode("li", {
|
12503 | "class": [bem$u("item", {
|
12504 | disabled,
|
12505 | border: mode === "simple",
|
12506 | next: true
|
12507 | }), BORDER_SURROUND]
|
12508 | }, [vue.createVNode("button", {
|
12509 | "type": "button",
|
12510 | "disabled": disabled,
|
12511 | "onClick": () => updateModelValue(modelValue + 1, true)
|
12512 | }, [slot ? slot() : props2.nextText || t$6("next")])]);
|
12513 | };
|
12514 | const renderPages = () => pages.value.map((page) => vue.createVNode("li", {
|
12515 | "class": [bem$u("item", {
|
12516 | active: page.active,
|
12517 | page: true
|
12518 | }), BORDER_SURROUND]
|
12519 | }, [vue.createVNode("button", {
|
12520 | "type": "button",
|
12521 | "aria-current": page.active || void 0,
|
12522 | "onClick": () => updateModelValue(page.number, true)
|
12523 | }, [slots.page ? slots.page(page) : page.text])]));
|
12524 | return () => vue.createVNode("nav", {
|
12525 | "role": "navigation",
|
12526 | "class": bem$u()
|
12527 | }, [vue.createVNode("ul", {
|
12528 | "class": bem$u("items")
|
12529 | }, [renderPrevButton(), props2.mode === "simple" ? renderDesc() : renderPages(), renderNextButton()])]);
|
12530 | }
|
12531 | });
|
12532 | const Pagination = withInstall(stdin_default$D);
|
12533 | const [name$u, bem$t] = createNamespace("password-input");
|
12534 | const passwordInputProps = {
|
12535 | info: String,
|
12536 | mask: truthProp,
|
12537 | value: makeStringProp(""),
|
12538 | gutter: numericProp,
|
12539 | length: makeNumericProp(6),
|
12540 | focused: Boolean,
|
12541 | errorInfo: String
|
12542 | };
|
12543 | var stdin_default$C = vue.defineComponent({
|
12544 | name: name$u,
|
12545 | props: passwordInputProps,
|
12546 | emits: ["focus"],
|
12547 | setup(props2, {
|
12548 | emit
|
12549 | }) {
|
12550 | const onTouchStart = (event) => {
|
12551 | event.stopPropagation();
|
12552 | emit("focus", event);
|
12553 | };
|
12554 | const renderPoints = () => {
|
12555 | const Points = [];
|
12556 | const {
|
12557 | mask,
|
12558 | value,
|
12559 | gutter,
|
12560 | focused
|
12561 | } = props2;
|
12562 | const length = +props2.length;
|
12563 | for (let i = 0; i < length; i++) {
|
12564 | const char = value[i];
|
12565 | const showBorder = i !== 0 && !gutter;
|
12566 | const showCursor = focused && i === value.length;
|
12567 | let style;
|
12568 | if (i !== 0 && gutter) {
|
12569 | style = {
|
12570 | marginLeft: addUnit(gutter)
|
12571 | };
|
12572 | }
|
12573 | Points.push(vue.createVNode("li", {
|
12574 | "class": [{
|
12575 | [BORDER_LEFT]: showBorder
|
12576 | }, bem$t("item", {
|
12577 | focus: showCursor
|
12578 | })],
|
12579 | "style": style
|
12580 | }, [mask ? vue.createVNode("i", {
|
12581 | "style": {
|
12582 | visibility: char ? "visible" : "hidden"
|
12583 | }
|
12584 | }, null) : char, showCursor && vue.createVNode("div", {
|
12585 | "class": bem$t("cursor")
|
12586 | }, null)]));
|
12587 | }
|
12588 | return Points;
|
12589 | };
|
12590 | return () => {
|
12591 | const info = props2.errorInfo || props2.info;
|
12592 | return vue.createVNode("div", {
|
12593 | "class": bem$t()
|
12594 | }, [vue.createVNode("ul", {
|
12595 | "class": [bem$t("security"), {
|
12596 | [BORDER_SURROUND]: !props2.gutter
|
12597 | }],
|
12598 | "onTouchstartPassive": onTouchStart
|
12599 | }, [renderPoints()]), info && vue.createVNode("div", {
|
12600 | "class": bem$t(props2.errorInfo ? "error-info" : "info")
|
12601 | }, [info])]);
|
12602 | };
|
12603 | }
|
12604 | });
|
12605 | const PasswordInput = withInstall(stdin_default$C);
|
12606 | const PickerGroup = withInstall(stdin_default$1A);
|
12607 | const [name$t, bem$s] = createNamespace("popover");
|
12608 | const popupProps = ["overlay", "duration", "teleport", "overlayStyle", "overlayClass", "closeOnClickOverlay"];
|
12609 | const popoverProps = {
|
12610 | show: Boolean,
|
12611 | theme: makeStringProp("light"),
|
12612 | overlay: Boolean,
|
12613 | actions: makeArrayProp(),
|
12614 | actionsDirection: makeStringProp("vertical"),
|
12615 | trigger: makeStringProp("click"),
|
12616 | duration: numericProp,
|
12617 | showArrow: truthProp,
|
12618 | placement: makeStringProp("bottom"),
|
12619 | iconPrefix: String,
|
12620 | overlayClass: unknownProp,
|
12621 | overlayStyle: Object,
|
12622 | closeOnClickAction: truthProp,
|
12623 | closeOnClickOverlay: truthProp,
|
12624 | closeOnClickOutside: truthProp,
|
12625 | offset: {
|
12626 | type: Array,
|
12627 | default: () => [0, 8]
|
12628 | },
|
12629 | teleport: {
|
12630 | type: [String, Object],
|
12631 | default: "body"
|
12632 | }
|
12633 | };
|
12634 | var stdin_default$B = vue.defineComponent({
|
12635 | name: name$t,
|
12636 | props: popoverProps,
|
12637 | emits: ["select", "touchstart", "update:show"],
|
12638 | setup(props2, {
|
12639 | emit,
|
12640 | slots,
|
12641 | attrs
|
12642 | }) {
|
12643 | let popper;
|
12644 | const popupRef = vue.ref();
|
12645 | const wrapperRef = vue.ref();
|
12646 | const popoverRef = vue.ref();
|
12647 | const show = useSyncPropRef(() => props2.show, (value) => emit("update:show", value));
|
12648 | const getPopoverOptions = () => ({
|
12649 | placement: props2.placement,
|
12650 | modifiers: [{
|
12651 | name: "computeStyles",
|
12652 | options: {
|
12653 | adaptive: false,
|
12654 | gpuAcceleration: false
|
12655 | }
|
12656 | }, extend({}, popperjs.offsetModifier, {
|
12657 | options: {
|
12658 | offset: props2.offset
|
12659 | }
|
12660 | })]
|
12661 | });
|
12662 | const createPopperInstance = () => {
|
12663 | if (wrapperRef.value && popoverRef.value) {
|
12664 | return popperjs.createPopper(wrapperRef.value, popoverRef.value.popupRef.value, getPopoverOptions());
|
12665 | }
|
12666 | return null;
|
12667 | };
|
12668 | const updateLocation = () => {
|
12669 | vue.nextTick(() => {
|
12670 | if (!show.value) {
|
12671 | return;
|
12672 | }
|
12673 | if (!popper) {
|
12674 | popper = createPopperInstance();
|
12675 | if (inBrowser) {
|
12676 | window.addEventListener("animationend", updateLocation);
|
12677 | window.addEventListener("transitionend", updateLocation);
|
12678 | }
|
12679 | } else {
|
12680 | popper.setOptions(getPopoverOptions());
|
12681 | }
|
12682 | });
|
12683 | };
|
12684 | const updateShow = (value) => {
|
12685 | show.value = value;
|
12686 | };
|
12687 | const onClickWrapper = () => {
|
12688 | if (props2.trigger === "click") {
|
12689 | show.value = !show.value;
|
12690 | }
|
12691 | };
|
12692 | const onClickAction = (action, index) => {
|
12693 | if (action.disabled) {
|
12694 | return;
|
12695 | }
|
12696 | emit("select", action, index);
|
12697 | if (props2.closeOnClickAction) {
|
12698 | show.value = false;
|
12699 | }
|
12700 | };
|
12701 | const onClickAway = () => {
|
12702 | if (show.value && props2.closeOnClickOutside && (!props2.overlay || props2.closeOnClickOverlay)) {
|
12703 | show.value = false;
|
12704 | }
|
12705 | };
|
12706 | const renderActionContent = (action, index) => {
|
12707 | if (slots.action) {
|
12708 | return slots.action({
|
12709 | action,
|
12710 | index
|
12711 | });
|
12712 | }
|
12713 | return [action.icon && vue.createVNode(Icon, {
|
12714 | "name": action.icon,
|
12715 | "classPrefix": props2.iconPrefix,
|
12716 | "class": bem$s("action-icon")
|
12717 | }, null), vue.createVNode("div", {
|
12718 | "class": [bem$s("action-text"), {
|
12719 | [BORDER_BOTTOM]: props2.actionsDirection === "vertical"
|
12720 | }]
|
12721 | }, [action.text])];
|
12722 | };
|
12723 | const renderAction = (action, index) => {
|
12724 | const {
|
12725 | icon,
|
12726 | color,
|
12727 | disabled,
|
12728 | className
|
12729 | } = action;
|
12730 | return vue.createVNode("div", {
|
12731 | "role": "menuitem",
|
12732 | "class": [bem$s("action", {
|
12733 | disabled,
|
12734 | "with-icon": icon
|
12735 | }), {
|
12736 | [BORDER_RIGHT]: props2.actionsDirection === "horizontal"
|
12737 | }, className],
|
12738 | "style": {
|
12739 | color
|
12740 | },
|
12741 | "tabindex": disabled ? void 0 : 0,
|
12742 | "aria-disabled": disabled || void 0,
|
12743 | "onClick": () => onClickAction(action, index)
|
12744 | }, [renderActionContent(action, index)]);
|
12745 | };
|
12746 | vue.onMounted(() => {
|
12747 | updateLocation();
|
12748 | vue.watchEffect(() => {
|
12749 | var _a;
|
12750 | popupRef.value = (_a = popoverRef.value) == null ? void 0 : _a.popupRef.value;
|
12751 | });
|
12752 | });
|
12753 | vue.onBeforeUnmount(() => {
|
12754 | if (popper) {
|
12755 | if (inBrowser) {
|
12756 | window.removeEventListener("animationend", updateLocation);
|
12757 | window.removeEventListener("transitionend", updateLocation);
|
12758 | }
|
12759 | popper.destroy();
|
12760 | popper = null;
|
12761 | }
|
12762 | });
|
12763 | vue.watch(() => [show.value, props2.offset, props2.placement], updateLocation);
|
12764 | use.useClickAway([wrapperRef, popupRef], onClickAway, {
|
12765 | eventName: "touchstart"
|
12766 | });
|
12767 | return () => {
|
12768 | var _a;
|
12769 | return vue.createVNode(vue.Fragment, null, [vue.createVNode("span", {
|
12770 | "ref": wrapperRef,
|
12771 | "class": bem$s("wrapper"),
|
12772 | "onClick": onClickWrapper
|
12773 | }, [(_a = slots.reference) == null ? void 0 : _a.call(slots)]), vue.createVNode(Popup, vue.mergeProps({
|
12774 | "ref": popoverRef,
|
12775 | "show": show.value,
|
12776 | "class": bem$s([props2.theme]),
|
12777 | "position": "",
|
12778 | "transition": "van-popover-zoom",
|
12779 | "lockScroll": false,
|
12780 | "onUpdate:show": updateShow
|
12781 | }, attrs, useScopeId(), pick(props2, popupProps)), {
|
12782 | default: () => [props2.showArrow && vue.createVNode("div", {
|
12783 | "class": bem$s("arrow")
|
12784 | }, null), vue.createVNode("div", {
|
12785 | "role": "menu",
|
12786 | "class": bem$s("content", props2.actionsDirection)
|
12787 | }, [slots.default ? slots.default() : props2.actions.map(renderAction)])]
|
12788 | })]);
|
12789 | };
|
12790 | }
|
12791 | });
|
12792 | const Popover = withInstall(stdin_default$B);
|
12793 | const [name$s, bem$r] = createNamespace("progress");
|
12794 | const progressProps = {
|
12795 | color: String,
|
12796 | inactive: Boolean,
|
12797 | pivotText: String,
|
12798 | textColor: String,
|
12799 | showPivot: truthProp,
|
12800 | pivotColor: String,
|
12801 | trackColor: String,
|
12802 | strokeWidth: numericProp,
|
12803 | percentage: {
|
12804 | type: numericProp,
|
12805 | default: 0,
|
12806 | validator: (value) => +value >= 0 && +value <= 100
|
12807 | }
|
12808 | };
|
12809 | var stdin_default$A = vue.defineComponent({
|
12810 | name: name$s,
|
12811 | props: progressProps,
|
12812 | setup(props2) {
|
12813 | const background = vue.computed(() => props2.inactive ? void 0 : props2.color);
|
12814 | const renderPivot = () => {
|
12815 | const {
|
12816 | textColor,
|
12817 | pivotText,
|
12818 | pivotColor,
|
12819 | percentage
|
12820 | } = props2;
|
12821 | const text = pivotText != null ? pivotText : `${percentage}%`;
|
12822 | if (props2.showPivot && text) {
|
12823 | const style = {
|
12824 | color: textColor,
|
12825 | left: `${+percentage}%`,
|
12826 | transform: `translate(-${+percentage}%,-50%)`,
|
12827 | background: pivotColor || background.value
|
12828 | };
|
12829 | return vue.createVNode("span", {
|
12830 | "style": style,
|
12831 | "class": bem$r("pivot", {
|
12832 | inactive: props2.inactive
|
12833 | })
|
12834 | }, [text]);
|
12835 | }
|
12836 | };
|
12837 | return () => {
|
12838 | const {
|
12839 | trackColor,
|
12840 | percentage,
|
12841 | strokeWidth
|
12842 | } = props2;
|
12843 | const rootStyle = {
|
12844 | background: trackColor,
|
12845 | height: addUnit(strokeWidth)
|
12846 | };
|
12847 | const portionStyle = {
|
12848 | width: `${percentage}%`,
|
12849 | background: background.value
|
12850 | };
|
12851 | return vue.createVNode("div", {
|
12852 | "class": bem$r(),
|
12853 | "style": rootStyle
|
12854 | }, [vue.createVNode("span", {
|
12855 | "class": bem$r("portion", {
|
12856 | inactive: props2.inactive
|
12857 | }),
|
12858 | "style": portionStyle
|
12859 | }, null), renderPivot()]);
|
12860 | };
|
12861 | }
|
12862 | });
|
12863 | const Progress = withInstall(stdin_default$A);
|
12864 | const [name$r, bem$q, t$5] = createNamespace("pull-refresh");
|
12865 | const DEFAULT_HEAD_HEIGHT = 50;
|
12866 | const TEXT_STATUS = ["pulling", "loosing", "success"];
|
12867 | const pullRefreshProps = {
|
12868 | disabled: Boolean,
|
12869 | modelValue: Boolean,
|
12870 | headHeight: makeNumericProp(DEFAULT_HEAD_HEIGHT),
|
12871 | successText: String,
|
12872 | pullingText: String,
|
12873 | loosingText: String,
|
12874 | loadingText: String,
|
12875 | pullDistance: numericProp,
|
12876 | successDuration: makeNumericProp(500),
|
12877 | animationDuration: makeNumericProp(300)
|
12878 | };
|
12879 | var stdin_default$z = vue.defineComponent({
|
12880 | name: name$r,
|
12881 | props: pullRefreshProps,
|
12882 | emits: ["change", "refresh", "update:modelValue"],
|
12883 | setup(props2, {
|
12884 | emit,
|
12885 | slots
|
12886 | }) {
|
12887 | let reachTop;
|
12888 | const root = vue.ref();
|
12889 | const track = vue.ref();
|
12890 | const scrollParent = use.useScrollParent(root);
|
12891 | const state = vue.reactive({
|
12892 | status: "normal",
|
12893 | distance: 0,
|
12894 | duration: 0
|
12895 | });
|
12896 | const touch = useTouch();
|
12897 | const getHeadStyle = () => {
|
12898 | if (props2.headHeight !== DEFAULT_HEAD_HEIGHT) {
|
12899 | return {
|
12900 | height: `${props2.headHeight}px`
|
12901 | };
|
12902 | }
|
12903 | };
|
12904 | const isTouchable = () => state.status !== "loading" && state.status !== "success" && !props2.disabled;
|
12905 | const ease = (distance) => {
|
12906 | const pullDistance = +(props2.pullDistance || props2.headHeight);
|
12907 | if (distance > pullDistance) {
|
12908 | if (distance < pullDistance * 2) {
|
12909 | distance = pullDistance + (distance - pullDistance) / 2;
|
12910 | } else {
|
12911 | distance = pullDistance * 1.5 + (distance - pullDistance * 2) / 4;
|
12912 | }
|
12913 | }
|
12914 | return Math.round(distance);
|
12915 | };
|
12916 | const setStatus = (distance, isLoading) => {
|
12917 | const pullDistance = +(props2.pullDistance || props2.headHeight);
|
12918 | state.distance = distance;
|
12919 | if (isLoading) {
|
12920 | state.status = "loading";
|
12921 | } else if (distance === 0) {
|
12922 | state.status = "normal";
|
12923 | } else if (distance < pullDistance) {
|
12924 | state.status = "pulling";
|
12925 | } else {
|
12926 | state.status = "loosing";
|
12927 | }
|
12928 | emit("change", {
|
12929 | status: state.status,
|
12930 | distance
|
12931 | });
|
12932 | };
|
12933 | const getStatusText = () => {
|
12934 | const {
|
12935 | status
|
12936 | } = state;
|
12937 | if (status === "normal") {
|
12938 | return "";
|
12939 | }
|
12940 | return props2[`${status}Text`] || t$5(status);
|
12941 | };
|
12942 | const renderStatus = () => {
|
12943 | const {
|
12944 | status,
|
12945 | distance
|
12946 | } = state;
|
12947 | if (slots[status]) {
|
12948 | return slots[status]({
|
12949 | distance
|
12950 | });
|
12951 | }
|
12952 | const nodes = [];
|
12953 | if (TEXT_STATUS.includes(status)) {
|
12954 | nodes.push(vue.createVNode("div", {
|
12955 | "class": bem$q("text")
|
12956 | }, [getStatusText()]));
|
12957 | }
|
12958 | if (status === "loading") {
|
12959 | nodes.push(vue.createVNode(Loading, {
|
12960 | "class": bem$q("loading")
|
12961 | }, {
|
12962 | default: getStatusText
|
12963 | }));
|
12964 | }
|
12965 | return nodes;
|
12966 | };
|
12967 | const showSuccessTip = () => {
|
12968 | state.status = "success";
|
12969 | setTimeout(() => {
|
12970 | setStatus(0);
|
12971 | }, +props2.successDuration);
|
12972 | };
|
12973 | const checkPosition = (event) => {
|
12974 | reachTop = getScrollTop(scrollParent.value) === 0;
|
12975 | if (reachTop) {
|
12976 | state.duration = 0;
|
12977 | touch.start(event);
|
12978 | }
|
12979 | };
|
12980 | const onTouchStart = (event) => {
|
12981 | if (isTouchable()) {
|
12982 | checkPosition(event);
|
12983 | }
|
12984 | };
|
12985 | const onTouchMove = (event) => {
|
12986 | if (isTouchable()) {
|
12987 | if (!reachTop) {
|
12988 | checkPosition(event);
|
12989 | }
|
12990 | const {
|
12991 | deltaY
|
12992 | } = touch;
|
12993 | touch.move(event);
|
12994 | if (reachTop && deltaY.value >= 0 && touch.isVertical()) {
|
12995 | preventDefault(event);
|
12996 | setStatus(ease(deltaY.value));
|
12997 | }
|
12998 | }
|
12999 | };
|
13000 | const onTouchEnd = () => {
|
13001 | if (reachTop && touch.deltaY.value && isTouchable()) {
|
13002 | state.duration = +props2.animationDuration;
|
13003 | if (state.status === "loosing") {
|
13004 | setStatus(+props2.headHeight, true);
|
13005 | emit("update:modelValue", true);
|
13006 | vue.nextTick(() => emit("refresh"));
|
13007 | } else {
|
13008 | setStatus(0);
|
13009 | }
|
13010 | }
|
13011 | };
|
13012 | vue.watch(() => props2.modelValue, (value) => {
|
13013 | state.duration = +props2.animationDuration;
|
13014 | if (value) {
|
13015 | setStatus(+props2.headHeight, true);
|
13016 | } else if (slots.success || props2.successText) {
|
13017 | showSuccessTip();
|
13018 | } else {
|
13019 | setStatus(0, false);
|
13020 | }
|
13021 | });
|
13022 | use.useEventListener("touchmove", onTouchMove, {
|
13023 | target: track
|
13024 | });
|
13025 | return () => {
|
13026 | var _a;
|
13027 | const trackStyle = {
|
13028 | transitionDuration: `${state.duration}ms`,
|
13029 | transform: state.distance ? `translate3d(0,${state.distance}px, 0)` : ""
|
13030 | };
|
13031 | return vue.createVNode("div", {
|
13032 | "ref": root,
|
13033 | "class": bem$q()
|
13034 | }, [vue.createVNode("div", {
|
13035 | "ref": track,
|
13036 | "class": bem$q("track"),
|
13037 | "style": trackStyle,
|
13038 | "onTouchstartPassive": onTouchStart,
|
13039 | "onTouchend": onTouchEnd,
|
13040 | "onTouchcancel": onTouchEnd
|
13041 | }, [vue.createVNode("div", {
|
13042 | "class": bem$q("head"),
|
13043 | "style": getHeadStyle()
|
13044 | }, [renderStatus()]), (_a = slots.default) == null ? void 0 : _a.call(slots)])]);
|
13045 | };
|
13046 | }
|
13047 | });
|
13048 | const PullRefresh = withInstall(stdin_default$z);
|
13049 | const [name$q, bem$p] = createNamespace("rate");
|
13050 | function getRateStatus(value, index, allowHalf, readonly) {
|
13051 | if (value >= index) {
|
13052 | return {
|
13053 | status: "full",
|
13054 | value: 1
|
13055 | };
|
13056 | }
|
13057 | if (value + 0.5 >= index && allowHalf && !readonly) {
|
13058 | return {
|
13059 | status: "half",
|
13060 | value: 0.5
|
13061 | };
|
13062 | }
|
13063 | if (value + 1 >= index && allowHalf && readonly) {
|
13064 | const cardinal = 10 ** 10;
|
13065 | return {
|
13066 | status: "half",
|
13067 | value: Math.round((value - index + 1) * cardinal) / cardinal
|
13068 | };
|
13069 | }
|
13070 | return {
|
13071 | status: "void",
|
13072 | value: 0
|
13073 | };
|
13074 | }
|
13075 | const rateProps = {
|
13076 | size: numericProp,
|
13077 | icon: makeStringProp("star"),
|
13078 | color: String,
|
13079 | count: makeNumericProp(5),
|
13080 | gutter: numericProp,
|
13081 | clearable: Boolean,
|
13082 | readonly: Boolean,
|
13083 | disabled: Boolean,
|
13084 | voidIcon: makeStringProp("star-o"),
|
13085 | allowHalf: Boolean,
|
13086 | voidColor: String,
|
13087 | touchable: truthProp,
|
13088 | iconPrefix: String,
|
13089 | modelValue: makeNumberProp(0),
|
13090 | disabledColor: String
|
13091 | };
|
13092 | var stdin_default$y = vue.defineComponent({
|
13093 | name: name$q,
|
13094 | props: rateProps,
|
13095 | emits: ["change", "update:modelValue"],
|
13096 | setup(props2, {
|
13097 | emit
|
13098 | }) {
|
13099 | const touch = useTouch();
|
13100 | const [itemRefs, setItemRefs] = useRefs();
|
13101 | const groupRef = vue.ref();
|
13102 | const unselectable = vue.computed(() => props2.readonly || props2.disabled);
|
13103 | const untouchable = vue.computed(() => unselectable.value || !props2.touchable);
|
13104 | const list = vue.computed(() => Array(+props2.count).fill("").map((_, i) => getRateStatus(props2.modelValue, i + 1, props2.allowHalf, props2.readonly)));
|
13105 | let ranges;
|
13106 | let groupRefRect;
|
13107 | let minRectTop = Number.MAX_SAFE_INTEGER;
|
13108 | let maxRectTop = Number.MIN_SAFE_INTEGER;
|
13109 | const updateRanges = () => {
|
13110 | groupRefRect = use.useRect(groupRef);
|
13111 | const rects = itemRefs.value.map(use.useRect);
|
13112 | ranges = [];
|
13113 | rects.forEach((rect, index) => {
|
13114 | minRectTop = Math.min(rect.top, minRectTop);
|
13115 | maxRectTop = Math.max(rect.top, maxRectTop);
|
13116 | if (props2.allowHalf) {
|
13117 | ranges.push({
|
13118 | score: index + 0.5,
|
13119 | left: rect.left,
|
13120 | top: rect.top,
|
13121 | height: rect.height
|
13122 | }, {
|
13123 | score: index + 1,
|
13124 | left: rect.left + rect.width / 2,
|
13125 | top: rect.top,
|
13126 | height: rect.height
|
13127 | });
|
13128 | } else {
|
13129 | ranges.push({
|
13130 | score: index + 1,
|
13131 | left: rect.left,
|
13132 | top: rect.top,
|
13133 | height: rect.height
|
13134 | });
|
13135 | }
|
13136 | });
|
13137 | };
|
13138 | const getScoreByPosition = (x, y) => {
|
13139 | for (let i = ranges.length - 1; i > 0; i--) {
|
13140 | if (y >= groupRefRect.top && y <= groupRefRect.bottom) {
|
13141 | if (x > ranges[i].left && y >= ranges[i].top && y <= ranges[i].top + ranges[i].height) {
|
13142 | return ranges[i].score;
|
13143 | }
|
13144 | } else {
|
13145 | const curTop = y < groupRefRect.top ? minRectTop : maxRectTop;
|
13146 | if (x > ranges[i].left && ranges[i].top === curTop) {
|
13147 | return ranges[i].score;
|
13148 | }
|
13149 | }
|
13150 | }
|
13151 | return props2.allowHalf ? 0.5 : 1;
|
13152 | };
|
13153 | const select = (value) => {
|
13154 | if (unselectable.value || value === props2.modelValue) return;
|
13155 | emit("update:modelValue", value);
|
13156 | emit("change", value);
|
13157 | };
|
13158 | const onTouchStart = (event) => {
|
13159 | if (untouchable.value) {
|
13160 | return;
|
13161 | }
|
13162 | touch.start(event);
|
13163 | updateRanges();
|
13164 | };
|
13165 | const onTouchMove = (event) => {
|
13166 | if (untouchable.value) {
|
13167 | return;
|
13168 | }
|
13169 | touch.move(event);
|
13170 | if (touch.isHorizontal() && !touch.isTap.value) {
|
13171 | const {
|
13172 | clientX,
|
13173 | clientY
|
13174 | } = event.touches[0];
|
13175 | preventDefault(event);
|
13176 | select(getScoreByPosition(clientX, clientY));
|
13177 | }
|
13178 | };
|
13179 | const renderStar = (item, index) => {
|
13180 | const {
|
13181 | icon,
|
13182 | size,
|
13183 | color,
|
13184 | count,
|
13185 | gutter,
|
13186 | voidIcon,
|
13187 | disabled,
|
13188 | voidColor,
|
13189 | allowHalf,
|
13190 | iconPrefix,
|
13191 | disabledColor
|
13192 | } = props2;
|
13193 | const score = index + 1;
|
13194 | const isFull = item.status === "full";
|
13195 | const isVoid = item.status === "void";
|
13196 | const renderHalf = allowHalf && item.value > 0 && item.value < 1;
|
13197 | let style;
|
13198 | if (gutter && score !== +count) {
|
13199 | style = {
|
13200 | paddingRight: addUnit(gutter)
|
13201 | };
|
13202 | }
|
13203 | const onClickItem = (event) => {
|
13204 | updateRanges();
|
13205 | let value = allowHalf ? getScoreByPosition(event.clientX, event.clientY) : score;
|
13206 | if (props2.clearable && touch.isTap.value && value === props2.modelValue) {
|
13207 | value = 0;
|
13208 | }
|
13209 | select(value);
|
13210 | };
|
13211 | return vue.createVNode("div", {
|
13212 | "key": index,
|
13213 | "ref": setItemRefs(index),
|
13214 | "role": "radio",
|
13215 | "style": style,
|
13216 | "class": bem$p("item"),
|
13217 | "tabindex": disabled ? void 0 : 0,
|
13218 | "aria-setsize": count,
|
13219 | "aria-posinset": score,
|
13220 | "aria-checked": !isVoid,
|
13221 | "onClick": onClickItem
|
13222 | }, [vue.createVNode(Icon, {
|
13223 | "size": size,
|
13224 | "name": isFull ? icon : voidIcon,
|
13225 | "class": bem$p("icon", {
|
13226 | disabled,
|
13227 | full: isFull
|
13228 | }),
|
13229 | "color": disabled ? disabledColor : isFull ? color : voidColor,
|
13230 | "classPrefix": iconPrefix
|
13231 | }, null), renderHalf && vue.createVNode(Icon, {
|
13232 | "size": size,
|
13233 | "style": {
|
13234 | width: item.value + "em"
|
13235 | },
|
13236 | "name": isVoid ? voidIcon : icon,
|
13237 | "class": bem$p("icon", ["half", {
|
13238 | disabled,
|
13239 | full: !isVoid
|
13240 | }]),
|
13241 | "color": disabled ? disabledColor : isVoid ? voidColor : color,
|
13242 | "classPrefix": iconPrefix
|
13243 | }, null)]);
|
13244 | };
|
13245 | use.useCustomFieldValue(() => props2.modelValue);
|
13246 | use.useEventListener("touchmove", onTouchMove, {
|
13247 | target: groupRef
|
13248 | });
|
13249 | return () => vue.createVNode("div", {
|
13250 | "ref": groupRef,
|
13251 | "role": "radiogroup",
|
13252 | "class": bem$p({
|
13253 | readonly: props2.readonly,
|
13254 | disabled: props2.disabled
|
13255 | }),
|
13256 | "tabindex": props2.disabled ? void 0 : 0,
|
13257 | "aria-disabled": props2.disabled,
|
13258 | "aria-readonly": props2.readonly,
|
13259 | "onTouchstartPassive": onTouchStart
|
13260 | }, [list.value.map(renderStar)]);
|
13261 | }
|
13262 | });
|
13263 | const Rate = withInstall(stdin_default$y);
|
13264 | const props = {
|
13265 | figureArr: makeArrayProp(),
|
13266 | delay: Number,
|
13267 | duration: makeNumberProp(2),
|
13268 | isStart: Boolean,
|
13269 | direction: makeStringProp("down"),
|
13270 | height: makeNumberProp(40)
|
13271 | };
|
13272 | const [name$p, bem$o] = createNamespace("rolling-text-item");
|
13273 | var stdin_default$x = vue.defineComponent({
|
13274 | name: name$p,
|
13275 | props,
|
13276 | setup(props2) {
|
13277 | const newFigureArr = vue.computed(() => props2.direction === "down" ? props2.figureArr.slice().reverse() : props2.figureArr);
|
13278 | const translatePx = vue.computed(() => {
|
13279 | const totalHeight = props2.height * (props2.figureArr.length - 1);
|
13280 | return `-${totalHeight}px`;
|
13281 | });
|
13282 | const itemStyle = vue.computed(() => ({
|
13283 | lineHeight: addUnit(props2.height)
|
13284 | }));
|
13285 | const rootStyle = vue.computed(() => ({
|
13286 | height: addUnit(props2.height),
|
13287 | "--van-translate": translatePx.value,
|
13288 | "--van-duration": props2.duration + "s",
|
13289 | "--van-delay": props2.delay + "s"
|
13290 | }));
|
13291 | return () => vue.createVNode("div", {
|
13292 | "class": bem$o([props2.direction]),
|
13293 | "style": rootStyle.value
|
13294 | }, [vue.createVNode("div", {
|
13295 | "class": bem$o("box", {
|
13296 | animate: props2.isStart
|
13297 | })
|
13298 | }, [Array.isArray(newFigureArr.value) && newFigureArr.value.map((figure) => vue.createVNode("div", {
|
13299 | "class": bem$o("item"),
|
13300 | "style": itemStyle.value
|
13301 | }, [figure]))])]);
|
13302 | }
|
13303 | });
|
13304 | const [name$o, bem$n] = createNamespace("rolling-text");
|
13305 | const rollingTextProps = {
|
13306 | startNum: makeNumberProp(0),
|
13307 | targetNum: Number,
|
13308 | textList: makeArrayProp(),
|
13309 | duration: makeNumberProp(2),
|
13310 | autoStart: truthProp,
|
13311 | direction: makeStringProp("down"),
|
13312 | stopOrder: makeStringProp("ltr"),
|
13313 | height: makeNumberProp(40)
|
13314 | };
|
13315 | const CIRCLE_NUM = 2;
|
13316 | var stdin_default$w = vue.defineComponent({
|
13317 | name: name$o,
|
13318 | props: rollingTextProps,
|
13319 | setup(props2) {
|
13320 | const isCustomType = vue.computed(() => Array.isArray(props2.textList) && props2.textList.length);
|
13321 | const itemLength = vue.computed(() => {
|
13322 | if (isCustomType.value) return props2.textList[0].length;
|
13323 | return `${Math.max(props2.startNum, props2.targetNum)}`.length;
|
13324 | });
|
13325 | const getTextArrByIdx = (idx) => {
|
13326 | const result = [];
|
13327 | for (let i = 0; i < props2.textList.length; i++) {
|
13328 | result.push(props2.textList[i][idx]);
|
13329 | }
|
13330 | return result;
|
13331 | };
|
13332 | const targetNumArr = vue.computed(() => {
|
13333 | if (isCustomType.value) return new Array(itemLength.value).fill("");
|
13334 | return padZero(props2.targetNum, itemLength.value).split("");
|
13335 | });
|
13336 | const startNumArr = vue.computed(() => padZero(props2.startNum, itemLength.value).split(""));
|
13337 | const getFigureArr = (i) => {
|
13338 | const start2 = +startNumArr.value[i];
|
13339 | const target = +targetNumArr.value[i];
|
13340 | const result = [];
|
13341 | for (let i2 = start2; i2 <= 9; i2++) {
|
13342 | result.push(i2);
|
13343 | }
|
13344 | for (let i2 = 0; i2 <= CIRCLE_NUM; i2++) {
|
13345 | for (let j = 0; j <= 9; j++) {
|
13346 | result.push(j);
|
13347 | }
|
13348 | }
|
13349 | for (let i2 = 0; i2 <= target; i2++) {
|
13350 | result.push(i2);
|
13351 | }
|
13352 | return result;
|
13353 | };
|
13354 | const getDelay = (i, len) => {
|
13355 | if (props2.stopOrder === "ltr") return 0.2 * i;
|
13356 | return 0.2 * (len - 1 - i);
|
13357 | };
|
13358 | const rolling = vue.ref(props2.autoStart);
|
13359 | const start = () => {
|
13360 | rolling.value = true;
|
13361 | };
|
13362 | const reset = () => {
|
13363 | rolling.value = false;
|
13364 | if (props2.autoStart) {
|
13365 | use.raf(() => start());
|
13366 | }
|
13367 | };
|
13368 | vue.watch(() => props2.autoStart, (value) => {
|
13369 | if (value) {
|
13370 | start();
|
13371 | }
|
13372 | });
|
13373 | useExpose({
|
13374 | start,
|
13375 | reset
|
13376 | });
|
13377 | return () => vue.createVNode("div", {
|
13378 | "class": bem$n()
|
13379 | }, [targetNumArr.value.map((_, i) => vue.createVNode(stdin_default$x, {
|
13380 | "figureArr": isCustomType.value ? getTextArrByIdx(i) : getFigureArr(i),
|
13381 | "duration": props2.duration,
|
13382 | "direction": props2.direction,
|
13383 | "isStart": rolling.value,
|
13384 | "height": props2.height,
|
13385 | "delay": getDelay(i, itemLength.value)
|
13386 | }, null))]);
|
13387 | }
|
13388 | });
|
13389 | const RollingText = withInstall(stdin_default$w);
|
13390 | const Row = withInstall(stdin_default$17);
|
13391 | const [name$n, bem$m, t$4] = createNamespace("search");
|
13392 | const searchProps = extend({}, fieldSharedProps, {
|
13393 | label: String,
|
13394 | shape: makeStringProp("square"),
|
13395 | leftIcon: makeStringProp("search"),
|
13396 | clearable: truthProp,
|
13397 | actionText: String,
|
13398 | background: String,
|
13399 | showAction: Boolean
|
13400 | });
|
13401 | var stdin_default$v = vue.defineComponent({
|
13402 | name: name$n,
|
13403 | props: searchProps,
|
13404 | emits: ["blur", "focus", "clear", "search", "cancel", "clickInput", "clickLeftIcon", "clickRightIcon", "update:modelValue"],
|
13405 | setup(props2, {
|
13406 | emit,
|
13407 | slots,
|
13408 | attrs
|
13409 | }) {
|
13410 | const id = useId();
|
13411 | const fieldRef = vue.ref();
|
13412 | const onCancel = () => {
|
13413 | if (!slots.action) {
|
13414 | emit("update:modelValue", "");
|
13415 | emit("cancel");
|
13416 | }
|
13417 | };
|
13418 | const onKeypress = (event) => {
|
13419 | const ENTER_CODE = 13;
|
13420 | if (event.keyCode === ENTER_CODE) {
|
13421 | preventDefault(event);
|
13422 | emit("search", props2.modelValue);
|
13423 | }
|
13424 | };
|
13425 | const getInputId = () => props2.id || `${id}-input`;
|
13426 | const renderLabel = () => {
|
13427 | if (slots.label || props2.label) {
|
13428 | return vue.createVNode("label", {
|
13429 | "class": bem$m("label"),
|
13430 | "for": getInputId(),
|
13431 | "data-allow-mismatch": "attribute"
|
13432 | }, [slots.label ? slots.label() : props2.label]);
|
13433 | }
|
13434 | };
|
13435 | const renderAction = () => {
|
13436 | if (props2.showAction) {
|
13437 | const text = props2.actionText || t$4("cancel");
|
13438 | return vue.createVNode("div", {
|
13439 | "class": bem$m("action"),
|
13440 | "role": "button",
|
13441 | "tabindex": 0,
|
13442 | "onClick": onCancel
|
13443 | }, [slots.action ? slots.action() : text]);
|
13444 | }
|
13445 | };
|
13446 | const blur = () => {
|
13447 | var _a;
|
13448 | return (_a = fieldRef.value) == null ? void 0 : _a.blur();
|
13449 | };
|
13450 | const focus = () => {
|
13451 | var _a;
|
13452 | return (_a = fieldRef.value) == null ? void 0 : _a.focus();
|
13453 | };
|
13454 | const onBlur = (event) => emit("blur", event);
|
13455 | const onFocus = (event) => emit("focus", event);
|
13456 | const onClear = (event) => emit("clear", event);
|
13457 | const onClickInput = (event) => emit("clickInput", event);
|
13458 | const onClickLeftIcon = (event) => emit("clickLeftIcon", event);
|
13459 | const onClickRightIcon = (event) => emit("clickRightIcon", event);
|
13460 | const fieldPropNames = Object.keys(fieldSharedProps);
|
13461 | const renderField = () => {
|
13462 | const fieldAttrs = extend({}, attrs, pick(props2, fieldPropNames), {
|
13463 | id: getInputId()
|
13464 | });
|
13465 | const onInput = (value) => emit("update:modelValue", value);
|
13466 | return vue.createVNode(Field, vue.mergeProps({
|
13467 | "ref": fieldRef,
|
13468 | "type": "search",
|
13469 | "class": bem$m("field", {
|
13470 | "with-message": fieldAttrs.errorMessage
|
13471 | }),
|
13472 | "border": false,
|
13473 | "onBlur": onBlur,
|
13474 | "onFocus": onFocus,
|
13475 | "onClear": onClear,
|
13476 | "onKeypress": onKeypress,
|
13477 | "onClickInput": onClickInput,
|
13478 | "onClickLeftIcon": onClickLeftIcon,
|
13479 | "onClickRightIcon": onClickRightIcon,
|
13480 | "onUpdate:modelValue": onInput
|
13481 | }, fieldAttrs), pick(slots, ["left-icon", "right-icon"]));
|
13482 | };
|
13483 | useExpose({
|
13484 | focus,
|
13485 | blur
|
13486 | });
|
13487 | return () => {
|
13488 | var _a;
|
13489 | return vue.createVNode("div", {
|
13490 | "class": bem$m({
|
13491 | "show-action": props2.showAction
|
13492 | }),
|
13493 | "style": {
|
13494 | background: props2.background
|
13495 | }
|
13496 | }, [(_a = slots.left) == null ? void 0 : _a.call(slots), vue.createVNode("div", {
|
13497 | "class": bem$m("content", props2.shape)
|
13498 | }, [renderLabel(), renderField()]), renderAction()]);
|
13499 | };
|
13500 | }
|
13501 | });
|
13502 | const Search = withInstall(stdin_default$v);
|
13503 | const isImage = (name2) => name2 == null ? void 0 : name2.includes("/");
|
13504 | const popupInheritKeys = [...popupSharedPropKeys, "round", "closeOnPopstate", "safeAreaInsetBottom"];
|
13505 | const iconMap = {
|
13506 | qq: "qq",
|
13507 | link: "link-o",
|
13508 | weibo: "weibo",
|
13509 | qrcode: "qr",
|
13510 | poster: "photo-o",
|
13511 | wechat: "wechat",
|
13512 | "weapp-qrcode": "miniprogram-o",
|
13513 | "wechat-moments": "wechat-moments"
|
13514 | };
|
13515 | const [name$m, bem$l, t$3] = createNamespace("share-sheet");
|
13516 | const shareSheetProps = extend({}, popupSharedProps, {
|
13517 | title: String,
|
13518 | round: truthProp,
|
13519 | options: makeArrayProp(),
|
13520 | cancelText: String,
|
13521 | description: String,
|
13522 | closeOnPopstate: truthProp,
|
13523 | safeAreaInsetBottom: truthProp
|
13524 | });
|
13525 | var stdin_default$u = vue.defineComponent({
|
13526 | name: name$m,
|
13527 | props: shareSheetProps,
|
13528 | emits: ["cancel", "select", "update:show"],
|
13529 | setup(props2, {
|
13530 | emit,
|
13531 | slots
|
13532 | }) {
|
13533 | const updateShow = (value) => emit("update:show", value);
|
13534 | const onCancel = () => {
|
13535 | updateShow(false);
|
13536 | emit("cancel");
|
13537 | };
|
13538 | const onSelect = (option, index) => emit("select", option, index);
|
13539 | const renderHeader = () => {
|
13540 | const title = slots.title ? slots.title() : props2.title;
|
13541 | const description = slots.description ? slots.description() : props2.description;
|
13542 | if (title || description) {
|
13543 | return vue.createVNode("div", {
|
13544 | "class": bem$l("header")
|
13545 | }, [title && vue.createVNode("h2", {
|
13546 | "class": bem$l("title")
|
13547 | }, [title]), description && vue.createVNode("span", {
|
13548 | "class": bem$l("description")
|
13549 | }, [description])]);
|
13550 | }
|
13551 | };
|
13552 | const renderIcon = (icon) => {
|
13553 | if (isImage(icon)) {
|
13554 | return vue.createVNode("img", {
|
13555 | "src": icon,
|
13556 | "class": bem$l("image-icon")
|
13557 | }, null);
|
13558 | }
|
13559 | return vue.createVNode("div", {
|
13560 | "class": bem$l("icon", [icon])
|
13561 | }, [vue.createVNode(Icon, {
|
13562 | "name": iconMap[icon] || icon
|
13563 | }, null)]);
|
13564 | };
|
13565 | const renderOption = (option, index) => {
|
13566 | const {
|
13567 | name: name2,
|
13568 | icon,
|
13569 | className,
|
13570 | description
|
13571 | } = option;
|
13572 | return vue.createVNode("div", {
|
13573 | "role": "button",
|
13574 | "tabindex": 0,
|
13575 | "class": [bem$l("option"), className, HAPTICS_FEEDBACK],
|
13576 | "onClick": () => onSelect(option, index)
|
13577 | }, [renderIcon(icon), name2 && vue.createVNode("span", {
|
13578 | "class": bem$l("name")
|
13579 | }, [name2]), description && vue.createVNode("span", {
|
13580 | "class": bem$l("option-description")
|
13581 | }, [description])]);
|
13582 | };
|
13583 | const renderOptions = (options, border) => vue.createVNode("div", {
|
13584 | "class": bem$l("options", {
|
13585 | border
|
13586 | })
|
13587 | }, [options.map(renderOption)]);
|
13588 | const renderRows = () => {
|
13589 | const {
|
13590 | options
|
13591 | } = props2;
|
13592 | if (Array.isArray(options[0])) {
|
13593 | return options.map((item, index) => renderOptions(item, index !== 0));
|
13594 | }
|
13595 | return renderOptions(options);
|
13596 | };
|
13597 | const renderCancelButton = () => {
|
13598 | var _a;
|
13599 | const cancelText = (_a = props2.cancelText) != null ? _a : t$3("cancel");
|
13600 | if (slots.cancel || cancelText) {
|
13601 | return vue.createVNode("button", {
|
13602 | "type": "button",
|
13603 | "class": bem$l("cancel"),
|
13604 | "onClick": onCancel
|
13605 | }, [slots.cancel ? slots.cancel() : cancelText]);
|
13606 | }
|
13607 | };
|
13608 | return () => vue.createVNode(Popup, vue.mergeProps({
|
13609 | "class": bem$l(),
|
13610 | "position": "bottom",
|
13611 | "onUpdate:show": updateShow
|
13612 | }, pick(props2, popupInheritKeys)), {
|
13613 | default: () => [renderHeader(), renderRows(), renderCancelButton()]
|
13614 | });
|
13615 | }
|
13616 | });
|
13617 | const ShareSheet = withInstall(stdin_default$u);
|
13618 | const [name$l, bem$k] = createNamespace("sidebar");
|
13619 | const SIDEBAR_KEY = Symbol(name$l);
|
13620 | const sidebarProps = {
|
13621 | modelValue: makeNumericProp(0)
|
13622 | };
|
13623 | var stdin_default$t = vue.defineComponent({
|
13624 | name: name$l,
|
13625 | props: sidebarProps,
|
13626 | emits: ["change", "update:modelValue"],
|
13627 | setup(props2, {
|
13628 | emit,
|
13629 | slots
|
13630 | }) {
|
13631 | const {
|
13632 | linkChildren
|
13633 | } = use.useChildren(SIDEBAR_KEY);
|
13634 | const getActive = () => +props2.modelValue;
|
13635 | const setActive = (value) => {
|
13636 | if (value !== getActive()) {
|
13637 | emit("update:modelValue", value);
|
13638 | emit("change", value);
|
13639 | }
|
13640 | };
|
13641 | linkChildren({
|
13642 | getActive,
|
13643 | setActive
|
13644 | });
|
13645 | return () => {
|
13646 | var _a;
|
13647 | return vue.createVNode("div", {
|
13648 | "role": "tablist",
|
13649 | "class": bem$k()
|
13650 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
13651 | };
|
13652 | }
|
13653 | });
|
13654 | const Sidebar = withInstall(stdin_default$t);
|
13655 | const [name$k, bem$j] = createNamespace("sidebar-item");
|
13656 | const sidebarItemProps = extend({}, routeProps, {
|
13657 | dot: Boolean,
|
13658 | title: String,
|
13659 | badge: numericProp,
|
13660 | disabled: Boolean,
|
13661 | badgeProps: Object
|
13662 | });
|
13663 | var stdin_default$s = vue.defineComponent({
|
13664 | name: name$k,
|
13665 | props: sidebarItemProps,
|
13666 | emits: ["click"],
|
13667 | setup(props2, {
|
13668 | emit,
|
13669 | slots
|
13670 | }) {
|
13671 | const route2 = useRoute();
|
13672 | const {
|
13673 | parent,
|
13674 | index
|
13675 | } = use.useParent(SIDEBAR_KEY);
|
13676 | if (!parent) {
|
13677 | if (process.env.NODE_ENV !== "production") {
|
13678 | console.error("[Vant] <SidebarItem> must be a child component of <Sidebar>.");
|
13679 | }
|
13680 | return;
|
13681 | }
|
13682 | const onClick = () => {
|
13683 | if (props2.disabled) {
|
13684 | return;
|
13685 | }
|
13686 | emit("click", index.value);
|
13687 | parent.setActive(index.value);
|
13688 | route2();
|
13689 | };
|
13690 | return () => {
|
13691 | const {
|
13692 | dot,
|
13693 | badge,
|
13694 | title,
|
13695 | disabled
|
13696 | } = props2;
|
13697 | const selected = index.value === parent.getActive();
|
13698 | return vue.createVNode("div", {
|
13699 | "role": "tab",
|
13700 | "class": bem$j({
|
13701 | select: selected,
|
13702 | disabled
|
13703 | }),
|
13704 | "tabindex": disabled ? void 0 : 0,
|
13705 | "aria-selected": selected,
|
13706 | "onClick": onClick
|
13707 | }, [vue.createVNode(Badge, vue.mergeProps({
|
13708 | "dot": dot,
|
13709 | "class": bem$j("text"),
|
13710 | "content": badge
|
13711 | }, props2.badgeProps), {
|
13712 | default: () => [slots.title ? slots.title() : title]
|
13713 | })]);
|
13714 | };
|
13715 | }
|
13716 | });
|
13717 | const SidebarItem = withInstall(stdin_default$s);
|
13718 | const [name$j, bem$i, t$2] = createNamespace("signature");
|
13719 | const signatureProps = {
|
13720 | tips: String,
|
13721 | type: makeStringProp("png"),
|
13722 | penColor: makeStringProp("#000"),
|
13723 | lineWidth: makeNumberProp(3),
|
13724 | clearButtonText: String,
|
13725 | backgroundColor: makeStringProp(""),
|
13726 | confirmButtonText: String
|
13727 | };
|
13728 | const hasCanvasSupport = () => {
|
13729 | var _a;
|
13730 | const canvas = document.createElement("canvas");
|
13731 | return !!((_a = canvas.getContext) == null ? void 0 : _a.call(canvas, "2d"));
|
13732 | };
|
13733 | var stdin_default$r = vue.defineComponent({
|
13734 | name: name$j,
|
13735 | props: signatureProps,
|
13736 | emits: ["submit", "clear", "start", "end", "signing"],
|
13737 | setup(props2, {
|
13738 | emit
|
13739 | }) {
|
13740 | const canvasRef = vue.ref();
|
13741 | const wrapRef = vue.ref();
|
13742 | const ctx = vue.computed(() => {
|
13743 | if (!canvasRef.value) return null;
|
13744 | return canvasRef.value.getContext("2d");
|
13745 | });
|
13746 | const isRenderCanvas = inBrowser ? hasCanvasSupport() : true;
|
13747 | let canvasWidth = 0;
|
13748 | let canvasHeight = 0;
|
13749 | let canvasRect;
|
13750 | const touchStart = () => {
|
13751 | if (!ctx.value) {
|
13752 | return false;
|
13753 | }
|
13754 | ctx.value.beginPath();
|
13755 | ctx.value.lineWidth = props2.lineWidth;
|
13756 | ctx.value.strokeStyle = props2.penColor;
|
13757 | canvasRect = use.useRect(canvasRef);
|
13758 | emit("start");
|
13759 | };
|
13760 | const touchMove = (event) => {
|
13761 | if (!ctx.value) {
|
13762 | return false;
|
13763 | }
|
13764 | preventDefault(event);
|
13765 | const touch = event.touches[0];
|
13766 | const mouseX = touch.clientX - ((canvasRect == null ? void 0 : canvasRect.left) || 0);
|
13767 | const mouseY = touch.clientY - ((canvasRect == null ? void 0 : canvasRect.top) || 0);
|
13768 | ctx.value.lineCap = "round";
|
13769 | ctx.value.lineJoin = "round";
|
13770 | ctx.value.lineTo(mouseX, mouseY);
|
13771 | ctx.value.stroke();
|
13772 | emit("signing", event);
|
13773 | };
|
13774 | const touchEnd = (event) => {
|
13775 | preventDefault(event);
|
13776 | emit("end");
|
13777 | };
|
13778 | const isCanvasEmpty = (canvas) => {
|
13779 | const empty = document.createElement("canvas");
|
13780 | empty.width = canvas.width;
|
13781 | empty.height = canvas.height;
|
13782 | if (props2.backgroundColor) {
|
13783 | const emptyCtx = empty.getContext("2d");
|
13784 | setCanvasBgColor(emptyCtx);
|
13785 | }
|
13786 | return canvas.toDataURL() === empty.toDataURL();
|
13787 | };
|
13788 | const setCanvasBgColor = (ctx2) => {
|
13789 | if (ctx2 && props2.backgroundColor) {
|
13790 | ctx2.fillStyle = props2.backgroundColor;
|
13791 | ctx2.fillRect(0, 0, canvasWidth, canvasHeight);
|
13792 | }
|
13793 | };
|
13794 | const submit = () => {
|
13795 | var _a, _b;
|
13796 | const canvas = canvasRef.value;
|
13797 | if (!canvas) {
|
13798 | return;
|
13799 | }
|
13800 | const isEmpty = isCanvasEmpty(canvas);
|
13801 | const image = isEmpty ? "" : ((_b = (_a = {
|
13802 | jpg: () => canvas.toDataURL("image/jpeg", 0.8),
|
13803 | jpeg: () => canvas.toDataURL("image/jpeg", 0.8)
|
13804 | })[props2.type]) == null ? void 0 : _b.call(_a)) || canvas.toDataURL(`image/${props2.type}`);
|
13805 | emit("submit", {
|
13806 | image,
|
13807 | canvas
|
13808 | });
|
13809 | };
|
13810 | const clear = () => {
|
13811 | if (ctx.value) {
|
13812 | ctx.value.clearRect(0, 0, canvasWidth, canvasHeight);
|
13813 | ctx.value.closePath();
|
13814 | setCanvasBgColor(ctx.value);
|
13815 | }
|
13816 | emit("clear");
|
13817 | };
|
13818 | const initialize = () => {
|
13819 | var _a, _b, _c;
|
13820 | if (isRenderCanvas && canvasRef.value) {
|
13821 | const canvas = canvasRef.value;
|
13822 | const dpr = inBrowser ? window.devicePixelRatio : 1;
|
13823 | canvasWidth = canvas.width = (((_a = wrapRef.value) == null ? void 0 : _a.offsetWidth) || 0) * dpr;
|
13824 | canvasHeight = canvas.height = (((_b = wrapRef.value) == null ? void 0 : _b.offsetHeight) || 0) * dpr;
|
13825 | (_c = ctx.value) == null ? void 0 : _c.scale(dpr, dpr);
|
13826 | setCanvasBgColor(ctx.value);
|
13827 | }
|
13828 | };
|
13829 | const resize = () => {
|
13830 | if (ctx.value) {
|
13831 | const data = ctx.value.getImageData(0, 0, canvasWidth, canvasHeight);
|
13832 | initialize();
|
13833 | ctx.value.putImageData(data, 0, 0);
|
13834 | }
|
13835 | };
|
13836 | vue.watch(windowWidth, resize);
|
13837 | vue.onMounted(initialize);
|
13838 | useExpose({
|
13839 | resize,
|
13840 | clear,
|
13841 | submit
|
13842 | });
|
13843 | return () => vue.createVNode("div", {
|
13844 | "class": bem$i()
|
13845 | }, [vue.createVNode("div", {
|
13846 | "class": bem$i("content"),
|
13847 | "ref": wrapRef
|
13848 | }, [isRenderCanvas ? vue.createVNode("canvas", {
|
13849 | "ref": canvasRef,
|
13850 | "onTouchstartPassive": touchStart,
|
13851 | "onTouchmove": touchMove,
|
13852 | "onTouchend": touchEnd
|
13853 | }, null) : vue.createVNode("p", null, [props2.tips])]), vue.createVNode("div", {
|
13854 | "class": bem$i("footer")
|
13855 | }, [vue.createVNode(Button, {
|
13856 | "size": "small",
|
13857 | "onClick": clear
|
13858 | }, {
|
13859 | default: () => [props2.clearButtonText || t$2("clear")]
|
13860 | }), vue.createVNode(Button, {
|
13861 | "type": "primary",
|
13862 | "size": "small",
|
13863 | "onClick": submit
|
13864 | }, {
|
13865 | default: () => [props2.confirmButtonText || t$2("confirm")]
|
13866 | })])]);
|
13867 | }
|
13868 | });
|
13869 | const Signature = withInstall(stdin_default$r);
|
13870 | const [name$i, bem$h] = createNamespace("skeleton-title");
|
13871 | const skeletonTitleProps = {
|
13872 | round: Boolean,
|
13873 | titleWidth: numericProp
|
13874 | };
|
13875 | var stdin_default$q = vue.defineComponent({
|
13876 | name: name$i,
|
13877 | props: skeletonTitleProps,
|
13878 | setup(props2) {
|
13879 | return () => vue.createVNode("h3", {
|
13880 | "class": bem$h([{
|
13881 | round: props2.round
|
13882 | }]),
|
13883 | "style": {
|
13884 | width: addUnit(props2.titleWidth)
|
13885 | }
|
13886 | }, null);
|
13887 | }
|
13888 | });
|
13889 | const SkeletonTitle = withInstall(stdin_default$q);
|
13890 | var stdin_default$p = SkeletonTitle;
|
13891 | const [name$h, bem$g] = createNamespace("skeleton-avatar");
|
13892 | const skeletonAvatarProps = {
|
13893 | avatarSize: numericProp,
|
13894 | avatarShape: makeStringProp("round")
|
13895 | };
|
13896 | var stdin_default$o = vue.defineComponent({
|
13897 | name: name$h,
|
13898 | props: skeletonAvatarProps,
|
13899 | setup(props2) {
|
13900 | return () => vue.createVNode("div", {
|
13901 | "class": bem$g([props2.avatarShape]),
|
13902 | "style": getSizeStyle(props2.avatarSize)
|
13903 | }, null);
|
13904 | }
|
13905 | });
|
13906 | const SkeletonAvatar = withInstall(stdin_default$o);
|
13907 | var stdin_default$n = SkeletonAvatar;
|
13908 | const DEFAULT_ROW_WIDTH = "100%";
|
13909 | const skeletonParagraphProps = {
|
13910 | round: Boolean,
|
13911 | rowWidth: {
|
13912 | type: numericProp,
|
13913 | default: DEFAULT_ROW_WIDTH
|
13914 | }
|
13915 | };
|
13916 | const [name$g, bem$f] = createNamespace("skeleton-paragraph");
|
13917 | var stdin_default$m = vue.defineComponent({
|
13918 | name: name$g,
|
13919 | props: skeletonParagraphProps,
|
13920 | setup(props2) {
|
13921 | return () => vue.createVNode("div", {
|
13922 | "class": bem$f([{
|
13923 | round: props2.round
|
13924 | }]),
|
13925 | "style": {
|
13926 | width: props2.rowWidth
|
13927 | }
|
13928 | }, null);
|
13929 | }
|
13930 | });
|
13931 | const SkeletonParagraph = withInstall(stdin_default$m);
|
13932 | var stdin_default$l = SkeletonParagraph;
|
13933 | const [name$f, bem$e] = createNamespace("skeleton");
|
13934 | const DEFAULT_LAST_ROW_WIDTH = "60%";
|
13935 | const skeletonProps = {
|
13936 | row: makeNumericProp(0),
|
13937 | round: Boolean,
|
13938 | title: Boolean,
|
13939 | titleWidth: numericProp,
|
13940 | avatar: Boolean,
|
13941 | avatarSize: numericProp,
|
13942 | avatarShape: makeStringProp("round"),
|
13943 | loading: truthProp,
|
13944 | animate: truthProp,
|
13945 | rowWidth: {
|
13946 | type: [Number, String, Array],
|
13947 | default: DEFAULT_ROW_WIDTH
|
13948 | }
|
13949 | };
|
13950 | var stdin_default$k = vue.defineComponent({
|
13951 | name: name$f,
|
13952 | inheritAttrs: false,
|
13953 | props: skeletonProps,
|
13954 | setup(props2, {
|
13955 | slots,
|
13956 | attrs
|
13957 | }) {
|
13958 | const renderAvatar = () => {
|
13959 | if (props2.avatar) {
|
13960 | return vue.createVNode(stdin_default$n, {
|
13961 | "avatarShape": props2.avatarShape,
|
13962 | "avatarSize": props2.avatarSize
|
13963 | }, null);
|
13964 | }
|
13965 | };
|
13966 | const renderTitle = () => {
|
13967 | if (props2.title) {
|
13968 | return vue.createVNode(stdin_default$p, {
|
13969 | "round": props2.round,
|
13970 | "titleWidth": props2.titleWidth
|
13971 | }, null);
|
13972 | }
|
13973 | };
|
13974 | const getRowWidth = (index) => {
|
13975 | const {
|
13976 | rowWidth
|
13977 | } = props2;
|
13978 | if (rowWidth === DEFAULT_ROW_WIDTH && index === +props2.row - 1) {
|
13979 | return DEFAULT_LAST_ROW_WIDTH;
|
13980 | }
|
13981 | if (Array.isArray(rowWidth)) {
|
13982 | return rowWidth[index];
|
13983 | }
|
13984 | return rowWidth;
|
13985 | };
|
13986 | const renderRows = () => Array(+props2.row).fill("").map((_, i) => vue.createVNode(stdin_default$l, {
|
13987 | "key": i,
|
13988 | "round": props2.round,
|
13989 | "rowWidth": addUnit(getRowWidth(i))
|
13990 | }, null));
|
13991 | const renderContents = () => {
|
13992 | if (slots.template) {
|
13993 | return slots.template();
|
13994 | }
|
13995 | return vue.createVNode(vue.Fragment, null, [renderAvatar(), vue.createVNode("div", {
|
13996 | "class": bem$e("content")
|
13997 | }, [renderTitle(), renderRows()])]);
|
13998 | };
|
13999 | return () => {
|
14000 | var _a;
|
14001 | if (!props2.loading) {
|
14002 | return (_a = slots.default) == null ? void 0 : _a.call(slots);
|
14003 | }
|
14004 | return vue.createVNode("div", vue.mergeProps({
|
14005 | "class": bem$e({
|
14006 | animate: props2.animate,
|
14007 | round: props2.round
|
14008 | })
|
14009 | }, attrs), [renderContents()]);
|
14010 | };
|
14011 | }
|
14012 | });
|
14013 | const Skeleton = withInstall(stdin_default$k);
|
14014 | const [name$e, bem$d] = createNamespace("skeleton-image");
|
14015 | const skeletonImageProps = {
|
14016 | imageSize: numericProp,
|
14017 | imageShape: makeStringProp("square")
|
14018 | };
|
14019 | var stdin_default$j = vue.defineComponent({
|
14020 | name: name$e,
|
14021 | props: skeletonImageProps,
|
14022 | setup(props2) {
|
14023 | return () => vue.createVNode("div", {
|
14024 | "class": bem$d([props2.imageShape]),
|
14025 | "style": getSizeStyle(props2.imageSize)
|
14026 | }, [vue.createVNode(Icon, {
|
14027 | "name": "photo",
|
14028 | "class": bem$d("icon")
|
14029 | }, null)]);
|
14030 | }
|
14031 | });
|
14032 | const SkeletonImage = withInstall(stdin_default$j);
|
14033 | const [name$d, bem$c] = createNamespace("slider");
|
14034 | const sliderProps = {
|
14035 | min: makeNumericProp(0),
|
14036 | max: makeNumericProp(100),
|
14037 | step: makeNumericProp(1),
|
14038 | range: Boolean,
|
14039 | reverse: Boolean,
|
14040 | disabled: Boolean,
|
14041 | readonly: Boolean,
|
14042 | vertical: Boolean,
|
14043 | barHeight: numericProp,
|
14044 | buttonSize: numericProp,
|
14045 | activeColor: String,
|
14046 | inactiveColor: String,
|
14047 | modelValue: {
|
14048 | type: [Number, Array],
|
14049 | default: 0
|
14050 | }
|
14051 | };
|
14052 | var stdin_default$i = vue.defineComponent({
|
14053 | name: name$d,
|
14054 | props: sliderProps,
|
14055 | emits: ["change", "dragEnd", "dragStart", "update:modelValue"],
|
14056 | setup(props2, {
|
14057 | emit,
|
14058 | slots
|
14059 | }) {
|
14060 | let buttonIndex;
|
14061 | let current2;
|
14062 | let startValue;
|
14063 | const root = vue.ref();
|
14064 | const slider = [vue.ref(), vue.ref()];
|
14065 | const dragStatus = vue.ref();
|
14066 | const touch = useTouch();
|
14067 | const scope = vue.computed(() => Number(props2.max) - Number(props2.min));
|
14068 | const wrapperStyle = vue.computed(() => {
|
14069 | const crossAxis = props2.vertical ? "width" : "height";
|
14070 | return {
|
14071 | background: props2.inactiveColor,
|
14072 | [crossAxis]: addUnit(props2.barHeight)
|
14073 | };
|
14074 | });
|
14075 | const isRange = (val) => props2.range && Array.isArray(val);
|
14076 | const calcMainAxis = () => {
|
14077 | const {
|
14078 | modelValue,
|
14079 | min
|
14080 | } = props2;
|
14081 | if (isRange(modelValue)) {
|
14082 | return `${(modelValue[1] - modelValue[0]) * 100 / scope.value}%`;
|
14083 | }
|
14084 | return `${(modelValue - Number(min)) * 100 / scope.value}%`;
|
14085 | };
|
14086 | const calcOffset = () => {
|
14087 | const {
|
14088 | modelValue,
|
14089 | min
|
14090 | } = props2;
|
14091 | if (isRange(modelValue)) {
|
14092 | return `${(modelValue[0] - Number(min)) * 100 / scope.value}%`;
|
14093 | }
|
14094 | return "0%";
|
14095 | };
|
14096 | const barStyle = vue.computed(() => {
|
14097 | const mainAxis = props2.vertical ? "height" : "width";
|
14098 | const style = {
|
14099 | [mainAxis]: calcMainAxis(),
|
14100 | background: props2.activeColor
|
14101 | };
|
14102 | if (dragStatus.value) {
|
14103 | style.transition = "none";
|
14104 | }
|
14105 | const getPositionKey = () => {
|
14106 | if (props2.vertical) {
|
14107 | return props2.reverse ? "bottom" : "top";
|
14108 | }
|
14109 | return props2.reverse ? "right" : "left";
|
14110 | };
|
14111 | style[getPositionKey()] = calcOffset();
|
14112 | return style;
|
14113 | });
|
14114 | const format2 = (value) => {
|
14115 | const min = +props2.min;
|
14116 | const max = +props2.max;
|
14117 | const step = +props2.step;
|
14118 | value = clamp(value, min, max);
|
14119 | const diff = Math.round((value - min) / step) * step;
|
14120 | return addNumber(min, diff);
|
14121 | };
|
14122 | const updateStartValue = () => {
|
14123 | const current22 = props2.modelValue;
|
14124 | if (isRange(current22)) {
|
14125 | startValue = current22.map(format2);
|
14126 | } else {
|
14127 | startValue = format2(current22);
|
14128 | }
|
14129 | };
|
14130 | const handleRangeValue = (value) => {
|
14131 | var _a, _b;
|
14132 | const left = (_a = value[0]) != null ? _a : Number(props2.min);
|
14133 | const right = (_b = value[1]) != null ? _b : Number(props2.max);
|
14134 | return left > right ? [right, left] : [left, right];
|
14135 | };
|
14136 | const updateValue = (value, end) => {
|
14137 | if (isRange(value)) {
|
14138 | value = handleRangeValue(value).map(format2);
|
14139 | } else {
|
14140 | value = format2(value);
|
14141 | }
|
14142 | if (!isSameValue(value, props2.modelValue)) {
|
14143 | emit("update:modelValue", value);
|
14144 | }
|
14145 | if (end && !isSameValue(value, startValue)) {
|
14146 | emit("change", value);
|
14147 | }
|
14148 | };
|
14149 | const onClick = (event) => {
|
14150 | event.stopPropagation();
|
14151 | if (props2.disabled || props2.readonly) {
|
14152 | return;
|
14153 | }
|
14154 | updateStartValue();
|
14155 | const {
|
14156 | min,
|
14157 | reverse,
|
14158 | vertical,
|
14159 | modelValue
|
14160 | } = props2;
|
14161 | const rect = use.useRect(root);
|
14162 | const getDelta = () => {
|
14163 | if (vertical) {
|
14164 | if (reverse) {
|
14165 | return rect.bottom - event.clientY;
|
14166 | }
|
14167 | return event.clientY - rect.top;
|
14168 | }
|
14169 | if (reverse) {
|
14170 | return rect.right - event.clientX;
|
14171 | }
|
14172 | return event.clientX - rect.left;
|
14173 | };
|
14174 | const total = vertical ? rect.height : rect.width;
|
14175 | const value = Number(min) + getDelta() / total * scope.value;
|
14176 | if (isRange(modelValue)) {
|
14177 | const [left, right] = modelValue;
|
14178 | const middle = (left + right) / 2;
|
14179 | if (value <= middle) {
|
14180 | updateValue([value, right], true);
|
14181 | } else {
|
14182 | updateValue([left, value], true);
|
14183 | }
|
14184 | } else {
|
14185 | updateValue(value, true);
|
14186 | }
|
14187 | };
|
14188 | const onTouchStart = (event) => {
|
14189 | if (props2.disabled || props2.readonly) {
|
14190 | return;
|
14191 | }
|
14192 | touch.start(event);
|
14193 | current2 = props2.modelValue;
|
14194 | updateStartValue();
|
14195 | dragStatus.value = "start";
|
14196 | };
|
14197 | const onTouchMove = (event) => {
|
14198 | if (props2.disabled || props2.readonly) {
|
14199 | return;
|
14200 | }
|
14201 | if (dragStatus.value === "start") {
|
14202 | emit("dragStart", event);
|
14203 | }
|
14204 | preventDefault(event, true);
|
14205 | touch.move(event);
|
14206 | dragStatus.value = "dragging";
|
14207 | const rect = use.useRect(root);
|
14208 | const delta = props2.vertical ? touch.deltaY.value : touch.deltaX.value;
|
14209 | const total = props2.vertical ? rect.height : rect.width;
|
14210 | let diff = delta / total * scope.value;
|
14211 | if (props2.reverse) {
|
14212 | diff = -diff;
|
14213 | }
|
14214 | if (isRange(startValue)) {
|
14215 | const index = props2.reverse ? 1 - buttonIndex : buttonIndex;
|
14216 | current2[index] = startValue[index] + diff;
|
14217 | } else {
|
14218 | current2 = startValue + diff;
|
14219 | }
|
14220 | updateValue(current2);
|
14221 | };
|
14222 | const onTouchEnd = (event) => {
|
14223 | if (props2.disabled || props2.readonly) {
|
14224 | return;
|
14225 | }
|
14226 | if (dragStatus.value === "dragging") {
|
14227 | updateValue(current2, true);
|
14228 | emit("dragEnd", event);
|
14229 | }
|
14230 | dragStatus.value = "";
|
14231 | };
|
14232 | const getButtonClassName = (index) => {
|
14233 | if (typeof index === "number") {
|
14234 | const position = ["left", "right"];
|
14235 | return bem$c(`button-wrapper`, position[index]);
|
14236 | }
|
14237 | return bem$c("button-wrapper", props2.reverse ? "left" : "right");
|
14238 | };
|
14239 | const renderButtonContent = (value, index) => {
|
14240 | const dragging = dragStatus.value === "dragging";
|
14241 | if (typeof index === "number") {
|
14242 | const slot = slots[index === 0 ? "left-button" : "right-button"];
|
14243 | let dragIndex;
|
14244 | if (dragging && Array.isArray(current2)) {
|
14245 | dragIndex = current2[0] > current2[1] ? buttonIndex ^ 1 : buttonIndex;
|
14246 | }
|
14247 | if (slot) {
|
14248 | return slot({
|
14249 | value,
|
14250 | dragging,
|
14251 | dragIndex
|
14252 | });
|
14253 | }
|
14254 | }
|
14255 | if (slots.button) {
|
14256 | return slots.button({
|
14257 | value,
|
14258 | dragging
|
14259 | });
|
14260 | }
|
14261 | return vue.createVNode("div", {
|
14262 | "class": bem$c("button"),
|
14263 | "style": getSizeStyle(props2.buttonSize)
|
14264 | }, null);
|
14265 | };
|
14266 | const renderButton = (index) => {
|
14267 | const current22 = typeof index === "number" ? props2.modelValue[index] : props2.modelValue;
|
14268 | return vue.createVNode("div", {
|
14269 | "ref": slider[index != null ? index : 0],
|
14270 | "role": "slider",
|
14271 | "class": getButtonClassName(index),
|
14272 | "tabindex": props2.disabled ? void 0 : 0,
|
14273 | "aria-valuemin": props2.min,
|
14274 | "aria-valuenow": current22,
|
14275 | "aria-valuemax": props2.max,
|
14276 | "aria-disabled": props2.disabled || void 0,
|
14277 | "aria-readonly": props2.readonly || void 0,
|
14278 | "aria-orientation": props2.vertical ? "vertical" : "horizontal",
|
14279 | "onTouchstartPassive": (event) => {
|
14280 | if (typeof index === "number") {
|
14281 | buttonIndex = index;
|
14282 | }
|
14283 | onTouchStart(event);
|
14284 | },
|
14285 | "onTouchend": onTouchEnd,
|
14286 | "onTouchcancel": onTouchEnd,
|
14287 | "onClick": stopPropagation
|
14288 | }, [renderButtonContent(current22, index)]);
|
14289 | };
|
14290 | updateValue(props2.modelValue);
|
14291 | use.useCustomFieldValue(() => props2.modelValue);
|
14292 | slider.forEach((item) => {
|
14293 | use.useEventListener("touchmove", onTouchMove, {
|
14294 | target: item
|
14295 | });
|
14296 | });
|
14297 | return () => vue.createVNode("div", {
|
14298 | "ref": root,
|
14299 | "style": wrapperStyle.value,
|
14300 | "class": bem$c({
|
14301 | vertical: props2.vertical,
|
14302 | disabled: props2.disabled
|
14303 | }),
|
14304 | "onClick": onClick
|
14305 | }, [vue.createVNode("div", {
|
14306 | "class": bem$c("bar"),
|
14307 | "style": barStyle.value
|
14308 | }, [props2.range ? [renderButton(0), renderButton(1)] : renderButton()])]);
|
14309 | }
|
14310 | });
|
14311 | const Slider = withInstall(stdin_default$i);
|
14312 | const [name$c, bem$b] = createNamespace("space");
|
14313 | const spaceProps = {
|
14314 | align: String,
|
14315 | direction: {
|
14316 | type: String,
|
14317 | default: "horizontal"
|
14318 | },
|
14319 | size: {
|
14320 | type: [Number, String, Array],
|
14321 | default: 8
|
14322 | },
|
14323 | wrap: Boolean,
|
14324 | fill: Boolean
|
14325 | };
|
14326 | function filterEmpty(children = []) {
|
14327 | const nodes = [];
|
14328 | children.forEach((child) => {
|
14329 | if (Array.isArray(child)) {
|
14330 | nodes.push(...child);
|
14331 | } else if (child.type === vue.Fragment) {
|
14332 | nodes.push(...filterEmpty(child.children));
|
14333 | } else {
|
14334 | nodes.push(child);
|
14335 | }
|
14336 | });
|
14337 | return nodes.filter((c) => {
|
14338 | var _a;
|
14339 | 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() === ""));
|
14340 | });
|
14341 | }
|
14342 | var stdin_default$h = vue.defineComponent({
|
14343 | name: name$c,
|
14344 | props: spaceProps,
|
14345 | setup(props2, {
|
14346 | slots
|
14347 | }) {
|
14348 | const mergedAlign = vue.computed(() => {
|
14349 | var _a;
|
14350 | return (_a = props2.align) != null ? _a : props2.direction === "horizontal" ? "center" : "";
|
14351 | });
|
14352 | const getMargin = (size) => {
|
14353 | if (typeof size === "number") {
|
14354 | return size + "px";
|
14355 | }
|
14356 | return size;
|
14357 | };
|
14358 | const getMarginStyle = (isLast) => {
|
14359 | const style = {};
|
14360 | const marginRight = `${getMargin(Array.isArray(props2.size) ? props2.size[0] : props2.size)}`;
|
14361 | const marginBottom = `${getMargin(Array.isArray(props2.size) ? props2.size[1] : props2.size)}`;
|
14362 | if (isLast) {
|
14363 | return props2.wrap ? {
|
14364 | marginBottom
|
14365 | } : {};
|
14366 | }
|
14367 | if (props2.direction === "horizontal") {
|
14368 | style.marginRight = marginRight;
|
14369 | }
|
14370 | if (props2.direction === "vertical" || props2.wrap) {
|
14371 | style.marginBottom = marginBottom;
|
14372 | }
|
14373 | return style;
|
14374 | };
|
14375 | return () => {
|
14376 | var _a;
|
14377 | const children = filterEmpty((_a = slots.default) == null ? void 0 : _a.call(slots));
|
14378 | return vue.createVNode("div", {
|
14379 | "class": [bem$b({
|
14380 | [props2.direction]: props2.direction,
|
14381 | [`align-${mergedAlign.value}`]: mergedAlign.value,
|
14382 | wrap: props2.wrap,
|
14383 | fill: props2.fill
|
14384 | })]
|
14385 | }, [children.map((c, i) => vue.createVNode("div", {
|
14386 | "key": `item-${i}`,
|
14387 | "class": `${name$c}-item`,
|
14388 | "style": getMarginStyle(i === children.length - 1)
|
14389 | }, [c]))]);
|
14390 | };
|
14391 | }
|
14392 | });
|
14393 | const Space = withInstall(stdin_default$h);
|
14394 | const [name$b, bem$a] = createNamespace("steps");
|
14395 | const stepsProps = {
|
14396 | active: makeNumericProp(0),
|
14397 | direction: makeStringProp("horizontal"),
|
14398 | activeIcon: makeStringProp("checked"),
|
14399 | iconPrefix: String,
|
14400 | finishIcon: String,
|
14401 | activeColor: String,
|
14402 | inactiveIcon: String,
|
14403 | inactiveColor: String
|
14404 | };
|
14405 | const STEPS_KEY = Symbol(name$b);
|
14406 | var stdin_default$g = vue.defineComponent({
|
14407 | name: name$b,
|
14408 | props: stepsProps,
|
14409 | emits: ["clickStep"],
|
14410 | setup(props2, {
|
14411 | emit,
|
14412 | slots
|
14413 | }) {
|
14414 | const {
|
14415 | linkChildren
|
14416 | } = use.useChildren(STEPS_KEY);
|
14417 | const onClickStep = (index) => emit("clickStep", index);
|
14418 | linkChildren({
|
14419 | props: props2,
|
14420 | onClickStep
|
14421 | });
|
14422 | return () => {
|
14423 | var _a;
|
14424 | return vue.createVNode("div", {
|
14425 | "class": bem$a([props2.direction])
|
14426 | }, [vue.createVNode("div", {
|
14427 | "class": bem$a("items")
|
14428 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
|
14429 | };
|
14430 | }
|
14431 | });
|
14432 | const [name$a, bem$9] = createNamespace("step");
|
14433 | var stdin_default$f = vue.defineComponent({
|
14434 | name: name$a,
|
14435 | setup(props2, {
|
14436 | slots
|
14437 | }) {
|
14438 | const {
|
14439 | parent,
|
14440 | index
|
14441 | } = use.useParent(STEPS_KEY);
|
14442 | if (!parent) {
|
14443 | if (process.env.NODE_ENV !== "production") {
|
14444 | console.error("[Vant] <Step> must be a child component of <Steps>.");
|
14445 | }
|
14446 | return;
|
14447 | }
|
14448 | const parentProps = parent.props;
|
14449 | const getStatus = () => {
|
14450 | const active = +parentProps.active;
|
14451 | if (index.value < active) {
|
14452 | return "finish";
|
14453 | }
|
14454 | return index.value === active ? "process" : "waiting";
|
14455 | };
|
14456 | const isActive = () => getStatus() === "process";
|
14457 | const lineStyle = vue.computed(() => ({
|
14458 | background: getStatus() === "finish" ? parentProps.activeColor : parentProps.inactiveColor
|
14459 | }));
|
14460 | const titleStyle = vue.computed(() => {
|
14461 | if (isActive()) {
|
14462 | return {
|
14463 | color: parentProps.activeColor
|
14464 | };
|
14465 | }
|
14466 | if (getStatus() === "waiting") {
|
14467 | return {
|
14468 | color: parentProps.inactiveColor
|
14469 | };
|
14470 | }
|
14471 | });
|
14472 | const onClickStep = () => parent.onClickStep(index.value);
|
14473 | const renderCircle = () => {
|
14474 | const {
|
14475 | iconPrefix,
|
14476 | finishIcon,
|
14477 | activeIcon,
|
14478 | activeColor,
|
14479 | inactiveIcon
|
14480 | } = parentProps;
|
14481 | if (isActive()) {
|
14482 | if (slots["active-icon"]) {
|
14483 | return slots["active-icon"]();
|
14484 | }
|
14485 | return vue.createVNode(Icon, {
|
14486 | "class": bem$9("icon", "active"),
|
14487 | "name": activeIcon,
|
14488 | "color": activeColor,
|
14489 | "classPrefix": iconPrefix
|
14490 | }, null);
|
14491 | }
|
14492 | if (getStatus() === "finish" && (finishIcon || slots["finish-icon"])) {
|
14493 | if (slots["finish-icon"]) {
|
14494 | return slots["finish-icon"]();
|
14495 | }
|
14496 | return vue.createVNode(Icon, {
|
14497 | "class": bem$9("icon", "finish"),
|
14498 | "name": finishIcon,
|
14499 | "color": activeColor,
|
14500 | "classPrefix": iconPrefix
|
14501 | }, null);
|
14502 | }
|
14503 | if (slots["inactive-icon"]) {
|
14504 | return slots["inactive-icon"]();
|
14505 | }
|
14506 | if (inactiveIcon) {
|
14507 | return vue.createVNode(Icon, {
|
14508 | "class": bem$9("icon"),
|
14509 | "name": inactiveIcon,
|
14510 | "classPrefix": iconPrefix
|
14511 | }, null);
|
14512 | }
|
14513 | return vue.createVNode("i", {
|
14514 | "class": bem$9("circle"),
|
14515 | "style": lineStyle.value
|
14516 | }, null);
|
14517 | };
|
14518 | return () => {
|
14519 | var _a;
|
14520 | const status = getStatus();
|
14521 | return vue.createVNode("div", {
|
14522 | "class": [BORDER, bem$9([parentProps.direction, {
|
14523 | [status]: status
|
14524 | }])]
|
14525 | }, [vue.createVNode("div", {
|
14526 | "class": bem$9("title", {
|
14527 | active: isActive()
|
14528 | }),
|
14529 | "style": titleStyle.value,
|
14530 | "onClick": onClickStep
|
14531 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), vue.createVNode("div", {
|
14532 | "class": bem$9("circle-container"),
|
14533 | "onClick": onClickStep
|
14534 | }, [renderCircle()]), vue.createVNode("div", {
|
14535 | "class": bem$9("line"),
|
14536 | "style": lineStyle.value
|
14537 | }, null)]);
|
14538 | };
|
14539 | }
|
14540 | });
|
14541 | const Step = withInstall(stdin_default$f);
|
14542 | const [name$9, bem$8] = createNamespace("stepper");
|
14543 | const LONG_PRESS_INTERVAL = 200;
|
14544 | const isEqual = (value1, value2) => String(value1) === String(value2);
|
14545 | const stepperProps = {
|
14546 | min: makeNumericProp(1),
|
14547 | max: makeNumericProp(Infinity),
|
14548 | name: makeNumericProp(""),
|
14549 | step: makeNumericProp(1),
|
14550 | theme: String,
|
14551 | integer: Boolean,
|
14552 | disabled: Boolean,
|
14553 | showPlus: truthProp,
|
14554 | showMinus: truthProp,
|
14555 | showInput: truthProp,
|
14556 | longPress: truthProp,
|
14557 | autoFixed: truthProp,
|
14558 | allowEmpty: Boolean,
|
14559 | modelValue: numericProp,
|
14560 | inputWidth: numericProp,
|
14561 | buttonSize: numericProp,
|
14562 | placeholder: String,
|
14563 | disablePlus: Boolean,
|
14564 | disableMinus: Boolean,
|
14565 | disableInput: Boolean,
|
14566 | beforeChange: Function,
|
14567 | defaultValue: makeNumericProp(1),
|
14568 | decimalLength: numericProp
|
14569 | };
|
14570 | var stdin_default$e = vue.defineComponent({
|
14571 | name: name$9,
|
14572 | props: stepperProps,
|
14573 | emits: ["plus", "blur", "minus", "focus", "change", "overlimit", "update:modelValue"],
|
14574 | setup(props2, {
|
14575 | emit
|
14576 | }) {
|
14577 | const format2 = (value, autoFixed = true) => {
|
14578 | const {
|
14579 | min,
|
14580 | max,
|
14581 | allowEmpty,
|
14582 | decimalLength
|
14583 | } = props2;
|
14584 | if (allowEmpty && value === "") {
|
14585 | return value;
|
14586 | }
|
14587 | value = formatNumber(String(value), !props2.integer);
|
14588 | value = value === "" ? 0 : +value;
|
14589 | value = Number.isNaN(value) ? +min : value;
|
14590 | value = autoFixed ? Math.max(Math.min(+max, value), +min) : value;
|
14591 | if (isDef(decimalLength)) {
|
14592 | value = value.toFixed(+decimalLength);
|
14593 | }
|
14594 | return value;
|
14595 | };
|
14596 | const getInitialValue = () => {
|
14597 | var _a;
|
14598 | const defaultValue = (_a = props2.modelValue) != null ? _a : props2.defaultValue;
|
14599 | const value = format2(defaultValue);
|
14600 | if (!isEqual(value, props2.modelValue)) {
|
14601 | emit("update:modelValue", value);
|
14602 | }
|
14603 | return value;
|
14604 | };
|
14605 | let actionType;
|
14606 | const inputRef = vue.ref();
|
14607 | const current2 = vue.ref(getInitialValue());
|
14608 | const minusDisabled = vue.computed(() => props2.disabled || props2.disableMinus || +current2.value <= +props2.min);
|
14609 | const plusDisabled = vue.computed(() => props2.disabled || props2.disablePlus || +current2.value >= +props2.max);
|
14610 | const inputStyle = vue.computed(() => ({
|
14611 | width: addUnit(props2.inputWidth),
|
14612 | height: addUnit(props2.buttonSize)
|
14613 | }));
|
14614 | const buttonStyle = vue.computed(() => getSizeStyle(props2.buttonSize));
|
14615 | const check = () => {
|
14616 | const value = format2(current2.value);
|
14617 | if (!isEqual(value, current2.value)) {
|
14618 | current2.value = value;
|
14619 | }
|
14620 | };
|
14621 | const setValue = (value) => {
|
14622 | if (props2.beforeChange) {
|
14623 | callInterceptor(props2.beforeChange, {
|
14624 | args: [value],
|
14625 | done() {
|
14626 | current2.value = value;
|
14627 | }
|
14628 | });
|
14629 | } else {
|
14630 | current2.value = value;
|
14631 | }
|
14632 | };
|
14633 | const onChange = () => {
|
14634 | if (actionType === "plus" && plusDisabled.value || actionType === "minus" && minusDisabled.value) {
|
14635 | emit("overlimit", actionType);
|
14636 | return;
|
14637 | }
|
14638 | const diff = actionType === "minus" ? -props2.step : +props2.step;
|
14639 | const value = format2(addNumber(+current2.value, diff));
|
14640 | setValue(value);
|
14641 | emit(actionType);
|
14642 | };
|
14643 | const onInput = (event) => {
|
14644 | const input = event.target;
|
14645 | const {
|
14646 | value
|
14647 | } = input;
|
14648 | const {
|
14649 | decimalLength
|
14650 | } = props2;
|
14651 | let formatted = formatNumber(String(value), !props2.integer);
|
14652 | if (isDef(decimalLength) && formatted.includes(".")) {
|
14653 | const pair = formatted.split(".");
|
14654 | formatted = `${pair[0]}.${pair[1].slice(0, +decimalLength)}`;
|
14655 | }
|
14656 | if (props2.beforeChange) {
|
14657 | input.value = String(current2.value);
|
14658 | } else if (!isEqual(value, formatted)) {
|
14659 | input.value = formatted;
|
14660 | }
|
14661 | const isNumeric2 = formatted === String(+formatted);
|
14662 | setValue(isNumeric2 ? +formatted : formatted);
|
14663 | };
|
14664 | const onFocus = (event) => {
|
14665 | var _a;
|
14666 | if (props2.disableInput) {
|
14667 | (_a = inputRef.value) == null ? void 0 : _a.blur();
|
14668 | } else {
|
14669 | emit("focus", event);
|
14670 | }
|
14671 | };
|
14672 | const onBlur = (event) => {
|
14673 | const input = event.target;
|
14674 | const value = format2(input.value, props2.autoFixed);
|
14675 | input.value = String(value);
|
14676 | current2.value = value;
|
14677 | vue.nextTick(() => {
|
14678 | emit("blur", event);
|
14679 | resetScroll();
|
14680 | });
|
14681 | };
|
14682 | let isLongPress;
|
14683 | let longPressTimer;
|
14684 | const longPressStep = () => {
|
14685 | longPressTimer = setTimeout(() => {
|
14686 | onChange();
|
14687 | longPressStep();
|
14688 | }, LONG_PRESS_INTERVAL);
|
14689 | };
|
14690 | const onTouchStart = () => {
|
14691 | if (props2.longPress) {
|
14692 | isLongPress = false;
|
14693 | clearTimeout(longPressTimer);
|
14694 | longPressTimer = setTimeout(() => {
|
14695 | isLongPress = true;
|
14696 | onChange();
|
14697 | longPressStep();
|
14698 | }, LONG_PRESS_START_TIME);
|
14699 | }
|
14700 | };
|
14701 | const onTouchEnd = (event) => {
|
14702 | if (props2.longPress) {
|
14703 | clearTimeout(longPressTimer);
|
14704 | if (isLongPress) {
|
14705 | preventDefault(event);
|
14706 | }
|
14707 | }
|
14708 | };
|
14709 | const onMousedown = (event) => {
|
14710 | if (props2.disableInput) {
|
14711 | preventDefault(event);
|
14712 | }
|
14713 | };
|
14714 | const createListeners = (type) => ({
|
14715 | onClick: (event) => {
|
14716 | preventDefault(event);
|
14717 | actionType = type;
|
14718 | onChange();
|
14719 | },
|
14720 | onTouchstartPassive: () => {
|
14721 | actionType = type;
|
14722 | onTouchStart();
|
14723 | },
|
14724 | onTouchend: onTouchEnd,
|
14725 | onTouchcancel: onTouchEnd
|
14726 | });
|
14727 | vue.watch(() => [props2.max, props2.min, props2.integer, props2.decimalLength], check);
|
14728 | vue.watch(() => props2.modelValue, (value) => {
|
14729 | if (!isEqual(value, current2.value)) {
|
14730 | current2.value = format2(value);
|
14731 | }
|
14732 | });
|
14733 | vue.watch(current2, (value) => {
|
14734 | emit("update:modelValue", value);
|
14735 | emit("change", value, {
|
14736 | name: props2.name
|
14737 | });
|
14738 | });
|
14739 | use.useCustomFieldValue(() => props2.modelValue);
|
14740 | return () => vue.createVNode("div", {
|
14741 | "role": "group",
|
14742 | "class": bem$8([props2.theme])
|
14743 | }, [vue.withDirectives(vue.createVNode("button", vue.mergeProps({
|
14744 | "type": "button",
|
14745 | "style": buttonStyle.value,
|
14746 | "class": [bem$8("minus", {
|
14747 | disabled: minusDisabled.value
|
14748 | }), {
|
14749 | [HAPTICS_FEEDBACK]: !minusDisabled.value
|
14750 | }],
|
14751 | "aria-disabled": minusDisabled.value || void 0
|
14752 | }, createListeners("minus")), null), [[vue.vShow, props2.showMinus]]), vue.withDirectives(vue.createVNode("input", {
|
14753 | "ref": inputRef,
|
14754 | "type": props2.integer ? "tel" : "text",
|
14755 | "role": "spinbutton",
|
14756 | "class": bem$8("input"),
|
14757 | "value": current2.value,
|
14758 | "style": inputStyle.value,
|
14759 | "disabled": props2.disabled,
|
14760 | "readonly": props2.disableInput,
|
14761 | "inputmode": props2.integer ? "numeric" : "decimal",
|
14762 | "placeholder": props2.placeholder,
|
14763 | "autocomplete": "off",
|
14764 | "aria-valuemax": props2.max,
|
14765 | "aria-valuemin": props2.min,
|
14766 | "aria-valuenow": current2.value,
|
14767 | "onBlur": onBlur,
|
14768 | "onInput": onInput,
|
14769 | "onFocus": onFocus,
|
14770 | "onMousedown": onMousedown
|
14771 | }, null), [[vue.vShow, props2.showInput]]), vue.withDirectives(vue.createVNode("button", vue.mergeProps({
|
14772 | "type": "button",
|
14773 | "style": buttonStyle.value,
|
14774 | "class": [bem$8("plus", {
|
14775 | disabled: plusDisabled.value
|
14776 | }), {
|
14777 | [HAPTICS_FEEDBACK]: !plusDisabled.value
|
14778 | }],
|
14779 | "aria-disabled": plusDisabled.value || void 0
|
14780 | }, createListeners("plus")), null), [[vue.vShow, props2.showPlus]])]);
|
14781 | }
|
14782 | });
|
14783 | const Stepper = withInstall(stdin_default$e);
|
14784 | const Steps = withInstall(stdin_default$g);
|
14785 | const [name$8, bem$7, t$1] = createNamespace("submit-bar");
|
14786 | const submitBarProps = {
|
14787 | tip: String,
|
14788 | label: String,
|
14789 | price: Number,
|
14790 | tipIcon: String,
|
14791 | loading: Boolean,
|
14792 | currency: makeStringProp("¥"),
|
14793 | disabled: Boolean,
|
14794 | textAlign: String,
|
14795 | buttonText: String,
|
14796 | buttonType: makeStringProp("danger"),
|
14797 | buttonColor: String,
|
14798 | suffixLabel: String,
|
14799 | placeholder: Boolean,
|
14800 | decimalLength: makeNumericProp(2),
|
14801 | safeAreaInsetBottom: truthProp
|
14802 | };
|
14803 | var stdin_default$d = vue.defineComponent({
|
14804 | name: name$8,
|
14805 | props: submitBarProps,
|
14806 | emits: ["submit"],
|
14807 | setup(props2, {
|
14808 | emit,
|
14809 | slots
|
14810 | }) {
|
14811 | const root = vue.ref();
|
14812 | const renderPlaceholder = usePlaceholder(root, bem$7);
|
14813 | const renderText = () => {
|
14814 | const {
|
14815 | price,
|
14816 | label,
|
14817 | currency,
|
14818 | textAlign,
|
14819 | suffixLabel,
|
14820 | decimalLength
|
14821 | } = props2;
|
14822 | if (typeof price === "number") {
|
14823 | const pricePair = (price / 100).toFixed(+decimalLength).split(".");
|
14824 | const decimal = decimalLength ? `.${pricePair[1]}` : "";
|
14825 | return vue.createVNode("div", {
|
14826 | "class": bem$7("text"),
|
14827 | "style": {
|
14828 | textAlign
|
14829 | }
|
14830 | }, [vue.createVNode("span", null, [label || t$1("label")]), vue.createVNode("span", {
|
14831 | "class": bem$7("price")
|
14832 | }, [currency, vue.createVNode("span", {
|
14833 | "class": bem$7("price-integer")
|
14834 | }, [pricePair[0]]), decimal]), suffixLabel && vue.createVNode("span", {
|
14835 | "class": bem$7("suffix-label")
|
14836 | }, [suffixLabel])]);
|
14837 | }
|
14838 | };
|
14839 | const renderTip = () => {
|
14840 | var _a;
|
14841 | const {
|
14842 | tip,
|
14843 | tipIcon
|
14844 | } = props2;
|
14845 | if (slots.tip || tip) {
|
14846 | return vue.createVNode("div", {
|
14847 | "class": bem$7("tip")
|
14848 | }, [tipIcon && vue.createVNode(Icon, {
|
14849 | "class": bem$7("tip-icon"),
|
14850 | "name": tipIcon
|
14851 | }, null), tip && vue.createVNode("span", {
|
14852 | "class": bem$7("tip-text")
|
14853 | }, [tip]), (_a = slots.tip) == null ? void 0 : _a.call(slots)]);
|
14854 | }
|
14855 | };
|
14856 | const onClickButton = () => emit("submit");
|
14857 | const renderButton = () => {
|
14858 | if (slots.button) {
|
14859 | return slots.button();
|
14860 | }
|
14861 | return vue.createVNode(Button, {
|
14862 | "round": true,
|
14863 | "type": props2.buttonType,
|
14864 | "text": props2.buttonText,
|
14865 | "class": bem$7("button", props2.buttonType),
|
14866 | "color": props2.buttonColor,
|
14867 | "loading": props2.loading,
|
14868 | "disabled": props2.disabled,
|
14869 | "onClick": onClickButton
|
14870 | }, null);
|
14871 | };
|
14872 | const renderSubmitBar = () => {
|
14873 | var _a, _b;
|
14874 | return vue.createVNode("div", {
|
14875 | "ref": root,
|
14876 | "class": [bem$7(), {
|
14877 | "van-safe-area-bottom": props2.safeAreaInsetBottom
|
14878 | }]
|
14879 | }, [(_a = slots.top) == null ? void 0 : _a.call(slots), renderTip(), vue.createVNode("div", {
|
14880 | "class": bem$7("bar")
|
14881 | }, [(_b = slots.default) == null ? void 0 : _b.call(slots), renderText(), renderButton()])]);
|
14882 | };
|
14883 | return () => {
|
14884 | if (props2.placeholder) {
|
14885 | return renderPlaceholder(renderSubmitBar);
|
14886 | }
|
14887 | return renderSubmitBar();
|
14888 | };
|
14889 | }
|
14890 | });
|
14891 | const SubmitBar = withInstall(stdin_default$d);
|
14892 | const [name$7, bem$6] = createNamespace("swipe-cell");
|
14893 | const swipeCellProps = {
|
14894 | name: makeNumericProp(""),
|
14895 | disabled: Boolean,
|
14896 | leftWidth: numericProp,
|
14897 | rightWidth: numericProp,
|
14898 | beforeClose: Function,
|
14899 | stopPropagation: Boolean
|
14900 | };
|
14901 | var stdin_default$c = vue.defineComponent({
|
14902 | name: name$7,
|
14903 | props: swipeCellProps,
|
14904 | emits: ["open", "close", "click"],
|
14905 | setup(props2, {
|
14906 | emit,
|
14907 | slots
|
14908 | }) {
|
14909 | let opened;
|
14910 | let lockClick2;
|
14911 | let startOffset;
|
14912 | let isInBeforeClosing;
|
14913 | const root = vue.ref();
|
14914 | const leftRef = vue.ref();
|
14915 | const rightRef = vue.ref();
|
14916 | const state = vue.reactive({
|
14917 | offset: 0,
|
14918 | dragging: false
|
14919 | });
|
14920 | const touch = useTouch();
|
14921 | const getWidthByRef = (ref2) => ref2.value ? use.useRect(ref2).width : 0;
|
14922 | const leftWidth = vue.computed(() => isDef(props2.leftWidth) ? +props2.leftWidth : getWidthByRef(leftRef));
|
14923 | const rightWidth = vue.computed(() => isDef(props2.rightWidth) ? +props2.rightWidth : getWidthByRef(rightRef));
|
14924 | const open = (side) => {
|
14925 | state.offset = side === "left" ? leftWidth.value : -rightWidth.value;
|
14926 | if (!opened) {
|
14927 | opened = true;
|
14928 | emit("open", {
|
14929 | name: props2.name,
|
14930 | position: side
|
14931 | });
|
14932 | }
|
14933 | };
|
14934 | const close = (position) => {
|
14935 | state.offset = 0;
|
14936 | if (opened) {
|
14937 | opened = false;
|
14938 | emit("close", {
|
14939 | name: props2.name,
|
14940 | position
|
14941 | });
|
14942 | }
|
14943 | };
|
14944 | const toggle = (side) => {
|
14945 | const offset = Math.abs(state.offset);
|
14946 | const THRESHOLD = 0.15;
|
14947 | const threshold = opened ? 1 - THRESHOLD : THRESHOLD;
|
14948 | const width = side === "left" ? leftWidth.value : rightWidth.value;
|
14949 | if (width && offset > width * threshold) {
|
14950 | open(side);
|
14951 | } else {
|
14952 | close(side);
|
14953 | }
|
14954 | };
|
14955 | const onTouchStart = (event) => {
|
14956 | if (!props2.disabled) {
|
14957 | startOffset = state.offset;
|
14958 | touch.start(event);
|
14959 | }
|
14960 | };
|
14961 | const onTouchMove = (event) => {
|
14962 | if (props2.disabled) {
|
14963 | return;
|
14964 | }
|
14965 | const {
|
14966 | deltaX
|
14967 | } = touch;
|
14968 | touch.move(event);
|
14969 | if (touch.isHorizontal()) {
|
14970 | lockClick2 = true;
|
14971 | state.dragging = true;
|
14972 | const isEdge = !opened || deltaX.value * startOffset < 0;
|
14973 | if (isEdge) {
|
14974 | preventDefault(event, props2.stopPropagation);
|
14975 | }
|
14976 | state.offset = clamp(deltaX.value + startOffset, -rightWidth.value, leftWidth.value);
|
14977 | }
|
14978 | };
|
14979 | const onTouchEnd = () => {
|
14980 | if (state.dragging) {
|
14981 | state.dragging = false;
|
14982 | toggle(state.offset > 0 ? "left" : "right");
|
14983 | setTimeout(() => {
|
14984 | lockClick2 = false;
|
14985 | }, 0);
|
14986 | }
|
14987 | };
|
14988 | const onClick = (position = "outside", event) => {
|
14989 | if (isInBeforeClosing) return;
|
14990 | emit("click", position);
|
14991 | if (opened && !lockClick2) {
|
14992 | isInBeforeClosing = true;
|
14993 | callInterceptor(props2.beforeClose, {
|
14994 | args: [{
|
14995 | event,
|
14996 | name: props2.name,
|
14997 | position
|
14998 | }],
|
14999 | done: () => {
|
15000 | isInBeforeClosing = false;
|
15001 | close(position);
|
15002 | },
|
15003 | canceled: () => isInBeforeClosing = false,
|
15004 | error: () => isInBeforeClosing = false
|
15005 | });
|
15006 | }
|
15007 | };
|
15008 | const getClickHandler = (position, stop) => (event) => {
|
15009 | if (stop) {
|
15010 | event.stopPropagation();
|
15011 | }
|
15012 | if (lockClick2) {
|
15013 | return;
|
15014 | }
|
15015 | onClick(position, event);
|
15016 | };
|
15017 | const renderSideContent = (side, ref2) => {
|
15018 | const contentSlot = slots[side];
|
15019 | if (contentSlot) {
|
15020 | return vue.createVNode("div", {
|
15021 | "ref": ref2,
|
15022 | "class": bem$6(side),
|
15023 | "onClick": getClickHandler(side, true)
|
15024 | }, [contentSlot()]);
|
15025 | }
|
15026 | };
|
15027 | useExpose({
|
15028 | open,
|
15029 | close
|
15030 | });
|
15031 | use.useClickAway(root, (event) => onClick("outside", event), {
|
15032 | eventName: "touchstart"
|
15033 | });
|
15034 | use.useEventListener("touchmove", onTouchMove, {
|
15035 | target: root
|
15036 | });
|
15037 | return () => {
|
15038 | var _a;
|
15039 | const wrapperStyle = {
|
15040 | transform: `translate3d(${state.offset}px, 0, 0)`,
|
15041 | transitionDuration: state.dragging ? "0s" : ".6s"
|
15042 | };
|
15043 | return vue.createVNode("div", {
|
15044 | "ref": root,
|
15045 | "class": bem$6(),
|
15046 | "onClick": getClickHandler("cell", lockClick2),
|
15047 | "onTouchstartPassive": onTouchStart,
|
15048 | "onTouchend": onTouchEnd,
|
15049 | "onTouchcancel": onTouchEnd
|
15050 | }, [vue.createVNode("div", {
|
15051 | "class": bem$6("wrapper"),
|
15052 | "style": wrapperStyle
|
15053 | }, [renderSideContent("left", leftRef), (_a = slots.default) == null ? void 0 : _a.call(slots), renderSideContent("right", rightRef)])]);
|
15054 | };
|
15055 | }
|
15056 | });
|
15057 | const SwipeCell = withInstall(stdin_default$c);
|
15058 | const [name$6, bem$5] = createNamespace("tabbar");
|
15059 | const tabbarProps = {
|
15060 | route: Boolean,
|
15061 | fixed: truthProp,
|
15062 | border: truthProp,
|
15063 | zIndex: numericProp,
|
15064 | placeholder: Boolean,
|
15065 | activeColor: String,
|
15066 | beforeChange: Function,
|
15067 | inactiveColor: String,
|
15068 | modelValue: makeNumericProp(0),
|
15069 | safeAreaInsetBottom: {
|
15070 | type: Boolean,
|
15071 | default: null
|
15072 | }
|
15073 | };
|
15074 | const TABBAR_KEY = Symbol(name$6);
|
15075 | var stdin_default$b = vue.defineComponent({
|
15076 | name: name$6,
|
15077 | props: tabbarProps,
|
15078 | emits: ["change", "update:modelValue"],
|
15079 | setup(props2, {
|
15080 | emit,
|
15081 | slots
|
15082 | }) {
|
15083 | const root = vue.ref();
|
15084 | const {
|
15085 | linkChildren
|
15086 | } = use.useChildren(TABBAR_KEY);
|
15087 | const renderPlaceholder = usePlaceholder(root, bem$5);
|
15088 | const enableSafeArea = () => {
|
15089 | var _a;
|
15090 | return (_a = props2.safeAreaInsetBottom) != null ? _a : props2.fixed;
|
15091 | };
|
15092 | const renderTabbar = () => {
|
15093 | var _a;
|
15094 | const {
|
15095 | fixed,
|
15096 | zIndex,
|
15097 | border
|
15098 | } = props2;
|
15099 | return vue.createVNode("div", {
|
15100 | "ref": root,
|
15101 | "role": "tablist",
|
15102 | "style": getZIndexStyle(zIndex),
|
15103 | "class": [bem$5({
|
15104 | fixed
|
15105 | }), {
|
15106 | [BORDER_TOP_BOTTOM]: border,
|
15107 | "van-safe-area-bottom": enableSafeArea()
|
15108 | }]
|
15109 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
15110 | };
|
15111 | const setActive = (active, afterChange) => {
|
15112 | callInterceptor(props2.beforeChange, {
|
15113 | args: [active],
|
15114 | done() {
|
15115 | emit("update:modelValue", active);
|
15116 | emit("change", active);
|
15117 | afterChange();
|
15118 | }
|
15119 | });
|
15120 | };
|
15121 | linkChildren({
|
15122 | props: props2,
|
15123 | setActive
|
15124 | });
|
15125 | return () => {
|
15126 | if (props2.fixed && props2.placeholder) {
|
15127 | return renderPlaceholder(renderTabbar);
|
15128 | }
|
15129 | return renderTabbar();
|
15130 | };
|
15131 | }
|
15132 | });
|
15133 | const Tabbar = withInstall(stdin_default$b);
|
15134 | const [name$5, bem$4] = createNamespace("tabbar-item");
|
15135 | const tabbarItemProps = extend({}, routeProps, {
|
15136 | dot: Boolean,
|
15137 | icon: String,
|
15138 | name: numericProp,
|
15139 | badge: numericProp,
|
15140 | badgeProps: Object,
|
15141 | iconPrefix: String
|
15142 | });
|
15143 | var stdin_default$a = vue.defineComponent({
|
15144 | name: name$5,
|
15145 | props: tabbarItemProps,
|
15146 | emits: ["click"],
|
15147 | setup(props2, {
|
15148 | emit,
|
15149 | slots
|
15150 | }) {
|
15151 | const route2 = useRoute();
|
15152 | const vm = vue.getCurrentInstance().proxy;
|
15153 | const {
|
15154 | parent,
|
15155 | index
|
15156 | } = use.useParent(TABBAR_KEY);
|
15157 | if (!parent) {
|
15158 | if (process.env.NODE_ENV !== "production") {
|
15159 | console.error("[Vant] <TabbarItem> must be a child component of <Tabbar>.");
|
15160 | }
|
15161 | return;
|
15162 | }
|
15163 | const active = vue.computed(() => {
|
15164 | var _a;
|
15165 | const {
|
15166 | route: route22,
|
15167 | modelValue
|
15168 | } = parent.props;
|
15169 | if (route22 && "$route" in vm) {
|
15170 | const {
|
15171 | $route
|
15172 | } = vm;
|
15173 | const {
|
15174 | to
|
15175 | } = props2;
|
15176 | const config = isObject(to) ? to : {
|
15177 | path: to
|
15178 | };
|
15179 | return !!$route.matched.find((val) => {
|
15180 | const pathMatched = "path" in config && config.path === val.path;
|
15181 | const nameMatched = "name" in config && config.name === val.name;
|
15182 | return pathMatched || nameMatched;
|
15183 | });
|
15184 | }
|
15185 | return ((_a = props2.name) != null ? _a : index.value) === modelValue;
|
15186 | });
|
15187 | const onClick = (event) => {
|
15188 | var _a;
|
15189 | if (!active.value) {
|
15190 | parent.setActive((_a = props2.name) != null ? _a : index.value, route2);
|
15191 | }
|
15192 | emit("click", event);
|
15193 | };
|
15194 | const renderIcon = () => {
|
15195 | if (slots.icon) {
|
15196 | return slots.icon({
|
15197 | active: active.value
|
15198 | });
|
15199 | }
|
15200 | if (props2.icon) {
|
15201 | return vue.createVNode(Icon, {
|
15202 | "name": props2.icon,
|
15203 | "classPrefix": props2.iconPrefix
|
15204 | }, null);
|
15205 | }
|
15206 | };
|
15207 | return () => {
|
15208 | var _a;
|
15209 | const {
|
15210 | dot,
|
15211 | badge
|
15212 | } = props2;
|
15213 | const {
|
15214 | activeColor,
|
15215 | inactiveColor
|
15216 | } = parent.props;
|
15217 | const color = active.value ? activeColor : inactiveColor;
|
15218 | return vue.createVNode("div", {
|
15219 | "role": "tab",
|
15220 | "class": bem$4({
|
15221 | active: active.value
|
15222 | }),
|
15223 | "style": {
|
15224 | color
|
15225 | },
|
15226 | "tabindex": 0,
|
15227 | "aria-selected": active.value,
|
15228 | "onClick": onClick
|
15229 | }, [vue.createVNode(Badge, vue.mergeProps({
|
15230 | "dot": dot,
|
15231 | "class": bem$4("icon"),
|
15232 | "content": badge
|
15233 | }, props2.badgeProps), {
|
15234 | default: renderIcon
|
15235 | }), vue.createVNode("div", {
|
15236 | "class": bem$4("text")
|
15237 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots, {
|
15238 | active: active.value
|
15239 | })])]);
|
15240 | };
|
15241 | }
|
15242 | });
|
15243 | const TabbarItem = withInstall(stdin_default$a);
|
15244 | const [name$4, bem$3] = createNamespace("text-ellipsis");
|
15245 | const textEllipsisProps = {
|
15246 | rows: makeNumericProp(1),
|
15247 | dots: makeStringProp("..."),
|
15248 | content: makeStringProp(""),
|
15249 | expandText: makeStringProp(""),
|
15250 | collapseText: makeStringProp(""),
|
15251 | position: makeStringProp("end")
|
15252 | };
|
15253 | var stdin_default$9 = vue.defineComponent({
|
15254 | name: name$4,
|
15255 | props: textEllipsisProps,
|
15256 | emits: ["clickAction"],
|
15257 | setup(props2, {
|
15258 | emit,
|
15259 | slots
|
15260 | }) {
|
15261 | const text = vue.ref(props2.content);
|
15262 | const expanded = vue.ref(false);
|
15263 | const hasAction = vue.ref(false);
|
15264 | const root = vue.ref();
|
15265 | const actionRef = vue.ref();
|
15266 | let needRecalculate = false;
|
15267 | const actionText = vue.computed(() => expanded.value ? props2.collapseText : props2.expandText);
|
15268 | const pxToNum = (value) => {
|
15269 | if (!value) return 0;
|
15270 | const match = value.match(/^\d*(\.\d*)?/);
|
15271 | return match ? Number(match[0]) : 0;
|
15272 | };
|
15273 | const cloneContainer = () => {
|
15274 | if (!root.value || !root.value.isConnected) return;
|
15275 | const originStyle = window.getComputedStyle(root.value);
|
15276 | const container = document.createElement("div");
|
15277 | const styleNames = Array.prototype.slice.apply(originStyle);
|
15278 | styleNames.forEach((name2) => {
|
15279 | container.style.setProperty(name2, originStyle.getPropertyValue(name2));
|
15280 | });
|
15281 | container.style.position = "fixed";
|
15282 | container.style.zIndex = "-9999";
|
15283 | container.style.top = "-9999px";
|
15284 | container.style.height = "auto";
|
15285 | container.style.minHeight = "auto";
|
15286 | container.style.maxHeight = "auto";
|
15287 | container.innerText = props2.content;
|
15288 | document.body.appendChild(container);
|
15289 | return container;
|
15290 | };
|
15291 | const calcEllipsisText = (container, maxHeight) => {
|
15292 | var _a, _b;
|
15293 | const {
|
15294 | content,
|
15295 | position,
|
15296 | dots
|
15297 | } = props2;
|
15298 | const end = content.length;
|
15299 | const middle = 0 + end >> 1;
|
15300 | const actionHTML = slots.action ? (_b = (_a = actionRef.value) == null ? void 0 : _a.outerHTML) != null ? _b : "" : props2.expandText;
|
15301 | const calcEllipse = () => {
|
15302 | const tail = (left, right) => {
|
15303 | if (right - left <= 1) {
|
15304 | if (position === "end") {
|
15305 | return content.slice(0, left) + dots;
|
15306 | }
|
15307 | return dots + content.slice(right, end);
|
15308 | }
|
15309 | const middle2 = Math.round((left + right) / 2);
|
15310 | if (position === "end") {
|
15311 | container.innerText = content.slice(0, middle2) + dots;
|
15312 | } else {
|
15313 | container.innerText = dots + content.slice(middle2, end);
|
15314 | }
|
15315 | container.innerHTML += actionHTML;
|
15316 | if (container.offsetHeight > maxHeight) {
|
15317 | if (position === "end") {
|
15318 | return tail(left, middle2);
|
15319 | }
|
15320 | return tail(middle2, right);
|
15321 | }
|
15322 | if (position === "end") {
|
15323 | return tail(middle2, right);
|
15324 | }
|
15325 | return tail(left, middle2);
|
15326 | };
|
15327 | return tail(0, end);
|
15328 | };
|
15329 | const middleTail = (leftPart, rightPart) => {
|
15330 | if (leftPart[1] - leftPart[0] <= 1 && rightPart[1] - rightPart[0] <= 1) {
|
15331 | return content.slice(0, leftPart[0]) + dots + content.slice(rightPart[1], end);
|
15332 | }
|
15333 | const leftMiddle = Math.floor((leftPart[0] + leftPart[1]) / 2);
|
15334 | const rightMiddle = Math.ceil((rightPart[0] + rightPart[1]) / 2);
|
15335 | container.innerText = props2.content.slice(0, leftMiddle) + props2.dots + props2.content.slice(rightMiddle, end);
|
15336 | container.innerHTML += actionHTML;
|
15337 | if (container.offsetHeight >= maxHeight) {
|
15338 | return middleTail([leftPart[0], leftMiddle], [rightMiddle, rightPart[1]]);
|
15339 | }
|
15340 | return middleTail([leftMiddle, leftPart[1]], [rightPart[0], rightMiddle]);
|
15341 | };
|
15342 | return props2.position === "middle" ? middleTail([0, middle], [middle, end]) : calcEllipse();
|
15343 | };
|
15344 | const calcEllipsised = () => {
|
15345 | const container = cloneContainer();
|
15346 | if (!container) {
|
15347 | needRecalculate = true;
|
15348 | return;
|
15349 | }
|
15350 | const {
|
15351 | paddingBottom,
|
15352 | paddingTop,
|
15353 | lineHeight
|
15354 | } = container.style;
|
15355 | const maxHeight = Math.ceil((Number(props2.rows) + 0.5) * pxToNum(lineHeight) + pxToNum(paddingTop) + pxToNum(paddingBottom));
|
15356 | if (maxHeight < container.offsetHeight) {
|
15357 | hasAction.value = true;
|
15358 | text.value = calcEllipsisText(container, maxHeight);
|
15359 | } else {
|
15360 | hasAction.value = false;
|
15361 | text.value = props2.content;
|
15362 | }
|
15363 | document.body.removeChild(container);
|
15364 | };
|
15365 | const toggle = (isExpanded = !expanded.value) => {
|
15366 | expanded.value = isExpanded;
|
15367 | };
|
15368 | const onClickAction = (event) => {
|
15369 | toggle();
|
15370 | emit("clickAction", event);
|
15371 | };
|
15372 | const renderAction = () => {
|
15373 | const action = slots.action ? slots.action({
|
15374 | expanded: expanded.value
|
15375 | }) : actionText.value;
|
15376 | return vue.createVNode("span", {
|
15377 | "ref": actionRef,
|
15378 | "class": bem$3("action"),
|
15379 | "onClick": onClickAction
|
15380 | }, [action]);
|
15381 | };
|
15382 | vue.onMounted(() => {
|
15383 | calcEllipsised();
|
15384 | if (slots.action) {
|
15385 | vue.nextTick(calcEllipsised);
|
15386 | }
|
15387 | });
|
15388 | vue.onActivated(() => {
|
15389 | if (needRecalculate) {
|
15390 | needRecalculate = false;
|
15391 | calcEllipsised();
|
15392 | }
|
15393 | });
|
15394 | vue.watch([windowWidth, () => [props2.content, props2.rows, props2.position]], calcEllipsised);
|
15395 | useExpose({
|
15396 | toggle
|
15397 | });
|
15398 | return () => vue.createVNode("div", {
|
15399 | "ref": root,
|
15400 | "class": bem$3()
|
15401 | }, [expanded.value ? props2.content : text.value, hasAction.value ? renderAction() : null]);
|
15402 | }
|
15403 | });
|
15404 | const TextEllipsis = withInstall(stdin_default$9);
|
15405 | const [name$3] = createNamespace("time-picker");
|
15406 | const validateTime = (val) => /^([01]\d|2[0-3]):([0-5]\d):([0-5]\d)$/.test(val);
|
15407 | const fullColumns = ["hour", "minute", "second"];
|
15408 | const timePickerProps = extend({}, sharedProps, {
|
15409 | minHour: makeNumericProp(0),
|
15410 | maxHour: makeNumericProp(23),
|
15411 | minMinute: makeNumericProp(0),
|
15412 | maxMinute: makeNumericProp(59),
|
15413 | minSecond: makeNumericProp(0),
|
15414 | maxSecond: makeNumericProp(59),
|
15415 | minTime: {
|
15416 | type: String,
|
15417 | validator: validateTime
|
15418 | },
|
15419 | maxTime: {
|
15420 | type: String,
|
15421 | validator: validateTime
|
15422 | },
|
15423 | columnsType: {
|
15424 | type: Array,
|
15425 | default: () => ["hour", "minute"]
|
15426 | }
|
15427 | });
|
15428 | var stdin_default$8 = vue.defineComponent({
|
15429 | name: name$3,
|
15430 | props: timePickerProps,
|
15431 | emits: ["confirm", "cancel", "change", "update:modelValue"],
|
15432 | setup(props2, {
|
15433 | emit,
|
15434 | slots
|
15435 | }) {
|
15436 | const currentValues = vue.ref(props2.modelValue);
|
15437 | const pickerRef = vue.ref();
|
15438 | const getValidTime = (time) => {
|
15439 | const timeLimitArr = time.split(":");
|
15440 | return fullColumns.map((col, i) => props2.columnsType.includes(col) ? timeLimitArr[i] : "00");
|
15441 | };
|
15442 | const confirm = () => {
|
15443 | var _a;
|
15444 | return (_a = pickerRef.value) == null ? void 0 : _a.confirm();
|
15445 | };
|
15446 | const getSelectedTime = () => currentValues.value;
|
15447 | const columns = vue.computed(() => {
|
15448 | let {
|
15449 | minHour,
|
15450 | maxHour,
|
15451 | minMinute,
|
15452 | maxMinute,
|
15453 | minSecond,
|
15454 | maxSecond
|
15455 | } = props2;
|
15456 | if (props2.minTime || props2.maxTime) {
|
15457 | const fullTime = {
|
15458 | hour: 0,
|
15459 | minute: 0,
|
15460 | second: 0
|
15461 | };
|
15462 | props2.columnsType.forEach((col, i) => {
|
15463 | var _a;
|
15464 | fullTime[col] = (_a = currentValues.value[i]) != null ? _a : 0;
|
15465 | });
|
15466 | const {
|
15467 | hour,
|
15468 | minute
|
15469 | } = fullTime;
|
15470 | if (props2.minTime) {
|
15471 | const [minH, minM, minS] = getValidTime(props2.minTime);
|
15472 | minHour = minH;
|
15473 | minMinute = +hour <= +minHour ? minM : "00";
|
15474 | minSecond = +hour <= +minHour && +minute <= +minMinute ? minS : "00";
|
15475 | }
|
15476 | if (props2.maxTime) {
|
15477 | const [maxH, maxM, maxS] = getValidTime(props2.maxTime);
|
15478 | maxHour = maxH;
|
15479 | maxMinute = +hour >= +maxHour ? maxM : "59";
|
15480 | maxSecond = +hour >= +maxHour && +minute >= +maxMinute ? maxS : "59";
|
15481 | }
|
15482 | }
|
15483 | return props2.columnsType.map((type) => {
|
15484 | const {
|
15485 | filter,
|
15486 | formatter
|
15487 | } = props2;
|
15488 | switch (type) {
|
15489 | case "hour":
|
15490 | return genOptions(+minHour, +maxHour, type, formatter, filter, currentValues.value);
|
15491 | case "minute":
|
15492 | return genOptions(+minMinute, +maxMinute, type, formatter, filter, currentValues.value);
|
15493 | case "second":
|
15494 | return genOptions(+minSecond, +maxSecond, type, formatter, filter, currentValues.value);
|
15495 | default:
|
15496 | if (process.env.NODE_ENV !== "production") {
|
15497 | throw new Error(`[Vant] DatePicker: unsupported columns type: ${type}`);
|
15498 | }
|
15499 | return [];
|
15500 | }
|
15501 | });
|
15502 | });
|
15503 | vue.watch(currentValues, (newValues) => {
|
15504 | if (!isSameValue(newValues, props2.modelValue)) {
|
15505 | emit("update:modelValue", newValues);
|
15506 | }
|
15507 | });
|
15508 | vue.watch(() => props2.modelValue, (newValues) => {
|
15509 | newValues = formatValueRange(newValues, columns.value);
|
15510 | if (!isSameValue(newValues, currentValues.value)) {
|
15511 | currentValues.value = newValues;
|
15512 | }
|
15513 | }, {
|
15514 | immediate: true
|
15515 | });
|
15516 | const onChange = (...args) => emit("change", ...args);
|
15517 | const onCancel = (...args) => emit("cancel", ...args);
|
15518 | const onConfirm = (...args) => emit("confirm", ...args);
|
15519 | useExpose({
|
15520 | confirm,
|
15521 | getSelectedTime
|
15522 | });
|
15523 | return () => vue.createVNode(Picker, vue.mergeProps({
|
15524 | "ref": pickerRef,
|
15525 | "modelValue": currentValues.value,
|
15526 | "onUpdate:modelValue": ($event) => currentValues.value = $event,
|
15527 | "columns": columns.value,
|
15528 | "onChange": onChange,
|
15529 | "onCancel": onCancel,
|
15530 | "onConfirm": onConfirm
|
15531 | }, pick(props2, pickerInheritKeys)), slots);
|
15532 | }
|
15533 | });
|
15534 | const TimePicker = withInstall(stdin_default$8);
|
15535 | const [name$2, bem$2] = createNamespace("tree-select");
|
15536 | const treeSelectProps = {
|
15537 | max: makeNumericProp(Infinity),
|
15538 | items: makeArrayProp(),
|
15539 | height: makeNumericProp(300),
|
15540 | selectedIcon: makeStringProp("success"),
|
15541 | mainActiveIndex: makeNumericProp(0),
|
15542 | activeId: {
|
15543 | type: [Number, String, Array],
|
15544 | default: 0
|
15545 | }
|
15546 | };
|
15547 | var stdin_default$7 = vue.defineComponent({
|
15548 | name: name$2,
|
15549 | props: treeSelectProps,
|
15550 | emits: ["clickNav", "clickItem", "update:activeId", "update:mainActiveIndex"],
|
15551 | setup(props2, {
|
15552 | emit,
|
15553 | slots
|
15554 | }) {
|
15555 | const isActiveItem = (id) => Array.isArray(props2.activeId) ? props2.activeId.includes(id) : props2.activeId === id;
|
15556 | const renderSubItem = (item) => {
|
15557 | const onClick = () => {
|
15558 | if (item.disabled) {
|
15559 | return;
|
15560 | }
|
15561 | let activeId;
|
15562 | if (Array.isArray(props2.activeId)) {
|
15563 | activeId = props2.activeId.slice();
|
15564 | const index = activeId.indexOf(item.id);
|
15565 | if (index !== -1) {
|
15566 | activeId.splice(index, 1);
|
15567 | } else if (activeId.length < +props2.max) {
|
15568 | activeId.push(item.id);
|
15569 | }
|
15570 | } else {
|
15571 | activeId = item.id;
|
15572 | }
|
15573 | emit("update:activeId", activeId);
|
15574 | emit("clickItem", item);
|
15575 | };
|
15576 | return vue.createVNode("div", {
|
15577 | "key": item.id,
|
15578 | "class": ["van-ellipsis", bem$2("item", {
|
15579 | active: isActiveItem(item.id),
|
15580 | disabled: item.disabled
|
15581 | })],
|
15582 | "onClick": onClick
|
15583 | }, [item.text, isActiveItem(item.id) && vue.createVNode(Icon, {
|
15584 | "name": props2.selectedIcon,
|
15585 | "class": bem$2("selected")
|
15586 | }, null)]);
|
15587 | };
|
15588 | const onSidebarChange = (index) => {
|
15589 | emit("update:mainActiveIndex", index);
|
15590 | };
|
15591 | const onClickSidebarItem = (index) => emit("clickNav", index);
|
15592 | const renderSidebar = () => {
|
15593 | const Items = props2.items.map((item) => vue.createVNode(SidebarItem, {
|
15594 | "dot": item.dot,
|
15595 | "badge": item.badge,
|
15596 | "class": [bem$2("nav-item"), item.className],
|
15597 | "disabled": item.disabled,
|
15598 | "onClick": onClickSidebarItem
|
15599 | }, {
|
15600 | title: () => slots["nav-text"] ? slots["nav-text"](item) : item.text
|
15601 | }));
|
15602 | return vue.createVNode(Sidebar, {
|
15603 | "class": bem$2("nav"),
|
15604 | "modelValue": props2.mainActiveIndex,
|
15605 | "onChange": onSidebarChange
|
15606 | }, {
|
15607 | default: () => [Items]
|
15608 | });
|
15609 | };
|
15610 | const renderContent = () => {
|
15611 | if (slots.content) {
|
15612 | return slots.content();
|
15613 | }
|
15614 | const selected = props2.items[+props2.mainActiveIndex] || {};
|
15615 | if (selected.children) {
|
15616 | return selected.children.map(renderSubItem);
|
15617 | }
|
15618 | };
|
15619 | return () => vue.createVNode("div", {
|
15620 | "class": bem$2(),
|
15621 | "style": {
|
15622 | height: addUnit(props2.height)
|
15623 | }
|
15624 | }, [renderSidebar(), vue.createVNode("div", {
|
15625 | "class": bem$2("content")
|
15626 | }, [renderContent()])]);
|
15627 | }
|
15628 | });
|
15629 | const TreeSelect = withInstall(stdin_default$7);
|
15630 | const [name$1, bem$1, t] = createNamespace("uploader");
|
15631 | function readFileContent(file, resultType) {
|
15632 | return new Promise((resolve) => {
|
15633 | if (resultType === "file") {
|
15634 | resolve();
|
15635 | return;
|
15636 | }
|
15637 | const reader = new FileReader();
|
15638 | reader.onload = (event) => {
|
15639 | resolve(event.target.result);
|
15640 | };
|
15641 | if (resultType === "dataUrl") {
|
15642 | reader.readAsDataURL(file);
|
15643 | } else if (resultType === "text") {
|
15644 | reader.readAsText(file);
|
15645 | }
|
15646 | });
|
15647 | }
|
15648 | function isOversize(items, maxSize) {
|
15649 | return toArray(items).some((item) => {
|
15650 | if (item.file) {
|
15651 | if (isFunction(maxSize)) {
|
15652 | return maxSize(item.file);
|
15653 | }
|
15654 | return item.file.size > +maxSize;
|
15655 | }
|
15656 | return false;
|
15657 | });
|
15658 | }
|
15659 | function filterFiles(items, maxSize) {
|
15660 | const valid = [];
|
15661 | const invalid = [];
|
15662 | items.forEach((item) => {
|
15663 | if (isOversize(item, maxSize)) {
|
15664 | invalid.push(item);
|
15665 | } else {
|
15666 | valid.push(item);
|
15667 | }
|
15668 | });
|
15669 | return { valid, invalid };
|
15670 | }
|
15671 | const IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg|avif)/i;
|
15672 | const isImageUrl = (url) => IMAGE_REGEXP.test(url);
|
15673 | function isImageFile(item) {
|
15674 | if (item.isImage) {
|
15675 | return true;
|
15676 | }
|
15677 | if (item.file && item.file.type) {
|
15678 | return item.file.type.indexOf("image") === 0;
|
15679 | }
|
15680 | if (item.url) {
|
15681 | return isImageUrl(item.url);
|
15682 | }
|
15683 | if (typeof item.content === "string") {
|
15684 | return item.content.indexOf("data:image") === 0;
|
15685 | }
|
15686 | return false;
|
15687 | }
|
15688 | var stdin_default$6 = vue.defineComponent({
|
15689 | props: {
|
15690 | name: numericProp,
|
15691 | item: makeRequiredProp(Object),
|
15692 | index: Number,
|
15693 | imageFit: String,
|
15694 | lazyLoad: Boolean,
|
15695 | deletable: Boolean,
|
15696 | reupload: Boolean,
|
15697 | previewSize: [Number, String, Array],
|
15698 | beforeDelete: Function
|
15699 | },
|
15700 | emits: ["delete", "preview", "reupload"],
|
15701 | setup(props2, {
|
15702 | emit,
|
15703 | slots
|
15704 | }) {
|
15705 | const renderMask = () => {
|
15706 | const {
|
15707 | status,
|
15708 | message
|
15709 | } = props2.item;
|
15710 | if (status === "uploading" || status === "failed") {
|
15711 | const MaskIcon = status === "failed" ? vue.createVNode(Icon, {
|
15712 | "name": "close",
|
15713 | "class": bem$1("mask-icon")
|
15714 | }, null) : vue.createVNode(Loading, {
|
15715 | "class": bem$1("loading")
|
15716 | }, null);
|
15717 | const showMessage = isDef(message) && message !== "";
|
15718 | return vue.createVNode("div", {
|
15719 | "class": bem$1("mask")
|
15720 | }, [MaskIcon, showMessage && vue.createVNode("div", {
|
15721 | "class": bem$1("mask-message")
|
15722 | }, [message])]);
|
15723 | }
|
15724 | };
|
15725 | const onDelete = (event) => {
|
15726 | const {
|
15727 | name: name2,
|
15728 | item,
|
15729 | index,
|
15730 | beforeDelete
|
15731 | } = props2;
|
15732 | event.stopPropagation();
|
15733 | callInterceptor(beforeDelete, {
|
15734 | args: [item, {
|
15735 | name: name2,
|
15736 | index
|
15737 | }],
|
15738 | done: () => emit("delete")
|
15739 | });
|
15740 | };
|
15741 | const onPreview = () => emit("preview");
|
15742 | const onReupload = () => emit("reupload");
|
15743 | const renderDeleteIcon = () => {
|
15744 | if (props2.deletable && props2.item.status !== "uploading") {
|
15745 | const slot = slots["preview-delete"];
|
15746 | return vue.createVNode("div", {
|
15747 | "role": "button",
|
15748 | "class": bem$1("preview-delete", {
|
15749 | shadow: !slot
|
15750 | }),
|
15751 | "tabindex": 0,
|
15752 | "aria-label": t("delete"),
|
15753 | "onClick": onDelete
|
15754 | }, [slot ? slot() : vue.createVNode(Icon, {
|
15755 | "name": "cross",
|
15756 | "class": bem$1("preview-delete-icon")
|
15757 | }, null)]);
|
15758 | }
|
15759 | };
|
15760 | const renderCover = () => {
|
15761 | if (slots["preview-cover"]) {
|
15762 | const {
|
15763 | index,
|
15764 | item
|
15765 | } = props2;
|
15766 | return vue.createVNode("div", {
|
15767 | "class": bem$1("preview-cover")
|
15768 | }, [slots["preview-cover"](extend({
|
15769 | index
|
15770 | }, item))]);
|
15771 | }
|
15772 | };
|
15773 | const renderPreview = () => {
|
15774 | const {
|
15775 | item,
|
15776 | lazyLoad,
|
15777 | imageFit,
|
15778 | previewSize,
|
15779 | reupload
|
15780 | } = props2;
|
15781 | if (isImageFile(item)) {
|
15782 | return vue.createVNode(Image$1, {
|
15783 | "fit": imageFit,
|
15784 | "src": item.objectUrl || item.content || item.url,
|
15785 | "class": bem$1("preview-image"),
|
15786 | "width": Array.isArray(previewSize) ? previewSize[0] : previewSize,
|
15787 | "height": Array.isArray(previewSize) ? previewSize[1] : previewSize,
|
15788 | "lazyLoad": lazyLoad,
|
15789 | "onClick": reupload ? onReupload : onPreview
|
15790 | }, {
|
15791 | default: renderCover
|
15792 | });
|
15793 | }
|
15794 | return vue.createVNode("div", {
|
15795 | "class": bem$1("file"),
|
15796 | "style": getSizeStyle(props2.previewSize)
|
15797 | }, [vue.createVNode(Icon, {
|
15798 | "class": bem$1("file-icon"),
|
15799 | "name": "description"
|
15800 | }, null), vue.createVNode("div", {
|
15801 | "class": [bem$1("file-name"), "van-ellipsis"]
|
15802 | }, [item.file ? item.file.name : item.url]), renderCover()]);
|
15803 | };
|
15804 | return () => vue.createVNode("div", {
|
15805 | "class": bem$1("preview")
|
15806 | }, [renderPreview(), renderMask(), renderDeleteIcon()]);
|
15807 | }
|
15808 | });
|
15809 | const uploaderProps = {
|
15810 | name: makeNumericProp(""),
|
15811 | accept: makeStringProp("image/*"),
|
15812 | capture: String,
|
15813 | multiple: Boolean,
|
15814 | disabled: Boolean,
|
15815 | readonly: Boolean,
|
15816 | lazyLoad: Boolean,
|
15817 | maxCount: makeNumericProp(Infinity),
|
15818 | imageFit: makeStringProp("cover"),
|
15819 | resultType: makeStringProp("dataUrl"),
|
15820 | uploadIcon: makeStringProp("photograph"),
|
15821 | uploadText: String,
|
15822 | deletable: truthProp,
|
15823 | reupload: Boolean,
|
15824 | afterRead: Function,
|
15825 | showUpload: truthProp,
|
15826 | modelValue: makeArrayProp(),
|
15827 | beforeRead: Function,
|
15828 | beforeDelete: Function,
|
15829 | previewSize: [Number, String, Array],
|
15830 | previewImage: truthProp,
|
15831 | previewOptions: Object,
|
15832 | previewFullImage: truthProp,
|
15833 | maxSize: {
|
15834 | type: [Number, String, Function],
|
15835 | default: Infinity
|
15836 | }
|
15837 | };
|
15838 | var stdin_default$5 = vue.defineComponent({
|
15839 | name: name$1,
|
15840 | props: uploaderProps,
|
15841 | emits: ["delete", "oversize", "clickUpload", "closePreview", "clickPreview", "clickReupload", "update:modelValue"],
|
15842 | setup(props2, {
|
15843 | emit,
|
15844 | slots
|
15845 | }) {
|
15846 | const inputRef = vue.ref();
|
15847 | const urls = [];
|
15848 | const reuploadIndex = vue.ref(-1);
|
15849 | const isReuploading = vue.ref(false);
|
15850 | const getDetail = (index = props2.modelValue.length) => ({
|
15851 | name: props2.name,
|
15852 | index
|
15853 | });
|
15854 | const resetInput = () => {
|
15855 | if (inputRef.value) {
|
15856 | inputRef.value.value = "";
|
15857 | }
|
15858 | };
|
15859 | const onAfterRead = (items) => {
|
15860 | resetInput();
|
15861 | if (isOversize(items, props2.maxSize)) {
|
15862 | if (Array.isArray(items)) {
|
15863 | const result = filterFiles(items, props2.maxSize);
|
15864 | items = result.valid;
|
15865 | emit("oversize", result.invalid, getDetail());
|
15866 | if (!items.length) {
|
15867 | return;
|
15868 | }
|
15869 | } else {
|
15870 | emit("oversize", items, getDetail());
|
15871 | return;
|
15872 | }
|
15873 | }
|
15874 | items = vue.reactive(items);
|
15875 | if (reuploadIndex.value > -1) {
|
15876 | const arr = [...props2.modelValue];
|
15877 | arr.splice(reuploadIndex.value, 1, items);
|
15878 | emit("update:modelValue", arr);
|
15879 | reuploadIndex.value = -1;
|
15880 | } else {
|
15881 | emit("update:modelValue", [...props2.modelValue, ...toArray(items)]);
|
15882 | }
|
15883 | if (props2.afterRead) {
|
15884 | props2.afterRead(items, getDetail());
|
15885 | }
|
15886 | };
|
15887 | const readFile = (files) => {
|
15888 | const {
|
15889 | maxCount,
|
15890 | modelValue,
|
15891 | resultType
|
15892 | } = props2;
|
15893 | if (Array.isArray(files)) {
|
15894 | const remainCount = +maxCount - modelValue.length;
|
15895 | if (files.length > remainCount) {
|
15896 | files = files.slice(0, remainCount);
|
15897 | }
|
15898 | Promise.all(files.map((file) => readFileContent(file, resultType))).then((contents) => {
|
15899 | const fileList = files.map((file, index) => {
|
15900 | const result = {
|
15901 | file,
|
15902 | status: "",
|
15903 | message: "",
|
15904 | objectUrl: URL.createObjectURL(file)
|
15905 | };
|
15906 | if (contents[index]) {
|
15907 | result.content = contents[index];
|
15908 | }
|
15909 | return result;
|
15910 | });
|
15911 | onAfterRead(fileList);
|
15912 | });
|
15913 | } else {
|
15914 | readFileContent(files, resultType).then((content) => {
|
15915 | const result = {
|
15916 | file: files,
|
15917 | status: "",
|
15918 | message: "",
|
15919 | objectUrl: URL.createObjectURL(files)
|
15920 | };
|
15921 | if (content) {
|
15922 | result.content = content;
|
15923 | }
|
15924 | onAfterRead(result);
|
15925 | });
|
15926 | }
|
15927 | };
|
15928 | const onChange = (event) => {
|
15929 | const {
|
15930 | files
|
15931 | } = event.target;
|
15932 | if (props2.disabled || !files || !files.length) {
|
15933 | return;
|
15934 | }
|
15935 | const file = files.length === 1 ? files[0] : [].slice.call(files);
|
15936 | if (props2.beforeRead) {
|
15937 | const response = props2.beforeRead(file, getDetail());
|
15938 | if (!response) {
|
15939 | resetInput();
|
15940 | return;
|
15941 | }
|
15942 | if (isPromise(response)) {
|
15943 | response.then((data) => {
|
15944 | if (data) {
|
15945 | readFile(data);
|
15946 | } else {
|
15947 | readFile(file);
|
15948 | }
|
15949 | }).catch(resetInput);
|
15950 | return;
|
15951 | }
|
15952 | }
|
15953 | readFile(file);
|
15954 | };
|
15955 | let imagePreview;
|
15956 | const onClosePreview = () => emit("closePreview");
|
15957 | const previewImage = (item) => {
|
15958 | if (props2.previewFullImage) {
|
15959 | const imageFiles = props2.modelValue.filter(isImageFile);
|
15960 | const images = imageFiles.map((item2) => {
|
15961 | if (item2.objectUrl && !item2.url && item2.status !== "failed") {
|
15962 | item2.url = item2.objectUrl;
|
15963 | urls.push(item2.url);
|
15964 | }
|
15965 | return item2.url;
|
15966 | }).filter(Boolean);
|
15967 | imagePreview = showImagePreview(extend({
|
15968 | images,
|
15969 | startPosition: imageFiles.indexOf(item),
|
15970 | onClose: onClosePreview
|
15971 | }, props2.previewOptions));
|
15972 | }
|
15973 | };
|
15974 | const closeImagePreview = () => {
|
15975 | if (imagePreview) {
|
15976 | imagePreview.close();
|
15977 | }
|
15978 | };
|
15979 | const deleteFile = (item, index) => {
|
15980 | const fileList = props2.modelValue.slice(0);
|
15981 | fileList.splice(index, 1);
|
15982 | emit("update:modelValue", fileList);
|
15983 | emit("delete", item, getDetail(index));
|
15984 | };
|
15985 | const reuploadFile = (index) => {
|
15986 | isReuploading.value = true;
|
15987 | reuploadIndex.value = index;
|
15988 | vue.nextTick(() => chooseFile());
|
15989 | };
|
15990 | const onInputClick = () => {
|
15991 | if (!isReuploading.value) {
|
15992 | reuploadIndex.value = -1;
|
15993 | }
|
15994 | isReuploading.value = false;
|
15995 | };
|
15996 | const renderPreviewItem = (item, index) => {
|
15997 | const needPickData = ["imageFit", "deletable", "reupload", "previewSize", "beforeDelete"];
|
15998 | const previewData = extend(pick(props2, needPickData), pick(item, needPickData, true));
|
15999 | return vue.createVNode(stdin_default$6, vue.mergeProps({
|
16000 | "item": item,
|
16001 | "index": index,
|
16002 | "onClick": () => emit(props2.reupload ? "clickReupload" : "clickPreview", item, getDetail(index)),
|
16003 | "onDelete": () => deleteFile(item, index),
|
16004 | "onPreview": () => previewImage(item),
|
16005 | "onReupload": () => reuploadFile(index)
|
16006 | }, pick(props2, ["name", "lazyLoad"]), previewData), pick(slots, ["preview-cover", "preview-delete"]));
|
16007 | };
|
16008 | const renderPreviewList = () => {
|
16009 | if (props2.previewImage) {
|
16010 | return props2.modelValue.map(renderPreviewItem);
|
16011 | }
|
16012 | };
|
16013 | const onClickUpload = (event) => emit("clickUpload", event);
|
16014 | const renderUpload = () => {
|
16015 | const lessThanMax = props2.modelValue.length < +props2.maxCount;
|
16016 | const Input = props2.readonly ? null : vue.createVNode("input", {
|
16017 | "ref": inputRef,
|
16018 | "type": "file",
|
16019 | "class": bem$1("input"),
|
16020 | "accept": props2.accept,
|
16021 | "capture": props2.capture,
|
16022 | "multiple": props2.multiple && reuploadIndex.value === -1,
|
16023 | "disabled": props2.disabled,
|
16024 | "onChange": onChange,
|
16025 | "onClick": onInputClick
|
16026 | }, null);
|
16027 | if (slots.default) {
|
16028 | return vue.withDirectives(vue.createVNode("div", {
|
16029 | "class": bem$1("input-wrapper"),
|
16030 | "onClick": onClickUpload
|
16031 | }, [slots.default(), Input]), [[vue.vShow, lessThanMax]]);
|
16032 | }
|
16033 | return vue.withDirectives(vue.createVNode("div", {
|
16034 | "class": bem$1("upload", {
|
16035 | readonly: props2.readonly
|
16036 | }),
|
16037 | "style": getSizeStyle(props2.previewSize),
|
16038 | "onClick": onClickUpload
|
16039 | }, [vue.createVNode(Icon, {
|
16040 | "name": props2.uploadIcon,
|
16041 | "class": bem$1("upload-icon")
|
16042 | }, null), props2.uploadText && vue.createVNode("span", {
|
16043 | "class": bem$1("upload-text")
|
16044 | }, [props2.uploadText]), Input]), [[vue.vShow, props2.showUpload && lessThanMax]]);
|
16045 | };
|
16046 | const chooseFile = () => {
|
16047 | if (inputRef.value && !props2.disabled) {
|
16048 | inputRef.value.click();
|
16049 | }
|
16050 | };
|
16051 | vue.onBeforeUnmount(() => {
|
16052 | urls.forEach((url) => URL.revokeObjectURL(url));
|
16053 | });
|
16054 | useExpose({
|
16055 | chooseFile,
|
16056 | reuploadFile,
|
16057 | closeImagePreview
|
16058 | });
|
16059 | use.useCustomFieldValue(() => props2.modelValue);
|
16060 | return () => vue.createVNode("div", {
|
16061 | "class": bem$1()
|
16062 | }, [vue.createVNode("div", {
|
16063 | "class": bem$1("wrapper", {
|
16064 | disabled: props2.disabled
|
16065 | })
|
16066 | }, [renderPreviewList(), renderUpload()])]);
|
16067 | }
|
16068 | });
|
16069 | const Uploader = withInstall(stdin_default$5);
|
16070 | const [name, bem] = createNamespace("watermark");
|
16071 | const watermarkProps = {
|
16072 | gapX: makeNumberProp(0),
|
16073 | gapY: makeNumberProp(0),
|
16074 | image: String,
|
16075 | width: makeNumberProp(100),
|
16076 | height: makeNumberProp(100),
|
16077 | rotate: makeNumericProp(-22),
|
16078 | zIndex: numericProp,
|
16079 | content: String,
|
16080 | opacity: numericProp,
|
16081 | fullPage: truthProp,
|
16082 | textColor: makeStringProp("#dcdee0")
|
16083 | };
|
16084 | var stdin_default$4 = vue.defineComponent({
|
16085 | name,
|
16086 | props: watermarkProps,
|
16087 | setup(props2, {
|
16088 | slots
|
16089 | }) {
|
16090 | const svgElRef = vue.ref();
|
16091 | const watermarkUrl = vue.ref("");
|
16092 | const imageBase64 = vue.ref("");
|
16093 | const renderWatermark = () => {
|
16094 | const rotateStyle = {
|
16095 | transformOrigin: "center",
|
16096 | transform: `rotate(${props2.rotate}deg)`
|
16097 | };
|
16098 | const svgInner = () => {
|
16099 | if (props2.image && !slots.content) {
|
16100 | return vue.createVNode("image", {
|
16101 | "href": imageBase64.value,
|
16102 | "xlink:href": imageBase64.value,
|
16103 | "x": "0",
|
16104 | "y": "0",
|
16105 | "width": props2.width,
|
16106 | "height": props2.height,
|
16107 | "style": rotateStyle
|
16108 | }, null);
|
16109 | }
|
16110 | return vue.createVNode("foreignObject", {
|
16111 | "x": "0",
|
16112 | "y": "0",
|
16113 | "width": props2.width,
|
16114 | "height": props2.height
|
16115 | }, [vue.createVNode("div", {
|
16116 | "xmlns": "http://www.w3.org/1999/xhtml",
|
16117 | "style": rotateStyle
|
16118 | }, [slots.content ? slots.content() : vue.createVNode("span", {
|
16119 | "style": {
|
16120 | color: props2.textColor
|
16121 | }
|
16122 | }, [props2.content])])]);
|
16123 | };
|
16124 | const svgWidth = props2.width + props2.gapX;
|
16125 | const svgHeight = props2.height + props2.gapY;
|
16126 | return vue.createVNode("svg", {
|
16127 | "viewBox": `0 0 ${svgWidth} ${svgHeight}`,
|
16128 | "width": svgWidth,
|
16129 | "height": svgHeight,
|
16130 | "xmlns": "http://www.w3.org/2000/svg",
|
16131 | "xmlns:xlink": "http://www.w3.org/1999/xlink",
|
16132 | "style": {
|
16133 | padding: `0 ${props2.gapX}px ${props2.gapY}px 0`,
|
16134 | opacity: props2.opacity
|
16135 | }
|
16136 | }, [svgInner()]);
|
16137 | };
|
16138 | const makeImageToBase64 = (url) => {
|
16139 | const canvas = document.createElement("canvas");
|
16140 | const image = new Image();
|
16141 | image.crossOrigin = "anonymous";
|
16142 | image.referrerPolicy = "no-referrer";
|
16143 | image.onload = () => {
|
16144 | canvas.width = image.naturalWidth;
|
16145 | canvas.height = image.naturalHeight;
|
16146 | const ctx = canvas.getContext("2d");
|
16147 | ctx == null ? void 0 : ctx.drawImage(image, 0, 0);
|
16148 | imageBase64.value = canvas.toDataURL();
|
16149 | };
|
16150 | image.src = url;
|
16151 | };
|
16152 | const makeSvgToBlobUrl = (svgStr) => {
|
16153 | const svgBlob = new Blob([svgStr], {
|
16154 | type: "image/svg+xml"
|
16155 | });
|
16156 | return URL.createObjectURL(svgBlob);
|
16157 | };
|
16158 | vue.watchEffect(() => {
|
16159 | if (props2.image) {
|
16160 | makeImageToBase64(props2.image);
|
16161 | }
|
16162 | });
|
16163 | vue.watch(() => [imageBase64.value, props2.content, props2.textColor, props2.height, props2.width, props2.rotate, props2.gapX, props2.gapY], () => {
|
16164 | vue.nextTick(() => {
|
16165 | if (svgElRef.value) {
|
16166 | if (watermarkUrl.value) {
|
16167 | URL.revokeObjectURL(watermarkUrl.value);
|
16168 | }
|
16169 | watermarkUrl.value = makeSvgToBlobUrl(svgElRef.value.innerHTML);
|
16170 | }
|
16171 | });
|
16172 | }, {
|
16173 | immediate: true
|
16174 | });
|
16175 | vue.onUnmounted(() => {
|
16176 | if (watermarkUrl.value) {
|
16177 | URL.revokeObjectURL(watermarkUrl.value);
|
16178 | }
|
16179 | });
|
16180 | return () => {
|
16181 | const style = extend({
|
16182 | backgroundImage: `url(${watermarkUrl.value})`
|
16183 | }, getZIndexStyle(props2.zIndex));
|
16184 | return vue.createVNode("div", {
|
16185 | "class": bem({
|
16186 | full: props2.fullPage
|
16187 | }),
|
16188 | "style": style
|
16189 | }, [vue.createVNode("div", {
|
16190 | "class": bem("wrapper"),
|
16191 | "ref": svgElRef
|
16192 | }, [renderWatermark()])]);
|
16193 | };
|
16194 | }
|
16195 | });
|
16196 | const Watermark = withInstall(stdin_default$4);
|
16197 | class ReactiveListener {
|
16198 | constructor({
|
16199 | el,
|
16200 | src,
|
16201 | error,
|
16202 | loading,
|
16203 | bindType,
|
16204 | $parent,
|
16205 | options,
|
16206 | cors,
|
16207 | elRenderer,
|
16208 | imageCache
|
16209 | }) {
|
16210 | this.el = el;
|
16211 | this.src = src;
|
16212 | this.error = error;
|
16213 | this.loading = loading;
|
16214 | this.bindType = bindType;
|
16215 | this.attempt = 0;
|
16216 | this.cors = cors;
|
16217 | this.naturalHeight = 0;
|
16218 | this.naturalWidth = 0;
|
16219 | this.options = options;
|
16220 | this.$parent = $parent;
|
16221 | this.elRenderer = elRenderer;
|
16222 | this.imageCache = imageCache;
|
16223 | this.performanceData = {
|
16224 | loadStart: 0,
|
16225 | loadEnd: 0
|
16226 | };
|
16227 | this.filter();
|
16228 | this.initState();
|
16229 | this.render("loading", false);
|
16230 | }
|
16231 | |
16232 |
|
16233 |
|
16234 |
|
16235 | initState() {
|
16236 | if ("dataset" in this.el) {
|
16237 | this.el.dataset.src = this.src;
|
16238 | } else {
|
16239 | this.el.setAttribute("data-src", this.src);
|
16240 | }
|
16241 | this.state = {
|
16242 | loading: false,
|
16243 | error: false,
|
16244 | loaded: false,
|
16245 | rendered: false
|
16246 | };
|
16247 | }
|
16248 | |
16249 |
|
16250 |
|
16251 |
|
16252 | record(event) {
|
16253 | this.performanceData[event] = Date.now();
|
16254 | }
|
16255 | |
16256 |
|
16257 |
|
16258 |
|
16259 |
|
16260 |
|
16261 |
|
16262 | update({ src, loading, error }) {
|
16263 | const oldSrc = this.src;
|
16264 | this.src = src;
|
16265 | this.loading = loading;
|
16266 | this.error = error;
|
16267 | this.filter();
|
16268 | if (oldSrc !== this.src) {
|
16269 | this.attempt = 0;
|
16270 | this.initState();
|
16271 | }
|
16272 | }
|
16273 | |
16274 |
|
16275 |
|
16276 |
|
16277 | checkInView() {
|
16278 | const rect = use.useRect(this.el);
|
16279 | return rect.top < window.innerHeight * this.options.preLoad && rect.bottom > this.options.preLoadTop && rect.left < window.innerWidth * this.options.preLoad && rect.right > 0;
|
16280 | }
|
16281 | |
16282 |
|
16283 |
|
16284 | filter() {
|
16285 | Object.keys(this.options.filter).forEach((key) => {
|
16286 | this.options.filter[key](this, this.options);
|
16287 | });
|
16288 | }
|
16289 | |
16290 |
|
16291 |
|
16292 |
|
16293 |
|
16294 | renderLoading(cb) {
|
16295 | this.state.loading = true;
|
16296 | loadImageAsync(
|
16297 | {
|
16298 | src: this.loading,
|
16299 | cors: this.cors
|
16300 | },
|
16301 | () => {
|
16302 | this.render("loading", false);
|
16303 | this.state.loading = false;
|
16304 | cb();
|
16305 | },
|
16306 | () => {
|
16307 | cb();
|
16308 | this.state.loading = false;
|
16309 | if (process.env.NODE_ENV !== "production" && !this.options.silent)
|
16310 | console.warn(
|
16311 | `[@vant/lazyload] load failed with loading image(${this.loading})`
|
16312 | );
|
16313 | }
|
16314 | );
|
16315 | }
|
16316 | |
16317 |
|
16318 |
|
16319 |
|
16320 | load(onFinish = noop) {
|
16321 | if (this.attempt > this.options.attempt - 1 && this.state.error) {
|
16322 | if (process.env.NODE_ENV !== "production" && !this.options.silent) {
|
16323 | console.log(
|
16324 | `[@vant/lazyload] ${this.src} tried too more than ${this.options.attempt} times`
|
16325 | );
|
16326 | }
|
16327 | onFinish();
|
16328 | return;
|
16329 | }
|
16330 | if (this.state.rendered && this.state.loaded) return;
|
16331 | if (this.imageCache.has(this.src)) {
|
16332 | this.state.loaded = true;
|
16333 | this.render("loaded", true);
|
16334 | this.state.rendered = true;
|
16335 | return onFinish();
|
16336 | }
|
16337 | this.renderLoading(() => {
|
16338 | var _a, _b;
|
16339 | this.attempt++;
|
16340 | (_b = (_a = this.options.adapter).beforeLoad) == null ? void 0 : _b.call(_a, this, this.options);
|
16341 | this.record("loadStart");
|
16342 | loadImageAsync(
|
16343 | {
|
16344 | src: this.src,
|
16345 | cors: this.cors
|
16346 | },
|
16347 | (data) => {
|
16348 | this.naturalHeight = data.naturalHeight;
|
16349 | this.naturalWidth = data.naturalWidth;
|
16350 | this.state.loaded = true;
|
16351 | this.state.error = false;
|
16352 | this.record("loadEnd");
|
16353 | this.render("loaded", false);
|
16354 | this.state.rendered = true;
|
16355 | this.imageCache.add(this.src);
|
16356 | onFinish();
|
16357 | },
|
16358 | (err) => {
|
16359 | !this.options.silent && console.error(err);
|
16360 | this.state.error = true;
|
16361 | this.state.loaded = false;
|
16362 | this.render("error", false);
|
16363 | }
|
16364 | );
|
16365 | });
|
16366 | }
|
16367 | |
16368 |
|
16369 |
|
16370 |
|
16371 |
|
16372 |
|
16373 | render(state, cache) {
|
16374 | this.elRenderer(this, state, cache);
|
16375 | }
|
16376 | |
16377 |
|
16378 |
|
16379 |
|
16380 | performance() {
|
16381 | let state = "loading";
|
16382 | let time = 0;
|
16383 | if (this.state.loaded) {
|
16384 | state = "loaded";
|
16385 | time = (this.performanceData.loadEnd - this.performanceData.loadStart) / 1e3;
|
16386 | }
|
16387 | if (this.state.error) state = "error";
|
16388 | return {
|
16389 | src: this.src,
|
16390 | state,
|
16391 | time
|
16392 | };
|
16393 | }
|
16394 | |
16395 |
|
16396 |
|
16397 |
|
16398 | $destroy() {
|
16399 | this.el = null;
|
16400 | this.src = null;
|
16401 | this.error = null;
|
16402 | this.loading = null;
|
16403 | this.bindType = null;
|
16404 | this.attempt = 0;
|
16405 | }
|
16406 | }
|
16407 | const DEFAULT_URL = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
|
16408 | const DEFAULT_EVENTS = [
|
16409 | "scroll",
|
16410 | "wheel",
|
16411 | "mousewheel",
|
16412 | "resize",
|
16413 | "animationend",
|
16414 | "transitionend",
|
16415 | "touchmove"
|
16416 | ];
|
16417 | const DEFAULT_OBSERVER_OPTIONS = {
|
16418 | rootMargin: "0px",
|
16419 | threshold: 0
|
16420 | };
|
16421 | function stdin_default$3() {
|
16422 | return class Lazy {
|
16423 | constructor({
|
16424 | preLoad,
|
16425 | error,
|
16426 | throttleWait,
|
16427 | preLoadTop,
|
16428 | dispatchEvent,
|
16429 | loading,
|
16430 | attempt,
|
16431 | silent = true,
|
16432 | scale,
|
16433 | listenEvents,
|
16434 | filter,
|
16435 | adapter,
|
16436 | observer,
|
16437 | observerOptions
|
16438 | }) {
|
16439 | this.mode = modeType.event;
|
16440 | this.listeners = [];
|
16441 | this.targetIndex = 0;
|
16442 | this.targets = [];
|
16443 | this.options = {
|
16444 | silent,
|
16445 | dispatchEvent: !!dispatchEvent,
|
16446 | throttleWait: throttleWait || 200,
|
16447 | preLoad: preLoad || 1.3,
|
16448 | preLoadTop: preLoadTop || 0,
|
16449 | error: error || DEFAULT_URL,
|
16450 | loading: loading || DEFAULT_URL,
|
16451 | attempt: attempt || 3,
|
16452 | scale: scale || getDPR(scale),
|
16453 | ListenEvents: listenEvents || DEFAULT_EVENTS,
|
16454 | supportWebp: supportWebp(),
|
16455 | filter: filter || {},
|
16456 | adapter: adapter || {},
|
16457 | observer: !!observer,
|
16458 | observerOptions: observerOptions || DEFAULT_OBSERVER_OPTIONS
|
16459 | };
|
16460 | this.initEvent();
|
16461 | this.imageCache = new ImageCache({ max: 200 });
|
16462 | this.lazyLoadHandler = throttle(
|
16463 | this.lazyLoadHandler.bind(this),
|
16464 | this.options.throttleWait
|
16465 | );
|
16466 | this.setMode(this.options.observer ? modeType.observer : modeType.event);
|
16467 | }
|
16468 | |
16469 |
|
16470 |
|
16471 |
|
16472 |
|
16473 | config(options = {}) {
|
16474 | Object.assign(this.options, options);
|
16475 | }
|
16476 | |
16477 |
|
16478 |
|
16479 |
|
16480 | performance() {
|
16481 | return this.listeners.map((item) => item.performance());
|
16482 | }
|
16483 | |
16484 |
|
16485 |
|
16486 |
|
16487 |
|
16488 | addLazyBox(vm) {
|
16489 | this.listeners.push(vm);
|
16490 | if (use.inBrowser) {
|
16491 | this.addListenerTarget(window);
|
16492 | this.observer && this.observer.observe(vm.el);
|
16493 | if (vm.$el && vm.$el.parentNode) {
|
16494 | this.addListenerTarget(vm.$el.parentNode);
|
16495 | }
|
16496 | }
|
16497 | }
|
16498 | |
16499 |
|
16500 |
|
16501 |
|
16502 |
|
16503 |
|
16504 |
|
16505 | add(el, binding, vnode) {
|
16506 | if (this.listeners.some((item) => item.el === el)) {
|
16507 | this.update(el, binding);
|
16508 | return vue.nextTick(this.lazyLoadHandler);
|
16509 | }
|
16510 | const value = this.valueFormatter(binding.value);
|
16511 | let { src } = value;
|
16512 | vue.nextTick(() => {
|
16513 | src = getBestSelectionFromSrcset(el, this.options.scale) || src;
|
16514 | this.observer && this.observer.observe(el);
|
16515 | const container = Object.keys(binding.modifiers)[0];
|
16516 | let $parent;
|
16517 | if (container) {
|
16518 | $parent = vnode.context.$refs[container];
|
16519 | $parent = $parent ? $parent.$el || $parent : document.getElementById(container);
|
16520 | }
|
16521 | if (!$parent) {
|
16522 | $parent = use.getScrollParent(el);
|
16523 | }
|
16524 | const newListener = new ReactiveListener({
|
16525 | bindType: binding.arg,
|
16526 | $parent,
|
16527 | el,
|
16528 | src,
|
16529 | loading: value.loading,
|
16530 | error: value.error,
|
16531 | cors: value.cors,
|
16532 | elRenderer: this.elRenderer.bind(this),
|
16533 | options: this.options,
|
16534 | imageCache: this.imageCache
|
16535 | });
|
16536 | this.listeners.push(newListener);
|
16537 | if (use.inBrowser) {
|
16538 | this.addListenerTarget(window);
|
16539 | this.addListenerTarget($parent);
|
16540 | }
|
16541 | this.lazyLoadHandler();
|
16542 | vue.nextTick(() => this.lazyLoadHandler());
|
16543 | });
|
16544 | }
|
16545 | |
16546 |
|
16547 |
|
16548 |
|
16549 |
|
16550 |
|
16551 | update(el, binding, vnode) {
|
16552 | const value = this.valueFormatter(binding.value);
|
16553 | let { src } = value;
|
16554 | src = getBestSelectionFromSrcset(el, this.options.scale) || src;
|
16555 | const exist = this.listeners.find((item) => item.el === el);
|
16556 | if (!exist) {
|
16557 | this.add(el, binding, vnode);
|
16558 | } else {
|
16559 | exist.update({
|
16560 | src,
|
16561 | error: value.error,
|
16562 | loading: value.loading
|
16563 | });
|
16564 | }
|
16565 | if (this.observer) {
|
16566 | this.observer.unobserve(el);
|
16567 | this.observer.observe(el);
|
16568 | }
|
16569 | this.lazyLoadHandler();
|
16570 | vue.nextTick(() => this.lazyLoadHandler());
|
16571 | }
|
16572 | |
16573 |
|
16574 |
|
16575 |
|
16576 |
|
16577 | remove(el) {
|
16578 | if (!el) return;
|
16579 | this.observer && this.observer.unobserve(el);
|
16580 | const existItem = this.listeners.find((item) => item.el === el);
|
16581 | if (existItem) {
|
16582 | this.removeListenerTarget(existItem.$parent);
|
16583 | this.removeListenerTarget(window);
|
16584 | remove(this.listeners, existItem);
|
16585 | existItem.$destroy();
|
16586 | }
|
16587 | }
|
16588 | |
16589 |
|
16590 |
|
16591 |
|
16592 |
|
16593 | removeComponent(vm) {
|
16594 | if (!vm) return;
|
16595 | remove(this.listeners, vm);
|
16596 | this.observer && this.observer.unobserve(vm.el);
|
16597 | if (vm.$parent && vm.$el.parentNode) {
|
16598 | this.removeListenerTarget(vm.$el.parentNode);
|
16599 | }
|
16600 | this.removeListenerTarget(window);
|
16601 | }
|
16602 | setMode(mode) {
|
16603 | if (!hasIntersectionObserver && mode === modeType.observer) {
|
16604 | mode = modeType.event;
|
16605 | }
|
16606 | this.mode = mode;
|
16607 | if (mode === modeType.event) {
|
16608 | if (this.observer) {
|
16609 | this.listeners.forEach((listener) => {
|
16610 | this.observer.unobserve(listener.el);
|
16611 | });
|
16612 | this.observer = null;
|
16613 | }
|
16614 | this.targets.forEach((target) => {
|
16615 | this.initListen(target.el, true);
|
16616 | });
|
16617 | } else {
|
16618 | this.targets.forEach((target) => {
|
16619 | this.initListen(target.el, false);
|
16620 | });
|
16621 | this.initIntersectionObserver();
|
16622 | }
|
16623 | }
|
16624 | |
16625 |
|
16626 |
|
16627 | |
16628 |
|
16629 |
|
16630 |
|
16631 |
|
16632 | addListenerTarget(el) {
|
16633 | if (!el) return;
|
16634 | let target = this.targets.find((target2) => target2.el === el);
|
16635 | if (!target) {
|
16636 | target = {
|
16637 | el,
|
16638 | id: ++this.targetIndex,
|
16639 | childrenCount: 1,
|
16640 | listened: true
|
16641 | };
|
16642 | this.mode === modeType.event && this.initListen(target.el, true);
|
16643 | this.targets.push(target);
|
16644 | } else {
|
16645 | target.childrenCount++;
|
16646 | }
|
16647 | return this.targetIndex;
|
16648 | }
|
16649 | |
16650 |
|
16651 |
|
16652 |
|
16653 |
|
16654 | removeListenerTarget(el) {
|
16655 | this.targets.forEach((target, index) => {
|
16656 | if (target.el === el) {
|
16657 | target.childrenCount--;
|
16658 | if (!target.childrenCount) {
|
16659 | this.initListen(target.el, false);
|
16660 | this.targets.splice(index, 1);
|
16661 | target = null;
|
16662 | }
|
16663 | }
|
16664 | });
|
16665 | }
|
16666 | |
16667 |
|
16668 |
|
16669 |
|
16670 |
|
16671 |
|
16672 | initListen(el, start) {
|
16673 | this.options.ListenEvents.forEach(
|
16674 | (evt) => (start ? on : off)(el, evt, this.lazyLoadHandler)
|
16675 | );
|
16676 | }
|
16677 | initEvent() {
|
16678 | this.Event = {
|
16679 | listeners: {
|
16680 | loading: [],
|
16681 | loaded: [],
|
16682 | error: []
|
16683 | }
|
16684 | };
|
16685 | this.$on = (event, func) => {
|
16686 | if (!this.Event.listeners[event]) this.Event.listeners[event] = [];
|
16687 | this.Event.listeners[event].push(func);
|
16688 | };
|
16689 | this.$once = (event, func) => {
|
16690 | const on2 = (...args) => {
|
16691 | this.$off(event, on2);
|
16692 | func.apply(this, args);
|
16693 | };
|
16694 | this.$on(event, on2);
|
16695 | };
|
16696 | this.$off = (event, func) => {
|
16697 | if (!func) {
|
16698 | if (!this.Event.listeners[event]) return;
|
16699 | this.Event.listeners[event].length = 0;
|
16700 | return;
|
16701 | }
|
16702 | remove(this.Event.listeners[event], func);
|
16703 | };
|
16704 | this.$emit = (event, context, inCache) => {
|
16705 | if (!this.Event.listeners[event]) return;
|
16706 | this.Event.listeners[event].forEach((func) => func(context, inCache));
|
16707 | };
|
16708 | }
|
16709 | |
16710 |
|
16711 |
|
16712 |
|
16713 | lazyLoadHandler() {
|
16714 | const freeList = [];
|
16715 | this.listeners.forEach((listener) => {
|
16716 | if (!listener.el || !listener.el.parentNode) {
|
16717 | freeList.push(listener);
|
16718 | }
|
16719 | const catIn = listener.checkInView();
|
16720 | if (!catIn) return;
|
16721 | listener.load();
|
16722 | });
|
16723 | freeList.forEach((item) => {
|
16724 | remove(this.listeners, item);
|
16725 | item.$destroy();
|
16726 | });
|
16727 | }
|
16728 | |
16729 |
|
16730 |
|
16731 |
|
16732 |
|
16733 | initIntersectionObserver() {
|
16734 | if (!hasIntersectionObserver) {
|
16735 | return;
|
16736 | }
|
16737 | this.observer = new IntersectionObserver(
|
16738 | this.observerHandler.bind(this),
|
16739 | this.options.observerOptions
|
16740 | );
|
16741 | if (this.listeners.length) {
|
16742 | this.listeners.forEach((listener) => {
|
16743 | this.observer.observe(listener.el);
|
16744 | });
|
16745 | }
|
16746 | }
|
16747 | |
16748 |
|
16749 |
|
16750 |
|
16751 | observerHandler(entries) {
|
16752 | entries.forEach((entry) => {
|
16753 | if (entry.isIntersecting) {
|
16754 | this.listeners.forEach((listener) => {
|
16755 | if (listener.el === entry.target) {
|
16756 | if (listener.state.loaded)
|
16757 | return this.observer.unobserve(listener.el);
|
16758 | listener.load();
|
16759 | }
|
16760 | });
|
16761 | }
|
16762 | });
|
16763 | }
|
16764 | |
16765 |
|
16766 |
|
16767 |
|
16768 |
|
16769 |
|
16770 |
|
16771 | elRenderer(listener, state, cache) {
|
16772 | if (!listener.el) return;
|
16773 | const { el, bindType } = listener;
|
16774 | let src;
|
16775 | switch (state) {
|
16776 | case "loading":
|
16777 | src = listener.loading;
|
16778 | break;
|
16779 | case "error":
|
16780 | src = listener.error;
|
16781 | break;
|
16782 | default:
|
16783 | ({ src } = listener);
|
16784 | break;
|
16785 | }
|
16786 | if (bindType) {
|
16787 | el.style[bindType] = 'url("' + src + '")';
|
16788 | } else if (el.getAttribute("src") !== src) {
|
16789 | el.setAttribute("src", src);
|
16790 | }
|
16791 | el.setAttribute("lazy", state);
|
16792 | this.$emit(state, listener, cache);
|
16793 | this.options.adapter[state] && this.options.adapter[state](listener, this.options);
|
16794 | if (this.options.dispatchEvent) {
|
16795 | const event = new CustomEvent(state, {
|
16796 | detail: listener
|
16797 | });
|
16798 | el.dispatchEvent(event);
|
16799 | }
|
16800 | }
|
16801 | |
16802 |
|
16803 |
|
16804 |
|
16805 |
|
16806 | valueFormatter(value) {
|
16807 | let src = value;
|
16808 | let { loading, error } = this.options;
|
16809 | if (isObject(value)) {
|
16810 | if (process.env.NODE_ENV !== "production" && !value.src && !this.options.silent) {
|
16811 | console.error("[@vant/lazyload] miss src with " + value);
|
16812 | }
|
16813 | ({ src } = value);
|
16814 | loading = value.loading || this.options.loading;
|
16815 | error = value.error || this.options.error;
|
16816 | }
|
16817 | return {
|
16818 | src,
|
16819 | loading,
|
16820 | error
|
16821 | };
|
16822 | }
|
16823 | };
|
16824 | }
|
16825 | var stdin_default$2 = (lazy) => ({
|
16826 | props: {
|
16827 | tag: {
|
16828 | type: String,
|
16829 | default: "div"
|
16830 | }
|
16831 | },
|
16832 | emits: ["show"],
|
16833 | render() {
|
16834 | return vue.h(
|
16835 | this.tag,
|
16836 | this.show && this.$slots.default ? this.$slots.default() : null
|
16837 | );
|
16838 | },
|
16839 | data() {
|
16840 | return {
|
16841 | el: null,
|
16842 | state: {
|
16843 | loaded: false
|
16844 | },
|
16845 | show: false
|
16846 | };
|
16847 | },
|
16848 | mounted() {
|
16849 | this.el = this.$el;
|
16850 | lazy.addLazyBox(this);
|
16851 | lazy.lazyLoadHandler();
|
16852 | },
|
16853 | beforeUnmount() {
|
16854 | lazy.removeComponent(this);
|
16855 | },
|
16856 | methods: {
|
16857 | checkInView() {
|
16858 | const rect = use.useRect(this.$el);
|
16859 | return use.inBrowser && rect.top < window.innerHeight * lazy.options.preLoad && rect.bottom > 0 && rect.left < window.innerWidth * lazy.options.preLoad && rect.right > 0;
|
16860 | },
|
16861 | load() {
|
16862 | this.show = true;
|
16863 | this.state.loaded = true;
|
16864 | this.$emit("show", this);
|
16865 | },
|
16866 | destroy() {
|
16867 | return this.$destroy;
|
16868 | }
|
16869 | }
|
16870 | });
|
16871 | const defaultOptions = {
|
16872 | selector: "img"
|
16873 | };
|
16874 | class LazyContainer {
|
16875 | constructor({ el, binding, vnode, lazy }) {
|
16876 | this.el = null;
|
16877 | this.vnode = vnode;
|
16878 | this.binding = binding;
|
16879 | this.options = {};
|
16880 | this.lazy = lazy;
|
16881 | this.queue = [];
|
16882 | this.update({ el, binding });
|
16883 | }
|
16884 | update({ el, binding }) {
|
16885 | this.el = el;
|
16886 | this.options = Object.assign({}, defaultOptions, binding.value);
|
16887 | const imgs = this.getImgs();
|
16888 | imgs.forEach((el2) => {
|
16889 | this.lazy.add(
|
16890 | el2,
|
16891 | Object.assign({}, this.binding, {
|
16892 | value: {
|
16893 | src: "dataset" in el2 ? el2.dataset.src : el2.getAttribute("data-src"),
|
16894 | error: ("dataset" in el2 ? el2.dataset.error : el2.getAttribute("data-error")) || this.options.error,
|
16895 | loading: ("dataset" in el2 ? el2.dataset.loading : el2.getAttribute("data-loading")) || this.options.loading
|
16896 | }
|
16897 | }),
|
16898 | this.vnode
|
16899 | );
|
16900 | });
|
16901 | }
|
16902 | getImgs() {
|
16903 | return Array.from(this.el.querySelectorAll(this.options.selector));
|
16904 | }
|
16905 | clear() {
|
16906 | const imgs = this.getImgs();
|
16907 | imgs.forEach((el) => this.lazy.remove(el));
|
16908 | this.vnode = null;
|
16909 | this.binding = null;
|
16910 | this.lazy = null;
|
16911 | }
|
16912 | }
|
16913 | class LazyContainerManager {
|
16914 | constructor({ lazy }) {
|
16915 | this.lazy = lazy;
|
16916 | this.queue = [];
|
16917 | }
|
16918 | bind(el, binding, vnode) {
|
16919 | const container = new LazyContainer({
|
16920 | el,
|
16921 | binding,
|
16922 | vnode,
|
16923 | lazy: this.lazy
|
16924 | });
|
16925 | this.queue.push(container);
|
16926 | }
|
16927 | update(el, binding, vnode) {
|
16928 | const container = this.queue.find((item) => item.el === el);
|
16929 | if (!container) return;
|
16930 | container.update({ el, binding, vnode });
|
16931 | }
|
16932 | unbind(el) {
|
16933 | const container = this.queue.find((item) => item.el === el);
|
16934 | if (!container) return;
|
16935 | container.clear();
|
16936 | remove(this.queue, container);
|
16937 | }
|
16938 | }
|
16939 | var stdin_default$1 = (lazyManager) => ({
|
16940 | props: {
|
16941 | src: [String, Object],
|
16942 | tag: {
|
16943 | type: String,
|
16944 | default: "img"
|
16945 | }
|
16946 | },
|
16947 | render() {
|
16948 | var _a, _b;
|
16949 | return vue.h(
|
16950 | this.tag,
|
16951 | {
|
16952 | src: this.renderSrc
|
16953 | },
|
16954 | (_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a)
|
16955 | );
|
16956 | },
|
16957 | data() {
|
16958 | return {
|
16959 | el: null,
|
16960 | options: {
|
16961 | src: "",
|
16962 | error: "",
|
16963 | loading: "",
|
16964 | attempt: lazyManager.options.attempt
|
16965 | },
|
16966 | state: {
|
16967 | loaded: false,
|
16968 | error: false,
|
16969 | attempt: 0
|
16970 | },
|
16971 | renderSrc: ""
|
16972 | };
|
16973 | },
|
16974 | watch: {
|
16975 | src() {
|
16976 | this.init();
|
16977 | lazyManager.addLazyBox(this);
|
16978 | lazyManager.lazyLoadHandler();
|
16979 | }
|
16980 | },
|
16981 | created() {
|
16982 | this.init();
|
16983 | },
|
16984 | mounted() {
|
16985 | this.el = this.$el;
|
16986 | lazyManager.addLazyBox(this);
|
16987 | lazyManager.lazyLoadHandler();
|
16988 | },
|
16989 | beforeUnmount() {
|
16990 | lazyManager.removeComponent(this);
|
16991 | },
|
16992 | methods: {
|
16993 | init() {
|
16994 | const { src, loading, error } = lazyManager.valueFormatter(this.src);
|
16995 | this.state.loaded = false;
|
16996 | this.options.src = src;
|
16997 | this.options.error = error;
|
16998 | this.options.loading = loading;
|
16999 | this.renderSrc = this.options.loading;
|
17000 | },
|
17001 | checkInView() {
|
17002 | const rect = use.useRect(this.$el);
|
17003 | return rect.top < window.innerHeight * lazyManager.options.preLoad && rect.bottom > 0 && rect.left < window.innerWidth * lazyManager.options.preLoad && rect.right > 0;
|
17004 | },
|
17005 | load(onFinish = noop) {
|
17006 | if (this.state.attempt > this.options.attempt - 1 && this.state.error) {
|
17007 | if (process.env.NODE_ENV !== "production" && !lazyManager.options.silent) {
|
17008 | console.log(
|
17009 | `[@vant/lazyload] ${this.options.src} tried too more than ${this.options.attempt} times`
|
17010 | );
|
17011 | }
|
17012 | onFinish();
|
17013 | return;
|
17014 | }
|
17015 | const { src } = this.options;
|
17016 | loadImageAsync(
|
17017 | { src },
|
17018 | ({ src: src2 }) => {
|
17019 | this.renderSrc = src2;
|
17020 | this.state.loaded = true;
|
17021 | },
|
17022 | () => {
|
17023 | this.state.attempt++;
|
17024 | this.renderSrc = this.options.error;
|
17025 | this.state.error = true;
|
17026 | }
|
17027 | );
|
17028 | }
|
17029 | }
|
17030 | });
|
17031 | const Lazyload = {
|
17032 | |
17033 |
|
17034 |
|
17035 |
|
17036 |
|
17037 | install(app, options = {}) {
|
17038 | const LazyClass = stdin_default$3();
|
17039 | const lazy = new LazyClass(options);
|
17040 | const lazyContainer = new LazyContainerManager({ lazy });
|
17041 | app.config.globalProperties.$Lazyload = lazy;
|
17042 | if (options.lazyComponent) {
|
17043 | app.component("LazyComponent", stdin_default$2(lazy));
|
17044 | }
|
17045 | if (options.lazyImage) {
|
17046 | app.component("LazyImage", stdin_default$1(lazy));
|
17047 | }
|
17048 | app.directive("lazy", {
|
17049 | beforeMount: lazy.add.bind(lazy),
|
17050 | updated: lazy.update.bind(lazy),
|
17051 | unmounted: lazy.remove.bind(lazy)
|
17052 | });
|
17053 | app.directive("lazy-container", {
|
17054 | beforeMount: lazyContainer.bind.bind(lazyContainer),
|
17055 | updated: lazyContainer.update.bind(lazyContainer),
|
17056 | unmounted: lazyContainer.unbind.bind(lazyContainer)
|
17057 | });
|
17058 | }
|
17059 | };
|
17060 | const version = "4.9.8";
|
17061 | function install(app) {
|
17062 | const components = [
|
17063 | ActionBar,
|
17064 | ActionBarButton,
|
17065 | ActionBarIcon,
|
17066 | ActionSheet,
|
17067 | AddressEdit,
|
17068 | AddressList,
|
17069 | Area,
|
17070 | BackTop,
|
17071 | Badge,
|
17072 | Barrage,
|
17073 | Button,
|
17074 | Calendar,
|
17075 | Card,
|
17076 | Cascader,
|
17077 | Cell,
|
17078 | CellGroup,
|
17079 | Checkbox,
|
17080 | CheckboxGroup,
|
17081 | Circle,
|
17082 | Col,
|
17083 | Collapse,
|
17084 | CollapseItem,
|
17085 | ConfigProvider,
|
17086 | ContactCard,
|
17087 | ContactEdit,
|
17088 | ContactList,
|
17089 | CountDown,
|
17090 | Coupon,
|
17091 | CouponCell,
|
17092 | CouponList,
|
17093 | DatePicker,
|
17094 | Dialog,
|
17095 | Divider,
|
17096 | DropdownItem,
|
17097 | DropdownMenu,
|
17098 | Empty,
|
17099 | Field,
|
17100 | FloatingBubble,
|
17101 | FloatingPanel,
|
17102 | Form,
|
17103 | Grid,
|
17104 | GridItem,
|
17105 | Highlight,
|
17106 | Icon,
|
17107 | Image$1,
|
17108 | ImagePreview,
|
17109 | IndexAnchor,
|
17110 | IndexBar,
|
17111 | List,
|
17112 | Loading,
|
17113 | Locale,
|
17114 | NavBar,
|
17115 | NoticeBar,
|
17116 | Notify,
|
17117 | NumberKeyboard,
|
17118 | Overlay,
|
17119 | Pagination,
|
17120 | PasswordInput,
|
17121 | Picker,
|
17122 | PickerGroup,
|
17123 | Popover,
|
17124 | Popup,
|
17125 | Progress,
|
17126 | PullRefresh,
|
17127 | Radio,
|
17128 | RadioGroup,
|
17129 | Rate,
|
17130 | RollingText,
|
17131 | Row,
|
17132 | Search,
|
17133 | ShareSheet,
|
17134 | Sidebar,
|
17135 | SidebarItem,
|
17136 | Signature,
|
17137 | Skeleton,
|
17138 | SkeletonAvatar,
|
17139 | SkeletonImage,
|
17140 | SkeletonParagraph,
|
17141 | SkeletonTitle,
|
17142 | Slider,
|
17143 | Space,
|
17144 | Step,
|
17145 | Stepper,
|
17146 | Steps,
|
17147 | Sticky,
|
17148 | SubmitBar,
|
17149 | Swipe,
|
17150 | SwipeCell,
|
17151 | SwipeItem,
|
17152 | Switch,
|
17153 | Tab,
|
17154 | Tabbar,
|
17155 | TabbarItem,
|
17156 | Tabs,
|
17157 | Tag,
|
17158 | TextEllipsis,
|
17159 | TimePicker,
|
17160 | Toast,
|
17161 | TreeSelect,
|
17162 | Uploader,
|
17163 | Watermark
|
17164 | ];
|
17165 | components.forEach((item) => {
|
17166 | if (item.install) {
|
17167 | app.use(item);
|
17168 | } else if (item.name) {
|
17169 | app.component(item.name, item);
|
17170 | }
|
17171 | });
|
17172 | }
|
17173 | var stdin_default = {
|
17174 | install,
|
17175 | version
|
17176 | };
|
17177 | exports.ActionBar = ActionBar;
|
17178 | exports.ActionBarButton = ActionBarButton;
|
17179 | exports.ActionBarIcon = ActionBarIcon;
|
17180 | exports.ActionSheet = ActionSheet;
|
17181 | exports.AddressEdit = AddressEdit;
|
17182 | exports.AddressList = AddressList;
|
17183 | exports.Area = Area;
|
17184 | exports.BackTop = BackTop;
|
17185 | exports.Badge = Badge;
|
17186 | exports.Barrage = Barrage;
|
17187 | exports.Button = Button;
|
17188 | exports.Calendar = Calendar;
|
17189 | exports.Card = Card;
|
17190 | exports.Cascader = Cascader;
|
17191 | exports.Cell = Cell;
|
17192 | exports.CellGroup = CellGroup;
|
17193 | exports.Checkbox = Checkbox;
|
17194 | exports.CheckboxGroup = CheckboxGroup;
|
17195 | exports.Circle = Circle;
|
17196 | exports.Col = Col;
|
17197 | exports.Collapse = Collapse;
|
17198 | exports.CollapseItem = CollapseItem;
|
17199 | exports.ConfigProvider = ConfigProvider;
|
17200 | exports.ContactCard = ContactCard;
|
17201 | exports.ContactEdit = ContactEdit;
|
17202 | exports.ContactList = ContactList;
|
17203 | exports.CountDown = CountDown;
|
17204 | exports.Coupon = Coupon;
|
17205 | exports.CouponCell = CouponCell;
|
17206 | exports.CouponList = CouponList;
|
17207 | exports.DEFAULT_ROW_WIDTH = DEFAULT_ROW_WIDTH;
|
17208 | exports.DatePicker = DatePicker;
|
17209 | exports.Dialog = Dialog;
|
17210 | exports.Divider = Divider;
|
17211 | exports.DropdownItem = DropdownItem;
|
17212 | exports.DropdownMenu = DropdownMenu;
|
17213 | exports.Empty = Empty;
|
17214 | exports.Field = Field;
|
17215 | exports.FloatingBubble = FloatingBubble;
|
17216 | exports.FloatingPanel = FloatingPanel;
|
17217 | exports.Form = Form;
|
17218 | exports.Grid = Grid;
|
17219 | exports.GridItem = GridItem;
|
17220 | exports.Highlight = Highlight;
|
17221 | exports.Icon = Icon;
|
17222 | exports.Image = Image$1;
|
17223 | exports.ImagePreview = ImagePreview;
|
17224 | exports.IndexAnchor = IndexAnchor;
|
17225 | exports.IndexBar = IndexBar;
|
17226 | exports.Lazyload = Lazyload;
|
17227 | exports.List = List;
|
17228 | exports.Loading = Loading;
|
17229 | exports.Locale = Locale;
|
17230 | exports.NavBar = NavBar;
|
17231 | exports.NoticeBar = NoticeBar;
|
17232 | exports.Notify = Notify;
|
17233 | exports.NumberKeyboard = NumberKeyboard;
|
17234 | exports.Overlay = Overlay;
|
17235 | exports.Pagination = Pagination;
|
17236 | exports.PasswordInput = PasswordInput;
|
17237 | exports.Picker = Picker;
|
17238 | exports.PickerGroup = PickerGroup;
|
17239 | exports.Popover = Popover;
|
17240 | exports.Popup = Popup;
|
17241 | exports.Progress = Progress;
|
17242 | exports.PullRefresh = PullRefresh;
|
17243 | exports.Radio = Radio;
|
17244 | exports.RadioGroup = RadioGroup;
|
17245 | exports.Rate = Rate;
|
17246 | exports.RollingText = RollingText;
|
17247 | exports.Row = Row;
|
17248 | exports.Search = Search;
|
17249 | exports.ShareSheet = ShareSheet;
|
17250 | exports.Sidebar = Sidebar;
|
17251 | exports.SidebarItem = SidebarItem;
|
17252 | exports.Signature = Signature;
|
17253 | exports.Skeleton = Skeleton;
|
17254 | exports.SkeletonAvatar = SkeletonAvatar;
|
17255 | exports.SkeletonImage = SkeletonImage;
|
17256 | exports.SkeletonParagraph = SkeletonParagraph;
|
17257 | exports.SkeletonTitle = SkeletonTitle;
|
17258 | exports.Slider = Slider;
|
17259 | exports.Space = Space;
|
17260 | exports.Step = Step;
|
17261 | exports.Stepper = Stepper;
|
17262 | exports.Steps = Steps;
|
17263 | exports.Sticky = Sticky;
|
17264 | exports.SubmitBar = SubmitBar;
|
17265 | exports.Swipe = Swipe;
|
17266 | exports.SwipeCell = SwipeCell;
|
17267 | exports.SwipeItem = SwipeItem;
|
17268 | exports.Switch = Switch;
|
17269 | exports.Tab = Tab;
|
17270 | exports.Tabbar = Tabbar;
|
17271 | exports.TabbarItem = TabbarItem;
|
17272 | exports.Tabs = Tabs;
|
17273 | exports.Tag = Tag;
|
17274 | exports.TextEllipsis = TextEllipsis;
|
17275 | exports.TimePicker = TimePicker;
|
17276 | exports.Toast = Toast;
|
17277 | exports.TreeSelect = TreeSelect;
|
17278 | exports.Uploader = Uploader;
|
17279 | exports.Watermark = Watermark;
|
17280 | exports.actionBarButtonProps = actionBarButtonProps;
|
17281 | exports.actionBarIconProps = actionBarIconProps;
|
17282 | exports.actionBarProps = actionBarProps;
|
17283 | exports.actionSheetProps = actionSheetProps;
|
17284 | exports.addressEditProps = addressEditProps;
|
17285 | exports.addressListProps = addressListProps;
|
17286 | exports.allowMultipleToast = allowMultipleToast;
|
17287 | exports.areaProps = areaProps;
|
17288 | exports.backTopProps = backTopProps;
|
17289 | exports.badgeProps = badgeProps;
|
17290 | exports.barrageProps = barrageProps;
|
17291 | exports.buttonProps = buttonProps;
|
17292 | exports.calendarProps = calendarProps;
|
17293 | exports.cardProps = cardProps;
|
17294 | exports.cascaderProps = cascaderProps;
|
17295 | exports.cellGroupProps = cellGroupProps;
|
17296 | exports.cellProps = cellProps;
|
17297 | exports.checkboxGroupProps = checkboxGroupProps;
|
17298 | exports.checkboxProps = checkboxProps;
|
17299 | exports.circleProps = circleProps;
|
17300 | exports.closeDialog = closeDialog;
|
17301 | exports.closeNotify = closeNotify;
|
17302 | exports.closeToast = closeToast;
|
17303 | exports.colProps = colProps;
|
17304 | exports.collapseItemProps = collapseItemProps;
|
17305 | exports.collapseProps = collapseProps;
|
17306 | exports.configProviderProps = configProviderProps;
|
17307 | exports.contactCardProps = contactCardProps;
|
17308 | exports.contactEditProps = contactEditProps;
|
17309 | exports.contactListProps = contactListProps;
|
17310 | exports.countDownProps = countDownProps;
|
17311 | exports.couponCellProps = couponCellProps;
|
17312 | exports.couponListProps = couponListProps;
|
17313 | exports.datePickerProps = datePickerProps;
|
17314 | exports.default = stdin_default;
|
17315 | exports.dialogProps = dialogProps;
|
17316 | exports.dividerProps = dividerProps;
|
17317 | exports.dropdownItemProps = dropdownItemProps;
|
17318 | exports.dropdownMenuProps = dropdownMenuProps;
|
17319 | exports.emptyProps = emptyProps;
|
17320 | exports.fieldProps = fieldProps;
|
17321 | exports.floatingBubbleProps = floatingBubbleProps;
|
17322 | exports.floatingPanelProps = floatingPanelProps;
|
17323 | exports.formProps = formProps;
|
17324 | exports.gridItemProps = gridItemProps;
|
17325 | exports.gridProps = gridProps;
|
17326 | exports.highlightProps = highlightProps;
|
17327 | exports.iconProps = iconProps;
|
17328 | exports.imagePreviewProps = imagePreviewProps;
|
17329 | exports.imageProps = imageProps;
|
17330 | exports.indexAnchorProps = indexAnchorProps;
|
17331 | exports.indexBarProps = indexBarProps;
|
17332 | exports.install = install;
|
17333 | exports.listProps = listProps;
|
17334 | exports.loadingProps = loadingProps;
|
17335 | exports.navBarProps = navBarProps;
|
17336 | exports.noticeBarProps = noticeBarProps;
|
17337 | exports.notifyProps = notifyProps;
|
17338 | exports.numberKeyboardProps = numberKeyboardProps;
|
17339 | exports.overlayProps = overlayProps;
|
17340 | exports.paginationProps = paginationProps;
|
17341 | exports.passwordInputProps = passwordInputProps;
|
17342 | exports.pickerGroupProps = pickerGroupProps;
|
17343 | exports.pickerProps = pickerProps;
|
17344 | exports.popoverProps = popoverProps;
|
17345 | exports.popupProps = popupProps$2;
|
17346 | exports.progressProps = progressProps;
|
17347 | exports.pullRefreshProps = pullRefreshProps;
|
17348 | exports.radioGroupProps = radioGroupProps;
|
17349 | exports.radioProps = radioProps;
|
17350 | exports.rateProps = rateProps;
|
17351 | exports.resetDialogDefaultOptions = resetDialogDefaultOptions;
|
17352 | exports.resetNotifyDefaultOptions = resetNotifyDefaultOptions;
|
17353 | exports.resetToastDefaultOptions = resetToastDefaultOptions;
|
17354 | exports.rollingTextProps = rollingTextProps;
|
17355 | exports.rowProps = rowProps;
|
17356 | exports.searchProps = searchProps;
|
17357 | exports.setDialogDefaultOptions = setDialogDefaultOptions;
|
17358 | exports.setNotifyDefaultOptions = setNotifyDefaultOptions;
|
17359 | exports.setToastDefaultOptions = setToastDefaultOptions;
|
17360 | exports.shareSheetProps = shareSheetProps;
|
17361 | exports.showConfirmDialog = showConfirmDialog;
|
17362 | exports.showDialog = showDialog;
|
17363 | exports.showFailToast = showFailToast;
|
17364 | exports.showImagePreview = showImagePreview;
|
17365 | exports.showLoadingToast = showLoadingToast;
|
17366 | exports.showNotify = showNotify;
|
17367 | exports.showSuccessToast = showSuccessToast;
|
17368 | exports.showToast = showToast;
|
17369 | exports.sidebarItemProps = sidebarItemProps;
|
17370 | exports.sidebarProps = sidebarProps;
|
17371 | exports.skeletonAvatarProps = skeletonAvatarProps;
|
17372 | exports.skeletonImageProps = skeletonImageProps;
|
17373 | exports.skeletonParagraphProps = skeletonParagraphProps;
|
17374 | exports.skeletonProps = skeletonProps;
|
17375 | exports.skeletonTitleProps = skeletonTitleProps;
|
17376 | exports.sliderProps = sliderProps;
|
17377 | exports.spaceProps = spaceProps;
|
17378 | exports.stepperProps = stepperProps;
|
17379 | exports.stepsProps = stepsProps;
|
17380 | exports.stickyProps = stickyProps;
|
17381 | exports.submitBarProps = submitBarProps;
|
17382 | exports.swipeCellProps = swipeCellProps;
|
17383 | exports.swipeProps = swipeProps;
|
17384 | exports.switchProps = switchProps;
|
17385 | exports.tabProps = tabProps;
|
17386 | exports.tabbarItemProps = tabbarItemProps;
|
17387 | exports.tabbarProps = tabbarProps;
|
17388 | exports.tabsProps = tabsProps;
|
17389 | exports.tagProps = tagProps;
|
17390 | exports.textEllipsisProps = textEllipsisProps;
|
17391 | exports.timePickerProps = timePickerProps;
|
17392 | exports.toastProps = toastProps;
|
17393 | exports.treeSelectProps = treeSelectProps;
|
17394 | exports.uploaderProps = uploaderProps;
|
17395 | exports.useCurrentLang = useCurrentLang;
|
17396 | exports.version = version;
|
17397 | exports.watermarkProps = watermarkProps;
|