1 | import { unref, ref, reactive, inject, watch, onMounted, nextTick, createVNode, defineComponent, getCurrentInstance, computed, onActivated, onDeactivated, onBeforeUnmount, provide, watchEffect, mergeProps, Transition, withDirectives, vShow, Teleport, Fragment, onBeforeUpdate, Comment, createTextVNode, onUnmounted, createApp, resolveDirective, withKeys, onUpdated, Text, h } from "vue";
|
2 | import { useWindowSize, useRect, useChildren, useParent, onMountedOrActivated, getScrollParent, useEventListener, cancelRaf, raf, useScrollParent, usePageVisibility, doubleRaf, CUSTOM_FIELD_INJECTION_KEY, useCustomFieldValue, inBrowser as inBrowser$1, useToggle, useCountDown, useClickAway } from "@vant/use";
|
3 | import { normalizeClass, stringifyStyle, normalizeStyle } from "@vue/shared";
|
4 | import { offsetModifier, createPopper } from "@vant/popperjs";
|
5 | function noop() {
|
6 | }
|
7 | const extend = Object.assign;
|
8 | const inBrowser = typeof window !== "undefined";
|
9 | const isObject = (val) => val !== null && typeof val === "object";
|
10 | const isDef = (val) => val !== void 0 && val !== null;
|
11 | const isFunction = (val) => typeof val === "function";
|
12 | const isPromise = (val) => isObject(val) && isFunction(val.then) && isFunction(val.catch);
|
13 | const isDate = (val) => Object.prototype.toString.call(val) === "[object Date]" && !Number.isNaN(val.getTime());
|
14 | function isMobile(value) {
|
15 | value = value.replace(/[^-|\d]/g, "");
|
16 | return /^((\+86)|(86))?(1)\d{10}$/.test(value) || /^0[0-9-]{10,13}$/.test(value);
|
17 | }
|
18 | const isNumeric = (val) => typeof val === "number" || /^\d+(\.\d+)?$/.test(val);
|
19 | const isIOS$1 = () => inBrowser ? /ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase()) : false;
|
20 | function get(object, path) {
|
21 | const keys = path.split(".");
|
22 | let result = object;
|
23 | keys.forEach((key) => {
|
24 | var _a;
|
25 | result = isObject(result) ? (_a = result[key]) != null ? _a : "" : "";
|
26 | });
|
27 | return result;
|
28 | }
|
29 | function pick(obj, keys, ignoreUndefined) {
|
30 | return keys.reduce(
|
31 | (ret, key) => {
|
32 | if (!ignoreUndefined || obj[key] !== void 0) {
|
33 | ret[key] = obj[key];
|
34 | }
|
35 | return ret;
|
36 | },
|
37 | {}
|
38 | );
|
39 | }
|
40 | const isSameValue = (newValue, oldValue) => JSON.stringify(newValue) === JSON.stringify(oldValue);
|
41 | const toArray = (item) => Array.isArray(item) ? item : [item];
|
42 | const unknownProp = null;
|
43 | const numericProp = [Number, String];
|
44 | const truthProp = {
|
45 | type: Boolean,
|
46 | default: true
|
47 | };
|
48 | const makeRequiredProp = (type) => ({
|
49 | type,
|
50 | required: true
|
51 | });
|
52 | const makeArrayProp = () => ({
|
53 | type: Array,
|
54 | default: () => []
|
55 | });
|
56 | const makeNumberProp = (defaultVal) => ({
|
57 | type: Number,
|
58 | default: defaultVal
|
59 | });
|
60 | const makeNumericProp = (defaultVal) => ({
|
61 | type: numericProp,
|
62 | default: defaultVal
|
63 | });
|
64 | const makeStringProp = (defaultVal) => ({
|
65 | type: String,
|
66 | default: defaultVal
|
67 | });
|
68 | function getScrollTop(el) {
|
69 | const top = "scrollTop" in el ? el.scrollTop : el.pageYOffset;
|
70 | return Math.max(top, 0);
|
71 | }
|
72 | function setScrollTop(el, value) {
|
73 | if ("scrollTop" in el) {
|
74 | el.scrollTop = value;
|
75 | } else {
|
76 | el.scrollTo(el.scrollX, value);
|
77 | }
|
78 | }
|
79 | function getRootScrollTop() {
|
80 | return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
|
81 | }
|
82 | function setRootScrollTop(value) {
|
83 | setScrollTop(window, value);
|
84 | setScrollTop(document.body, value);
|
85 | }
|
86 | function getElementTop(el, scroller) {
|
87 | if (el === window) {
|
88 | return 0;
|
89 | }
|
90 | const scrollTop = scroller ? getScrollTop(scroller) : getRootScrollTop();
|
91 | return useRect(el).top + scrollTop;
|
92 | }
|
93 | const isIOS = isIOS$1();
|
94 | function resetScroll() {
|
95 | if (isIOS) {
|
96 | setRootScrollTop(getRootScrollTop());
|
97 | }
|
98 | }
|
99 | const stopPropagation = (event) => event.stopPropagation();
|
100 | function preventDefault(event, isStopPropagation) {
|
101 | if (typeof event.cancelable !== "boolean" || event.cancelable) {
|
102 | event.preventDefault();
|
103 | }
|
104 | if (isStopPropagation) {
|
105 | stopPropagation(event);
|
106 | }
|
107 | }
|
108 | function isHidden(elementRef) {
|
109 | const el = unref(elementRef);
|
110 | if (!el) {
|
111 | return false;
|
112 | }
|
113 | const style = window.getComputedStyle(el);
|
114 | const hidden = style.display === "none";
|
115 | const parentHidden = el.offsetParent === null && style.position !== "fixed";
|
116 | return hidden || parentHidden;
|
117 | }
|
118 | const { width: windowWidth, height: windowHeight } = useWindowSize();
|
119 | function isContainingBlock(el) {
|
120 | const css = window.getComputedStyle(el);
|
121 | return css.transform !== "none" || css.perspective !== "none" || ["transform", "perspective", "filter"].some(
|
122 | (value) => (css.willChange || "").includes(value)
|
123 | );
|
124 | }
|
125 | function getContainingBlock(el) {
|
126 | let node = el.parentElement;
|
127 | while (node) {
|
128 | if (node && node.tagName !== "HTML" && node.tagName !== "BODY" && isContainingBlock(node)) {
|
129 | return node;
|
130 | }
|
131 | node = node.parentElement;
|
132 | }
|
133 | return null;
|
134 | }
|
135 | function addUnit(value) {
|
136 | if (isDef(value)) {
|
137 | return isNumeric(value) ? `${value}px` : String(value);
|
138 | }
|
139 | return void 0;
|
140 | }
|
141 | function getSizeStyle(originSize) {
|
142 | if (isDef(originSize)) {
|
143 | if (Array.isArray(originSize)) {
|
144 | return {
|
145 | width: addUnit(originSize[0]),
|
146 | height: addUnit(originSize[1])
|
147 | };
|
148 | }
|
149 | const size = addUnit(originSize);
|
150 | return {
|
151 | width: size,
|
152 | height: size
|
153 | };
|
154 | }
|
155 | }
|
156 | function getZIndexStyle(zIndex) {
|
157 | const style = {};
|
158 | if (zIndex !== void 0) {
|
159 | style.zIndex = +zIndex;
|
160 | }
|
161 | return style;
|
162 | }
|
163 | let rootFontSize;
|
164 | function getRootFontSize() {
|
165 | if (!rootFontSize) {
|
166 | const doc = document.documentElement;
|
167 | const fontSize = doc.style.fontSize || window.getComputedStyle(doc).fontSize;
|
168 | rootFontSize = parseFloat(fontSize);
|
169 | }
|
170 | return rootFontSize;
|
171 | }
|
172 | function convertRem(value) {
|
173 | value = value.replace(/rem/g, "");
|
174 | return +value * getRootFontSize();
|
175 | }
|
176 | function convertVw(value) {
|
177 | value = value.replace(/vw/g, "");
|
178 | return +value * windowWidth.value / 100;
|
179 | }
|
180 | function convertVh(value) {
|
181 | value = value.replace(/vh/g, "");
|
182 | return +value * windowHeight.value / 100;
|
183 | }
|
184 | function unitToPx(value) {
|
185 | if (typeof value === "number") {
|
186 | return value;
|
187 | }
|
188 | if (inBrowser) {
|
189 | if (value.includes("rem")) {
|
190 | return convertRem(value);
|
191 | }
|
192 | if (value.includes("vw")) {
|
193 | return convertVw(value);
|
194 | }
|
195 | if (value.includes("vh")) {
|
196 | return convertVh(value);
|
197 | }
|
198 | }
|
199 | return parseFloat(value);
|
200 | }
|
201 | const camelizeRE = /-(\w)/g;
|
202 | const camelize = (str) => str.replace(camelizeRE, (_, c) => c.toUpperCase());
|
203 | const kebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase().replace(/^-/, "");
|
204 | function padZero(num, targetLength = 2) {
|
205 | let str = num + "";
|
206 | while (str.length < targetLength) {
|
207 | str = "0" + str;
|
208 | }
|
209 | return str;
|
210 | }
|
211 | const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
|
212 | function trimExtraChar(value, char, regExp) {
|
213 | const index = value.indexOf(char);
|
214 | if (index === -1) {
|
215 | return value;
|
216 | }
|
217 | if (char === "-" && index !== 0) {
|
218 | return value.slice(0, index);
|
219 | }
|
220 | return value.slice(0, index + 1) + value.slice(index).replace(regExp, "");
|
221 | }
|
222 | function formatNumber(value, allowDot = true, allowMinus = true) {
|
223 | if (allowDot) {
|
224 | value = trimExtraChar(value, ".", /\./g);
|
225 | } else {
|
226 | value = value.split(".")[0];
|
227 | }
|
228 | if (allowMinus) {
|
229 | value = trimExtraChar(value, "-", /-/g);
|
230 | } else {
|
231 | value = value.replace(/-/, "");
|
232 | }
|
233 | const regExp = allowDot ? /[^-0-9.]/g : /[^-0-9]/g;
|
234 | return value.replace(regExp, "");
|
235 | }
|
236 | function addNumber(num1, num2) {
|
237 | const cardinal = 10 ** 10;
|
238 | return Math.round((num1 + num2) * cardinal) / cardinal;
|
239 | }
|
240 | const { hasOwnProperty } = Object.prototype;
|
241 | function assignKey(to, from, key) {
|
242 | const val = from[key];
|
243 | if (!isDef(val)) {
|
244 | return;
|
245 | }
|
246 | if (!hasOwnProperty.call(to, key) || !isObject(val)) {
|
247 | to[key] = val;
|
248 | } else {
|
249 | to[key] = deepAssign(Object(to[key]), val);
|
250 | }
|
251 | }
|
252 | function deepAssign(to, from) {
|
253 | Object.keys(from).forEach((key) => {
|
254 | assignKey(to, from, key);
|
255 | });
|
256 | return to;
|
257 | }
|
258 | var stdin_default$1W = {
|
259 | name: "姓名",
|
260 | tel: "电话",
|
261 | save: "保存",
|
262 | clear: "清空",
|
263 | cancel: "取消",
|
264 | confirm: "确认",
|
265 | delete: "删除",
|
266 | loading: "加载中...",
|
267 | noCoupon: "暂无优惠券",
|
268 | nameEmpty: "请填写姓名",
|
269 | addContact: "添加联系人",
|
270 | telInvalid: "请填写正确的电话",
|
271 | vanCalendar: {
|
272 | end: "结束",
|
273 | start: "开始",
|
274 | title: "日期选择",
|
275 | weekdays: ["日", "一", "二", "三", "四", "五", "六"],
|
276 | monthTitle: (year, month) => `${year}年${month}月`,
|
277 | rangePrompt: (maxRange) => `最多选择 ${maxRange} 天`
|
278 | },
|
279 | vanCascader: {
|
280 | select: "请选择"
|
281 | },
|
282 | vanPagination: {
|
283 | prev: "上一页",
|
284 | next: "下一页"
|
285 | },
|
286 | vanPullRefresh: {
|
287 | pulling: "下拉即可刷新...",
|
288 | loosing: "释放即可刷新..."
|
289 | },
|
290 | vanSubmitBar: {
|
291 | label: "合计:"
|
292 | },
|
293 | vanCoupon: {
|
294 | unlimited: "无门槛",
|
295 | discount: (discount) => `${discount}折`,
|
296 | condition: (condition) => `满${condition}元可用`
|
297 | },
|
298 | vanCouponCell: {
|
299 | title: "优惠券",
|
300 | count: (count) => `${count}张可用`
|
301 | },
|
302 | vanCouponList: {
|
303 | exchange: "兑换",
|
304 | close: "不使用",
|
305 | enable: "可用",
|
306 | disabled: "不可用",
|
307 | placeholder: "输入优惠码"
|
308 | },
|
309 | vanAddressEdit: {
|
310 | area: "地区",
|
311 | areaEmpty: "请选择地区",
|
312 | addressEmpty: "请填写详细地址",
|
313 | addressDetail: "详细地址",
|
314 | defaultAddress: "设为默认收货地址"
|
315 | },
|
316 | vanAddressList: {
|
317 | add: "新增地址"
|
318 | }
|
319 | };
|
320 | const lang = ref("zh-CN");
|
321 | const messages = reactive({
|
322 | "zh-CN": stdin_default$1W
|
323 | });
|
324 | const Locale = {
|
325 | messages() {
|
326 | return messages[lang.value];
|
327 | },
|
328 | use(newLang, newMessages) {
|
329 | lang.value = newLang;
|
330 | this.add({ [newLang]: newMessages });
|
331 | },
|
332 | add(newMessages = {}) {
|
333 | deepAssign(messages, newMessages);
|
334 | }
|
335 | };
|
336 | const useCurrentLang = () => lang;
|
337 | var stdin_default$1V = Locale;
|
338 | function createTranslate(name2) {
|
339 | const prefix = camelize(name2) + ".";
|
340 | return (path, ...args) => {
|
341 | const messages2 = stdin_default$1V.messages();
|
342 | const message = get(messages2, prefix + path) || get(messages2, path);
|
343 | return isFunction(message) ? message(...args) : message;
|
344 | };
|
345 | }
|
346 | function genBem(name2, mods) {
|
347 | if (!mods) {
|
348 | return "";
|
349 | }
|
350 | if (typeof mods === "string") {
|
351 | return ` ${name2}--${mods}`;
|
352 | }
|
353 | if (Array.isArray(mods)) {
|
354 | return mods.reduce(
|
355 | (ret, item) => ret + genBem(name2, item),
|
356 | ""
|
357 | );
|
358 | }
|
359 | return Object.keys(mods).reduce(
|
360 | (ret, key) => ret + (mods[key] ? genBem(name2, key) : ""),
|
361 | ""
|
362 | );
|
363 | }
|
364 | function createBEM(name2) {
|
365 | return (el, mods) => {
|
366 | if (el && typeof el !== "string") {
|
367 | mods = el;
|
368 | el = "";
|
369 | }
|
370 | el = el ? `${name2}__${el}` : name2;
|
371 | return `${el}${genBem(el, mods)}`;
|
372 | };
|
373 | }
|
374 | function createNamespace(name2) {
|
375 | const prefixedName = `van-${name2}`;
|
376 | return [
|
377 | prefixedName,
|
378 | createBEM(prefixedName),
|
379 | createTranslate(prefixedName)
|
380 | ];
|
381 | }
|
382 | const BORDER = "van-hairline";
|
383 | const BORDER_TOP = `${BORDER}--top`;
|
384 | const BORDER_LEFT = `${BORDER}--left`;
|
385 | const BORDER_RIGHT = `${BORDER}--right`;
|
386 | const BORDER_BOTTOM = `${BORDER}--bottom`;
|
387 | const BORDER_SURROUND = `${BORDER}--surround`;
|
388 | const BORDER_TOP_BOTTOM = `${BORDER}--top-bottom`;
|
389 | const BORDER_UNSET_TOP_BOTTOM = `${BORDER}-unset--top-bottom`;
|
390 | const HAPTICS_FEEDBACK = "van-haptics-feedback";
|
391 | const FORM_KEY = Symbol("van-form");
|
392 | const LONG_PRESS_START_TIME = 500;
|
393 | const TAP_OFFSET = 5;
|
394 | function callInterceptor(interceptor, {
|
395 | args = [],
|
396 | done,
|
397 | canceled,
|
398 | error
|
399 | }) {
|
400 | if (interceptor) {
|
401 | const returnVal = interceptor.apply(null, args);
|
402 | if (isPromise(returnVal)) {
|
403 | returnVal.then((value) => {
|
404 | if (value) {
|
405 | done();
|
406 | } else if (canceled) {
|
407 | canceled();
|
408 | }
|
409 | }).catch(error || noop);
|
410 | } else if (returnVal) {
|
411 | done();
|
412 | } else if (canceled) {
|
413 | canceled();
|
414 | }
|
415 | } else {
|
416 | done();
|
417 | }
|
418 | }
|
419 | function withInstall(options) {
|
420 | options.install = (app) => {
|
421 | const { name: name2 } = options;
|
422 | if (name2) {
|
423 | app.component(name2, options);
|
424 | app.component(camelize(`-${name2}`), options);
|
425 | }
|
426 | };
|
427 | return options;
|
428 | }
|
429 | function closest(arr, target) {
|
430 | return arr.reduce(
|
431 | (pre, cur) => Math.abs(pre - target) < Math.abs(cur - target) ? pre : cur
|
432 | );
|
433 | }
|
434 | const POPUP_TOGGLE_KEY = Symbol();
|
435 | function onPopupReopen(callback) {
|
436 | const popupToggleStatus = inject(POPUP_TOGGLE_KEY, null);
|
437 | if (popupToggleStatus) {
|
438 | watch(popupToggleStatus, (show) => {
|
439 | if (show) {
|
440 | callback();
|
441 | }
|
442 | });
|
443 | }
|
444 | }
|
445 | const useHeight = (element, withSafeArea) => {
|
446 | const height = ref();
|
447 | const setHeight = () => {
|
448 | height.value = useRect(element).height;
|
449 | };
|
450 | onMounted(() => {
|
451 | nextTick(setHeight);
|
452 | if (withSafeArea) {
|
453 | for (let i = 1; i <= 3; i++) {
|
454 | setTimeout(setHeight, 100 * i);
|
455 | }
|
456 | }
|
457 | });
|
458 | onPopupReopen(() => nextTick(setHeight));
|
459 | watch([windowWidth, windowHeight], setHeight);
|
460 | return height;
|
461 | };
|
462 | function usePlaceholder(contentRef, bem2) {
|
463 | const height = useHeight(contentRef, true);
|
464 | return (renderContent) => createVNode("div", {
|
465 | "class": bem2("placeholder"),
|
466 | "style": {
|
467 | height: height.value ? `${height.value}px` : void 0
|
468 | }
|
469 | }, [renderContent()]);
|
470 | }
|
471 | const [name$1K, bem$1F] = createNamespace("action-bar");
|
472 | const ACTION_BAR_KEY = Symbol(name$1K);
|
473 | const actionBarProps = {
|
474 | placeholder: Boolean,
|
475 | safeAreaInsetBottom: truthProp
|
476 | };
|
477 | var stdin_default$1U = defineComponent({
|
478 | name: name$1K,
|
479 | props: actionBarProps,
|
480 | setup(props2, {
|
481 | slots
|
482 | }) {
|
483 | const root = ref();
|
484 | const renderPlaceholder = usePlaceholder(root, bem$1F);
|
485 | const {
|
486 | linkChildren
|
487 | } = useChildren(ACTION_BAR_KEY);
|
488 | linkChildren();
|
489 | const renderActionBar = () => {
|
490 | var _a;
|
491 | return createVNode("div", {
|
492 | "ref": root,
|
493 | "class": [bem$1F(), {
|
494 | "van-safe-area-bottom": props2.safeAreaInsetBottom
|
495 | }]
|
496 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
497 | };
|
498 | return () => {
|
499 | if (props2.placeholder) {
|
500 | return renderPlaceholder(renderActionBar);
|
501 | }
|
502 | return renderActionBar();
|
503 | };
|
504 | }
|
505 | });
|
506 | const ActionBar = withInstall(stdin_default$1U);
|
507 | function useExpose(apis) {
|
508 | const instance2 = getCurrentInstance();
|
509 | if (instance2) {
|
510 | extend(instance2.proxy, apis);
|
511 | }
|
512 | }
|
513 | const routeProps = {
|
514 | to: [String, Object],
|
515 | url: String,
|
516 | replace: Boolean
|
517 | };
|
518 | function route({
|
519 | to,
|
520 | url,
|
521 | replace,
|
522 | $router: router
|
523 | }) {
|
524 | if (to && router) {
|
525 | router[replace ? "replace" : "push"](to);
|
526 | } else if (url) {
|
527 | replace ? location.replace(url) : location.href = url;
|
528 | }
|
529 | }
|
530 | function useRoute() {
|
531 | const vm = getCurrentInstance().proxy;
|
532 | return () => route(vm);
|
533 | }
|
534 | const [name$1J, bem$1E] = createNamespace("badge");
|
535 | const badgeProps = {
|
536 | dot: Boolean,
|
537 | max: numericProp,
|
538 | tag: makeStringProp("div"),
|
539 | color: String,
|
540 | offset: Array,
|
541 | content: numericProp,
|
542 | showZero: truthProp,
|
543 | position: makeStringProp("top-right")
|
544 | };
|
545 | var stdin_default$1T = defineComponent({
|
546 | name: name$1J,
|
547 | props: badgeProps,
|
548 | setup(props2, {
|
549 | slots
|
550 | }) {
|
551 | const hasContent = () => {
|
552 | if (slots.content) {
|
553 | return true;
|
554 | }
|
555 | const {
|
556 | content,
|
557 | showZero
|
558 | } = props2;
|
559 | return isDef(content) && content !== "" && (showZero || content !== 0 && content !== "0");
|
560 | };
|
561 | const renderContent = () => {
|
562 | const {
|
563 | dot,
|
564 | max,
|
565 | content
|
566 | } = props2;
|
567 | if (!dot && hasContent()) {
|
568 | if (slots.content) {
|
569 | return slots.content();
|
570 | }
|
571 | if (isDef(max) && isNumeric(content) && +content > +max) {
|
572 | return `${max}+`;
|
573 | }
|
574 | return content;
|
575 | }
|
576 | };
|
577 | const getOffsetWithMinusString = (val) => val.startsWith("-") ? val.replace("-", "") : `-${val}`;
|
578 | const style = computed(() => {
|
579 | const style2 = {
|
580 | background: props2.color
|
581 | };
|
582 | if (props2.offset) {
|
583 | const [x, y] = props2.offset;
|
584 | const {
|
585 | position
|
586 | } = props2;
|
587 | const [offsetY, offsetX] = position.split("-");
|
588 | if (slots.default) {
|
589 | if (typeof y === "number") {
|
590 | style2[offsetY] = addUnit(offsetY === "top" ? y : -y);
|
591 | } else {
|
592 | style2[offsetY] = offsetY === "top" ? addUnit(y) : getOffsetWithMinusString(y);
|
593 | }
|
594 | if (typeof x === "number") {
|
595 | style2[offsetX] = addUnit(offsetX === "left" ? x : -x);
|
596 | } else {
|
597 | style2[offsetX] = offsetX === "left" ? addUnit(x) : getOffsetWithMinusString(x);
|
598 | }
|
599 | } else {
|
600 | style2.marginTop = addUnit(y);
|
601 | style2.marginLeft = addUnit(x);
|
602 | }
|
603 | }
|
604 | return style2;
|
605 | });
|
606 | const renderBadge = () => {
|
607 | if (hasContent() || props2.dot) {
|
608 | return createVNode("div", {
|
609 | "class": bem$1E([props2.position, {
|
610 | dot: props2.dot,
|
611 | fixed: !!slots.default
|
612 | }]),
|
613 | "style": style.value
|
614 | }, [renderContent()]);
|
615 | }
|
616 | };
|
617 | return () => {
|
618 | if (slots.default) {
|
619 | const {
|
620 | tag
|
621 | } = props2;
|
622 | return createVNode(tag, {
|
623 | "class": bem$1E("wrapper")
|
624 | }, {
|
625 | default: () => [slots.default(), renderBadge()]
|
626 | });
|
627 | }
|
628 | return renderBadge();
|
629 | };
|
630 | }
|
631 | });
|
632 | const Badge = withInstall(stdin_default$1T);
|
633 | let globalZIndex = 2e3;
|
634 | const useGlobalZIndex = () => ++globalZIndex;
|
635 | const setGlobalZIndex = (val) => {
|
636 | globalZIndex = val;
|
637 | };
|
638 | const [name$1I, bem$1D] = createNamespace("config-provider");
|
639 | const CONFIG_PROVIDER_KEY = Symbol(name$1I);
|
640 | const configProviderProps = {
|
641 | tag: makeStringProp("div"),
|
642 | theme: makeStringProp("light"),
|
643 | zIndex: Number,
|
644 | themeVars: Object,
|
645 | themeVarsDark: Object,
|
646 | themeVarsLight: Object,
|
647 | themeVarsScope: makeStringProp("local"),
|
648 | iconPrefix: String
|
649 | };
|
650 | function insertDash(str) {
|
651 | return str.replace(/([a-zA-Z])(\d)/g, "$1-$2");
|
652 | }
|
653 | function mapThemeVarsToCSSVars(themeVars) {
|
654 | const cssVars = {};
|
655 | Object.keys(themeVars).forEach((key) => {
|
656 | const formattedKey = insertDash(kebabCase(key));
|
657 | cssVars[`--van-${formattedKey}`] = themeVars[key];
|
658 | });
|
659 | return cssVars;
|
660 | }
|
661 | function syncThemeVarsOnRoot(newStyle = {}, oldStyle = {}) {
|
662 | Object.keys(newStyle).forEach((key) => {
|
663 | if (newStyle[key] !== oldStyle[key]) {
|
664 | document.documentElement.style.setProperty(key, newStyle[key]);
|
665 | }
|
666 | });
|
667 | Object.keys(oldStyle).forEach((key) => {
|
668 | if (!newStyle[key]) {
|
669 | document.documentElement.style.removeProperty(key);
|
670 | }
|
671 | });
|
672 | }
|
673 | var stdin_default$1S = defineComponent({
|
674 | name: name$1I,
|
675 | props: configProviderProps,
|
676 | setup(props2, {
|
677 | slots
|
678 | }) {
|
679 | const style = computed(() => mapThemeVarsToCSSVars(extend({}, props2.themeVars, props2.theme === "dark" ? props2.themeVarsDark : props2.themeVarsLight)));
|
680 | if (inBrowser) {
|
681 | const addTheme = () => {
|
682 | document.documentElement.classList.add(`van-theme-${props2.theme}`);
|
683 | };
|
684 | const removeTheme = (theme = props2.theme) => {
|
685 | document.documentElement.classList.remove(`van-theme-${theme}`);
|
686 | };
|
687 | watch(() => props2.theme, (newVal, oldVal) => {
|
688 | if (oldVal) {
|
689 | removeTheme(oldVal);
|
690 | }
|
691 | addTheme();
|
692 | }, {
|
693 | immediate: true
|
694 | });
|
695 | onActivated(addTheme);
|
696 | onDeactivated(removeTheme);
|
697 | onBeforeUnmount(removeTheme);
|
698 | watch(style, (newStyle, oldStyle) => {
|
699 | if (props2.themeVarsScope === "global") {
|
700 | syncThemeVarsOnRoot(newStyle, oldStyle);
|
701 | }
|
702 | });
|
703 | watch(() => props2.themeVarsScope, (newScope, oldScope) => {
|
704 | if (oldScope === "global") {
|
705 | syncThemeVarsOnRoot({}, style.value);
|
706 | }
|
707 | if (newScope === "global") {
|
708 | syncThemeVarsOnRoot(style.value, {});
|
709 | }
|
710 | });
|
711 | if (props2.themeVarsScope === "global") {
|
712 | syncThemeVarsOnRoot(style.value, {});
|
713 | }
|
714 | }
|
715 | provide(CONFIG_PROVIDER_KEY, props2);
|
716 | watchEffect(() => {
|
717 | if (props2.zIndex !== void 0) {
|
718 | setGlobalZIndex(props2.zIndex);
|
719 | }
|
720 | });
|
721 | return () => createVNode(props2.tag, {
|
722 | "class": bem$1D(),
|
723 | "style": props2.themeVarsScope === "local" ? style.value : void 0
|
724 | }, {
|
725 | default: () => {
|
726 | var _a;
|
727 | return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
|
728 | }
|
729 | });
|
730 | }
|
731 | });
|
732 | const [name$1H, bem$1C] = createNamespace("icon");
|
733 | const isImage$1 = (name2) => name2 == null ? void 0 : name2.includes("/");
|
734 | const iconProps = {
|
735 | dot: Boolean,
|
736 | tag: makeStringProp("i"),
|
737 | name: String,
|
738 | size: numericProp,
|
739 | badge: numericProp,
|
740 | color: String,
|
741 | badgeProps: Object,
|
742 | classPrefix: String
|
743 | };
|
744 | var stdin_default$1R = defineComponent({
|
745 | name: name$1H,
|
746 | props: iconProps,
|
747 | setup(props2, {
|
748 | slots
|
749 | }) {
|
750 | const config = inject(CONFIG_PROVIDER_KEY, null);
|
751 | const classPrefix = computed(() => props2.classPrefix || (config == null ? void 0 : config.iconPrefix) || bem$1C());
|
752 | return () => {
|
753 | const {
|
754 | tag,
|
755 | dot,
|
756 | name: name2,
|
757 | size,
|
758 | badge,
|
759 | color
|
760 | } = props2;
|
761 | const isImageIcon = isImage$1(name2);
|
762 | return createVNode(Badge, mergeProps({
|
763 | "dot": dot,
|
764 | "tag": tag,
|
765 | "class": [classPrefix.value, isImageIcon ? "" : `${classPrefix.value}-${name2}`],
|
766 | "style": {
|
767 | color,
|
768 | fontSize: addUnit(size)
|
769 | },
|
770 | "content": badge
|
771 | }, props2.badgeProps), {
|
772 | default: () => {
|
773 | var _a;
|
774 | return [(_a = slots.default) == null ? void 0 : _a.call(slots), isImageIcon && createVNode("img", {
|
775 | "class": bem$1C("image"),
|
776 | "src": name2
|
777 | }, null)];
|
778 | }
|
779 | });
|
780 | };
|
781 | }
|
782 | });
|
783 | const Icon = withInstall(stdin_default$1R);
|
784 | var stdin_default$1Q = Icon;
|
785 | const [name$1G, bem$1B] = createNamespace("loading");
|
786 | const SpinIcon = Array(12).fill(null).map((_, index) => createVNode("i", {
|
787 | "class": bem$1B("line", String(index + 1))
|
788 | }, null));
|
789 | const CircularIcon = createVNode("svg", {
|
790 | "class": bem$1B("circular"),
|
791 | "viewBox": "25 25 50 50"
|
792 | }, [createVNode("circle", {
|
793 | "cx": "50",
|
794 | "cy": "50",
|
795 | "r": "20",
|
796 | "fill": "none"
|
797 | }, null)]);
|
798 | const loadingProps = {
|
799 | size: numericProp,
|
800 | type: makeStringProp("circular"),
|
801 | color: String,
|
802 | vertical: Boolean,
|
803 | textSize: numericProp,
|
804 | textColor: String
|
805 | };
|
806 | var stdin_default$1P = defineComponent({
|
807 | name: name$1G,
|
808 | props: loadingProps,
|
809 | setup(props2, {
|
810 | slots
|
811 | }) {
|
812 | const spinnerStyle = computed(() => extend({
|
813 | color: props2.color
|
814 | }, getSizeStyle(props2.size)));
|
815 | const renderIcon = () => {
|
816 | const DefaultIcon = props2.type === "spinner" ? SpinIcon : CircularIcon;
|
817 | return createVNode("span", {
|
818 | "class": bem$1B("spinner", props2.type),
|
819 | "style": spinnerStyle.value
|
820 | }, [slots.icon ? slots.icon() : DefaultIcon]);
|
821 | };
|
822 | const renderText = () => {
|
823 | var _a;
|
824 | if (slots.default) {
|
825 | return createVNode("span", {
|
826 | "class": bem$1B("text"),
|
827 | "style": {
|
828 | fontSize: addUnit(props2.textSize),
|
829 | color: (_a = props2.textColor) != null ? _a : props2.color
|
830 | }
|
831 | }, [slots.default()]);
|
832 | }
|
833 | };
|
834 | return () => {
|
835 | const {
|
836 | type,
|
837 | vertical
|
838 | } = props2;
|
839 | return createVNode("div", {
|
840 | "class": bem$1B([type, {
|
841 | vertical
|
842 | }]),
|
843 | "aria-live": "polite",
|
844 | "aria-busy": true
|
845 | }, [renderIcon(), renderText()]);
|
846 | };
|
847 | }
|
848 | });
|
849 | const Loading = withInstall(stdin_default$1P);
|
850 | const [name$1F, bem$1A] = createNamespace("button");
|
851 | const buttonProps = extend({}, routeProps, {
|
852 | tag: makeStringProp("button"),
|
853 | text: String,
|
854 | icon: String,
|
855 | type: makeStringProp("default"),
|
856 | size: makeStringProp("normal"),
|
857 | color: String,
|
858 | block: Boolean,
|
859 | plain: Boolean,
|
860 | round: Boolean,
|
861 | square: Boolean,
|
862 | loading: Boolean,
|
863 | hairline: Boolean,
|
864 | disabled: Boolean,
|
865 | iconPrefix: String,
|
866 | nativeType: makeStringProp("button"),
|
867 | loadingSize: numericProp,
|
868 | loadingText: String,
|
869 | loadingType: String,
|
870 | iconPosition: makeStringProp("left")
|
871 | });
|
872 | var stdin_default$1O = defineComponent({
|
873 | name: name$1F,
|
874 | props: buttonProps,
|
875 | emits: ["click"],
|
876 | setup(props2, {
|
877 | emit,
|
878 | slots
|
879 | }) {
|
880 | const route2 = useRoute();
|
881 | const renderLoadingIcon = () => {
|
882 | if (slots.loading) {
|
883 | return slots.loading();
|
884 | }
|
885 | return createVNode(Loading, {
|
886 | "size": props2.loadingSize,
|
887 | "type": props2.loadingType,
|
888 | "class": bem$1A("loading")
|
889 | }, null);
|
890 | };
|
891 | const renderIcon = () => {
|
892 | if (props2.loading) {
|
893 | return renderLoadingIcon();
|
894 | }
|
895 | if (slots.icon) {
|
896 | return createVNode("div", {
|
897 | "class": bem$1A("icon")
|
898 | }, [slots.icon()]);
|
899 | }
|
900 | if (props2.icon) {
|
901 | return createVNode(Icon, {
|
902 | "name": props2.icon,
|
903 | "class": bem$1A("icon"),
|
904 | "classPrefix": props2.iconPrefix
|
905 | }, null);
|
906 | }
|
907 | };
|
908 | const renderText = () => {
|
909 | let text;
|
910 | if (props2.loading) {
|
911 | text = props2.loadingText;
|
912 | } else {
|
913 | text = slots.default ? slots.default() : props2.text;
|
914 | }
|
915 | if (text) {
|
916 | return createVNode("span", {
|
917 | "class": bem$1A("text")
|
918 | }, [text]);
|
919 | }
|
920 | };
|
921 | const getStyle = () => {
|
922 | const {
|
923 | color,
|
924 | plain
|
925 | } = props2;
|
926 | if (color) {
|
927 | const style = {
|
928 | color: plain ? color : "white"
|
929 | };
|
930 | if (!plain) {
|
931 | style.background = color;
|
932 | }
|
933 | if (color.includes("gradient")) {
|
934 | style.border = 0;
|
935 | } else {
|
936 | style.borderColor = color;
|
937 | }
|
938 | return style;
|
939 | }
|
940 | };
|
941 | const onClick = (event) => {
|
942 | if (props2.loading) {
|
943 | preventDefault(event);
|
944 | } else if (!props2.disabled) {
|
945 | emit("click", event);
|
946 | route2();
|
947 | }
|
948 | };
|
949 | return () => {
|
950 | const {
|
951 | tag,
|
952 | type,
|
953 | size,
|
954 | block,
|
955 | round,
|
956 | plain,
|
957 | square,
|
958 | loading,
|
959 | disabled,
|
960 | hairline,
|
961 | nativeType,
|
962 | iconPosition
|
963 | } = props2;
|
964 | const classes = [bem$1A([type, size, {
|
965 | plain,
|
966 | block,
|
967 | round,
|
968 | square,
|
969 | loading,
|
970 | disabled,
|
971 | hairline
|
972 | }]), {
|
973 | [BORDER_SURROUND]: hairline
|
974 | }];
|
975 | return createVNode(tag, {
|
976 | "type": nativeType,
|
977 | "class": classes,
|
978 | "style": getStyle(),
|
979 | "disabled": disabled,
|
980 | "onClick": onClick
|
981 | }, {
|
982 | default: () => [createVNode("div", {
|
983 | "class": bem$1A("content")
|
984 | }, [iconPosition === "left" && renderIcon(), renderText(), iconPosition === "right" && renderIcon()])]
|
985 | });
|
986 | };
|
987 | }
|
988 | });
|
989 | const Button = withInstall(stdin_default$1O);
|
990 | const [name$1E, bem$1z] = createNamespace("action-bar-button");
|
991 | const actionBarButtonProps = extend({}, routeProps, {
|
992 | type: String,
|
993 | text: String,
|
994 | icon: String,
|
995 | color: String,
|
996 | loading: Boolean,
|
997 | disabled: Boolean
|
998 | });
|
999 | var stdin_default$1N = defineComponent({
|
1000 | name: name$1E,
|
1001 | props: actionBarButtonProps,
|
1002 | setup(props2, {
|
1003 | slots
|
1004 | }) {
|
1005 | const route2 = useRoute();
|
1006 | const {
|
1007 | parent,
|
1008 | index
|
1009 | } = useParent(ACTION_BAR_KEY);
|
1010 | const isFirst = computed(() => {
|
1011 | if (parent) {
|
1012 | const prev = parent.children[index.value - 1];
|
1013 | return !(prev && "isButton" in prev);
|
1014 | }
|
1015 | });
|
1016 | const isLast = computed(() => {
|
1017 | if (parent) {
|
1018 | const next = parent.children[index.value + 1];
|
1019 | return !(next && "isButton" in next);
|
1020 | }
|
1021 | });
|
1022 | useExpose({
|
1023 | isButton: true
|
1024 | });
|
1025 | return () => {
|
1026 | const {
|
1027 | type,
|
1028 | icon,
|
1029 | text,
|
1030 | color,
|
1031 | loading,
|
1032 | disabled
|
1033 | } = props2;
|
1034 | return createVNode(Button, {
|
1035 | "class": bem$1z([type, {
|
1036 | last: isLast.value,
|
1037 | first: isFirst.value
|
1038 | }]),
|
1039 | "size": "large",
|
1040 | "type": type,
|
1041 | "icon": icon,
|
1042 | "color": color,
|
1043 | "loading": loading,
|
1044 | "disabled": disabled,
|
1045 | "onClick": route2
|
1046 | }, {
|
1047 | default: () => [slots.default ? slots.default() : text]
|
1048 | });
|
1049 | };
|
1050 | }
|
1051 | });
|
1052 | const ActionBarButton = withInstall(stdin_default$1N);
|
1053 | const [name$1D, bem$1y] = createNamespace("action-bar-icon");
|
1054 | const actionBarIconProps = extend({}, routeProps, {
|
1055 | dot: Boolean,
|
1056 | text: String,
|
1057 | icon: String,
|
1058 | color: String,
|
1059 | badge: numericProp,
|
1060 | iconClass: unknownProp,
|
1061 | badgeProps: Object,
|
1062 | iconPrefix: String
|
1063 | });
|
1064 | var stdin_default$1M = defineComponent({
|
1065 | name: name$1D,
|
1066 | props: actionBarIconProps,
|
1067 | setup(props2, {
|
1068 | slots
|
1069 | }) {
|
1070 | const route2 = useRoute();
|
1071 | useParent(ACTION_BAR_KEY);
|
1072 | const renderIcon = () => {
|
1073 | const {
|
1074 | dot,
|
1075 | badge,
|
1076 | icon,
|
1077 | color,
|
1078 | iconClass,
|
1079 | badgeProps: badgeProps2,
|
1080 | iconPrefix
|
1081 | } = props2;
|
1082 | if (slots.icon) {
|
1083 | return createVNode(Badge, mergeProps({
|
1084 | "dot": dot,
|
1085 | "class": bem$1y("icon"),
|
1086 | "content": badge
|
1087 | }, badgeProps2), {
|
1088 | default: slots.icon
|
1089 | });
|
1090 | }
|
1091 | return createVNode(Icon, {
|
1092 | "tag": "div",
|
1093 | "dot": dot,
|
1094 | "name": icon,
|
1095 | "badge": badge,
|
1096 | "color": color,
|
1097 | "class": [bem$1y("icon"), iconClass],
|
1098 | "badgeProps": badgeProps2,
|
1099 | "classPrefix": iconPrefix
|
1100 | }, null);
|
1101 | };
|
1102 | return () => createVNode("div", {
|
1103 | "role": "button",
|
1104 | "class": bem$1y(),
|
1105 | "tabindex": 0,
|
1106 | "onClick": route2
|
1107 | }, [renderIcon(), slots.default ? slots.default() : props2.text]);
|
1108 | }
|
1109 | });
|
1110 | const ActionBarIcon = withInstall(stdin_default$1M);
|
1111 | const popupSharedProps = {
|
1112 |
|
1113 | show: Boolean,
|
1114 |
|
1115 | zIndex: numericProp,
|
1116 |
|
1117 | overlay: truthProp,
|
1118 |
|
1119 | duration: numericProp,
|
1120 |
|
1121 | teleport: [String, Object],
|
1122 |
|
1123 | lockScroll: truthProp,
|
1124 |
|
1125 | lazyRender: truthProp,
|
1126 |
|
1127 | beforeClose: Function,
|
1128 |
|
1129 | overlayStyle: Object,
|
1130 |
|
1131 | overlayClass: unknownProp,
|
1132 |
|
1133 | transitionAppear: Boolean,
|
1134 |
|
1135 | closeOnClickOverlay: truthProp
|
1136 | };
|
1137 | const popupSharedPropKeys = Object.keys(
|
1138 | popupSharedProps
|
1139 | );
|
1140 | function getDirection(x, y) {
|
1141 | if (x > y) {
|
1142 | return "horizontal";
|
1143 | }
|
1144 | if (y > x) {
|
1145 | return "vertical";
|
1146 | }
|
1147 | return "";
|
1148 | }
|
1149 | function useTouch() {
|
1150 | const startX = ref(0);
|
1151 | const startY = ref(0);
|
1152 | const deltaX = ref(0);
|
1153 | const deltaY = ref(0);
|
1154 | const offsetX = ref(0);
|
1155 | const offsetY = ref(0);
|
1156 | const direction = ref("");
|
1157 | const isTap = ref(true);
|
1158 | const isVertical = () => direction.value === "vertical";
|
1159 | const isHorizontal = () => direction.value === "horizontal";
|
1160 | const reset = () => {
|
1161 | deltaX.value = 0;
|
1162 | deltaY.value = 0;
|
1163 | offsetX.value = 0;
|
1164 | offsetY.value = 0;
|
1165 | direction.value = "";
|
1166 | isTap.value = true;
|
1167 | };
|
1168 | const start = (event) => {
|
1169 | reset();
|
1170 | startX.value = event.touches[0].clientX;
|
1171 | startY.value = event.touches[0].clientY;
|
1172 | };
|
1173 | const move = (event) => {
|
1174 | const touch = event.touches[0];
|
1175 | deltaX.value = (touch.clientX < 0 ? 0 : touch.clientX) - startX.value;
|
1176 | deltaY.value = touch.clientY - startY.value;
|
1177 | offsetX.value = Math.abs(deltaX.value);
|
1178 | offsetY.value = Math.abs(deltaY.value);
|
1179 | const LOCK_DIRECTION_DISTANCE = 10;
|
1180 | if (!direction.value || offsetX.value < LOCK_DIRECTION_DISTANCE && offsetY.value < LOCK_DIRECTION_DISTANCE) {
|
1181 | direction.value = getDirection(offsetX.value, offsetY.value);
|
1182 | }
|
1183 | if (isTap.value && (offsetX.value > TAP_OFFSET || offsetY.value > TAP_OFFSET)) {
|
1184 | isTap.value = false;
|
1185 | }
|
1186 | };
|
1187 | return {
|
1188 | move,
|
1189 | start,
|
1190 | reset,
|
1191 | startX,
|
1192 | startY,
|
1193 | deltaX,
|
1194 | deltaY,
|
1195 | offsetX,
|
1196 | offsetY,
|
1197 | direction,
|
1198 | isVertical,
|
1199 | isHorizontal,
|
1200 | isTap
|
1201 | };
|
1202 | }
|
1203 | let totalLockCount = 0;
|
1204 | const BODY_LOCK_CLASS = "van-overflow-hidden";
|
1205 | function useLockScroll(rootRef, shouldLock) {
|
1206 | const touch = useTouch();
|
1207 | const DIRECTION_UP = "01";
|
1208 | const DIRECTION_DOWN = "10";
|
1209 | const onTouchMove = (event) => {
|
1210 | touch.move(event);
|
1211 | const direction = touch.deltaY.value > 0 ? DIRECTION_DOWN : DIRECTION_UP;
|
1212 | const el = getScrollParent(
|
1213 | event.target,
|
1214 | rootRef.value
|
1215 | );
|
1216 | const { scrollHeight, offsetHeight, scrollTop } = el;
|
1217 | let status = "11";
|
1218 | if (scrollTop === 0) {
|
1219 | status = offsetHeight >= scrollHeight ? "00" : "01";
|
1220 | } else if (scrollTop + offsetHeight >= scrollHeight) {
|
1221 | status = "10";
|
1222 | }
|
1223 | if (status !== "11" && touch.isVertical() && !(parseInt(status, 2) & parseInt(direction, 2))) {
|
1224 | preventDefault(event, true);
|
1225 | }
|
1226 | };
|
1227 | const lock = () => {
|
1228 | document.addEventListener("touchstart", touch.start);
|
1229 | document.addEventListener("touchmove", onTouchMove, { passive: false });
|
1230 | if (!totalLockCount) {
|
1231 | document.body.classList.add(BODY_LOCK_CLASS);
|
1232 | }
|
1233 | totalLockCount++;
|
1234 | };
|
1235 | const unlock = () => {
|
1236 | if (totalLockCount) {
|
1237 | document.removeEventListener("touchstart", touch.start);
|
1238 | document.removeEventListener("touchmove", onTouchMove);
|
1239 | totalLockCount--;
|
1240 | if (!totalLockCount) {
|
1241 | document.body.classList.remove(BODY_LOCK_CLASS);
|
1242 | }
|
1243 | }
|
1244 | };
|
1245 | const init = () => shouldLock() && lock();
|
1246 | const destroy = () => shouldLock() && unlock();
|
1247 | onMountedOrActivated(init);
|
1248 | onDeactivated(destroy);
|
1249 | onBeforeUnmount(destroy);
|
1250 | watch(shouldLock, (value) => {
|
1251 | value ? lock() : unlock();
|
1252 | });
|
1253 | }
|
1254 | function useLazyRender(show) {
|
1255 | const inited = ref(false);
|
1256 | watch(
|
1257 | show,
|
1258 | (value) => {
|
1259 | if (value) {
|
1260 | inited.value = value;
|
1261 | }
|
1262 | },
|
1263 | { immediate: true }
|
1264 | );
|
1265 | return (render) => () => inited.value ? render() : null;
|
1266 | }
|
1267 | const useScopeId = () => {
|
1268 | var _a;
|
1269 | const { scopeId } = ((_a = getCurrentInstance()) == null ? void 0 : _a.vnode) || {};
|
1270 | return scopeId ? { [scopeId]: "" } : null;
|
1271 | };
|
1272 | const [name$1C, bem$1x] = createNamespace("overlay");
|
1273 | const overlayProps = {
|
1274 | show: Boolean,
|
1275 | zIndex: numericProp,
|
1276 | duration: numericProp,
|
1277 | className: unknownProp,
|
1278 | lockScroll: truthProp,
|
1279 | lazyRender: truthProp,
|
1280 | customStyle: Object
|
1281 | };
|
1282 | var stdin_default$1L = defineComponent({
|
1283 | name: name$1C,
|
1284 | props: overlayProps,
|
1285 | setup(props2, {
|
1286 | slots
|
1287 | }) {
|
1288 | const root = ref();
|
1289 | const lazyRender = useLazyRender(() => props2.show || !props2.lazyRender);
|
1290 | const onTouchMove = (event) => {
|
1291 | if (props2.lockScroll) {
|
1292 | preventDefault(event, true);
|
1293 | }
|
1294 | };
|
1295 | const renderOverlay = lazyRender(() => {
|
1296 | var _a;
|
1297 | const style = extend(getZIndexStyle(props2.zIndex), props2.customStyle);
|
1298 | if (isDef(props2.duration)) {
|
1299 | style.animationDuration = `${props2.duration}s`;
|
1300 | }
|
1301 | return withDirectives(createVNode("div", {
|
1302 | "ref": root,
|
1303 | "style": style,
|
1304 | "class": [bem$1x(), props2.className]
|
1305 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), [[vShow, props2.show]]);
|
1306 | });
|
1307 | useEventListener("touchmove", onTouchMove, {
|
1308 | target: root
|
1309 | });
|
1310 | return () => createVNode(Transition, {
|
1311 | "name": "van-fade",
|
1312 | "appear": true
|
1313 | }, {
|
1314 | default: renderOverlay
|
1315 | });
|
1316 | }
|
1317 | });
|
1318 | const Overlay = withInstall(stdin_default$1L);
|
1319 | const popupProps$2 = extend({}, popupSharedProps, {
|
1320 | round: Boolean,
|
1321 | position: makeStringProp("center"),
|
1322 | closeIcon: makeStringProp("cross"),
|
1323 | closeable: Boolean,
|
1324 | transition: String,
|
1325 | iconPrefix: String,
|
1326 | closeOnPopstate: Boolean,
|
1327 | closeIconPosition: makeStringProp("top-right"),
|
1328 | safeAreaInsetTop: Boolean,
|
1329 | safeAreaInsetBottom: Boolean
|
1330 | });
|
1331 | const [name$1B, bem$1w] = createNamespace("popup");
|
1332 | var stdin_default$1K = defineComponent({
|
1333 | name: name$1B,
|
1334 | inheritAttrs: false,
|
1335 | props: popupProps$2,
|
1336 | emits: ["open", "close", "opened", "closed", "keydown", "update:show", "clickOverlay", "clickCloseIcon"],
|
1337 | setup(props2, {
|
1338 | emit,
|
1339 | attrs,
|
1340 | slots
|
1341 | }) {
|
1342 | let opened;
|
1343 | let shouldReopen;
|
1344 | const zIndex = ref();
|
1345 | const popupRef = ref();
|
1346 | const lazyRender = useLazyRender(() => props2.show || !props2.lazyRender);
|
1347 | const style = computed(() => {
|
1348 | const style2 = {
|
1349 | zIndex: zIndex.value
|
1350 | };
|
1351 | if (isDef(props2.duration)) {
|
1352 | const key = props2.position === "center" ? "animationDuration" : "transitionDuration";
|
1353 | style2[key] = `${props2.duration}s`;
|
1354 | }
|
1355 | return style2;
|
1356 | });
|
1357 | const open = () => {
|
1358 | if (!opened) {
|
1359 | opened = true;
|
1360 | zIndex.value = props2.zIndex !== void 0 ? +props2.zIndex : useGlobalZIndex();
|
1361 | emit("open");
|
1362 | }
|
1363 | };
|
1364 | const close = () => {
|
1365 | if (opened) {
|
1366 | callInterceptor(props2.beforeClose, {
|
1367 | done() {
|
1368 | opened = false;
|
1369 | emit("close");
|
1370 | emit("update:show", false);
|
1371 | }
|
1372 | });
|
1373 | }
|
1374 | };
|
1375 | const onClickOverlay = (event) => {
|
1376 | emit("clickOverlay", event);
|
1377 | if (props2.closeOnClickOverlay) {
|
1378 | close();
|
1379 | }
|
1380 | };
|
1381 | const renderOverlay = () => {
|
1382 | if (props2.overlay) {
|
1383 | return createVNode(Overlay, mergeProps({
|
1384 | "show": props2.show,
|
1385 | "class": props2.overlayClass,
|
1386 | "zIndex": zIndex.value,
|
1387 | "duration": props2.duration,
|
1388 | "customStyle": props2.overlayStyle,
|
1389 | "role": props2.closeOnClickOverlay ? "button" : void 0,
|
1390 | "tabindex": props2.closeOnClickOverlay ? 0 : void 0
|
1391 | }, useScopeId(), {
|
1392 | "onClick": onClickOverlay
|
1393 | }), {
|
1394 | default: slots["overlay-content"]
|
1395 | });
|
1396 | }
|
1397 | };
|
1398 | const onClickCloseIcon = (event) => {
|
1399 | emit("clickCloseIcon", event);
|
1400 | close();
|
1401 | };
|
1402 | const renderCloseIcon = () => {
|
1403 | if (props2.closeable) {
|
1404 | return createVNode(Icon, {
|
1405 | "role": "button",
|
1406 | "tabindex": 0,
|
1407 | "name": props2.closeIcon,
|
1408 | "class": [bem$1w("close-icon", props2.closeIconPosition), HAPTICS_FEEDBACK],
|
1409 | "classPrefix": props2.iconPrefix,
|
1410 | "onClick": onClickCloseIcon
|
1411 | }, null);
|
1412 | }
|
1413 | };
|
1414 | let timer2;
|
1415 | const onOpened = () => {
|
1416 | if (timer2)
|
1417 | clearTimeout(timer2);
|
1418 | timer2 = setTimeout(() => {
|
1419 | emit("opened");
|
1420 | });
|
1421 | };
|
1422 | const onClosed = () => emit("closed");
|
1423 | const onKeydown = (event) => emit("keydown", event);
|
1424 | const renderPopup = lazyRender(() => {
|
1425 | var _a;
|
1426 | const {
|
1427 | round,
|
1428 | position,
|
1429 | safeAreaInsetTop,
|
1430 | safeAreaInsetBottom
|
1431 | } = props2;
|
1432 | return withDirectives(createVNode("div", mergeProps({
|
1433 | "ref": popupRef,
|
1434 | "style": style.value,
|
1435 | "role": "dialog",
|
1436 | "tabindex": 0,
|
1437 | "class": [bem$1w({
|
1438 | round,
|
1439 | [position]: position
|
1440 | }), {
|
1441 | "van-safe-area-top": safeAreaInsetTop,
|
1442 | "van-safe-area-bottom": safeAreaInsetBottom
|
1443 | }],
|
1444 | "onKeydown": onKeydown
|
1445 | }, attrs, useScopeId()), [(_a = slots.default) == null ? void 0 : _a.call(slots), renderCloseIcon()]), [[vShow, props2.show]]);
|
1446 | });
|
1447 | const renderTransition = () => {
|
1448 | const {
|
1449 | position,
|
1450 | transition,
|
1451 | transitionAppear
|
1452 | } = props2;
|
1453 | const name2 = position === "center" ? "van-fade" : `van-popup-slide-${position}`;
|
1454 | return createVNode(Transition, {
|
1455 | "name": transition || name2,
|
1456 | "appear": transitionAppear,
|
1457 | "onAfterEnter": onOpened,
|
1458 | "onAfterLeave": onClosed
|
1459 | }, {
|
1460 | default: renderPopup
|
1461 | });
|
1462 | };
|
1463 | watch(() => props2.show, (show) => {
|
1464 | if (show && !opened) {
|
1465 | open();
|
1466 | if (attrs.tabindex === 0) {
|
1467 | nextTick(() => {
|
1468 | var _a;
|
1469 | (_a = popupRef.value) == null ? void 0 : _a.focus();
|
1470 | });
|
1471 | }
|
1472 | }
|
1473 | if (!show && opened) {
|
1474 | opened = false;
|
1475 | emit("close");
|
1476 | }
|
1477 | });
|
1478 | useExpose({
|
1479 | popupRef
|
1480 | });
|
1481 | useLockScroll(popupRef, () => props2.show && props2.lockScroll);
|
1482 | useEventListener("popstate", () => {
|
1483 | if (props2.closeOnPopstate) {
|
1484 | close();
|
1485 | shouldReopen = false;
|
1486 | }
|
1487 | });
|
1488 | onMounted(() => {
|
1489 | if (props2.show) {
|
1490 | open();
|
1491 | }
|
1492 | });
|
1493 | onActivated(() => {
|
1494 | if (shouldReopen) {
|
1495 | emit("update:show", true);
|
1496 | shouldReopen = false;
|
1497 | }
|
1498 | });
|
1499 | onDeactivated(() => {
|
1500 | if (props2.show && props2.teleport) {
|
1501 | close();
|
1502 | shouldReopen = true;
|
1503 | }
|
1504 | });
|
1505 | provide(POPUP_TOGGLE_KEY, () => props2.show);
|
1506 | return () => {
|
1507 | if (props2.teleport) {
|
1508 | return createVNode(Teleport, {
|
1509 | "to": props2.teleport
|
1510 | }, {
|
1511 | default: () => [renderOverlay(), renderTransition()]
|
1512 | });
|
1513 | }
|
1514 | return createVNode(Fragment, null, [renderOverlay(), renderTransition()]);
|
1515 | };
|
1516 | }
|
1517 | });
|
1518 | const Popup = withInstall(stdin_default$1K);
|
1519 | const [name$1A, bem$1v] = createNamespace("action-sheet");
|
1520 | const actionSheetProps = extend({}, popupSharedProps, {
|
1521 | title: String,
|
1522 | round: truthProp,
|
1523 | actions: makeArrayProp(),
|
1524 | closeIcon: makeStringProp("cross"),
|
1525 | closeable: truthProp,
|
1526 | cancelText: String,
|
1527 | description: String,
|
1528 | closeOnPopstate: truthProp,
|
1529 | closeOnClickAction: Boolean,
|
1530 | safeAreaInsetBottom: truthProp
|
1531 | });
|
1532 | const popupInheritKeys$2 = [...popupSharedPropKeys, "round", "closeOnPopstate", "safeAreaInsetBottom"];
|
1533 | var stdin_default$1J = defineComponent({
|
1534 | name: name$1A,
|
1535 | props: actionSheetProps,
|
1536 | emits: ["select", "cancel", "update:show"],
|
1537 | setup(props2, {
|
1538 | slots,
|
1539 | emit
|
1540 | }) {
|
1541 | const updateShow = (show) => emit("update:show", show);
|
1542 | const onCancel = () => {
|
1543 | updateShow(false);
|
1544 | emit("cancel");
|
1545 | };
|
1546 | const renderHeader = () => {
|
1547 | if (props2.title) {
|
1548 | return createVNode("div", {
|
1549 | "class": bem$1v("header")
|
1550 | }, [props2.title, props2.closeable && createVNode(Icon, {
|
1551 | "name": props2.closeIcon,
|
1552 | "class": [bem$1v("close"), HAPTICS_FEEDBACK],
|
1553 | "onClick": onCancel
|
1554 | }, null)]);
|
1555 | }
|
1556 | };
|
1557 | const renderCancel = () => {
|
1558 | if (slots.cancel || props2.cancelText) {
|
1559 | return [createVNode("div", {
|
1560 | "class": bem$1v("gap")
|
1561 | }, null), createVNode("button", {
|
1562 | "type": "button",
|
1563 | "class": bem$1v("cancel"),
|
1564 | "onClick": onCancel
|
1565 | }, [slots.cancel ? slots.cancel() : props2.cancelText])];
|
1566 | }
|
1567 | };
|
1568 | const renderIcon = (action) => {
|
1569 | if (action.icon) {
|
1570 | return createVNode(Icon, {
|
1571 | "class": bem$1v("item-icon"),
|
1572 | "name": action.icon
|
1573 | }, null);
|
1574 | }
|
1575 | };
|
1576 | const renderActionContent = (action, index) => {
|
1577 | if (action.loading) {
|
1578 | return createVNode(Loading, {
|
1579 | "class": bem$1v("loading-icon")
|
1580 | }, null);
|
1581 | }
|
1582 | if (slots.action) {
|
1583 | return slots.action({
|
1584 | action,
|
1585 | index
|
1586 | });
|
1587 | }
|
1588 | return [createVNode("span", {
|
1589 | "class": bem$1v("name")
|
1590 | }, [action.name]), action.subname && createVNode("div", {
|
1591 | "class": bem$1v("subname")
|
1592 | }, [action.subname])];
|
1593 | };
|
1594 | const renderAction = (action, index) => {
|
1595 | const {
|
1596 | color,
|
1597 | loading,
|
1598 | callback,
|
1599 | disabled,
|
1600 | className
|
1601 | } = action;
|
1602 | const onClick = () => {
|
1603 | if (disabled || loading) {
|
1604 | return;
|
1605 | }
|
1606 | if (callback) {
|
1607 | callback(action);
|
1608 | }
|
1609 | if (props2.closeOnClickAction) {
|
1610 | updateShow(false);
|
1611 | }
|
1612 | nextTick(() => emit("select", action, index));
|
1613 | };
|
1614 | return createVNode("button", {
|
1615 | "type": "button",
|
1616 | "style": {
|
1617 | color
|
1618 | },
|
1619 | "class": [bem$1v("item", {
|
1620 | loading,
|
1621 | disabled
|
1622 | }), className],
|
1623 | "onClick": onClick
|
1624 | }, [renderIcon(action), renderActionContent(action, index)]);
|
1625 | };
|
1626 | const renderDescription = () => {
|
1627 | if (props2.description || slots.description) {
|
1628 | const content = slots.description ? slots.description() : props2.description;
|
1629 | return createVNode("div", {
|
1630 | "class": bem$1v("description")
|
1631 | }, [content]);
|
1632 | }
|
1633 | };
|
1634 | return () => createVNode(Popup, mergeProps({
|
1635 | "class": bem$1v(),
|
1636 | "position": "bottom",
|
1637 | "onUpdate:show": updateShow
|
1638 | }, pick(props2, popupInheritKeys$2)), {
|
1639 | default: () => {
|
1640 | var _a;
|
1641 | return [renderHeader(), renderDescription(), createVNode("div", {
|
1642 | "class": bem$1v("content")
|
1643 | }, [props2.actions.map(renderAction), (_a = slots.default) == null ? void 0 : _a.call(slots)]), renderCancel()];
|
1644 | }
|
1645 | });
|
1646 | }
|
1647 | });
|
1648 | const ActionSheet = withInstall(stdin_default$1J);
|
1649 | const [name$1z, bem$1u, t$k] = createNamespace("picker");
|
1650 | const getFirstEnabledOption = (options) => options.find((option) => !option.disabled) || options[0];
|
1651 | function getColumnsType(columns, fields) {
|
1652 | const firstColumn = columns[0];
|
1653 | if (firstColumn) {
|
1654 | if (Array.isArray(firstColumn)) {
|
1655 | return "multiple";
|
1656 | }
|
1657 | if (fields.children in firstColumn) {
|
1658 | return "cascade";
|
1659 | }
|
1660 | }
|
1661 | return "default";
|
1662 | }
|
1663 | function findIndexOfEnabledOption(options, index) {
|
1664 | index = clamp(index, 0, options.length);
|
1665 | for (let i = index; i < options.length; i++) {
|
1666 | if (!options[i].disabled)
|
1667 | return i;
|
1668 | }
|
1669 | for (let i = index - 1; i >= 0; i--) {
|
1670 | if (!options[i].disabled)
|
1671 | return i;
|
1672 | }
|
1673 | return 0;
|
1674 | }
|
1675 | const isOptionExist = (options, value, fields) => value !== void 0 && !!options.find((option) => option[fields.value] === value);
|
1676 | function findOptionByValue(options, value, fields) {
|
1677 | const index = options.findIndex((option) => option[fields.value] === value);
|
1678 | const enabledIndex = findIndexOfEnabledOption(options, index);
|
1679 | return options[enabledIndex];
|
1680 | }
|
1681 | function formatCascadeColumns(columns, fields, selectedValues) {
|
1682 | const formatted = [];
|
1683 | let cursor = {
|
1684 | [fields.children]: columns
|
1685 | };
|
1686 | let columnIndex = 0;
|
1687 | while (cursor && cursor[fields.children]) {
|
1688 | const options = cursor[fields.children];
|
1689 | const value = selectedValues.value[columnIndex];
|
1690 | cursor = isDef(value) ? findOptionByValue(options, value, fields) : void 0;
|
1691 | if (!cursor && options.length) {
|
1692 | const firstValue = getFirstEnabledOption(options)[fields.value];
|
1693 | cursor = findOptionByValue(options, firstValue, fields);
|
1694 | }
|
1695 | columnIndex++;
|
1696 | formatted.push(options);
|
1697 | }
|
1698 | return formatted;
|
1699 | }
|
1700 | function getElementTranslateY(element) {
|
1701 | const { transform } = window.getComputedStyle(element);
|
1702 | const translateY = transform.slice(7, transform.length - 1).split(", ")[5];
|
1703 | return Number(translateY);
|
1704 | }
|
1705 | function assignDefaultFields(fields) {
|
1706 | return extend(
|
1707 | {
|
1708 | text: "text",
|
1709 | value: "value",
|
1710 | children: "children"
|
1711 | },
|
1712 | fields
|
1713 | );
|
1714 | }
|
1715 | const DEFAULT_DURATION = 200;
|
1716 | const MOMENTUM_TIME = 300;
|
1717 | const MOMENTUM_DISTANCE = 15;
|
1718 | const [name$1y, bem$1t] = createNamespace("picker-column");
|
1719 | const PICKER_KEY = Symbol(name$1y);
|
1720 | var stdin_default$1I = defineComponent({
|
1721 | name: name$1y,
|
1722 | props: {
|
1723 | value: numericProp,
|
1724 | fields: makeRequiredProp(Object),
|
1725 | options: makeArrayProp(),
|
1726 | readonly: Boolean,
|
1727 | allowHtml: Boolean,
|
1728 | optionHeight: makeRequiredProp(Number),
|
1729 | swipeDuration: makeRequiredProp(numericProp),
|
1730 | visibleOptionNum: makeRequiredProp(numericProp)
|
1731 | },
|
1732 | emits: ["change", "clickOption", "scrollInto"],
|
1733 | setup(props2, {
|
1734 | emit,
|
1735 | slots
|
1736 | }) {
|
1737 | let moving;
|
1738 | let startOffset;
|
1739 | let touchStartTime;
|
1740 | let momentumOffset;
|
1741 | let transitionEndTrigger;
|
1742 | const root = ref();
|
1743 | const wrapper = ref();
|
1744 | const currentOffset = ref(0);
|
1745 | const currentDuration = ref(0);
|
1746 | const touch = useTouch();
|
1747 | const count = () => props2.options.length;
|
1748 | const baseOffset = () => props2.optionHeight * (+props2.visibleOptionNum - 1) / 2;
|
1749 | const updateValueByIndex = (index) => {
|
1750 | let enabledIndex = findIndexOfEnabledOption(props2.options, index);
|
1751 | const offset = -enabledIndex * props2.optionHeight;
|
1752 | const trigger = () => {
|
1753 | if (enabledIndex > count() - 1) {
|
1754 | enabledIndex = findIndexOfEnabledOption(props2.options, index);
|
1755 | }
|
1756 | const value = props2.options[enabledIndex][props2.fields.value];
|
1757 | if (value !== props2.value) {
|
1758 | emit("change", value);
|
1759 | }
|
1760 | };
|
1761 | if (moving && offset !== currentOffset.value) {
|
1762 | transitionEndTrigger = trigger;
|
1763 | } else {
|
1764 | trigger();
|
1765 | }
|
1766 | currentOffset.value = offset;
|
1767 | };
|
1768 | const isReadonly = () => props2.readonly || !props2.options.length;
|
1769 | const onClickOption = (index) => {
|
1770 | if (moving || isReadonly()) {
|
1771 | return;
|
1772 | }
|
1773 | transitionEndTrigger = null;
|
1774 | currentDuration.value = DEFAULT_DURATION;
|
1775 | updateValueByIndex(index);
|
1776 | emit("clickOption", props2.options[index]);
|
1777 | };
|
1778 | const getIndexByOffset = (offset) => clamp(Math.round(-offset / props2.optionHeight), 0, count() - 1);
|
1779 | const currentIndex = computed(() => getIndexByOffset(currentOffset.value));
|
1780 | const momentum = (distance, duration) => {
|
1781 | const speed = Math.abs(distance / duration);
|
1782 | distance = currentOffset.value + speed / 3e-3 * (distance < 0 ? -1 : 1);
|
1783 | const index = getIndexByOffset(distance);
|
1784 | currentDuration.value = +props2.swipeDuration;
|
1785 | updateValueByIndex(index);
|
1786 | };
|
1787 | const stopMomentum = () => {
|
1788 | moving = false;
|
1789 | currentDuration.value = 0;
|
1790 | if (transitionEndTrigger) {
|
1791 | transitionEndTrigger();
|
1792 | transitionEndTrigger = null;
|
1793 | }
|
1794 | };
|
1795 | const onTouchStart = (event) => {
|
1796 | if (isReadonly()) {
|
1797 | return;
|
1798 | }
|
1799 | touch.start(event);
|
1800 | if (moving) {
|
1801 | const translateY = getElementTranslateY(wrapper.value);
|
1802 | currentOffset.value = Math.min(0, translateY - baseOffset());
|
1803 | }
|
1804 | currentDuration.value = 0;
|
1805 | startOffset = currentOffset.value;
|
1806 | touchStartTime = Date.now();
|
1807 | momentumOffset = startOffset;
|
1808 | transitionEndTrigger = null;
|
1809 | };
|
1810 | const onTouchMove = (event) => {
|
1811 | if (isReadonly()) {
|
1812 | return;
|
1813 | }
|
1814 | touch.move(event);
|
1815 | if (touch.isVertical()) {
|
1816 | moving = true;
|
1817 | preventDefault(event, true);
|
1818 | }
|
1819 | const newOffset = clamp(startOffset + touch.deltaY.value, -(count() * props2.optionHeight), props2.optionHeight);
|
1820 | const newIndex = getIndexByOffset(newOffset);
|
1821 | if (newIndex !== currentIndex.value) {
|
1822 | emit("scrollInto", props2.options[newIndex]);
|
1823 | }
|
1824 | currentOffset.value = newOffset;
|
1825 | const now = Date.now();
|
1826 | if (now - touchStartTime > MOMENTUM_TIME) {
|
1827 | touchStartTime = now;
|
1828 | momentumOffset = newOffset;
|
1829 | }
|
1830 | };
|
1831 | const onTouchEnd = () => {
|
1832 | if (isReadonly()) {
|
1833 | return;
|
1834 | }
|
1835 | const distance = currentOffset.value - momentumOffset;
|
1836 | const duration = Date.now() - touchStartTime;
|
1837 | const startMomentum = duration < MOMENTUM_TIME && Math.abs(distance) > MOMENTUM_DISTANCE;
|
1838 | if (startMomentum) {
|
1839 | momentum(distance, duration);
|
1840 | return;
|
1841 | }
|
1842 | const index = getIndexByOffset(currentOffset.value);
|
1843 | currentDuration.value = DEFAULT_DURATION;
|
1844 | updateValueByIndex(index);
|
1845 | setTimeout(() => {
|
1846 | moving = false;
|
1847 | }, 0);
|
1848 | };
|
1849 | const renderOptions = () => {
|
1850 | const optionStyle = {
|
1851 | height: `${props2.optionHeight}px`
|
1852 | };
|
1853 | return props2.options.map((option, index) => {
|
1854 | const text = option[props2.fields.text];
|
1855 | const {
|
1856 | disabled
|
1857 | } = option;
|
1858 | const value = option[props2.fields.value];
|
1859 | const data = {
|
1860 | role: "button",
|
1861 | style: optionStyle,
|
1862 | tabindex: disabled ? -1 : 0,
|
1863 | class: [bem$1t("item", {
|
1864 | disabled,
|
1865 | selected: value === props2.value
|
1866 | }), option.className],
|
1867 | onClick: () => onClickOption(index)
|
1868 | };
|
1869 | const childData = {
|
1870 | class: "van-ellipsis",
|
1871 | [props2.allowHtml ? "innerHTML" : "textContent"]: text
|
1872 | };
|
1873 | return createVNode("li", data, [slots.option ? slots.option(option, index) : createVNode("div", childData, null)]);
|
1874 | });
|
1875 | };
|
1876 | useParent(PICKER_KEY);
|
1877 | useExpose({
|
1878 | stopMomentum
|
1879 | });
|
1880 | watchEffect(() => {
|
1881 | const index = moving ? Math.floor(-currentOffset.value / props2.optionHeight) : props2.options.findIndex((option) => option[props2.fields.value] === props2.value);
|
1882 | const enabledIndex = findIndexOfEnabledOption(props2.options, index);
|
1883 | const offset = -enabledIndex * props2.optionHeight;
|
1884 | if (moving && enabledIndex < index)
|
1885 | stopMomentum();
|
1886 | currentOffset.value = offset;
|
1887 | });
|
1888 | useEventListener("touchmove", onTouchMove, {
|
1889 | target: root
|
1890 | });
|
1891 | return () => createVNode("div", {
|
1892 | "ref": root,
|
1893 | "class": bem$1t(),
|
1894 | "onTouchstartPassive": onTouchStart,
|
1895 | "onTouchend": onTouchEnd,
|
1896 | "onTouchcancel": onTouchEnd
|
1897 | }, [createVNode("ul", {
|
1898 | "ref": wrapper,
|
1899 | "style": {
|
1900 | transform: `translate3d(0, ${currentOffset.value + baseOffset()}px, 0)`,
|
1901 | transitionDuration: `${currentDuration.value}ms`,
|
1902 | transitionProperty: currentDuration.value ? "all" : "none"
|
1903 | },
|
1904 | "class": bem$1t("wrapper"),
|
1905 | "onTransitionend": stopMomentum
|
1906 | }, [renderOptions()])]);
|
1907 | }
|
1908 | });
|
1909 | const [name$1x] = createNamespace("picker-toolbar");
|
1910 | const pickerToolbarProps = {
|
1911 | title: String,
|
1912 | cancelButtonText: String,
|
1913 | confirmButtonText: String
|
1914 | };
|
1915 | const pickerToolbarSlots = ["cancel", "confirm", "title", "toolbar"];
|
1916 | const pickerToolbarPropKeys = Object.keys(pickerToolbarProps);
|
1917 | var stdin_default$1H = defineComponent({
|
1918 | name: name$1x,
|
1919 | props: pickerToolbarProps,
|
1920 | emits: ["confirm", "cancel"],
|
1921 | setup(props2, {
|
1922 | emit,
|
1923 | slots
|
1924 | }) {
|
1925 | const renderTitle = () => {
|
1926 | if (slots.title) {
|
1927 | return slots.title();
|
1928 | }
|
1929 | if (props2.title) {
|
1930 | return createVNode("div", {
|
1931 | "class": [bem$1u("title"), "van-ellipsis"]
|
1932 | }, [props2.title]);
|
1933 | }
|
1934 | };
|
1935 | const onCancel = () => emit("cancel");
|
1936 | const onConfirm = () => emit("confirm");
|
1937 | const renderCancel = () => {
|
1938 | var _a;
|
1939 | const text = (_a = props2.cancelButtonText) != null ? _a : t$k("cancel");
|
1940 | if (!slots.cancel && !text) {
|
1941 | return;
|
1942 | }
|
1943 | return createVNode("button", {
|
1944 | "type": "button",
|
1945 | "class": [bem$1u("cancel"), HAPTICS_FEEDBACK],
|
1946 | "onClick": onCancel
|
1947 | }, [slots.cancel ? slots.cancel() : text]);
|
1948 | };
|
1949 | const renderConfirm = () => {
|
1950 | var _a;
|
1951 | const text = (_a = props2.confirmButtonText) != null ? _a : t$k("confirm");
|
1952 | if (!slots.confirm && !text) {
|
1953 | return;
|
1954 | }
|
1955 | return createVNode("button", {
|
1956 | "type": "button",
|
1957 | "class": [bem$1u("confirm"), HAPTICS_FEEDBACK],
|
1958 | "onClick": onConfirm
|
1959 | }, [slots.confirm ? slots.confirm() : text]);
|
1960 | };
|
1961 | return () => createVNode("div", {
|
1962 | "class": bem$1u("toolbar")
|
1963 | }, [slots.toolbar ? slots.toolbar() : [renderCancel(), renderTitle(), renderConfirm()]]);
|
1964 | }
|
1965 | });
|
1966 | const useSyncPropRef = (getProp, setProp) => {
|
1967 | const propRef = ref(getProp());
|
1968 | watch(getProp, (value) => {
|
1969 | if (value !== propRef.value) {
|
1970 | propRef.value = value;
|
1971 | }
|
1972 | });
|
1973 | watch(propRef, (value) => {
|
1974 | if (value !== getProp()) {
|
1975 | setProp(value);
|
1976 | }
|
1977 | });
|
1978 | return propRef;
|
1979 | };
|
1980 | function scrollLeftTo(scroller, to, duration) {
|
1981 | let rafId;
|
1982 | let count = 0;
|
1983 | const from = scroller.scrollLeft;
|
1984 | const frames = duration === 0 ? 1 : Math.round(duration * 1e3 / 16);
|
1985 | function cancel() {
|
1986 | cancelRaf(rafId);
|
1987 | }
|
1988 | function animate() {
|
1989 | scroller.scrollLeft += (to - from) / frames;
|
1990 | if (++count < frames) {
|
1991 | rafId = raf(animate);
|
1992 | }
|
1993 | }
|
1994 | animate();
|
1995 | return cancel;
|
1996 | }
|
1997 | function scrollTopTo(scroller, to, duration, callback) {
|
1998 | let rafId;
|
1999 | let current2 = getScrollTop(scroller);
|
2000 | const isDown = current2 < to;
|
2001 | const frames = duration === 0 ? 1 : Math.round(duration * 1e3 / 16);
|
2002 | const step = (to - current2) / frames;
|
2003 | function cancel() {
|
2004 | cancelRaf(rafId);
|
2005 | }
|
2006 | function animate() {
|
2007 | current2 += step;
|
2008 | if (isDown && current2 > to || !isDown && current2 < to) {
|
2009 | current2 = to;
|
2010 | }
|
2011 | setScrollTop(scroller, current2);
|
2012 | if (isDown && current2 < to || !isDown && current2 > to) {
|
2013 | rafId = raf(animate);
|
2014 | } else if (callback) {
|
2015 | rafId = raf(callback);
|
2016 | }
|
2017 | }
|
2018 | animate();
|
2019 | return cancel;
|
2020 | }
|
2021 | let current = 0;
|
2022 | function useId() {
|
2023 | const vm = getCurrentInstance();
|
2024 | const { name: name2 = "unknown" } = (vm == null ? void 0 : vm.type) || {};
|
2025 | if (process.env.NODE_ENV === "test") {
|
2026 | return name2;
|
2027 | }
|
2028 | return `${name2}-${++current}`;
|
2029 | }
|
2030 | function useRefs() {
|
2031 | const refs = ref([]);
|
2032 | const cache = [];
|
2033 | onBeforeUpdate(() => {
|
2034 | refs.value = [];
|
2035 | });
|
2036 | const setRefs = (index) => {
|
2037 | if (!cache[index]) {
|
2038 | cache[index] = (el) => {
|
2039 | refs.value[index] = el;
|
2040 | };
|
2041 | }
|
2042 | return cache[index];
|
2043 | };
|
2044 | return [refs, setRefs];
|
2045 | }
|
2046 | function useVisibilityChange(target, onChange) {
|
2047 | if (!inBrowser || !window.IntersectionObserver) {
|
2048 | return;
|
2049 | }
|
2050 | const observer = new IntersectionObserver(
|
2051 | (entries) => {
|
2052 | onChange(entries[0].intersectionRatio > 0);
|
2053 | },
|
2054 | { root: document.body }
|
2055 | );
|
2056 | const observe = () => {
|
2057 | if (target.value) {
|
2058 | observer.observe(target.value);
|
2059 | }
|
2060 | };
|
2061 | const unobserve = () => {
|
2062 | if (target.value) {
|
2063 | observer.unobserve(target.value);
|
2064 | }
|
2065 | };
|
2066 | onDeactivated(unobserve);
|
2067 | onBeforeUnmount(unobserve);
|
2068 | onMountedOrActivated(observe);
|
2069 | }
|
2070 | const [name$1w, bem$1s] = createNamespace("sticky");
|
2071 | const stickyProps = {
|
2072 | zIndex: numericProp,
|
2073 | position: makeStringProp("top"),
|
2074 | container: Object,
|
2075 | offsetTop: makeNumericProp(0),
|
2076 | offsetBottom: makeNumericProp(0)
|
2077 | };
|
2078 | var stdin_default$1G = defineComponent({
|
2079 | name: name$1w,
|
2080 | props: stickyProps,
|
2081 | emits: ["scroll", "change"],
|
2082 | setup(props2, {
|
2083 | emit,
|
2084 | slots
|
2085 | }) {
|
2086 | const root = ref();
|
2087 | const scrollParent = useScrollParent(root);
|
2088 | const state = reactive({
|
2089 | fixed: false,
|
2090 | width: 0,
|
2091 |
|
2092 | height: 0,
|
2093 |
|
2094 | transform: 0
|
2095 | });
|
2096 | const isReset = ref(false);
|
2097 | const offset = computed(() => unitToPx(props2.position === "top" ? props2.offsetTop : props2.offsetBottom));
|
2098 | const rootStyle = computed(() => {
|
2099 | if (isReset.value) {
|
2100 | return;
|
2101 | }
|
2102 | const {
|
2103 | fixed,
|
2104 | height,
|
2105 | width
|
2106 | } = state;
|
2107 | if (fixed) {
|
2108 | return {
|
2109 | width: `${width}px`,
|
2110 | height: `${height}px`
|
2111 | };
|
2112 | }
|
2113 | });
|
2114 | const stickyStyle = computed(() => {
|
2115 | if (!state.fixed || isReset.value) {
|
2116 | return;
|
2117 | }
|
2118 | const style = extend(getZIndexStyle(props2.zIndex), {
|
2119 | width: `${state.width}px`,
|
2120 | height: `${state.height}px`,
|
2121 | [props2.position]: `${offset.value}px`
|
2122 | });
|
2123 | if (state.transform) {
|
2124 | style.transform = `translate3d(0, ${state.transform}px, 0)`;
|
2125 | }
|
2126 | return style;
|
2127 | });
|
2128 | const emitScroll = (scrollTop) => emit("scroll", {
|
2129 | scrollTop,
|
2130 | isFixed: state.fixed
|
2131 | });
|
2132 | const onScroll = () => {
|
2133 | if (!root.value || isHidden(root)) {
|
2134 | return;
|
2135 | }
|
2136 | const {
|
2137 | container,
|
2138 | position
|
2139 | } = props2;
|
2140 | const rootRect = useRect(root);
|
2141 | const scrollTop = getScrollTop(window);
|
2142 | state.width = rootRect.width;
|
2143 | state.height = rootRect.height;
|
2144 | if (position === "top") {
|
2145 | if (container) {
|
2146 | const containerRect = useRect(container);
|
2147 | const difference = containerRect.bottom - offset.value - state.height;
|
2148 | state.fixed = offset.value > rootRect.top && containerRect.bottom > 0;
|
2149 | state.transform = difference < 0 ? difference : 0;
|
2150 | } else {
|
2151 | state.fixed = offset.value > rootRect.top;
|
2152 | }
|
2153 | } else {
|
2154 | const {
|
2155 | clientHeight
|
2156 | } = document.documentElement;
|
2157 | if (container) {
|
2158 | const containerRect = useRect(container);
|
2159 | const difference = clientHeight - containerRect.top - offset.value - state.height;
|
2160 | state.fixed = clientHeight - offset.value < rootRect.bottom && clientHeight > containerRect.top;
|
2161 | state.transform = difference < 0 ? -difference : 0;
|
2162 | } else {
|
2163 | state.fixed = clientHeight - offset.value < rootRect.bottom;
|
2164 | }
|
2165 | }
|
2166 | emitScroll(scrollTop);
|
2167 | };
|
2168 | watch(() => state.fixed, (value) => emit("change", value));
|
2169 | useEventListener("scroll", onScroll, {
|
2170 | target: scrollParent,
|
2171 | passive: true
|
2172 | });
|
2173 | useVisibilityChange(root, onScroll);
|
2174 | watch([windowWidth, windowHeight], () => {
|
2175 | if (!root.value || isHidden(root) || !state.fixed) {
|
2176 | return;
|
2177 | }
|
2178 | isReset.value = true;
|
2179 | nextTick(() => {
|
2180 | const rootRect = useRect(root);
|
2181 | state.width = rootRect.width;
|
2182 | state.height = rootRect.height;
|
2183 | isReset.value = false;
|
2184 | });
|
2185 | });
|
2186 | return () => {
|
2187 | var _a;
|
2188 | return createVNode("div", {
|
2189 | "ref": root,
|
2190 | "style": rootStyle.value
|
2191 | }, [createVNode("div", {
|
2192 | "class": bem$1s({
|
2193 | fixed: state.fixed && !isReset.value
|
2194 | }),
|
2195 | "style": stickyStyle.value
|
2196 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
|
2197 | };
|
2198 | }
|
2199 | });
|
2200 | const Sticky = withInstall(stdin_default$1G);
|
2201 | const [name$1v, bem$1r] = createNamespace("swipe");
|
2202 | const swipeProps = {
|
2203 | loop: truthProp,
|
2204 | width: numericProp,
|
2205 | height: numericProp,
|
2206 | vertical: Boolean,
|
2207 | autoplay: makeNumericProp(0),
|
2208 | duration: makeNumericProp(500),
|
2209 | touchable: truthProp,
|
2210 | lazyRender: Boolean,
|
2211 | initialSwipe: makeNumericProp(0),
|
2212 | indicatorColor: String,
|
2213 | showIndicators: truthProp,
|
2214 | stopPropagation: truthProp
|
2215 | };
|
2216 | const SWIPE_KEY = Symbol(name$1v);
|
2217 | var stdin_default$1F = defineComponent({
|
2218 | name: name$1v,
|
2219 | props: swipeProps,
|
2220 | emits: ["change", "dragStart", "dragEnd"],
|
2221 | setup(props2, {
|
2222 | emit,
|
2223 | slots
|
2224 | }) {
|
2225 | const root = ref();
|
2226 | const track = ref();
|
2227 | const state = reactive({
|
2228 | rect: null,
|
2229 | width: 0,
|
2230 | height: 0,
|
2231 | offset: 0,
|
2232 | active: 0,
|
2233 | swiping: false
|
2234 | });
|
2235 | let dragging = false;
|
2236 | const touch = useTouch();
|
2237 | const {
|
2238 | children,
|
2239 | linkChildren
|
2240 | } = useChildren(SWIPE_KEY);
|
2241 | const count = computed(() => children.length);
|
2242 | const size = computed(() => state[props2.vertical ? "height" : "width"]);
|
2243 | const delta = computed(() => props2.vertical ? touch.deltaY.value : touch.deltaX.value);
|
2244 | const minOffset = computed(() => {
|
2245 | if (state.rect) {
|
2246 | const base = props2.vertical ? state.rect.height : state.rect.width;
|
2247 | return base - size.value * count.value;
|
2248 | }
|
2249 | return 0;
|
2250 | });
|
2251 | const maxCount = computed(() => size.value ? Math.ceil(Math.abs(minOffset.value) / size.value) : count.value);
|
2252 | const trackSize = computed(() => count.value * size.value);
|
2253 | const activeIndicator = computed(() => (state.active + count.value) % count.value);
|
2254 | const isCorrectDirection = computed(() => {
|
2255 | const expect = props2.vertical ? "vertical" : "horizontal";
|
2256 | return touch.direction.value === expect;
|
2257 | });
|
2258 | const trackStyle = computed(() => {
|
2259 | const style = {
|
2260 | transitionDuration: `${state.swiping ? 0 : props2.duration}ms`,
|
2261 | transform: `translate${props2.vertical ? "Y" : "X"}(${+state.offset.toFixed(2)}px)`
|
2262 | };
|
2263 | if (size.value) {
|
2264 | const mainAxis = props2.vertical ? "height" : "width";
|
2265 | const crossAxis = props2.vertical ? "width" : "height";
|
2266 | style[mainAxis] = `${trackSize.value}px`;
|
2267 | style[crossAxis] = props2[crossAxis] ? `${props2[crossAxis]}px` : "";
|
2268 | }
|
2269 | return style;
|
2270 | });
|
2271 | const getTargetActive = (pace) => {
|
2272 | const {
|
2273 | active
|
2274 | } = state;
|
2275 | if (pace) {
|
2276 | if (props2.loop) {
|
2277 | return clamp(active + pace, -1, count.value);
|
2278 | }
|
2279 | return clamp(active + pace, 0, maxCount.value);
|
2280 | }
|
2281 | return active;
|
2282 | };
|
2283 | const getTargetOffset = (targetActive, offset = 0) => {
|
2284 | let currentPosition = targetActive * size.value;
|
2285 | if (!props2.loop) {
|
2286 | currentPosition = Math.min(currentPosition, -minOffset.value);
|
2287 | }
|
2288 | let targetOffset = offset - currentPosition;
|
2289 | if (!props2.loop) {
|
2290 | targetOffset = clamp(targetOffset, minOffset.value, 0);
|
2291 | }
|
2292 | return targetOffset;
|
2293 | };
|
2294 | const move = ({
|
2295 | pace = 0,
|
2296 | offset = 0,
|
2297 | emitChange
|
2298 | }) => {
|
2299 | if (count.value <= 1) {
|
2300 | return;
|
2301 | }
|
2302 | const {
|
2303 | active
|
2304 | } = state;
|
2305 | const targetActive = getTargetActive(pace);
|
2306 | const targetOffset = getTargetOffset(targetActive, offset);
|
2307 | if (props2.loop) {
|
2308 | if (children[0] && targetOffset !== minOffset.value) {
|
2309 | const outRightBound = targetOffset < minOffset.value;
|
2310 | children[0].setOffset(outRightBound ? trackSize.value : 0);
|
2311 | }
|
2312 | if (children[count.value - 1] && targetOffset !== 0) {
|
2313 | const outLeftBound = targetOffset > 0;
|
2314 | children[count.value - 1].setOffset(outLeftBound ? -trackSize.value : 0);
|
2315 | }
|
2316 | }
|
2317 | state.active = targetActive;
|
2318 | state.offset = targetOffset;
|
2319 | if (emitChange && targetActive !== active) {
|
2320 | emit("change", activeIndicator.value);
|
2321 | }
|
2322 | };
|
2323 | const correctPosition = () => {
|
2324 | state.swiping = true;
|
2325 | if (state.active <= -1) {
|
2326 | move({
|
2327 | pace: count.value
|
2328 | });
|
2329 | } else if (state.active >= count.value) {
|
2330 | move({
|
2331 | pace: -count.value
|
2332 | });
|
2333 | }
|
2334 | };
|
2335 | const prev = () => {
|
2336 | correctPosition();
|
2337 | touch.reset();
|
2338 | doubleRaf(() => {
|
2339 | state.swiping = false;
|
2340 | move({
|
2341 | pace: -1,
|
2342 | emitChange: true
|
2343 | });
|
2344 | });
|
2345 | };
|
2346 | const next = () => {
|
2347 | correctPosition();
|
2348 | touch.reset();
|
2349 | doubleRaf(() => {
|
2350 | state.swiping = false;
|
2351 | move({
|
2352 | pace: 1,
|
2353 | emitChange: true
|
2354 | });
|
2355 | });
|
2356 | };
|
2357 | let autoplayTimer;
|
2358 | const stopAutoplay = () => clearTimeout(autoplayTimer);
|
2359 | const autoplay = () => {
|
2360 | stopAutoplay();
|
2361 | if (+props2.autoplay > 0 && count.value > 1) {
|
2362 | autoplayTimer = setTimeout(() => {
|
2363 | next();
|
2364 | autoplay();
|
2365 | }, +props2.autoplay);
|
2366 | }
|
2367 | };
|
2368 | const initialize = (active = +props2.initialSwipe) => {
|
2369 | if (!root.value) {
|
2370 | return;
|
2371 | }
|
2372 | const cb = () => {
|
2373 | var _a, _b;
|
2374 | if (!isHidden(root)) {
|
2375 | const rect = {
|
2376 | width: root.value.offsetWidth,
|
2377 | height: root.value.offsetHeight
|
2378 | };
|
2379 | state.rect = rect;
|
2380 | state.width = +((_a = props2.width) != null ? _a : rect.width);
|
2381 | state.height = +((_b = props2.height) != null ? _b : rect.height);
|
2382 | }
|
2383 | if (count.value) {
|
2384 | active = Math.min(count.value - 1, active);
|
2385 | if (active === -1) {
|
2386 | active = count.value - 1;
|
2387 | }
|
2388 | }
|
2389 | state.active = active;
|
2390 | state.swiping = true;
|
2391 | state.offset = getTargetOffset(active);
|
2392 | children.forEach((swipe) => {
|
2393 | swipe.setOffset(0);
|
2394 | });
|
2395 | autoplay();
|
2396 | };
|
2397 | if (isHidden(root)) {
|
2398 | nextTick().then(cb);
|
2399 | } else {
|
2400 | cb();
|
2401 | }
|
2402 | };
|
2403 | const resize = () => initialize(state.active);
|
2404 | let touchStartTime;
|
2405 | const onTouchStart = (event) => {
|
2406 | if (!props2.touchable ||
|
2407 | event.touches.length > 1)
|
2408 | return;
|
2409 | touch.start(event);
|
2410 | dragging = false;
|
2411 | touchStartTime = Date.now();
|
2412 | stopAutoplay();
|
2413 | correctPosition();
|
2414 | };
|
2415 | const onTouchMove = (event) => {
|
2416 | if (props2.touchable && state.swiping) {
|
2417 | touch.move(event);
|
2418 | if (isCorrectDirection.value) {
|
2419 | const isEdgeTouch = !props2.loop && (state.active === 0 && delta.value > 0 || state.active === count.value - 1 && delta.value < 0);
|
2420 | if (!isEdgeTouch) {
|
2421 | preventDefault(event, props2.stopPropagation);
|
2422 | move({
|
2423 | offset: delta.value
|
2424 | });
|
2425 | if (!dragging) {
|
2426 | emit("dragStart", {
|
2427 | index: activeIndicator.value
|
2428 | });
|
2429 | dragging = true;
|
2430 | }
|
2431 | }
|
2432 | }
|
2433 | }
|
2434 | };
|
2435 | const onTouchEnd = () => {
|
2436 | if (!props2.touchable || !state.swiping) {
|
2437 | return;
|
2438 | }
|
2439 | const duration = Date.now() - touchStartTime;
|
2440 | const speed = delta.value / duration;
|
2441 | const shouldSwipe = Math.abs(speed) > 0.25 || Math.abs(delta.value) > size.value / 2;
|
2442 | if (shouldSwipe && isCorrectDirection.value) {
|
2443 | const offset = props2.vertical ? touch.offsetY.value : touch.offsetX.value;
|
2444 | let pace = 0;
|
2445 | if (props2.loop) {
|
2446 | pace = offset > 0 ? delta.value > 0 ? -1 : 1 : 0;
|
2447 | } else {
|
2448 | pace = -Math[delta.value > 0 ? "ceil" : "floor"](delta.value / size.value);
|
2449 | }
|
2450 | move({
|
2451 | pace,
|
2452 | emitChange: true
|
2453 | });
|
2454 | } else if (delta.value) {
|
2455 | move({
|
2456 | pace: 0
|
2457 | });
|
2458 | }
|
2459 | dragging = false;
|
2460 | state.swiping = false;
|
2461 | emit("dragEnd", {
|
2462 | index: activeIndicator.value
|
2463 | });
|
2464 | autoplay();
|
2465 | };
|
2466 | const swipeTo = (index, options = {}) => {
|
2467 | correctPosition();
|
2468 | touch.reset();
|
2469 | doubleRaf(() => {
|
2470 | let targetIndex;
|
2471 | if (props2.loop && index === count.value) {
|
2472 | targetIndex = state.active === 0 ? 0 : index;
|
2473 | } else {
|
2474 | targetIndex = index % count.value;
|
2475 | }
|
2476 | if (options.immediate) {
|
2477 | doubleRaf(() => {
|
2478 | state.swiping = false;
|
2479 | });
|
2480 | } else {
|
2481 | state.swiping = false;
|
2482 | }
|
2483 | move({
|
2484 | pace: targetIndex - state.active,
|
2485 | emitChange: true
|
2486 | });
|
2487 | });
|
2488 | };
|
2489 | const renderDot = (_, index) => {
|
2490 | const active = index === activeIndicator.value;
|
2491 | const style = active ? {
|
2492 | backgroundColor: props2.indicatorColor
|
2493 | } : void 0;
|
2494 | return createVNode("i", {
|
2495 | "style": style,
|
2496 | "class": bem$1r("indicator", {
|
2497 | active
|
2498 | })
|
2499 | }, null);
|
2500 | };
|
2501 | const renderIndicator = () => {
|
2502 | if (slots.indicator) {
|
2503 | return slots.indicator({
|
2504 | active: activeIndicator.value,
|
2505 | total: count.value
|
2506 | });
|
2507 | }
|
2508 | if (props2.showIndicators && count.value > 1) {
|
2509 | return createVNode("div", {
|
2510 | "class": bem$1r("indicators", {
|
2511 | vertical: props2.vertical
|
2512 | })
|
2513 | }, [Array(count.value).fill("").map(renderDot)]);
|
2514 | }
|
2515 | };
|
2516 | useExpose({
|
2517 | prev,
|
2518 | next,
|
2519 | state,
|
2520 | resize,
|
2521 | swipeTo
|
2522 | });
|
2523 | linkChildren({
|
2524 | size,
|
2525 | props: props2,
|
2526 | count,
|
2527 | activeIndicator
|
2528 | });
|
2529 | watch(() => props2.initialSwipe, (value) => initialize(+value));
|
2530 | watch(count, () => initialize(state.active));
|
2531 | watch(() => props2.autoplay, autoplay);
|
2532 | watch([windowWidth, windowHeight, () => props2.width, () => props2.height], resize);
|
2533 | watch(usePageVisibility(), (visible) => {
|
2534 | if (visible === "visible") {
|
2535 | autoplay();
|
2536 | } else {
|
2537 | stopAutoplay();
|
2538 | }
|
2539 | });
|
2540 | onMounted(initialize);
|
2541 | onActivated(() => initialize(state.active));
|
2542 | onPopupReopen(() => initialize(state.active));
|
2543 | onDeactivated(stopAutoplay);
|
2544 | onBeforeUnmount(stopAutoplay);
|
2545 | useEventListener("touchmove", onTouchMove, {
|
2546 | target: track
|
2547 | });
|
2548 | return () => {
|
2549 | var _a;
|
2550 | return createVNode("div", {
|
2551 | "ref": root,
|
2552 | "class": bem$1r()
|
2553 | }, [createVNode("div", {
|
2554 | "ref": track,
|
2555 | "style": trackStyle.value,
|
2556 | "class": bem$1r("track", {
|
2557 | vertical: props2.vertical
|
2558 | }),
|
2559 | "onTouchstartPassive": onTouchStart,
|
2560 | "onTouchend": onTouchEnd,
|
2561 | "onTouchcancel": onTouchEnd
|
2562 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), renderIndicator()]);
|
2563 | };
|
2564 | }
|
2565 | });
|
2566 | const Swipe = withInstall(stdin_default$1F);
|
2567 | const [name$1u, bem$1q] = createNamespace("tabs");
|
2568 | var stdin_default$1E = defineComponent({
|
2569 | name: name$1u,
|
2570 | props: {
|
2571 | count: makeRequiredProp(Number),
|
2572 | inited: Boolean,
|
2573 | animated: Boolean,
|
2574 | duration: makeRequiredProp(numericProp),
|
2575 | swipeable: Boolean,
|
2576 | lazyRender: Boolean,
|
2577 | currentIndex: makeRequiredProp(Number)
|
2578 | },
|
2579 | emits: ["change"],
|
2580 | setup(props2, {
|
2581 | emit,
|
2582 | slots
|
2583 | }) {
|
2584 | const swipeRef = ref();
|
2585 | const onChange = (index) => emit("change", index);
|
2586 | const renderChildren = () => {
|
2587 | var _a;
|
2588 | const Content = (_a = slots.default) == null ? void 0 : _a.call(slots);
|
2589 | if (props2.animated || props2.swipeable) {
|
2590 | return createVNode(Swipe, {
|
2591 | "ref": swipeRef,
|
2592 | "loop": false,
|
2593 | "class": bem$1q("track"),
|
2594 | "duration": +props2.duration * 1e3,
|
2595 | "touchable": props2.swipeable,
|
2596 | "lazyRender": props2.lazyRender,
|
2597 | "showIndicators": false,
|
2598 | "onChange": onChange
|
2599 | }, {
|
2600 | default: () => [Content]
|
2601 | });
|
2602 | }
|
2603 | return Content;
|
2604 | };
|
2605 | const swipeToCurrentTab = (index) => {
|
2606 | const swipe = swipeRef.value;
|
2607 | if (swipe && swipe.state.active !== index) {
|
2608 | swipe.swipeTo(index, {
|
2609 | immediate: !props2.inited
|
2610 | });
|
2611 | }
|
2612 | };
|
2613 | watch(() => props2.currentIndex, swipeToCurrentTab);
|
2614 | onMounted(() => {
|
2615 | swipeToCurrentTab(props2.currentIndex);
|
2616 | });
|
2617 | useExpose({
|
2618 | swipeRef
|
2619 | });
|
2620 | return () => createVNode("div", {
|
2621 | "class": bem$1q("content", {
|
2622 | animated: props2.animated || props2.swipeable
|
2623 | })
|
2624 | }, [renderChildren()]);
|
2625 | }
|
2626 | });
|
2627 | const [name$1t, bem$1p] = createNamespace("tabs");
|
2628 | const tabsProps = {
|
2629 | type: makeStringProp("line"),
|
2630 | color: String,
|
2631 | border: Boolean,
|
2632 | sticky: Boolean,
|
2633 | shrink: Boolean,
|
2634 | active: makeNumericProp(0),
|
2635 | duration: makeNumericProp(0.3),
|
2636 | animated: Boolean,
|
2637 | ellipsis: truthProp,
|
2638 | swipeable: Boolean,
|
2639 | scrollspy: Boolean,
|
2640 | offsetTop: makeNumericProp(0),
|
2641 | background: String,
|
2642 | lazyRender: truthProp,
|
2643 | showHeader: truthProp,
|
2644 | lineWidth: numericProp,
|
2645 | lineHeight: numericProp,
|
2646 | beforeChange: Function,
|
2647 | swipeThreshold: makeNumericProp(5),
|
2648 | titleActiveColor: String,
|
2649 | titleInactiveColor: String
|
2650 | };
|
2651 | const TABS_KEY = Symbol(name$1t);
|
2652 | var stdin_default$1D = defineComponent({
|
2653 | name: name$1t,
|
2654 | props: tabsProps,
|
2655 | emits: ["change", "scroll", "rendered", "clickTab", "update:active"],
|
2656 | setup(props2, {
|
2657 | emit,
|
2658 | slots
|
2659 | }) {
|
2660 | let tabHeight;
|
2661 | let lockScroll;
|
2662 | let stickyFixed;
|
2663 | let cancelScrollLeftToRaf;
|
2664 | let cancelScrollTopToRaf;
|
2665 | const root = ref();
|
2666 | const navRef = ref();
|
2667 | const wrapRef = ref();
|
2668 | const contentRef = ref();
|
2669 | const id = useId();
|
2670 | const scroller = useScrollParent(root);
|
2671 | const [titleRefs, setTitleRefs] = useRefs();
|
2672 | const {
|
2673 | children,
|
2674 | linkChildren
|
2675 | } = useChildren(TABS_KEY);
|
2676 | const state = reactive({
|
2677 | inited: false,
|
2678 | position: "",
|
2679 | lineStyle: {},
|
2680 | currentIndex: -1
|
2681 | });
|
2682 | const scrollable = computed(() => children.length > +props2.swipeThreshold || !props2.ellipsis || props2.shrink);
|
2683 | const navStyle = computed(() => ({
|
2684 | borderColor: props2.color,
|
2685 | background: props2.background
|
2686 | }));
|
2687 | const getTabName = (tab, index) => {
|
2688 | var _a;
|
2689 | return (_a = tab.name) != null ? _a : index;
|
2690 | };
|
2691 | const currentName = computed(() => {
|
2692 | const activeTab = children[state.currentIndex];
|
2693 | if (activeTab) {
|
2694 | return getTabName(activeTab, state.currentIndex);
|
2695 | }
|
2696 | });
|
2697 | const offsetTopPx = computed(() => unitToPx(props2.offsetTop));
|
2698 | const scrollOffset = computed(() => {
|
2699 | if (props2.sticky) {
|
2700 | return offsetTopPx.value + tabHeight;
|
2701 | }
|
2702 | return 0;
|
2703 | });
|
2704 | const scrollIntoView = (immediate) => {
|
2705 | const nav = navRef.value;
|
2706 | const titles = titleRefs.value;
|
2707 | if (!scrollable.value || !nav || !titles || !titles[state.currentIndex]) {
|
2708 | return;
|
2709 | }
|
2710 | const title = titles[state.currentIndex].$el;
|
2711 | const to = title.offsetLeft - (nav.offsetWidth - title.offsetWidth) / 2;
|
2712 | if (cancelScrollLeftToRaf)
|
2713 | cancelScrollLeftToRaf();
|
2714 | cancelScrollLeftToRaf = scrollLeftTo(nav, to, immediate ? 0 : +props2.duration);
|
2715 | };
|
2716 | const setLine = () => {
|
2717 | const shouldAnimate = state.inited;
|
2718 | nextTick(() => {
|
2719 | const titles = titleRefs.value;
|
2720 | if (!titles || !titles[state.currentIndex] || props2.type !== "line" || isHidden(root.value)) {
|
2721 | return;
|
2722 | }
|
2723 | const title = titles[state.currentIndex].$el;
|
2724 | const {
|
2725 | lineWidth,
|
2726 | lineHeight
|
2727 | } = props2;
|
2728 | const left = title.offsetLeft + title.offsetWidth / 2;
|
2729 | const lineStyle = {
|
2730 | width: addUnit(lineWidth),
|
2731 | backgroundColor: props2.color,
|
2732 | transform: `translateX(${left}px) translateX(-50%)`
|
2733 | };
|
2734 | if (shouldAnimate) {
|
2735 | lineStyle.transitionDuration = `${props2.duration}s`;
|
2736 | }
|
2737 | if (isDef(lineHeight)) {
|
2738 | const height = addUnit(lineHeight);
|
2739 | lineStyle.height = height;
|
2740 | lineStyle.borderRadius = height;
|
2741 | }
|
2742 | state.lineStyle = lineStyle;
|
2743 | });
|
2744 | };
|
2745 | const findAvailableTab = (index) => {
|
2746 | const diff = index < state.currentIndex ? -1 : 1;
|
2747 | while (index >= 0 && index < children.length) {
|
2748 | if (!children[index].disabled) {
|
2749 | return index;
|
2750 | }
|
2751 | index += diff;
|
2752 | }
|
2753 | };
|
2754 | const setCurrentIndex = (currentIndex, skipScrollIntoView) => {
|
2755 | const newIndex = findAvailableTab(currentIndex);
|
2756 | if (!isDef(newIndex)) {
|
2757 | return;
|
2758 | }
|
2759 | const newTab = children[newIndex];
|
2760 | const newName = getTabName(newTab, newIndex);
|
2761 | const shouldEmitChange = state.currentIndex !== null;
|
2762 | if (state.currentIndex !== newIndex) {
|
2763 | state.currentIndex = newIndex;
|
2764 | if (!skipScrollIntoView) {
|
2765 | scrollIntoView();
|
2766 | }
|
2767 | setLine();
|
2768 | }
|
2769 | if (newName !== props2.active) {
|
2770 | emit("update:active", newName);
|
2771 | if (shouldEmitChange) {
|
2772 | emit("change", newName, newTab.title);
|
2773 | }
|
2774 | }
|
2775 | if (stickyFixed && !props2.scrollspy) {
|
2776 | setRootScrollTop(Math.ceil(getElementTop(root.value) - offsetTopPx.value));
|
2777 | }
|
2778 | };
|
2779 | const setCurrentIndexByName = (name2, skipScrollIntoView) => {
|
2780 | const matched = children.find((tab, index2) => getTabName(tab, index2) === name2);
|
2781 | const index = matched ? children.indexOf(matched) : 0;
|
2782 | setCurrentIndex(index, skipScrollIntoView);
|
2783 | };
|
2784 | const scrollToCurrentContent = (immediate = false) => {
|
2785 | if (props2.scrollspy) {
|
2786 | const target = children[state.currentIndex].$el;
|
2787 | if (target && scroller.value) {
|
2788 | const to = getElementTop(target, scroller.value) - scrollOffset.value;
|
2789 | lockScroll = true;
|
2790 | if (cancelScrollTopToRaf)
|
2791 | cancelScrollTopToRaf();
|
2792 | cancelScrollTopToRaf = scrollTopTo(scroller.value, to, immediate ? 0 : +props2.duration, () => {
|
2793 | lockScroll = false;
|
2794 | });
|
2795 | }
|
2796 | }
|
2797 | };
|
2798 | const onClickTab = (item, index, event) => {
|
2799 | const {
|
2800 | title,
|
2801 | disabled
|
2802 | } = children[index];
|
2803 | const name2 = getTabName(children[index], index);
|
2804 | if (!disabled) {
|
2805 | callInterceptor(props2.beforeChange, {
|
2806 | args: [name2],
|
2807 | done: () => {
|
2808 | setCurrentIndex(index);
|
2809 | scrollToCurrentContent();
|
2810 | }
|
2811 | });
|
2812 | route(item);
|
2813 | }
|
2814 | emit("clickTab", {
|
2815 | name: name2,
|
2816 | title,
|
2817 | event,
|
2818 | disabled
|
2819 | });
|
2820 | };
|
2821 | const onStickyScroll = (params) => {
|
2822 | stickyFixed = params.isFixed;
|
2823 | emit("scroll", params);
|
2824 | };
|
2825 | const scrollTo = (name2) => {
|
2826 | nextTick(() => {
|
2827 | setCurrentIndexByName(name2);
|
2828 | scrollToCurrentContent(true);
|
2829 | });
|
2830 | };
|
2831 | const getCurrentIndexOnScroll = () => {
|
2832 | for (let index = 0; index < children.length; index++) {
|
2833 | const {
|
2834 | top
|
2835 | } = useRect(children[index].$el);
|
2836 | if (top > scrollOffset.value) {
|
2837 | return index === 0 ? 0 : index - 1;
|
2838 | }
|
2839 | }
|
2840 | return children.length - 1;
|
2841 | };
|
2842 | const onScroll = () => {
|
2843 | if (props2.scrollspy && !lockScroll) {
|
2844 | const index = getCurrentIndexOnScroll();
|
2845 | setCurrentIndex(index);
|
2846 | }
|
2847 | };
|
2848 | const renderLine = () => {
|
2849 | if (props2.type === "line" && children.length) {
|
2850 | return createVNode("div", {
|
2851 | "class": bem$1p("line"),
|
2852 | "style": state.lineStyle
|
2853 | }, null);
|
2854 | }
|
2855 | };
|
2856 | const renderHeader = () => {
|
2857 | var _a, _b, _c;
|
2858 | const {
|
2859 | type,
|
2860 | border,
|
2861 | sticky
|
2862 | } = props2;
|
2863 | const Header = [createVNode("div", {
|
2864 | "ref": sticky ? void 0 : wrapRef,
|
2865 | "class": [bem$1p("wrap"), {
|
2866 | [BORDER_TOP_BOTTOM]: type === "line" && border
|
2867 | }]
|
2868 | }, [createVNode("div", {
|
2869 | "ref": navRef,
|
2870 | "role": "tablist",
|
2871 | "class": bem$1p("nav", [type, {
|
2872 | shrink: props2.shrink,
|
2873 | complete: scrollable.value
|
2874 | }]),
|
2875 | "style": navStyle.value,
|
2876 | "aria-orientation": "horizontal"
|
2877 | }, [(_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)];
|
2878 | if (sticky) {
|
2879 | return createVNode("div", {
|
2880 | "ref": wrapRef
|
2881 | }, [Header]);
|
2882 | }
|
2883 | return Header;
|
2884 | };
|
2885 | const resize = () => {
|
2886 | setLine();
|
2887 | nextTick(() => {
|
2888 | var _a, _b;
|
2889 | scrollIntoView(true);
|
2890 | (_b = (_a = contentRef.value) == null ? void 0 : _a.swipeRef.value) == null ? void 0 : _b.resize();
|
2891 | });
|
2892 | };
|
2893 | watch(() => [props2.color, props2.duration, props2.lineWidth, props2.lineHeight], setLine);
|
2894 | watch(windowWidth, resize);
|
2895 | watch(() => props2.active, (value) => {
|
2896 | if (value !== currentName.value) {
|
2897 | setCurrentIndexByName(value);
|
2898 | }
|
2899 | });
|
2900 | watch(() => children.length, () => {
|
2901 | if (state.inited) {
|
2902 | setCurrentIndexByName(props2.active);
|
2903 | setLine();
|
2904 | nextTick(() => {
|
2905 | scrollIntoView(true);
|
2906 | });
|
2907 | }
|
2908 | });
|
2909 | const init = () => {
|
2910 | setCurrentIndexByName(props2.active, true);
|
2911 | nextTick(() => {
|
2912 | state.inited = true;
|
2913 | if (wrapRef.value) {
|
2914 | tabHeight = useRect(wrapRef.value).height;
|
2915 | }
|
2916 | scrollIntoView(true);
|
2917 | });
|
2918 | };
|
2919 | const onRendered = (name2, title) => emit("rendered", name2, title);
|
2920 | useExpose({
|
2921 | resize,
|
2922 | scrollTo
|
2923 | });
|
2924 | onActivated(setLine);
|
2925 | onPopupReopen(setLine);
|
2926 | onMountedOrActivated(init);
|
2927 | useVisibilityChange(root, setLine);
|
2928 | useEventListener("scroll", onScroll, {
|
2929 | target: scroller,
|
2930 | passive: true
|
2931 | });
|
2932 | linkChildren({
|
2933 | id,
|
2934 | props: props2,
|
2935 | setLine,
|
2936 | scrollable,
|
2937 | onRendered,
|
2938 | currentName,
|
2939 | setTitleRefs,
|
2940 | scrollIntoView
|
2941 | });
|
2942 | return () => createVNode("div", {
|
2943 | "ref": root,
|
2944 | "class": bem$1p([props2.type])
|
2945 | }, [props2.showHeader ? props2.sticky ? createVNode(Sticky, {
|
2946 | "container": root.value,
|
2947 | "offsetTop": offsetTopPx.value,
|
2948 | "onScroll": onStickyScroll
|
2949 | }, {
|
2950 | default: () => [renderHeader()]
|
2951 | }) : renderHeader() : null, createVNode(stdin_default$1E, {
|
2952 | "ref": contentRef,
|
2953 | "count": children.length,
|
2954 | "inited": state.inited,
|
2955 | "animated": props2.animated,
|
2956 | "duration": props2.duration,
|
2957 | "swipeable": props2.swipeable,
|
2958 | "lazyRender": props2.lazyRender,
|
2959 | "currentIndex": state.currentIndex,
|
2960 | "onChange": setCurrentIndex
|
2961 | }, {
|
2962 | default: () => {
|
2963 | var _a;
|
2964 | return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
|
2965 | }
|
2966 | })]);
|
2967 | }
|
2968 | });
|
2969 | const TAB_STATUS_KEY = Symbol();
|
2970 | const useTabStatus = () => inject(TAB_STATUS_KEY, null);
|
2971 | const [name$1s, bem$1o] = createNamespace("tab");
|
2972 | const TabTitle = defineComponent({
|
2973 | name: name$1s,
|
2974 | props: {
|
2975 | id: String,
|
2976 | dot: Boolean,
|
2977 | type: String,
|
2978 | color: String,
|
2979 | title: String,
|
2980 | badge: numericProp,
|
2981 | shrink: Boolean,
|
2982 | isActive: Boolean,
|
2983 | disabled: Boolean,
|
2984 | controls: String,
|
2985 | scrollable: Boolean,
|
2986 | activeColor: String,
|
2987 | inactiveColor: String,
|
2988 | showZeroBadge: truthProp
|
2989 | },
|
2990 | setup(props2, {
|
2991 | slots
|
2992 | }) {
|
2993 | const style = computed(() => {
|
2994 | const style2 = {};
|
2995 | const {
|
2996 | type,
|
2997 | color,
|
2998 | disabled,
|
2999 | isActive,
|
3000 | activeColor,
|
3001 | inactiveColor
|
3002 | } = props2;
|
3003 | const isCard = type === "card";
|
3004 | if (color && isCard) {
|
3005 | style2.borderColor = color;
|
3006 | if (!disabled) {
|
3007 | if (isActive) {
|
3008 | style2.backgroundColor = color;
|
3009 | } else {
|
3010 | style2.color = color;
|
3011 | }
|
3012 | }
|
3013 | }
|
3014 | const titleColor = isActive ? activeColor : inactiveColor;
|
3015 | if (titleColor) {
|
3016 | style2.color = titleColor;
|
3017 | }
|
3018 | return style2;
|
3019 | });
|
3020 | const renderText = () => {
|
3021 | const Text2 = createVNode("span", {
|
3022 | "class": bem$1o("text", {
|
3023 | ellipsis: !props2.scrollable
|
3024 | })
|
3025 | }, [slots.title ? slots.title() : props2.title]);
|
3026 | if (props2.dot || isDef(props2.badge) && props2.badge !== "") {
|
3027 | return createVNode(Badge, {
|
3028 | "dot": props2.dot,
|
3029 | "content": props2.badge,
|
3030 | "showZero": props2.showZeroBadge
|
3031 | }, {
|
3032 | default: () => [Text2]
|
3033 | });
|
3034 | }
|
3035 | return Text2;
|
3036 | };
|
3037 | return () => createVNode("div", {
|
3038 | "id": props2.id,
|
3039 | "role": "tab",
|
3040 | "class": [bem$1o([props2.type, {
|
3041 | grow: props2.scrollable && !props2.shrink,
|
3042 | shrink: props2.shrink,
|
3043 | active: props2.isActive,
|
3044 | disabled: props2.disabled
|
3045 | }])],
|
3046 | "style": style.value,
|
3047 | "tabindex": props2.disabled ? void 0 : props2.isActive ? 0 : -1,
|
3048 | "aria-selected": props2.isActive,
|
3049 | "aria-disabled": props2.disabled || void 0,
|
3050 | "aria-controls": props2.controls
|
3051 | }, [renderText()]);
|
3052 | }
|
3053 | });
|
3054 | const [name$1r, bem$1n] = createNamespace("swipe-item");
|
3055 | var stdin_default$1C = defineComponent({
|
3056 | name: name$1r,
|
3057 | setup(props2, {
|
3058 | slots
|
3059 | }) {
|
3060 | let rendered;
|
3061 | const state = reactive({
|
3062 | offset: 0,
|
3063 | inited: false,
|
3064 | mounted: false
|
3065 | });
|
3066 | const {
|
3067 | parent,
|
3068 | index
|
3069 | } = useParent(SWIPE_KEY);
|
3070 | if (!parent) {
|
3071 | if (process.env.NODE_ENV !== "production") {
|
3072 | console.error("[Vant] <SwipeItem> must be a child component of <Swipe>.");
|
3073 | }
|
3074 | return;
|
3075 | }
|
3076 | const style = computed(() => {
|
3077 | const style2 = {};
|
3078 | const {
|
3079 | vertical
|
3080 | } = parent.props;
|
3081 | if (parent.size.value) {
|
3082 | style2[vertical ? "height" : "width"] = `${parent.size.value}px`;
|
3083 | }
|
3084 | if (state.offset) {
|
3085 | style2.transform = `translate${vertical ? "Y" : "X"}(${state.offset}px)`;
|
3086 | }
|
3087 | return style2;
|
3088 | });
|
3089 | const shouldRender = computed(() => {
|
3090 | const {
|
3091 | loop,
|
3092 | lazyRender
|
3093 | } = parent.props;
|
3094 | if (!lazyRender || rendered) {
|
3095 | return true;
|
3096 | }
|
3097 | if (!state.mounted) {
|
3098 | return false;
|
3099 | }
|
3100 | const active = parent.activeIndicator.value;
|
3101 | const maxActive = parent.count.value - 1;
|
3102 | const prevActive = active === 0 && loop ? maxActive : active - 1;
|
3103 | const nextActive = active === maxActive && loop ? 0 : active + 1;
|
3104 | rendered = index.value === active || index.value === prevActive || index.value === nextActive;
|
3105 | return rendered;
|
3106 | });
|
3107 | const setOffset = (offset) => {
|
3108 | state.offset = offset;
|
3109 | };
|
3110 | onMounted(() => {
|
3111 | nextTick(() => {
|
3112 | state.mounted = true;
|
3113 | });
|
3114 | });
|
3115 | useExpose({
|
3116 | setOffset
|
3117 | });
|
3118 | return () => {
|
3119 | var _a;
|
3120 | return createVNode("div", {
|
3121 | "class": bem$1n(),
|
3122 | "style": style.value
|
3123 | }, [shouldRender.value ? (_a = slots.default) == null ? void 0 : _a.call(slots) : null]);
|
3124 | };
|
3125 | }
|
3126 | });
|
3127 | const SwipeItem = withInstall(stdin_default$1C);
|
3128 | const [name$1q, bem$1m] = createNamespace("tab");
|
3129 | const tabProps = extend({}, routeProps, {
|
3130 | dot: Boolean,
|
3131 | name: numericProp,
|
3132 | badge: numericProp,
|
3133 | title: String,
|
3134 | disabled: Boolean,
|
3135 | titleClass: unknownProp,
|
3136 | titleStyle: [String, Object],
|
3137 | showZeroBadge: truthProp
|
3138 | });
|
3139 | var stdin_default$1B = defineComponent({
|
3140 | name: name$1q,
|
3141 | props: tabProps,
|
3142 | setup(props2, {
|
3143 | slots
|
3144 | }) {
|
3145 | const id = useId();
|
3146 | const inited = ref(false);
|
3147 | const instance2 = getCurrentInstance();
|
3148 | const {
|
3149 | parent,
|
3150 | index
|
3151 | } = useParent(TABS_KEY);
|
3152 | if (!parent) {
|
3153 | if (process.env.NODE_ENV !== "production") {
|
3154 | console.error("[Vant] <Tab> must be a child component of <Tabs>.");
|
3155 | }
|
3156 | return;
|
3157 | }
|
3158 | const getName = () => {
|
3159 | var _a;
|
3160 | return (_a = props2.name) != null ? _a : index.value;
|
3161 | };
|
3162 | const init = () => {
|
3163 | inited.value = true;
|
3164 | if (parent.props.lazyRender) {
|
3165 | nextTick(() => {
|
3166 | parent.onRendered(getName(), props2.title);
|
3167 | });
|
3168 | }
|
3169 | };
|
3170 | const active = computed(() => {
|
3171 | const isActive = getName() === parent.currentName.value;
|
3172 | if (isActive && !inited.value) {
|
3173 | init();
|
3174 | }
|
3175 | return isActive;
|
3176 | });
|
3177 | const parsedClass = ref("");
|
3178 | const parsedStyle = ref("");
|
3179 | watchEffect(() => {
|
3180 | const {
|
3181 | titleClass,
|
3182 | titleStyle
|
3183 | } = props2;
|
3184 | parsedClass.value = titleClass ? normalizeClass(titleClass) : "";
|
3185 | parsedStyle.value = titleStyle && typeof titleStyle !== "string" ? stringifyStyle(normalizeStyle(titleStyle)) : titleStyle;
|
3186 | });
|
3187 | const renderTitle = (onClickTab) => createVNode(TabTitle, mergeProps({
|
3188 | "key": id,
|
3189 | "id": `${parent.id}-${index.value}`,
|
3190 | "ref": parent.setTitleRefs(index.value),
|
3191 | "style": parsedStyle.value,
|
3192 | "class": parsedClass.value,
|
3193 | "isActive": active.value,
|
3194 | "controls": id,
|
3195 | "scrollable": parent.scrollable.value,
|
3196 | "activeColor": parent.props.titleActiveColor,
|
3197 | "inactiveColor": parent.props.titleInactiveColor,
|
3198 | "onClick": (event) => onClickTab(instance2.proxy, index.value, event)
|
3199 | }, pick(parent.props, ["type", "color", "shrink"]), pick(props2, ["dot", "badge", "title", "disabled", "showZeroBadge"])), {
|
3200 | title: slots.title
|
3201 | });
|
3202 | const hasInactiveClass = ref(!active.value);
|
3203 | watch(active, (val) => {
|
3204 | if (val) {
|
3205 | hasInactiveClass.value = false;
|
3206 | } else {
|
3207 | doubleRaf(() => {
|
3208 | hasInactiveClass.value = true;
|
3209 | });
|
3210 | }
|
3211 | });
|
3212 | watch(() => props2.title, () => {
|
3213 | parent.setLine();
|
3214 | parent.scrollIntoView();
|
3215 | });
|
3216 | provide(TAB_STATUS_KEY, active);
|
3217 | useExpose({
|
3218 | id,
|
3219 | renderTitle
|
3220 | });
|
3221 | return () => {
|
3222 | var _a;
|
3223 | const label = `${parent.id}-${index.value}`;
|
3224 | const {
|
3225 | animated,
|
3226 | swipeable,
|
3227 | scrollspy,
|
3228 | lazyRender
|
3229 | } = parent.props;
|
3230 | if (!slots.default && !animated) {
|
3231 | return;
|
3232 | }
|
3233 | const show = scrollspy || active.value;
|
3234 | if (animated || swipeable) {
|
3235 | return createVNode(SwipeItem, {
|
3236 | "id": id,
|
3237 | "role": "tabpanel",
|
3238 | "class": bem$1m("panel-wrapper", {
|
3239 | inactive: hasInactiveClass.value
|
3240 | }),
|
3241 | "tabindex": active.value ? 0 : -1,
|
3242 | "aria-hidden": !active.value,
|
3243 | "aria-labelledby": label
|
3244 | }, {
|
3245 | default: () => {
|
3246 | var _a2;
|
3247 | return [createVNode("div", {
|
3248 | "class": bem$1m("panel")
|
3249 | }, [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)])];
|
3250 | }
|
3251 | });
|
3252 | }
|
3253 | const shouldRender = inited.value || scrollspy || !lazyRender;
|
3254 | const Content = shouldRender ? (_a = slots.default) == null ? void 0 : _a.call(slots) : null;
|
3255 | return withDirectives(createVNode("div", {
|
3256 | "id": id,
|
3257 | "role": "tabpanel",
|
3258 | "class": bem$1m("panel"),
|
3259 | "tabindex": show ? 0 : -1,
|
3260 | "aria-labelledby": label
|
3261 | }, [Content]), [[vShow, show]]);
|
3262 | };
|
3263 | }
|
3264 | });
|
3265 | const Tab = withInstall(stdin_default$1B);
|
3266 | const Tabs = withInstall(stdin_default$1D);
|
3267 | const [name$1p, bem$1l] = createNamespace("picker-group");
|
3268 | const PICKER_GROUP_KEY = Symbol(name$1p);
|
3269 | const pickerGroupProps = extend({
|
3270 | tabs: makeArrayProp(),
|
3271 | activeTab: makeNumericProp(0),
|
3272 | nextStepText: String
|
3273 | }, pickerToolbarProps);
|
3274 | var stdin_default$1A = defineComponent({
|
3275 | name: name$1p,
|
3276 | props: pickerGroupProps,
|
3277 | emits: ["confirm", "cancel", "update:activeTab"],
|
3278 | setup(props2, {
|
3279 | emit,
|
3280 | slots
|
3281 | }) {
|
3282 | const activeTab = useSyncPropRef(() => props2.activeTab, (value) => emit("update:activeTab", value));
|
3283 | const {
|
3284 | children,
|
3285 | linkChildren
|
3286 | } = useChildren(PICKER_GROUP_KEY);
|
3287 | linkChildren();
|
3288 | const showNextButton = () => +activeTab.value < props2.tabs.length - 1 && props2.nextStepText;
|
3289 | const onConfirm = () => {
|
3290 | if (showNextButton()) {
|
3291 | activeTab.value = +activeTab.value + 1;
|
3292 | } else {
|
3293 | emit("confirm", children.map((item) => item.confirm()));
|
3294 | }
|
3295 | };
|
3296 | const onCancel = () => emit("cancel");
|
3297 | return () => {
|
3298 | var _a, _b;
|
3299 | const childNodes = (_b = (_a = slots.default) == null ? void 0 : _a.call(slots)) == null ? void 0 : _b.filter((node) => node.type !== Comment);
|
3300 | const confirmButtonText = showNextButton() ? props2.nextStepText : props2.confirmButtonText;
|
3301 | return createVNode("div", {
|
3302 | "class": bem$1l()
|
3303 | }, [createVNode(stdin_default$1H, {
|
3304 | "title": props2.title,
|
3305 | "cancelButtonText": props2.cancelButtonText,
|
3306 | "confirmButtonText": confirmButtonText,
|
3307 | "onConfirm": onConfirm,
|
3308 | "onCancel": onCancel
|
3309 | }, pick(slots, pickerToolbarSlots)), createVNode(Tabs, {
|
3310 | "active": activeTab.value,
|
3311 | "onUpdate:active": ($event) => activeTab.value = $event,
|
3312 | "class": bem$1l("tabs"),
|
3313 | "shrink": true,
|
3314 | "animated": true,
|
3315 | "lazyRender": false
|
3316 | }, {
|
3317 | default: () => [props2.tabs.map((title, index) => createVNode(Tab, {
|
3318 | "title": title,
|
3319 | "titleClass": bem$1l("tab-title")
|
3320 | }, {
|
3321 | default: () => [childNodes == null ? void 0 : childNodes[index]]
|
3322 | }))]
|
3323 | })]);
|
3324 | };
|
3325 | }
|
3326 | });
|
3327 | const pickerSharedProps = extend({
|
3328 | loading: Boolean,
|
3329 | readonly: Boolean,
|
3330 | allowHtml: Boolean,
|
3331 | optionHeight: makeNumericProp(44),
|
3332 | showToolbar: truthProp,
|
3333 | swipeDuration: makeNumericProp(1e3),
|
3334 | visibleOptionNum: makeNumericProp(6)
|
3335 | }, pickerToolbarProps);
|
3336 | const pickerProps = extend({}, pickerSharedProps, {
|
3337 | columns: makeArrayProp(),
|
3338 | modelValue: makeArrayProp(),
|
3339 | toolbarPosition: makeStringProp("top"),
|
3340 | columnsFieldNames: Object
|
3341 | });
|
3342 | var stdin_default$1z = defineComponent({
|
3343 | name: name$1z,
|
3344 | props: pickerProps,
|
3345 | emits: ["confirm", "cancel", "change", "scrollInto", "clickOption", "update:modelValue"],
|
3346 | setup(props2, {
|
3347 | emit,
|
3348 | slots
|
3349 | }) {
|
3350 | const columnsRef = ref();
|
3351 | const selectedValues = ref(props2.modelValue.slice(0));
|
3352 | const {
|
3353 | parent
|
3354 | } = useParent(PICKER_GROUP_KEY);
|
3355 | const {
|
3356 | children,
|
3357 | linkChildren
|
3358 | } = useChildren(PICKER_KEY);
|
3359 | linkChildren();
|
3360 | const fields = computed(() => assignDefaultFields(props2.columnsFieldNames));
|
3361 | const optionHeight = computed(() => unitToPx(props2.optionHeight));
|
3362 | const columnsType = computed(() => getColumnsType(props2.columns, fields.value));
|
3363 | const currentColumns = computed(() => {
|
3364 | const {
|
3365 | columns
|
3366 | } = props2;
|
3367 | switch (columnsType.value) {
|
3368 | case "multiple":
|
3369 | return columns;
|
3370 | case "cascade":
|
3371 | return formatCascadeColumns(columns, fields.value, selectedValues);
|
3372 | default:
|
3373 | return [columns];
|
3374 | }
|
3375 | });
|
3376 | const hasOptions = computed(() => currentColumns.value.some((options) => options.length));
|
3377 | const selectedOptions = computed(() => currentColumns.value.map((options, index) => findOptionByValue(options, selectedValues.value[index], fields.value)));
|
3378 | const selectedIndexes = computed(() => currentColumns.value.map((options, index) => options.findIndex((option) => option[fields.value.value] === selectedValues.value[index])));
|
3379 | const setValue = (index, value) => {
|
3380 | if (selectedValues.value[index] !== value) {
|
3381 | const newValues = selectedValues.value.slice(0);
|
3382 | newValues[index] = value;
|
3383 | selectedValues.value = newValues;
|
3384 | }
|
3385 | };
|
3386 | const getEventParams = () => ({
|
3387 | selectedValues: selectedValues.value.slice(0),
|
3388 | selectedOptions: selectedOptions.value,
|
3389 | selectedIndexes: selectedIndexes.value
|
3390 | });
|
3391 | const onChange = (value, columnIndex) => {
|
3392 | setValue(columnIndex, value);
|
3393 | if (columnsType.value === "cascade") {
|
3394 | selectedValues.value.forEach((value2, index) => {
|
3395 | const options = currentColumns.value[index];
|
3396 | if (!isOptionExist(options, value2, fields.value)) {
|
3397 | setValue(index, options.length ? options[0][fields.value.value] : void 0);
|
3398 | }
|
3399 | });
|
3400 | }
|
3401 | nextTick(() => {
|
3402 | emit("change", extend({
|
3403 | columnIndex
|
3404 | }, getEventParams()));
|
3405 | });
|
3406 | };
|
3407 | const onClickOption = (currentOption, columnIndex) => {
|
3408 | const params = {
|
3409 | columnIndex,
|
3410 | currentOption
|
3411 | };
|
3412 | emit("clickOption", extend(getEventParams(), params));
|
3413 | emit("scrollInto", params);
|
3414 | };
|
3415 | const confirm = () => {
|
3416 | children.forEach((child) => child.stopMomentum());
|
3417 | const params = getEventParams();
|
3418 | nextTick(() => {
|
3419 | emit("confirm", params);
|
3420 | });
|
3421 | return params;
|
3422 | };
|
3423 | const cancel = () => emit("cancel", getEventParams());
|
3424 | const renderColumnItems = () => currentColumns.value.map((options, columnIndex) => createVNode(stdin_default$1I, {
|
3425 | "value": selectedValues.value[columnIndex],
|
3426 | "fields": fields.value,
|
3427 | "options": options,
|
3428 | "readonly": props2.readonly,
|
3429 | "allowHtml": props2.allowHtml,
|
3430 | "optionHeight": optionHeight.value,
|
3431 | "swipeDuration": props2.swipeDuration,
|
3432 | "visibleOptionNum": props2.visibleOptionNum,
|
3433 | "onChange": (value) => onChange(value, columnIndex),
|
3434 | "onClickOption": (option) => onClickOption(option, columnIndex),
|
3435 | "onScrollInto": (option) => {
|
3436 | emit("scrollInto", {
|
3437 | currentOption: option,
|
3438 | columnIndex
|
3439 | });
|
3440 | }
|
3441 | }, {
|
3442 | option: slots.option
|
3443 | }));
|
3444 | const renderMask = (wrapHeight) => {
|
3445 | if (hasOptions.value) {
|
3446 | const frameStyle = {
|
3447 | height: `${optionHeight.value}px`
|
3448 | };
|
3449 | const maskStyle = {
|
3450 | backgroundSize: `100% ${(wrapHeight - optionHeight.value) / 2}px`
|
3451 | };
|
3452 | return [createVNode("div", {
|
3453 | "class": bem$1u("mask"),
|
3454 | "style": maskStyle
|
3455 | }, null), createVNode("div", {
|
3456 | "class": [BORDER_UNSET_TOP_BOTTOM, bem$1u("frame")],
|
3457 | "style": frameStyle
|
3458 | }, null)];
|
3459 | }
|
3460 | };
|
3461 | const renderColumns = () => {
|
3462 | const wrapHeight = optionHeight.value * +props2.visibleOptionNum;
|
3463 | const columnsStyle = {
|
3464 | height: `${wrapHeight}px`
|
3465 | };
|
3466 | return createVNode("div", {
|
3467 | "ref": columnsRef,
|
3468 | "class": bem$1u("columns"),
|
3469 | "style": columnsStyle
|
3470 | }, [renderColumnItems(), renderMask(wrapHeight)]);
|
3471 | };
|
3472 | const renderToolbar = () => {
|
3473 | if (props2.showToolbar && !parent) {
|
3474 | return createVNode(stdin_default$1H, mergeProps(pick(props2, pickerToolbarPropKeys), {
|
3475 | "onConfirm": confirm,
|
3476 | "onCancel": cancel
|
3477 | }), pick(slots, pickerToolbarSlots));
|
3478 | }
|
3479 | };
|
3480 | watch(currentColumns, (columns) => {
|
3481 | columns.forEach((options, index) => {
|
3482 | if (options.length && !isOptionExist(options, selectedValues.value[index], fields.value)) {
|
3483 | setValue(index, getFirstEnabledOption(options)[fields.value.value]);
|
3484 | }
|
3485 | });
|
3486 | }, {
|
3487 | immediate: true
|
3488 | });
|
3489 | let lastEmittedModelValue;
|
3490 | watch(() => props2.modelValue, (newValues) => {
|
3491 | if (!isSameValue(newValues, selectedValues.value) && !isSameValue(newValues, lastEmittedModelValue)) {
|
3492 | selectedValues.value = newValues.slice(0);
|
3493 | lastEmittedModelValue = newValues.slice(0);
|
3494 | }
|
3495 | }, {
|
3496 | deep: true
|
3497 | });
|
3498 | watch(selectedValues, (newValues) => {
|
3499 | if (!isSameValue(newValues, props2.modelValue)) {
|
3500 | lastEmittedModelValue = newValues.slice(0);
|
3501 | emit("update:modelValue", lastEmittedModelValue);
|
3502 | }
|
3503 | }, {
|
3504 | immediate: true
|
3505 | });
|
3506 | useEventListener("touchmove", preventDefault, {
|
3507 | target: columnsRef
|
3508 | });
|
3509 | const getSelectedOptions = () => selectedOptions.value;
|
3510 | useExpose({
|
3511 | confirm,
|
3512 | getSelectedOptions
|
3513 | });
|
3514 | return () => {
|
3515 | var _a, _b;
|
3516 | return createVNode("div", {
|
3517 | "class": bem$1u()
|
3518 | }, [props2.toolbarPosition === "top" ? renderToolbar() : null, props2.loading ? createVNode(Loading, {
|
3519 | "class": bem$1u("loading")
|
3520 | }, 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]);
|
3521 | };
|
3522 | }
|
3523 | });
|
3524 | const AREA_EMPTY_CODE = "000000";
|
3525 | const INHERIT_SLOTS = [
|
3526 | "title",
|
3527 | "cancel",
|
3528 | "confirm",
|
3529 | "toolbar",
|
3530 | "columns-top",
|
3531 | "columns-bottom"
|
3532 | ];
|
3533 | const INHERIT_PROPS = [
|
3534 | "title",
|
3535 | "loading",
|
3536 | "readonly",
|
3537 | "optionHeight",
|
3538 | "swipeDuration",
|
3539 | "visibleOptionNum",
|
3540 | "cancelButtonText",
|
3541 | "confirmButtonText"
|
3542 | ];
|
3543 | const makeOption = (text = "", value = AREA_EMPTY_CODE, children = void 0) => ({
|
3544 | text,
|
3545 | value,
|
3546 | children
|
3547 | });
|
3548 | function formatDataForCascade({
|
3549 | areaList,
|
3550 | columnsNum,
|
3551 | columnsPlaceholder: placeholder
|
3552 | }) {
|
3553 | const {
|
3554 | city_list: city = {},
|
3555 | county_list: county = {},
|
3556 | province_list: province = {}
|
3557 | } = areaList;
|
3558 | const showCity = +columnsNum > 1;
|
3559 | const showCounty = +columnsNum > 2;
|
3560 | const getProvinceChildren = () => {
|
3561 | if (showCity) {
|
3562 | return placeholder.length ? [
|
3563 | makeOption(
|
3564 | placeholder[0],
|
3565 | AREA_EMPTY_CODE,
|
3566 | showCounty ? [] : void 0
|
3567 | )
|
3568 | ] : [];
|
3569 | }
|
3570 | };
|
3571 | const provinceMap = new Map();
|
3572 | Object.keys(province).forEach((code) => {
|
3573 | provinceMap.set(
|
3574 | code.slice(0, 2),
|
3575 | makeOption(province[code], code, getProvinceChildren())
|
3576 | );
|
3577 | });
|
3578 | const cityMap = new Map();
|
3579 | if (showCity) {
|
3580 | const getCityChildren = () => {
|
3581 | if (showCounty) {
|
3582 | return placeholder.length ? [makeOption(placeholder[1])] : [];
|
3583 | }
|
3584 | };
|
3585 | Object.keys(city).forEach((code) => {
|
3586 | const option = makeOption(city[code], code, getCityChildren());
|
3587 | cityMap.set(code.slice(0, 4), option);
|
3588 | const province2 = provinceMap.get(code.slice(0, 2));
|
3589 | if (province2) {
|
3590 | province2.children.push(option);
|
3591 | }
|
3592 | });
|
3593 | }
|
3594 | if (showCounty) {
|
3595 | Object.keys(county).forEach((code) => {
|
3596 | const city2 = cityMap.get(code.slice(0, 4));
|
3597 | if (city2) {
|
3598 | city2.children.push(makeOption(county[code], code));
|
3599 | }
|
3600 | });
|
3601 | }
|
3602 | const options = Array.from(provinceMap.values());
|
3603 | if (placeholder.length) {
|
3604 | const county2 = showCounty ? [makeOption(placeholder[2])] : void 0;
|
3605 | const city2 = showCity ? [makeOption(placeholder[1], AREA_EMPTY_CODE, county2)] : void 0;
|
3606 | options.unshift(makeOption(placeholder[0], AREA_EMPTY_CODE, city2));
|
3607 | }
|
3608 | return options;
|
3609 | }
|
3610 | const Picker = withInstall(stdin_default$1z);
|
3611 | const [name$1o, bem$1k] = createNamespace("area");
|
3612 | const areaProps = extend({}, pick(pickerSharedProps, INHERIT_PROPS), {
|
3613 | modelValue: String,
|
3614 | columnsNum: makeNumericProp(3),
|
3615 | columnsPlaceholder: makeArrayProp(),
|
3616 | areaList: {
|
3617 | type: Object,
|
3618 | default: () => ({})
|
3619 | }
|
3620 | });
|
3621 | var stdin_default$1y = defineComponent({
|
3622 | name: name$1o,
|
3623 | props: areaProps,
|
3624 | emits: ["change", "confirm", "cancel", "update:modelValue"],
|
3625 | setup(props2, {
|
3626 | emit,
|
3627 | slots
|
3628 | }) {
|
3629 | const codes = ref([]);
|
3630 | const picker = ref();
|
3631 | const columns = computed(() => formatDataForCascade(props2));
|
3632 | const onChange = (...args) => emit("change", ...args);
|
3633 | const onCancel = (...args) => emit("cancel", ...args);
|
3634 | const onConfirm = (...args) => emit("confirm", ...args);
|
3635 | watch(codes, (newCodes) => {
|
3636 | const lastCode = newCodes.length ? newCodes[newCodes.length - 1] : "";
|
3637 | if (lastCode && lastCode !== props2.modelValue) {
|
3638 | emit("update:modelValue", lastCode);
|
3639 | }
|
3640 | }, {
|
3641 | deep: true
|
3642 | });
|
3643 | watch(() => props2.modelValue, (newCode) => {
|
3644 | if (newCode) {
|
3645 | const lastCode = codes.value.length ? codes.value[codes.value.length - 1] : "";
|
3646 | if (newCode !== lastCode) {
|
3647 | codes.value = [`${newCode.slice(0, 2)}0000`, `${newCode.slice(0, 4)}00`, newCode].slice(0, +props2.columnsNum);
|
3648 | }
|
3649 | } else {
|
3650 | codes.value = [];
|
3651 | }
|
3652 | }, {
|
3653 | immediate: true
|
3654 | });
|
3655 | useExpose({
|
3656 | confirm: () => {
|
3657 | var _a;
|
3658 | return (_a = picker.value) == null ? void 0 : _a.confirm();
|
3659 | },
|
3660 | getSelectedOptions: () => {
|
3661 | var _a;
|
3662 | return ((_a = picker.value) == null ? void 0 : _a.getSelectedOptions()) || [];
|
3663 | }
|
3664 | });
|
3665 | return () => createVNode(Picker, mergeProps({
|
3666 | "ref": picker,
|
3667 | "modelValue": codes.value,
|
3668 | "onUpdate:modelValue": ($event) => codes.value = $event,
|
3669 | "class": bem$1k(),
|
3670 | "columns": columns.value,
|
3671 | "onChange": onChange,
|
3672 | "onCancel": onCancel,
|
3673 | "onConfirm": onConfirm
|
3674 | }, pick(props2, INHERIT_PROPS)), pick(slots, INHERIT_SLOTS));
|
3675 | }
|
3676 | });
|
3677 | const Area = withInstall(stdin_default$1y);
|
3678 | const [name$1n, bem$1j] = createNamespace("cell");
|
3679 | const cellSharedProps = {
|
3680 | tag: makeStringProp("div"),
|
3681 | icon: String,
|
3682 | size: String,
|
3683 | title: numericProp,
|
3684 | value: numericProp,
|
3685 | label: numericProp,
|
3686 | center: Boolean,
|
3687 | isLink: Boolean,
|
3688 | border: truthProp,
|
3689 | iconPrefix: String,
|
3690 | valueClass: unknownProp,
|
3691 | labelClass: unknownProp,
|
3692 | titleClass: unknownProp,
|
3693 | titleStyle: null,
|
3694 | arrowDirection: String,
|
3695 | required: {
|
3696 | type: [Boolean, String],
|
3697 | default: null
|
3698 | },
|
3699 | clickable: {
|
3700 | type: Boolean,
|
3701 | default: null
|
3702 | }
|
3703 | };
|
3704 | const cellProps = extend({}, cellSharedProps, routeProps);
|
3705 | var stdin_default$1x = defineComponent({
|
3706 | name: name$1n,
|
3707 | props: cellProps,
|
3708 | setup(props2, {
|
3709 | slots
|
3710 | }) {
|
3711 | const route2 = useRoute();
|
3712 | const renderLabel = () => {
|
3713 | const showLabel = slots.label || isDef(props2.label);
|
3714 | if (showLabel) {
|
3715 | return createVNode("div", {
|
3716 | "class": [bem$1j("label"), props2.labelClass]
|
3717 | }, [slots.label ? slots.label() : props2.label]);
|
3718 | }
|
3719 | };
|
3720 | const renderTitle = () => {
|
3721 | var _a;
|
3722 | if (slots.title || isDef(props2.title)) {
|
3723 | const titleSlot = (_a = slots.title) == null ? void 0 : _a.call(slots);
|
3724 | if (Array.isArray(titleSlot) && titleSlot.length === 0) {
|
3725 | return;
|
3726 | }
|
3727 | return createVNode("div", {
|
3728 | "class": [bem$1j("title"), props2.titleClass],
|
3729 | "style": props2.titleStyle
|
3730 | }, [titleSlot || createVNode("span", null, [props2.title]), renderLabel()]);
|
3731 | }
|
3732 | };
|
3733 | const renderValue = () => {
|
3734 | const slot = slots.value || slots.default;
|
3735 | const hasValue = slot || isDef(props2.value);
|
3736 | if (hasValue) {
|
3737 | return createVNode("div", {
|
3738 | "class": [bem$1j("value"), props2.valueClass]
|
3739 | }, [slot ? slot() : createVNode("span", null, [props2.value])]);
|
3740 | }
|
3741 | };
|
3742 | const renderLeftIcon = () => {
|
3743 | if (slots.icon) {
|
3744 | return slots.icon();
|
3745 | }
|
3746 | if (props2.icon) {
|
3747 | return createVNode(Icon, {
|
3748 | "name": props2.icon,
|
3749 | "class": bem$1j("left-icon"),
|
3750 | "classPrefix": props2.iconPrefix
|
3751 | }, null);
|
3752 | }
|
3753 | };
|
3754 | const renderRightIcon = () => {
|
3755 | if (slots["right-icon"]) {
|
3756 | return slots["right-icon"]();
|
3757 | }
|
3758 | if (props2.isLink) {
|
3759 | const name2 = props2.arrowDirection && props2.arrowDirection !== "right" ? `arrow-${props2.arrowDirection}` : "arrow";
|
3760 | return createVNode(Icon, {
|
3761 | "name": name2,
|
3762 | "class": bem$1j("right-icon")
|
3763 | }, null);
|
3764 | }
|
3765 | };
|
3766 | return () => {
|
3767 | var _a;
|
3768 | const {
|
3769 | tag,
|
3770 | size,
|
3771 | center,
|
3772 | border,
|
3773 | isLink,
|
3774 | required
|
3775 | } = props2;
|
3776 | const clickable = (_a = props2.clickable) != null ? _a : isLink;
|
3777 | const classes = {
|
3778 | center,
|
3779 | required: !!required,
|
3780 | clickable,
|
3781 | borderless: !border
|
3782 | };
|
3783 | if (size) {
|
3784 | classes[size] = !!size;
|
3785 | }
|
3786 | return createVNode(tag, {
|
3787 | "class": bem$1j(classes),
|
3788 | "role": clickable ? "button" : void 0,
|
3789 | "tabindex": clickable ? 0 : void 0,
|
3790 | "onClick": route2
|
3791 | }, {
|
3792 | default: () => {
|
3793 | var _a2;
|
3794 | return [renderLeftIcon(), renderTitle(), renderValue(), renderRightIcon(), (_a2 = slots.extra) == null ? void 0 : _a2.call(slots)];
|
3795 | }
|
3796 | });
|
3797 | };
|
3798 | }
|
3799 | });
|
3800 | const Cell = withInstall(stdin_default$1x);
|
3801 | const [name$1m, bem$1i] = createNamespace("form");
|
3802 | const formProps = {
|
3803 | colon: Boolean,
|
3804 | disabled: Boolean,
|
3805 | readonly: Boolean,
|
3806 | required: [Boolean, String],
|
3807 | showError: Boolean,
|
3808 | labelWidth: numericProp,
|
3809 | labelAlign: String,
|
3810 | inputAlign: String,
|
3811 | scrollToError: Boolean,
|
3812 | validateFirst: Boolean,
|
3813 | submitOnEnter: truthProp,
|
3814 | showErrorMessage: truthProp,
|
3815 | errorMessageAlign: String,
|
3816 | validateTrigger: {
|
3817 | type: [String, Array],
|
3818 | default: "onBlur"
|
3819 | }
|
3820 | };
|
3821 | var stdin_default$1w = defineComponent({
|
3822 | name: name$1m,
|
3823 | props: formProps,
|
3824 | emits: ["submit", "failed"],
|
3825 | setup(props2, {
|
3826 | emit,
|
3827 | slots
|
3828 | }) {
|
3829 | const {
|
3830 | children,
|
3831 | linkChildren
|
3832 | } = useChildren(FORM_KEY);
|
3833 | const getFieldsByNames = (names) => {
|
3834 | if (names) {
|
3835 | return children.filter((field) => names.includes(field.name));
|
3836 | }
|
3837 | return children;
|
3838 | };
|
3839 | const validateSeq = (names) => new Promise((resolve, reject) => {
|
3840 | const errors = [];
|
3841 | const fields = getFieldsByNames(names);
|
3842 | fields.reduce((promise, field) => promise.then(() => {
|
3843 | if (!errors.length) {
|
3844 | return field.validate().then((error) => {
|
3845 | if (error) {
|
3846 | errors.push(error);
|
3847 | }
|
3848 | });
|
3849 | }
|
3850 | }), Promise.resolve()).then(() => {
|
3851 | if (errors.length) {
|
3852 | reject(errors);
|
3853 | } else {
|
3854 | resolve();
|
3855 | }
|
3856 | });
|
3857 | });
|
3858 | const validateAll = (names) => new Promise((resolve, reject) => {
|
3859 | const fields = getFieldsByNames(names);
|
3860 | Promise.all(fields.map((item) => item.validate())).then((errors) => {
|
3861 | errors = errors.filter(Boolean);
|
3862 | if (errors.length) {
|
3863 | reject(errors);
|
3864 | } else {
|
3865 | resolve();
|
3866 | }
|
3867 | });
|
3868 | });
|
3869 | const validateField = (name2) => {
|
3870 | const matched = children.find((item) => item.name === name2);
|
3871 | if (matched) {
|
3872 | return new Promise((resolve, reject) => {
|
3873 | matched.validate().then((error) => {
|
3874 | if (error) {
|
3875 | reject(error);
|
3876 | } else {
|
3877 | resolve();
|
3878 | }
|
3879 | });
|
3880 | });
|
3881 | }
|
3882 | return Promise.reject();
|
3883 | };
|
3884 | const validate = (name2) => {
|
3885 | if (typeof name2 === "string") {
|
3886 | return validateField(name2);
|
3887 | }
|
3888 | return props2.validateFirst ? validateSeq(name2) : validateAll(name2);
|
3889 | };
|
3890 | const resetValidation = (name2) => {
|
3891 | if (typeof name2 === "string") {
|
3892 | name2 = [name2];
|
3893 | }
|
3894 | const fields = getFieldsByNames(name2);
|
3895 | fields.forEach((item) => {
|
3896 | item.resetValidation();
|
3897 | });
|
3898 | };
|
3899 | const getValidationStatus = () => children.reduce((form, field) => {
|
3900 | form[field.name] = field.getValidationStatus();
|
3901 | return form;
|
3902 | }, {});
|
3903 | const scrollToField = (name2, options) => {
|
3904 | children.some((item) => {
|
3905 | if (item.name === name2) {
|
3906 | item.$el.scrollIntoView(options);
|
3907 | return true;
|
3908 | }
|
3909 | return false;
|
3910 | });
|
3911 | };
|
3912 | const getValues = () => children.reduce((form, field) => {
|
3913 | if (field.name !== void 0) {
|
3914 | form[field.name] = field.formValue.value;
|
3915 | }
|
3916 | return form;
|
3917 | }, {});
|
3918 | const submit = () => {
|
3919 | const values = getValues();
|
3920 | validate().then(() => emit("submit", values)).catch((errors) => {
|
3921 | emit("failed", {
|
3922 | values,
|
3923 | errors
|
3924 | });
|
3925 | if (props2.scrollToError && errors[0].name) {
|
3926 | scrollToField(errors[0].name);
|
3927 | }
|
3928 | });
|
3929 | };
|
3930 | const onSubmit = (event) => {
|
3931 | preventDefault(event);
|
3932 | submit();
|
3933 | };
|
3934 | linkChildren({
|
3935 | props: props2
|
3936 | });
|
3937 | useExpose({
|
3938 | submit,
|
3939 | validate,
|
3940 | getValues,
|
3941 | scrollToField,
|
3942 | resetValidation,
|
3943 | getValidationStatus
|
3944 | });
|
3945 | return () => {
|
3946 | var _a;
|
3947 | return createVNode("form", {
|
3948 | "class": bem$1i(),
|
3949 | "onSubmit": onSubmit
|
3950 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
3951 | };
|
3952 | }
|
3953 | });
|
3954 | const Form = withInstall(stdin_default$1w);
|
3955 | function isEmptyValue(value) {
|
3956 | if (Array.isArray(value)) {
|
3957 | return !value.length;
|
3958 | }
|
3959 | if (value === 0) {
|
3960 | return false;
|
3961 | }
|
3962 | return !value;
|
3963 | }
|
3964 | function runSyncRule(value, rule) {
|
3965 | if (isEmptyValue(value)) {
|
3966 | if (rule.required) {
|
3967 | return false;
|
3968 | }
|
3969 | if (rule.validateEmpty === false) {
|
3970 | return true;
|
3971 | }
|
3972 | }
|
3973 | if (rule.pattern && !rule.pattern.test(String(value))) {
|
3974 | return false;
|
3975 | }
|
3976 | return true;
|
3977 | }
|
3978 | function runRuleValidator(value, rule) {
|
3979 | return new Promise((resolve) => {
|
3980 | const returnVal = rule.validator(value, rule);
|
3981 | if (isPromise(returnVal)) {
|
3982 | returnVal.then(resolve);
|
3983 | return;
|
3984 | }
|
3985 | resolve(returnVal);
|
3986 | });
|
3987 | }
|
3988 | function getRuleMessage(value, rule) {
|
3989 | const { message } = rule;
|
3990 | if (isFunction(message)) {
|
3991 | return message(value, rule);
|
3992 | }
|
3993 | return message || "";
|
3994 | }
|
3995 | function startComposing({ target }) {
|
3996 | target.composing = true;
|
3997 | }
|
3998 | function endComposing({ target }) {
|
3999 | if (target.composing) {
|
4000 | target.composing = false;
|
4001 | target.dispatchEvent(new Event("input"));
|
4002 | }
|
4003 | }
|
4004 | function resizeTextarea(input, autosize) {
|
4005 | const scrollTop = getRootScrollTop();
|
4006 | input.style.height = "auto";
|
4007 | let height = input.scrollHeight;
|
4008 | if (isObject(autosize)) {
|
4009 | const { maxHeight, minHeight } = autosize;
|
4010 | if (maxHeight !== void 0) {
|
4011 | height = Math.min(height, maxHeight);
|
4012 | }
|
4013 | if (minHeight !== void 0) {
|
4014 | height = Math.max(height, minHeight);
|
4015 | }
|
4016 | }
|
4017 | if (height) {
|
4018 | input.style.height = `${height}px`;
|
4019 | setRootScrollTop(scrollTop);
|
4020 | }
|
4021 | }
|
4022 | function mapInputType(type) {
|
4023 | if (type === "number") {
|
4024 | return {
|
4025 | type: "text",
|
4026 | inputmode: "decimal"
|
4027 | };
|
4028 | }
|
4029 | if (type === "digit") {
|
4030 | return {
|
4031 | type: "tel",
|
4032 | inputmode: "numeric"
|
4033 | };
|
4034 | }
|
4035 | return { type };
|
4036 | }
|
4037 | function getStringLength(str) {
|
4038 | return [...str].length;
|
4039 | }
|
4040 | function cutString(str, maxlength) {
|
4041 | return [...str].slice(0, maxlength).join("");
|
4042 | }
|
4043 | const [name$1l, bem$1h] = createNamespace("field");
|
4044 | const fieldSharedProps = {
|
4045 | id: String,
|
4046 | name: String,
|
4047 | leftIcon: String,
|
4048 | rightIcon: String,
|
4049 | autofocus: Boolean,
|
4050 | clearable: Boolean,
|
4051 | maxlength: numericProp,
|
4052 | formatter: Function,
|
4053 | clearIcon: makeStringProp("clear"),
|
4054 | modelValue: makeNumericProp(""),
|
4055 | inputAlign: String,
|
4056 | placeholder: String,
|
4057 | autocomplete: String,
|
4058 | autocapitalize: String,
|
4059 | autocorrect: String,
|
4060 | errorMessage: String,
|
4061 | enterkeyhint: String,
|
4062 | clearTrigger: makeStringProp("focus"),
|
4063 | formatTrigger: makeStringProp("onChange"),
|
4064 | spellcheck: {
|
4065 | type: Boolean,
|
4066 | default: null
|
4067 | },
|
4068 | error: {
|
4069 | type: Boolean,
|
4070 | default: null
|
4071 | },
|
4072 | disabled: {
|
4073 | type: Boolean,
|
4074 | default: null
|
4075 | },
|
4076 | readonly: {
|
4077 | type: Boolean,
|
4078 | default: null
|
4079 | }
|
4080 | };
|
4081 | const fieldProps = extend({}, cellSharedProps, fieldSharedProps, {
|
4082 | rows: numericProp,
|
4083 | type: makeStringProp("text"),
|
4084 | rules: Array,
|
4085 | autosize: [Boolean, Object],
|
4086 | labelWidth: numericProp,
|
4087 | labelClass: unknownProp,
|
4088 | labelAlign: String,
|
4089 | showWordLimit: Boolean,
|
4090 | errorMessageAlign: String,
|
4091 | colon: {
|
4092 | type: Boolean,
|
4093 | default: null
|
4094 | }
|
4095 | });
|
4096 | var stdin_default$1v = defineComponent({
|
4097 | name: name$1l,
|
4098 | props: fieldProps,
|
4099 | emits: ["blur", "focus", "clear", "keypress", "clickInput", "endValidate", "startValidate", "clickLeftIcon", "clickRightIcon", "update:modelValue"],
|
4100 | setup(props2, {
|
4101 | emit,
|
4102 | slots
|
4103 | }) {
|
4104 | const id = useId();
|
4105 | const state = reactive({
|
4106 | status: "unvalidated",
|
4107 | focused: false,
|
4108 | validateMessage: ""
|
4109 | });
|
4110 | const inputRef = ref();
|
4111 | const clearIconRef = ref();
|
4112 | const customValue = ref();
|
4113 | const {
|
4114 | parent: form
|
4115 | } = useParent(FORM_KEY);
|
4116 | const getModelValue = () => {
|
4117 | var _a;
|
4118 | return String((_a = props2.modelValue) != null ? _a : "");
|
4119 | };
|
4120 | const getProp = (key) => {
|
4121 | if (isDef(props2[key])) {
|
4122 | return props2[key];
|
4123 | }
|
4124 | if (form && isDef(form.props[key])) {
|
4125 | return form.props[key];
|
4126 | }
|
4127 | };
|
4128 | const showClear = computed(() => {
|
4129 | const readonly = getProp("readonly");
|
4130 | if (props2.clearable && !readonly) {
|
4131 | const hasValue = getModelValue() !== "";
|
4132 | const trigger = props2.clearTrigger === "always" || props2.clearTrigger === "focus" && state.focused;
|
4133 | return hasValue && trigger;
|
4134 | }
|
4135 | return false;
|
4136 | });
|
4137 | const formValue = computed(() => {
|
4138 | if (customValue.value && slots.input) {
|
4139 | return customValue.value();
|
4140 | }
|
4141 | return props2.modelValue;
|
4142 | });
|
4143 | const showRequiredMark = computed(() => {
|
4144 | var _a;
|
4145 | const required = getProp("required");
|
4146 | if (required === "auto") {
|
4147 | return (_a = props2.rules) == null ? void 0 : _a.some((rule) => rule.required);
|
4148 | }
|
4149 | return required;
|
4150 | });
|
4151 | const runRules = (rules) => rules.reduce((promise, rule) => promise.then(() => {
|
4152 | if (state.status === "failed") {
|
4153 | return;
|
4154 | }
|
4155 | let {
|
4156 | value
|
4157 | } = formValue;
|
4158 | if (rule.formatter) {
|
4159 | value = rule.formatter(value, rule);
|
4160 | }
|
4161 | if (!runSyncRule(value, rule)) {
|
4162 | state.status = "failed";
|
4163 | state.validateMessage = getRuleMessage(value, rule);
|
4164 | return;
|
4165 | }
|
4166 | if (rule.validator) {
|
4167 | if (isEmptyValue(value) && rule.validateEmpty === false) {
|
4168 | return;
|
4169 | }
|
4170 | return runRuleValidator(value, rule).then((result) => {
|
4171 | if (result && typeof result === "string") {
|
4172 | state.status = "failed";
|
4173 | state.validateMessage = result;
|
4174 | } else if (result === false) {
|
4175 | state.status = "failed";
|
4176 | state.validateMessage = getRuleMessage(value, rule);
|
4177 | }
|
4178 | });
|
4179 | }
|
4180 | }), Promise.resolve());
|
4181 | const resetValidation = () => {
|
4182 | state.status = "unvalidated";
|
4183 | state.validateMessage = "";
|
4184 | };
|
4185 | const endValidate = () => emit("endValidate", {
|
4186 | status: state.status,
|
4187 | message: state.validateMessage
|
4188 | });
|
4189 | const validate = (rules = props2.rules) => new Promise((resolve) => {
|
4190 | resetValidation();
|
4191 | if (rules) {
|
4192 | emit("startValidate");
|
4193 | runRules(rules).then(() => {
|
4194 | if (state.status === "failed") {
|
4195 | resolve({
|
4196 | name: props2.name,
|
4197 | message: state.validateMessage
|
4198 | });
|
4199 | endValidate();
|
4200 | } else {
|
4201 | state.status = "passed";
|
4202 | resolve();
|
4203 | endValidate();
|
4204 | }
|
4205 | });
|
4206 | } else {
|
4207 | resolve();
|
4208 | }
|
4209 | });
|
4210 | const validateWithTrigger = (trigger) => {
|
4211 | if (form && props2.rules) {
|
4212 | const {
|
4213 | validateTrigger
|
4214 | } = form.props;
|
4215 | const defaultTrigger = toArray(validateTrigger).includes(trigger);
|
4216 | const rules = props2.rules.filter((rule) => {
|
4217 | if (rule.trigger) {
|
4218 | return toArray(rule.trigger).includes(trigger);
|
4219 | }
|
4220 | return defaultTrigger;
|
4221 | });
|
4222 | if (rules.length) {
|
4223 | validate(rules);
|
4224 | }
|
4225 | }
|
4226 | };
|
4227 | const limitValueLength = (value) => {
|
4228 | var _a;
|
4229 | const {
|
4230 | maxlength
|
4231 | } = props2;
|
4232 | if (isDef(maxlength) && getStringLength(value) > +maxlength) {
|
4233 | const modelValue = getModelValue();
|
4234 | if (modelValue && getStringLength(modelValue) === +maxlength) {
|
4235 | return modelValue;
|
4236 | }
|
4237 | const selectionEnd = (_a = inputRef.value) == null ? void 0 : _a.selectionEnd;
|
4238 | if (state.focused && selectionEnd) {
|
4239 | const valueArr = [...value];
|
4240 | const exceededLength = valueArr.length - +maxlength;
|
4241 | valueArr.splice(selectionEnd - exceededLength, exceededLength);
|
4242 | return valueArr.join("");
|
4243 | }
|
4244 | return cutString(value, +maxlength);
|
4245 | }
|
4246 | return value;
|
4247 | };
|
4248 | const updateValue = (value, trigger = "onChange") => {
|
4249 | const originalValue = value;
|
4250 | value = limitValueLength(value);
|
4251 | const limitDiffLen = getStringLength(originalValue) - getStringLength(value);
|
4252 | if (props2.type === "number" || props2.type === "digit") {
|
4253 | const isNumber = props2.type === "number";
|
4254 | value = formatNumber(value, isNumber, isNumber);
|
4255 | }
|
4256 | let formatterDiffLen = 0;
|
4257 | if (props2.formatter && trigger === props2.formatTrigger) {
|
4258 | const {
|
4259 | formatter,
|
4260 | maxlength
|
4261 | } = props2;
|
4262 | value = formatter(value);
|
4263 | if (isDef(maxlength) && getStringLength(value) > +maxlength) {
|
4264 | value = cutString(value, +maxlength);
|
4265 | }
|
4266 | if (inputRef.value && state.focused) {
|
4267 | const {
|
4268 | selectionEnd
|
4269 | } = inputRef.value;
|
4270 | const bcoVal = cutString(originalValue, selectionEnd);
|
4271 | formatterDiffLen = getStringLength(formatter(bcoVal)) - getStringLength(bcoVal);
|
4272 | }
|
4273 | }
|
4274 | if (inputRef.value && inputRef.value.value !== value) {
|
4275 | if (state.focused) {
|
4276 | let {
|
4277 | selectionStart,
|
4278 | selectionEnd
|
4279 | } = inputRef.value;
|
4280 | inputRef.value.value = value;
|
4281 | if (isDef(selectionStart) && isDef(selectionEnd)) {
|
4282 | const valueLen = getStringLength(value);
|
4283 | if (limitDiffLen) {
|
4284 | selectionStart -= limitDiffLen;
|
4285 | selectionEnd -= limitDiffLen;
|
4286 | } else if (formatterDiffLen) {
|
4287 | selectionStart += formatterDiffLen;
|
4288 | selectionEnd += formatterDiffLen;
|
4289 | }
|
4290 | inputRef.value.setSelectionRange(Math.min(selectionStart, valueLen), Math.min(selectionEnd, valueLen));
|
4291 | }
|
4292 | } else {
|
4293 | inputRef.value.value = value;
|
4294 | }
|
4295 | }
|
4296 | if (value !== props2.modelValue) {
|
4297 | emit("update:modelValue", value);
|
4298 | }
|
4299 | };
|
4300 | const onInput = (event) => {
|
4301 | if (!event.target.composing) {
|
4302 | updateValue(event.target.value);
|
4303 | }
|
4304 | };
|
4305 | const blur = () => {
|
4306 | var _a;
|
4307 | return (_a = inputRef.value) == null ? void 0 : _a.blur();
|
4308 | };
|
4309 | const focus = () => {
|
4310 | var _a;
|
4311 | return (_a = inputRef.value) == null ? void 0 : _a.focus();
|
4312 | };
|
4313 | const adjustTextareaSize = () => {
|
4314 | const input = inputRef.value;
|
4315 | if (props2.type === "textarea" && props2.autosize && input) {
|
4316 | resizeTextarea(input, props2.autosize);
|
4317 | }
|
4318 | };
|
4319 | const onFocus = (event) => {
|
4320 | state.focused = true;
|
4321 | emit("focus", event);
|
4322 | nextTick(adjustTextareaSize);
|
4323 | if (getProp("readonly")) {
|
4324 | blur();
|
4325 | }
|
4326 | };
|
4327 | const onBlur = (event) => {
|
4328 | state.focused = false;
|
4329 | updateValue(getModelValue(), "onBlur");
|
4330 | emit("blur", event);
|
4331 | if (getProp("readonly")) {
|
4332 | return;
|
4333 | }
|
4334 | validateWithTrigger("onBlur");
|
4335 | nextTick(adjustTextareaSize);
|
4336 | resetScroll();
|
4337 | };
|
4338 | const onClickInput = (event) => emit("clickInput", event);
|
4339 | const onClickLeftIcon = (event) => emit("clickLeftIcon", event);
|
4340 | const onClickRightIcon = (event) => emit("clickRightIcon", event);
|
4341 | const onClear = (event) => {
|
4342 | preventDefault(event);
|
4343 | emit("update:modelValue", "");
|
4344 | emit("clear", event);
|
4345 | };
|
4346 | const showError = computed(() => {
|
4347 | if (typeof props2.error === "boolean") {
|
4348 | return props2.error;
|
4349 | }
|
4350 | if (form && form.props.showError && state.status === "failed") {
|
4351 | return true;
|
4352 | }
|
4353 | });
|
4354 | const labelStyle = computed(() => {
|
4355 | const labelWidth = getProp("labelWidth");
|
4356 | const labelAlign = getProp("labelAlign");
|
4357 | if (labelWidth && labelAlign !== "top") {
|
4358 | return {
|
4359 | width: addUnit(labelWidth)
|
4360 | };
|
4361 | }
|
4362 | });
|
4363 | const onKeypress = (event) => {
|
4364 | const ENTER_CODE = 13;
|
4365 | if (event.keyCode === ENTER_CODE) {
|
4366 | const submitOnEnter = form && form.props.submitOnEnter;
|
4367 | if (!submitOnEnter && props2.type !== "textarea") {
|
4368 | preventDefault(event);
|
4369 | }
|
4370 | if (props2.type === "search") {
|
4371 | blur();
|
4372 | }
|
4373 | }
|
4374 | emit("keypress", event);
|
4375 | };
|
4376 | const getInputId = () => props2.id || `${id}-input`;
|
4377 | const getValidationStatus = () => state.status;
|
4378 | const renderInput = () => {
|
4379 | const controlClass = bem$1h("control", [getProp("inputAlign"), {
|
4380 | error: showError.value,
|
4381 | custom: !!slots.input,
|
4382 | "min-height": props2.type === "textarea" && !props2.autosize
|
4383 | }]);
|
4384 | if (slots.input) {
|
4385 | return createVNode("div", {
|
4386 | "class": controlClass,
|
4387 | "onClick": onClickInput
|
4388 | }, [slots.input()]);
|
4389 | }
|
4390 | const inputAttrs = {
|
4391 | id: getInputId(),
|
4392 | ref: inputRef,
|
4393 | name: props2.name,
|
4394 | rows: props2.rows !== void 0 ? +props2.rows : void 0,
|
4395 | class: controlClass,
|
4396 | disabled: getProp("disabled"),
|
4397 | readonly: getProp("readonly"),
|
4398 | autofocus: props2.autofocus,
|
4399 | placeholder: props2.placeholder,
|
4400 | autocomplete: props2.autocomplete,
|
4401 | autocapitalize: props2.autocapitalize,
|
4402 | autocorrect: props2.autocorrect,
|
4403 | enterkeyhint: props2.enterkeyhint,
|
4404 | spellcheck: props2.spellcheck,
|
4405 | "aria-labelledby": props2.label ? `${id}-label` : void 0,
|
4406 | onBlur,
|
4407 | onFocus,
|
4408 | onInput,
|
4409 | onClick: onClickInput,
|
4410 | onChange: endComposing,
|
4411 | onKeypress,
|
4412 | onCompositionend: endComposing,
|
4413 | onCompositionstart: startComposing
|
4414 | };
|
4415 | if (props2.type === "textarea") {
|
4416 | return createVNode("textarea", inputAttrs, null);
|
4417 | }
|
4418 | return createVNode("input", mergeProps(mapInputType(props2.type), inputAttrs), null);
|
4419 | };
|
4420 | const renderLeftIcon = () => {
|
4421 | const leftIconSlot = slots["left-icon"];
|
4422 | if (props2.leftIcon || leftIconSlot) {
|
4423 | return createVNode("div", {
|
4424 | "class": bem$1h("left-icon"),
|
4425 | "onClick": onClickLeftIcon
|
4426 | }, [leftIconSlot ? leftIconSlot() : createVNode(Icon, {
|
4427 | "name": props2.leftIcon,
|
4428 | "classPrefix": props2.iconPrefix
|
4429 | }, null)]);
|
4430 | }
|
4431 | };
|
4432 | const renderRightIcon = () => {
|
4433 | const rightIconSlot = slots["right-icon"];
|
4434 | if (props2.rightIcon || rightIconSlot) {
|
4435 | return createVNode("div", {
|
4436 | "class": bem$1h("right-icon"),
|
4437 | "onClick": onClickRightIcon
|
4438 | }, [rightIconSlot ? rightIconSlot() : createVNode(Icon, {
|
4439 | "name": props2.rightIcon,
|
4440 | "classPrefix": props2.iconPrefix
|
4441 | }, null)]);
|
4442 | }
|
4443 | };
|
4444 | const renderWordLimit = () => {
|
4445 | if (props2.showWordLimit && props2.maxlength) {
|
4446 | const count = getStringLength(getModelValue());
|
4447 | return createVNode("div", {
|
4448 | "class": bem$1h("word-limit")
|
4449 | }, [createVNode("span", {
|
4450 | "class": bem$1h("word-num")
|
4451 | }, [count]), createTextVNode("/"), props2.maxlength]);
|
4452 | }
|
4453 | };
|
4454 | const renderMessage = () => {
|
4455 | if (form && form.props.showErrorMessage === false) {
|
4456 | return;
|
4457 | }
|
4458 | const message = props2.errorMessage || state.validateMessage;
|
4459 | if (message) {
|
4460 | const slot = slots["error-message"];
|
4461 | const errorMessageAlign = getProp("errorMessageAlign");
|
4462 | return createVNode("div", {
|
4463 | "class": bem$1h("error-message", errorMessageAlign)
|
4464 | }, [slot ? slot({
|
4465 | message
|
4466 | }) : message]);
|
4467 | }
|
4468 | };
|
4469 | const renderLabel = () => {
|
4470 | const labelWidth = getProp("labelWidth");
|
4471 | const labelAlign = getProp("labelAlign");
|
4472 | const colon = getProp("colon") ? ":" : "";
|
4473 | if (slots.label) {
|
4474 | return [slots.label(), colon];
|
4475 | }
|
4476 | if (props2.label) {
|
4477 | return createVNode("label", {
|
4478 | "id": `${id}-label`,
|
4479 | "for": slots.input ? void 0 : getInputId(),
|
4480 | "onClick": (event) => {
|
4481 | preventDefault(event);
|
4482 | focus();
|
4483 | },
|
4484 | "style": labelAlign === "top" && labelWidth ? {
|
4485 | width: addUnit(labelWidth)
|
4486 | } : void 0
|
4487 | }, [props2.label + colon]);
|
4488 | }
|
4489 | };
|
4490 | const renderFieldBody = () => [createVNode("div", {
|
4491 | "class": bem$1h("body")
|
4492 | }, [renderInput(), showClear.value && createVNode(Icon, {
|
4493 | "ref": clearIconRef,
|
4494 | "name": props2.clearIcon,
|
4495 | "class": bem$1h("clear")
|
4496 | }, null), renderRightIcon(), slots.button && createVNode("div", {
|
4497 | "class": bem$1h("button")
|
4498 | }, [slots.button()])]), renderWordLimit(), renderMessage()];
|
4499 | useExpose({
|
4500 | blur,
|
4501 | focus,
|
4502 | validate,
|
4503 | formValue,
|
4504 | resetValidation,
|
4505 | getValidationStatus
|
4506 | });
|
4507 | provide(CUSTOM_FIELD_INJECTION_KEY, {
|
4508 | customValue,
|
4509 | resetValidation,
|
4510 | validateWithTrigger
|
4511 | });
|
4512 | watch(() => props2.modelValue, () => {
|
4513 | updateValue(getModelValue());
|
4514 | resetValidation();
|
4515 | validateWithTrigger("onChange");
|
4516 | nextTick(adjustTextareaSize);
|
4517 | });
|
4518 | onMounted(() => {
|
4519 | updateValue(getModelValue(), props2.formatTrigger);
|
4520 | nextTick(adjustTextareaSize);
|
4521 | });
|
4522 | useEventListener("touchstart", onClear, {
|
4523 | target: computed(() => {
|
4524 | var _a;
|
4525 | return (_a = clearIconRef.value) == null ? void 0 : _a.$el;
|
4526 | })
|
4527 | });
|
4528 | return () => {
|
4529 | const disabled = getProp("disabled");
|
4530 | const labelAlign = getProp("labelAlign");
|
4531 | const LeftIcon = renderLeftIcon();
|
4532 | const renderTitle = () => {
|
4533 | const Label = renderLabel();
|
4534 | if (labelAlign === "top") {
|
4535 | return [LeftIcon, Label].filter(Boolean);
|
4536 | }
|
4537 | return Label || [];
|
4538 | };
|
4539 | return createVNode(Cell, {
|
4540 | "size": props2.size,
|
4541 | "class": bem$1h({
|
4542 | error: showError.value,
|
4543 | disabled,
|
4544 | [`label-${labelAlign}`]: labelAlign
|
4545 | }),
|
4546 | "center": props2.center,
|
4547 | "border": props2.border,
|
4548 | "isLink": props2.isLink,
|
4549 | "clickable": props2.clickable,
|
4550 | "titleStyle": labelStyle.value,
|
4551 | "valueClass": bem$1h("value"),
|
4552 | "titleClass": [bem$1h("label", [labelAlign, {
|
4553 | required: showRequiredMark.value
|
4554 | }]), props2.labelClass],
|
4555 | "arrowDirection": props2.arrowDirection
|
4556 | }, {
|
4557 | icon: LeftIcon && labelAlign !== "top" ? () => LeftIcon : null,
|
4558 | title: renderTitle,
|
4559 | value: renderFieldBody,
|
4560 | extra: slots.extra
|
4561 | });
|
4562 | };
|
4563 | }
|
4564 | });
|
4565 | const Field = withInstall(stdin_default$1v);
|
4566 | let lockCount = 0;
|
4567 | function lockClick(lock) {
|
4568 | if (lock) {
|
4569 | if (!lockCount) {
|
4570 | document.body.classList.add("van-toast--unclickable");
|
4571 | }
|
4572 | lockCount++;
|
4573 | } else if (lockCount) {
|
4574 | lockCount--;
|
4575 | if (!lockCount) {
|
4576 | document.body.classList.remove("van-toast--unclickable");
|
4577 | }
|
4578 | }
|
4579 | }
|
4580 | const [name$1k, bem$1g] = createNamespace("toast");
|
4581 | const popupInheritProps$1 = ["show", "overlay", "teleport", "transition", "overlayClass", "overlayStyle", "closeOnClickOverlay", "zIndex"];
|
4582 | const toastProps = {
|
4583 | icon: String,
|
4584 | show: Boolean,
|
4585 | type: makeStringProp("text"),
|
4586 | overlay: Boolean,
|
4587 | message: numericProp,
|
4588 | iconSize: numericProp,
|
4589 | duration: makeNumberProp(2e3),
|
4590 | position: makeStringProp("middle"),
|
4591 | teleport: [String, Object],
|
4592 | wordBreak: String,
|
4593 | className: unknownProp,
|
4594 | iconPrefix: String,
|
4595 | transition: makeStringProp("van-fade"),
|
4596 | loadingType: String,
|
4597 | forbidClick: Boolean,
|
4598 | overlayClass: unknownProp,
|
4599 | overlayStyle: Object,
|
4600 | closeOnClick: Boolean,
|
4601 | closeOnClickOverlay: Boolean,
|
4602 | zIndex: numericProp
|
4603 | };
|
4604 | var stdin_default$1u = defineComponent({
|
4605 | name: name$1k,
|
4606 | props: toastProps,
|
4607 | emits: ["update:show"],
|
4608 | setup(props2, {
|
4609 | emit,
|
4610 | slots
|
4611 | }) {
|
4612 | let timer2;
|
4613 | let clickable = false;
|
4614 | const toggleClickable = () => {
|
4615 | const newValue = props2.show && props2.forbidClick;
|
4616 | if (clickable !== newValue) {
|
4617 | clickable = newValue;
|
4618 | lockClick(clickable);
|
4619 | }
|
4620 | };
|
4621 | const updateShow = (show) => emit("update:show", show);
|
4622 | const onClick = () => {
|
4623 | if (props2.closeOnClick) {
|
4624 | updateShow(false);
|
4625 | }
|
4626 | };
|
4627 | const clearTimer = () => clearTimeout(timer2);
|
4628 | const renderIcon = () => {
|
4629 | const {
|
4630 | icon,
|
4631 | type,
|
4632 | iconSize,
|
4633 | iconPrefix,
|
4634 | loadingType
|
4635 | } = props2;
|
4636 | const hasIcon = icon || type === "success" || type === "fail";
|
4637 | if (hasIcon) {
|
4638 | return createVNode(Icon, {
|
4639 | "name": icon || type,
|
4640 | "size": iconSize,
|
4641 | "class": bem$1g("icon"),
|
4642 | "classPrefix": iconPrefix
|
4643 | }, null);
|
4644 | }
|
4645 | if (type === "loading") {
|
4646 | return createVNode(Loading, {
|
4647 | "class": bem$1g("loading"),
|
4648 | "size": iconSize,
|
4649 | "type": loadingType
|
4650 | }, null);
|
4651 | }
|
4652 | };
|
4653 | const renderMessage = () => {
|
4654 | const {
|
4655 | type,
|
4656 | message
|
4657 | } = props2;
|
4658 | if (slots.message) {
|
4659 | return createVNode("div", {
|
4660 | "class": bem$1g("text")
|
4661 | }, [slots.message()]);
|
4662 | }
|
4663 | if (isDef(message) && message !== "") {
|
4664 | return type === "html" ? createVNode("div", {
|
4665 | "key": 0,
|
4666 | "class": bem$1g("text"),
|
4667 | "innerHTML": String(message)
|
4668 | }, null) : createVNode("div", {
|
4669 | "class": bem$1g("text")
|
4670 | }, [message]);
|
4671 | }
|
4672 | };
|
4673 | watch(() => [props2.show, props2.forbidClick], toggleClickable);
|
4674 | watch(() => [props2.show, props2.type, props2.message, props2.duration], () => {
|
4675 | clearTimer();
|
4676 | if (props2.show && props2.duration > 0) {
|
4677 | timer2 = setTimeout(() => {
|
4678 | updateShow(false);
|
4679 | }, props2.duration);
|
4680 | }
|
4681 | });
|
4682 | onMounted(toggleClickable);
|
4683 | onUnmounted(toggleClickable);
|
4684 | return () => createVNode(Popup, mergeProps({
|
4685 | "class": [bem$1g([props2.position, props2.wordBreak === "normal" ? "break-normal" : props2.wordBreak, {
|
4686 | [props2.type]: !props2.icon
|
4687 | }]), props2.className],
|
4688 | "lockScroll": false,
|
4689 | "onClick": onClick,
|
4690 | "onClosed": clearTimer,
|
4691 | "onUpdate:show": updateShow
|
4692 | }, pick(props2, popupInheritProps$1)), {
|
4693 | default: () => [renderIcon(), renderMessage()]
|
4694 | });
|
4695 | }
|
4696 | });
|
4697 | function usePopupState() {
|
4698 | const state = reactive({
|
4699 | show: false
|
4700 | });
|
4701 | const toggle = (show) => {
|
4702 | state.show = show;
|
4703 | };
|
4704 | const open = (props2) => {
|
4705 | extend(state, props2, { transitionAppear: true });
|
4706 | toggle(true);
|
4707 | };
|
4708 | const close = () => toggle(false);
|
4709 | useExpose({ open, close, toggle });
|
4710 | return {
|
4711 | open,
|
4712 | close,
|
4713 | state,
|
4714 | toggle
|
4715 | };
|
4716 | }
|
4717 | function mountComponent(RootComponent) {
|
4718 | const app = createApp(RootComponent);
|
4719 | const root = document.createElement("div");
|
4720 | document.body.appendChild(root);
|
4721 | return {
|
4722 | instance: app.mount(root),
|
4723 | unmount() {
|
4724 | app.unmount();
|
4725 | document.body.removeChild(root);
|
4726 | }
|
4727 | };
|
4728 | }
|
4729 | const defaultOptions$1 = {
|
4730 | icon: "",
|
4731 | type: "text",
|
4732 | message: "",
|
4733 | className: "",
|
4734 | overlay: false,
|
4735 | onClose: void 0,
|
4736 | onOpened: void 0,
|
4737 | duration: 2e3,
|
4738 | teleport: "body",
|
4739 | iconSize: void 0,
|
4740 | iconPrefix: void 0,
|
4741 | position: "middle",
|
4742 | transition: "van-fade",
|
4743 | forbidClick: false,
|
4744 | loadingType: void 0,
|
4745 | overlayClass: "",
|
4746 | overlayStyle: void 0,
|
4747 | closeOnClick: false,
|
4748 | closeOnClickOverlay: false
|
4749 | };
|
4750 | let queue = [];
|
4751 | let allowMultiple = false;
|
4752 | let currentOptions$2 = extend({}, defaultOptions$1);
|
4753 | const defaultOptionsMap = new Map();
|
4754 | function parseOptions$1(message) {
|
4755 | if (isObject(message)) {
|
4756 | return message;
|
4757 | }
|
4758 | return {
|
4759 | message
|
4760 | };
|
4761 | }
|
4762 | function createInstance() {
|
4763 | const {
|
4764 | instance: instance2,
|
4765 | unmount
|
4766 | } = mountComponent({
|
4767 | setup() {
|
4768 | const message = ref("");
|
4769 | const {
|
4770 | open,
|
4771 | state,
|
4772 | close,
|
4773 | toggle
|
4774 | } = usePopupState();
|
4775 | const onClosed = () => {
|
4776 | if (allowMultiple) {
|
4777 | queue = queue.filter((item) => item !== instance2);
|
4778 | unmount();
|
4779 | }
|
4780 | };
|
4781 | const render = () => {
|
4782 | const attrs = {
|
4783 | onClosed,
|
4784 | "onUpdate:show": toggle
|
4785 | };
|
4786 | return createVNode(stdin_default$1u, mergeProps(state, attrs), null);
|
4787 | };
|
4788 | watch(message, (val) => {
|
4789 | state.message = val;
|
4790 | });
|
4791 | getCurrentInstance().render = render;
|
4792 | return {
|
4793 | open,
|
4794 | close,
|
4795 | message
|
4796 | };
|
4797 | }
|
4798 | });
|
4799 | return instance2;
|
4800 | }
|
4801 | function getInstance() {
|
4802 | if (!queue.length || allowMultiple) {
|
4803 | const instance2 = createInstance();
|
4804 | queue.push(instance2);
|
4805 | }
|
4806 | return queue[queue.length - 1];
|
4807 | }
|
4808 | function showToast(options = {}) {
|
4809 | if (!inBrowser) {
|
4810 | return {};
|
4811 | }
|
4812 | const toast = getInstance();
|
4813 | const parsedOptions = parseOptions$1(options);
|
4814 | toast.open(extend({}, currentOptions$2, defaultOptionsMap.get(parsedOptions.type || currentOptions$2.type), parsedOptions));
|
4815 | return toast;
|
4816 | }
|
4817 | const createMethod = (type) => (options) => showToast(extend({
|
4818 | type
|
4819 | }, parseOptions$1(options)));
|
4820 | const showLoadingToast = createMethod("loading");
|
4821 | const showSuccessToast = createMethod("success");
|
4822 | const showFailToast = createMethod("fail");
|
4823 | const closeToast = (all) => {
|
4824 | var _a;
|
4825 | if (queue.length) {
|
4826 | if (all) {
|
4827 | queue.forEach((toast) => {
|
4828 | toast.close();
|
4829 | });
|
4830 | queue = [];
|
4831 | } else if (!allowMultiple) {
|
4832 | queue[0].close();
|
4833 | } else {
|
4834 | (_a = queue.shift()) == null ? void 0 : _a.close();
|
4835 | }
|
4836 | }
|
4837 | };
|
4838 | function setToastDefaultOptions(type, options) {
|
4839 | if (typeof type === "string") {
|
4840 | defaultOptionsMap.set(type, options);
|
4841 | } else {
|
4842 | extend(currentOptions$2, type);
|
4843 | }
|
4844 | }
|
4845 | const resetToastDefaultOptions = (type) => {
|
4846 | if (typeof type === "string") {
|
4847 | defaultOptionsMap.delete(type);
|
4848 | } else {
|
4849 | currentOptions$2 = extend({}, defaultOptions$1);
|
4850 | defaultOptionsMap.clear();
|
4851 | }
|
4852 | };
|
4853 | const allowMultipleToast = (value = true) => {
|
4854 | allowMultiple = value;
|
4855 | };
|
4856 | const Toast = withInstall(stdin_default$1u);
|
4857 | const [name$1j, bem$1f] = createNamespace("switch");
|
4858 | const switchProps = {
|
4859 | size: numericProp,
|
4860 | loading: Boolean,
|
4861 | disabled: Boolean,
|
4862 | modelValue: unknownProp,
|
4863 | activeColor: String,
|
4864 | inactiveColor: String,
|
4865 | activeValue: {
|
4866 | type: unknownProp,
|
4867 | default: true
|
4868 | },
|
4869 | inactiveValue: {
|
4870 | type: unknownProp,
|
4871 | default: false
|
4872 | }
|
4873 | };
|
4874 | var stdin_default$1t = defineComponent({
|
4875 | name: name$1j,
|
4876 | props: switchProps,
|
4877 | emits: ["change", "update:modelValue"],
|
4878 | setup(props2, {
|
4879 | emit,
|
4880 | slots
|
4881 | }) {
|
4882 | const isChecked = () => props2.modelValue === props2.activeValue;
|
4883 | const onClick = () => {
|
4884 | if (!props2.disabled && !props2.loading) {
|
4885 | const newValue = isChecked() ? props2.inactiveValue : props2.activeValue;
|
4886 | emit("update:modelValue", newValue);
|
4887 | emit("change", newValue);
|
4888 | }
|
4889 | };
|
4890 | const renderLoading = () => {
|
4891 | if (props2.loading) {
|
4892 | const color = isChecked() ? props2.activeColor : props2.inactiveColor;
|
4893 | return createVNode(Loading, {
|
4894 | "class": bem$1f("loading"),
|
4895 | "color": color
|
4896 | }, null);
|
4897 | }
|
4898 | if (slots.node) {
|
4899 | return slots.node();
|
4900 | }
|
4901 | };
|
4902 | useCustomFieldValue(() => props2.modelValue);
|
4903 | return () => {
|
4904 | var _a;
|
4905 | const {
|
4906 | size,
|
4907 | loading,
|
4908 | disabled,
|
4909 | activeColor,
|
4910 | inactiveColor
|
4911 | } = props2;
|
4912 | const checked = isChecked();
|
4913 | const style = {
|
4914 | fontSize: addUnit(size),
|
4915 | backgroundColor: checked ? activeColor : inactiveColor
|
4916 | };
|
4917 | return createVNode("div", {
|
4918 | "role": "switch",
|
4919 | "class": bem$1f({
|
4920 | on: checked,
|
4921 | loading,
|
4922 | disabled
|
4923 | }),
|
4924 | "style": style,
|
4925 | "tabindex": disabled ? void 0 : 0,
|
4926 | "aria-checked": checked,
|
4927 | "onClick": onClick
|
4928 | }, [createVNode("div", {
|
4929 | "class": bem$1f("node")
|
4930 | }, [renderLoading()]), (_a = slots.background) == null ? void 0 : _a.call(slots)]);
|
4931 | };
|
4932 | }
|
4933 | });
|
4934 | const Switch = withInstall(stdin_default$1t);
|
4935 | const [name$1i, bem$1e] = createNamespace("address-edit-detail");
|
4936 | const t$j = createNamespace("address-edit")[2];
|
4937 | var stdin_default$1s = defineComponent({
|
4938 | name: name$1i,
|
4939 | props: {
|
4940 | show: Boolean,
|
4941 | rows: numericProp,
|
4942 | value: String,
|
4943 | rules: Array,
|
4944 | focused: Boolean,
|
4945 | maxlength: numericProp,
|
4946 | searchResult: Array,
|
4947 | showSearchResult: Boolean
|
4948 | },
|
4949 | emits: ["blur", "focus", "input", "selectSearch"],
|
4950 | setup(props2, {
|
4951 | emit
|
4952 | }) {
|
4953 | const field = ref();
|
4954 | const showSearchResult = () => props2.focused && props2.searchResult && props2.showSearchResult;
|
4955 | const onSelect = (express) => {
|
4956 | emit("selectSearch", express);
|
4957 | emit("input", `${express.address || ""} ${express.name || ""}`.trim());
|
4958 | };
|
4959 | const renderSearchResult = () => {
|
4960 | if (!showSearchResult()) {
|
4961 | return;
|
4962 | }
|
4963 | const {
|
4964 | searchResult
|
4965 | } = props2;
|
4966 | return searchResult.map((express) => createVNode(Cell, {
|
4967 | "clickable": true,
|
4968 | "key": (express.name || "") + (express.address || ""),
|
4969 | "icon": "location-o",
|
4970 | "title": express.name,
|
4971 | "label": express.address,
|
4972 | "class": bem$1e("search-item"),
|
4973 | "border": false,
|
4974 | "onClick": () => onSelect(express)
|
4975 | }, null));
|
4976 | };
|
4977 | const onBlur = (event) => emit("blur", event);
|
4978 | const onFocus = (event) => emit("focus", event);
|
4979 | const onInput = (value) => emit("input", value);
|
4980 | return () => {
|
4981 | if (props2.show) {
|
4982 | return createVNode(Fragment, null, [createVNode(Field, {
|
4983 | "autosize": true,
|
4984 | "clearable": true,
|
4985 | "ref": field,
|
4986 | "class": bem$1e(),
|
4987 | "rows": props2.rows,
|
4988 | "type": "textarea",
|
4989 | "rules": props2.rules,
|
4990 | "label": t$j("addressDetail"),
|
4991 | "border": !showSearchResult(),
|
4992 | "maxlength": props2.maxlength,
|
4993 | "modelValue": props2.value,
|
4994 | "placeholder": t$j("addressDetail"),
|
4995 | "onBlur": onBlur,
|
4996 | "onFocus": onFocus,
|
4997 | "onUpdate:modelValue": onInput
|
4998 | }, null), renderSearchResult()]);
|
4999 | }
|
5000 | };
|
5001 | }
|
5002 | });
|
5003 | const [name$1h, bem$1d, t$i] = createNamespace("address-edit");
|
5004 | const DEFAULT_DATA = {
|
5005 | name: "",
|
5006 | tel: "",
|
5007 | city: "",
|
5008 | county: "",
|
5009 | country: "",
|
5010 | province: "",
|
5011 | areaCode: "",
|
5012 | isDefault: false,
|
5013 | addressDetail: ""
|
5014 | };
|
5015 | const addressEditProps = {
|
5016 | areaList: Object,
|
5017 | isSaving: Boolean,
|
5018 | isDeleting: Boolean,
|
5019 | validator: Function,
|
5020 | showArea: truthProp,
|
5021 | showDetail: truthProp,
|
5022 | showDelete: Boolean,
|
5023 | disableArea: Boolean,
|
5024 | searchResult: Array,
|
5025 | telMaxlength: numericProp,
|
5026 | showSetDefault: Boolean,
|
5027 | saveButtonText: String,
|
5028 | areaPlaceholder: String,
|
5029 | deleteButtonText: String,
|
5030 | showSearchResult: Boolean,
|
5031 | detailRows: makeNumericProp(1),
|
5032 | detailMaxlength: makeNumericProp(200),
|
5033 | areaColumnsPlaceholder: makeArrayProp(),
|
5034 | addressInfo: {
|
5035 | type: Object,
|
5036 | default: () => extend({}, DEFAULT_DATA)
|
5037 | },
|
5038 | telValidator: {
|
5039 | type: Function,
|
5040 | default: isMobile
|
5041 | }
|
5042 | };
|
5043 | var stdin_default$1r = defineComponent({
|
5044 | name: name$1h,
|
5045 | props: addressEditProps,
|
5046 | emits: ["save", "focus", "change", "delete", "clickArea", "changeArea", "changeDetail", "selectSearch", "changeDefault"],
|
5047 | setup(props2, {
|
5048 | emit,
|
5049 | slots
|
5050 | }) {
|
5051 | const areaRef = ref();
|
5052 | const data = reactive({});
|
5053 | const showAreaPopup = ref(false);
|
5054 | const detailFocused = ref(false);
|
5055 | const areaListLoaded = computed(() => isObject(props2.areaList) && Object.keys(props2.areaList).length);
|
5056 | const areaText = computed(() => {
|
5057 | const {
|
5058 | province,
|
5059 | city,
|
5060 | county,
|
5061 | areaCode
|
5062 | } = data;
|
5063 | if (areaCode) {
|
5064 | const arr = [province, city, county];
|
5065 | if (province && province === city) {
|
5066 | arr.splice(1, 1);
|
5067 | }
|
5068 | return arr.filter(Boolean).join("/");
|
5069 | }
|
5070 | return "";
|
5071 | });
|
5072 | const hideBottomFields = computed(() => {
|
5073 | var _a;
|
5074 | return ((_a = props2.searchResult) == null ? void 0 : _a.length) && detailFocused.value;
|
5075 | });
|
5076 | const onFocus = (key) => {
|
5077 | detailFocused.value = key === "addressDetail";
|
5078 | emit("focus", key);
|
5079 | };
|
5080 | const onChange = (key, value) => {
|
5081 | emit("change", {
|
5082 | key,
|
5083 | value
|
5084 | });
|
5085 | };
|
5086 | const rules = computed(() => {
|
5087 | const {
|
5088 | validator,
|
5089 | telValidator
|
5090 | } = props2;
|
5091 | const makeRule = (name2, emptyMessage) => ({
|
5092 | validator: (value) => {
|
5093 | if (validator) {
|
5094 | const message = validator(name2, value);
|
5095 | if (message) {
|
5096 | return message;
|
5097 | }
|
5098 | }
|
5099 | if (!value) {
|
5100 | return emptyMessage;
|
5101 | }
|
5102 | return true;
|
5103 | }
|
5104 | });
|
5105 | return {
|
5106 | name: [makeRule("name", t$i("nameEmpty"))],
|
5107 | tel: [makeRule("tel", t$i("telInvalid")), {
|
5108 | validator: telValidator,
|
5109 | message: t$i("telInvalid")
|
5110 | }],
|
5111 | areaCode: [makeRule("areaCode", t$i("areaEmpty"))],
|
5112 | addressDetail: [makeRule("addressDetail", t$i("addressEmpty"))]
|
5113 | };
|
5114 | });
|
5115 | const onSave = () => emit("save", data);
|
5116 | const onChangeDetail = (val) => {
|
5117 | data.addressDetail = val;
|
5118 | emit("changeDetail", val);
|
5119 | };
|
5120 | const assignAreaText = (options) => {
|
5121 | data.province = options[0].text;
|
5122 | data.city = options[1].text;
|
5123 | data.county = options[2].text;
|
5124 | };
|
5125 | const onAreaConfirm = ({
|
5126 | selectedValues,
|
5127 | selectedOptions
|
5128 | }) => {
|
5129 | if (selectedValues.some((value) => value === AREA_EMPTY_CODE)) {
|
5130 | showToast(t$i("areaEmpty"));
|
5131 | } else {
|
5132 | showAreaPopup.value = false;
|
5133 | assignAreaText(selectedOptions);
|
5134 | emit("changeArea", selectedOptions);
|
5135 | }
|
5136 | };
|
5137 | const onDelete = () => emit("delete", data);
|
5138 | const setAreaCode = (code) => {
|
5139 | data.areaCode = code || "";
|
5140 | };
|
5141 | const onDetailBlur = () => {
|
5142 | setTimeout(() => {
|
5143 | detailFocused.value = false;
|
5144 | });
|
5145 | };
|
5146 | const setAddressDetail = (value) => {
|
5147 | data.addressDetail = value;
|
5148 | };
|
5149 | const renderSetDefaultCell = () => {
|
5150 | if (props2.showSetDefault) {
|
5151 | const slots2 = {
|
5152 | "right-icon": () => createVNode(Switch, {
|
5153 | "modelValue": data.isDefault,
|
5154 | "onUpdate:modelValue": ($event) => data.isDefault = $event,
|
5155 | "onChange": (event) => emit("changeDefault", event)
|
5156 | }, null)
|
5157 | };
|
5158 | return withDirectives(createVNode(Cell, {
|
5159 | "center": true,
|
5160 | "border": false,
|
5161 | "title": t$i("defaultAddress"),
|
5162 | "class": bem$1d("default")
|
5163 | }, slots2), [[vShow, !hideBottomFields.value]]);
|
5164 | }
|
5165 | };
|
5166 | useExpose({
|
5167 | setAreaCode,
|
5168 | setAddressDetail
|
5169 | });
|
5170 | watch(() => props2.addressInfo, (value) => {
|
5171 | extend(data, DEFAULT_DATA, value);
|
5172 | nextTick(() => {
|
5173 | var _a;
|
5174 | const options = (_a = areaRef.value) == null ? void 0 : _a.getSelectedOptions();
|
5175 | if (options && options.every((option) => option && option.value !== AREA_EMPTY_CODE)) {
|
5176 | assignAreaText(options);
|
5177 | }
|
5178 | });
|
5179 | }, {
|
5180 | deep: true,
|
5181 | immediate: true
|
5182 | });
|
5183 | return () => {
|
5184 | const {
|
5185 | disableArea
|
5186 | } = props2;
|
5187 | return createVNode(Form, {
|
5188 | "class": bem$1d(),
|
5189 | "onSubmit": onSave
|
5190 | }, {
|
5191 | default: () => {
|
5192 | var _a;
|
5193 | return [createVNode("div", {
|
5194 | "class": bem$1d("fields")
|
5195 | }, [createVNode(Field, {
|
5196 | "modelValue": data.name,
|
5197 | "onUpdate:modelValue": [($event) => data.name = $event, (val) => onChange("name", val)],
|
5198 | "clearable": true,
|
5199 | "label": t$i("name"),
|
5200 | "rules": rules.value.name,
|
5201 | "placeholder": t$i("name"),
|
5202 | "onFocus": () => onFocus("name")
|
5203 | }, null), createVNode(Field, {
|
5204 | "modelValue": data.tel,
|
5205 | "onUpdate:modelValue": [($event) => data.tel = $event, (val) => onChange("tel", val)],
|
5206 | "clearable": true,
|
5207 | "type": "tel",
|
5208 | "label": t$i("tel"),
|
5209 | "rules": rules.value.tel,
|
5210 | "maxlength": props2.telMaxlength,
|
5211 | "placeholder": t$i("tel"),
|
5212 | "onFocus": () => onFocus("tel")
|
5213 | }, null), withDirectives(createVNode(Field, {
|
5214 | "readonly": true,
|
5215 | "label": t$i("area"),
|
5216 | "is-link": !disableArea,
|
5217 | "modelValue": areaText.value,
|
5218 | "rules": props2.showArea ? rules.value.areaCode : void 0,
|
5219 | "placeholder": props2.areaPlaceholder || t$i("area"),
|
5220 | "onFocus": () => onFocus("areaCode"),
|
5221 | "onClick": () => {
|
5222 | emit("clickArea");
|
5223 | showAreaPopup.value = !disableArea;
|
5224 | }
|
5225 | }, null), [[vShow, props2.showArea]]), createVNode(stdin_default$1s, {
|
5226 | "show": props2.showDetail,
|
5227 | "rows": props2.detailRows,
|
5228 | "rules": rules.value.addressDetail,
|
5229 | "value": data.addressDetail,
|
5230 | "focused": detailFocused.value,
|
5231 | "maxlength": props2.detailMaxlength,
|
5232 | "searchResult": props2.searchResult,
|
5233 | "showSearchResult": props2.showSearchResult,
|
5234 | "onBlur": onDetailBlur,
|
5235 | "onFocus": () => onFocus("addressDetail"),
|
5236 | "onInput": onChangeDetail,
|
5237 | "onSelectSearch": (event) => emit("selectSearch", event)
|
5238 | }, null), (_a = slots.default) == null ? void 0 : _a.call(slots)]), renderSetDefaultCell(), withDirectives(createVNode("div", {
|
5239 | "class": bem$1d("buttons")
|
5240 | }, [createVNode(Button, {
|
5241 | "block": true,
|
5242 | "round": true,
|
5243 | "type": "primary",
|
5244 | "text": props2.saveButtonText || t$i("save"),
|
5245 | "class": bem$1d("button"),
|
5246 | "loading": props2.isSaving,
|
5247 | "nativeType": "submit"
|
5248 | }, null), props2.showDelete && createVNode(Button, {
|
5249 | "block": true,
|
5250 | "round": true,
|
5251 | "class": bem$1d("button"),
|
5252 | "loading": props2.isDeleting,
|
5253 | "text": props2.deleteButtonText || t$i("delete"),
|
5254 | "onClick": onDelete
|
5255 | }, null)]), [[vShow, !hideBottomFields.value]]), createVNode(Popup, {
|
5256 | "show": showAreaPopup.value,
|
5257 | "onUpdate:show": ($event) => showAreaPopup.value = $event,
|
5258 | "round": true,
|
5259 | "teleport": "body",
|
5260 | "position": "bottom",
|
5261 | "lazyRender": false
|
5262 | }, {
|
5263 | default: () => [createVNode(Area, {
|
5264 | "modelValue": data.areaCode,
|
5265 | "onUpdate:modelValue": ($event) => data.areaCode = $event,
|
5266 | "ref": areaRef,
|
5267 | "loading": !areaListLoaded.value,
|
5268 | "areaList": props2.areaList,
|
5269 | "columnsPlaceholder": props2.areaColumnsPlaceholder,
|
5270 | "onConfirm": onAreaConfirm,
|
5271 | "onCancel": () => {
|
5272 | showAreaPopup.value = false;
|
5273 | }
|
5274 | }, null)]
|
5275 | })];
|
5276 | }
|
5277 | });
|
5278 | };
|
5279 | }
|
5280 | });
|
5281 | const AddressEdit = withInstall(stdin_default$1r);
|
5282 | const [name$1g, bem$1c] = createNamespace("radio-group");
|
5283 | const radioGroupProps = {
|
5284 | shape: String,
|
5285 | disabled: Boolean,
|
5286 | iconSize: numericProp,
|
5287 | direction: String,
|
5288 | modelValue: unknownProp,
|
5289 | checkedColor: String
|
5290 | };
|
5291 | const RADIO_KEY = Symbol(name$1g);
|
5292 | var stdin_default$1q = defineComponent({
|
5293 | name: name$1g,
|
5294 | props: radioGroupProps,
|
5295 | emits: ["change", "update:modelValue"],
|
5296 | setup(props2, {
|
5297 | emit,
|
5298 | slots
|
5299 | }) {
|
5300 | const {
|
5301 | linkChildren
|
5302 | } = useChildren(RADIO_KEY);
|
5303 | const updateValue = (value) => emit("update:modelValue", value);
|
5304 | watch(() => props2.modelValue, (value) => emit("change", value));
|
5305 | linkChildren({
|
5306 | props: props2,
|
5307 | updateValue
|
5308 | });
|
5309 | useCustomFieldValue(() => props2.modelValue);
|
5310 | return () => {
|
5311 | var _a;
|
5312 | return createVNode("div", {
|
5313 | "class": bem$1c([props2.direction]),
|
5314 | "role": "radiogroup"
|
5315 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
5316 | };
|
5317 | }
|
5318 | });
|
5319 | const RadioGroup = withInstall(stdin_default$1q);
|
5320 | const [name$1f, bem$1b] = createNamespace("tag");
|
5321 | const tagProps = {
|
5322 | size: String,
|
5323 | mark: Boolean,
|
5324 | show: truthProp,
|
5325 | type: makeStringProp("default"),
|
5326 | color: String,
|
5327 | plain: Boolean,
|
5328 | round: Boolean,
|
5329 | textColor: String,
|
5330 | closeable: Boolean
|
5331 | };
|
5332 | var stdin_default$1p = defineComponent({
|
5333 | name: name$1f,
|
5334 | props: tagProps,
|
5335 | emits: ["close"],
|
5336 | setup(props2, {
|
5337 | slots,
|
5338 | emit
|
5339 | }) {
|
5340 | const onClose = (event) => {
|
5341 | event.stopPropagation();
|
5342 | emit("close", event);
|
5343 | };
|
5344 | const getStyle = () => {
|
5345 | if (props2.plain) {
|
5346 | return {
|
5347 | color: props2.textColor || props2.color,
|
5348 | borderColor: props2.color
|
5349 | };
|
5350 | }
|
5351 | return {
|
5352 | color: props2.textColor,
|
5353 | background: props2.color
|
5354 | };
|
5355 | };
|
5356 | const renderTag = () => {
|
5357 | var _a;
|
5358 | const {
|
5359 | type,
|
5360 | mark,
|
5361 | plain,
|
5362 | round,
|
5363 | size,
|
5364 | closeable
|
5365 | } = props2;
|
5366 | const classes = {
|
5367 | mark,
|
5368 | plain,
|
5369 | round
|
5370 | };
|
5371 | if (size) {
|
5372 | classes[size] = size;
|
5373 | }
|
5374 | const CloseIcon = closeable && createVNode(Icon, {
|
5375 | "name": "cross",
|
5376 | "class": [bem$1b("close"), HAPTICS_FEEDBACK],
|
5377 | "onClick": onClose
|
5378 | }, null);
|
5379 | return createVNode("span", {
|
5380 | "style": getStyle(),
|
5381 | "class": bem$1b([classes, type])
|
5382 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots), CloseIcon]);
|
5383 | };
|
5384 | return () => createVNode(Transition, {
|
5385 | "name": props2.closeable ? "van-fade" : void 0
|
5386 | }, {
|
5387 | default: () => [props2.show ? renderTag() : null]
|
5388 | });
|
5389 | }
|
5390 | });
|
5391 | const Tag = withInstall(stdin_default$1p);
|
5392 | const checkerProps = {
|
5393 | name: unknownProp,
|
5394 | disabled: Boolean,
|
5395 | iconSize: numericProp,
|
5396 | modelValue: unknownProp,
|
5397 | checkedColor: String,
|
5398 | labelPosition: String,
|
5399 | labelDisabled: Boolean
|
5400 | };
|
5401 | var stdin_default$1o = defineComponent({
|
5402 | props: extend({}, checkerProps, {
|
5403 | bem: makeRequiredProp(Function),
|
5404 | role: String,
|
5405 | shape: String,
|
5406 | parent: Object,
|
5407 | checked: Boolean,
|
5408 | bindGroup: truthProp,
|
5409 | indeterminate: {
|
5410 | type: Boolean,
|
5411 | default: null
|
5412 | }
|
5413 | }),
|
5414 | emits: ["click", "toggle"],
|
5415 | setup(props2, {
|
5416 | emit,
|
5417 | slots
|
5418 | }) {
|
5419 | const iconRef = ref();
|
5420 | const getParentProp = (name2) => {
|
5421 | if (props2.parent && props2.bindGroup) {
|
5422 | return props2.parent.props[name2];
|
5423 | }
|
5424 | };
|
5425 | const disabled = computed(() => {
|
5426 | if (props2.parent && props2.bindGroup) {
|
5427 | const disabled2 = getParentProp("disabled") || props2.disabled;
|
5428 | if (props2.role === "checkbox") {
|
5429 | const checkedCount = getParentProp("modelValue").length;
|
5430 | const max = getParentProp("max");
|
5431 | const overlimit = max && checkedCount >= +max;
|
5432 | return disabled2 || overlimit && !props2.checked;
|
5433 | }
|
5434 | return disabled2;
|
5435 | }
|
5436 | return props2.disabled;
|
5437 | });
|
5438 | const direction = computed(() => getParentProp("direction"));
|
5439 | const iconStyle = computed(() => {
|
5440 | const checkedColor = props2.checkedColor || getParentProp("checkedColor");
|
5441 | if (checkedColor && props2.checked && !disabled.value) {
|
5442 | return {
|
5443 | borderColor: checkedColor,
|
5444 | backgroundColor: checkedColor
|
5445 | };
|
5446 | }
|
5447 | });
|
5448 | const shape = computed(() => {
|
5449 | return props2.shape || getParentProp("shape") || "round";
|
5450 | });
|
5451 | const onClick = (event) => {
|
5452 | const {
|
5453 | target
|
5454 | } = event;
|
5455 | const icon = iconRef.value;
|
5456 | const iconClicked = icon === target || (icon == null ? void 0 : icon.contains(target));
|
5457 | if (!disabled.value && (iconClicked || !props2.labelDisabled)) {
|
5458 | emit("toggle");
|
5459 | }
|
5460 | emit("click", event);
|
5461 | };
|
5462 | const renderIcon = () => {
|
5463 | var _a, _b;
|
5464 | const {
|
5465 | bem: bem2,
|
5466 | checked,
|
5467 | indeterminate
|
5468 | } = props2;
|
5469 | const iconSize = props2.iconSize || getParentProp("iconSize");
|
5470 | return createVNode("div", {
|
5471 | "ref": iconRef,
|
5472 | "class": bem2("icon", [shape.value, {
|
5473 | disabled: disabled.value,
|
5474 | checked,
|
5475 | indeterminate
|
5476 | }]),
|
5477 | "style": shape.value !== "dot" ? {
|
5478 | fontSize: addUnit(iconSize)
|
5479 | } : {
|
5480 | width: addUnit(iconSize),
|
5481 | height: addUnit(iconSize),
|
5482 | borderColor: (_a = iconStyle.value) == null ? void 0 : _a.borderColor
|
5483 | }
|
5484 | }, [slots.icon ? slots.icon({
|
5485 | checked,
|
5486 | disabled: disabled.value
|
5487 | }) : shape.value !== "dot" ? createVNode(Icon, {
|
5488 | "name": indeterminate ? "minus" : "success",
|
5489 | "style": iconStyle.value
|
5490 | }, null) : createVNode("div", {
|
5491 | "class": bem2("icon--dot__icon"),
|
5492 | "style": {
|
5493 | backgroundColor: (_b = iconStyle.value) == null ? void 0 : _b.backgroundColor
|
5494 | }
|
5495 | }, null)]);
|
5496 | };
|
5497 | const renderLabel = () => {
|
5498 | const {
|
5499 | checked
|
5500 | } = props2;
|
5501 | if (slots.default) {
|
5502 | return createVNode("span", {
|
5503 | "class": props2.bem("label", [props2.labelPosition, {
|
5504 | disabled: disabled.value
|
5505 | }])
|
5506 | }, [slots.default({
|
5507 | checked,
|
5508 | disabled: disabled.value
|
5509 | })]);
|
5510 | }
|
5511 | };
|
5512 | return () => {
|
5513 | const nodes = props2.labelPosition === "left" ? [renderLabel(), renderIcon()] : [renderIcon(), renderLabel()];
|
5514 | return createVNode("div", {
|
5515 | "role": props2.role,
|
5516 | "class": props2.bem([{
|
5517 | disabled: disabled.value,
|
5518 | "label-disabled": props2.labelDisabled
|
5519 | }, direction.value]),
|
5520 | "tabindex": disabled.value ? void 0 : 0,
|
5521 | "aria-checked": props2.checked,
|
5522 | "onClick": onClick
|
5523 | }, [nodes]);
|
5524 | };
|
5525 | }
|
5526 | });
|
5527 | const radioProps = extend({}, checkerProps, {
|
5528 | shape: String
|
5529 | });
|
5530 | const [name$1e, bem$1a] = createNamespace("radio");
|
5531 | var stdin_default$1n = defineComponent({
|
5532 | name: name$1e,
|
5533 | props: radioProps,
|
5534 | emits: ["update:modelValue"],
|
5535 | setup(props2, {
|
5536 | emit,
|
5537 | slots
|
5538 | }) {
|
5539 | const {
|
5540 | parent
|
5541 | } = useParent(RADIO_KEY);
|
5542 | const checked = () => {
|
5543 | const value = parent ? parent.props.modelValue : props2.modelValue;
|
5544 | return value === props2.name;
|
5545 | };
|
5546 | const toggle = () => {
|
5547 | if (parent) {
|
5548 | parent.updateValue(props2.name);
|
5549 | } else {
|
5550 | emit("update:modelValue", props2.name);
|
5551 | }
|
5552 | };
|
5553 | return () => createVNode(stdin_default$1o, mergeProps({
|
5554 | "bem": bem$1a,
|
5555 | "role": "radio",
|
5556 | "parent": parent,
|
5557 | "checked": checked(),
|
5558 | "onToggle": toggle
|
5559 | }, props2), pick(slots, ["default", "icon"]));
|
5560 | }
|
5561 | });
|
5562 | const Radio = withInstall(stdin_default$1n);
|
5563 | const [name$1d, bem$19] = createNamespace("address-item");
|
5564 | var stdin_default$1m = defineComponent({
|
5565 | name: name$1d,
|
5566 | props: {
|
5567 | address: makeRequiredProp(Object),
|
5568 | disabled: Boolean,
|
5569 | switchable: Boolean,
|
5570 | defaultTagText: String,
|
5571 | rightIcon: makeStringProp("edit")
|
5572 | },
|
5573 | emits: ["edit", "click", "select"],
|
5574 | setup(props2, {
|
5575 | slots,
|
5576 | emit
|
5577 | }) {
|
5578 | const onClick = () => {
|
5579 | if (props2.switchable) {
|
5580 | emit("select");
|
5581 | }
|
5582 | emit("click");
|
5583 | };
|
5584 | const renderRightIcon = () => createVNode(Icon, {
|
5585 | "name": props2.rightIcon,
|
5586 | "class": bem$19("edit"),
|
5587 | "onClick": (event) => {
|
5588 | event.stopPropagation();
|
5589 | emit("edit");
|
5590 | emit("click");
|
5591 | }
|
5592 | }, null);
|
5593 | const renderTag = () => {
|
5594 | if (slots.tag) {
|
5595 | return slots.tag(props2.address);
|
5596 | }
|
5597 | if (props2.address.isDefault && props2.defaultTagText) {
|
5598 | return createVNode(Tag, {
|
5599 | "type": "primary",
|
5600 | "round": true,
|
5601 | "class": bem$19("tag")
|
5602 | }, {
|
5603 | default: () => [props2.defaultTagText]
|
5604 | });
|
5605 | }
|
5606 | };
|
5607 | const renderContent = () => {
|
5608 | const {
|
5609 | address,
|
5610 | disabled,
|
5611 | switchable
|
5612 | } = props2;
|
5613 | const Info = [createVNode("div", {
|
5614 | "class": bem$19("name")
|
5615 | }, [`${address.name} ${address.tel}`, renderTag()]), createVNode("div", {
|
5616 | "class": bem$19("address")
|
5617 | }, [address.address])];
|
5618 | if (switchable && !disabled) {
|
5619 | return createVNode(Radio, {
|
5620 | "name": address.id,
|
5621 | "iconSize": 18
|
5622 | }, {
|
5623 | default: () => [Info]
|
5624 | });
|
5625 | }
|
5626 | return Info;
|
5627 | };
|
5628 | return () => {
|
5629 | var _a;
|
5630 | const {
|
5631 | disabled
|
5632 | } = props2;
|
5633 | return createVNode("div", {
|
5634 | "class": bem$19({
|
5635 | disabled
|
5636 | }),
|
5637 | "onClick": onClick
|
5638 | }, [createVNode(Cell, {
|
5639 | "border": false,
|
5640 | "titleClass": bem$19("title")
|
5641 | }, {
|
5642 | title: renderContent,
|
5643 | "right-icon": renderRightIcon
|
5644 | }), (_a = slots.bottom) == null ? void 0 : _a.call(slots, extend({}, props2.address, {
|
5645 | disabled
|
5646 | }))]);
|
5647 | };
|
5648 | }
|
5649 | });
|
5650 | const [name$1c, bem$18, t$h] = createNamespace("address-list");
|
5651 | const addressListProps = {
|
5652 | list: makeArrayProp(),
|
5653 | modelValue: numericProp,
|
5654 | switchable: truthProp,
|
5655 | disabledText: String,
|
5656 | disabledList: makeArrayProp(),
|
5657 | showAddButton: truthProp,
|
5658 | addButtonText: String,
|
5659 | defaultTagText: String,
|
5660 | rightIcon: makeStringProp("edit")
|
5661 | };
|
5662 | var stdin_default$1l = defineComponent({
|
5663 | name: name$1c,
|
5664 | props: addressListProps,
|
5665 | emits: ["add", "edit", "select", "clickItem", "editDisabled", "selectDisabled", "update:modelValue"],
|
5666 | setup(props2, {
|
5667 | slots,
|
5668 | emit
|
5669 | }) {
|
5670 | const renderItem = (item, index, disabled) => {
|
5671 | const onEdit = () => emit(disabled ? "editDisabled" : "edit", item, index);
|
5672 | const onClick = () => emit("clickItem", item, index);
|
5673 | const onSelect = () => {
|
5674 | emit(disabled ? "selectDisabled" : "select", item, index);
|
5675 | if (!disabled) {
|
5676 | emit("update:modelValue", item.id);
|
5677 | }
|
5678 | };
|
5679 | return createVNode(stdin_default$1m, {
|
5680 | "key": item.id,
|
5681 | "address": item,
|
5682 | "disabled": disabled,
|
5683 | "switchable": props2.switchable,
|
5684 | "defaultTagText": props2.defaultTagText,
|
5685 | "rightIcon": props2.rightIcon,
|
5686 | "onEdit": onEdit,
|
5687 | "onClick": onClick,
|
5688 | "onSelect": onSelect
|
5689 | }, {
|
5690 | bottom: slots["item-bottom"],
|
5691 | tag: slots.tag
|
5692 | });
|
5693 | };
|
5694 | const renderList = (list, disabled) => {
|
5695 | if (list) {
|
5696 | return list.map((item, index) => renderItem(item, index, disabled));
|
5697 | }
|
5698 | };
|
5699 | const renderBottom = () => props2.showAddButton ? createVNode("div", {
|
5700 | "class": [bem$18("bottom"), "van-safe-area-bottom"]
|
5701 | }, [createVNode(Button, {
|
5702 | "round": true,
|
5703 | "block": true,
|
5704 | "type": "primary",
|
5705 | "text": props2.addButtonText || t$h("add"),
|
5706 | "class": bem$18("add"),
|
5707 | "onClick": () => emit("add")
|
5708 | }, null)]) : void 0;
|
5709 | return () => {
|
5710 | var _a, _b;
|
5711 | const List2 = renderList(props2.list);
|
5712 | const DisabledList = renderList(props2.disabledList, true);
|
5713 | const DisabledText = props2.disabledText && createVNode("div", {
|
5714 | "class": bem$18("disabled-text")
|
5715 | }, [props2.disabledText]);
|
5716 | return createVNode("div", {
|
5717 | "class": bem$18()
|
5718 | }, [(_a = slots.top) == null ? void 0 : _a.call(slots), createVNode(RadioGroup, {
|
5719 | "modelValue": props2.modelValue
|
5720 | }, {
|
5721 | default: () => [List2]
|
5722 | }), DisabledText, DisabledList, (_b = slots.default) == null ? void 0 : _b.call(slots), renderBottom()]);
|
5723 | };
|
5724 | }
|
5725 | });
|
5726 | const AddressList = withInstall(stdin_default$1l);
|
5727 | const hasIntersectionObserver = inBrowser$1 && "IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype;
|
5728 | const modeType = {
|
5729 | event: "event",
|
5730 | observer: "observer"
|
5731 | };
|
5732 | function remove(arr, item) {
|
5733 | if (!arr.length)
|
5734 | return;
|
5735 | const index = arr.indexOf(item);
|
5736 | if (index > -1)
|
5737 | return arr.splice(index, 1);
|
5738 | }
|
5739 | function getBestSelectionFromSrcset(el, scale) {
|
5740 | if (el.tagName !== "IMG" || !el.getAttribute("data-srcset"))
|
5741 | return;
|
5742 | let options = el.getAttribute("data-srcset");
|
5743 | const container = el.parentNode;
|
5744 | const containerWidth = container.offsetWidth * scale;
|
5745 | let spaceIndex;
|
5746 | let tmpSrc;
|
5747 | let tmpWidth;
|
5748 | options = options.trim().split(",");
|
5749 | const result = options.map((item) => {
|
5750 | item = item.trim();
|
5751 | spaceIndex = item.lastIndexOf(" ");
|
5752 | if (spaceIndex === -1) {
|
5753 | tmpSrc = item;
|
5754 | tmpWidth = 999998;
|
5755 | } else {
|
5756 | tmpSrc = item.substr(0, spaceIndex);
|
5757 | tmpWidth = parseInt(
|
5758 | item.substr(spaceIndex + 1, item.length - spaceIndex - 2),
|
5759 | 10
|
5760 | );
|
5761 | }
|
5762 | return [tmpWidth, tmpSrc];
|
5763 | });
|
5764 | result.sort((a, b) => {
|
5765 | if (a[0] < b[0]) {
|
5766 | return 1;
|
5767 | }
|
5768 | if (a[0] > b[0]) {
|
5769 | return -1;
|
5770 | }
|
5771 | if (a[0] === b[0]) {
|
5772 | if (b[1].indexOf(".webp", b[1].length - 5) !== -1) {
|
5773 | return 1;
|
5774 | }
|
5775 | if (a[1].indexOf(".webp", a[1].length - 5) !== -1) {
|
5776 | return -1;
|
5777 | }
|
5778 | }
|
5779 | return 0;
|
5780 | });
|
5781 | let bestSelectedSrc = "";
|
5782 | let tmpOption;
|
5783 | for (let i = 0; i < result.length; i++) {
|
5784 | tmpOption = result[i];
|
5785 | bestSelectedSrc = tmpOption[1];
|
5786 | const next = result[i + 1];
|
5787 | if (next && next[0] < containerWidth) {
|
5788 | bestSelectedSrc = tmpOption[1];
|
5789 | break;
|
5790 | } else if (!next) {
|
5791 | bestSelectedSrc = tmpOption[1];
|
5792 | break;
|
5793 | }
|
5794 | }
|
5795 | return bestSelectedSrc;
|
5796 | }
|
5797 | const getDPR = (scale = 1) => inBrowser$1 ? window.devicePixelRatio || scale : scale;
|
5798 | function supportWebp() {
|
5799 | if (!inBrowser$1)
|
5800 | return false;
|
5801 | let support = true;
|
5802 | try {
|
5803 | const elem = document.createElement("canvas");
|
5804 | if (elem.getContext && elem.getContext("2d")) {
|
5805 | support = elem.toDataURL("image/webp").indexOf("data:image/webp") === 0;
|
5806 | }
|
5807 | } catch (err) {
|
5808 | support = false;
|
5809 | }
|
5810 | return support;
|
5811 | }
|
5812 | function throttle(action, delay) {
|
5813 | let timeout = null;
|
5814 | let lastRun = 0;
|
5815 | return function(...args) {
|
5816 | if (timeout) {
|
5817 | return;
|
5818 | }
|
5819 | const elapsed = Date.now() - lastRun;
|
5820 | const runCallback = () => {
|
5821 | lastRun = Date.now();
|
5822 | timeout = false;
|
5823 | action.apply(this, args);
|
5824 | };
|
5825 | if (elapsed >= delay) {
|
5826 | runCallback();
|
5827 | } else {
|
5828 | timeout = setTimeout(runCallback, delay);
|
5829 | }
|
5830 | };
|
5831 | }
|
5832 | function on(el, type, func) {
|
5833 | el.addEventListener(type, func, {
|
5834 | capture: false,
|
5835 | passive: true
|
5836 | });
|
5837 | }
|
5838 | function off(el, type, func) {
|
5839 | el.removeEventListener(type, func, false);
|
5840 | }
|
5841 | const loadImageAsync = (item, resolve, reject) => {
|
5842 | const image = new Image();
|
5843 | if (!item || !item.src) {
|
5844 | return reject(new Error("image src is required"));
|
5845 | }
|
5846 | image.src = item.src;
|
5847 | if (item.cors) {
|
5848 | image.crossOrigin = item.cors;
|
5849 | }
|
5850 | image.onload = () => resolve({
|
5851 | naturalHeight: image.naturalHeight,
|
5852 | naturalWidth: image.naturalWidth,
|
5853 | src: image.src
|
5854 | });
|
5855 | image.onerror = (e) => reject(e);
|
5856 | };
|
5857 | class ImageCache {
|
5858 | constructor({ max }) {
|
5859 | this.options = {
|
5860 | max: max || 100
|
5861 | };
|
5862 | this.caches = [];
|
5863 | }
|
5864 | has(key) {
|
5865 | return this.caches.indexOf(key) > -1;
|
5866 | }
|
5867 | add(key) {
|
5868 | if (this.has(key))
|
5869 | return;
|
5870 | this.caches.push(key);
|
5871 | if (this.caches.length > this.options.max) {
|
5872 | this.free();
|
5873 | }
|
5874 | }
|
5875 | free() {
|
5876 | this.caches.shift();
|
5877 | }
|
5878 | }
|
5879 | const [name$1b, bem$17] = createNamespace("back-top");
|
5880 | const backTopProps = {
|
5881 | right: numericProp,
|
5882 | bottom: numericProp,
|
5883 | zIndex: numericProp,
|
5884 | target: [String, Object],
|
5885 | offset: makeNumericProp(200),
|
5886 | immediate: Boolean,
|
5887 | teleport: {
|
5888 | type: [String, Object],
|
5889 | default: "body"
|
5890 | }
|
5891 | };
|
5892 | var stdin_default$1k = defineComponent({
|
5893 | name: name$1b,
|
5894 | inheritAttrs: false,
|
5895 | props: backTopProps,
|
5896 | emits: ["click"],
|
5897 | setup(props2, {
|
5898 | emit,
|
5899 | slots,
|
5900 | attrs
|
5901 | }) {
|
5902 | let shouldReshow = false;
|
5903 | const show = ref(false);
|
5904 | const root = ref();
|
5905 | const scrollParent = ref();
|
5906 | const style = computed(() => extend(getZIndexStyle(props2.zIndex), {
|
5907 | right: addUnit(props2.right),
|
5908 | bottom: addUnit(props2.bottom)
|
5909 | }));
|
5910 | const onClick = (event) => {
|
5911 | var _a;
|
5912 | emit("click", event);
|
5913 | (_a = scrollParent.value) == null ? void 0 : _a.scrollTo({
|
5914 | top: 0,
|
5915 | behavior: props2.immediate ? "auto" : "smooth"
|
5916 | });
|
5917 | };
|
5918 | const scroll = () => {
|
5919 | show.value = scrollParent.value ? getScrollTop(scrollParent.value) >= +props2.offset : false;
|
5920 | };
|
5921 | const getTarget = () => {
|
5922 | const {
|
5923 | target
|
5924 | } = props2;
|
5925 | if (typeof target === "string") {
|
5926 | const el = document.querySelector(target);
|
5927 | if (el) {
|
5928 | return el;
|
5929 | }
|
5930 | if (process.env.NODE_ENV !== "production") {
|
5931 | console.error(`[Vant] BackTop: target element "${target}" was not found, the BackTop component will not be rendered.`);
|
5932 | }
|
5933 | } else {
|
5934 | return target;
|
5935 | }
|
5936 | };
|
5937 | const updateTarget = () => {
|
5938 | if (inBrowser) {
|
5939 | nextTick(() => {
|
5940 | scrollParent.value = props2.target ? getTarget() : getScrollParent(root.value);
|
5941 | scroll();
|
5942 | });
|
5943 | }
|
5944 | };
|
5945 | useEventListener("scroll", throttle(scroll, 100), {
|
5946 | target: scrollParent
|
5947 | });
|
5948 | onMounted(updateTarget);
|
5949 | onActivated(() => {
|
5950 | if (shouldReshow) {
|
5951 | show.value = true;
|
5952 | shouldReshow = false;
|
5953 | }
|
5954 | });
|
5955 | onDeactivated(() => {
|
5956 | if (show.value && props2.teleport) {
|
5957 | show.value = false;
|
5958 | shouldReshow = true;
|
5959 | }
|
5960 | });
|
5961 | watch(() => props2.target, updateTarget);
|
5962 | return () => {
|
5963 | const Content = createVNode("div", mergeProps({
|
5964 | "ref": !props2.teleport ? root : void 0,
|
5965 | "class": bem$17({
|
5966 | active: show.value
|
5967 | }),
|
5968 | "style": style.value,
|
5969 | "onClick": onClick
|
5970 | }, attrs), [slots.default ? slots.default() : createVNode(Icon, {
|
5971 | "name": "back-top",
|
5972 | "class": bem$17("icon")
|
5973 | }, null)]);
|
5974 | if (props2.teleport) {
|
5975 | return [createVNode("div", {
|
5976 | "ref": root,
|
5977 | "class": bem$17("placeholder")
|
5978 | }, null), createVNode(Teleport, {
|
5979 | "to": props2.teleport
|
5980 | }, {
|
5981 | default: () => [Content]
|
5982 | })];
|
5983 | }
|
5984 | return Content;
|
5985 | };
|
5986 | }
|
5987 | });
|
5988 | const BackTop = withInstall(stdin_default$1k);
|
5989 | var __async = (__this, __arguments, generator) => {
|
5990 | return new Promise((resolve, reject) => {
|
5991 | var fulfilled = (value) => {
|
5992 | try {
|
5993 | step(generator.next(value));
|
5994 | } catch (e) {
|
5995 | reject(e);
|
5996 | }
|
5997 | };
|
5998 | var rejected = (value) => {
|
5999 | try {
|
6000 | step(generator.throw(value));
|
6001 | } catch (e) {
|
6002 | reject(e);
|
6003 | }
|
6004 | };
|
6005 | var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
6006 | step((generator = generator.apply(__this, __arguments)).next());
|
6007 | });
|
6008 | };
|
6009 | const barrageProps = {
|
6010 | top: makeNumericProp(10),
|
6011 | rows: makeNumericProp(4),
|
6012 | duration: makeNumericProp(4e3),
|
6013 | autoPlay: truthProp,
|
6014 | delay: makeNumberProp(300),
|
6015 | modelValue: makeArrayProp()
|
6016 | };
|
6017 | const [name$1a, bem$16] = createNamespace("barrage");
|
6018 | var stdin_default$1j = defineComponent({
|
6019 | name: name$1a,
|
6020 | props: barrageProps,
|
6021 | emits: ["update:modelValue"],
|
6022 | setup(props2, {
|
6023 | emit,
|
6024 | slots
|
6025 | }) {
|
6026 | const barrageWrapper = ref();
|
6027 | const className = bem$16("item");
|
6028 | const total = ref(0);
|
6029 | const barrageItems = [];
|
6030 | const createBarrageItem = (text, delay = props2.delay) => {
|
6031 | const item = document.createElement("span");
|
6032 | item.className = className;
|
6033 | item.innerText = String(text);
|
6034 | item.style.animationDuration = `${props2.duration}ms`;
|
6035 | item.style.animationDelay = `${delay}ms`;
|
6036 | item.style.animationName = "van-barrage";
|
6037 | item.style.animationTimingFunction = "linear";
|
6038 | return item;
|
6039 | };
|
6040 | const isInitBarrage = ref(true);
|
6041 | const isPlay = ref(props2.autoPlay);
|
6042 | const appendBarrageItem = ({
|
6043 | id,
|
6044 | text
|
6045 | }, i) => {
|
6046 | var _a;
|
6047 | const item = createBarrageItem(text, isInitBarrage.value ? i * props2.delay : void 0);
|
6048 | if (!props2.autoPlay && isPlay.value === false) {
|
6049 | item.style.animationPlayState = "paused";
|
6050 | }
|
6051 | (_a = barrageWrapper.value) == null ? void 0 : _a.append(item);
|
6052 | total.value++;
|
6053 | const top = (total.value - 1) % +props2.rows * item.offsetHeight + +props2.top;
|
6054 | item.style.top = `${top}px`;
|
6055 | item.dataset.id = String(id);
|
6056 | barrageItems.push(item);
|
6057 | item.addEventListener("animationend", () => {
|
6058 | emit("update:modelValue", [...props2.modelValue].filter((v) => String(v.id) !== item.dataset.id));
|
6059 | });
|
6060 | };
|
6061 | const updateBarrages = (newValue, oldValue) => {
|
6062 | const map = new Map(oldValue.map((item) => [item.id, item]));
|
6063 | newValue.forEach((item, i) => {
|
6064 | if (map.has(item.id)) {
|
6065 | map.delete(item.id);
|
6066 | } else {
|
6067 | appendBarrageItem(item, i);
|
6068 | }
|
6069 | });
|
6070 | map.forEach((item) => {
|
6071 | const index = barrageItems.findIndex((span) => span.dataset.id === String(item.id));
|
6072 | if (index > -1) {
|
6073 | barrageItems[index].remove();
|
6074 | barrageItems.splice(index, 1);
|
6075 | }
|
6076 | });
|
6077 | isInitBarrage.value = false;
|
6078 | };
|
6079 | watch(() => props2.modelValue.slice(), (newValue, oldValue) => updateBarrages(newValue != null ? newValue : [], oldValue != null ? oldValue : []), {
|
6080 | deep: true
|
6081 | });
|
6082 | const rootStyle = ref({});
|
6083 | onMounted(() => __async(this, null, function* () {
|
6084 | var _a;
|
6085 | rootStyle.value["--move-distance"] = `-${(_a = barrageWrapper.value) == null ? void 0 : _a.offsetWidth}px`;
|
6086 | yield nextTick();
|
6087 | updateBarrages(props2.modelValue, []);
|
6088 | }));
|
6089 | const play = () => {
|
6090 | isPlay.value = true;
|
6091 | barrageItems.forEach((item) => {
|
6092 | item.style.animationPlayState = "running";
|
6093 | });
|
6094 | };
|
6095 | const pause = () => {
|
6096 | isPlay.value = false;
|
6097 | barrageItems.forEach((item) => {
|
6098 | item.style.animationPlayState = "paused";
|
6099 | });
|
6100 | };
|
6101 | useExpose({
|
6102 | play,
|
6103 | pause
|
6104 | });
|
6105 | return () => {
|
6106 | var _a;
|
6107 | return createVNode("div", {
|
6108 | "class": bem$16(),
|
6109 | "ref": barrageWrapper,
|
6110 | "style": rootStyle.value
|
6111 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
6112 | };
|
6113 | }
|
6114 | });
|
6115 | const Barrage = withInstall(stdin_default$1j);
|
6116 | const [name$19, bem$15, t$g] = createNamespace("calendar");
|
6117 | const formatMonthTitle = (date) => t$g("monthTitle", date.getFullYear(), date.getMonth() + 1);
|
6118 | function compareMonth(date1, date2) {
|
6119 | const year1 = date1.getFullYear();
|
6120 | const year2 = date2.getFullYear();
|
6121 | if (year1 === year2) {
|
6122 | const month1 = date1.getMonth();
|
6123 | const month2 = date2.getMonth();
|
6124 | return month1 === month2 ? 0 : month1 > month2 ? 1 : -1;
|
6125 | }
|
6126 | return year1 > year2 ? 1 : -1;
|
6127 | }
|
6128 | function compareDay(day1, day2) {
|
6129 | const compareMonthResult = compareMonth(day1, day2);
|
6130 | if (compareMonthResult === 0) {
|
6131 | const date1 = day1.getDate();
|
6132 | const date2 = day2.getDate();
|
6133 | return date1 === date2 ? 0 : date1 > date2 ? 1 : -1;
|
6134 | }
|
6135 | return compareMonthResult;
|
6136 | }
|
6137 | const cloneDate = (date) => new Date(date);
|
6138 | const cloneDates = (dates) => Array.isArray(dates) ? dates.map(cloneDate) : cloneDate(dates);
|
6139 | function getDayByOffset(date, offset) {
|
6140 | const cloned = cloneDate(date);
|
6141 | cloned.setDate(cloned.getDate() + offset);
|
6142 | return cloned;
|
6143 | }
|
6144 | const getPrevDay = (date) => getDayByOffset(date, -1);
|
6145 | const getNextDay = (date) => getDayByOffset(date, 1);
|
6146 | const getToday = () => {
|
6147 | const today = new Date();
|
6148 | today.setHours(0, 0, 0, 0);
|
6149 | return today;
|
6150 | };
|
6151 | function calcDateNum(date) {
|
6152 | const day1 = date[0].getTime();
|
6153 | const day2 = date[1].getTime();
|
6154 | return (day2 - day1) / (1e3 * 60 * 60 * 24) + 1;
|
6155 | }
|
6156 | const sharedProps = extend({}, pickerSharedProps, {
|
6157 | modelValue: makeArrayProp(),
|
6158 | filter: Function,
|
6159 | formatter: {
|
6160 | type: Function,
|
6161 | default: (type, option) => option
|
6162 | }
|
6163 | });
|
6164 | const pickerInheritKeys = Object.keys(pickerSharedProps);
|
6165 | function times(n, iteratee) {
|
6166 | if (n < 0) {
|
6167 | return [];
|
6168 | }
|
6169 | const result = Array(n);
|
6170 | let index = -1;
|
6171 | while (++index < n) {
|
6172 | result[index] = iteratee(index);
|
6173 | }
|
6174 | return result;
|
6175 | }
|
6176 | const getMonthEndDay = (year, month) => 32 - new Date(year, month - 1, 32).getDate();
|
6177 | const genOptions = (min, max, type, formatter, filter, values) => {
|
6178 | const options = times(max - min + 1, (index) => {
|
6179 | const value = padZero(min + index);
|
6180 | return formatter(type, {
|
6181 | text: value,
|
6182 | value
|
6183 | });
|
6184 | });
|
6185 | return filter ? filter(type, options, values) : options;
|
6186 | };
|
6187 | const formatValueRange = (values, columns) => values.map((value, index) => {
|
6188 | const column = columns[index];
|
6189 | if (column.length) {
|
6190 | const minValue = +column[0].value;
|
6191 | const maxValue = +column[column.length - 1].value;
|
6192 | return padZero(clamp(+value, minValue, maxValue));
|
6193 | }
|
6194 | return value;
|
6195 | });
|
6196 | const [name$18] = createNamespace("calendar-day");
|
6197 | var stdin_default$1i = defineComponent({
|
6198 | name: name$18,
|
6199 | props: {
|
6200 | item: makeRequiredProp(Object),
|
6201 | color: String,
|
6202 | index: Number,
|
6203 | offset: makeNumberProp(0),
|
6204 | rowHeight: String
|
6205 | },
|
6206 | emits: ["click", "clickDisabledDate"],
|
6207 | setup(props2, {
|
6208 | emit,
|
6209 | slots
|
6210 | }) {
|
6211 | const style = computed(() => {
|
6212 | var _a;
|
6213 | const {
|
6214 | item,
|
6215 | index,
|
6216 | color,
|
6217 | offset,
|
6218 | rowHeight
|
6219 | } = props2;
|
6220 | const style2 = {
|
6221 | height: rowHeight
|
6222 | };
|
6223 | if (item.type === "placeholder") {
|
6224 | style2.width = "100%";
|
6225 | return style2;
|
6226 | }
|
6227 | if (index === 0) {
|
6228 | style2.marginLeft = `${100 * offset / 7}%`;
|
6229 | }
|
6230 | if (color) {
|
6231 | switch (item.type) {
|
6232 | case "end":
|
6233 | case "start":
|
6234 | case "start-end":
|
6235 | case "multiple-middle":
|
6236 | case "multiple-selected":
|
6237 | style2.background = color;
|
6238 | break;
|
6239 | case "middle":
|
6240 | style2.color = color;
|
6241 | break;
|
6242 | }
|
6243 | }
|
6244 | if (offset + (((_a = item.date) == null ? void 0 : _a.getDate()) || 1) > 28) {
|
6245 | style2.marginBottom = 0;
|
6246 | }
|
6247 | return style2;
|
6248 | });
|
6249 | const onClick = () => {
|
6250 | if (props2.item.type !== "disabled") {
|
6251 | emit("click", props2.item);
|
6252 | } else {
|
6253 | emit("clickDisabledDate", props2.item);
|
6254 | }
|
6255 | };
|
6256 | const renderTopInfo = () => {
|
6257 | const {
|
6258 | topInfo
|
6259 | } = props2.item;
|
6260 | if (topInfo || slots["top-info"]) {
|
6261 | return createVNode("div", {
|
6262 | "class": bem$15("top-info")
|
6263 | }, [slots["top-info"] ? slots["top-info"](props2.item) : topInfo]);
|
6264 | }
|
6265 | };
|
6266 | const renderBottomInfo = () => {
|
6267 | const {
|
6268 | bottomInfo
|
6269 | } = props2.item;
|
6270 | if (bottomInfo || slots["bottom-info"]) {
|
6271 | return createVNode("div", {
|
6272 | "class": bem$15("bottom-info")
|
6273 | }, [slots["bottom-info"] ? slots["bottom-info"](props2.item) : bottomInfo]);
|
6274 | }
|
6275 | };
|
6276 | const renderContent = () => {
|
6277 | const {
|
6278 | item,
|
6279 | color,
|
6280 | rowHeight
|
6281 | } = props2;
|
6282 | const {
|
6283 | type,
|
6284 | text
|
6285 | } = item;
|
6286 | const Nodes = [renderTopInfo(), text, renderBottomInfo()];
|
6287 | if (type === "selected") {
|
6288 | return createVNode("div", {
|
6289 | "class": bem$15("selected-day"),
|
6290 | "style": {
|
6291 | width: rowHeight,
|
6292 | height: rowHeight,
|
6293 | background: color
|
6294 | }
|
6295 | }, [Nodes]);
|
6296 | }
|
6297 | return Nodes;
|
6298 | };
|
6299 | return () => {
|
6300 | const {
|
6301 | type,
|
6302 | className
|
6303 | } = props2.item;
|
6304 | if (type === "placeholder") {
|
6305 | return createVNode("div", {
|
6306 | "class": bem$15("day"),
|
6307 | "style": style.value
|
6308 | }, null);
|
6309 | }
|
6310 | return createVNode("div", {
|
6311 | "role": "gridcell",
|
6312 | "style": style.value,
|
6313 | "class": [bem$15("day", type), className],
|
6314 | "tabindex": type === "disabled" ? void 0 : -1,
|
6315 | "onClick": onClick
|
6316 | }, [renderContent()]);
|
6317 | };
|
6318 | }
|
6319 | });
|
6320 | const [name$17] = createNamespace("calendar-month");
|
6321 | const calendarMonthProps = {
|
6322 | date: makeRequiredProp(Date),
|
6323 | type: String,
|
6324 | color: String,
|
6325 | minDate: makeRequiredProp(Date),
|
6326 | maxDate: makeRequiredProp(Date),
|
6327 | showMark: Boolean,
|
6328 | rowHeight: numericProp,
|
6329 | formatter: Function,
|
6330 | lazyRender: Boolean,
|
6331 | currentDate: [Date, Array],
|
6332 | allowSameDay: Boolean,
|
6333 | showSubtitle: Boolean,
|
6334 | showMonthTitle: Boolean,
|
6335 | firstDayOfWeek: Number
|
6336 | };
|
6337 | var stdin_default$1h = defineComponent({
|
6338 | name: name$17,
|
6339 | props: calendarMonthProps,
|
6340 | emits: ["click", "clickDisabledDate"],
|
6341 | setup(props2, {
|
6342 | emit,
|
6343 | slots
|
6344 | }) {
|
6345 | const [visible, setVisible] = useToggle();
|
6346 | const daysRef = ref();
|
6347 | const monthRef = ref();
|
6348 | const height = useHeight(monthRef);
|
6349 | const title = computed(() => formatMonthTitle(props2.date));
|
6350 | const rowHeight = computed(() => addUnit(props2.rowHeight));
|
6351 | const offset = computed(() => {
|
6352 | const realDay = props2.date.getDay();
|
6353 | if (props2.firstDayOfWeek) {
|
6354 | return (realDay + 7 - props2.firstDayOfWeek) % 7;
|
6355 | }
|
6356 | return realDay;
|
6357 | });
|
6358 | const totalDay = computed(() => getMonthEndDay(props2.date.getFullYear(), props2.date.getMonth() + 1));
|
6359 | const shouldRender = computed(() => visible.value || !props2.lazyRender);
|
6360 | const getTitle = () => title.value;
|
6361 | const getMultipleDayType = (day) => {
|
6362 | const isSelected = (date) => props2.currentDate.some((item) => compareDay(item, date) === 0);
|
6363 | if (isSelected(day)) {
|
6364 | const prevDay = getPrevDay(day);
|
6365 | const nextDay = getNextDay(day);
|
6366 | const prevSelected = isSelected(prevDay);
|
6367 | const nextSelected = isSelected(nextDay);
|
6368 | if (prevSelected && nextSelected) {
|
6369 | return "multiple-middle";
|
6370 | }
|
6371 | if (prevSelected) {
|
6372 | return "end";
|
6373 | }
|
6374 | if (nextSelected) {
|
6375 | return "start";
|
6376 | }
|
6377 | return "multiple-selected";
|
6378 | }
|
6379 | return "";
|
6380 | };
|
6381 | const getRangeDayType = (day) => {
|
6382 | const [startDay, endDay] = props2.currentDate;
|
6383 | if (!startDay) {
|
6384 | return "";
|
6385 | }
|
6386 | const compareToStart = compareDay(day, startDay);
|
6387 | if (!endDay) {
|
6388 | return compareToStart === 0 ? "start" : "";
|
6389 | }
|
6390 | const compareToEnd = compareDay(day, endDay);
|
6391 | if (props2.allowSameDay && compareToStart === 0 && compareToEnd === 0) {
|
6392 | return "start-end";
|
6393 | }
|
6394 | if (compareToStart === 0) {
|
6395 | return "start";
|
6396 | }
|
6397 | if (compareToEnd === 0) {
|
6398 | return "end";
|
6399 | }
|
6400 | if (compareToStart > 0 && compareToEnd < 0) {
|
6401 | return "middle";
|
6402 | }
|
6403 | return "";
|
6404 | };
|
6405 | const getDayType = (day) => {
|
6406 | const {
|
6407 | type,
|
6408 | minDate,
|
6409 | maxDate,
|
6410 | currentDate
|
6411 | } = props2;
|
6412 | if (compareDay(day, minDate) < 0 || compareDay(day, maxDate) > 0) {
|
6413 | return "disabled";
|
6414 | }
|
6415 | if (currentDate === null) {
|
6416 | return "";
|
6417 | }
|
6418 | if (Array.isArray(currentDate)) {
|
6419 | if (type === "multiple") {
|
6420 | return getMultipleDayType(day);
|
6421 | }
|
6422 | if (type === "range") {
|
6423 | return getRangeDayType(day);
|
6424 | }
|
6425 | } else if (type === "single") {
|
6426 | return compareDay(day, currentDate) === 0 ? "selected" : "";
|
6427 | }
|
6428 | return "";
|
6429 | };
|
6430 | const getBottomInfo = (dayType) => {
|
6431 | if (props2.type === "range") {
|
6432 | if (dayType === "start" || dayType === "end") {
|
6433 | return t$g(dayType);
|
6434 | }
|
6435 | if (dayType === "start-end") {
|
6436 | return `${t$g("start")}/${t$g("end")}`;
|
6437 | }
|
6438 | }
|
6439 | };
|
6440 | const renderTitle = () => {
|
6441 | if (props2.showMonthTitle) {
|
6442 | return createVNode("div", {
|
6443 | "class": bem$15("month-title")
|
6444 | }, [slots["month-title"] ? slots["month-title"]({
|
6445 | date: props2.date,
|
6446 | text: title.value
|
6447 | }) : title.value]);
|
6448 | }
|
6449 | };
|
6450 | const renderMark = () => {
|
6451 | if (props2.showMark && shouldRender.value) {
|
6452 | return createVNode("div", {
|
6453 | "class": bem$15("month-mark")
|
6454 | }, [props2.date.getMonth() + 1]);
|
6455 | }
|
6456 | };
|
6457 | const placeholders = computed(() => {
|
6458 | const count = Math.ceil((totalDay.value + offset.value) / 7);
|
6459 | return Array(count).fill({
|
6460 | type: "placeholder"
|
6461 | });
|
6462 | });
|
6463 | const days = computed(() => {
|
6464 | const days2 = [];
|
6465 | const year = props2.date.getFullYear();
|
6466 | const month = props2.date.getMonth();
|
6467 | for (let day = 1; day <= totalDay.value; day++) {
|
6468 | const date = new Date(year, month, day);
|
6469 | const type = getDayType(date);
|
6470 | let config = {
|
6471 | date,
|
6472 | type,
|
6473 | text: day,
|
6474 | bottomInfo: getBottomInfo(type)
|
6475 | };
|
6476 | if (props2.formatter) {
|
6477 | config = props2.formatter(config);
|
6478 | }
|
6479 | days2.push(config);
|
6480 | }
|
6481 | return days2;
|
6482 | });
|
6483 | const disabledDays = computed(() => days.value.filter((day) => day.type === "disabled"));
|
6484 | const scrollToDate = (body, targetDate) => {
|
6485 | if (daysRef.value) {
|
6486 | const daysRect = useRect(daysRef.value);
|
6487 | const totalRows = placeholders.value.length;
|
6488 | const currentRow = Math.ceil((targetDate.getDate() + offset.value) / 7);
|
6489 | const rowOffset = (currentRow - 1) * daysRect.height / totalRows;
|
6490 | setScrollTop(body, daysRect.top + rowOffset + body.scrollTop - useRect(body).top);
|
6491 | }
|
6492 | };
|
6493 | const renderDay = (item, index) => createVNode(stdin_default$1i, {
|
6494 | "item": item,
|
6495 | "index": index,
|
6496 | "color": props2.color,
|
6497 | "offset": offset.value,
|
6498 | "rowHeight": rowHeight.value,
|
6499 | "onClick": (item2) => emit("click", item2),
|
6500 | "onClickDisabledDate": (item2) => emit("clickDisabledDate", item2)
|
6501 | }, pick(slots, ["top-info", "bottom-info"]));
|
6502 | const renderDays = () => createVNode("div", {
|
6503 | "ref": daysRef,
|
6504 | "role": "grid",
|
6505 | "class": bem$15("days")
|
6506 | }, [renderMark(), (shouldRender.value ? days : placeholders).value.map(renderDay)]);
|
6507 | useExpose({
|
6508 | getTitle,
|
6509 | getHeight: () => height.value,
|
6510 | setVisible,
|
6511 | scrollToDate,
|
6512 | disabledDays
|
6513 | });
|
6514 | return () => createVNode("div", {
|
6515 | "class": bem$15("month"),
|
6516 | "ref": monthRef
|
6517 | }, [renderTitle(), renderDays()]);
|
6518 | }
|
6519 | });
|
6520 | const [name$16] = createNamespace("calendar-header");
|
6521 | var stdin_default$1g = defineComponent({
|
6522 | name: name$16,
|
6523 | props: {
|
6524 | date: Date,
|
6525 | title: String,
|
6526 | subtitle: String,
|
6527 | showTitle: Boolean,
|
6528 | showSubtitle: Boolean,
|
6529 | firstDayOfWeek: Number
|
6530 | },
|
6531 | emits: ["clickSubtitle"],
|
6532 | setup(props2, {
|
6533 | slots,
|
6534 | emit
|
6535 | }) {
|
6536 | const renderTitle = () => {
|
6537 | if (props2.showTitle) {
|
6538 | const text = props2.title || t$g("title");
|
6539 | const title = slots.title ? slots.title() : text;
|
6540 | return createVNode("div", {
|
6541 | "class": bem$15("header-title")
|
6542 | }, [title]);
|
6543 | }
|
6544 | };
|
6545 | const onClickSubtitle = (event) => emit("clickSubtitle", event);
|
6546 | const renderSubtitle = () => {
|
6547 | if (props2.showSubtitle) {
|
6548 | const title = slots.subtitle ? slots.subtitle({
|
6549 | date: props2.date,
|
6550 | text: props2.subtitle
|
6551 | }) : props2.subtitle;
|
6552 | return createVNode("div", {
|
6553 | "class": bem$15("header-subtitle"),
|
6554 | "onClick": onClickSubtitle
|
6555 | }, [title]);
|
6556 | }
|
6557 | };
|
6558 | const renderWeekDays = () => {
|
6559 | const {
|
6560 | firstDayOfWeek
|
6561 | } = props2;
|
6562 | const weekdays = t$g("weekdays");
|
6563 | const renderWeekDays2 = [...weekdays.slice(firstDayOfWeek, 7), ...weekdays.slice(0, firstDayOfWeek)];
|
6564 | return createVNode("div", {
|
6565 | "class": bem$15("weekdays")
|
6566 | }, [renderWeekDays2.map((text) => createVNode("span", {
|
6567 | "class": bem$15("weekday")
|
6568 | }, [text]))]);
|
6569 | };
|
6570 | return () => createVNode("div", {
|
6571 | "class": bem$15("header")
|
6572 | }, [renderTitle(), renderSubtitle(), renderWeekDays()]);
|
6573 | }
|
6574 | });
|
6575 | const calendarProps = {
|
6576 | show: Boolean,
|
6577 | type: makeStringProp("single"),
|
6578 | title: String,
|
6579 | color: String,
|
6580 | round: truthProp,
|
6581 | readonly: Boolean,
|
6582 | poppable: truthProp,
|
6583 | maxRange: makeNumericProp(null),
|
6584 | position: makeStringProp("bottom"),
|
6585 | teleport: [String, Object],
|
6586 | showMark: truthProp,
|
6587 | showTitle: truthProp,
|
6588 | formatter: Function,
|
6589 | rowHeight: numericProp,
|
6590 | confirmText: String,
|
6591 | rangePrompt: String,
|
6592 | lazyRender: truthProp,
|
6593 | showConfirm: truthProp,
|
6594 | defaultDate: [Date, Array],
|
6595 | allowSameDay: Boolean,
|
6596 | showSubtitle: truthProp,
|
6597 | closeOnPopstate: truthProp,
|
6598 | showRangePrompt: truthProp,
|
6599 | confirmDisabledText: String,
|
6600 | closeOnClickOverlay: truthProp,
|
6601 | safeAreaInsetTop: Boolean,
|
6602 | safeAreaInsetBottom: truthProp,
|
6603 | minDate: {
|
6604 | type: Date,
|
6605 | validator: isDate,
|
6606 | default: getToday
|
6607 | },
|
6608 | maxDate: {
|
6609 | type: Date,
|
6610 | validator: isDate,
|
6611 | default: () => {
|
6612 | const now = getToday();
|
6613 | return new Date(now.getFullYear(), now.getMonth() + 6, now.getDate());
|
6614 | }
|
6615 | },
|
6616 | firstDayOfWeek: {
|
6617 | type: numericProp,
|
6618 | default: 0,
|
6619 | validator: (val) => val >= 0 && val <= 6
|
6620 | }
|
6621 | };
|
6622 | var stdin_default$1f = defineComponent({
|
6623 | name: name$19,
|
6624 | props: calendarProps,
|
6625 | emits: ["select", "confirm", "unselect", "monthShow", "overRange", "update:show", "clickSubtitle", "clickDisabledDate"],
|
6626 | setup(props2, {
|
6627 | emit,
|
6628 | slots
|
6629 | }) {
|
6630 | const limitDateRange = (date, minDate = props2.minDate, maxDate = props2.maxDate) => {
|
6631 | if (compareDay(date, minDate) === -1) {
|
6632 | return minDate;
|
6633 | }
|
6634 | if (compareDay(date, maxDate) === 1) {
|
6635 | return maxDate;
|
6636 | }
|
6637 | return date;
|
6638 | };
|
6639 | const getInitialDate = (defaultDate = props2.defaultDate) => {
|
6640 | const {
|
6641 | type,
|
6642 | minDate,
|
6643 | maxDate,
|
6644 | allowSameDay
|
6645 | } = props2;
|
6646 | if (defaultDate === null) {
|
6647 | return defaultDate;
|
6648 | }
|
6649 | const now = getToday();
|
6650 | if (type === "range") {
|
6651 | if (!Array.isArray(defaultDate)) {
|
6652 | defaultDate = [];
|
6653 | }
|
6654 | const start = limitDateRange(defaultDate[0] || now, minDate, allowSameDay ? maxDate : getPrevDay(maxDate));
|
6655 | const end = limitDateRange(defaultDate[1] || now, allowSameDay ? minDate : getNextDay(minDate));
|
6656 | return [start, end];
|
6657 | }
|
6658 | if (type === "multiple") {
|
6659 | if (Array.isArray(defaultDate)) {
|
6660 | return defaultDate.map((date) => limitDateRange(date));
|
6661 | }
|
6662 | return [limitDateRange(now)];
|
6663 | }
|
6664 | if (!defaultDate || Array.isArray(defaultDate)) {
|
6665 | defaultDate = now;
|
6666 | }
|
6667 | return limitDateRange(defaultDate);
|
6668 | };
|
6669 | let bodyHeight;
|
6670 | const bodyRef = ref();
|
6671 | const subtitle = ref({
|
6672 | textFn: () => "",
|
6673 | date: void 0
|
6674 | });
|
6675 | const currentDate = ref(getInitialDate());
|
6676 | const [monthRefs, setMonthRefs] = useRefs();
|
6677 | const dayOffset = computed(() => props2.firstDayOfWeek ? +props2.firstDayOfWeek % 7 : 0);
|
6678 | const months = computed(() => {
|
6679 | const months2 = [];
|
6680 | const cursor = new Date(props2.minDate);
|
6681 | cursor.setDate(1);
|
6682 | do {
|
6683 | months2.push(new Date(cursor));
|
6684 | cursor.setMonth(cursor.getMonth() + 1);
|
6685 | } while (compareMonth(cursor, props2.maxDate) !== 1);
|
6686 | return months2;
|
6687 | });
|
6688 | const buttonDisabled = computed(() => {
|
6689 | if (currentDate.value) {
|
6690 | if (props2.type === "range") {
|
6691 | return !currentDate.value[0] || !currentDate.value[1];
|
6692 | }
|
6693 | if (props2.type === "multiple") {
|
6694 | return !currentDate.value.length;
|
6695 | }
|
6696 | }
|
6697 | return !currentDate.value;
|
6698 | });
|
6699 | const getSelectedDate = () => currentDate.value;
|
6700 | const onScroll = () => {
|
6701 | const top = getScrollTop(bodyRef.value);
|
6702 | const bottom = top + bodyHeight;
|
6703 | const heights = months.value.map((item, index) => monthRefs.value[index].getHeight());
|
6704 | const heightSum = heights.reduce((a, b) => a + b, 0);
|
6705 | if (bottom > heightSum && top > 0) {
|
6706 | return;
|
6707 | }
|
6708 | let height = 0;
|
6709 | let currentMonth;
|
6710 | const visibleRange = [-1, -1];
|
6711 | for (let i = 0; i < months.value.length; i++) {
|
6712 | const month = monthRefs.value[i];
|
6713 | const visible = height <= bottom && height + heights[i] >= top;
|
6714 | if (visible) {
|
6715 | visibleRange[1] = i;
|
6716 | if (!currentMonth) {
|
6717 | currentMonth = month;
|
6718 | visibleRange[0] = i;
|
6719 | }
|
6720 | if (!monthRefs.value[i].showed) {
|
6721 | monthRefs.value[i].showed = true;
|
6722 | emit("monthShow", {
|
6723 | date: month.date,
|
6724 | title: month.getTitle()
|
6725 | });
|
6726 | }
|
6727 | }
|
6728 | height += heights[i];
|
6729 | }
|
6730 | months.value.forEach((month, index) => {
|
6731 | const visible = index >= visibleRange[0] - 1 && index <= visibleRange[1] + 1;
|
6732 | monthRefs.value[index].setVisible(visible);
|
6733 | });
|
6734 | if (currentMonth) {
|
6735 | subtitle.value = {
|
6736 | textFn: currentMonth.getTitle,
|
6737 | date: currentMonth.date
|
6738 | };
|
6739 | }
|
6740 | };
|
6741 | const scrollToDate = (targetDate) => {
|
6742 | raf(() => {
|
6743 | months.value.some((month, index) => {
|
6744 | if (compareMonth(month, targetDate) === 0) {
|
6745 | if (bodyRef.value) {
|
6746 | monthRefs.value[index].scrollToDate(bodyRef.value, targetDate);
|
6747 | }
|
6748 | return true;
|
6749 | }
|
6750 | return false;
|
6751 | });
|
6752 | onScroll();
|
6753 | });
|
6754 | };
|
6755 | const scrollToCurrentDate = () => {
|
6756 | if (props2.poppable && !props2.show) {
|
6757 | return;
|
6758 | }
|
6759 | if (currentDate.value) {
|
6760 | const targetDate = props2.type === "single" ? currentDate.value : currentDate.value[0];
|
6761 | if (isDate(targetDate)) {
|
6762 | scrollToDate(targetDate);
|
6763 | }
|
6764 | } else {
|
6765 | raf(onScroll);
|
6766 | }
|
6767 | };
|
6768 | const init = () => {
|
6769 | if (props2.poppable && !props2.show) {
|
6770 | return;
|
6771 | }
|
6772 | raf(() => {
|
6773 | bodyHeight = Math.floor(useRect(bodyRef).height);
|
6774 | });
|
6775 | scrollToCurrentDate();
|
6776 | };
|
6777 | const reset = (date = getInitialDate()) => {
|
6778 | currentDate.value = date;
|
6779 | scrollToCurrentDate();
|
6780 | };
|
6781 | const checkRange = (date) => {
|
6782 | const {
|
6783 | maxRange,
|
6784 | rangePrompt,
|
6785 | showRangePrompt
|
6786 | } = props2;
|
6787 | if (maxRange && calcDateNum(date) > +maxRange) {
|
6788 | if (showRangePrompt) {
|
6789 | showToast(rangePrompt || t$g("rangePrompt", maxRange));
|
6790 | }
|
6791 | emit("overRange");
|
6792 | return false;
|
6793 | }
|
6794 | return true;
|
6795 | };
|
6796 | const onConfirm = () => {
|
6797 | var _a;
|
6798 | return emit("confirm", (_a = currentDate.value) != null ? _a : cloneDates(currentDate.value));
|
6799 | };
|
6800 | const select = (date, complete) => {
|
6801 | const setCurrentDate = (date2) => {
|
6802 | currentDate.value = date2;
|
6803 | emit("select", cloneDates(date2));
|
6804 | };
|
6805 | if (complete && props2.type === "range") {
|
6806 | const valid = checkRange(date);
|
6807 | if (!valid) {
|
6808 | setCurrentDate([date[0], getDayByOffset(date[0], +props2.maxRange - 1)]);
|
6809 | return;
|
6810 | }
|
6811 | }
|
6812 | setCurrentDate(date);
|
6813 | if (complete && !props2.showConfirm) {
|
6814 | onConfirm();
|
6815 | }
|
6816 | };
|
6817 | const getDisabledDate = (disabledDays2, startDay, date) => {
|
6818 | var _a;
|
6819 | return (_a = disabledDays2.find((day) => compareDay(startDay, day.date) === -1 && compareDay(day.date, date) === -1)) == null ? void 0 : _a.date;
|
6820 | };
|
6821 | const disabledDays = computed(() => monthRefs.value.reduce((arr, ref2) => {
|
6822 | var _a, _b;
|
6823 | arr.push(...(_b = (_a = ref2.disabledDays) == null ? void 0 : _a.value) != null ? _b : []);
|
6824 | return arr;
|
6825 | }, []));
|
6826 | const onClickDay = (item) => {
|
6827 | if (props2.readonly || !item.date) {
|
6828 | return;
|
6829 | }
|
6830 | const {
|
6831 | date
|
6832 | } = item;
|
6833 | const {
|
6834 | type
|
6835 | } = props2;
|
6836 | if (type === "range") {
|
6837 | if (!currentDate.value) {
|
6838 | select([date]);
|
6839 | return;
|
6840 | }
|
6841 | const [startDay, endDay] = currentDate.value;
|
6842 | if (startDay && !endDay) {
|
6843 | const compareToStart = compareDay(date, startDay);
|
6844 | if (compareToStart === 1) {
|
6845 | const disabledDay = getDisabledDate(disabledDays.value, startDay, date);
|
6846 | if (disabledDay) {
|
6847 | const endDay2 = getPrevDay(disabledDay);
|
6848 | if (compareDay(startDay, endDay2) === -1) {
|
6849 | select([startDay, endDay2]);
|
6850 | } else {
|
6851 | select([date]);
|
6852 | }
|
6853 | } else {
|
6854 | select([startDay, date], true);
|
6855 | }
|
6856 | } else if (compareToStart === -1) {
|
6857 | select([date]);
|
6858 | } else if (props2.allowSameDay) {
|
6859 | select([date, date], true);
|
6860 | }
|
6861 | } else {
|
6862 | select([date]);
|
6863 | }
|
6864 | } else if (type === "multiple") {
|
6865 | if (!currentDate.value) {
|
6866 | select([date]);
|
6867 | return;
|
6868 | }
|
6869 | const dates = currentDate.value;
|
6870 | const selectedIndex = dates.findIndex((dateItem) => compareDay(dateItem, date) === 0);
|
6871 | if (selectedIndex !== -1) {
|
6872 | const [unselectedDate] = dates.splice(selectedIndex, 1);
|
6873 | emit("unselect", cloneDate(unselectedDate));
|
6874 | } else if (props2.maxRange && dates.length >= +props2.maxRange) {
|
6875 | showToast(props2.rangePrompt || t$g("rangePrompt", props2.maxRange));
|
6876 | } else {
|
6877 | select([...dates, date]);
|
6878 | }
|
6879 | } else {
|
6880 | select(date, true);
|
6881 | }
|
6882 | };
|
6883 | const updateShow = (value) => emit("update:show", value);
|
6884 | const renderMonth = (date, index) => {
|
6885 | const showMonthTitle = index !== 0 || !props2.showSubtitle;
|
6886 | return createVNode(stdin_default$1h, mergeProps({
|
6887 | "ref": setMonthRefs(index),
|
6888 | "date": date,
|
6889 | "currentDate": currentDate.value,
|
6890 | "showMonthTitle": showMonthTitle,
|
6891 | "firstDayOfWeek": dayOffset.value
|
6892 | }, pick(props2, ["type", "color", "minDate", "maxDate", "showMark", "formatter", "rowHeight", "lazyRender", "showSubtitle", "allowSameDay"]), {
|
6893 | "onClick": onClickDay,
|
6894 | "onClickDisabledDate": (item) => emit("clickDisabledDate", item)
|
6895 | }), pick(slots, ["top-info", "bottom-info", "month-title"]));
|
6896 | };
|
6897 | const renderFooterButton = () => {
|
6898 | if (slots.footer) {
|
6899 | return slots.footer();
|
6900 | }
|
6901 | if (props2.showConfirm) {
|
6902 | const slot = slots["confirm-text"];
|
6903 | const disabled = buttonDisabled.value;
|
6904 | const text = disabled ? props2.confirmDisabledText : props2.confirmText;
|
6905 | return createVNode(Button, {
|
6906 | "round": true,
|
6907 | "block": true,
|
6908 | "type": "primary",
|
6909 | "color": props2.color,
|
6910 | "class": bem$15("confirm"),
|
6911 | "disabled": disabled,
|
6912 | "nativeType": "button",
|
6913 | "onClick": onConfirm
|
6914 | }, {
|
6915 | default: () => [slot ? slot({
|
6916 | disabled
|
6917 | }) : text || t$g("confirm")]
|
6918 | });
|
6919 | }
|
6920 | };
|
6921 | const renderFooter = () => createVNode("div", {
|
6922 | "class": [bem$15("footer"), {
|
6923 | "van-safe-area-bottom": props2.safeAreaInsetBottom
|
6924 | }]
|
6925 | }, [renderFooterButton()]);
|
6926 | const renderCalendar = () => {
|
6927 | const subTitle = subtitle.value.textFn();
|
6928 | return createVNode("div", {
|
6929 | "class": bem$15()
|
6930 | }, [createVNode(stdin_default$1g, {
|
6931 | "date": subtitle.value.date,
|
6932 | "title": props2.title,
|
6933 | "subtitle": subTitle,
|
6934 | "showTitle": props2.showTitle,
|
6935 | "showSubtitle": props2.showSubtitle,
|
6936 | "firstDayOfWeek": dayOffset.value,
|
6937 | "onClickSubtitle": (event) => emit("clickSubtitle", event)
|
6938 | }, pick(slots, ["title", "subtitle"])), createVNode("div", {
|
6939 | "ref": bodyRef,
|
6940 | "class": bem$15("body"),
|
6941 | "onScroll": onScroll
|
6942 | }, [months.value.map(renderMonth)]), renderFooter()]);
|
6943 | };
|
6944 | watch(() => props2.show, init);
|
6945 | watch(() => [props2.type, props2.minDate, props2.maxDate], () => reset(getInitialDate(currentDate.value)));
|
6946 | watch(() => props2.defaultDate, (value = null) => {
|
6947 | currentDate.value = value;
|
6948 | scrollToCurrentDate();
|
6949 | });
|
6950 | useExpose({
|
6951 | reset,
|
6952 | scrollToDate,
|
6953 | getSelectedDate
|
6954 | });
|
6955 | onMountedOrActivated(init);
|
6956 | return () => {
|
6957 | if (props2.poppable) {
|
6958 | return createVNode(Popup, {
|
6959 | "show": props2.show,
|
6960 | "class": bem$15("popup"),
|
6961 | "round": props2.round,
|
6962 | "position": props2.position,
|
6963 | "closeable": props2.showTitle || props2.showSubtitle,
|
6964 | "teleport": props2.teleport,
|
6965 | "closeOnPopstate": props2.closeOnPopstate,
|
6966 | "safeAreaInsetTop": props2.safeAreaInsetTop,
|
6967 | "closeOnClickOverlay": props2.closeOnClickOverlay,
|
6968 | "onUpdate:show": updateShow
|
6969 | }, {
|
6970 | default: renderCalendar
|
6971 | });
|
6972 | }
|
6973 | return renderCalendar();
|
6974 | };
|
6975 | }
|
6976 | });
|
6977 | const Calendar = withInstall(stdin_default$1f);
|
6978 | const [name$15, bem$14] = createNamespace("image");
|
6979 | const imageProps = {
|
6980 | src: String,
|
6981 | alt: String,
|
6982 | fit: String,
|
6983 | position: String,
|
6984 | round: Boolean,
|
6985 | block: Boolean,
|
6986 | width: numericProp,
|
6987 | height: numericProp,
|
6988 | radius: numericProp,
|
6989 | lazyLoad: Boolean,
|
6990 | iconSize: numericProp,
|
6991 | showError: truthProp,
|
6992 | errorIcon: makeStringProp("photo-fail"),
|
6993 | iconPrefix: String,
|
6994 | showLoading: truthProp,
|
6995 | loadingIcon: makeStringProp("photo"),
|
6996 | crossorigin: String,
|
6997 | referrerpolicy: String
|
6998 | };
|
6999 | var stdin_default$1e = defineComponent({
|
7000 | name: name$15,
|
7001 | props: imageProps,
|
7002 | emits: ["load", "error"],
|
7003 | setup(props2, {
|
7004 | emit,
|
7005 | slots
|
7006 | }) {
|
7007 | const error = ref(false);
|
7008 | const loading = ref(true);
|
7009 | const imageRef = ref();
|
7010 | const {
|
7011 | $Lazyload
|
7012 | } = getCurrentInstance().proxy;
|
7013 | const style = computed(() => {
|
7014 | const style2 = {
|
7015 | width: addUnit(props2.width),
|
7016 | height: addUnit(props2.height)
|
7017 | };
|
7018 | if (isDef(props2.radius)) {
|
7019 | style2.overflow = "hidden";
|
7020 | style2.borderRadius = addUnit(props2.radius);
|
7021 | }
|
7022 | return style2;
|
7023 | });
|
7024 | watch(() => props2.src, () => {
|
7025 | error.value = false;
|
7026 | loading.value = true;
|
7027 | });
|
7028 | const onLoad = (event) => {
|
7029 | if (loading.value) {
|
7030 | loading.value = false;
|
7031 | emit("load", event);
|
7032 | }
|
7033 | };
|
7034 | const triggerLoad = () => {
|
7035 | const loadEvent = new Event("load");
|
7036 | Object.defineProperty(loadEvent, "target", {
|
7037 | value: imageRef.value,
|
7038 | enumerable: true
|
7039 | });
|
7040 | onLoad(loadEvent);
|
7041 | };
|
7042 | const onError = (event) => {
|
7043 | error.value = true;
|
7044 | loading.value = false;
|
7045 | emit("error", event);
|
7046 | };
|
7047 | const renderIcon = (name2, className, slot) => {
|
7048 | if (slot) {
|
7049 | return slot();
|
7050 | }
|
7051 | return createVNode(Icon, {
|
7052 | "name": name2,
|
7053 | "size": props2.iconSize,
|
7054 | "class": className,
|
7055 | "classPrefix": props2.iconPrefix
|
7056 | }, null);
|
7057 | };
|
7058 | const renderPlaceholder = () => {
|
7059 | if (loading.value && props2.showLoading) {
|
7060 | return createVNode("div", {
|
7061 | "class": bem$14("loading")
|
7062 | }, [renderIcon(props2.loadingIcon, bem$14("loading-icon"), slots.loading)]);
|
7063 | }
|
7064 | if (error.value && props2.showError) {
|
7065 | return createVNode("div", {
|
7066 | "class": bem$14("error")
|
7067 | }, [renderIcon(props2.errorIcon, bem$14("error-icon"), slots.error)]);
|
7068 | }
|
7069 | };
|
7070 | const renderImage = () => {
|
7071 | if (error.value || !props2.src) {
|
7072 | return;
|
7073 | }
|
7074 | const attrs = {
|
7075 | alt: props2.alt,
|
7076 | class: bem$14("img"),
|
7077 | style: {
|
7078 | objectFit: props2.fit,
|
7079 | objectPosition: props2.position
|
7080 | },
|
7081 | crossorigin: props2.crossorigin,
|
7082 | referrerpolicy: props2.referrerpolicy
|
7083 | };
|
7084 | if (props2.lazyLoad) {
|
7085 | return withDirectives(createVNode("img", mergeProps({
|
7086 | "ref": imageRef
|
7087 | }, attrs), null), [[resolveDirective("lazy"), props2.src]]);
|
7088 | }
|
7089 | return createVNode("img", mergeProps({
|
7090 | "ref": imageRef,
|
7091 | "src": props2.src,
|
7092 | "onLoad": onLoad,
|
7093 | "onError": onError
|
7094 | }, attrs), null);
|
7095 | };
|
7096 | const onLazyLoaded = ({
|
7097 | el
|
7098 | }) => {
|
7099 | const check = () => {
|
7100 | if (el === imageRef.value && loading.value) {
|
7101 | triggerLoad();
|
7102 | }
|
7103 | };
|
7104 | if (imageRef.value) {
|
7105 | check();
|
7106 | } else {
|
7107 | nextTick(check);
|
7108 | }
|
7109 | };
|
7110 | const onLazyLoadError = ({
|
7111 | el
|
7112 | }) => {
|
7113 | if (el === imageRef.value && !error.value) {
|
7114 | onError();
|
7115 | }
|
7116 | };
|
7117 | if ($Lazyload && inBrowser) {
|
7118 | $Lazyload.$on("loaded", onLazyLoaded);
|
7119 | $Lazyload.$on("error", onLazyLoadError);
|
7120 | onBeforeUnmount(() => {
|
7121 | $Lazyload.$off("loaded", onLazyLoaded);
|
7122 | $Lazyload.$off("error", onLazyLoadError);
|
7123 | });
|
7124 | }
|
7125 | onMounted(() => {
|
7126 | nextTick(() => {
|
7127 | var _a;
|
7128 | if (((_a = imageRef.value) == null ? void 0 : _a.complete) && !props2.lazyLoad) {
|
7129 | triggerLoad();
|
7130 | }
|
7131 | });
|
7132 | });
|
7133 | return () => {
|
7134 | var _a;
|
7135 | return createVNode("div", {
|
7136 | "class": bem$14({
|
7137 | round: props2.round,
|
7138 | block: props2.block
|
7139 | }),
|
7140 | "style": style.value
|
7141 | }, [renderImage(), renderPlaceholder(), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
7142 | };
|
7143 | }
|
7144 | });
|
7145 | const Image$1 = withInstall(stdin_default$1e);
|
7146 | const [name$14, bem$13] = createNamespace("card");
|
7147 | const cardProps = {
|
7148 | tag: String,
|
7149 | num: numericProp,
|
7150 | desc: String,
|
7151 | thumb: String,
|
7152 | title: String,
|
7153 | price: numericProp,
|
7154 | centered: Boolean,
|
7155 | lazyLoad: Boolean,
|
7156 | currency: makeStringProp("¥"),
|
7157 | thumbLink: String,
|
7158 | originPrice: numericProp
|
7159 | };
|
7160 | var stdin_default$1d = defineComponent({
|
7161 | name: name$14,
|
7162 | props: cardProps,
|
7163 | emits: ["clickThumb"],
|
7164 | setup(props2, {
|
7165 | slots,
|
7166 | emit
|
7167 | }) {
|
7168 | const renderTitle = () => {
|
7169 | if (slots.title) {
|
7170 | return slots.title();
|
7171 | }
|
7172 | if (props2.title) {
|
7173 | return createVNode("div", {
|
7174 | "class": [bem$13("title"), "van-multi-ellipsis--l2"]
|
7175 | }, [props2.title]);
|
7176 | }
|
7177 | };
|
7178 | const renderThumbTag = () => {
|
7179 | if (slots.tag || props2.tag) {
|
7180 | return createVNode("div", {
|
7181 | "class": bem$13("tag")
|
7182 | }, [slots.tag ? slots.tag() : createVNode(Tag, {
|
7183 | "mark": true,
|
7184 | "type": "primary"
|
7185 | }, {
|
7186 | default: () => [props2.tag]
|
7187 | })]);
|
7188 | }
|
7189 | };
|
7190 | const renderThumbImage = () => {
|
7191 | if (slots.thumb) {
|
7192 | return slots.thumb();
|
7193 | }
|
7194 | return createVNode(Image$1, {
|
7195 | "src": props2.thumb,
|
7196 | "fit": "cover",
|
7197 | "width": "100%",
|
7198 | "height": "100%",
|
7199 | "lazyLoad": props2.lazyLoad
|
7200 | }, null);
|
7201 | };
|
7202 | const renderThumb = () => {
|
7203 | if (slots.thumb || props2.thumb) {
|
7204 | return createVNode("a", {
|
7205 | "href": props2.thumbLink,
|
7206 | "class": bem$13("thumb"),
|
7207 | "onClick": (event) => emit("clickThumb", event)
|
7208 | }, [renderThumbImage(), renderThumbTag()]);
|
7209 | }
|
7210 | };
|
7211 | const renderDesc = () => {
|
7212 | if (slots.desc) {
|
7213 | return slots.desc();
|
7214 | }
|
7215 | if (props2.desc) {
|
7216 | return createVNode("div", {
|
7217 | "class": [bem$13("desc"), "van-ellipsis"]
|
7218 | }, [props2.desc]);
|
7219 | }
|
7220 | };
|
7221 | const renderPriceText = () => {
|
7222 | const priceArr = props2.price.toString().split(".");
|
7223 | return createVNode("div", null, [createVNode("span", {
|
7224 | "class": bem$13("price-currency")
|
7225 | }, [props2.currency]), createVNode("span", {
|
7226 | "class": bem$13("price-integer")
|
7227 | }, [priceArr[0]]), createTextVNode("."), createVNode("span", {
|
7228 | "class": bem$13("price-decimal")
|
7229 | }, [priceArr[1]])]);
|
7230 | };
|
7231 | return () => {
|
7232 | var _a, _b, _c;
|
7233 | const showNum = slots.num || isDef(props2.num);
|
7234 | const showPrice = slots.price || isDef(props2.price);
|
7235 | const showOriginPrice = slots["origin-price"] || isDef(props2.originPrice);
|
7236 | const showBottom = showNum || showPrice || showOriginPrice || slots.bottom;
|
7237 | const Price = showPrice && createVNode("div", {
|
7238 | "class": bem$13("price")
|
7239 | }, [slots.price ? slots.price() : renderPriceText()]);
|
7240 | const OriginPrice = showOriginPrice && createVNode("div", {
|
7241 | "class": bem$13("origin-price")
|
7242 | }, [slots["origin-price"] ? slots["origin-price"]() : `${props2.currency} ${props2.originPrice}`]);
|
7243 | const Num = showNum && createVNode("div", {
|
7244 | "class": bem$13("num")
|
7245 | }, [slots.num ? slots.num() : `x${props2.num}`]);
|
7246 | const Footer = slots.footer && createVNode("div", {
|
7247 | "class": bem$13("footer")
|
7248 | }, [slots.footer()]);
|
7249 | const Bottom = showBottom && createVNode("div", {
|
7250 | "class": bem$13("bottom")
|
7251 | }, [(_a = slots["price-top"]) == null ? void 0 : _a.call(slots), Price, OriginPrice, Num, (_b = slots.bottom) == null ? void 0 : _b.call(slots)]);
|
7252 | return createVNode("div", {
|
7253 | "class": bem$13()
|
7254 | }, [createVNode("div", {
|
7255 | "class": bem$13("header")
|
7256 | }, [renderThumb(), createVNode("div", {
|
7257 | "class": bem$13("content", {
|
7258 | centered: props2.centered
|
7259 | })
|
7260 | }, [createVNode("div", null, [renderTitle(), renderDesc(), (_c = slots.tags) == null ? void 0 : _c.call(slots)]), Bottom])]), Footer]);
|
7261 | };
|
7262 | }
|
7263 | });
|
7264 | const Card = withInstall(stdin_default$1d);
|
7265 | const [name$13, bem$12, t$f] = createNamespace("cascader");
|
7266 | const cascaderProps = {
|
7267 | title: String,
|
7268 | options: makeArrayProp(),
|
7269 | closeable: truthProp,
|
7270 | swipeable: truthProp,
|
7271 | closeIcon: makeStringProp("cross"),
|
7272 | showHeader: truthProp,
|
7273 | modelValue: numericProp,
|
7274 | fieldNames: Object,
|
7275 | placeholder: String,
|
7276 | activeColor: String
|
7277 | };
|
7278 | var stdin_default$1c = defineComponent({
|
7279 | name: name$13,
|
7280 | props: cascaderProps,
|
7281 | emits: ["close", "change", "finish", "clickTab", "update:modelValue"],
|
7282 | setup(props2, {
|
7283 | slots,
|
7284 | emit
|
7285 | }) {
|
7286 | const tabs = ref([]);
|
7287 | const activeTab = ref(0);
|
7288 | const [selectedElementRefs, setSelectedElementRefs] = useRefs();
|
7289 | const {
|
7290 | text: textKey,
|
7291 | value: valueKey,
|
7292 | children: childrenKey
|
7293 | } = extend({
|
7294 | text: "text",
|
7295 | value: "value",
|
7296 | children: "children"
|
7297 | }, props2.fieldNames);
|
7298 | const getSelectedOptionsByValue = (options, value) => {
|
7299 | for (const option of options) {
|
7300 | if (option[valueKey] === value) {
|
7301 | return [option];
|
7302 | }
|
7303 | if (option[childrenKey]) {
|
7304 | const selectedOptions = getSelectedOptionsByValue(option[childrenKey], value);
|
7305 | if (selectedOptions) {
|
7306 | return [option, ...selectedOptions];
|
7307 | }
|
7308 | }
|
7309 | }
|
7310 | };
|
7311 | const updateTabs = () => {
|
7312 | const {
|
7313 | options,
|
7314 | modelValue
|
7315 | } = props2;
|
7316 | if (modelValue !== void 0) {
|
7317 | const selectedOptions = getSelectedOptionsByValue(options, modelValue);
|
7318 | if (selectedOptions) {
|
7319 | let optionsCursor = options;
|
7320 | tabs.value = selectedOptions.map((option) => {
|
7321 | const tab = {
|
7322 | options: optionsCursor,
|
7323 | selected: option
|
7324 | };
|
7325 | const next = optionsCursor.find((item) => item[valueKey] === option[valueKey]);
|
7326 | if (next) {
|
7327 | optionsCursor = next[childrenKey];
|
7328 | }
|
7329 | return tab;
|
7330 | });
|
7331 | if (optionsCursor) {
|
7332 | tabs.value.push({
|
7333 | options: optionsCursor,
|
7334 | selected: null
|
7335 | });
|
7336 | }
|
7337 | nextTick(() => {
|
7338 | activeTab.value = tabs.value.length - 1;
|
7339 | });
|
7340 | return;
|
7341 | }
|
7342 | }
|
7343 | tabs.value = [{
|
7344 | options,
|
7345 | selected: null
|
7346 | }];
|
7347 | };
|
7348 | const onSelect = (option, tabIndex) => {
|
7349 | if (option.disabled) {
|
7350 | return;
|
7351 | }
|
7352 | tabs.value[tabIndex].selected = option;
|
7353 | if (tabs.value.length > tabIndex + 1) {
|
7354 | tabs.value = tabs.value.slice(0, tabIndex + 1);
|
7355 | }
|
7356 | if (option[childrenKey]) {
|
7357 | const nextTab = {
|
7358 | options: option[childrenKey],
|
7359 | selected: null
|
7360 | };
|
7361 | if (tabs.value[tabIndex + 1]) {
|
7362 | tabs.value[tabIndex + 1] = nextTab;
|
7363 | } else {
|
7364 | tabs.value.push(nextTab);
|
7365 | }
|
7366 | nextTick(() => {
|
7367 | activeTab.value++;
|
7368 | });
|
7369 | }
|
7370 | const selectedOptions = tabs.value.map((tab) => tab.selected).filter(Boolean);
|
7371 | emit("update:modelValue", option[valueKey]);
|
7372 | const params = {
|
7373 | value: option[valueKey],
|
7374 | tabIndex,
|
7375 | selectedOptions
|
7376 | };
|
7377 | emit("change", params);
|
7378 | if (!option[childrenKey]) {
|
7379 | emit("finish", params);
|
7380 | }
|
7381 | };
|
7382 | const onClose = () => emit("close");
|
7383 | const onClickTab = ({
|
7384 | name: name2,
|
7385 | title
|
7386 | }) => emit("clickTab", name2, title);
|
7387 | const renderHeader = () => props2.showHeader ? createVNode("div", {
|
7388 | "class": bem$12("header")
|
7389 | }, [createVNode("h2", {
|
7390 | "class": bem$12("title")
|
7391 | }, [slots.title ? slots.title() : props2.title]), props2.closeable ? createVNode(Icon, {
|
7392 | "name": props2.closeIcon,
|
7393 | "class": [bem$12("close-icon"), HAPTICS_FEEDBACK],
|
7394 | "onClick": onClose
|
7395 | }, null) : null]) : null;
|
7396 | const renderOption = (option, selectedOption, tabIndex) => {
|
7397 | const {
|
7398 | disabled
|
7399 | } = option;
|
7400 | const selected = !!(selectedOption && option[valueKey] === selectedOption[valueKey]);
|
7401 | const color = option.color || (selected ? props2.activeColor : void 0);
|
7402 | const Text2 = slots.option ? slots.option({
|
7403 | option,
|
7404 | selected
|
7405 | }) : createVNode("span", null, [option[textKey]]);
|
7406 | return createVNode("li", {
|
7407 | "ref": selected ? setSelectedElementRefs(tabIndex) : void 0,
|
7408 | "role": "menuitemradio",
|
7409 | "class": [bem$12("option", {
|
7410 | selected,
|
7411 | disabled
|
7412 | }), option.className],
|
7413 | "style": {
|
7414 | color
|
7415 | },
|
7416 | "tabindex": disabled ? void 0 : selected ? 0 : -1,
|
7417 | "aria-checked": selected,
|
7418 | "aria-disabled": disabled || void 0,
|
7419 | "onClick": () => onSelect(option, tabIndex)
|
7420 | }, [Text2, selected ? createVNode(Icon, {
|
7421 | "name": "success",
|
7422 | "class": bem$12("selected-icon")
|
7423 | }, null) : null]);
|
7424 | };
|
7425 | const renderOptions = (options, selectedOption, tabIndex) => createVNode("ul", {
|
7426 | "role": "menu",
|
7427 | "class": bem$12("options")
|
7428 | }, [options.map((option) => renderOption(option, selectedOption, tabIndex))]);
|
7429 | const renderTab = (tab, tabIndex) => {
|
7430 | const {
|
7431 | options,
|
7432 | selected
|
7433 | } = tab;
|
7434 | const placeholder = props2.placeholder || t$f("select");
|
7435 | const title = selected ? selected[textKey] : placeholder;
|
7436 | return createVNode(Tab, {
|
7437 | "title": title,
|
7438 | "titleClass": bem$12("tab", {
|
7439 | unselected: !selected
|
7440 | })
|
7441 | }, {
|
7442 | default: () => {
|
7443 | var _a, _b;
|
7444 | return [(_a = slots["options-top"]) == null ? void 0 : _a.call(slots, {
|
7445 | tabIndex
|
7446 | }), renderOptions(options, selected, tabIndex), (_b = slots["options-bottom"]) == null ? void 0 : _b.call(slots, {
|
7447 | tabIndex
|
7448 | })];
|
7449 | }
|
7450 | });
|
7451 | };
|
7452 | const renderTabs = () => createVNode(Tabs, {
|
7453 | "active": activeTab.value,
|
7454 | "onUpdate:active": ($event) => activeTab.value = $event,
|
7455 | "shrink": true,
|
7456 | "animated": true,
|
7457 | "class": bem$12("tabs"),
|
7458 | "color": props2.activeColor,
|
7459 | "swipeable": props2.swipeable,
|
7460 | "onClickTab": onClickTab
|
7461 | }, {
|
7462 | default: () => [tabs.value.map(renderTab)]
|
7463 | });
|
7464 | const scrollIntoView = (el) => {
|
7465 | const scrollParent = el.parentElement;
|
7466 | if (scrollParent) {
|
7467 | scrollParent.scrollTop = el.offsetTop - (scrollParent.offsetHeight - el.offsetHeight) / 2;
|
7468 | }
|
7469 | };
|
7470 | updateTabs();
|
7471 | watch(activeTab, (value) => {
|
7472 | const el = selectedElementRefs.value[value];
|
7473 | if (el)
|
7474 | scrollIntoView(el);
|
7475 | });
|
7476 | watch(() => props2.options, updateTabs, {
|
7477 | deep: true
|
7478 | });
|
7479 | watch(() => props2.modelValue, (value) => {
|
7480 | if (value !== void 0) {
|
7481 | const values = tabs.value.map((tab) => {
|
7482 | var _a;
|
7483 | return (_a = tab.selected) == null ? void 0 : _a[valueKey];
|
7484 | });
|
7485 | if (values.includes(value)) {
|
7486 | return;
|
7487 | }
|
7488 | }
|
7489 | updateTabs();
|
7490 | });
|
7491 | return () => createVNode("div", {
|
7492 | "class": bem$12()
|
7493 | }, [renderHeader(), renderTabs()]);
|
7494 | }
|
7495 | });
|
7496 | const Cascader = withInstall(stdin_default$1c);
|
7497 | const [name$12, bem$11] = createNamespace("cell-group");
|
7498 | const cellGroupProps = {
|
7499 | title: String,
|
7500 | inset: Boolean,
|
7501 | border: truthProp
|
7502 | };
|
7503 | var stdin_default$1b = defineComponent({
|
7504 | name: name$12,
|
7505 | inheritAttrs: false,
|
7506 | props: cellGroupProps,
|
7507 | setup(props2, {
|
7508 | slots,
|
7509 | attrs
|
7510 | }) {
|
7511 | const renderGroup = () => {
|
7512 | var _a;
|
7513 | return createVNode("div", mergeProps({
|
7514 | "class": [bem$11({
|
7515 | inset: props2.inset
|
7516 | }), {
|
7517 | [BORDER_TOP_BOTTOM]: props2.border && !props2.inset
|
7518 | }]
|
7519 | }, attrs, useScopeId()), [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
7520 | };
|
7521 | const renderTitle = () => createVNode("div", {
|
7522 | "class": bem$11("title", {
|
7523 | inset: props2.inset
|
7524 | })
|
7525 | }, [slots.title ? slots.title() : props2.title]);
|
7526 | return () => {
|
7527 | if (props2.title || slots.title) {
|
7528 | return createVNode(Fragment, null, [renderTitle(), renderGroup()]);
|
7529 | }
|
7530 | return renderGroup();
|
7531 | };
|
7532 | }
|
7533 | });
|
7534 | const CellGroup = withInstall(stdin_default$1b);
|
7535 | const [name$11, bem$10] = createNamespace("checkbox-group");
|
7536 | const checkboxGroupProps = {
|
7537 | max: numericProp,
|
7538 | shape: makeStringProp("round"),
|
7539 | disabled: Boolean,
|
7540 | iconSize: numericProp,
|
7541 | direction: String,
|
7542 | modelValue: makeArrayProp(),
|
7543 | checkedColor: String
|
7544 | };
|
7545 | const CHECKBOX_GROUP_KEY = Symbol(name$11);
|
7546 | var stdin_default$1a = defineComponent({
|
7547 | name: name$11,
|
7548 | props: checkboxGroupProps,
|
7549 | emits: ["change", "update:modelValue"],
|
7550 | setup(props2, {
|
7551 | emit,
|
7552 | slots
|
7553 | }) {
|
7554 | const {
|
7555 | children,
|
7556 | linkChildren
|
7557 | } = useChildren(CHECKBOX_GROUP_KEY);
|
7558 | const updateValue = (value) => emit("update:modelValue", value);
|
7559 | const toggleAll = (options = {}) => {
|
7560 | if (typeof options === "boolean") {
|
7561 | options = {
|
7562 | checked: options
|
7563 | };
|
7564 | }
|
7565 | const {
|
7566 | checked,
|
7567 | skipDisabled
|
7568 | } = options;
|
7569 | const checkedChildren = children.filter((item) => {
|
7570 | if (!item.props.bindGroup) {
|
7571 | return false;
|
7572 | }
|
7573 | if (item.props.disabled && skipDisabled) {
|
7574 | return item.checked.value;
|
7575 | }
|
7576 | return checked != null ? checked : !item.checked.value;
|
7577 | });
|
7578 | const names = checkedChildren.map((item) => item.name);
|
7579 | updateValue(names);
|
7580 | };
|
7581 | watch(() => props2.modelValue, (value) => emit("change", value));
|
7582 | useExpose({
|
7583 | toggleAll
|
7584 | });
|
7585 | useCustomFieldValue(() => props2.modelValue);
|
7586 | linkChildren({
|
7587 | props: props2,
|
7588 | updateValue
|
7589 | });
|
7590 | return () => {
|
7591 | var _a;
|
7592 | return createVNode("div", {
|
7593 | "class": bem$10([props2.direction])
|
7594 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
7595 | };
|
7596 | }
|
7597 | });
|
7598 | const [name$10, bem$$] = createNamespace("checkbox");
|
7599 | const checkboxProps = extend({}, checkerProps, {
|
7600 | shape: String,
|
7601 | bindGroup: truthProp,
|
7602 | indeterminate: {
|
7603 | type: Boolean,
|
7604 | default: null
|
7605 | }
|
7606 | });
|
7607 | var stdin_default$19 = defineComponent({
|
7608 | name: name$10,
|
7609 | props: checkboxProps,
|
7610 | emits: ["change", "update:modelValue"],
|
7611 | setup(props2, {
|
7612 | emit,
|
7613 | slots
|
7614 | }) {
|
7615 | const {
|
7616 | parent
|
7617 | } = useParent(CHECKBOX_GROUP_KEY);
|
7618 | const setParentValue = (checked2) => {
|
7619 | const {
|
7620 | name: name2
|
7621 | } = props2;
|
7622 | const {
|
7623 | max,
|
7624 | modelValue
|
7625 | } = parent.props;
|
7626 | const value = modelValue.slice();
|
7627 | if (checked2) {
|
7628 | const overlimit = max && value.length >= +max;
|
7629 | if (!overlimit && !value.includes(name2)) {
|
7630 | value.push(name2);
|
7631 | if (props2.bindGroup) {
|
7632 | parent.updateValue(value);
|
7633 | }
|
7634 | }
|
7635 | } else {
|
7636 | const index = value.indexOf(name2);
|
7637 | if (index !== -1) {
|
7638 | value.splice(index, 1);
|
7639 | if (props2.bindGroup) {
|
7640 | parent.updateValue(value);
|
7641 | }
|
7642 | }
|
7643 | }
|
7644 | };
|
7645 | const checked = computed(() => {
|
7646 | if (parent && props2.bindGroup) {
|
7647 | return parent.props.modelValue.indexOf(props2.name) !== -1;
|
7648 | }
|
7649 | return !!props2.modelValue;
|
7650 | });
|
7651 | const toggle = (newValue = !checked.value) => {
|
7652 | if (parent && props2.bindGroup) {
|
7653 | setParentValue(newValue);
|
7654 | } else {
|
7655 | emit("update:modelValue", newValue);
|
7656 | }
|
7657 | if (props2.indeterminate !== null)
|
7658 | emit("change", newValue);
|
7659 | };
|
7660 | watch(() => props2.modelValue, (value) => {
|
7661 | if (props2.indeterminate === null)
|
7662 | emit("change", value);
|
7663 | });
|
7664 | useExpose({
|
7665 | toggle,
|
7666 | props: props2,
|
7667 | checked
|
7668 | });
|
7669 | useCustomFieldValue(() => props2.modelValue);
|
7670 | return () => createVNode(stdin_default$1o, mergeProps({
|
7671 | "bem": bem$$,
|
7672 | "role": "checkbox",
|
7673 | "parent": parent,
|
7674 | "checked": checked.value,
|
7675 | "onToggle": toggle
|
7676 | }, props2), pick(slots, ["default", "icon"]));
|
7677 | }
|
7678 | });
|
7679 | const Checkbox = withInstall(stdin_default$19);
|
7680 | const CheckboxGroup = withInstall(stdin_default$1a);
|
7681 | const [name$$, bem$_] = createNamespace("circle");
|
7682 | let uid = 0;
|
7683 | const format = (rate) => Math.min(Math.max(+rate, 0), 100);
|
7684 | function getPath(clockwise, viewBoxSize) {
|
7685 | const sweepFlag = clockwise ? 1 : 0;
|
7686 | 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`;
|
7687 | }
|
7688 | const circleProps = {
|
7689 | text: String,
|
7690 | size: numericProp,
|
7691 | fill: makeStringProp("none"),
|
7692 | rate: makeNumericProp(100),
|
7693 | speed: makeNumericProp(0),
|
7694 | color: [String, Object],
|
7695 | clockwise: truthProp,
|
7696 | layerColor: String,
|
7697 | currentRate: makeNumberProp(0),
|
7698 | strokeWidth: makeNumericProp(40),
|
7699 | strokeLinecap: String,
|
7700 | startPosition: makeStringProp("top")
|
7701 | };
|
7702 | var stdin_default$18 = defineComponent({
|
7703 | name: name$$,
|
7704 | props: circleProps,
|
7705 | emits: ["update:currentRate"],
|
7706 | setup(props2, {
|
7707 | emit,
|
7708 | slots
|
7709 | }) {
|
7710 | const id = `van-circle-${uid++}`;
|
7711 | const viewBoxSize = computed(() => +props2.strokeWidth + 1e3);
|
7712 | const path = computed(() => getPath(props2.clockwise, viewBoxSize.value));
|
7713 | const svgStyle = computed(() => {
|
7714 | const ROTATE_ANGLE_MAP = {
|
7715 | top: 0,
|
7716 | right: 90,
|
7717 | bottom: 180,
|
7718 | left: 270
|
7719 | };
|
7720 | const angleValue = ROTATE_ANGLE_MAP[props2.startPosition];
|
7721 | if (angleValue) {
|
7722 | return {
|
7723 | transform: `rotate(${angleValue}deg)`
|
7724 | };
|
7725 | }
|
7726 | });
|
7727 | watch(() => props2.rate, (rate) => {
|
7728 | let rafId;
|
7729 | const startTime = Date.now();
|
7730 | const startRate = props2.currentRate;
|
7731 | const endRate = format(rate);
|
7732 | const duration = Math.abs((startRate - endRate) * 1e3 / +props2.speed);
|
7733 | const animate = () => {
|
7734 | const now = Date.now();
|
7735 | const progress = Math.min((now - startTime) / duration, 1);
|
7736 | const rate2 = progress * (endRate - startRate) + startRate;
|
7737 | emit("update:currentRate", format(parseFloat(rate2.toFixed(1))));
|
7738 | if (endRate > startRate ? rate2 < endRate : rate2 > endRate) {
|
7739 | rafId = raf(animate);
|
7740 | }
|
7741 | };
|
7742 | if (props2.speed) {
|
7743 | if (rafId) {
|
7744 | cancelRaf(rafId);
|
7745 | }
|
7746 | rafId = raf(animate);
|
7747 | } else {
|
7748 | emit("update:currentRate", endRate);
|
7749 | }
|
7750 | }, {
|
7751 | immediate: true
|
7752 | });
|
7753 | const renderHover = () => {
|
7754 | const PERIMETER = 3140;
|
7755 | const {
|
7756 | strokeWidth,
|
7757 | currentRate,
|
7758 | strokeLinecap
|
7759 | } = props2;
|
7760 | const offset = PERIMETER * currentRate / 100;
|
7761 | const color = isObject(props2.color) ? `url(#${id})` : props2.color;
|
7762 | const style = {
|
7763 | stroke: color,
|
7764 | strokeWidth: `${+strokeWidth + 1}px`,
|
7765 | strokeLinecap,
|
7766 | strokeDasharray: `${offset}px ${PERIMETER}px`
|
7767 | };
|
7768 | return createVNode("path", {
|
7769 | "d": path.value,
|
7770 | "style": style,
|
7771 | "class": bem$_("hover"),
|
7772 | "stroke": color
|
7773 | }, null);
|
7774 | };
|
7775 | const renderLayer = () => {
|
7776 | const style = {
|
7777 | fill: props2.fill,
|
7778 | stroke: props2.layerColor,
|
7779 | strokeWidth: `${props2.strokeWidth}px`
|
7780 | };
|
7781 | return createVNode("path", {
|
7782 | "class": bem$_("layer"),
|
7783 | "style": style,
|
7784 | "d": path.value
|
7785 | }, null);
|
7786 | };
|
7787 | const renderGradient = () => {
|
7788 | const {
|
7789 | color
|
7790 | } = props2;
|
7791 | if (!isObject(color)) {
|
7792 | return;
|
7793 | }
|
7794 | const Stops = Object.keys(color).sort((a, b) => parseFloat(a) - parseFloat(b)).map((key, index) => createVNode("stop", {
|
7795 | "key": index,
|
7796 | "offset": key,
|
7797 | "stop-color": color[key]
|
7798 | }, null));
|
7799 | return createVNode("defs", null, [createVNode("linearGradient", {
|
7800 | "id": id,
|
7801 | "x1": "100%",
|
7802 | "y1": "0%",
|
7803 | "x2": "0%",
|
7804 | "y2": "0%"
|
7805 | }, [Stops])]);
|
7806 | };
|
7807 | const renderText = () => {
|
7808 | if (slots.default) {
|
7809 | return slots.default();
|
7810 | }
|
7811 | if (props2.text) {
|
7812 | return createVNode("div", {
|
7813 | "class": bem$_("text")
|
7814 | }, [props2.text]);
|
7815 | }
|
7816 | };
|
7817 | return () => createVNode("div", {
|
7818 | "class": bem$_(),
|
7819 | "style": getSizeStyle(props2.size)
|
7820 | }, [createVNode("svg", {
|
7821 | "viewBox": `0 0 ${viewBoxSize.value} ${viewBoxSize.value}`,
|
7822 | "style": svgStyle.value
|
7823 | }, [renderGradient(), renderLayer(), renderHover()]), renderText()]);
|
7824 | }
|
7825 | });
|
7826 | const Circle = withInstall(stdin_default$18);
|
7827 | const [name$_, bem$Z] = createNamespace("row");
|
7828 | const ROW_KEY = Symbol(name$_);
|
7829 | const rowProps = {
|
7830 | tag: makeStringProp("div"),
|
7831 | wrap: truthProp,
|
7832 | align: String,
|
7833 | gutter: {
|
7834 | type: [String, Number, Array],
|
7835 | default: 0
|
7836 | },
|
7837 | justify: String
|
7838 | };
|
7839 | var stdin_default$17 = defineComponent({
|
7840 | name: name$_,
|
7841 | props: rowProps,
|
7842 | setup(props2, {
|
7843 | slots
|
7844 | }) {
|
7845 | const {
|
7846 | children,
|
7847 | linkChildren
|
7848 | } = useChildren(ROW_KEY);
|
7849 | const groups = computed(() => {
|
7850 | const groups2 = [[]];
|
7851 | let totalSpan = 0;
|
7852 | children.forEach((child, index) => {
|
7853 | totalSpan += Number(child.span);
|
7854 | if (totalSpan > 24) {
|
7855 | groups2.push([index]);
|
7856 | totalSpan -= 24;
|
7857 | } else {
|
7858 | groups2[groups2.length - 1].push(index);
|
7859 | }
|
7860 | });
|
7861 | return groups2;
|
7862 | });
|
7863 | const spaces = computed(() => {
|
7864 | let gutter = 0;
|
7865 | if (Array.isArray(props2.gutter)) {
|
7866 | gutter = Number(props2.gutter[0]) || 0;
|
7867 | } else {
|
7868 | gutter = Number(props2.gutter);
|
7869 | }
|
7870 | const spaces2 = [];
|
7871 | if (!gutter) {
|
7872 | return spaces2;
|
7873 | }
|
7874 | groups.value.forEach((group) => {
|
7875 | const averagePadding = gutter * (group.length - 1) / group.length;
|
7876 | group.forEach((item, index) => {
|
7877 | if (index === 0) {
|
7878 | spaces2.push({
|
7879 | right: averagePadding
|
7880 | });
|
7881 | } else {
|
7882 | const left = gutter - spaces2[item - 1].right;
|
7883 | const right = averagePadding - left;
|
7884 | spaces2.push({
|
7885 | left,
|
7886 | right
|
7887 | });
|
7888 | }
|
7889 | });
|
7890 | });
|
7891 | return spaces2;
|
7892 | });
|
7893 | const verticalSpaces = computed(() => {
|
7894 | const {
|
7895 | gutter
|
7896 | } = props2;
|
7897 | const spaces2 = [];
|
7898 | if (Array.isArray(gutter) && gutter.length > 1) {
|
7899 | const bottom = Number(gutter[1]) || 0;
|
7900 | if (bottom <= 0) {
|
7901 | return spaces2;
|
7902 | }
|
7903 | groups.value.forEach((group, index) => {
|
7904 | if (index === groups.value.length - 1)
|
7905 | return;
|
7906 | group.forEach(() => {
|
7907 | spaces2.push({
|
7908 | bottom
|
7909 | });
|
7910 | });
|
7911 | });
|
7912 | }
|
7913 | return spaces2;
|
7914 | });
|
7915 | linkChildren({
|
7916 | spaces,
|
7917 | verticalSpaces
|
7918 | });
|
7919 | return () => {
|
7920 | const {
|
7921 | tag,
|
7922 | wrap,
|
7923 | align,
|
7924 | justify
|
7925 | } = props2;
|
7926 | return createVNode(tag, {
|
7927 | "class": bem$Z({
|
7928 | [`align-${align}`]: align,
|
7929 | [`justify-${justify}`]: justify,
|
7930 | nowrap: !wrap
|
7931 | })
|
7932 | }, {
|
7933 | default: () => {
|
7934 | var _a;
|
7935 | return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
|
7936 | }
|
7937 | });
|
7938 | };
|
7939 | }
|
7940 | });
|
7941 | const [name$Z, bem$Y] = createNamespace("col");
|
7942 | const colProps = {
|
7943 | tag: makeStringProp("div"),
|
7944 | span: makeNumericProp(0),
|
7945 | offset: numericProp
|
7946 | };
|
7947 | var stdin_default$16 = defineComponent({
|
7948 | name: name$Z,
|
7949 | props: colProps,
|
7950 | setup(props2, {
|
7951 | slots
|
7952 | }) {
|
7953 | const {
|
7954 | parent,
|
7955 | index
|
7956 | } = useParent(ROW_KEY);
|
7957 | const style = computed(() => {
|
7958 | if (!parent) {
|
7959 | return;
|
7960 | }
|
7961 | const {
|
7962 | spaces,
|
7963 | verticalSpaces
|
7964 | } = parent;
|
7965 | let styles = {};
|
7966 | if (spaces && spaces.value && spaces.value[index.value]) {
|
7967 | const {
|
7968 | left,
|
7969 | right
|
7970 | } = spaces.value[index.value];
|
7971 | styles = {
|
7972 | paddingLeft: left ? `${left}px` : null,
|
7973 | paddingRight: right ? `${right}px` : null
|
7974 | };
|
7975 | }
|
7976 | const {
|
7977 | bottom
|
7978 | } = verticalSpaces.value[index.value] || {};
|
7979 | return extend(styles, {
|
7980 | marginBottom: bottom ? `${bottom}px` : null
|
7981 | });
|
7982 | });
|
7983 | return () => {
|
7984 | const {
|
7985 | tag,
|
7986 | span,
|
7987 | offset
|
7988 | } = props2;
|
7989 | return createVNode(tag, {
|
7990 | "style": style.value,
|
7991 | "class": bem$Y({
|
7992 | [span]: span,
|
7993 | [`offset-${offset}`]: offset
|
7994 | })
|
7995 | }, {
|
7996 | default: () => {
|
7997 | var _a;
|
7998 | return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
|
7999 | }
|
8000 | });
|
8001 | };
|
8002 | }
|
8003 | });
|
8004 | const Col = withInstall(stdin_default$16);
|
8005 | const [name$Y, bem$X] = createNamespace("collapse");
|
8006 | const COLLAPSE_KEY = Symbol(name$Y);
|
8007 | const collapseProps = {
|
8008 | border: truthProp,
|
8009 | accordion: Boolean,
|
8010 | modelValue: {
|
8011 | type: [String, Number, Array],
|
8012 | default: ""
|
8013 | }
|
8014 | };
|
8015 | function validateModelValue(modelValue, accordion) {
|
8016 | if (accordion && Array.isArray(modelValue)) {
|
8017 | console.error('[Vant] Collapse: "v-model" should not be Array in accordion mode');
|
8018 | return false;
|
8019 | }
|
8020 | if (!accordion && !Array.isArray(modelValue)) {
|
8021 | console.error('[Vant] Collapse: "v-model" should be Array in non-accordion mode');
|
8022 | return false;
|
8023 | }
|
8024 | return true;
|
8025 | }
|
8026 | var stdin_default$15 = defineComponent({
|
8027 | name: name$Y,
|
8028 | props: collapseProps,
|
8029 | emits: ["change", "update:modelValue"],
|
8030 | setup(props2, {
|
8031 | emit,
|
8032 | slots
|
8033 | }) {
|
8034 | const {
|
8035 | linkChildren,
|
8036 | children
|
8037 | } = useChildren(COLLAPSE_KEY);
|
8038 | const updateName = (name2) => {
|
8039 | emit("change", name2);
|
8040 | emit("update:modelValue", name2);
|
8041 | };
|
8042 | const toggle = (name2, expanded) => {
|
8043 | const {
|
8044 | accordion,
|
8045 | modelValue
|
8046 | } = props2;
|
8047 | if (accordion) {
|
8048 | updateName(name2 === modelValue ? "" : name2);
|
8049 | } else if (expanded) {
|
8050 | updateName(modelValue.concat(name2));
|
8051 | } else {
|
8052 | updateName(modelValue.filter((activeName) => activeName !== name2));
|
8053 | }
|
8054 | };
|
8055 | const toggleAll = (options = {}) => {
|
8056 | if (props2.accordion) {
|
8057 | return;
|
8058 | }
|
8059 | if (typeof options === "boolean") {
|
8060 | options = {
|
8061 | expanded: options
|
8062 | };
|
8063 | }
|
8064 | const {
|
8065 | expanded,
|
8066 | skipDisabled
|
8067 | } = options;
|
8068 | const expandedChildren = children.filter((item) => {
|
8069 | if (item.disabled && skipDisabled) {
|
8070 | return item.expanded.value;
|
8071 | }
|
8072 | return expanded != null ? expanded : !item.expanded.value;
|
8073 | });
|
8074 | const names = expandedChildren.map((item) => item.itemName.value);
|
8075 | updateName(names);
|
8076 | };
|
8077 | const isExpanded = (name2) => {
|
8078 | const {
|
8079 | accordion,
|
8080 | modelValue
|
8081 | } = props2;
|
8082 | if (process.env.NODE_ENV !== "production" && !validateModelValue(modelValue, accordion)) {
|
8083 | return false;
|
8084 | }
|
8085 | return accordion ? modelValue === name2 : modelValue.includes(name2);
|
8086 | };
|
8087 | useExpose({
|
8088 | toggleAll
|
8089 | });
|
8090 | linkChildren({
|
8091 | toggle,
|
8092 | isExpanded
|
8093 | });
|
8094 | return () => {
|
8095 | var _a;
|
8096 | return createVNode("div", {
|
8097 | "class": [bem$X(), {
|
8098 | [BORDER_TOP_BOTTOM]: props2.border
|
8099 | }]
|
8100 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
8101 | };
|
8102 | }
|
8103 | });
|
8104 | const Collapse = withInstall(stdin_default$15);
|
8105 | const [name$X, bem$W] = createNamespace("collapse-item");
|
8106 | const CELL_SLOTS = ["icon", "title", "value", "label", "right-icon"];
|
8107 | const collapseItemProps = extend({}, cellSharedProps, {
|
8108 | name: numericProp,
|
8109 | isLink: truthProp,
|
8110 | disabled: Boolean,
|
8111 | readonly: Boolean,
|
8112 | lazyRender: truthProp
|
8113 | });
|
8114 | var stdin_default$14 = defineComponent({
|
8115 | name: name$X,
|
8116 | props: collapseItemProps,
|
8117 | setup(props2, {
|
8118 | slots
|
8119 | }) {
|
8120 | const wrapperRef = ref();
|
8121 | const contentRef = ref();
|
8122 | const {
|
8123 | parent,
|
8124 | index
|
8125 | } = useParent(COLLAPSE_KEY);
|
8126 | if (!parent) {
|
8127 | if (process.env.NODE_ENV !== "production") {
|
8128 | console.error("[Vant] <CollapseItem> must be a child component of <Collapse>.");
|
8129 | }
|
8130 | return;
|
8131 | }
|
8132 | const name2 = computed(() => {
|
8133 | var _a;
|
8134 | return (_a = props2.name) != null ? _a : index.value;
|
8135 | });
|
8136 | const expanded = computed(() => parent.isExpanded(name2.value));
|
8137 | const show = ref(expanded.value);
|
8138 | const lazyRender = useLazyRender(() => show.value || !props2.lazyRender);
|
8139 | const onTransitionEnd = () => {
|
8140 | if (!expanded.value) {
|
8141 | show.value = false;
|
8142 | } else if (wrapperRef.value) {
|
8143 | wrapperRef.value.style.height = "";
|
8144 | }
|
8145 | };
|
8146 | watch(expanded, (value, oldValue) => {
|
8147 | if (oldValue === null) {
|
8148 | return;
|
8149 | }
|
8150 | if (value) {
|
8151 | show.value = true;
|
8152 | }
|
8153 | const tick = value ? nextTick : raf;
|
8154 | tick(() => {
|
8155 | if (!contentRef.value || !wrapperRef.value) {
|
8156 | return;
|
8157 | }
|
8158 | const {
|
8159 | offsetHeight
|
8160 | } = contentRef.value;
|
8161 | if (offsetHeight) {
|
8162 | const contentHeight = `${offsetHeight}px`;
|
8163 | wrapperRef.value.style.height = value ? "0" : contentHeight;
|
8164 | doubleRaf(() => {
|
8165 | if (wrapperRef.value) {
|
8166 | wrapperRef.value.style.height = value ? contentHeight : "0";
|
8167 | }
|
8168 | });
|
8169 | } else {
|
8170 | onTransitionEnd();
|
8171 | }
|
8172 | });
|
8173 | });
|
8174 | const toggle = (newValue = !expanded.value) => {
|
8175 | parent.toggle(name2.value, newValue);
|
8176 | };
|
8177 | const onClickTitle = () => {
|
8178 | if (!props2.disabled && !props2.readonly) {
|
8179 | toggle();
|
8180 | }
|
8181 | };
|
8182 | const renderTitle = () => {
|
8183 | const {
|
8184 | border,
|
8185 | disabled,
|
8186 | readonly
|
8187 | } = props2;
|
8188 | const attrs = pick(props2, Object.keys(cellSharedProps));
|
8189 | if (readonly) {
|
8190 | attrs.isLink = false;
|
8191 | }
|
8192 | if (disabled || readonly) {
|
8193 | attrs.clickable = false;
|
8194 | }
|
8195 | return createVNode(Cell, mergeProps({
|
8196 | "role": "button",
|
8197 | "class": bem$W("title", {
|
8198 | disabled,
|
8199 | expanded: expanded.value,
|
8200 | borderless: !border
|
8201 | }),
|
8202 | "aria-expanded": String(expanded.value),
|
8203 | "onClick": onClickTitle
|
8204 | }, attrs), pick(slots, CELL_SLOTS));
|
8205 | };
|
8206 | const renderContent = lazyRender(() => {
|
8207 | var _a;
|
8208 | return withDirectives(createVNode("div", {
|
8209 | "ref": wrapperRef,
|
8210 | "class": bem$W("wrapper"),
|
8211 | "onTransitionend": onTransitionEnd
|
8212 | }, [createVNode("div", {
|
8213 | "ref": contentRef,
|
8214 | "class": bem$W("content")
|
8215 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]), [[vShow, show.value]]);
|
8216 | });
|
8217 | useExpose({
|
8218 | toggle,
|
8219 | expanded,
|
8220 | itemName: name2
|
8221 | });
|
8222 | return () => createVNode("div", {
|
8223 | "class": [bem$W({
|
8224 | border: index.value && props2.border
|
8225 | })]
|
8226 | }, [renderTitle(), renderContent()]);
|
8227 | }
|
8228 | });
|
8229 | const CollapseItem = withInstall(stdin_default$14);
|
8230 | const ConfigProvider = withInstall(stdin_default$1S);
|
8231 | const [name$W, bem$V, t$e] = createNamespace("contact-card");
|
8232 | const contactCardProps = {
|
8233 | tel: String,
|
8234 | name: String,
|
8235 | type: makeStringProp("add"),
|
8236 | addText: String,
|
8237 | editable: truthProp
|
8238 | };
|
8239 | var stdin_default$13 = defineComponent({
|
8240 | name: name$W,
|
8241 | props: contactCardProps,
|
8242 | emits: ["click"],
|
8243 | setup(props2, {
|
8244 | emit
|
8245 | }) {
|
8246 | const onClick = (event) => {
|
8247 | if (props2.editable) {
|
8248 | emit("click", event);
|
8249 | }
|
8250 | };
|
8251 | const renderContent = () => {
|
8252 | if (props2.type === "add") {
|
8253 | return props2.addText || t$e("addContact");
|
8254 | }
|
8255 | return [createVNode("div", null, [`${t$e("name")}:${props2.name}`]), createVNode("div", null, [`${t$e("tel")}:${props2.tel}`])];
|
8256 | };
|
8257 | return () => createVNode(Cell, {
|
8258 | "center": true,
|
8259 | "icon": props2.type === "edit" ? "contact" : "add-square",
|
8260 | "class": bem$V([props2.type]),
|
8261 | "border": false,
|
8262 | "isLink": props2.editable,
|
8263 | "titleClass": bem$V("title"),
|
8264 | "onClick": onClick
|
8265 | }, {
|
8266 | title: renderContent
|
8267 | });
|
8268 | }
|
8269 | });
|
8270 | const ContactCard = withInstall(stdin_default$13);
|
8271 | const [name$V, bem$U, t$d] = createNamespace("contact-edit");
|
8272 | const DEFAULT_CONTACT = {
|
8273 | tel: "",
|
8274 | name: ""
|
8275 | };
|
8276 | const contactEditProps = {
|
8277 | isEdit: Boolean,
|
8278 | isSaving: Boolean,
|
8279 | isDeleting: Boolean,
|
8280 | showSetDefault: Boolean,
|
8281 | setDefaultLabel: String,
|
8282 | contactInfo: {
|
8283 | type: Object,
|
8284 | default: () => extend({}, DEFAULT_CONTACT)
|
8285 | },
|
8286 | telValidator: {
|
8287 | type: Function,
|
8288 | default: isMobile
|
8289 | }
|
8290 | };
|
8291 | var stdin_default$12 = defineComponent({
|
8292 | name: name$V,
|
8293 | props: contactEditProps,
|
8294 | emits: ["save", "delete", "changeDefault"],
|
8295 | setup(props2, {
|
8296 | emit
|
8297 | }) {
|
8298 | const contact = reactive(extend({}, DEFAULT_CONTACT, props2.contactInfo));
|
8299 | const onSave = () => {
|
8300 | if (!props2.isSaving) {
|
8301 | emit("save", contact);
|
8302 | }
|
8303 | };
|
8304 | const onDelete = () => emit("delete", contact);
|
8305 | const renderButtons = () => createVNode("div", {
|
8306 | "class": bem$U("buttons")
|
8307 | }, [createVNode(Button, {
|
8308 | "block": true,
|
8309 | "round": true,
|
8310 | "type": "primary",
|
8311 | "text": t$d("save"),
|
8312 | "class": bem$U("button"),
|
8313 | "loading": props2.isSaving,
|
8314 | "nativeType": "submit"
|
8315 | }, null), props2.isEdit && createVNode(Button, {
|
8316 | "block": true,
|
8317 | "round": true,
|
8318 | "text": t$d("delete"),
|
8319 | "class": bem$U("button"),
|
8320 | "loading": props2.isDeleting,
|
8321 | "onClick": onDelete
|
8322 | }, null)]);
|
8323 | const renderSwitch = () => createVNode(Switch, {
|
8324 | "modelValue": contact.isDefault,
|
8325 | "onUpdate:modelValue": ($event) => contact.isDefault = $event,
|
8326 | "onChange": (checked) => emit("changeDefault", checked)
|
8327 | }, null);
|
8328 | const renderSetDefault = () => {
|
8329 | if (props2.showSetDefault) {
|
8330 | return createVNode(Cell, {
|
8331 | "title": props2.setDefaultLabel,
|
8332 | "class": bem$U("switch-cell"),
|
8333 | "border": false
|
8334 | }, {
|
8335 | "right-icon": renderSwitch
|
8336 | });
|
8337 | }
|
8338 | };
|
8339 | watch(() => props2.contactInfo, (value) => extend(contact, DEFAULT_CONTACT, value));
|
8340 | return () => createVNode(Form, {
|
8341 | "class": bem$U(),
|
8342 | "onSubmit": onSave
|
8343 | }, {
|
8344 | default: () => [createVNode("div", {
|
8345 | "class": bem$U("fields")
|
8346 | }, [createVNode(Field, {
|
8347 | "modelValue": contact.name,
|
8348 | "onUpdate:modelValue": ($event) => contact.name = $event,
|
8349 | "clearable": true,
|
8350 | "label": t$d("name"),
|
8351 | "rules": [{
|
8352 | required: true,
|
8353 | message: t$d("nameEmpty")
|
8354 | }],
|
8355 | "maxlength": "30",
|
8356 | "placeholder": t$d("name")
|
8357 | }, null), createVNode(Field, {
|
8358 | "modelValue": contact.tel,
|
8359 | "onUpdate:modelValue": ($event) => contact.tel = $event,
|
8360 | "clearable": true,
|
8361 | "type": "tel",
|
8362 | "label": t$d("tel"),
|
8363 | "rules": [{
|
8364 | validator: props2.telValidator,
|
8365 | message: t$d("telInvalid")
|
8366 | }],
|
8367 | "placeholder": t$d("tel")
|
8368 | }, null)]), renderSetDefault(), renderButtons()]
|
8369 | });
|
8370 | }
|
8371 | });
|
8372 | const ContactEdit = withInstall(stdin_default$12);
|
8373 | const [name$U, bem$T, t$c] = createNamespace("contact-list");
|
8374 | const contactListProps = {
|
8375 | list: Array,
|
8376 | addText: String,
|
8377 | modelValue: unknownProp,
|
8378 | defaultTagText: String
|
8379 | };
|
8380 | var stdin_default$11 = defineComponent({
|
8381 | name: name$U,
|
8382 | props: contactListProps,
|
8383 | emits: ["add", "edit", "select", "update:modelValue"],
|
8384 | setup(props2, {
|
8385 | emit
|
8386 | }) {
|
8387 | const renderItem = (item, index) => {
|
8388 | const onClick = () => {
|
8389 | emit("update:modelValue", item.id);
|
8390 | emit("select", item, index);
|
8391 | };
|
8392 | const renderRightIcon = () => createVNode(Radio, {
|
8393 | "class": bem$T("radio"),
|
8394 | "name": item.id,
|
8395 | "iconSize": 18
|
8396 | }, null);
|
8397 | const renderEditIcon = () => createVNode(Icon, {
|
8398 | "name": "edit",
|
8399 | "class": bem$T("edit"),
|
8400 | "onClick": (event) => {
|
8401 | event.stopPropagation();
|
8402 | emit("edit", item, index);
|
8403 | }
|
8404 | }, null);
|
8405 | const renderContent = () => {
|
8406 | const nodes = [`${item.name},${item.tel}`];
|
8407 | if (item.isDefault && props2.defaultTagText) {
|
8408 | nodes.push(createVNode(Tag, {
|
8409 | "type": "primary",
|
8410 | "round": true,
|
8411 | "class": bem$T("item-tag")
|
8412 | }, {
|
8413 | default: () => [props2.defaultTagText]
|
8414 | }));
|
8415 | }
|
8416 | return nodes;
|
8417 | };
|
8418 | return createVNode(Cell, {
|
8419 | "key": item.id,
|
8420 | "isLink": true,
|
8421 | "center": true,
|
8422 | "class": bem$T("item"),
|
8423 | "titleClass": bem$T("item-title"),
|
8424 | "onClick": onClick
|
8425 | }, {
|
8426 | icon: renderEditIcon,
|
8427 | title: renderContent,
|
8428 | "right-icon": renderRightIcon
|
8429 | });
|
8430 | };
|
8431 | return () => createVNode("div", {
|
8432 | "class": bem$T()
|
8433 | }, [createVNode(RadioGroup, {
|
8434 | "modelValue": props2.modelValue,
|
8435 | "class": bem$T("group")
|
8436 | }, {
|
8437 | default: () => [props2.list && props2.list.map(renderItem)]
|
8438 | }), createVNode("div", {
|
8439 | "class": [bem$T("bottom"), "van-safe-area-bottom"]
|
8440 | }, [createVNode(Button, {
|
8441 | "round": true,
|
8442 | "block": true,
|
8443 | "type": "primary",
|
8444 | "class": bem$T("add"),
|
8445 | "text": props2.addText || t$c("addContact"),
|
8446 | "onClick": () => emit("add")
|
8447 | }, null)])]);
|
8448 | }
|
8449 | });
|
8450 | const ContactList = withInstall(stdin_default$11);
|
8451 | function parseFormat(format2, currentTime) {
|
8452 | const { days } = currentTime;
|
8453 | let { hours, minutes, seconds, milliseconds } = currentTime;
|
8454 | if (format2.includes("DD")) {
|
8455 | format2 = format2.replace("DD", padZero(days));
|
8456 | } else {
|
8457 | hours += days * 24;
|
8458 | }
|
8459 | if (format2.includes("HH")) {
|
8460 | format2 = format2.replace("HH", padZero(hours));
|
8461 | } else {
|
8462 | minutes += hours * 60;
|
8463 | }
|
8464 | if (format2.includes("mm")) {
|
8465 | format2 = format2.replace("mm", padZero(minutes));
|
8466 | } else {
|
8467 | seconds += minutes * 60;
|
8468 | }
|
8469 | if (format2.includes("ss")) {
|
8470 | format2 = format2.replace("ss", padZero(seconds));
|
8471 | } else {
|
8472 | milliseconds += seconds * 1e3;
|
8473 | }
|
8474 | if (format2.includes("S")) {
|
8475 | const ms = padZero(milliseconds, 3);
|
8476 | if (format2.includes("SSS")) {
|
8477 | format2 = format2.replace("SSS", ms);
|
8478 | } else if (format2.includes("SS")) {
|
8479 | format2 = format2.replace("SS", ms.slice(0, 2));
|
8480 | } else {
|
8481 | format2 = format2.replace("S", ms.charAt(0));
|
8482 | }
|
8483 | }
|
8484 | return format2;
|
8485 | }
|
8486 | const [name$T, bem$S] = createNamespace("count-down");
|
8487 | const countDownProps = {
|
8488 | time: makeNumericProp(0),
|
8489 | format: makeStringProp("HH:mm:ss"),
|
8490 | autoStart: truthProp,
|
8491 | millisecond: Boolean
|
8492 | };
|
8493 | var stdin_default$10 = defineComponent({
|
8494 | name: name$T,
|
8495 | props: countDownProps,
|
8496 | emits: ["change", "finish"],
|
8497 | setup(props2, {
|
8498 | emit,
|
8499 | slots
|
8500 | }) {
|
8501 | const {
|
8502 | start,
|
8503 | pause,
|
8504 | reset,
|
8505 | current: current2
|
8506 | } = useCountDown({
|
8507 | time: +props2.time,
|
8508 | millisecond: props2.millisecond,
|
8509 | onChange: (current22) => emit("change", current22),
|
8510 | onFinish: () => emit("finish")
|
8511 | });
|
8512 | const timeText = computed(() => parseFormat(props2.format, current2.value));
|
8513 | const resetTime = () => {
|
8514 | reset(+props2.time);
|
8515 | if (props2.autoStart) {
|
8516 | start();
|
8517 | }
|
8518 | };
|
8519 | watch(() => props2.time, resetTime, {
|
8520 | immediate: true
|
8521 | });
|
8522 | useExpose({
|
8523 | start,
|
8524 | pause,
|
8525 | reset: resetTime
|
8526 | });
|
8527 | return () => createVNode("div", {
|
8528 | "role": "timer",
|
8529 | "class": bem$S()
|
8530 | }, [slots.default ? slots.default(current2.value) : timeText.value]);
|
8531 | }
|
8532 | });
|
8533 | const CountDown = withInstall(stdin_default$10);
|
8534 | function getDate(timeStamp) {
|
8535 | const date = new Date(timeStamp * 1e3);
|
8536 | return `${date.getFullYear()}.${padZero(date.getMonth() + 1)}.${padZero(
|
8537 | date.getDate()
|
8538 | )}`;
|
8539 | }
|
8540 | const formatDiscount = (discount) => (discount / 10).toFixed(discount % 10 === 0 ? 0 : 1);
|
8541 | const formatAmount = (amount) => (amount / 100).toFixed(amount % 100 === 0 ? 0 : amount % 10 === 0 ? 1 : 2);
|
8542 | const [name$S, bem$R, t$b] = createNamespace("coupon");
|
8543 | var stdin_default$$ = defineComponent({
|
8544 | name: name$S,
|
8545 | props: {
|
8546 | chosen: Boolean,
|
8547 | coupon: makeRequiredProp(Object),
|
8548 | disabled: Boolean,
|
8549 | currency: makeStringProp("¥")
|
8550 | },
|
8551 | setup(props2) {
|
8552 | const validPeriod = computed(() => {
|
8553 | const {
|
8554 | startAt,
|
8555 | endAt
|
8556 | } = props2.coupon;
|
8557 | return `${getDate(startAt)} - ${getDate(endAt)}`;
|
8558 | });
|
8559 | const faceAmount = computed(() => {
|
8560 | const {
|
8561 | coupon,
|
8562 | currency
|
8563 | } = props2;
|
8564 | if (coupon.valueDesc) {
|
8565 | return [coupon.valueDesc, createVNode("span", null, [coupon.unitDesc || ""])];
|
8566 | }
|
8567 | if (coupon.denominations) {
|
8568 | const denominations = formatAmount(coupon.denominations);
|
8569 | return [createVNode("span", null, [currency]), ` ${denominations}`];
|
8570 | }
|
8571 | if (coupon.discount) {
|
8572 | return t$b("discount", formatDiscount(coupon.discount));
|
8573 | }
|
8574 | return "";
|
8575 | });
|
8576 | const conditionMessage = computed(() => {
|
8577 | const condition = formatAmount(props2.coupon.originCondition || 0);
|
8578 | return condition === "0" ? t$b("unlimited") : t$b("condition", condition);
|
8579 | });
|
8580 | return () => {
|
8581 | const {
|
8582 | chosen,
|
8583 | coupon,
|
8584 | disabled
|
8585 | } = props2;
|
8586 | const description = disabled && coupon.reason || coupon.description;
|
8587 | return createVNode("div", {
|
8588 | "class": bem$R({
|
8589 | disabled
|
8590 | })
|
8591 | }, [createVNode("div", {
|
8592 | "class": bem$R("content")
|
8593 | }, [createVNode("div", {
|
8594 | "class": bem$R("head")
|
8595 | }, [createVNode("h2", {
|
8596 | "class": bem$R("amount")
|
8597 | }, [faceAmount.value]), createVNode("p", {
|
8598 | "class": bem$R("condition")
|
8599 | }, [coupon.condition || conditionMessage.value])]), createVNode("div", {
|
8600 | "class": bem$R("body")
|
8601 | }, [createVNode("p", {
|
8602 | "class": bem$R("name")
|
8603 | }, [coupon.name]), createVNode("p", {
|
8604 | "class": bem$R("valid")
|
8605 | }, [validPeriod.value]), !disabled && createVNode(Checkbox, {
|
8606 | "class": bem$R("corner"),
|
8607 | "modelValue": chosen
|
8608 | }, null)])]), description && createVNode("p", {
|
8609 | "class": bem$R("description")
|
8610 | }, [description])]);
|
8611 | };
|
8612 | }
|
8613 | });
|
8614 | const Coupon = withInstall(stdin_default$$);
|
8615 | const [name$R, bem$Q, t$a] = createNamespace("coupon-cell");
|
8616 | const couponCellProps = {
|
8617 | title: String,
|
8618 | border: truthProp,
|
8619 | editable: truthProp,
|
8620 | coupons: makeArrayProp(),
|
8621 | currency: makeStringProp("¥"),
|
8622 | chosenCoupon: makeNumericProp(-1)
|
8623 | };
|
8624 | function formatValue({
|
8625 | coupons,
|
8626 | chosenCoupon,
|
8627 | currency
|
8628 | }) {
|
8629 | const coupon = coupons[+chosenCoupon];
|
8630 | if (coupon) {
|
8631 | let value = 0;
|
8632 | if (isDef(coupon.value)) {
|
8633 | ({
|
8634 | value
|
8635 | } = coupon);
|
8636 | } else if (isDef(coupon.denominations)) {
|
8637 | value = coupon.denominations;
|
8638 | }
|
8639 | return `-${currency} ${(value / 100).toFixed(2)}`;
|
8640 | }
|
8641 | return coupons.length === 0 ? t$a("noCoupon") : t$a("count", coupons.length);
|
8642 | }
|
8643 | var stdin_default$_ = defineComponent({
|
8644 | name: name$R,
|
8645 | props: couponCellProps,
|
8646 | setup(props2) {
|
8647 | return () => {
|
8648 | const selected = props2.coupons[+props2.chosenCoupon];
|
8649 | return createVNode(Cell, {
|
8650 | "class": bem$Q(),
|
8651 | "value": formatValue(props2),
|
8652 | "title": props2.title || t$a("title"),
|
8653 | "border": props2.border,
|
8654 | "isLink": props2.editable,
|
8655 | "valueClass": bem$Q("value", {
|
8656 | selected
|
8657 | })
|
8658 | }, null);
|
8659 | };
|
8660 | }
|
8661 | });
|
8662 | const CouponCell = withInstall(stdin_default$_);
|
8663 | const [name$Q, bem$P] = createNamespace("empty");
|
8664 | const emptyProps = {
|
8665 | image: makeStringProp("default"),
|
8666 | imageSize: [Number, String, Array],
|
8667 | description: String
|
8668 | };
|
8669 | var stdin_default$Z = defineComponent({
|
8670 | name: name$Q,
|
8671 | props: emptyProps,
|
8672 | setup(props2, {
|
8673 | slots
|
8674 | }) {
|
8675 | const renderDescription = () => {
|
8676 | const description = slots.description ? slots.description() : props2.description;
|
8677 | if (description) {
|
8678 | return createVNode("p", {
|
8679 | "class": bem$P("description")
|
8680 | }, [description]);
|
8681 | }
|
8682 | };
|
8683 | const renderBottom = () => {
|
8684 | if (slots.default) {
|
8685 | return createVNode("div", {
|
8686 | "class": bem$P("bottom")
|
8687 | }, [slots.default()]);
|
8688 | }
|
8689 | };
|
8690 | const baseId = useId();
|
8691 | const getId = (num) => `${baseId}-${num}`;
|
8692 | const getUrlById = (num) => `url(#${getId(num)})`;
|
8693 | const renderStop = (color, offset, opacity) => createVNode("stop", {
|
8694 | "stop-color": color,
|
8695 | "offset": `${offset}%`,
|
8696 | "stop-opacity": opacity
|
8697 | }, null);
|
8698 | const renderStops = (fromColor, toColor) => [renderStop(fromColor, 0), renderStop(toColor, 100)];
|
8699 | const renderShadow = (id) => [createVNode("defs", null, [createVNode("radialGradient", {
|
8700 | "id": getId(id),
|
8701 | "cx": "50%",
|
8702 | "cy": "54%",
|
8703 | "fx": "50%",
|
8704 | "fy": "54%",
|
8705 | "r": "297%",
|
8706 | "gradientTransform": "matrix(-.16 0 0 -.33 .58 .72)"
|
8707 | }, [renderStop("#EBEDF0", 0), renderStop("#F2F3F5", 100, 0.3)])]), createVNode("ellipse", {
|
8708 | "fill": getUrlById(id),
|
8709 | "opacity": ".8",
|
8710 | "cx": "80",
|
8711 | "cy": "140",
|
8712 | "rx": "46",
|
8713 | "ry": "8"
|
8714 | }, null)];
|
8715 | const renderBuilding = () => [createVNode("defs", null, [createVNode("linearGradient", {
|
8716 | "id": getId("a"),
|
8717 | "x1": "64%",
|
8718 | "y1": "100%",
|
8719 | "x2": "64%"
|
8720 | }, [renderStop("#FFF", 0, 0.5), renderStop("#F2F3F5", 100)])]), createVNode("g", {
|
8721 | "opacity": ".8"
|
8722 | }, [createVNode("path", {
|
8723 | "d": "M36 131V53H16v20H2v58h34z",
|
8724 | "fill": getUrlById("a")
|
8725 | }, null), createVNode("path", {
|
8726 | "d": "M123 15h22v14h9v77h-31V15z",
|
8727 | "fill": getUrlById("a")
|
8728 | }, null)])];
|
8729 | const renderCloud = () => [createVNode("defs", null, [createVNode("linearGradient", {
|
8730 | "id": getId("b"),
|
8731 | "x1": "64%",
|
8732 | "y1": "97%",
|
8733 | "x2": "64%",
|
8734 | "y2": "0%"
|
8735 | }, [renderStop("#F2F3F5", 0, 0.3), renderStop("#F2F3F5", 100)])]), createVNode("g", {
|
8736 | "opacity": ".8"
|
8737 | }, [createVNode("path", {
|
8738 | "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",
|
8739 | "fill": getUrlById("b")
|
8740 | }, null), createVNode("path", {
|
8741 | "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",
|
8742 | "fill": getUrlById("b")
|
8743 | }, null)])];
|
8744 | const renderNetwork = () => createVNode("svg", {
|
8745 | "viewBox": "0 0 160 160"
|
8746 | }, [createVNode("defs", null, [createVNode("linearGradient", {
|
8747 | "id": getId(1),
|
8748 | "x1": "64%",
|
8749 | "y1": "100%",
|
8750 | "x2": "64%"
|
8751 | }, [renderStop("#FFF", 0, 0.5), renderStop("#F2F3F5", 100)]), createVNode("linearGradient", {
|
8752 | "id": getId(2),
|
8753 | "x1": "50%",
|
8754 | "x2": "50%",
|
8755 | "y2": "84%"
|
8756 | }, [renderStop("#EBEDF0", 0), renderStop("#DCDEE0", 100, 0)]), createVNode("linearGradient", {
|
8757 | "id": getId(3),
|
8758 | "x1": "100%",
|
8759 | "x2": "100%",
|
8760 | "y2": "100%"
|
8761 | }, [renderStops("#EAEDF0", "#DCDEE0")]), createVNode("radialGradient", {
|
8762 | "id": getId(4),
|
8763 | "cx": "50%",
|
8764 | "cy": "0%",
|
8765 | "fx": "50%",
|
8766 | "fy": "0%",
|
8767 | "r": "100%",
|
8768 | "gradientTransform": "matrix(0 1 -.54 0 .5 -.5)"
|
8769 | }, [renderStop("#EBEDF0", 0), renderStop("#FFF", 100, 0)])]), createVNode("g", {
|
8770 | "fill": "none"
|
8771 | }, [renderBuilding(), createVNode("path", {
|
8772 | "fill": getUrlById(4),
|
8773 | "d": "M0 139h160v21H0z"
|
8774 | }, null), createVNode("path", {
|
8775 | "d": "M80 54a7 7 0 0 1 3 13v27l-2 2h-2a2 2 0 0 1-2-2V67a7 7 0 0 1 3-13z",
|
8776 | "fill": getUrlById(2)
|
8777 | }, null), createVNode("g", {
|
8778 | "opacity": ".6",
|
8779 | "stroke-linecap": "round",
|
8780 | "stroke-width": "7"
|
8781 | }, [createVNode("path", {
|
8782 | "d": "M64 47a19 19 0 0 0-5 13c0 5 2 10 5 13",
|
8783 | "stroke": getUrlById(3)
|
8784 | }, null), createVNode("path", {
|
8785 | "d": "M53 36a34 34 0 0 0 0 48",
|
8786 | "stroke": getUrlById(3)
|
8787 | }, null), createVNode("path", {
|
8788 | "d": "M95 73a19 19 0 0 0 6-13c0-5-2-9-6-13",
|
8789 | "stroke": getUrlById(3)
|
8790 | }, null), createVNode("path", {
|
8791 | "d": "M106 84a34 34 0 0 0 0-48",
|
8792 | "stroke": getUrlById(3)
|
8793 | }, null)]), createVNode("g", {
|
8794 | "transform": "translate(31 105)"
|
8795 | }, [createVNode("rect", {
|
8796 | "fill": "#EBEDF0",
|
8797 | "width": "98",
|
8798 | "height": "34",
|
8799 | "rx": "2"
|
8800 | }, null), createVNode("rect", {
|
8801 | "fill": "#FFF",
|
8802 | "x": "9",
|
8803 | "y": "8",
|
8804 | "width": "80",
|
8805 | "height": "18",
|
8806 | "rx": "1.1"
|
8807 | }, null), createVNode("rect", {
|
8808 | "fill": "#EBEDF0",
|
8809 | "x": "15",
|
8810 | "y": "12",
|
8811 | "width": "18",
|
8812 | "height": "6",
|
8813 | "rx": "1.1"
|
8814 | }, null)])])]);
|
8815 | const renderMaterial = () => createVNode("svg", {
|
8816 | "viewBox": "0 0 160 160"
|
8817 | }, [createVNode("defs", null, [createVNode("linearGradient", {
|
8818 | "x1": "50%",
|
8819 | "x2": "50%",
|
8820 | "y2": "100%",
|
8821 | "id": getId(5)
|
8822 | }, [renderStops("#F2F3F5", "#DCDEE0")]), createVNode("linearGradient", {
|
8823 | "x1": "95%",
|
8824 | "y1": "48%",
|
8825 | "x2": "5.5%",
|
8826 | "y2": "51%",
|
8827 | "id": getId(6)
|
8828 | }, [renderStops("#EAEDF1", "#DCDEE0")]), createVNode("linearGradient", {
|
8829 | "y1": "45%",
|
8830 | "x2": "100%",
|
8831 | "y2": "54%",
|
8832 | "id": getId(7)
|
8833 | }, [renderStops("#EAEDF1", "#DCDEE0")])]), renderBuilding(), renderCloud(), createVNode("g", {
|
8834 | "transform": "translate(36 50)",
|
8835 | "fill": "none"
|
8836 | }, [createVNode("g", {
|
8837 | "transform": "translate(8)"
|
8838 | }, [createVNode("rect", {
|
8839 | "fill": "#EBEDF0",
|
8840 | "opacity": ".6",
|
8841 | "x": "38",
|
8842 | "y": "13",
|
8843 | "width": "36",
|
8844 | "height": "53",
|
8845 | "rx": "2"
|
8846 | }, null), createVNode("rect", {
|
8847 | "fill": getUrlById(5),
|
8848 | "width": "64",
|
8849 | "height": "66",
|
8850 | "rx": "2"
|
8851 | }, null), createVNode("rect", {
|
8852 | "fill": "#FFF",
|
8853 | "x": "6",
|
8854 | "y": "6",
|
8855 | "width": "52",
|
8856 | "height": "55",
|
8857 | "rx": "1"
|
8858 | }, null), createVNode("g", {
|
8859 | "transform": "translate(15 17)",
|
8860 | "fill": getUrlById(6)
|
8861 | }, [createVNode("rect", {
|
8862 | "width": "34",
|
8863 | "height": "6",
|
8864 | "rx": "1"
|
8865 | }, null), createVNode("path", {
|
8866 | "d": "M0 14h34v6H0z"
|
8867 | }, null), createVNode("rect", {
|
8868 | "y": "28",
|
8869 | "width": "34",
|
8870 | "height": "6",
|
8871 | "rx": "1"
|
8872 | }, null)])]), createVNode("rect", {
|
8873 | "fill": getUrlById(7),
|
8874 | "y": "61",
|
8875 | "width": "88",
|
8876 | "height": "28",
|
8877 | "rx": "1"
|
8878 | }, null), createVNode("rect", {
|
8879 | "fill": "#F7F8FA",
|
8880 | "x": "29",
|
8881 | "y": "72",
|
8882 | "width": "30",
|
8883 | "height": "6",
|
8884 | "rx": "1"
|
8885 | }, null)])]);
|
8886 | const renderError = () => createVNode("svg", {
|
8887 | "viewBox": "0 0 160 160"
|
8888 | }, [createVNode("defs", null, [createVNode("linearGradient", {
|
8889 | "x1": "50%",
|
8890 | "x2": "50%",
|
8891 | "y2": "100%",
|
8892 | "id": getId(8)
|
8893 | }, [renderStops("#EAEDF1", "#DCDEE0")])]), renderBuilding(), renderCloud(), renderShadow("c"), createVNode("path", {
|
8894 | "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",
|
8895 | "fill": getUrlById(8)
|
8896 | }, null)]);
|
8897 | const renderSearch = () => createVNode("svg", {
|
8898 | "viewBox": "0 0 160 160"
|
8899 | }, [createVNode("defs", null, [createVNode("linearGradient", {
|
8900 | "x1": "50%",
|
8901 | "y1": "100%",
|
8902 | "x2": "50%",
|
8903 | "id": getId(9)
|
8904 | }, [renderStops("#EEE", "#D8D8D8")]), createVNode("linearGradient", {
|
8905 | "x1": "100%",
|
8906 | "y1": "50%",
|
8907 | "y2": "50%",
|
8908 | "id": getId(10)
|
8909 | }, [renderStops("#F2F3F5", "#DCDEE0")]), createVNode("linearGradient", {
|
8910 | "x1": "50%",
|
8911 | "x2": "50%",
|
8912 | "y2": "100%",
|
8913 | "id": getId(11)
|
8914 | }, [renderStops("#F2F3F5", "#DCDEE0")]), createVNode("linearGradient", {
|
8915 | "x1": "50%",
|
8916 | "x2": "50%",
|
8917 | "y2": "100%",
|
8918 | "id": getId(12)
|
8919 | }, [renderStops("#FFF", "#F7F8FA")])]), renderBuilding(), renderCloud(), renderShadow("d"), createVNode("g", {
|
8920 | "transform": "rotate(-45 113 -4)",
|
8921 | "fill": "none"
|
8922 | }, [createVNode("rect", {
|
8923 | "fill": getUrlById(9),
|
8924 | "x": "24",
|
8925 | "y": "52.8",
|
8926 | "width": "5.8",
|
8927 | "height": "19",
|
8928 | "rx": "1"
|
8929 | }, null), createVNode("rect", {
|
8930 | "fill": getUrlById(10),
|
8931 | "x": "22.1",
|
8932 | "y": "67.3",
|
8933 | "width": "9.9",
|
8934 | "height": "28",
|
8935 | "rx": "1"
|
8936 | }, null), createVNode("circle", {
|
8937 | "stroke": getUrlById(11),
|
8938 | "stroke-width": "8",
|
8939 | "cx": "27",
|
8940 | "cy": "27",
|
8941 | "r": "27"
|
8942 | }, null), createVNode("circle", {
|
8943 | "fill": getUrlById(12),
|
8944 | "cx": "27",
|
8945 | "cy": "27",
|
8946 | "r": "16"
|
8947 | }, null), createVNode("path", {
|
8948 | "d": "M37 7c-8 0-15 5-16 12",
|
8949 | "stroke": getUrlById(11),
|
8950 | "stroke-width": "3",
|
8951 | "opacity": ".5",
|
8952 | "stroke-linecap": "round",
|
8953 | "transform": "rotate(45 29 13)"
|
8954 | }, null)])]);
|
8955 | const renderImage = () => {
|
8956 | var _a;
|
8957 | if (slots.image) {
|
8958 | return slots.image();
|
8959 | }
|
8960 | const PRESET_IMAGES = {
|
8961 | error: renderError,
|
8962 | search: renderSearch,
|
8963 | network: renderNetwork,
|
8964 | default: renderMaterial
|
8965 | };
|
8966 | return ((_a = PRESET_IMAGES[props2.image]) == null ? void 0 : _a.call(PRESET_IMAGES)) || createVNode("img", {
|
8967 | "src": props2.image
|
8968 | }, null);
|
8969 | };
|
8970 | return () => createVNode("div", {
|
8971 | "class": bem$P()
|
8972 | }, [createVNode("div", {
|
8973 | "class": bem$P("image"),
|
8974 | "style": getSizeStyle(props2.imageSize)
|
8975 | }, [renderImage()]), renderDescription(), renderBottom()]);
|
8976 | }
|
8977 | });
|
8978 | const Empty = withInstall(stdin_default$Z);
|
8979 | const [name$P, bem$O, t$9] = createNamespace("coupon-list");
|
8980 | const couponListProps = {
|
8981 | code: makeStringProp(""),
|
8982 | coupons: makeArrayProp(),
|
8983 | currency: makeStringProp("¥"),
|
8984 | showCount: truthProp,
|
8985 | emptyImage: String,
|
8986 | chosenCoupon: makeNumberProp(-1),
|
8987 | enabledTitle: String,
|
8988 | disabledTitle: String,
|
8989 | disabledCoupons: makeArrayProp(),
|
8990 | showExchangeBar: truthProp,
|
8991 | showCloseButton: truthProp,
|
8992 | closeButtonText: String,
|
8993 | inputPlaceholder: String,
|
8994 | exchangeMinLength: makeNumberProp(1),
|
8995 | exchangeButtonText: String,
|
8996 | displayedCouponIndex: makeNumberProp(-1),
|
8997 | exchangeButtonLoading: Boolean,
|
8998 | exchangeButtonDisabled: Boolean
|
8999 | };
|
9000 | var stdin_default$Y = defineComponent({
|
9001 | name: name$P,
|
9002 | props: couponListProps,
|
9003 | emits: ["change", "exchange", "update:code"],
|
9004 | setup(props2, {
|
9005 | emit,
|
9006 | slots
|
9007 | }) {
|
9008 | const [couponRefs, setCouponRefs] = useRefs();
|
9009 | const root = ref();
|
9010 | const barRef = ref();
|
9011 | const activeTab = ref(0);
|
9012 | const listHeight = ref(0);
|
9013 | const currentCode = ref(props2.code);
|
9014 | const buttonDisabled = computed(() => !props2.exchangeButtonLoading && (props2.exchangeButtonDisabled || !currentCode.value || currentCode.value.length < props2.exchangeMinLength));
|
9015 | const updateListHeight = () => {
|
9016 | const TABS_HEIGHT = 44;
|
9017 | const rootHeight = useRect(root).height;
|
9018 | const headerHeight = useRect(barRef).height + TABS_HEIGHT;
|
9019 | listHeight.value = (rootHeight > headerHeight ? rootHeight : windowHeight.value) - headerHeight;
|
9020 | };
|
9021 | const onExchange = () => {
|
9022 | emit("exchange", currentCode.value);
|
9023 | if (!props2.code) {
|
9024 | currentCode.value = "";
|
9025 | }
|
9026 | };
|
9027 | const scrollToCoupon = (index) => {
|
9028 | nextTick(() => {
|
9029 | var _a;
|
9030 | return (_a = couponRefs.value[index]) == null ? void 0 : _a.scrollIntoView();
|
9031 | });
|
9032 | };
|
9033 | const renderEmpty = () => createVNode(Empty, {
|
9034 | "image": props2.emptyImage
|
9035 | }, {
|
9036 | default: () => [createVNode("p", {
|
9037 | "class": bem$O("empty-tip")
|
9038 | }, [t$9("noCoupon")])]
|
9039 | });
|
9040 | const renderExchangeBar = () => {
|
9041 | if (props2.showExchangeBar) {
|
9042 | return createVNode("div", {
|
9043 | "ref": barRef,
|
9044 | "class": bem$O("exchange-bar")
|
9045 | }, [createVNode(Field, {
|
9046 | "modelValue": currentCode.value,
|
9047 | "onUpdate:modelValue": ($event) => currentCode.value = $event,
|
9048 | "clearable": true,
|
9049 | "border": false,
|
9050 | "class": bem$O("field"),
|
9051 | "placeholder": props2.inputPlaceholder || t$9("placeholder"),
|
9052 | "maxlength": "20"
|
9053 | }, null), createVNode(Button, {
|
9054 | "plain": true,
|
9055 | "type": "primary",
|
9056 | "class": bem$O("exchange"),
|
9057 | "text": props2.exchangeButtonText || t$9("exchange"),
|
9058 | "loading": props2.exchangeButtonLoading,
|
9059 | "disabled": buttonDisabled.value,
|
9060 | "onClick": onExchange
|
9061 | }, null)]);
|
9062 | }
|
9063 | };
|
9064 | const renderCouponTab = () => {
|
9065 | const {
|
9066 | coupons
|
9067 | } = props2;
|
9068 | const count = props2.showCount ? ` (${coupons.length})` : "";
|
9069 | const title = (props2.enabledTitle || t$9("enable")) + count;
|
9070 | return createVNode(Tab, {
|
9071 | "title": title
|
9072 | }, {
|
9073 | default: () => {
|
9074 | var _a;
|
9075 | return [createVNode("div", {
|
9076 | "class": bem$O("list", {
|
9077 | "with-bottom": props2.showCloseButton
|
9078 | }),
|
9079 | "style": {
|
9080 | height: `${listHeight.value}px`
|
9081 | }
|
9082 | }, [coupons.map((coupon, index) => createVNode(Coupon, {
|
9083 | "key": coupon.id,
|
9084 | "ref": setCouponRefs(index),
|
9085 | "coupon": coupon,
|
9086 | "chosen": index === props2.chosenCoupon,
|
9087 | "currency": props2.currency,
|
9088 | "onClick": () => emit("change", index)
|
9089 | }, null)), !coupons.length && renderEmpty(), (_a = slots["list-footer"]) == null ? void 0 : _a.call(slots)])];
|
9090 | }
|
9091 | });
|
9092 | };
|
9093 | const renderDisabledTab = () => {
|
9094 | const {
|
9095 | disabledCoupons
|
9096 | } = props2;
|
9097 | const count = props2.showCount ? ` (${disabledCoupons.length})` : "";
|
9098 | const title = (props2.disabledTitle || t$9("disabled")) + count;
|
9099 | return createVNode(Tab, {
|
9100 | "title": title
|
9101 | }, {
|
9102 | default: () => {
|
9103 | var _a;
|
9104 | return [createVNode("div", {
|
9105 | "class": bem$O("list", {
|
9106 | "with-bottom": props2.showCloseButton
|
9107 | }),
|
9108 | "style": {
|
9109 | height: `${listHeight.value}px`
|
9110 | }
|
9111 | }, [disabledCoupons.map((coupon) => createVNode(Coupon, {
|
9112 | "disabled": true,
|
9113 | "key": coupon.id,
|
9114 | "coupon": coupon,
|
9115 | "currency": props2.currency
|
9116 | }, null)), !disabledCoupons.length && renderEmpty(), (_a = slots["disabled-list-footer"]) == null ? void 0 : _a.call(slots)])];
|
9117 | }
|
9118 | });
|
9119 | };
|
9120 | watch(() => props2.code, (value) => {
|
9121 | currentCode.value = value;
|
9122 | });
|
9123 | watch(windowHeight, updateListHeight);
|
9124 | watch(currentCode, (value) => emit("update:code", value));
|
9125 | watch(() => props2.displayedCouponIndex, scrollToCoupon);
|
9126 | onMounted(() => {
|
9127 | updateListHeight();
|
9128 | scrollToCoupon(props2.displayedCouponIndex);
|
9129 | });
|
9130 | return () => createVNode("div", {
|
9131 | "ref": root,
|
9132 | "class": bem$O()
|
9133 | }, [renderExchangeBar(), createVNode(Tabs, {
|
9134 | "active": activeTab.value,
|
9135 | "onUpdate:active": ($event) => activeTab.value = $event,
|
9136 | "class": bem$O("tab")
|
9137 | }, {
|
9138 | default: () => [renderCouponTab(), renderDisabledTab()]
|
9139 | }), createVNode("div", {
|
9140 | "class": bem$O("bottom")
|
9141 | }, [withDirectives(createVNode(Button, {
|
9142 | "round": true,
|
9143 | "block": true,
|
9144 | "type": "primary",
|
9145 | "class": bem$O("close"),
|
9146 | "text": props2.closeButtonText || t$9("close"),
|
9147 | "onClick": () => emit("change", -1)
|
9148 | }, null), [[vShow, props2.showCloseButton]])])]);
|
9149 | }
|
9150 | });
|
9151 | const CouponList = withInstall(stdin_default$Y);
|
9152 | const currentYear = ( new Date()).getFullYear();
|
9153 | const [name$O] = createNamespace("date-picker");
|
9154 | const datePickerProps = extend({}, sharedProps, {
|
9155 | columnsType: {
|
9156 | type: Array,
|
9157 | default: () => ["year", "month", "day"]
|
9158 | },
|
9159 | minDate: {
|
9160 | type: Date,
|
9161 | default: () => new Date(currentYear - 10, 0, 1),
|
9162 | validator: isDate
|
9163 | },
|
9164 | maxDate: {
|
9165 | type: Date,
|
9166 | default: () => new Date(currentYear + 10, 11, 31),
|
9167 | validator: isDate
|
9168 | }
|
9169 | });
|
9170 | var stdin_default$X = defineComponent({
|
9171 | name: name$O,
|
9172 | props: datePickerProps,
|
9173 | emits: ["confirm", "cancel", "change", "update:modelValue"],
|
9174 | setup(props2, {
|
9175 | emit,
|
9176 | slots
|
9177 | }) {
|
9178 | const currentValues = ref(props2.modelValue);
|
9179 | const updatedByExternalSources = ref(false);
|
9180 | const genYearOptions = () => {
|
9181 | const minYear = props2.minDate.getFullYear();
|
9182 | const maxYear = props2.maxDate.getFullYear();
|
9183 | return genOptions(minYear, maxYear, "year", props2.formatter, props2.filter);
|
9184 | };
|
9185 | const isMinYear = (year) => year === props2.minDate.getFullYear();
|
9186 | const isMaxYear = (year) => year === props2.maxDate.getFullYear();
|
9187 | const isMinMonth = (month) => month === props2.minDate.getMonth() + 1;
|
9188 | const isMaxMonth = (month) => month === props2.maxDate.getMonth() + 1;
|
9189 | const getValue = (type) => {
|
9190 | const {
|
9191 | minDate,
|
9192 | columnsType
|
9193 | } = props2;
|
9194 | const index = columnsType.indexOf(type);
|
9195 | const value = updatedByExternalSources.value ? props2.modelValue[index] : currentValues.value[index];
|
9196 | if (value) {
|
9197 | return +value;
|
9198 | }
|
9199 | switch (type) {
|
9200 | case "year":
|
9201 | return minDate.getFullYear();
|
9202 | case "month":
|
9203 | return minDate.getMonth() + 1;
|
9204 | case "day":
|
9205 | return minDate.getDate();
|
9206 | }
|
9207 | };
|
9208 | const genMonthOptions = () => {
|
9209 | const year = getValue("year");
|
9210 | const minMonth = isMinYear(year) ? props2.minDate.getMonth() + 1 : 1;
|
9211 | const maxMonth = isMaxYear(year) ? props2.maxDate.getMonth() + 1 : 12;
|
9212 | return genOptions(minMonth, maxMonth, "month", props2.formatter, props2.filter);
|
9213 | };
|
9214 | const genDayOptions = () => {
|
9215 | const year = getValue("year");
|
9216 | const month = getValue("month");
|
9217 | const minDate = isMinYear(year) && isMinMonth(month) ? props2.minDate.getDate() : 1;
|
9218 | const maxDate = isMaxYear(year) && isMaxMonth(month) ? props2.maxDate.getDate() : getMonthEndDay(year, month);
|
9219 | return genOptions(minDate, maxDate, "day", props2.formatter, props2.filter);
|
9220 | };
|
9221 | const columns = computed(() => props2.columnsType.map((type) => {
|
9222 | switch (type) {
|
9223 | case "year":
|
9224 | return genYearOptions();
|
9225 | case "month":
|
9226 | return genMonthOptions();
|
9227 | case "day":
|
9228 | return genDayOptions();
|
9229 | default:
|
9230 | if (process.env.NODE_ENV !== "production") {
|
9231 | throw new Error(`[Vant] DatePicker: unsupported columns type: ${type}`);
|
9232 | }
|
9233 | return [];
|
9234 | }
|
9235 | }));
|
9236 | watch(currentValues, (newValues) => {
|
9237 | if (!isSameValue(newValues, props2.modelValue)) {
|
9238 | emit("update:modelValue", newValues);
|
9239 | }
|
9240 | });
|
9241 | watch(() => props2.modelValue, (newValues, oldValues) => {
|
9242 | updatedByExternalSources.value = isSameValue(oldValues, currentValues.value);
|
9243 | newValues = formatValueRange(newValues, columns.value);
|
9244 | if (!isSameValue(newValues, currentValues.value)) {
|
9245 | currentValues.value = newValues;
|
9246 | }
|
9247 | updatedByExternalSources.value = false;
|
9248 | }, {
|
9249 | immediate: true
|
9250 | });
|
9251 | const onChange = (...args) => emit("change", ...args);
|
9252 | const onCancel = (...args) => emit("cancel", ...args);
|
9253 | const onConfirm = (...args) => emit("confirm", ...args);
|
9254 | return () => createVNode(Picker, mergeProps({
|
9255 | "modelValue": currentValues.value,
|
9256 | "onUpdate:modelValue": ($event) => currentValues.value = $event,
|
9257 | "columns": columns.value,
|
9258 | "onChange": onChange,
|
9259 | "onCancel": onCancel,
|
9260 | "onConfirm": onConfirm
|
9261 | }, pick(props2, pickerInheritKeys)), slots);
|
9262 | }
|
9263 | });
|
9264 | const DatePicker = withInstall(stdin_default$X);
|
9265 | const [name$N, bem$N, t$8] = createNamespace("dialog");
|
9266 | const dialogProps = extend({}, popupSharedProps, {
|
9267 | title: String,
|
9268 | theme: String,
|
9269 | width: numericProp,
|
9270 | message: [String, Function],
|
9271 | callback: Function,
|
9272 | allowHtml: Boolean,
|
9273 | className: unknownProp,
|
9274 | transition: makeStringProp("van-dialog-bounce"),
|
9275 | messageAlign: String,
|
9276 | closeOnPopstate: truthProp,
|
9277 | showCancelButton: Boolean,
|
9278 | cancelButtonText: String,
|
9279 | cancelButtonColor: String,
|
9280 | cancelButtonDisabled: Boolean,
|
9281 | confirmButtonText: String,
|
9282 | confirmButtonColor: String,
|
9283 | confirmButtonDisabled: Boolean,
|
9284 | showConfirmButton: truthProp,
|
9285 | closeOnClickOverlay: Boolean
|
9286 | });
|
9287 | const popupInheritKeys$1 = [...popupSharedPropKeys, "transition", "closeOnPopstate"];
|
9288 | var stdin_default$W = defineComponent({
|
9289 | name: name$N,
|
9290 | props: dialogProps,
|
9291 | emits: ["confirm", "cancel", "keydown", "update:show"],
|
9292 | setup(props2, {
|
9293 | emit,
|
9294 | slots
|
9295 | }) {
|
9296 | const root = ref();
|
9297 | const loading = reactive({
|
9298 | confirm: false,
|
9299 | cancel: false
|
9300 | });
|
9301 | const updateShow = (value) => emit("update:show", value);
|
9302 | const close = (action) => {
|
9303 | var _a;
|
9304 | updateShow(false);
|
9305 | (_a = props2.callback) == null ? void 0 : _a.call(props2, action);
|
9306 | };
|
9307 | const getActionHandler = (action) => () => {
|
9308 | if (!props2.show) {
|
9309 | return;
|
9310 | }
|
9311 | emit(action);
|
9312 | if (props2.beforeClose) {
|
9313 | loading[action] = true;
|
9314 | callInterceptor(props2.beforeClose, {
|
9315 | args: [action],
|
9316 | done() {
|
9317 | close(action);
|
9318 | loading[action] = false;
|
9319 | },
|
9320 | canceled() {
|
9321 | loading[action] = false;
|
9322 | }
|
9323 | });
|
9324 | } else {
|
9325 | close(action);
|
9326 | }
|
9327 | };
|
9328 | const onCancel = getActionHandler("cancel");
|
9329 | const onConfirm = getActionHandler("confirm");
|
9330 | const onKeydown = withKeys((event) => {
|
9331 | var _a, _b;
|
9332 | if (event.target !== ((_b = (_a = root.value) == null ? void 0 : _a.popupRef) == null ? void 0 : _b.value)) {
|
9333 | return;
|
9334 | }
|
9335 | const onEventType = {
|
9336 | Enter: props2.showConfirmButton ? onConfirm : noop,
|
9337 | Escape: props2.showCancelButton ? onCancel : noop
|
9338 | };
|
9339 | onEventType[event.key]();
|
9340 | emit("keydown", event);
|
9341 | }, ["enter", "esc"]);
|
9342 | const renderTitle = () => {
|
9343 | const title = slots.title ? slots.title() : props2.title;
|
9344 | if (title) {
|
9345 | return createVNode("div", {
|
9346 | "class": bem$N("header", {
|
9347 | isolated: !props2.message && !slots.default
|
9348 | })
|
9349 | }, [title]);
|
9350 | }
|
9351 | };
|
9352 | const renderMessage = (hasTitle) => {
|
9353 | const {
|
9354 | message,
|
9355 | allowHtml,
|
9356 | messageAlign
|
9357 | } = props2;
|
9358 | const classNames = bem$N("message", {
|
9359 | "has-title": hasTitle,
|
9360 | [messageAlign]: messageAlign
|
9361 | });
|
9362 | const content = isFunction(message) ? message() : message;
|
9363 | if (allowHtml && typeof content === "string") {
|
9364 | return createVNode("div", {
|
9365 | "class": classNames,
|
9366 | "innerHTML": content
|
9367 | }, null);
|
9368 | }
|
9369 | return createVNode("div", {
|
9370 | "class": classNames
|
9371 | }, [content]);
|
9372 | };
|
9373 | const renderContent = () => {
|
9374 | if (slots.default) {
|
9375 | return createVNode("div", {
|
9376 | "class": bem$N("content")
|
9377 | }, [slots.default()]);
|
9378 | }
|
9379 | const {
|
9380 | title,
|
9381 | message,
|
9382 | allowHtml
|
9383 | } = props2;
|
9384 | if (message) {
|
9385 | const hasTitle = !!(title || slots.title);
|
9386 | return createVNode("div", {
|
9387 | "key": allowHtml ? 1 : 0,
|
9388 | "class": bem$N("content", {
|
9389 | isolated: !hasTitle
|
9390 | })
|
9391 | }, [renderMessage(hasTitle)]);
|
9392 | }
|
9393 | };
|
9394 | const renderButtons = () => createVNode("div", {
|
9395 | "class": [BORDER_TOP, bem$N("footer")]
|
9396 | }, [props2.showCancelButton && createVNode(Button, {
|
9397 | "size": "large",
|
9398 | "text": props2.cancelButtonText || t$8("cancel"),
|
9399 | "class": bem$N("cancel"),
|
9400 | "style": {
|
9401 | color: props2.cancelButtonColor
|
9402 | },
|
9403 | "loading": loading.cancel,
|
9404 | "disabled": props2.cancelButtonDisabled,
|
9405 | "onClick": onCancel
|
9406 | }, null), props2.showConfirmButton && createVNode(Button, {
|
9407 | "size": "large",
|
9408 | "text": props2.confirmButtonText || t$8("confirm"),
|
9409 | "class": [bem$N("confirm"), {
|
9410 | [BORDER_LEFT]: props2.showCancelButton
|
9411 | }],
|
9412 | "style": {
|
9413 | color: props2.confirmButtonColor
|
9414 | },
|
9415 | "loading": loading.confirm,
|
9416 | "disabled": props2.confirmButtonDisabled,
|
9417 | "onClick": onConfirm
|
9418 | }, null)]);
|
9419 | const renderRoundButtons = () => createVNode(ActionBar, {
|
9420 | "class": bem$N("footer")
|
9421 | }, {
|
9422 | default: () => [props2.showCancelButton && createVNode(ActionBarButton, {
|
9423 | "type": "warning",
|
9424 | "text": props2.cancelButtonText || t$8("cancel"),
|
9425 | "class": bem$N("cancel"),
|
9426 | "color": props2.cancelButtonColor,
|
9427 | "loading": loading.cancel,
|
9428 | "disabled": props2.cancelButtonDisabled,
|
9429 | "onClick": onCancel
|
9430 | }, null), props2.showConfirmButton && createVNode(ActionBarButton, {
|
9431 | "type": "danger",
|
9432 | "text": props2.confirmButtonText || t$8("confirm"),
|
9433 | "class": bem$N("confirm"),
|
9434 | "color": props2.confirmButtonColor,
|
9435 | "loading": loading.confirm,
|
9436 | "disabled": props2.confirmButtonDisabled,
|
9437 | "onClick": onConfirm
|
9438 | }, null)]
|
9439 | });
|
9440 | const renderFooter = () => {
|
9441 | if (slots.footer) {
|
9442 | return slots.footer();
|
9443 | }
|
9444 | return props2.theme === "round-button" ? renderRoundButtons() : renderButtons();
|
9445 | };
|
9446 | return () => {
|
9447 | const {
|
9448 | width,
|
9449 | title,
|
9450 | theme,
|
9451 | message,
|
9452 | className
|
9453 | } = props2;
|
9454 | return createVNode(Popup, mergeProps({
|
9455 | "ref": root,
|
9456 | "role": "dialog",
|
9457 | "class": [bem$N([theme]), className],
|
9458 | "style": {
|
9459 | width: addUnit(width)
|
9460 | },
|
9461 | "tabindex": 0,
|
9462 | "aria-labelledby": title || message,
|
9463 | "onKeydown": onKeydown,
|
9464 | "onUpdate:show": updateShow
|
9465 | }, pick(props2, popupInheritKeys$1)), {
|
9466 | default: () => [renderTitle(), renderContent(), renderFooter()]
|
9467 | });
|
9468 | };
|
9469 | }
|
9470 | });
|
9471 | let instance$2;
|
9472 | const DEFAULT_OPTIONS = {
|
9473 | title: "",
|
9474 | width: "",
|
9475 | theme: null,
|
9476 | message: "",
|
9477 | overlay: true,
|
9478 | callback: null,
|
9479 | teleport: "body",
|
9480 | className: "",
|
9481 | allowHtml: false,
|
9482 | lockScroll: true,
|
9483 | transition: void 0,
|
9484 | beforeClose: null,
|
9485 | overlayClass: "",
|
9486 | overlayStyle: void 0,
|
9487 | messageAlign: "",
|
9488 | cancelButtonText: "",
|
9489 | cancelButtonColor: null,
|
9490 | cancelButtonDisabled: false,
|
9491 | confirmButtonText: "",
|
9492 | confirmButtonColor: null,
|
9493 | confirmButtonDisabled: false,
|
9494 | showConfirmButton: true,
|
9495 | showCancelButton: false,
|
9496 | closeOnPopstate: true,
|
9497 | closeOnClickOverlay: false
|
9498 | };
|
9499 | let currentOptions$1 = extend({}, DEFAULT_OPTIONS);
|
9500 | function initInstance$2() {
|
9501 | const Wrapper = {
|
9502 | setup() {
|
9503 | const {
|
9504 | state,
|
9505 | toggle
|
9506 | } = usePopupState();
|
9507 | return () => createVNode(stdin_default$W, mergeProps(state, {
|
9508 | "onUpdate:show": toggle
|
9509 | }), null);
|
9510 | }
|
9511 | };
|
9512 | ({
|
9513 | instance: instance$2
|
9514 | } = mountComponent(Wrapper));
|
9515 | }
|
9516 | function showDialog(options) {
|
9517 | if (!inBrowser) {
|
9518 | return Promise.resolve(void 0);
|
9519 | }
|
9520 | return new Promise((resolve, reject) => {
|
9521 | if (!instance$2) {
|
9522 | initInstance$2();
|
9523 | }
|
9524 | instance$2.open(extend({}, currentOptions$1, options, {
|
9525 | callback: (action) => {
|
9526 | (action === "confirm" ? resolve : reject)(action);
|
9527 | }
|
9528 | }));
|
9529 | });
|
9530 | }
|
9531 | const setDialogDefaultOptions = (options) => {
|
9532 | extend(currentOptions$1, options);
|
9533 | };
|
9534 | const resetDialogDefaultOptions = () => {
|
9535 | currentOptions$1 = extend({}, DEFAULT_OPTIONS);
|
9536 | };
|
9537 | const showConfirmDialog = (options) => showDialog(extend({
|
9538 | showCancelButton: true
|
9539 | }, options));
|
9540 | const closeDialog = () => {
|
9541 | if (instance$2) {
|
9542 | instance$2.toggle(false);
|
9543 | }
|
9544 | };
|
9545 | const Dialog = withInstall(stdin_default$W);
|
9546 | const [name$M, bem$M] = createNamespace("divider");
|
9547 | const dividerProps = {
|
9548 | dashed: Boolean,
|
9549 | hairline: truthProp,
|
9550 | vertical: Boolean,
|
9551 | contentPosition: makeStringProp("center")
|
9552 | };
|
9553 | var stdin_default$V = defineComponent({
|
9554 | name: name$M,
|
9555 | props: dividerProps,
|
9556 | setup(props2, {
|
9557 | slots
|
9558 | }) {
|
9559 | return () => {
|
9560 | var _a;
|
9561 | return createVNode("div", {
|
9562 | "role": "separator",
|
9563 | "class": bem$M({
|
9564 | dashed: props2.dashed,
|
9565 | hairline: props2.hairline,
|
9566 | vertical: props2.vertical,
|
9567 | [`content-${props2.contentPosition}`]: !!slots.default && !props2.vertical
|
9568 | })
|
9569 | }, [!props2.vertical && ((_a = slots.default) == null ? void 0 : _a.call(slots))]);
|
9570 | };
|
9571 | }
|
9572 | });
|
9573 | const Divider = withInstall(stdin_default$V);
|
9574 | const [name$L, bem$L] = createNamespace("dropdown-menu");
|
9575 | const dropdownMenuProps = {
|
9576 | overlay: truthProp,
|
9577 | zIndex: numericProp,
|
9578 | duration: makeNumericProp(0.2),
|
9579 | direction: makeStringProp("down"),
|
9580 | activeColor: String,
|
9581 | autoLocate: Boolean,
|
9582 | closeOnClickOutside: truthProp,
|
9583 | closeOnClickOverlay: truthProp,
|
9584 | swipeThreshold: numericProp
|
9585 | };
|
9586 | const DROPDOWN_KEY = Symbol(name$L);
|
9587 | var stdin_default$U = defineComponent({
|
9588 | name: name$L,
|
9589 | props: dropdownMenuProps,
|
9590 | setup(props2, {
|
9591 | slots
|
9592 | }) {
|
9593 | const id = useId();
|
9594 | const root = ref();
|
9595 | const barRef = ref();
|
9596 | const offset = ref(0);
|
9597 | const {
|
9598 | children,
|
9599 | linkChildren
|
9600 | } = useChildren(DROPDOWN_KEY);
|
9601 | const scrollParent = useScrollParent(root);
|
9602 | const opened = computed(() => children.some((item) => item.state.showWrapper));
|
9603 | const scrollable = computed(() => props2.swipeThreshold && children.length > +props2.swipeThreshold);
|
9604 | const barStyle = computed(() => {
|
9605 | if (opened.value && isDef(props2.zIndex)) {
|
9606 | return {
|
9607 | zIndex: +props2.zIndex + 1
|
9608 | };
|
9609 | }
|
9610 | });
|
9611 | const close = () => {
|
9612 | children.forEach((item) => {
|
9613 | item.toggle(false);
|
9614 | });
|
9615 | };
|
9616 | const onClickAway = () => {
|
9617 | if (props2.closeOnClickOutside) {
|
9618 | close();
|
9619 | }
|
9620 | };
|
9621 | const updateOffset = () => {
|
9622 | if (barRef.value) {
|
9623 | const rect = useRect(barRef);
|
9624 | if (props2.direction === "down") {
|
9625 | offset.value = rect.bottom;
|
9626 | } else {
|
9627 | offset.value = windowHeight.value - rect.top;
|
9628 | }
|
9629 | }
|
9630 | };
|
9631 | const onScroll = () => {
|
9632 | if (opened.value) {
|
9633 | updateOffset();
|
9634 | }
|
9635 | };
|
9636 | const toggleItem = (active) => {
|
9637 | children.forEach((item, index) => {
|
9638 | if (index === active) {
|
9639 | item.toggle();
|
9640 | } else if (item.state.showPopup) {
|
9641 | item.toggle(false, {
|
9642 | immediate: true
|
9643 | });
|
9644 | }
|
9645 | });
|
9646 | };
|
9647 | const renderTitle = (item, index) => {
|
9648 | const {
|
9649 | showPopup
|
9650 | } = item.state;
|
9651 | const {
|
9652 | disabled,
|
9653 | titleClass
|
9654 | } = item;
|
9655 | return createVNode("div", {
|
9656 | "id": `${id}-${index}`,
|
9657 | "role": "button",
|
9658 | "tabindex": disabled ? void 0 : 0,
|
9659 | "class": [bem$L("item", {
|
9660 | disabled,
|
9661 | grow: scrollable.value
|
9662 | }), {
|
9663 | [HAPTICS_FEEDBACK]: !disabled
|
9664 | }],
|
9665 | "onClick": () => {
|
9666 | if (!disabled) {
|
9667 | toggleItem(index);
|
9668 | }
|
9669 | }
|
9670 | }, [createVNode("span", {
|
9671 | "class": [bem$L("title", {
|
9672 | down: showPopup === (props2.direction === "down"),
|
9673 | active: showPopup
|
9674 | }), titleClass],
|
9675 | "style": {
|
9676 | color: showPopup ? props2.activeColor : ""
|
9677 | }
|
9678 | }, [createVNode("div", {
|
9679 | "class": "van-ellipsis"
|
9680 | }, [item.renderTitle()])])]);
|
9681 | };
|
9682 | useExpose({
|
9683 | close
|
9684 | });
|
9685 | linkChildren({
|
9686 | id,
|
9687 | props: props2,
|
9688 | offset,
|
9689 | updateOffset
|
9690 | });
|
9691 | useClickAway(root, onClickAway);
|
9692 | useEventListener("scroll", onScroll, {
|
9693 | target: scrollParent,
|
9694 | passive: true
|
9695 | });
|
9696 | return () => {
|
9697 | var _a;
|
9698 | return createVNode("div", {
|
9699 | "ref": root,
|
9700 | "class": bem$L()
|
9701 | }, [createVNode("div", {
|
9702 | "ref": barRef,
|
9703 | "style": barStyle.value,
|
9704 | "class": bem$L("bar", {
|
9705 | opened: opened.value,
|
9706 | scrollable: scrollable.value
|
9707 | })
|
9708 | }, [children.map(renderTitle)]), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
9709 | };
|
9710 | }
|
9711 | });
|
9712 | const [name$K, bem$K] = createNamespace("dropdown-item");
|
9713 | const dropdownItemProps = {
|
9714 | title: String,
|
9715 | options: makeArrayProp(),
|
9716 | disabled: Boolean,
|
9717 | teleport: [String, Object],
|
9718 | lazyRender: truthProp,
|
9719 | modelValue: unknownProp,
|
9720 | titleClass: unknownProp
|
9721 | };
|
9722 | var stdin_default$T = defineComponent({
|
9723 | name: name$K,
|
9724 | inheritAttrs: false,
|
9725 | props: dropdownItemProps,
|
9726 | emits: ["open", "opened", "close", "closed", "change", "update:modelValue"],
|
9727 | setup(props2, {
|
9728 | emit,
|
9729 | slots,
|
9730 | attrs
|
9731 | }) {
|
9732 | const state = reactive({
|
9733 | showPopup: false,
|
9734 | transition: true,
|
9735 | showWrapper: false
|
9736 | });
|
9737 | const wrapperRef = ref();
|
9738 | const {
|
9739 | parent,
|
9740 | index
|
9741 | } = useParent(DROPDOWN_KEY);
|
9742 | if (!parent) {
|
9743 | if (process.env.NODE_ENV !== "production") {
|
9744 | console.error("[Vant] <DropdownItem> must be a child component of <DropdownMenu>.");
|
9745 | }
|
9746 | return;
|
9747 | }
|
9748 | const getEmitter = (name2) => () => emit(name2);
|
9749 | const onOpen = getEmitter("open");
|
9750 | const onClose = getEmitter("close");
|
9751 | const onOpened = getEmitter("opened");
|
9752 | const onClosed = () => {
|
9753 | state.showWrapper = false;
|
9754 | emit("closed");
|
9755 | };
|
9756 | const onClickWrapper = (event) => {
|
9757 | if (props2.teleport) {
|
9758 | event.stopPropagation();
|
9759 | }
|
9760 | };
|
9761 | const toggle = (show = !state.showPopup, options = {}) => {
|
9762 | if (show === state.showPopup) {
|
9763 | return;
|
9764 | }
|
9765 | state.showPopup = show;
|
9766 | state.transition = !options.immediate;
|
9767 | if (show) {
|
9768 | parent.updateOffset();
|
9769 | state.showWrapper = true;
|
9770 | }
|
9771 | };
|
9772 | const renderTitle = () => {
|
9773 | if (slots.title) {
|
9774 | return slots.title();
|
9775 | }
|
9776 | if (props2.title) {
|
9777 | return props2.title;
|
9778 | }
|
9779 | const match = props2.options.find((option) => option.value === props2.modelValue);
|
9780 | return match ? match.text : "";
|
9781 | };
|
9782 | const renderOption = (option) => {
|
9783 | const {
|
9784 | activeColor
|
9785 | } = parent.props;
|
9786 | const active = option.value === props2.modelValue;
|
9787 | const onClick = () => {
|
9788 | state.showPopup = false;
|
9789 | if (option.value !== props2.modelValue) {
|
9790 | emit("update:modelValue", option.value);
|
9791 | emit("change", option.value);
|
9792 | }
|
9793 | };
|
9794 | const renderIcon = () => {
|
9795 | if (active) {
|
9796 | return createVNode(Icon, {
|
9797 | "class": bem$K("icon"),
|
9798 | "color": activeColor,
|
9799 | "name": "success"
|
9800 | }, null);
|
9801 | }
|
9802 | };
|
9803 | return createVNode(Cell, {
|
9804 | "role": "menuitem",
|
9805 | "key": String(option.value),
|
9806 | "icon": option.icon,
|
9807 | "title": option.text,
|
9808 | "class": bem$K("option", {
|
9809 | active
|
9810 | }),
|
9811 | "style": {
|
9812 | color: active ? activeColor : ""
|
9813 | },
|
9814 | "tabindex": active ? 0 : -1,
|
9815 | "clickable": true,
|
9816 | "onClick": onClick
|
9817 | }, {
|
9818 | value: renderIcon
|
9819 | });
|
9820 | };
|
9821 | const renderContent = () => {
|
9822 | const {
|
9823 | offset
|
9824 | } = parent;
|
9825 | const {
|
9826 | autoLocate,
|
9827 | zIndex,
|
9828 | overlay,
|
9829 | duration,
|
9830 | direction,
|
9831 | closeOnClickOverlay
|
9832 | } = parent.props;
|
9833 | const style = getZIndexStyle(zIndex);
|
9834 | let offsetValue = offset.value;
|
9835 | if (autoLocate && wrapperRef.value) {
|
9836 | const offsetParent = getContainingBlock(wrapperRef.value);
|
9837 | if (offsetParent) {
|
9838 | offsetValue -= useRect(offsetParent).top;
|
9839 | }
|
9840 | }
|
9841 | if (direction === "down") {
|
9842 | style.top = `${offsetValue}px`;
|
9843 | } else {
|
9844 | style.bottom = `${offsetValue}px`;
|
9845 | }
|
9846 | return withDirectives(createVNode("div", mergeProps({
|
9847 | "ref": wrapperRef,
|
9848 | "style": style,
|
9849 | "class": bem$K([direction]),
|
9850 | "onClick": onClickWrapper
|
9851 | }, attrs), [createVNode(Popup, {
|
9852 | "show": state.showPopup,
|
9853 | "onUpdate:show": ($event) => state.showPopup = $event,
|
9854 | "role": "menu",
|
9855 | "class": bem$K("content"),
|
9856 | "overlay": overlay,
|
9857 | "position": direction === "down" ? "top" : "bottom",
|
9858 | "duration": state.transition ? duration : 0,
|
9859 | "lazyRender": props2.lazyRender,
|
9860 | "overlayStyle": {
|
9861 | position: "absolute"
|
9862 | },
|
9863 | "aria-labelledby": `${parent.id}-${index.value}`,
|
9864 | "closeOnClickOverlay": closeOnClickOverlay,
|
9865 | "onOpen": onOpen,
|
9866 | "onClose": onClose,
|
9867 | "onOpened": onOpened,
|
9868 | "onClosed": onClosed
|
9869 | }, {
|
9870 | default: () => {
|
9871 | var _a;
|
9872 | return [props2.options.map(renderOption), (_a = slots.default) == null ? void 0 : _a.call(slots)];
|
9873 | }
|
9874 | })]), [[vShow, state.showWrapper]]);
|
9875 | };
|
9876 | useExpose({
|
9877 | state,
|
9878 | toggle,
|
9879 | renderTitle
|
9880 | });
|
9881 | return () => {
|
9882 | if (props2.teleport) {
|
9883 | return createVNode(Teleport, {
|
9884 | "to": props2.teleport
|
9885 | }, {
|
9886 | default: () => [renderContent()]
|
9887 | });
|
9888 | }
|
9889 | return renderContent();
|
9890 | };
|
9891 | }
|
9892 | });
|
9893 | const DropdownItem = withInstall(stdin_default$T);
|
9894 | const DropdownMenu = withInstall(stdin_default$U);
|
9895 | const floatingBubbleProps = {
|
9896 | gap: makeNumberProp(24),
|
9897 | icon: String,
|
9898 | axis: makeStringProp("y"),
|
9899 | magnetic: String,
|
9900 | offset: {
|
9901 | type: Object,
|
9902 | default: () => ({
|
9903 | x: -1,
|
9904 | y: -1
|
9905 | })
|
9906 | },
|
9907 | teleport: {
|
9908 | type: [String, Object],
|
9909 | default: "body"
|
9910 | }
|
9911 | };
|
9912 | const [name$J, bem$J] = createNamespace("floating-bubble");
|
9913 | var stdin_default$S = defineComponent({
|
9914 | name: name$J,
|
9915 | inheritAttrs: false,
|
9916 | props: floatingBubbleProps,
|
9917 | emits: ["click", "update:offset", "offsetChange"],
|
9918 | setup(props2, {
|
9919 | slots,
|
9920 | emit,
|
9921 | attrs
|
9922 | }) {
|
9923 | const rootRef = ref();
|
9924 | const state = ref({
|
9925 | x: 0,
|
9926 | y: 0,
|
9927 | width: 0,
|
9928 | height: 0
|
9929 | });
|
9930 | const boundary = computed(() => ({
|
9931 | top: props2.gap,
|
9932 | right: windowWidth.value - state.value.width - props2.gap,
|
9933 | bottom: windowHeight.value - state.value.height - props2.gap,
|
9934 | left: props2.gap
|
9935 | }));
|
9936 | const dragging = ref(false);
|
9937 | let initialized = false;
|
9938 | const rootStyle = computed(() => {
|
9939 | const style = {};
|
9940 | const x = addUnit(state.value.x);
|
9941 | const y = addUnit(state.value.y);
|
9942 | style.transform = `translate3d(${x}, ${y}, 0)`;
|
9943 | if (dragging.value || !initialized) {
|
9944 | style.transition = "none";
|
9945 | }
|
9946 | return style;
|
9947 | });
|
9948 | const updateState = () => {
|
9949 | if (!show.value)
|
9950 | return;
|
9951 | const {
|
9952 | width,
|
9953 | height
|
9954 | } = useRect(rootRef.value);
|
9955 | const {
|
9956 | offset
|
9957 | } = props2;
|
9958 | state.value = {
|
9959 | x: offset.x > -1 ? offset.x : windowWidth.value - width - props2.gap,
|
9960 | y: offset.y > -1 ? offset.y : windowHeight.value - height - props2.gap,
|
9961 | width,
|
9962 | height
|
9963 | };
|
9964 | };
|
9965 | const touch = useTouch();
|
9966 | let prevX = 0;
|
9967 | let prevY = 0;
|
9968 | const onTouchStart = (e) => {
|
9969 | touch.start(e);
|
9970 | dragging.value = true;
|
9971 | prevX = state.value.x;
|
9972 | prevY = state.value.y;
|
9973 | };
|
9974 | const onTouchMove = (e) => {
|
9975 | e.preventDefault();
|
9976 | touch.move(e);
|
9977 | if (props2.axis === "lock")
|
9978 | return;
|
9979 | if (!touch.isTap.value) {
|
9980 | if (props2.axis === "x" || props2.axis === "xy") {
|
9981 | let nextX = prevX + touch.deltaX.value;
|
9982 | if (nextX < boundary.value.left)
|
9983 | nextX = boundary.value.left;
|
9984 | if (nextX > boundary.value.right)
|
9985 | nextX = boundary.value.right;
|
9986 | state.value.x = nextX;
|
9987 | }
|
9988 | if (props2.axis === "y" || props2.axis === "xy") {
|
9989 | let nextY = prevY + touch.deltaY.value;
|
9990 | if (nextY < boundary.value.top)
|
9991 | nextY = boundary.value.top;
|
9992 | if (nextY > boundary.value.bottom)
|
9993 | nextY = boundary.value.bottom;
|
9994 | state.value.y = nextY;
|
9995 | }
|
9996 | const offset = pick(state.value, ["x", "y"]);
|
9997 | emit("update:offset", offset);
|
9998 | }
|
9999 | };
|
10000 | useEventListener("touchmove", onTouchMove, {
|
10001 | target: rootRef
|
10002 | });
|
10003 | const onTouchEnd = () => {
|
10004 | dragging.value = false;
|
10005 | nextTick(() => {
|
10006 | if (props2.magnetic === "x") {
|
10007 | const nextX = closest([boundary.value.left, boundary.value.right], state.value.x);
|
10008 | state.value.x = nextX;
|
10009 | }
|
10010 | if (props2.magnetic === "y") {
|
10011 | const nextY = closest([boundary.value.top, boundary.value.bottom], state.value.y);
|
10012 | state.value.y = nextY;
|
10013 | }
|
10014 | if (!touch.isTap.value) {
|
10015 | const offset = pick(state.value, ["x", "y"]);
|
10016 | emit("update:offset", offset);
|
10017 | if (prevX !== offset.x || prevY !== offset.y) {
|
10018 | emit("offsetChange", offset);
|
10019 | }
|
10020 | }
|
10021 | });
|
10022 | };
|
10023 | const onClick = (e) => {
|
10024 | if (touch.isTap.value)
|
10025 | emit("click", e);
|
10026 | else
|
10027 | e.stopPropagation();
|
10028 | };
|
10029 | onMounted(() => {
|
10030 | updateState();
|
10031 | nextTick(() => {
|
10032 | initialized = true;
|
10033 | });
|
10034 | });
|
10035 | watch([windowWidth, windowHeight, () => props2.gap, () => props2.offset], updateState);
|
10036 | const show = ref(true);
|
10037 | onActivated(() => {
|
10038 | show.value = true;
|
10039 | });
|
10040 | onDeactivated(() => {
|
10041 | if (props2.teleport) {
|
10042 | show.value = false;
|
10043 | }
|
10044 | });
|
10045 | return () => {
|
10046 | const Content = withDirectives(createVNode("div", mergeProps({
|
10047 | "class": bem$J(),
|
10048 | "ref": rootRef,
|
10049 | "onTouchstartPassive": onTouchStart,
|
10050 | "onTouchend": onTouchEnd,
|
10051 | "onTouchcancel": onTouchEnd,
|
10052 | "onClickCapture": onClick,
|
10053 | "style": rootStyle.value
|
10054 | }, attrs), [slots.default ? slots.default() : createVNode(stdin_default$1Q, {
|
10055 | "name": props2.icon,
|
10056 | "class": bem$J("icon")
|
10057 | }, null)]), [[vShow, show.value]]);
|
10058 | return props2.teleport ? createVNode(Teleport, {
|
10059 | "to": props2.teleport
|
10060 | }, {
|
10061 | default: () => [Content]
|
10062 | }) : Content;
|
10063 | };
|
10064 | }
|
10065 | });
|
10066 | const FloatingBubble = withInstall(stdin_default$S);
|
10067 | const floatingPanelProps = {
|
10068 | height: makeNumericProp(0),
|
10069 | anchors: makeArrayProp(),
|
10070 | duration: makeNumericProp(0.3),
|
10071 | contentDraggable: truthProp,
|
10072 | lockScroll: Boolean,
|
10073 | safeAreaInsetBottom: truthProp
|
10074 | };
|
10075 | const [name$I, bem$I] = createNamespace("floating-panel");
|
10076 | var stdin_default$R = defineComponent({
|
10077 | name: name$I,
|
10078 | props: floatingPanelProps,
|
10079 | emits: ["heightChange", "update:height"],
|
10080 | setup(props2, {
|
10081 | emit,
|
10082 | slots
|
10083 | }) {
|
10084 | const DAMP = 0.2;
|
10085 | const rootRef = ref();
|
10086 | const contentRef = ref();
|
10087 | const height = useSyncPropRef(() => +props2.height, (value) => emit("update:height", value));
|
10088 | const boundary = computed(() => {
|
10089 | var _a, _b;
|
10090 | return {
|
10091 | min: (_a = props2.anchors[0]) != null ? _a : 100,
|
10092 | max: (_b = props2.anchors[props2.anchors.length - 1]) != null ? _b : Math.round(windowHeight.value * 0.6)
|
10093 | };
|
10094 | });
|
10095 | const anchors = computed(() => props2.anchors.length >= 2 ? props2.anchors : [boundary.value.min, boundary.value.max]);
|
10096 | const dragging = ref(false);
|
10097 | const rootStyle = computed(() => ({
|
10098 | height: addUnit(boundary.value.max),
|
10099 | transform: `translateY(calc(100% + ${addUnit(-height.value)}))`,
|
10100 | transition: !dragging.value ? `transform ${props2.duration}s cubic-bezier(0.18, 0.89, 0.32, 1.28)` : "none"
|
10101 | }));
|
10102 | const ease = (moveY) => {
|
10103 | const absDistance = Math.abs(moveY);
|
10104 | const {
|
10105 | min,
|
10106 | max
|
10107 | } = boundary.value;
|
10108 | if (absDistance > max) {
|
10109 | return -(max + (absDistance - max) * DAMP);
|
10110 | }
|
10111 | if (absDistance < min) {
|
10112 | return -(min - (min - absDistance) * DAMP);
|
10113 | }
|
10114 | return moveY;
|
10115 | };
|
10116 | let startY;
|
10117 | let maxScroll = -1;
|
10118 | const touch = useTouch();
|
10119 | const onTouchstart = (e) => {
|
10120 | touch.start(e);
|
10121 | dragging.value = true;
|
10122 | startY = -height.value;
|
10123 | maxScroll = -1;
|
10124 | };
|
10125 | const onTouchmove = (e) => {
|
10126 | var _a;
|
10127 | touch.move(e);
|
10128 | const target = e.target;
|
10129 | if (contentRef.value === target || ((_a = contentRef.value) == null ? void 0 : _a.contains(target))) {
|
10130 | const {
|
10131 | scrollTop
|
10132 | } = contentRef.value;
|
10133 | maxScroll = Math.max(maxScroll, scrollTop);
|
10134 | if (!props2.contentDraggable)
|
10135 | return;
|
10136 | if (-startY < boundary.value.max) {
|
10137 | preventDefault(e, true);
|
10138 | } else if (!(scrollTop <= 0 && touch.deltaY.value > 0) || maxScroll > 0) {
|
10139 | return;
|
10140 | }
|
10141 | }
|
10142 | const moveY = touch.deltaY.value + startY;
|
10143 | height.value = -ease(moveY);
|
10144 | };
|
10145 | const onTouchend = () => {
|
10146 | maxScroll = -1;
|
10147 | dragging.value = false;
|
10148 | height.value = closest(anchors.value, height.value);
|
10149 | if (height.value !== -startY) {
|
10150 | emit("heightChange", {
|
10151 | height: height.value
|
10152 | });
|
10153 | }
|
10154 | };
|
10155 | watch(boundary, () => {
|
10156 | height.value = closest(anchors.value, height.value);
|
10157 | }, {
|
10158 | immediate: true
|
10159 | });
|
10160 | useLockScroll(rootRef, () => props2.lockScroll || dragging.value);
|
10161 | useEventListener("touchmove", onTouchmove, {
|
10162 | target: rootRef
|
10163 | });
|
10164 | return () => {
|
10165 | var _a;
|
10166 | return createVNode("div", {
|
10167 | "class": [bem$I(), {
|
10168 | "van-safe-area-bottom": props2.safeAreaInsetBottom
|
10169 | }],
|
10170 | "ref": rootRef,
|
10171 | "style": rootStyle.value,
|
10172 | "onTouchstartPassive": onTouchstart,
|
10173 | "onTouchend": onTouchend,
|
10174 | "onTouchcancel": onTouchend
|
10175 | }, [createVNode("div", {
|
10176 | "class": bem$I("header")
|
10177 | }, [createVNode("div", {
|
10178 | "class": bem$I("header-bar")
|
10179 | }, null)]), createVNode("div", {
|
10180 | "class": bem$I("content"),
|
10181 | "ref": contentRef
|
10182 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
|
10183 | };
|
10184 | }
|
10185 | });
|
10186 | const FloatingPanel = withInstall(stdin_default$R);
|
10187 | const [name$H, bem$H] = createNamespace("grid");
|
10188 | const gridProps = {
|
10189 | square: Boolean,
|
10190 | center: truthProp,
|
10191 | border: truthProp,
|
10192 | gutter: numericProp,
|
10193 | reverse: Boolean,
|
10194 | iconSize: numericProp,
|
10195 | direction: String,
|
10196 | clickable: Boolean,
|
10197 | columnNum: makeNumericProp(4)
|
10198 | };
|
10199 | const GRID_KEY = Symbol(name$H);
|
10200 | var stdin_default$Q = defineComponent({
|
10201 | name: name$H,
|
10202 | props: gridProps,
|
10203 | setup(props2, {
|
10204 | slots
|
10205 | }) {
|
10206 | const {
|
10207 | linkChildren
|
10208 | } = useChildren(GRID_KEY);
|
10209 | linkChildren({
|
10210 | props: props2
|
10211 | });
|
10212 | return () => {
|
10213 | var _a;
|
10214 | return createVNode("div", {
|
10215 | "style": {
|
10216 | paddingLeft: addUnit(props2.gutter)
|
10217 | },
|
10218 | "class": [bem$H(), {
|
10219 | [BORDER_TOP]: props2.border && !props2.gutter
|
10220 | }]
|
10221 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
10222 | };
|
10223 | }
|
10224 | });
|
10225 | const Grid = withInstall(stdin_default$Q);
|
10226 | const [name$G, bem$G] = createNamespace("grid-item");
|
10227 | const gridItemProps = extend({}, routeProps, {
|
10228 | dot: Boolean,
|
10229 | text: String,
|
10230 | icon: String,
|
10231 | badge: numericProp,
|
10232 | iconColor: String,
|
10233 | iconPrefix: String,
|
10234 | badgeProps: Object
|
10235 | });
|
10236 | var stdin_default$P = defineComponent({
|
10237 | name: name$G,
|
10238 | props: gridItemProps,
|
10239 | setup(props2, {
|
10240 | slots
|
10241 | }) {
|
10242 | const {
|
10243 | parent,
|
10244 | index
|
10245 | } = useParent(GRID_KEY);
|
10246 | const route2 = useRoute();
|
10247 | if (!parent) {
|
10248 | if (process.env.NODE_ENV !== "production") {
|
10249 | console.error("[Vant] <GridItem> must be a child component of <Grid>.");
|
10250 | }
|
10251 | return;
|
10252 | }
|
10253 | const rootStyle = computed(() => {
|
10254 | const {
|
10255 | square,
|
10256 | gutter,
|
10257 | columnNum
|
10258 | } = parent.props;
|
10259 | const percent = `${100 / +columnNum}%`;
|
10260 | const style = {
|
10261 | flexBasis: percent
|
10262 | };
|
10263 | if (square) {
|
10264 | style.paddingTop = percent;
|
10265 | } else if (gutter) {
|
10266 | const gutterValue = addUnit(gutter);
|
10267 | style.paddingRight = gutterValue;
|
10268 | if (index.value >= +columnNum) {
|
10269 | style.marginTop = gutterValue;
|
10270 | }
|
10271 | }
|
10272 | return style;
|
10273 | });
|
10274 | const contentStyle = computed(() => {
|
10275 | const {
|
10276 | square,
|
10277 | gutter
|
10278 | } = parent.props;
|
10279 | if (square && gutter) {
|
10280 | const gutterValue = addUnit(gutter);
|
10281 | return {
|
10282 | right: gutterValue,
|
10283 | bottom: gutterValue,
|
10284 | height: "auto"
|
10285 | };
|
10286 | }
|
10287 | });
|
10288 | const renderIcon = () => {
|
10289 | if (slots.icon) {
|
10290 | return createVNode(Badge, mergeProps({
|
10291 | "dot": props2.dot,
|
10292 | "content": props2.badge
|
10293 | }, props2.badgeProps), {
|
10294 | default: slots.icon
|
10295 | });
|
10296 | }
|
10297 | if (props2.icon) {
|
10298 | return createVNode(Icon, {
|
10299 | "dot": props2.dot,
|
10300 | "name": props2.icon,
|
10301 | "size": parent.props.iconSize,
|
10302 | "badge": props2.badge,
|
10303 | "class": bem$G("icon"),
|
10304 | "color": props2.iconColor,
|
10305 | "badgeProps": props2.badgeProps,
|
10306 | "classPrefix": props2.iconPrefix
|
10307 | }, null);
|
10308 | }
|
10309 | };
|
10310 | const renderText = () => {
|
10311 | if (slots.text) {
|
10312 | return slots.text();
|
10313 | }
|
10314 | if (props2.text) {
|
10315 | return createVNode("span", {
|
10316 | "class": bem$G("text")
|
10317 | }, [props2.text]);
|
10318 | }
|
10319 | };
|
10320 | const renderContent = () => {
|
10321 | if (slots.default) {
|
10322 | return slots.default();
|
10323 | }
|
10324 | return [renderIcon(), renderText()];
|
10325 | };
|
10326 | return () => {
|
10327 | const {
|
10328 | center,
|
10329 | border,
|
10330 | square,
|
10331 | gutter,
|
10332 | reverse,
|
10333 | direction,
|
10334 | clickable
|
10335 | } = parent.props;
|
10336 | const classes = [bem$G("content", [direction, {
|
10337 | center,
|
10338 | square,
|
10339 | reverse,
|
10340 | clickable,
|
10341 | surround: border && gutter
|
10342 | }]), {
|
10343 | [BORDER]: border
|
10344 | }];
|
10345 | return createVNode("div", {
|
10346 | "class": [bem$G({
|
10347 | square
|
10348 | })],
|
10349 | "style": rootStyle.value
|
10350 | }, [createVNode("div", {
|
10351 | "role": clickable ? "button" : void 0,
|
10352 | "class": classes,
|
10353 | "style": contentStyle.value,
|
10354 | "tabindex": clickable ? 0 : void 0,
|
10355 | "onClick": route2
|
10356 | }, [renderContent()])]);
|
10357 | };
|
10358 | }
|
10359 | });
|
10360 | const GridItem = withInstall(stdin_default$P);
|
10361 | const [name$F, bem$F] = createNamespace("highlight");
|
10362 | const highlightProps = {
|
10363 | autoEscape: truthProp,
|
10364 | caseSensitive: Boolean,
|
10365 | highlightClass: String,
|
10366 | highlightTag: makeStringProp("span"),
|
10367 | keywords: makeRequiredProp([String, Array]),
|
10368 | sourceString: makeStringProp(""),
|
10369 | tag: makeStringProp("div"),
|
10370 | unhighlightClass: String,
|
10371 | unhighlightTag: makeStringProp("span")
|
10372 | };
|
10373 | var stdin_default$O = defineComponent({
|
10374 | name: name$F,
|
10375 | props: highlightProps,
|
10376 | setup(props2) {
|
10377 | const highlightChunks = computed(() => {
|
10378 | const {
|
10379 | autoEscape,
|
10380 | caseSensitive,
|
10381 | keywords,
|
10382 | sourceString
|
10383 | } = props2;
|
10384 | const flags = caseSensitive ? "g" : "gi";
|
10385 | const _keywords = Array.isArray(keywords) ? keywords : [keywords];
|
10386 | let chunks = _keywords.filter((keyword) => keyword).reduce((chunks2, keyword) => {
|
10387 | if (autoEscape) {
|
10388 | keyword = keyword.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
10389 | }
|
10390 | const regex = new RegExp(keyword, flags);
|
10391 | let match;
|
10392 | while (match = regex.exec(sourceString)) {
|
10393 | const start = match.index;
|
10394 | const end = regex.lastIndex;
|
10395 | if (start >= end) {
|
10396 | regex.lastIndex++;
|
10397 | continue;
|
10398 | }
|
10399 | chunks2.push({
|
10400 | start,
|
10401 | end,
|
10402 | highlight: true
|
10403 | });
|
10404 | }
|
10405 | return chunks2;
|
10406 | }, []);
|
10407 | chunks = chunks.sort((a, b) => a.start - b.start).reduce((chunks2, currentChunk) => {
|
10408 | const prevChunk = chunks2[chunks2.length - 1];
|
10409 | if (!prevChunk || currentChunk.start > prevChunk.end) {
|
10410 | const unhighlightStart = prevChunk ? prevChunk.end : 0;
|
10411 | const unhighlightEnd = currentChunk.start;
|
10412 | if (unhighlightStart !== unhighlightEnd) {
|
10413 | chunks2.push({
|
10414 | start: unhighlightStart,
|
10415 | end: unhighlightEnd,
|
10416 | highlight: false
|
10417 | });
|
10418 | }
|
10419 | chunks2.push(currentChunk);
|
10420 | } else {
|
10421 | prevChunk.end = Math.max(prevChunk.end, currentChunk.end);
|
10422 | }
|
10423 | return chunks2;
|
10424 | }, []);
|
10425 | const lastChunk = chunks[chunks.length - 1];
|
10426 | if (lastChunk && lastChunk.end < sourceString.length) {
|
10427 | chunks.push({
|
10428 | start: lastChunk.end,
|
10429 | end: sourceString.length,
|
10430 | highlight: false
|
10431 | });
|
10432 | }
|
10433 | return chunks;
|
10434 | });
|
10435 | const renderContent = () => {
|
10436 | const {
|
10437 | sourceString,
|
10438 | highlightClass,
|
10439 | unhighlightClass,
|
10440 | highlightTag,
|
10441 | unhighlightTag
|
10442 | } = props2;
|
10443 | return highlightChunks.value.map((chunk) => {
|
10444 | const {
|
10445 | start,
|
10446 | end,
|
10447 | highlight
|
10448 | } = chunk;
|
10449 | const text = sourceString.slice(start, end);
|
10450 | if (highlight) {
|
10451 | return createVNode(highlightTag, {
|
10452 | "class": [bem$F("tag"), highlightClass]
|
10453 | }, {
|
10454 | default: () => [text]
|
10455 | });
|
10456 | }
|
10457 | return createVNode(unhighlightTag, {
|
10458 | "class": unhighlightClass
|
10459 | }, {
|
10460 | default: () => [text]
|
10461 | });
|
10462 | });
|
10463 | };
|
10464 | return () => {
|
10465 | const {
|
10466 | tag
|
10467 | } = props2;
|
10468 | return createVNode(tag, {
|
10469 | "class": bem$F()
|
10470 | }, {
|
10471 | default: () => [renderContent()]
|
10472 | });
|
10473 | };
|
10474 | }
|
10475 | });
|
10476 | const Highlight = withInstall(stdin_default$O);
|
10477 | const getDistance = (touches) => Math.sqrt((touches[0].clientX - touches[1].clientX) ** 2 + (touches[0].clientY - touches[1].clientY) ** 2);
|
10478 | const getCenter = (touches) => ({
|
10479 | x: (touches[0].clientX + touches[1].clientX) / 2,
|
10480 | y: (touches[0].clientY + touches[1].clientY) / 2
|
10481 | });
|
10482 | const bem$E = createNamespace("image-preview")[1];
|
10483 | const longImageRatio = 2.6;
|
10484 | const imagePreviewItemProps = {
|
10485 | src: String,
|
10486 | show: Boolean,
|
10487 | active: Number,
|
10488 | minZoom: makeRequiredProp(numericProp),
|
10489 | maxZoom: makeRequiredProp(numericProp),
|
10490 | rootWidth: makeRequiredProp(Number),
|
10491 | rootHeight: makeRequiredProp(Number),
|
10492 | disableZoom: Boolean,
|
10493 | doubleScale: Boolean,
|
10494 | closeOnClickImage: Boolean,
|
10495 | closeOnClickOverlay: Boolean,
|
10496 | vertical: Boolean
|
10497 | };
|
10498 | var stdin_default$N = defineComponent({
|
10499 | props: imagePreviewItemProps,
|
10500 | emits: ["scale", "close", "longPress"],
|
10501 | setup(props2, {
|
10502 | emit,
|
10503 | slots
|
10504 | }) {
|
10505 | const state = reactive({
|
10506 | scale: 1,
|
10507 | moveX: 0,
|
10508 | moveY: 0,
|
10509 | moving: false,
|
10510 | zooming: false,
|
10511 | initializing: false,
|
10512 | imageRatio: 0
|
10513 | });
|
10514 | const touch = useTouch();
|
10515 | const imageRef = ref();
|
10516 | const swipeItem = ref();
|
10517 | const vertical = ref(false);
|
10518 | const isLongImage = ref(false);
|
10519 | let initialMoveY = 0;
|
10520 | const imageStyle = computed(() => {
|
10521 | const {
|
10522 | scale,
|
10523 | moveX,
|
10524 | moveY,
|
10525 | moving,
|
10526 | zooming,
|
10527 | initializing
|
10528 | } = state;
|
10529 | const style = {
|
10530 | transitionDuration: zooming || moving || initializing ? "0s" : ".3s"
|
10531 | };
|
10532 | if (scale !== 1 || isLongImage.value) {
|
10533 | style.transform = `matrix(${scale}, 0, 0, ${scale}, ${moveX}, ${moveY})`;
|
10534 | }
|
10535 | return style;
|
10536 | });
|
10537 | const maxMoveX = computed(() => {
|
10538 | if (state.imageRatio) {
|
10539 | const {
|
10540 | rootWidth,
|
10541 | rootHeight
|
10542 | } = props2;
|
10543 | const displayWidth = vertical.value ? rootHeight / state.imageRatio : rootWidth;
|
10544 | return Math.max(0, (state.scale * displayWidth - rootWidth) / 2);
|
10545 | }
|
10546 | return 0;
|
10547 | });
|
10548 | const maxMoveY = computed(() => {
|
10549 | if (state.imageRatio) {
|
10550 | const {
|
10551 | rootWidth,
|
10552 | rootHeight
|
10553 | } = props2;
|
10554 | const displayHeight = vertical.value ? rootHeight : rootWidth * state.imageRatio;
|
10555 | return Math.max(0, (state.scale * displayHeight - rootHeight) / 2);
|
10556 | }
|
10557 | return 0;
|
10558 | });
|
10559 | const setScale = (scale, center) => {
|
10560 | var _a;
|
10561 | scale = clamp(scale, +props2.minZoom, +props2.maxZoom + 1);
|
10562 | if (scale !== state.scale) {
|
10563 | const ratio = scale / state.scale;
|
10564 | state.scale = scale;
|
10565 | if (center) {
|
10566 | const imageRect = useRect((_a = imageRef.value) == null ? void 0 : _a.$el);
|
10567 | const origin = {
|
10568 | x: imageRect.width * 0.5,
|
10569 | y: imageRect.height * 0.5
|
10570 | };
|
10571 | const moveX = state.moveX - (center.x - imageRect.left - origin.x) * (ratio - 1);
|
10572 | const moveY = state.moveY - (center.y - imageRect.top - origin.y) * (ratio - 1);
|
10573 | state.moveX = clamp(moveX, -maxMoveX.value, maxMoveX.value);
|
10574 | state.moveY = clamp(moveY, -maxMoveY.value, maxMoveY.value);
|
10575 | } else {
|
10576 | state.moveX = 0;
|
10577 | state.moveY = isLongImage.value ? initialMoveY : 0;
|
10578 | }
|
10579 | emit("scale", {
|
10580 | scale,
|
10581 | index: props2.active
|
10582 | });
|
10583 | }
|
10584 | };
|
10585 | const resetScale = () => {
|
10586 | setScale(1);
|
10587 | };
|
10588 | const toggleScale = () => {
|
10589 | const scale = state.scale > 1 ? 1 : 2;
|
10590 | setScale(scale, scale === 2 || isLongImage.value ? {
|
10591 | x: touch.startX.value,
|
10592 | y: touch.startY.value
|
10593 | } : void 0);
|
10594 | };
|
10595 | let fingerNum;
|
10596 | let startMoveX;
|
10597 | let startMoveY;
|
10598 | let startScale;
|
10599 | let startDistance;
|
10600 | let lastCenter;
|
10601 | let doubleTapTimer;
|
10602 | let touchStartTime;
|
10603 | let isImageMoved = false;
|
10604 | const onTouchStart = (event) => {
|
10605 | const {
|
10606 | touches
|
10607 | } = event;
|
10608 | fingerNum = touches.length;
|
10609 | if (fingerNum === 2 && props2.disableZoom) {
|
10610 | return;
|
10611 | }
|
10612 | const {
|
10613 | offsetX
|
10614 | } = touch;
|
10615 | touch.start(event);
|
10616 | startMoveX = state.moveX;
|
10617 | startMoveY = state.moveY;
|
10618 | touchStartTime = Date.now();
|
10619 | isImageMoved = false;
|
10620 | state.moving = fingerNum === 1 && (state.scale !== 1 || isLongImage.value);
|
10621 | state.zooming = fingerNum === 2 && !offsetX.value;
|
10622 | if (state.zooming) {
|
10623 | startScale = state.scale;
|
10624 | startDistance = getDistance(touches);
|
10625 | }
|
10626 | };
|
10627 | const onTouchMove = (event) => {
|
10628 | const {
|
10629 | touches
|
10630 | } = event;
|
10631 | touch.move(event);
|
10632 | if (state.moving) {
|
10633 | const {
|
10634 | deltaX,
|
10635 | deltaY
|
10636 | } = touch;
|
10637 | const moveX = deltaX.value + startMoveX;
|
10638 | const moveY = deltaY.value + startMoveY;
|
10639 | if ((props2.vertical ? touch.isVertical() && Math.abs(moveY) > maxMoveY.value : touch.isHorizontal() && Math.abs(moveX) > maxMoveX.value) && !isImageMoved) {
|
10640 | state.moving = false;
|
10641 | return;
|
10642 | }
|
10643 | isImageMoved = true;
|
10644 | preventDefault(event, true);
|
10645 | state.moveX = clamp(moveX, -maxMoveX.value, maxMoveX.value);
|
10646 | state.moveY = clamp(moveY, -maxMoveY.value, maxMoveY.value);
|
10647 | }
|
10648 | if (state.zooming) {
|
10649 | preventDefault(event, true);
|
10650 | if (touches.length === 2) {
|
10651 | const distance = getDistance(touches);
|
10652 | const scale = startScale * distance / startDistance;
|
10653 | lastCenter = getCenter(touches);
|
10654 | setScale(scale, lastCenter);
|
10655 | }
|
10656 | }
|
10657 | };
|
10658 | const checkClose = (event) => {
|
10659 | var _a;
|
10660 | const swipeItemEl = (_a = swipeItem.value) == null ? void 0 : _a.$el;
|
10661 | const imageEl = swipeItemEl.firstElementChild;
|
10662 | const isClickOverlay = event.target === swipeItemEl;
|
10663 | const isClickImage = imageEl == null ? void 0 : imageEl.contains(event.target);
|
10664 | if (!props2.closeOnClickImage && isClickImage)
|
10665 | return;
|
10666 | if (!props2.closeOnClickOverlay && isClickOverlay)
|
10667 | return;
|
10668 | emit("close");
|
10669 | };
|
10670 | const checkTap = (event) => {
|
10671 | if (fingerNum > 1) {
|
10672 | return;
|
10673 | }
|
10674 | const deltaTime = Date.now() - touchStartTime;
|
10675 | const TAP_TIME = 250;
|
10676 | if (touch.isTap.value) {
|
10677 | if (deltaTime < TAP_TIME) {
|
10678 | if (props2.doubleScale) {
|
10679 | if (doubleTapTimer) {
|
10680 | clearTimeout(doubleTapTimer);
|
10681 | doubleTapTimer = null;
|
10682 | toggleScale();
|
10683 | } else {
|
10684 | doubleTapTimer = setTimeout(() => {
|
10685 | checkClose(event);
|
10686 | doubleTapTimer = null;
|
10687 | }, TAP_TIME);
|
10688 | }
|
10689 | } else {
|
10690 | checkClose(event);
|
10691 | }
|
10692 | } else if (deltaTime > LONG_PRESS_START_TIME) {
|
10693 | emit("longPress");
|
10694 | }
|
10695 | }
|
10696 | };
|
10697 | const onTouchEnd = (event) => {
|
10698 | let stopPropagation2 = false;
|
10699 | if (state.moving || state.zooming) {
|
10700 | stopPropagation2 = true;
|
10701 | if (state.moving && startMoveX === state.moveX && startMoveY === state.moveY) {
|
10702 | stopPropagation2 = false;
|
10703 | }
|
10704 | if (!event.touches.length) {
|
10705 | if (state.zooming) {
|
10706 | state.moveX = clamp(state.moveX, -maxMoveX.value, maxMoveX.value);
|
10707 | state.moveY = clamp(state.moveY, -maxMoveY.value, maxMoveY.value);
|
10708 | state.zooming = false;
|
10709 | }
|
10710 | state.moving = false;
|
10711 | startMoveX = 0;
|
10712 | startMoveY = 0;
|
10713 | startScale = 1;
|
10714 | if (state.scale < 1) {
|
10715 | resetScale();
|
10716 | }
|
10717 | const maxZoom = +props2.maxZoom;
|
10718 | if (state.scale > maxZoom) {
|
10719 | setScale(maxZoom, lastCenter);
|
10720 | }
|
10721 | }
|
10722 | }
|
10723 | preventDefault(event, stopPropagation2);
|
10724 | checkTap(event);
|
10725 | touch.reset();
|
10726 | };
|
10727 | const resize = () => {
|
10728 | const {
|
10729 | rootWidth,
|
10730 | rootHeight
|
10731 | } = props2;
|
10732 | const rootRatio = rootHeight / rootWidth;
|
10733 | const {
|
10734 | imageRatio
|
10735 | } = state;
|
10736 | vertical.value = state.imageRatio > rootRatio && imageRatio < longImageRatio;
|
10737 | isLongImage.value = state.imageRatio > rootRatio && imageRatio >= longImageRatio;
|
10738 | if (isLongImage.value) {
|
10739 | initialMoveY = (imageRatio * rootWidth - rootHeight) / 2;
|
10740 | state.moveY = initialMoveY;
|
10741 | state.initializing = true;
|
10742 | raf(() => {
|
10743 | state.initializing = false;
|
10744 | });
|
10745 | }
|
10746 | resetScale();
|
10747 | };
|
10748 | const onLoad = (event) => {
|
10749 | const {
|
10750 | naturalWidth,
|
10751 | naturalHeight
|
10752 | } = event.target;
|
10753 | state.imageRatio = naturalHeight / naturalWidth;
|
10754 | resize();
|
10755 | };
|
10756 | watch(() => props2.active, resetScale);
|
10757 | watch(() => props2.show, (value) => {
|
10758 | if (!value) {
|
10759 | resetScale();
|
10760 | }
|
10761 | });
|
10762 | watch(() => [props2.rootWidth, props2.rootHeight], resize);
|
10763 | useEventListener("touchmove", onTouchMove, {
|
10764 | target: computed(() => {
|
10765 | var _a;
|
10766 | return (_a = swipeItem.value) == null ? void 0 : _a.$el;
|
10767 | })
|
10768 | });
|
10769 | useExpose({
|
10770 | resetScale
|
10771 | });
|
10772 | return () => {
|
10773 | const imageSlots = {
|
10774 | loading: () => createVNode(Loading, {
|
10775 | "type": "spinner"
|
10776 | }, null)
|
10777 | };
|
10778 | return createVNode(SwipeItem, {
|
10779 | "ref": swipeItem,
|
10780 | "class": bem$E("swipe-item"),
|
10781 | "onTouchstartPassive": onTouchStart,
|
10782 | "onTouchend": onTouchEnd,
|
10783 | "onTouchcancel": onTouchEnd
|
10784 | }, {
|
10785 | default: () => [slots.image ? createVNode("div", {
|
10786 | "class": bem$E("image-wrap")
|
10787 | }, [slots.image({
|
10788 | src: props2.src
|
10789 | })]) : createVNode(Image$1, {
|
10790 | "ref": imageRef,
|
10791 | "src": props2.src,
|
10792 | "fit": "contain",
|
10793 | "class": bem$E("image", {
|
10794 | vertical: vertical.value
|
10795 | }),
|
10796 | "style": imageStyle.value,
|
10797 | "onLoad": onLoad
|
10798 | }, imageSlots)]
|
10799 | });
|
10800 | };
|
10801 | }
|
10802 | });
|
10803 | const [name$E, bem$D] = createNamespace("image-preview");
|
10804 | const popupProps$1 = ["show", "teleport", "transition", "overlayStyle", "closeOnPopstate"];
|
10805 | const imagePreviewProps = {
|
10806 | show: Boolean,
|
10807 | loop: truthProp,
|
10808 | images: makeArrayProp(),
|
10809 | minZoom: makeNumericProp(1 / 3),
|
10810 | maxZoom: makeNumericProp(3),
|
10811 | overlay: truthProp,
|
10812 | vertical: Boolean,
|
10813 | closeable: Boolean,
|
10814 | showIndex: truthProp,
|
10815 | className: unknownProp,
|
10816 | closeIcon: makeStringProp("clear"),
|
10817 | transition: String,
|
10818 | beforeClose: Function,
|
10819 | doubleScale: truthProp,
|
10820 | overlayClass: unknownProp,
|
10821 | overlayStyle: Object,
|
10822 | swipeDuration: makeNumericProp(300),
|
10823 | startPosition: makeNumericProp(0),
|
10824 | showIndicators: Boolean,
|
10825 | closeOnPopstate: truthProp,
|
10826 | closeOnClickImage: truthProp,
|
10827 | closeOnClickOverlay: truthProp,
|
10828 | closeIconPosition: makeStringProp("top-right"),
|
10829 | teleport: [String, Object]
|
10830 | };
|
10831 | var stdin_default$M = defineComponent({
|
10832 | name: name$E,
|
10833 | props: imagePreviewProps,
|
10834 | emits: ["scale", "close", "closed", "change", "longPress", "update:show"],
|
10835 | setup(props2, {
|
10836 | emit,
|
10837 | slots
|
10838 | }) {
|
10839 | const swipeRef = ref();
|
10840 | const activedPreviewItemRef = ref();
|
10841 | const state = reactive({
|
10842 | active: 0,
|
10843 | rootWidth: 0,
|
10844 | rootHeight: 0,
|
10845 | disableZoom: false
|
10846 | });
|
10847 | const resize = () => {
|
10848 | if (swipeRef.value) {
|
10849 | const rect = useRect(swipeRef.value.$el);
|
10850 | state.rootWidth = rect.width;
|
10851 | state.rootHeight = rect.height;
|
10852 | swipeRef.value.resize();
|
10853 | }
|
10854 | };
|
10855 | const emitScale = (args) => emit("scale", args);
|
10856 | const updateShow = (show) => emit("update:show", show);
|
10857 | const emitClose = () => {
|
10858 | callInterceptor(props2.beforeClose, {
|
10859 | args: [state.active],
|
10860 | done: () => updateShow(false)
|
10861 | });
|
10862 | };
|
10863 | const setActive = (active) => {
|
10864 | if (active !== state.active) {
|
10865 | state.active = active;
|
10866 | emit("change", active);
|
10867 | }
|
10868 | };
|
10869 | const renderIndex = () => {
|
10870 | if (props2.showIndex) {
|
10871 | return createVNode("div", {
|
10872 | "class": bem$D("index")
|
10873 | }, [slots.index ? slots.index({
|
10874 | index: state.active
|
10875 | }) : `${state.active + 1} / ${props2.images.length}`]);
|
10876 | }
|
10877 | };
|
10878 | const renderCover = () => {
|
10879 | if (slots.cover) {
|
10880 | return createVNode("div", {
|
10881 | "class": bem$D("cover")
|
10882 | }, [slots.cover()]);
|
10883 | }
|
10884 | };
|
10885 | const onDragStart = () => {
|
10886 | state.disableZoom = true;
|
10887 | };
|
10888 | const onDragEnd = () => {
|
10889 | state.disableZoom = false;
|
10890 | };
|
10891 | const renderImages = () => createVNode(Swipe, {
|
10892 | "ref": swipeRef,
|
10893 | "lazyRender": true,
|
10894 | "loop": props2.loop,
|
10895 | "class": bem$D("swipe"),
|
10896 | "vertical": props2.vertical,
|
10897 | "duration": props2.swipeDuration,
|
10898 | "initialSwipe": props2.startPosition,
|
10899 | "showIndicators": props2.showIndicators,
|
10900 | "indicatorColor": "white",
|
10901 | "onChange": setActive,
|
10902 | "onDragEnd": onDragEnd,
|
10903 | "onDragStart": onDragStart
|
10904 | }, {
|
10905 | default: () => [props2.images.map((image, index) => createVNode(stdin_default$N, {
|
10906 | "ref": (item) => {
|
10907 | if (index === state.active) {
|
10908 | activedPreviewItemRef.value = item;
|
10909 | }
|
10910 | },
|
10911 | "src": image,
|
10912 | "show": props2.show,
|
10913 | "active": state.active,
|
10914 | "maxZoom": props2.maxZoom,
|
10915 | "minZoom": props2.minZoom,
|
10916 | "rootWidth": state.rootWidth,
|
10917 | "rootHeight": state.rootHeight,
|
10918 | "disableZoom": state.disableZoom,
|
10919 | "doubleScale": props2.doubleScale,
|
10920 | "closeOnClickImage": props2.closeOnClickImage,
|
10921 | "closeOnClickOverlay": props2.closeOnClickOverlay,
|
10922 | "vertical": props2.vertical,
|
10923 | "onScale": emitScale,
|
10924 | "onClose": emitClose,
|
10925 | "onLongPress": () => emit("longPress", {
|
10926 | index
|
10927 | })
|
10928 | }, {
|
10929 | image: slots.image
|
10930 | }))]
|
10931 | });
|
10932 | const renderClose = () => {
|
10933 | if (props2.closeable) {
|
10934 | return createVNode(Icon, {
|
10935 | "role": "button",
|
10936 | "name": props2.closeIcon,
|
10937 | "class": [bem$D("close-icon", props2.closeIconPosition), HAPTICS_FEEDBACK],
|
10938 | "onClick": emitClose
|
10939 | }, null);
|
10940 | }
|
10941 | };
|
10942 | const onClosed = () => emit("closed");
|
10943 | const swipeTo = (index, options) => {
|
10944 | var _a;
|
10945 | return (_a = swipeRef.value) == null ? void 0 : _a.swipeTo(index, options);
|
10946 | };
|
10947 | useExpose({
|
10948 | resetScale: () => {
|
10949 | var _a;
|
10950 | (_a = activedPreviewItemRef.value) == null ? void 0 : _a.resetScale();
|
10951 | },
|
10952 | swipeTo
|
10953 | });
|
10954 | onMounted(resize);
|
10955 | watch([windowWidth, windowHeight], resize);
|
10956 | watch(() => props2.startPosition, (value) => setActive(+value));
|
10957 | watch(() => props2.show, (value) => {
|
10958 | const {
|
10959 | images,
|
10960 | startPosition
|
10961 | } = props2;
|
10962 | if (value) {
|
10963 | setActive(+startPosition);
|
10964 | nextTick(() => {
|
10965 | resize();
|
10966 | swipeTo(+startPosition, {
|
10967 | immediate: true
|
10968 | });
|
10969 | });
|
10970 | } else {
|
10971 | emit("close", {
|
10972 | index: state.active,
|
10973 | url: images[state.active]
|
10974 | });
|
10975 | }
|
10976 | });
|
10977 | return () => createVNode(Popup, mergeProps({
|
10978 | "class": [bem$D(), props2.className],
|
10979 | "overlayClass": [bem$D("overlay"), props2.overlayClass],
|
10980 | "onClosed": onClosed,
|
10981 | "onUpdate:show": updateShow
|
10982 | }, pick(props2, popupProps$1)), {
|
10983 | default: () => [renderClose(), renderImages(), renderIndex(), renderCover()]
|
10984 | });
|
10985 | }
|
10986 | });
|
10987 | let instance$1;
|
10988 | const defaultConfig = {
|
10989 | loop: true,
|
10990 | images: [],
|
10991 | maxZoom: 3,
|
10992 | minZoom: 1 / 3,
|
10993 | onScale: void 0,
|
10994 | onClose: void 0,
|
10995 | onChange: void 0,
|
10996 | vertical: false,
|
10997 | teleport: "body",
|
10998 | className: "",
|
10999 | showIndex: true,
|
11000 | closeable: false,
|
11001 | closeIcon: "clear",
|
11002 | transition: void 0,
|
11003 | beforeClose: void 0,
|
11004 | doubleScale: true,
|
11005 | overlayStyle: void 0,
|
11006 | overlayClass: void 0,
|
11007 | startPosition: 0,
|
11008 | swipeDuration: 300,
|
11009 | showIndicators: false,
|
11010 | closeOnPopstate: true,
|
11011 | closeOnClickOverlay: true,
|
11012 | closeIconPosition: "top-right"
|
11013 | };
|
11014 | function initInstance$1() {
|
11015 | ({
|
11016 | instance: instance$1
|
11017 | } = mountComponent({
|
11018 | setup() {
|
11019 | const {
|
11020 | state,
|
11021 | toggle
|
11022 | } = usePopupState();
|
11023 | const onClosed = () => {
|
11024 | state.images = [];
|
11025 | };
|
11026 | return () => createVNode(stdin_default$M, mergeProps(state, {
|
11027 | "onClosed": onClosed,
|
11028 | "onUpdate:show": toggle
|
11029 | }), null);
|
11030 | }
|
11031 | }));
|
11032 | }
|
11033 | const showImagePreview = (options, startPosition = 0) => {
|
11034 | if (!inBrowser) {
|
11035 | return;
|
11036 | }
|
11037 | if (!instance$1) {
|
11038 | initInstance$1();
|
11039 | }
|
11040 | options = Array.isArray(options) ? {
|
11041 | images: options,
|
11042 | startPosition
|
11043 | } : options;
|
11044 | instance$1.open(extend({}, defaultConfig, options));
|
11045 | return instance$1;
|
11046 | };
|
11047 | const ImagePreview = withInstall(stdin_default$M);
|
11048 | function genAlphabet() {
|
11049 | const charCodeOfA = "A".charCodeAt(0);
|
11050 | const indexList = Array(26).fill("").map((_, i) => String.fromCharCode(charCodeOfA + i));
|
11051 | return indexList;
|
11052 | }
|
11053 | const [name$D, bem$C] = createNamespace("index-bar");
|
11054 | const indexBarProps = {
|
11055 | sticky: truthProp,
|
11056 | zIndex: numericProp,
|
11057 | teleport: [String, Object],
|
11058 | highlightColor: String,
|
11059 | stickyOffsetTop: makeNumberProp(0),
|
11060 | indexList: {
|
11061 | type: Array,
|
11062 | default: genAlphabet
|
11063 | }
|
11064 | };
|
11065 | const INDEX_BAR_KEY = Symbol(name$D);
|
11066 | var stdin_default$L = defineComponent({
|
11067 | name: name$D,
|
11068 | props: indexBarProps,
|
11069 | emits: ["select", "change"],
|
11070 | setup(props2, {
|
11071 | emit,
|
11072 | slots
|
11073 | }) {
|
11074 | const root = ref();
|
11075 | const sidebar = ref();
|
11076 | const activeAnchor = ref("");
|
11077 | const touch = useTouch();
|
11078 | const scrollParent = useScrollParent(root);
|
11079 | const {
|
11080 | children,
|
11081 | linkChildren
|
11082 | } = useChildren(INDEX_BAR_KEY);
|
11083 | let selectActiveIndex;
|
11084 | linkChildren({
|
11085 | props: props2
|
11086 | });
|
11087 | const sidebarStyle = computed(() => {
|
11088 | if (isDef(props2.zIndex)) {
|
11089 | return {
|
11090 | zIndex: +props2.zIndex + 1
|
11091 | };
|
11092 | }
|
11093 | });
|
11094 | const highlightStyle = computed(() => {
|
11095 | if (props2.highlightColor) {
|
11096 | return {
|
11097 | color: props2.highlightColor
|
11098 | };
|
11099 | }
|
11100 | });
|
11101 | const getActiveAnchor = (scrollTop, rects) => {
|
11102 | for (let i = children.length - 1; i >= 0; i--) {
|
11103 | const prevHeight = i > 0 ? rects[i - 1].height : 0;
|
11104 | const reachTop = props2.sticky ? prevHeight + props2.stickyOffsetTop : 0;
|
11105 | if (scrollTop + reachTop >= rects[i].top) {
|
11106 | return i;
|
11107 | }
|
11108 | }
|
11109 | return -1;
|
11110 | };
|
11111 | const getMatchAnchor = (index) => children.find((item) => String(item.index) === index);
|
11112 | const onScroll = () => {
|
11113 | if (isHidden(root)) {
|
11114 | return;
|
11115 | }
|
11116 | const {
|
11117 | sticky,
|
11118 | indexList
|
11119 | } = props2;
|
11120 | const scrollTop = getScrollTop(scrollParent.value);
|
11121 | const scrollParentRect = useRect(scrollParent);
|
11122 | const rects = children.map((item) => item.getRect(scrollParent.value, scrollParentRect));
|
11123 | let active = -1;
|
11124 | if (selectActiveIndex) {
|
11125 | const match = getMatchAnchor(selectActiveIndex);
|
11126 | if (match) {
|
11127 | const rect = match.getRect(scrollParent.value, scrollParentRect);
|
11128 | active = getActiveAnchor(rect.top, rects);
|
11129 | }
|
11130 | } else {
|
11131 | active = getActiveAnchor(scrollTop, rects);
|
11132 | }
|
11133 | activeAnchor.value = indexList[active];
|
11134 | if (sticky) {
|
11135 | children.forEach((item, index) => {
|
11136 | const {
|
11137 | state,
|
11138 | $el
|
11139 | } = item;
|
11140 | if (index === active || index === active - 1) {
|
11141 | const rect = $el.getBoundingClientRect();
|
11142 | state.left = rect.left;
|
11143 | state.width = rect.width;
|
11144 | } else {
|
11145 | state.left = null;
|
11146 | state.width = null;
|
11147 | }
|
11148 | if (index === active) {
|
11149 | state.active = true;
|
11150 | state.top = Math.max(props2.stickyOffsetTop, rects[index].top - scrollTop) + scrollParentRect.top;
|
11151 | } else if (index === active - 1 && selectActiveIndex === "") {
|
11152 | const activeItemTop = rects[active].top - scrollTop;
|
11153 | state.active = activeItemTop > 0;
|
11154 | state.top = activeItemTop + scrollParentRect.top - rects[index].height;
|
11155 | } else {
|
11156 | state.active = false;
|
11157 | }
|
11158 | });
|
11159 | }
|
11160 | selectActiveIndex = "";
|
11161 | };
|
11162 | const init = () => {
|
11163 | nextTick(onScroll);
|
11164 | };
|
11165 | useEventListener("scroll", onScroll, {
|
11166 | target: scrollParent,
|
11167 | passive: true
|
11168 | });
|
11169 | onMounted(init);
|
11170 | watch(() => props2.indexList, init);
|
11171 | watch(activeAnchor, (value) => {
|
11172 | if (value) {
|
11173 | emit("change", value);
|
11174 | }
|
11175 | });
|
11176 | const renderIndexes = () => props2.indexList.map((index) => {
|
11177 | const active = index === activeAnchor.value;
|
11178 | return createVNode("span", {
|
11179 | "class": bem$C("index", {
|
11180 | active
|
11181 | }),
|
11182 | "style": active ? highlightStyle.value : void 0,
|
11183 | "data-index": index
|
11184 | }, [index]);
|
11185 | });
|
11186 | const scrollTo = (index) => {
|
11187 | selectActiveIndex = String(index);
|
11188 | const match = getMatchAnchor(selectActiveIndex);
|
11189 | if (match) {
|
11190 | const scrollTop = getScrollTop(scrollParent.value);
|
11191 | const scrollParentRect = useRect(scrollParent);
|
11192 | const {
|
11193 | offsetHeight
|
11194 | } = document.documentElement;
|
11195 | match.$el.scrollIntoView();
|
11196 | if (scrollTop === offsetHeight - scrollParentRect.height) {
|
11197 | onScroll();
|
11198 | return;
|
11199 | }
|
11200 | if (props2.sticky && props2.stickyOffsetTop) {
|
11201 | setRootScrollTop(getRootScrollTop() - props2.stickyOffsetTop);
|
11202 | }
|
11203 | emit("select", match.index);
|
11204 | }
|
11205 | };
|
11206 | const scrollToElement = (element) => {
|
11207 | const {
|
11208 | index
|
11209 | } = element.dataset;
|
11210 | if (index) {
|
11211 | scrollTo(index);
|
11212 | }
|
11213 | };
|
11214 | const onClickSidebar = (event) => {
|
11215 | scrollToElement(event.target);
|
11216 | };
|
11217 | let touchActiveIndex;
|
11218 | const onTouchMove = (event) => {
|
11219 | touch.move(event);
|
11220 | if (touch.isVertical()) {
|
11221 | preventDefault(event);
|
11222 | const {
|
11223 | clientX,
|
11224 | clientY
|
11225 | } = event.touches[0];
|
11226 | const target = document.elementFromPoint(clientX, clientY);
|
11227 | if (target) {
|
11228 | const {
|
11229 | index
|
11230 | } = target.dataset;
|
11231 | if (index && touchActiveIndex !== index) {
|
11232 | touchActiveIndex = index;
|
11233 | scrollToElement(target);
|
11234 | }
|
11235 | }
|
11236 | }
|
11237 | };
|
11238 | const renderSidebar = () => createVNode("div", {
|
11239 | "ref": sidebar,
|
11240 | "class": bem$C("sidebar"),
|
11241 | "style": sidebarStyle.value,
|
11242 | "onClick": onClickSidebar,
|
11243 | "onTouchstartPassive": touch.start
|
11244 | }, [renderIndexes()]);
|
11245 | useExpose({
|
11246 | scrollTo
|
11247 | });
|
11248 | useEventListener("touchmove", onTouchMove, {
|
11249 | target: sidebar
|
11250 | });
|
11251 | return () => {
|
11252 | var _a;
|
11253 | return createVNode("div", {
|
11254 | "ref": root,
|
11255 | "class": bem$C()
|
11256 | }, [props2.teleport ? createVNode(Teleport, {
|
11257 | "to": props2.teleport
|
11258 | }, {
|
11259 | default: () => [renderSidebar()]
|
11260 | }) : renderSidebar(), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
11261 | };
|
11262 | }
|
11263 | });
|
11264 | const [name$C, bem$B] = createNamespace("index-anchor");
|
11265 | const indexAnchorProps = {
|
11266 | index: numericProp
|
11267 | };
|
11268 | var stdin_default$K = defineComponent({
|
11269 | name: name$C,
|
11270 | props: indexAnchorProps,
|
11271 | setup(props2, {
|
11272 | slots
|
11273 | }) {
|
11274 | const state = reactive({
|
11275 | top: 0,
|
11276 | left: null,
|
11277 | rect: {
|
11278 | top: 0,
|
11279 | height: 0
|
11280 | },
|
11281 | width: null,
|
11282 | active: false
|
11283 | });
|
11284 | const root = ref();
|
11285 | const {
|
11286 | parent
|
11287 | } = useParent(INDEX_BAR_KEY);
|
11288 | if (!parent) {
|
11289 | if (process.env.NODE_ENV !== "production") {
|
11290 | console.error("[Vant] <IndexAnchor> must be a child component of <IndexBar>.");
|
11291 | }
|
11292 | return;
|
11293 | }
|
11294 | const isSticky = () => state.active && parent.props.sticky;
|
11295 | const anchorStyle = computed(() => {
|
11296 | const {
|
11297 | zIndex,
|
11298 | highlightColor
|
11299 | } = parent.props;
|
11300 | if (isSticky()) {
|
11301 | return extend(getZIndexStyle(zIndex), {
|
11302 | left: state.left ? `${state.left}px` : void 0,
|
11303 | width: state.width ? `${state.width}px` : void 0,
|
11304 | transform: state.top ? `translate3d(0, ${state.top}px, 0)` : void 0,
|
11305 | color: highlightColor
|
11306 | });
|
11307 | }
|
11308 | });
|
11309 | const getRect = (scrollParent, scrollParentRect) => {
|
11310 | const rootRect = useRect(root);
|
11311 | state.rect.height = rootRect.height;
|
11312 | if (scrollParent === window || scrollParent === document.body) {
|
11313 | state.rect.top = rootRect.top + getRootScrollTop();
|
11314 | } else {
|
11315 | state.rect.top = rootRect.top + getScrollTop(scrollParent) - scrollParentRect.top;
|
11316 | }
|
11317 | return state.rect;
|
11318 | };
|
11319 | useExpose({
|
11320 | state,
|
11321 | getRect
|
11322 | });
|
11323 | return () => {
|
11324 | const sticky = isSticky();
|
11325 | return createVNode("div", {
|
11326 | "ref": root,
|
11327 | "style": {
|
11328 | height: sticky ? `${state.rect.height}px` : void 0
|
11329 | }
|
11330 | }, [createVNode("div", {
|
11331 | "style": anchorStyle.value,
|
11332 | "class": [bem$B({
|
11333 | sticky
|
11334 | }), {
|
11335 | [BORDER_BOTTOM]: sticky
|
11336 | }]
|
11337 | }, [slots.default ? slots.default() : props2.index])]);
|
11338 | };
|
11339 | }
|
11340 | });
|
11341 | const IndexAnchor = withInstall(stdin_default$K);
|
11342 | const IndexBar = withInstall(stdin_default$L);
|
11343 | const [name$B, bem$A, t$7] = createNamespace("list");
|
11344 | const listProps = {
|
11345 | error: Boolean,
|
11346 | offset: makeNumericProp(300),
|
11347 | loading: Boolean,
|
11348 | disabled: Boolean,
|
11349 | finished: Boolean,
|
11350 | scroller: Object,
|
11351 | errorText: String,
|
11352 | direction: makeStringProp("down"),
|
11353 | loadingText: String,
|
11354 | finishedText: String,
|
11355 | immediateCheck: truthProp
|
11356 | };
|
11357 | var stdin_default$J = defineComponent({
|
11358 | name: name$B,
|
11359 | props: listProps,
|
11360 | emits: ["load", "update:error", "update:loading"],
|
11361 | setup(props2, {
|
11362 | emit,
|
11363 | slots
|
11364 | }) {
|
11365 | const loading = ref(props2.loading);
|
11366 | const root = ref();
|
11367 | const placeholder = ref();
|
11368 | const tabStatus = useTabStatus();
|
11369 | const scrollParent = useScrollParent(root);
|
11370 | const scroller = computed(() => props2.scroller || scrollParent.value);
|
11371 | const check = () => {
|
11372 | nextTick(() => {
|
11373 | if (loading.value || props2.finished || props2.disabled || props2.error ||
|
11374 | (tabStatus == null ? void 0 : tabStatus.value) === false) {
|
11375 | return;
|
11376 | }
|
11377 | const {
|
11378 | direction
|
11379 | } = props2;
|
11380 | const offset = +props2.offset;
|
11381 | const scrollParentRect = useRect(scroller);
|
11382 | if (!scrollParentRect.height || isHidden(root)) {
|
11383 | return;
|
11384 | }
|
11385 | let isReachEdge = false;
|
11386 | const placeholderRect = useRect(placeholder);
|
11387 | if (direction === "up") {
|
11388 | isReachEdge = scrollParentRect.top - placeholderRect.top <= offset;
|
11389 | } else {
|
11390 | isReachEdge = placeholderRect.bottom - scrollParentRect.bottom <= offset;
|
11391 | }
|
11392 | if (isReachEdge) {
|
11393 | loading.value = true;
|
11394 | emit("update:loading", true);
|
11395 | emit("load");
|
11396 | }
|
11397 | });
|
11398 | };
|
11399 | const renderFinishedText = () => {
|
11400 | if (props2.finished) {
|
11401 | const text = slots.finished ? slots.finished() : props2.finishedText;
|
11402 | if (text) {
|
11403 | return createVNode("div", {
|
11404 | "class": bem$A("finished-text")
|
11405 | }, [text]);
|
11406 | }
|
11407 | }
|
11408 | };
|
11409 | const clickErrorText = () => {
|
11410 | emit("update:error", false);
|
11411 | check();
|
11412 | };
|
11413 | const renderErrorText = () => {
|
11414 | if (props2.error) {
|
11415 | const text = slots.error ? slots.error() : props2.errorText;
|
11416 | if (text) {
|
11417 | return createVNode("div", {
|
11418 | "role": "button",
|
11419 | "class": bem$A("error-text"),
|
11420 | "tabindex": 0,
|
11421 | "onClick": clickErrorText
|
11422 | }, [text]);
|
11423 | }
|
11424 | }
|
11425 | };
|
11426 | const renderLoading = () => {
|
11427 | if (loading.value && !props2.finished && !props2.disabled) {
|
11428 | return createVNode("div", {
|
11429 | "class": bem$A("loading")
|
11430 | }, [slots.loading ? slots.loading() : createVNode(Loading, {
|
11431 | "class": bem$A("loading-icon")
|
11432 | }, {
|
11433 | default: () => [props2.loadingText || t$7("loading")]
|
11434 | })]);
|
11435 | }
|
11436 | };
|
11437 | watch(() => [props2.loading, props2.finished, props2.error], check);
|
11438 | if (tabStatus) {
|
11439 | watch(tabStatus, (tabActive) => {
|
11440 | if (tabActive) {
|
11441 | check();
|
11442 | }
|
11443 | });
|
11444 | }
|
11445 | onUpdated(() => {
|
11446 | loading.value = props2.loading;
|
11447 | });
|
11448 | onMounted(() => {
|
11449 | if (props2.immediateCheck) {
|
11450 | check();
|
11451 | }
|
11452 | });
|
11453 | useExpose({
|
11454 | check
|
11455 | });
|
11456 | useEventListener("scroll", check, {
|
11457 | target: scroller,
|
11458 | passive: true
|
11459 | });
|
11460 | return () => {
|
11461 | var _a;
|
11462 | const Content = (_a = slots.default) == null ? void 0 : _a.call(slots);
|
11463 | const Placeholder = createVNode("div", {
|
11464 | "ref": placeholder,
|
11465 | "class": bem$A("placeholder")
|
11466 | }, null);
|
11467 | return createVNode("div", {
|
11468 | "ref": root,
|
11469 | "role": "feed",
|
11470 | "class": bem$A(),
|
11471 | "aria-busy": loading.value
|
11472 | }, [props2.direction === "down" ? Content : Placeholder, renderLoading(), renderFinishedText(), renderErrorText(), props2.direction === "up" ? Content : Placeholder]);
|
11473 | };
|
11474 | }
|
11475 | });
|
11476 | const List = withInstall(stdin_default$J);
|
11477 | const [name$A, bem$z] = createNamespace("nav-bar");
|
11478 | const navBarProps = {
|
11479 | title: String,
|
11480 | fixed: Boolean,
|
11481 | zIndex: numericProp,
|
11482 | border: truthProp,
|
11483 | leftText: String,
|
11484 | rightText: String,
|
11485 | leftDisabled: Boolean,
|
11486 | rightDisabled: Boolean,
|
11487 | leftArrow: Boolean,
|
11488 | placeholder: Boolean,
|
11489 | safeAreaInsetTop: Boolean,
|
11490 | clickable: truthProp
|
11491 | };
|
11492 | var stdin_default$I = defineComponent({
|
11493 | name: name$A,
|
11494 | props: navBarProps,
|
11495 | emits: ["clickLeft", "clickRight"],
|
11496 | setup(props2, {
|
11497 | emit,
|
11498 | slots
|
11499 | }) {
|
11500 | const navBarRef = ref();
|
11501 | const renderPlaceholder = usePlaceholder(navBarRef, bem$z);
|
11502 | const onClickLeft = (event) => {
|
11503 | if (!props2.leftDisabled) {
|
11504 | emit("clickLeft", event);
|
11505 | }
|
11506 | };
|
11507 | const onClickRight = (event) => {
|
11508 | if (!props2.rightDisabled) {
|
11509 | emit("clickRight", event);
|
11510 | }
|
11511 | };
|
11512 | const renderLeft = () => {
|
11513 | if (slots.left) {
|
11514 | return slots.left();
|
11515 | }
|
11516 | return [props2.leftArrow && createVNode(Icon, {
|
11517 | "class": bem$z("arrow"),
|
11518 | "name": "arrow-left"
|
11519 | }, null), props2.leftText && createVNode("span", {
|
11520 | "class": bem$z("text")
|
11521 | }, [props2.leftText])];
|
11522 | };
|
11523 | const renderRight = () => {
|
11524 | if (slots.right) {
|
11525 | return slots.right();
|
11526 | }
|
11527 | return createVNode("span", {
|
11528 | "class": bem$z("text")
|
11529 | }, [props2.rightText]);
|
11530 | };
|
11531 | const renderNavBar = () => {
|
11532 | const {
|
11533 | title,
|
11534 | fixed,
|
11535 | border,
|
11536 | zIndex
|
11537 | } = props2;
|
11538 | const style = getZIndexStyle(zIndex);
|
11539 | const hasLeft = props2.leftArrow || props2.leftText || slots.left;
|
11540 | const hasRight = props2.rightText || slots.right;
|
11541 | return createVNode("div", {
|
11542 | "ref": navBarRef,
|
11543 | "style": style,
|
11544 | "class": [bem$z({
|
11545 | fixed
|
11546 | }), {
|
11547 | [BORDER_BOTTOM]: border,
|
11548 | "van-safe-area-top": props2.safeAreaInsetTop
|
11549 | }]
|
11550 | }, [createVNode("div", {
|
11551 | "class": bem$z("content")
|
11552 | }, [hasLeft && createVNode("div", {
|
11553 | "class": [bem$z("left", {
|
11554 | disabled: props2.leftDisabled
|
11555 | }), props2.clickable && !props2.leftDisabled ? HAPTICS_FEEDBACK : ""],
|
11556 | "onClick": onClickLeft
|
11557 | }, [renderLeft()]), createVNode("div", {
|
11558 | "class": [bem$z("title"), "van-ellipsis"]
|
11559 | }, [slots.title ? slots.title() : title]), hasRight && createVNode("div", {
|
11560 | "class": [bem$z("right", {
|
11561 | disabled: props2.rightDisabled
|
11562 | }), props2.clickable && !props2.rightDisabled ? HAPTICS_FEEDBACK : ""],
|
11563 | "onClick": onClickRight
|
11564 | }, [renderRight()])])]);
|
11565 | };
|
11566 | return () => {
|
11567 | if (props2.fixed && props2.placeholder) {
|
11568 | return renderPlaceholder(renderNavBar);
|
11569 | }
|
11570 | return renderNavBar();
|
11571 | };
|
11572 | }
|
11573 | });
|
11574 | const NavBar = withInstall(stdin_default$I);
|
11575 | const [name$z, bem$y] = createNamespace("notice-bar");
|
11576 | const noticeBarProps = {
|
11577 | text: String,
|
11578 | mode: String,
|
11579 | color: String,
|
11580 | delay: makeNumericProp(1),
|
11581 | speed: makeNumericProp(60),
|
11582 | leftIcon: String,
|
11583 | wrapable: Boolean,
|
11584 | background: String,
|
11585 | scrollable: {
|
11586 | type: Boolean,
|
11587 | default: null
|
11588 | }
|
11589 | };
|
11590 | var stdin_default$H = defineComponent({
|
11591 | name: name$z,
|
11592 | props: noticeBarProps,
|
11593 | emits: ["close", "replay"],
|
11594 | setup(props2, {
|
11595 | emit,
|
11596 | slots
|
11597 | }) {
|
11598 | let wrapWidth = 0;
|
11599 | let contentWidth = 0;
|
11600 | let startTimer;
|
11601 | const wrapRef = ref();
|
11602 | const contentRef = ref();
|
11603 | const state = reactive({
|
11604 | show: true,
|
11605 | offset: 0,
|
11606 | duration: 0
|
11607 | });
|
11608 | const renderLeftIcon = () => {
|
11609 | if (slots["left-icon"]) {
|
11610 | return slots["left-icon"]();
|
11611 | }
|
11612 | if (props2.leftIcon) {
|
11613 | return createVNode(Icon, {
|
11614 | "class": bem$y("left-icon"),
|
11615 | "name": props2.leftIcon
|
11616 | }, null);
|
11617 | }
|
11618 | };
|
11619 | const getRightIconName = () => {
|
11620 | if (props2.mode === "closeable") {
|
11621 | return "cross";
|
11622 | }
|
11623 | if (props2.mode === "link") {
|
11624 | return "arrow";
|
11625 | }
|
11626 | };
|
11627 | const onClickRightIcon = (event) => {
|
11628 | if (props2.mode === "closeable") {
|
11629 | state.show = false;
|
11630 | emit("close", event);
|
11631 | }
|
11632 | };
|
11633 | const renderRightIcon = () => {
|
11634 | if (slots["right-icon"]) {
|
11635 | return slots["right-icon"]();
|
11636 | }
|
11637 | const name2 = getRightIconName();
|
11638 | if (name2) {
|
11639 | return createVNode(Icon, {
|
11640 | "name": name2,
|
11641 | "class": bem$y("right-icon"),
|
11642 | "onClick": onClickRightIcon
|
11643 | }, null);
|
11644 | }
|
11645 | };
|
11646 | const onTransitionEnd = () => {
|
11647 | state.offset = wrapWidth;
|
11648 | state.duration = 0;
|
11649 | raf(() => {
|
11650 | doubleRaf(() => {
|
11651 | state.offset = -contentWidth;
|
11652 | state.duration = (contentWidth + wrapWidth) / +props2.speed;
|
11653 | emit("replay");
|
11654 | });
|
11655 | });
|
11656 | };
|
11657 | const renderMarquee = () => {
|
11658 | const ellipsis = props2.scrollable === false && !props2.wrapable;
|
11659 | const style = {
|
11660 | transform: state.offset ? `translateX(${state.offset}px)` : "",
|
11661 | transitionDuration: `${state.duration}s`
|
11662 | };
|
11663 | return createVNode("div", {
|
11664 | "ref": wrapRef,
|
11665 | "role": "marquee",
|
11666 | "class": bem$y("wrap")
|
11667 | }, [createVNode("div", {
|
11668 | "ref": contentRef,
|
11669 | "style": style,
|
11670 | "class": [bem$y("content"), {
|
11671 | "van-ellipsis": ellipsis
|
11672 | }],
|
11673 | "onTransitionend": onTransitionEnd
|
11674 | }, [slots.default ? slots.default() : props2.text])]);
|
11675 | };
|
11676 | const reset = () => {
|
11677 | const {
|
11678 | delay,
|
11679 | speed,
|
11680 | scrollable
|
11681 | } = props2;
|
11682 | const ms = isDef(delay) ? +delay * 1e3 : 0;
|
11683 | wrapWidth = 0;
|
11684 | contentWidth = 0;
|
11685 | state.offset = 0;
|
11686 | state.duration = 0;
|
11687 | clearTimeout(startTimer);
|
11688 | startTimer = setTimeout(() => {
|
11689 | if (!wrapRef.value || !contentRef.value || scrollable === false) {
|
11690 | return;
|
11691 | }
|
11692 | const wrapRefWidth = useRect(wrapRef).width;
|
11693 | const contentRefWidth = useRect(contentRef).width;
|
11694 | if (scrollable || contentRefWidth > wrapRefWidth) {
|
11695 | doubleRaf(() => {
|
11696 | wrapWidth = wrapRefWidth;
|
11697 | contentWidth = contentRefWidth;
|
11698 | state.offset = -contentWidth;
|
11699 | state.duration = contentWidth / +speed;
|
11700 | });
|
11701 | }
|
11702 | }, ms);
|
11703 | };
|
11704 | onPopupReopen(reset);
|
11705 | onMountedOrActivated(reset);
|
11706 | useEventListener("pageshow", reset);
|
11707 | useExpose({
|
11708 | reset
|
11709 | });
|
11710 | watch(() => [props2.text, props2.scrollable], reset);
|
11711 | return () => {
|
11712 | const {
|
11713 | color,
|
11714 | wrapable,
|
11715 | background
|
11716 | } = props2;
|
11717 | return withDirectives(createVNode("div", {
|
11718 | "role": "alert",
|
11719 | "class": bem$y({
|
11720 | wrapable
|
11721 | }),
|
11722 | "style": {
|
11723 | color,
|
11724 | background
|
11725 | }
|
11726 | }, [renderLeftIcon(), renderMarquee(), renderRightIcon()]), [[vShow, state.show]]);
|
11727 | };
|
11728 | }
|
11729 | });
|
11730 | const NoticeBar = withInstall(stdin_default$H);
|
11731 | const [name$y, bem$x] = createNamespace("notify");
|
11732 | const popupInheritProps = ["lockScroll", "position", "show", "teleport", "zIndex"];
|
11733 | const notifyProps = extend({}, popupSharedProps, {
|
11734 | type: makeStringProp("danger"),
|
11735 | color: String,
|
11736 | message: numericProp,
|
11737 | position: makeStringProp("top"),
|
11738 | className: unknownProp,
|
11739 | background: String,
|
11740 | lockScroll: Boolean
|
11741 | });
|
11742 | var stdin_default$G = defineComponent({
|
11743 | name: name$y,
|
11744 | props: notifyProps,
|
11745 | emits: ["update:show"],
|
11746 | setup(props2, {
|
11747 | emit,
|
11748 | slots
|
11749 | }) {
|
11750 | const updateShow = (show) => emit("update:show", show);
|
11751 | return () => createVNode(Popup, mergeProps({
|
11752 | "class": [bem$x([props2.type]), props2.className],
|
11753 | "style": {
|
11754 | color: props2.color,
|
11755 | background: props2.background
|
11756 | },
|
11757 | "overlay": false,
|
11758 | "duration": 0.2,
|
11759 | "onUpdate:show": updateShow
|
11760 | }, pick(props2, popupInheritProps)), {
|
11761 | default: () => [slots.default ? slots.default() : props2.message]
|
11762 | });
|
11763 | }
|
11764 | });
|
11765 | let timer;
|
11766 | let instance;
|
11767 | const parseOptions = (message) => isObject(message) ? message : {
|
11768 | message
|
11769 | };
|
11770 | function initInstance() {
|
11771 | ({
|
11772 | instance
|
11773 | } = mountComponent({
|
11774 | setup() {
|
11775 | const {
|
11776 | state,
|
11777 | toggle
|
11778 | } = usePopupState();
|
11779 | return () => createVNode(stdin_default$G, mergeProps(state, {
|
11780 | "onUpdate:show": toggle
|
11781 | }), null);
|
11782 | }
|
11783 | }));
|
11784 | }
|
11785 | const getDefaultOptions = () => ({
|
11786 | type: "danger",
|
11787 | color: void 0,
|
11788 | message: "",
|
11789 | onClose: void 0,
|
11790 | onClick: void 0,
|
11791 | onOpened: void 0,
|
11792 | duration: 3e3,
|
11793 | position: void 0,
|
11794 | className: "",
|
11795 | lockScroll: false,
|
11796 | background: void 0
|
11797 | });
|
11798 | let currentOptions = getDefaultOptions();
|
11799 | const closeNotify = () => {
|
11800 | if (instance) {
|
11801 | instance.toggle(false);
|
11802 | }
|
11803 | };
|
11804 | function showNotify(options) {
|
11805 | if (!inBrowser) {
|
11806 | return;
|
11807 | }
|
11808 | if (!instance) {
|
11809 | initInstance();
|
11810 | }
|
11811 | options = extend({}, currentOptions, parseOptions(options));
|
11812 | instance.open(options);
|
11813 | clearTimeout(timer);
|
11814 | if (options.duration > 0) {
|
11815 | timer = setTimeout(closeNotify, options.duration);
|
11816 | }
|
11817 | return instance;
|
11818 | }
|
11819 | const setNotifyDefaultOptions = (options) => extend(currentOptions, options);
|
11820 | const resetNotifyDefaultOptions = () => {
|
11821 | currentOptions = getDefaultOptions();
|
11822 | };
|
11823 | const Notify = withInstall(stdin_default$G);
|
11824 | const [name$x, bem$w] = createNamespace("key");
|
11825 | const CollapseIcon = createVNode("svg", {
|
11826 | "class": bem$w("collapse-icon"),
|
11827 | "viewBox": "0 0 30 24"
|
11828 | }, [createVNode("path", {
|
11829 | "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",
|
11830 | "fill": "currentColor"
|
11831 | }, null)]);
|
11832 | const DeleteIcon = createVNode("svg", {
|
11833 | "class": bem$w("delete-icon"),
|
11834 | "viewBox": "0 0 32 22"
|
11835 | }, [createVNode("path", {
|
11836 | "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",
|
11837 | "fill": "currentColor"
|
11838 | }, null)]);
|
11839 | var stdin_default$F = defineComponent({
|
11840 | name: name$x,
|
11841 | props: {
|
11842 | type: String,
|
11843 | text: numericProp,
|
11844 | color: String,
|
11845 | wider: Boolean,
|
11846 | large: Boolean,
|
11847 | loading: Boolean
|
11848 | },
|
11849 | emits: ["press"],
|
11850 | setup(props2, {
|
11851 | emit,
|
11852 | slots
|
11853 | }) {
|
11854 | const active = ref(false);
|
11855 | const touch = useTouch();
|
11856 | const onTouchStart = (event) => {
|
11857 | touch.start(event);
|
11858 | active.value = true;
|
11859 | };
|
11860 | const onTouchMove = (event) => {
|
11861 | touch.move(event);
|
11862 | if (touch.direction.value) {
|
11863 | active.value = false;
|
11864 | }
|
11865 | };
|
11866 | const onTouchEnd = (event) => {
|
11867 | if (active.value) {
|
11868 | if (!slots.default) {
|
11869 | preventDefault(event);
|
11870 | }
|
11871 | active.value = false;
|
11872 | emit("press", props2.text, props2.type);
|
11873 | }
|
11874 | };
|
11875 | const renderContent = () => {
|
11876 | if (props2.loading) {
|
11877 | return createVNode(Loading, {
|
11878 | "class": bem$w("loading-icon")
|
11879 | }, null);
|
11880 | }
|
11881 | const text = slots.default ? slots.default() : props2.text;
|
11882 | switch (props2.type) {
|
11883 | case "delete":
|
11884 | return text || DeleteIcon;
|
11885 | case "extra":
|
11886 | return text || CollapseIcon;
|
11887 | default:
|
11888 | return text;
|
11889 | }
|
11890 | };
|
11891 | return () => createVNode("div", {
|
11892 | "class": bem$w("wrapper", {
|
11893 | wider: props2.wider
|
11894 | }),
|
11895 | "onTouchstartPassive": onTouchStart,
|
11896 | "onTouchmovePassive": onTouchMove,
|
11897 | "onTouchend": onTouchEnd,
|
11898 | "onTouchcancel": onTouchEnd
|
11899 | }, [createVNode("div", {
|
11900 | "role": "button",
|
11901 | "tabindex": 0,
|
11902 | "class": bem$w([props2.color, {
|
11903 | large: props2.large,
|
11904 | active: active.value,
|
11905 | delete: props2.type === "delete"
|
11906 | }])
|
11907 | }, [renderContent()])]);
|
11908 | }
|
11909 | });
|
11910 | const [name$w, bem$v] = createNamespace("number-keyboard");
|
11911 | const numberKeyboardProps = {
|
11912 | show: Boolean,
|
11913 | title: String,
|
11914 | theme: makeStringProp("default"),
|
11915 | zIndex: numericProp,
|
11916 | teleport: [String, Object],
|
11917 | maxlength: makeNumericProp(Infinity),
|
11918 | modelValue: makeStringProp(""),
|
11919 | transition: truthProp,
|
11920 | blurOnClose: truthProp,
|
11921 | showDeleteKey: truthProp,
|
11922 | randomKeyOrder: Boolean,
|
11923 | closeButtonText: String,
|
11924 | deleteButtonText: String,
|
11925 | closeButtonLoading: Boolean,
|
11926 | hideOnClickOutside: truthProp,
|
11927 | safeAreaInsetBottom: truthProp,
|
11928 | extraKey: {
|
11929 | type: [String, Array],
|
11930 | default: ""
|
11931 | }
|
11932 | };
|
11933 | function shuffle(array) {
|
11934 | for (let i = array.length - 1; i > 0; i--) {
|
11935 | const j = Math.floor(Math.random() * (i + 1));
|
11936 | const temp = array[i];
|
11937 | array[i] = array[j];
|
11938 | array[j] = temp;
|
11939 | }
|
11940 | return array;
|
11941 | }
|
11942 | var stdin_default$E = defineComponent({
|
11943 | name: name$w,
|
11944 | inheritAttrs: false,
|
11945 | props: numberKeyboardProps,
|
11946 | emits: ["show", "hide", "blur", "input", "close", "delete", "update:modelValue"],
|
11947 | setup(props2, {
|
11948 | emit,
|
11949 | slots,
|
11950 | attrs
|
11951 | }) {
|
11952 | const root = ref();
|
11953 | const genBasicKeys = () => {
|
11954 | const keys2 = Array(9).fill("").map((_, i) => ({
|
11955 | text: i + 1
|
11956 | }));
|
11957 | if (props2.randomKeyOrder) {
|
11958 | shuffle(keys2);
|
11959 | }
|
11960 | return keys2;
|
11961 | };
|
11962 | const genDefaultKeys = () => [...genBasicKeys(), {
|
11963 | text: props2.extraKey,
|
11964 | type: "extra"
|
11965 | }, {
|
11966 | text: 0
|
11967 | }, {
|
11968 | text: props2.showDeleteKey ? props2.deleteButtonText : "",
|
11969 | type: props2.showDeleteKey ? "delete" : ""
|
11970 | }];
|
11971 | const genCustomKeys = () => {
|
11972 | const keys2 = genBasicKeys();
|
11973 | const {
|
11974 | extraKey
|
11975 | } = props2;
|
11976 | const extraKeys = Array.isArray(extraKey) ? extraKey : [extraKey];
|
11977 | if (extraKeys.length === 1) {
|
11978 | keys2.push({
|
11979 | text: 0,
|
11980 | wider: true
|
11981 | }, {
|
11982 | text: extraKeys[0],
|
11983 | type: "extra"
|
11984 | });
|
11985 | } else if (extraKeys.length === 2) {
|
11986 | keys2.push({
|
11987 | text: extraKeys[0],
|
11988 | type: "extra"
|
11989 | }, {
|
11990 | text: 0
|
11991 | }, {
|
11992 | text: extraKeys[1],
|
11993 | type: "extra"
|
11994 | });
|
11995 | }
|
11996 | return keys2;
|
11997 | };
|
11998 | const keys = computed(() => props2.theme === "custom" ? genCustomKeys() : genDefaultKeys());
|
11999 | const onBlur = () => {
|
12000 | if (props2.show) {
|
12001 | emit("blur");
|
12002 | }
|
12003 | };
|
12004 | const onClose = () => {
|
12005 | emit("close");
|
12006 | if (props2.blurOnClose) {
|
12007 | onBlur();
|
12008 | }
|
12009 | };
|
12010 | const onAnimationEnd = () => emit(props2.show ? "show" : "hide");
|
12011 | const onPress = (text, type) => {
|
12012 | if (text === "") {
|
12013 | if (type === "extra") {
|
12014 | onBlur();
|
12015 | }
|
12016 | return;
|
12017 | }
|
12018 | const value = props2.modelValue;
|
12019 | if (type === "delete") {
|
12020 | emit("delete");
|
12021 | emit("update:modelValue", value.slice(0, value.length - 1));
|
12022 | } else if (type === "close") {
|
12023 | onClose();
|
12024 | } else if (value.length < +props2.maxlength) {
|
12025 | emit("input", text);
|
12026 | emit("update:modelValue", value + text);
|
12027 | }
|
12028 | };
|
12029 | const renderTitle = () => {
|
12030 | const {
|
12031 | title,
|
12032 | theme,
|
12033 | closeButtonText
|
12034 | } = props2;
|
12035 | const leftSlot = slots["title-left"];
|
12036 | const showClose = closeButtonText && theme === "default";
|
12037 | const showTitle = title || showClose || leftSlot;
|
12038 | if (!showTitle) {
|
12039 | return;
|
12040 | }
|
12041 | return createVNode("div", {
|
12042 | "class": bem$v("header")
|
12043 | }, [leftSlot && createVNode("span", {
|
12044 | "class": bem$v("title-left")
|
12045 | }, [leftSlot()]), title && createVNode("h2", {
|
12046 | "class": bem$v("title")
|
12047 | }, [title]), showClose && createVNode("button", {
|
12048 | "type": "button",
|
12049 | "class": [bem$v("close"), HAPTICS_FEEDBACK],
|
12050 | "onClick": onClose
|
12051 | }, [closeButtonText])]);
|
12052 | };
|
12053 | const renderKeys = () => keys.value.map((key) => {
|
12054 | const keySlots = {};
|
12055 | if (key.type === "delete") {
|
12056 | keySlots.default = slots.delete;
|
12057 | }
|
12058 | if (key.type === "extra") {
|
12059 | keySlots.default = slots["extra-key"];
|
12060 | }
|
12061 | return createVNode(stdin_default$F, {
|
12062 | "key": key.text,
|
12063 | "text": key.text,
|
12064 | "type": key.type,
|
12065 | "wider": key.wider,
|
12066 | "color": key.color,
|
12067 | "onPress": onPress
|
12068 | }, keySlots);
|
12069 | });
|
12070 | const renderSidebar = () => {
|
12071 | if (props2.theme === "custom") {
|
12072 | return createVNode("div", {
|
12073 | "class": bem$v("sidebar")
|
12074 | }, [props2.showDeleteKey && createVNode(stdin_default$F, {
|
12075 | "large": true,
|
12076 | "text": props2.deleteButtonText,
|
12077 | "type": "delete",
|
12078 | "onPress": onPress
|
12079 | }, {
|
12080 | default: slots.delete
|
12081 | }), createVNode(stdin_default$F, {
|
12082 | "large": true,
|
12083 | "text": props2.closeButtonText,
|
12084 | "type": "close",
|
12085 | "color": "blue",
|
12086 | "loading": props2.closeButtonLoading,
|
12087 | "onPress": onPress
|
12088 | }, null)]);
|
12089 | }
|
12090 | };
|
12091 | watch(() => props2.show, (value) => {
|
12092 | if (!props2.transition) {
|
12093 | emit(value ? "show" : "hide");
|
12094 | }
|
12095 | });
|
12096 | if (props2.hideOnClickOutside) {
|
12097 | useClickAway(root, onBlur, {
|
12098 | eventName: "touchstart"
|
12099 | });
|
12100 | }
|
12101 | return () => {
|
12102 | const Title = renderTitle();
|
12103 | const Content = createVNode(Transition, {
|
12104 | "name": props2.transition ? "van-slide-up" : ""
|
12105 | }, {
|
12106 | default: () => [withDirectives(createVNode("div", mergeProps({
|
12107 | "ref": root,
|
12108 | "style": getZIndexStyle(props2.zIndex),
|
12109 | "class": bem$v({
|
12110 | unfit: !props2.safeAreaInsetBottom,
|
12111 | "with-title": !!Title
|
12112 | }),
|
12113 | "onAnimationend": onAnimationEnd,
|
12114 | "onTouchstartPassive": stopPropagation
|
12115 | }, attrs), [Title, createVNode("div", {
|
12116 | "class": bem$v("body")
|
12117 | }, [createVNode("div", {
|
12118 | "class": bem$v("keys")
|
12119 | }, [renderKeys()]), renderSidebar()])]), [[vShow, props2.show]])]
|
12120 | });
|
12121 | if (props2.teleport) {
|
12122 | return createVNode(Teleport, {
|
12123 | "to": props2.teleport
|
12124 | }, {
|
12125 | default: () => [Content]
|
12126 | });
|
12127 | }
|
12128 | return Content;
|
12129 | };
|
12130 | }
|
12131 | });
|
12132 | const NumberKeyboard = withInstall(stdin_default$E);
|
12133 | const [name$v, bem$u, t$6] = createNamespace("pagination");
|
12134 | const makePage = (number, text, active) => ({
|
12135 | number,
|
12136 | text,
|
12137 | active
|
12138 | });
|
12139 | const paginationProps = {
|
12140 | mode: makeStringProp("multi"),
|
12141 | prevText: String,
|
12142 | nextText: String,
|
12143 | pageCount: makeNumericProp(0),
|
12144 | modelValue: makeNumberProp(0),
|
12145 | totalItems: makeNumericProp(0),
|
12146 | showPageSize: makeNumericProp(5),
|
12147 | itemsPerPage: makeNumericProp(10),
|
12148 | forceEllipses: Boolean,
|
12149 | showPrevButton: truthProp,
|
12150 | showNextButton: truthProp
|
12151 | };
|
12152 | var stdin_default$D = defineComponent({
|
12153 | name: name$v,
|
12154 | props: paginationProps,
|
12155 | emits: ["change", "update:modelValue"],
|
12156 | setup(props2, {
|
12157 | emit,
|
12158 | slots
|
12159 | }) {
|
12160 | const count = computed(() => {
|
12161 | const {
|
12162 | pageCount,
|
12163 | totalItems,
|
12164 | itemsPerPage
|
12165 | } = props2;
|
12166 | const count2 = +pageCount || Math.ceil(+totalItems / +itemsPerPage);
|
12167 | return Math.max(1, count2);
|
12168 | });
|
12169 | const pages = computed(() => {
|
12170 | const items = [];
|
12171 | const pageCount = count.value;
|
12172 | const showPageSize = +props2.showPageSize;
|
12173 | const {
|
12174 | modelValue,
|
12175 | forceEllipses
|
12176 | } = props2;
|
12177 | let startPage = 1;
|
12178 | let endPage = pageCount;
|
12179 | const isMaxSized = showPageSize < pageCount;
|
12180 | if (isMaxSized) {
|
12181 | startPage = Math.max(modelValue - Math.floor(showPageSize / 2), 1);
|
12182 | endPage = startPage + showPageSize - 1;
|
12183 | if (endPage > pageCount) {
|
12184 | endPage = pageCount;
|
12185 | startPage = endPage - showPageSize + 1;
|
12186 | }
|
12187 | }
|
12188 | for (let number = startPage; number <= endPage; number++) {
|
12189 | const page = makePage(number, number, number === modelValue);
|
12190 | items.push(page);
|
12191 | }
|
12192 | if (isMaxSized && showPageSize > 0 && forceEllipses) {
|
12193 | if (startPage > 1) {
|
12194 | const prevPages = makePage(startPage - 1, "...");
|
12195 | items.unshift(prevPages);
|
12196 | }
|
12197 | if (endPage < pageCount) {
|
12198 | const nextPages = makePage(endPage + 1, "...");
|
12199 | items.push(nextPages);
|
12200 | }
|
12201 | }
|
12202 | return items;
|
12203 | });
|
12204 | const updateModelValue = (value, emitChange) => {
|
12205 | value = clamp(value, 1, count.value);
|
12206 | if (props2.modelValue !== value) {
|
12207 | emit("update:modelValue", value);
|
12208 | if (emitChange) {
|
12209 | emit("change", value);
|
12210 | }
|
12211 | }
|
12212 | };
|
12213 | watchEffect(() => updateModelValue(props2.modelValue));
|
12214 | const renderDesc = () => createVNode("li", {
|
12215 | "class": bem$u("page-desc")
|
12216 | }, [slots.pageDesc ? slots.pageDesc() : `${props2.modelValue}/${count.value}`]);
|
12217 | const renderPrevButton = () => {
|
12218 | const {
|
12219 | mode,
|
12220 | modelValue,
|
12221 | showPrevButton
|
12222 | } = props2;
|
12223 | if (!showPrevButton) {
|
12224 | return;
|
12225 | }
|
12226 | const slot = slots["prev-text"];
|
12227 | const disabled = modelValue === 1;
|
12228 | return createVNode("li", {
|
12229 | "class": [bem$u("item", {
|
12230 | disabled,
|
12231 | border: mode === "simple",
|
12232 | prev: true
|
12233 | }), BORDER_SURROUND]
|
12234 | }, [createVNode("button", {
|
12235 | "type": "button",
|
12236 | "disabled": disabled,
|
12237 | "onClick": () => updateModelValue(modelValue - 1, true)
|
12238 | }, [slot ? slot() : props2.prevText || t$6("prev")])]);
|
12239 | };
|
12240 | const renderNextButton = () => {
|
12241 | const {
|
12242 | mode,
|
12243 | modelValue,
|
12244 | showNextButton
|
12245 | } = props2;
|
12246 | if (!showNextButton) {
|
12247 | return;
|
12248 | }
|
12249 | const slot = slots["next-text"];
|
12250 | const disabled = modelValue === count.value;
|
12251 | return createVNode("li", {
|
12252 | "class": [bem$u("item", {
|
12253 | disabled,
|
12254 | border: mode === "simple",
|
12255 | next: true
|
12256 | }), BORDER_SURROUND]
|
12257 | }, [createVNode("button", {
|
12258 | "type": "button",
|
12259 | "disabled": disabled,
|
12260 | "onClick": () => updateModelValue(modelValue + 1, true)
|
12261 | }, [slot ? slot() : props2.nextText || t$6("next")])]);
|
12262 | };
|
12263 | const renderPages = () => pages.value.map((page) => createVNode("li", {
|
12264 | "class": [bem$u("item", {
|
12265 | active: page.active,
|
12266 | page: true
|
12267 | }), BORDER_SURROUND]
|
12268 | }, [createVNode("button", {
|
12269 | "type": "button",
|
12270 | "aria-current": page.active || void 0,
|
12271 | "onClick": () => updateModelValue(page.number, true)
|
12272 | }, [slots.page ? slots.page(page) : page.text])]));
|
12273 | return () => createVNode("nav", {
|
12274 | "role": "navigation",
|
12275 | "class": bem$u()
|
12276 | }, [createVNode("ul", {
|
12277 | "class": bem$u("items")
|
12278 | }, [renderPrevButton(), props2.mode === "simple" ? renderDesc() : renderPages(), renderNextButton()])]);
|
12279 | }
|
12280 | });
|
12281 | const Pagination = withInstall(stdin_default$D);
|
12282 | const [name$u, bem$t] = createNamespace("password-input");
|
12283 | const passwordInputProps = {
|
12284 | info: String,
|
12285 | mask: truthProp,
|
12286 | value: makeStringProp(""),
|
12287 | gutter: numericProp,
|
12288 | length: makeNumericProp(6),
|
12289 | focused: Boolean,
|
12290 | errorInfo: String
|
12291 | };
|
12292 | var stdin_default$C = defineComponent({
|
12293 | name: name$u,
|
12294 | props: passwordInputProps,
|
12295 | emits: ["focus"],
|
12296 | setup(props2, {
|
12297 | emit
|
12298 | }) {
|
12299 | const onTouchStart = (event) => {
|
12300 | event.stopPropagation();
|
12301 | emit("focus", event);
|
12302 | };
|
12303 | const renderPoints = () => {
|
12304 | const Points = [];
|
12305 | const {
|
12306 | mask,
|
12307 | value,
|
12308 | gutter,
|
12309 | focused
|
12310 | } = props2;
|
12311 | const length = +props2.length;
|
12312 | for (let i = 0; i < length; i++) {
|
12313 | const char = value[i];
|
12314 | const showBorder = i !== 0 && !gutter;
|
12315 | const showCursor = focused && i === value.length;
|
12316 | let style;
|
12317 | if (i !== 0 && gutter) {
|
12318 | style = {
|
12319 | marginLeft: addUnit(gutter)
|
12320 | };
|
12321 | }
|
12322 | Points.push(createVNode("li", {
|
12323 | "class": [{
|
12324 | [BORDER_LEFT]: showBorder
|
12325 | }, bem$t("item", {
|
12326 | focus: showCursor
|
12327 | })],
|
12328 | "style": style
|
12329 | }, [mask ? createVNode("i", {
|
12330 | "style": {
|
12331 | visibility: char ? "visible" : "hidden"
|
12332 | }
|
12333 | }, null) : char, showCursor && createVNode("div", {
|
12334 | "class": bem$t("cursor")
|
12335 | }, null)]));
|
12336 | }
|
12337 | return Points;
|
12338 | };
|
12339 | return () => {
|
12340 | const info = props2.errorInfo || props2.info;
|
12341 | return createVNode("div", {
|
12342 | "class": bem$t()
|
12343 | }, [createVNode("ul", {
|
12344 | "class": [bem$t("security"), {
|
12345 | [BORDER_SURROUND]: !props2.gutter
|
12346 | }],
|
12347 | "onTouchstartPassive": onTouchStart
|
12348 | }, [renderPoints()]), info && createVNode("div", {
|
12349 | "class": bem$t(props2.errorInfo ? "error-info" : "info")
|
12350 | }, [info])]);
|
12351 | };
|
12352 | }
|
12353 | });
|
12354 | const PasswordInput = withInstall(stdin_default$C);
|
12355 | const PickerGroup = withInstall(stdin_default$1A);
|
12356 | const [name$t, bem$s] = createNamespace("popover");
|
12357 | const popupProps = ["overlay", "duration", "teleport", "overlayStyle", "overlayClass", "closeOnClickOverlay"];
|
12358 | const popoverProps = {
|
12359 | show: Boolean,
|
12360 | theme: makeStringProp("light"),
|
12361 | overlay: Boolean,
|
12362 | actions: makeArrayProp(),
|
12363 | actionsDirection: makeStringProp("vertical"),
|
12364 | trigger: makeStringProp("click"),
|
12365 | duration: numericProp,
|
12366 | showArrow: truthProp,
|
12367 | placement: makeStringProp("bottom"),
|
12368 | iconPrefix: String,
|
12369 | overlayClass: unknownProp,
|
12370 | overlayStyle: Object,
|
12371 | closeOnClickAction: truthProp,
|
12372 | closeOnClickOverlay: truthProp,
|
12373 | closeOnClickOutside: truthProp,
|
12374 | offset: {
|
12375 | type: Array,
|
12376 | default: () => [0, 8]
|
12377 | },
|
12378 | teleport: {
|
12379 | type: [String, Object],
|
12380 | default: "body"
|
12381 | }
|
12382 | };
|
12383 | var stdin_default$B = defineComponent({
|
12384 | name: name$t,
|
12385 | props: popoverProps,
|
12386 | emits: ["select", "touchstart", "update:show"],
|
12387 | setup(props2, {
|
12388 | emit,
|
12389 | slots,
|
12390 | attrs
|
12391 | }) {
|
12392 | let popper;
|
12393 | const popupRef = ref();
|
12394 | const wrapperRef = ref();
|
12395 | const popoverRef = ref();
|
12396 | const show = useSyncPropRef(() => props2.show, (value) => emit("update:show", value));
|
12397 | const getPopoverOptions = () => ({
|
12398 | placement: props2.placement,
|
12399 | modifiers: [{
|
12400 | name: "computeStyles",
|
12401 | options: {
|
12402 | adaptive: false,
|
12403 | gpuAcceleration: false
|
12404 | }
|
12405 | }, extend({}, offsetModifier, {
|
12406 | options: {
|
12407 | offset: props2.offset
|
12408 | }
|
12409 | })]
|
12410 | });
|
12411 | const createPopperInstance = () => {
|
12412 | if (wrapperRef.value && popoverRef.value) {
|
12413 | return createPopper(wrapperRef.value, popoverRef.value.popupRef.value, getPopoverOptions());
|
12414 | }
|
12415 | return null;
|
12416 | };
|
12417 | const updateLocation = () => {
|
12418 | nextTick(() => {
|
12419 | if (!show.value) {
|
12420 | return;
|
12421 | }
|
12422 | if (!popper) {
|
12423 | popper = createPopperInstance();
|
12424 | if (inBrowser) {
|
12425 | window.addEventListener("animationend", updateLocation);
|
12426 | window.addEventListener("transitionend", updateLocation);
|
12427 | }
|
12428 | } else {
|
12429 | popper.setOptions(getPopoverOptions());
|
12430 | }
|
12431 | });
|
12432 | };
|
12433 | const updateShow = (value) => {
|
12434 | show.value = value;
|
12435 | };
|
12436 | const onClickWrapper = () => {
|
12437 | if (props2.trigger === "click") {
|
12438 | show.value = !show.value;
|
12439 | }
|
12440 | };
|
12441 | const onClickAction = (action, index) => {
|
12442 | if (action.disabled) {
|
12443 | return;
|
12444 | }
|
12445 | emit("select", action, index);
|
12446 | if (props2.closeOnClickAction) {
|
12447 | show.value = false;
|
12448 | }
|
12449 | };
|
12450 | const onClickAway = () => {
|
12451 | if (show.value && props2.closeOnClickOutside && (!props2.overlay || props2.closeOnClickOverlay)) {
|
12452 | show.value = false;
|
12453 | }
|
12454 | };
|
12455 | const renderActionContent = (action, index) => {
|
12456 | if (slots.action) {
|
12457 | return slots.action({
|
12458 | action,
|
12459 | index
|
12460 | });
|
12461 | }
|
12462 | return [action.icon && createVNode(Icon, {
|
12463 | "name": action.icon,
|
12464 | "classPrefix": props2.iconPrefix,
|
12465 | "class": bem$s("action-icon")
|
12466 | }, null), createVNode("div", {
|
12467 | "class": [bem$s("action-text"), {
|
12468 | [BORDER_BOTTOM]: props2.actionsDirection === "vertical"
|
12469 | }]
|
12470 | }, [action.text])];
|
12471 | };
|
12472 | const renderAction = (action, index) => {
|
12473 | const {
|
12474 | icon,
|
12475 | color,
|
12476 | disabled,
|
12477 | className
|
12478 | } = action;
|
12479 | return createVNode("div", {
|
12480 | "role": "menuitem",
|
12481 | "class": [bem$s("action", {
|
12482 | disabled,
|
12483 | "with-icon": icon
|
12484 | }), {
|
12485 | [BORDER_RIGHT]: props2.actionsDirection === "horizontal"
|
12486 | }, className],
|
12487 | "style": {
|
12488 | color
|
12489 | },
|
12490 | "tabindex": disabled ? void 0 : 0,
|
12491 | "aria-disabled": disabled || void 0,
|
12492 | "onClick": () => onClickAction(action, index)
|
12493 | }, [renderActionContent(action, index)]);
|
12494 | };
|
12495 | onMounted(() => {
|
12496 | updateLocation();
|
12497 | watchEffect(() => {
|
12498 | var _a;
|
12499 | popupRef.value = (_a = popoverRef.value) == null ? void 0 : _a.popupRef.value;
|
12500 | });
|
12501 | });
|
12502 | onBeforeUnmount(() => {
|
12503 | if (popper) {
|
12504 | if (inBrowser) {
|
12505 | window.removeEventListener("animationend", updateLocation);
|
12506 | window.removeEventListener("transitionend", updateLocation);
|
12507 | }
|
12508 | popper.destroy();
|
12509 | popper = null;
|
12510 | }
|
12511 | });
|
12512 | watch(() => [show.value, props2.offset, props2.placement], updateLocation);
|
12513 | useClickAway([wrapperRef, popupRef], onClickAway, {
|
12514 | eventName: "touchstart"
|
12515 | });
|
12516 | return () => {
|
12517 | var _a;
|
12518 | return createVNode(Fragment, null, [createVNode("span", {
|
12519 | "ref": wrapperRef,
|
12520 | "class": bem$s("wrapper"),
|
12521 | "onClick": onClickWrapper
|
12522 | }, [(_a = slots.reference) == null ? void 0 : _a.call(slots)]), createVNode(Popup, mergeProps({
|
12523 | "ref": popoverRef,
|
12524 | "show": show.value,
|
12525 | "class": bem$s([props2.theme]),
|
12526 | "position": "",
|
12527 | "transition": "van-popover-zoom",
|
12528 | "lockScroll": false,
|
12529 | "onUpdate:show": updateShow
|
12530 | }, attrs, useScopeId(), pick(props2, popupProps)), {
|
12531 | default: () => [props2.showArrow && createVNode("div", {
|
12532 | "class": bem$s("arrow")
|
12533 | }, null), createVNode("div", {
|
12534 | "role": "menu",
|
12535 | "class": bem$s("content", props2.actionsDirection)
|
12536 | }, [slots.default ? slots.default() : props2.actions.map(renderAction)])]
|
12537 | })]);
|
12538 | };
|
12539 | }
|
12540 | });
|
12541 | const Popover = withInstall(stdin_default$B);
|
12542 | const [name$s, bem$r] = createNamespace("progress");
|
12543 | const progressProps = {
|
12544 | color: String,
|
12545 | inactive: Boolean,
|
12546 | pivotText: String,
|
12547 | textColor: String,
|
12548 | showPivot: truthProp,
|
12549 | pivotColor: String,
|
12550 | trackColor: String,
|
12551 | strokeWidth: numericProp,
|
12552 | percentage: {
|
12553 | type: numericProp,
|
12554 | default: 0,
|
12555 | validator: (value) => +value >= 0 && +value <= 100
|
12556 | }
|
12557 | };
|
12558 | var stdin_default$A = defineComponent({
|
12559 | name: name$s,
|
12560 | props: progressProps,
|
12561 | setup(props2) {
|
12562 | const background = computed(() => props2.inactive ? void 0 : props2.color);
|
12563 | const renderPivot = () => {
|
12564 | const {
|
12565 | textColor,
|
12566 | pivotText,
|
12567 | pivotColor,
|
12568 | percentage
|
12569 | } = props2;
|
12570 | const text = pivotText != null ? pivotText : `${percentage}%`;
|
12571 | if (props2.showPivot && text) {
|
12572 | const style = {
|
12573 | color: textColor,
|
12574 | left: `${+percentage}%`,
|
12575 | transform: `translate(-${+percentage}%,-50%)`,
|
12576 | background: pivotColor || background.value
|
12577 | };
|
12578 | return createVNode("span", {
|
12579 | "style": style,
|
12580 | "class": bem$r("pivot", {
|
12581 | inactive: props2.inactive
|
12582 | })
|
12583 | }, [text]);
|
12584 | }
|
12585 | };
|
12586 | return () => {
|
12587 | const {
|
12588 | trackColor,
|
12589 | percentage,
|
12590 | strokeWidth
|
12591 | } = props2;
|
12592 | const rootStyle = {
|
12593 | background: trackColor,
|
12594 | height: addUnit(strokeWidth)
|
12595 | };
|
12596 | const portionStyle = {
|
12597 | width: `${percentage}%`,
|
12598 | background: background.value
|
12599 | };
|
12600 | return createVNode("div", {
|
12601 | "class": bem$r(),
|
12602 | "style": rootStyle
|
12603 | }, [createVNode("span", {
|
12604 | "class": bem$r("portion", {
|
12605 | inactive: props2.inactive
|
12606 | }),
|
12607 | "style": portionStyle
|
12608 | }, null), renderPivot()]);
|
12609 | };
|
12610 | }
|
12611 | });
|
12612 | const Progress = withInstall(stdin_default$A);
|
12613 | const [name$r, bem$q, t$5] = createNamespace("pull-refresh");
|
12614 | const DEFAULT_HEAD_HEIGHT = 50;
|
12615 | const TEXT_STATUS = ["pulling", "loosing", "success"];
|
12616 | const pullRefreshProps = {
|
12617 | disabled: Boolean,
|
12618 | modelValue: Boolean,
|
12619 | headHeight: makeNumericProp(DEFAULT_HEAD_HEIGHT),
|
12620 | successText: String,
|
12621 | pullingText: String,
|
12622 | loosingText: String,
|
12623 | loadingText: String,
|
12624 | pullDistance: numericProp,
|
12625 | successDuration: makeNumericProp(500),
|
12626 | animationDuration: makeNumericProp(300)
|
12627 | };
|
12628 | var stdin_default$z = defineComponent({
|
12629 | name: name$r,
|
12630 | props: pullRefreshProps,
|
12631 | emits: ["change", "refresh", "update:modelValue"],
|
12632 | setup(props2, {
|
12633 | emit,
|
12634 | slots
|
12635 | }) {
|
12636 | let reachTop;
|
12637 | const root = ref();
|
12638 | const track = ref();
|
12639 | const scrollParent = useScrollParent(root);
|
12640 | const state = reactive({
|
12641 | status: "normal",
|
12642 | distance: 0,
|
12643 | duration: 0
|
12644 | });
|
12645 | const touch = useTouch();
|
12646 | const getHeadStyle = () => {
|
12647 | if (props2.headHeight !== DEFAULT_HEAD_HEIGHT) {
|
12648 | return {
|
12649 | height: `${props2.headHeight}px`
|
12650 | };
|
12651 | }
|
12652 | };
|
12653 | const isTouchable = () => state.status !== "loading" && state.status !== "success" && !props2.disabled;
|
12654 | const ease = (distance) => {
|
12655 | const pullDistance = +(props2.pullDistance || props2.headHeight);
|
12656 | if (distance > pullDistance) {
|
12657 | if (distance < pullDistance * 2) {
|
12658 | distance = pullDistance + (distance - pullDistance) / 2;
|
12659 | } else {
|
12660 | distance = pullDistance * 1.5 + (distance - pullDistance * 2) / 4;
|
12661 | }
|
12662 | }
|
12663 | return Math.round(distance);
|
12664 | };
|
12665 | const setStatus = (distance, isLoading) => {
|
12666 | const pullDistance = +(props2.pullDistance || props2.headHeight);
|
12667 | state.distance = distance;
|
12668 | if (isLoading) {
|
12669 | state.status = "loading";
|
12670 | } else if (distance === 0) {
|
12671 | state.status = "normal";
|
12672 | } else if (distance < pullDistance) {
|
12673 | state.status = "pulling";
|
12674 | } else {
|
12675 | state.status = "loosing";
|
12676 | }
|
12677 | emit("change", {
|
12678 | status: state.status,
|
12679 | distance
|
12680 | });
|
12681 | };
|
12682 | const getStatusText = () => {
|
12683 | const {
|
12684 | status
|
12685 | } = state;
|
12686 | if (status === "normal") {
|
12687 | return "";
|
12688 | }
|
12689 | return props2[`${status}Text`] || t$5(status);
|
12690 | };
|
12691 | const renderStatus = () => {
|
12692 | const {
|
12693 | status,
|
12694 | distance
|
12695 | } = state;
|
12696 | if (slots[status]) {
|
12697 | return slots[status]({
|
12698 | distance
|
12699 | });
|
12700 | }
|
12701 | const nodes = [];
|
12702 | if (TEXT_STATUS.includes(status)) {
|
12703 | nodes.push(createVNode("div", {
|
12704 | "class": bem$q("text")
|
12705 | }, [getStatusText()]));
|
12706 | }
|
12707 | if (status === "loading") {
|
12708 | nodes.push(createVNode(Loading, {
|
12709 | "class": bem$q("loading")
|
12710 | }, {
|
12711 | default: getStatusText
|
12712 | }));
|
12713 | }
|
12714 | return nodes;
|
12715 | };
|
12716 | const showSuccessTip = () => {
|
12717 | state.status = "success";
|
12718 | setTimeout(() => {
|
12719 | setStatus(0);
|
12720 | }, +props2.successDuration);
|
12721 | };
|
12722 | const checkPosition = (event) => {
|
12723 | reachTop = getScrollTop(scrollParent.value) === 0;
|
12724 | if (reachTop) {
|
12725 | state.duration = 0;
|
12726 | touch.start(event);
|
12727 | }
|
12728 | };
|
12729 | const onTouchStart = (event) => {
|
12730 | if (isTouchable()) {
|
12731 | checkPosition(event);
|
12732 | }
|
12733 | };
|
12734 | const onTouchMove = (event) => {
|
12735 | if (isTouchable()) {
|
12736 | if (!reachTop) {
|
12737 | checkPosition(event);
|
12738 | }
|
12739 | const {
|
12740 | deltaY
|
12741 | } = touch;
|
12742 | touch.move(event);
|
12743 | if (reachTop && deltaY.value >= 0 && touch.isVertical()) {
|
12744 | preventDefault(event);
|
12745 | setStatus(ease(deltaY.value));
|
12746 | }
|
12747 | }
|
12748 | };
|
12749 | const onTouchEnd = () => {
|
12750 | if (reachTop && touch.deltaY.value && isTouchable()) {
|
12751 | state.duration = +props2.animationDuration;
|
12752 | if (state.status === "loosing") {
|
12753 | setStatus(+props2.headHeight, true);
|
12754 | emit("update:modelValue", true);
|
12755 | nextTick(() => emit("refresh"));
|
12756 | } else {
|
12757 | setStatus(0);
|
12758 | }
|
12759 | }
|
12760 | };
|
12761 | watch(() => props2.modelValue, (value) => {
|
12762 | state.duration = +props2.animationDuration;
|
12763 | if (value) {
|
12764 | setStatus(+props2.headHeight, true);
|
12765 | } else if (slots.success || props2.successText) {
|
12766 | showSuccessTip();
|
12767 | } else {
|
12768 | setStatus(0, false);
|
12769 | }
|
12770 | });
|
12771 | useEventListener("touchmove", onTouchMove, {
|
12772 | target: track
|
12773 | });
|
12774 | return () => {
|
12775 | var _a;
|
12776 | const trackStyle = {
|
12777 | transitionDuration: `${state.duration}ms`,
|
12778 | transform: state.distance ? `translate3d(0,${state.distance}px, 0)` : ""
|
12779 | };
|
12780 | return createVNode("div", {
|
12781 | "ref": root,
|
12782 | "class": bem$q()
|
12783 | }, [createVNode("div", {
|
12784 | "ref": track,
|
12785 | "class": bem$q("track"),
|
12786 | "style": trackStyle,
|
12787 | "onTouchstartPassive": onTouchStart,
|
12788 | "onTouchend": onTouchEnd,
|
12789 | "onTouchcancel": onTouchEnd
|
12790 | }, [createVNode("div", {
|
12791 | "class": bem$q("head"),
|
12792 | "style": getHeadStyle()
|
12793 | }, [renderStatus()]), (_a = slots.default) == null ? void 0 : _a.call(slots)])]);
|
12794 | };
|
12795 | }
|
12796 | });
|
12797 | const PullRefresh = withInstall(stdin_default$z);
|
12798 | const [name$q, bem$p] = createNamespace("rate");
|
12799 | function getRateStatus(value, index, allowHalf, readonly) {
|
12800 | if (value >= index) {
|
12801 | return {
|
12802 | status: "full",
|
12803 | value: 1
|
12804 | };
|
12805 | }
|
12806 | if (value + 0.5 >= index && allowHalf && !readonly) {
|
12807 | return {
|
12808 | status: "half",
|
12809 | value: 0.5
|
12810 | };
|
12811 | }
|
12812 | if (value + 1 >= index && allowHalf && readonly) {
|
12813 | const cardinal = 10 ** 10;
|
12814 | return {
|
12815 | status: "half",
|
12816 | value: Math.round((value - index + 1) * cardinal) / cardinal
|
12817 | };
|
12818 | }
|
12819 | return {
|
12820 | status: "void",
|
12821 | value: 0
|
12822 | };
|
12823 | }
|
12824 | const rateProps = {
|
12825 | size: numericProp,
|
12826 | icon: makeStringProp("star"),
|
12827 | color: String,
|
12828 | count: makeNumericProp(5),
|
12829 | gutter: numericProp,
|
12830 | clearable: Boolean,
|
12831 | readonly: Boolean,
|
12832 | disabled: Boolean,
|
12833 | voidIcon: makeStringProp("star-o"),
|
12834 | allowHalf: Boolean,
|
12835 | voidColor: String,
|
12836 | touchable: truthProp,
|
12837 | iconPrefix: String,
|
12838 | modelValue: makeNumberProp(0),
|
12839 | disabledColor: String
|
12840 | };
|
12841 | var stdin_default$y = defineComponent({
|
12842 | name: name$q,
|
12843 | props: rateProps,
|
12844 | emits: ["change", "update:modelValue"],
|
12845 | setup(props2, {
|
12846 | emit
|
12847 | }) {
|
12848 | const touch = useTouch();
|
12849 | const [itemRefs, setItemRefs] = useRefs();
|
12850 | const groupRef = ref();
|
12851 | const unselectable = computed(() => props2.readonly || props2.disabled);
|
12852 | const untouchable = computed(() => unselectable.value || !props2.touchable);
|
12853 | const list = computed(() => Array(+props2.count).fill("").map((_, i) => getRateStatus(props2.modelValue, i + 1, props2.allowHalf, props2.readonly)));
|
12854 | let ranges;
|
12855 | let groupRefRect;
|
12856 | let minRectTop = Number.MAX_SAFE_INTEGER;
|
12857 | let maxRectTop = Number.MIN_SAFE_INTEGER;
|
12858 | const updateRanges = () => {
|
12859 | groupRefRect = useRect(groupRef);
|
12860 | const rects = itemRefs.value.map(useRect);
|
12861 | ranges = [];
|
12862 | rects.forEach((rect, index) => {
|
12863 | minRectTop = Math.min(rect.top, minRectTop);
|
12864 | maxRectTop = Math.max(rect.top, maxRectTop);
|
12865 | if (props2.allowHalf) {
|
12866 | ranges.push({
|
12867 | score: index + 0.5,
|
12868 | left: rect.left,
|
12869 | top: rect.top,
|
12870 | height: rect.height
|
12871 | }, {
|
12872 | score: index + 1,
|
12873 | left: rect.left + rect.width / 2,
|
12874 | top: rect.top,
|
12875 | height: rect.height
|
12876 | });
|
12877 | } else {
|
12878 | ranges.push({
|
12879 | score: index + 1,
|
12880 | left: rect.left,
|
12881 | top: rect.top,
|
12882 | height: rect.height
|
12883 | });
|
12884 | }
|
12885 | });
|
12886 | };
|
12887 | const getScoreByPosition = (x, y) => {
|
12888 | for (let i = ranges.length - 1; i > 0; i--) {
|
12889 | if (y >= groupRefRect.top && y <= groupRefRect.bottom) {
|
12890 | if (x > ranges[i].left && y >= ranges[i].top && y <= ranges[i].top + ranges[i].height) {
|
12891 | return ranges[i].score;
|
12892 | }
|
12893 | } else {
|
12894 | const curTop = y < groupRefRect.top ? minRectTop : maxRectTop;
|
12895 | if (x > ranges[i].left && ranges[i].top === curTop) {
|
12896 | return ranges[i].score;
|
12897 | }
|
12898 | }
|
12899 | }
|
12900 | return props2.allowHalf ? 0.5 : 1;
|
12901 | };
|
12902 | const select = (value) => {
|
12903 | if (unselectable.value || value === props2.modelValue)
|
12904 | return;
|
12905 | emit("update:modelValue", value);
|
12906 | emit("change", value);
|
12907 | };
|
12908 | const onTouchStart = (event) => {
|
12909 | if (untouchable.value) {
|
12910 | return;
|
12911 | }
|
12912 | touch.start(event);
|
12913 | updateRanges();
|
12914 | };
|
12915 | const onTouchMove = (event) => {
|
12916 | if (untouchable.value) {
|
12917 | return;
|
12918 | }
|
12919 | touch.move(event);
|
12920 | if (touch.isHorizontal() && !touch.isTap.value) {
|
12921 | const {
|
12922 | clientX,
|
12923 | clientY
|
12924 | } = event.touches[0];
|
12925 | preventDefault(event);
|
12926 | select(getScoreByPosition(clientX, clientY));
|
12927 | }
|
12928 | };
|
12929 | const renderStar = (item, index) => {
|
12930 | const {
|
12931 | icon,
|
12932 | size,
|
12933 | color,
|
12934 | count,
|
12935 | gutter,
|
12936 | voidIcon,
|
12937 | disabled,
|
12938 | voidColor,
|
12939 | allowHalf,
|
12940 | iconPrefix,
|
12941 | disabledColor
|
12942 | } = props2;
|
12943 | const score = index + 1;
|
12944 | const isFull = item.status === "full";
|
12945 | const isVoid = item.status === "void";
|
12946 | const renderHalf = allowHalf && item.value > 0 && item.value < 1;
|
12947 | let style;
|
12948 | if (gutter && score !== +count) {
|
12949 | style = {
|
12950 | paddingRight: addUnit(gutter)
|
12951 | };
|
12952 | }
|
12953 | const onClickItem = (event) => {
|
12954 | updateRanges();
|
12955 | let value = allowHalf ? getScoreByPosition(event.clientX, event.clientY) : score;
|
12956 | if (props2.clearable && touch.isTap.value && value === props2.modelValue) {
|
12957 | value = 0;
|
12958 | }
|
12959 | select(value);
|
12960 | };
|
12961 | return createVNode("div", {
|
12962 | "key": index,
|
12963 | "ref": setItemRefs(index),
|
12964 | "role": "radio",
|
12965 | "style": style,
|
12966 | "class": bem$p("item"),
|
12967 | "tabindex": disabled ? void 0 : 0,
|
12968 | "aria-setsize": count,
|
12969 | "aria-posinset": score,
|
12970 | "aria-checked": !isVoid,
|
12971 | "onClick": onClickItem
|
12972 | }, [createVNode(Icon, {
|
12973 | "size": size,
|
12974 | "name": isFull ? icon : voidIcon,
|
12975 | "class": bem$p("icon", {
|
12976 | disabled,
|
12977 | full: isFull
|
12978 | }),
|
12979 | "color": disabled ? disabledColor : isFull ? color : voidColor,
|
12980 | "classPrefix": iconPrefix
|
12981 | }, null), renderHalf && createVNode(Icon, {
|
12982 | "size": size,
|
12983 | "style": {
|
12984 | width: item.value + "em"
|
12985 | },
|
12986 | "name": isVoid ? voidIcon : icon,
|
12987 | "class": bem$p("icon", ["half", {
|
12988 | disabled,
|
12989 | full: !isVoid
|
12990 | }]),
|
12991 | "color": disabled ? disabledColor : isVoid ? voidColor : color,
|
12992 | "classPrefix": iconPrefix
|
12993 | }, null)]);
|
12994 | };
|
12995 | useCustomFieldValue(() => props2.modelValue);
|
12996 | useEventListener("touchmove", onTouchMove, {
|
12997 | target: groupRef
|
12998 | });
|
12999 | return () => createVNode("div", {
|
13000 | "ref": groupRef,
|
13001 | "role": "radiogroup",
|
13002 | "class": bem$p({
|
13003 | readonly: props2.readonly,
|
13004 | disabled: props2.disabled
|
13005 | }),
|
13006 | "tabindex": props2.disabled ? void 0 : 0,
|
13007 | "aria-disabled": props2.disabled,
|
13008 | "aria-readonly": props2.readonly,
|
13009 | "onTouchstartPassive": onTouchStart
|
13010 | }, [list.value.map(renderStar)]);
|
13011 | }
|
13012 | });
|
13013 | const Rate = withInstall(stdin_default$y);
|
13014 | const props = {
|
13015 | figureArr: makeArrayProp(),
|
13016 | delay: Number,
|
13017 | duration: makeNumberProp(2),
|
13018 | isStart: Boolean,
|
13019 | direction: makeStringProp("down"),
|
13020 | height: makeNumberProp(40)
|
13021 | };
|
13022 | const [name$p, bem$o] = createNamespace("rolling-text-item");
|
13023 | var stdin_default$x = defineComponent({
|
13024 | name: name$p,
|
13025 | props,
|
13026 | setup(props2) {
|
13027 | const newFigureArr = computed(() => props2.direction === "down" ? props2.figureArr.slice().reverse() : props2.figureArr);
|
13028 | const translatePx = computed(() => {
|
13029 | const totalHeight = props2.height * (props2.figureArr.length - 1);
|
13030 | return `-${totalHeight}px`;
|
13031 | });
|
13032 | const itemStyle = computed(() => ({
|
13033 | lineHeight: addUnit(props2.height)
|
13034 | }));
|
13035 | const rootStyle = computed(() => ({
|
13036 | height: addUnit(props2.height),
|
13037 | "--van-translate": translatePx.value,
|
13038 | "--van-duration": props2.duration + "s",
|
13039 | "--van-delay": props2.delay + "s"
|
13040 | }));
|
13041 | return () => createVNode("div", {
|
13042 | "class": bem$o([props2.direction]),
|
13043 | "style": rootStyle.value
|
13044 | }, [createVNode("div", {
|
13045 | "class": bem$o("box", {
|
13046 | animate: props2.isStart
|
13047 | })
|
13048 | }, [Array.isArray(newFigureArr.value) && newFigureArr.value.map((figure) => createVNode("div", {
|
13049 | "class": bem$o("item"),
|
13050 | "style": itemStyle.value
|
13051 | }, [figure]))])]);
|
13052 | }
|
13053 | });
|
13054 | const [name$o, bem$n] = createNamespace("rolling-text");
|
13055 | const rollingTextProps = {
|
13056 | startNum: makeNumberProp(0),
|
13057 | targetNum: Number,
|
13058 | textList: makeArrayProp(),
|
13059 | duration: makeNumberProp(2),
|
13060 | autoStart: truthProp,
|
13061 | direction: makeStringProp("down"),
|
13062 | stopOrder: makeStringProp("ltr"),
|
13063 | height: makeNumberProp(40)
|
13064 | };
|
13065 | const CIRCLE_NUM = 2;
|
13066 | var stdin_default$w = defineComponent({
|
13067 | name: name$o,
|
13068 | props: rollingTextProps,
|
13069 | setup(props2) {
|
13070 | const isCustomType = computed(() => Array.isArray(props2.textList) && props2.textList.length);
|
13071 | const itemLength = computed(() => {
|
13072 | if (isCustomType.value)
|
13073 | return props2.textList[0].length;
|
13074 | return `${Math.max(props2.startNum, props2.targetNum)}`.length;
|
13075 | });
|
13076 | const getTextArrByIdx = (idx) => {
|
13077 | const result = [];
|
13078 | for (let i = 0; i < props2.textList.length; i++) {
|
13079 | result.push(props2.textList[i][idx]);
|
13080 | }
|
13081 | return result;
|
13082 | };
|
13083 | const targetNumArr = computed(() => {
|
13084 | if (isCustomType.value)
|
13085 | return new Array(itemLength.value).fill("");
|
13086 | return padZero(props2.targetNum, itemLength.value).split("");
|
13087 | });
|
13088 | const startNumArr = computed(() => padZero(props2.startNum, itemLength.value).split(""));
|
13089 | const getFigureArr = (i) => {
|
13090 | const start2 = +startNumArr.value[i];
|
13091 | const target = +targetNumArr.value[i];
|
13092 | const result = [];
|
13093 | for (let i2 = start2; i2 <= 9; i2++) {
|
13094 | result.push(i2);
|
13095 | }
|
13096 | for (let i2 = 0; i2 <= CIRCLE_NUM; i2++) {
|
13097 | for (let j = 0; j <= 9; j++) {
|
13098 | result.push(j);
|
13099 | }
|
13100 | }
|
13101 | for (let i2 = 0; i2 <= target; i2++) {
|
13102 | result.push(i2);
|
13103 | }
|
13104 | return result;
|
13105 | };
|
13106 | const getDelay = (i, len) => {
|
13107 | if (props2.stopOrder === "ltr")
|
13108 | return 0.2 * i;
|
13109 | return 0.2 * (len - 1 - i);
|
13110 | };
|
13111 | const rolling = ref(props2.autoStart);
|
13112 | const start = () => {
|
13113 | rolling.value = true;
|
13114 | };
|
13115 | const reset = () => {
|
13116 | rolling.value = false;
|
13117 | if (props2.autoStart) {
|
13118 | raf(() => start());
|
13119 | }
|
13120 | };
|
13121 | watch(() => props2.autoStart, (value) => {
|
13122 | if (value) {
|
13123 | start();
|
13124 | }
|
13125 | });
|
13126 | useExpose({
|
13127 | start,
|
13128 | reset
|
13129 | });
|
13130 | return () => createVNode("div", {
|
13131 | "class": bem$n()
|
13132 | }, [targetNumArr.value.map((_, i) => createVNode(stdin_default$x, {
|
13133 | "figureArr": isCustomType.value ? getTextArrByIdx(i) : getFigureArr(i),
|
13134 | "duration": props2.duration,
|
13135 | "direction": props2.direction,
|
13136 | "isStart": rolling.value,
|
13137 | "height": props2.height,
|
13138 | "delay": getDelay(i, itemLength.value)
|
13139 | }, null))]);
|
13140 | }
|
13141 | });
|
13142 | const RollingText = withInstall(stdin_default$w);
|
13143 | const Row = withInstall(stdin_default$17);
|
13144 | const [name$n, bem$m, t$4] = createNamespace("search");
|
13145 | const searchProps = extend({}, fieldSharedProps, {
|
13146 | label: String,
|
13147 | shape: makeStringProp("square"),
|
13148 | leftIcon: makeStringProp("search"),
|
13149 | clearable: truthProp,
|
13150 | actionText: String,
|
13151 | background: String,
|
13152 | showAction: Boolean
|
13153 | });
|
13154 | var stdin_default$v = defineComponent({
|
13155 | name: name$n,
|
13156 | props: searchProps,
|
13157 | emits: ["blur", "focus", "clear", "search", "cancel", "clickInput", "clickLeftIcon", "clickRightIcon", "update:modelValue"],
|
13158 | setup(props2, {
|
13159 | emit,
|
13160 | slots,
|
13161 | attrs
|
13162 | }) {
|
13163 | const id = useId();
|
13164 | const fieldRef = ref();
|
13165 | const onCancel = () => {
|
13166 | if (!slots.action) {
|
13167 | emit("update:modelValue", "");
|
13168 | emit("cancel");
|
13169 | }
|
13170 | };
|
13171 | const onKeypress = (event) => {
|
13172 | const ENTER_CODE = 13;
|
13173 | if (event.keyCode === ENTER_CODE) {
|
13174 | preventDefault(event);
|
13175 | emit("search", props2.modelValue);
|
13176 | }
|
13177 | };
|
13178 | const getInputId = () => props2.id || `${id}-input`;
|
13179 | const renderLabel = () => {
|
13180 | if (slots.label || props2.label) {
|
13181 | return createVNode("label", {
|
13182 | "class": bem$m("label"),
|
13183 | "for": getInputId()
|
13184 | }, [slots.label ? slots.label() : props2.label]);
|
13185 | }
|
13186 | };
|
13187 | const renderAction = () => {
|
13188 | if (props2.showAction) {
|
13189 | const text = props2.actionText || t$4("cancel");
|
13190 | return createVNode("div", {
|
13191 | "class": bem$m("action"),
|
13192 | "role": "button",
|
13193 | "tabindex": 0,
|
13194 | "onClick": onCancel
|
13195 | }, [slots.action ? slots.action() : text]);
|
13196 | }
|
13197 | };
|
13198 | const blur = () => {
|
13199 | var _a;
|
13200 | return (_a = fieldRef.value) == null ? void 0 : _a.blur();
|
13201 | };
|
13202 | const focus = () => {
|
13203 | var _a;
|
13204 | return (_a = fieldRef.value) == null ? void 0 : _a.focus();
|
13205 | };
|
13206 | const onBlur = (event) => emit("blur", event);
|
13207 | const onFocus = (event) => emit("focus", event);
|
13208 | const onClear = (event) => emit("clear", event);
|
13209 | const onClickInput = (event) => emit("clickInput", event);
|
13210 | const onClickLeftIcon = (event) => emit("clickLeftIcon", event);
|
13211 | const onClickRightIcon = (event) => emit("clickRightIcon", event);
|
13212 | const fieldPropNames = Object.keys(fieldSharedProps);
|
13213 | const renderField = () => {
|
13214 | const fieldAttrs = extend({}, attrs, pick(props2, fieldPropNames), {
|
13215 | id: getInputId()
|
13216 | });
|
13217 | const onInput = (value) => emit("update:modelValue", value);
|
13218 | return createVNode(Field, mergeProps({
|
13219 | "ref": fieldRef,
|
13220 | "type": "search",
|
13221 | "class": bem$m("field", {
|
13222 | "with-message": fieldAttrs.errorMessage
|
13223 | }),
|
13224 | "border": false,
|
13225 | "onBlur": onBlur,
|
13226 | "onFocus": onFocus,
|
13227 | "onClear": onClear,
|
13228 | "onKeypress": onKeypress,
|
13229 | "onClickInput": onClickInput,
|
13230 | "onClickLeftIcon": onClickLeftIcon,
|
13231 | "onClickRightIcon": onClickRightIcon,
|
13232 | "onUpdate:modelValue": onInput
|
13233 | }, fieldAttrs), pick(slots, ["left-icon", "right-icon"]));
|
13234 | };
|
13235 | useExpose({
|
13236 | focus,
|
13237 | blur
|
13238 | });
|
13239 | return () => {
|
13240 | var _a;
|
13241 | return createVNode("div", {
|
13242 | "class": bem$m({
|
13243 | "show-action": props2.showAction
|
13244 | }),
|
13245 | "style": {
|
13246 | background: props2.background
|
13247 | }
|
13248 | }, [(_a = slots.left) == null ? void 0 : _a.call(slots), createVNode("div", {
|
13249 | "class": bem$m("content", props2.shape)
|
13250 | }, [renderLabel(), renderField()]), renderAction()]);
|
13251 | };
|
13252 | }
|
13253 | });
|
13254 | const Search = withInstall(stdin_default$v);
|
13255 | const isImage = (name2) => name2 == null ? void 0 : name2.includes("/");
|
13256 | const popupInheritKeys = [...popupSharedPropKeys, "round", "closeOnPopstate", "safeAreaInsetBottom"];
|
13257 | const iconMap = {
|
13258 | qq: "qq",
|
13259 | link: "link-o",
|
13260 | weibo: "weibo",
|
13261 | qrcode: "qr",
|
13262 | poster: "photo-o",
|
13263 | wechat: "wechat",
|
13264 | "weapp-qrcode": "miniprogram-o",
|
13265 | "wechat-moments": "wechat-moments"
|
13266 | };
|
13267 | const [name$m, bem$l, t$3] = createNamespace("share-sheet");
|
13268 | const shareSheetProps = extend({}, popupSharedProps, {
|
13269 | title: String,
|
13270 | round: truthProp,
|
13271 | options: makeArrayProp(),
|
13272 | cancelText: String,
|
13273 | description: String,
|
13274 | closeOnPopstate: truthProp,
|
13275 | safeAreaInsetBottom: truthProp
|
13276 | });
|
13277 | var stdin_default$u = defineComponent({
|
13278 | name: name$m,
|
13279 | props: shareSheetProps,
|
13280 | emits: ["cancel", "select", "update:show"],
|
13281 | setup(props2, {
|
13282 | emit,
|
13283 | slots
|
13284 | }) {
|
13285 | const updateShow = (value) => emit("update:show", value);
|
13286 | const onCancel = () => {
|
13287 | updateShow(false);
|
13288 | emit("cancel");
|
13289 | };
|
13290 | const onSelect = (option, index) => emit("select", option, index);
|
13291 | const renderHeader = () => {
|
13292 | const title = slots.title ? slots.title() : props2.title;
|
13293 | const description = slots.description ? slots.description() : props2.description;
|
13294 | if (title || description) {
|
13295 | return createVNode("div", {
|
13296 | "class": bem$l("header")
|
13297 | }, [title && createVNode("h2", {
|
13298 | "class": bem$l("title")
|
13299 | }, [title]), description && createVNode("span", {
|
13300 | "class": bem$l("description")
|
13301 | }, [description])]);
|
13302 | }
|
13303 | };
|
13304 | const renderIcon = (icon) => {
|
13305 | if (isImage(icon)) {
|
13306 | return createVNode("img", {
|
13307 | "src": icon,
|
13308 | "class": bem$l("image-icon")
|
13309 | }, null);
|
13310 | }
|
13311 | return createVNode("div", {
|
13312 | "class": bem$l("icon", [icon])
|
13313 | }, [createVNode(Icon, {
|
13314 | "name": iconMap[icon] || icon
|
13315 | }, null)]);
|
13316 | };
|
13317 | const renderOption = (option, index) => {
|
13318 | const {
|
13319 | name: name2,
|
13320 | icon,
|
13321 | className,
|
13322 | description
|
13323 | } = option;
|
13324 | return createVNode("div", {
|
13325 | "role": "button",
|
13326 | "tabindex": 0,
|
13327 | "class": [bem$l("option"), className, HAPTICS_FEEDBACK],
|
13328 | "onClick": () => onSelect(option, index)
|
13329 | }, [renderIcon(icon), name2 && createVNode("span", {
|
13330 | "class": bem$l("name")
|
13331 | }, [name2]), description && createVNode("span", {
|
13332 | "class": bem$l("option-description")
|
13333 | }, [description])]);
|
13334 | };
|
13335 | const renderOptions = (options, border) => createVNode("div", {
|
13336 | "class": bem$l("options", {
|
13337 | border
|
13338 | })
|
13339 | }, [options.map(renderOption)]);
|
13340 | const renderRows = () => {
|
13341 | const {
|
13342 | options
|
13343 | } = props2;
|
13344 | if (Array.isArray(options[0])) {
|
13345 | return options.map((item, index) => renderOptions(item, index !== 0));
|
13346 | }
|
13347 | return renderOptions(options);
|
13348 | };
|
13349 | const renderCancelButton = () => {
|
13350 | var _a;
|
13351 | const cancelText = (_a = props2.cancelText) != null ? _a : t$3("cancel");
|
13352 | if (slots.cancel || cancelText) {
|
13353 | return createVNode("button", {
|
13354 | "type": "button",
|
13355 | "class": bem$l("cancel"),
|
13356 | "onClick": onCancel
|
13357 | }, [slots.cancel ? slots.cancel() : cancelText]);
|
13358 | }
|
13359 | };
|
13360 | return () => createVNode(Popup, mergeProps({
|
13361 | "class": bem$l(),
|
13362 | "position": "bottom",
|
13363 | "onUpdate:show": updateShow
|
13364 | }, pick(props2, popupInheritKeys)), {
|
13365 | default: () => [renderHeader(), renderRows(), renderCancelButton()]
|
13366 | });
|
13367 | }
|
13368 | });
|
13369 | const ShareSheet = withInstall(stdin_default$u);
|
13370 | const [name$l, bem$k] = createNamespace("sidebar");
|
13371 | const SIDEBAR_KEY = Symbol(name$l);
|
13372 | const sidebarProps = {
|
13373 | modelValue: makeNumericProp(0)
|
13374 | };
|
13375 | var stdin_default$t = defineComponent({
|
13376 | name: name$l,
|
13377 | props: sidebarProps,
|
13378 | emits: ["change", "update:modelValue"],
|
13379 | setup(props2, {
|
13380 | emit,
|
13381 | slots
|
13382 | }) {
|
13383 | const {
|
13384 | linkChildren
|
13385 | } = useChildren(SIDEBAR_KEY);
|
13386 | const getActive = () => +props2.modelValue;
|
13387 | const setActive = (value) => {
|
13388 | if (value !== getActive()) {
|
13389 | emit("update:modelValue", value);
|
13390 | emit("change", value);
|
13391 | }
|
13392 | };
|
13393 | linkChildren({
|
13394 | getActive,
|
13395 | setActive
|
13396 | });
|
13397 | return () => {
|
13398 | var _a;
|
13399 | return createVNode("div", {
|
13400 | "role": "tablist",
|
13401 | "class": bem$k()
|
13402 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
13403 | };
|
13404 | }
|
13405 | });
|
13406 | const Sidebar = withInstall(stdin_default$t);
|
13407 | const [name$k, bem$j] = createNamespace("sidebar-item");
|
13408 | const sidebarItemProps = extend({}, routeProps, {
|
13409 | dot: Boolean,
|
13410 | title: String,
|
13411 | badge: numericProp,
|
13412 | disabled: Boolean,
|
13413 | badgeProps: Object
|
13414 | });
|
13415 | var stdin_default$s = defineComponent({
|
13416 | name: name$k,
|
13417 | props: sidebarItemProps,
|
13418 | emits: ["click"],
|
13419 | setup(props2, {
|
13420 | emit,
|
13421 | slots
|
13422 | }) {
|
13423 | const route2 = useRoute();
|
13424 | const {
|
13425 | parent,
|
13426 | index
|
13427 | } = useParent(SIDEBAR_KEY);
|
13428 | if (!parent) {
|
13429 | if (process.env.NODE_ENV !== "production") {
|
13430 | console.error("[Vant] <SidebarItem> must be a child component of <Sidebar>.");
|
13431 | }
|
13432 | return;
|
13433 | }
|
13434 | const onClick = () => {
|
13435 | if (props2.disabled) {
|
13436 | return;
|
13437 | }
|
13438 | emit("click", index.value);
|
13439 | parent.setActive(index.value);
|
13440 | route2();
|
13441 | };
|
13442 | return () => {
|
13443 | const {
|
13444 | dot,
|
13445 | badge,
|
13446 | title,
|
13447 | disabled
|
13448 | } = props2;
|
13449 | const selected = index.value === parent.getActive();
|
13450 | return createVNode("div", {
|
13451 | "role": "tab",
|
13452 | "class": bem$j({
|
13453 | select: selected,
|
13454 | disabled
|
13455 | }),
|
13456 | "tabindex": disabled ? void 0 : 0,
|
13457 | "aria-selected": selected,
|
13458 | "onClick": onClick
|
13459 | }, [createVNode(Badge, mergeProps({
|
13460 | "dot": dot,
|
13461 | "class": bem$j("text"),
|
13462 | "content": badge
|
13463 | }, props2.badgeProps), {
|
13464 | default: () => [slots.title ? slots.title() : title]
|
13465 | })]);
|
13466 | };
|
13467 | }
|
13468 | });
|
13469 | const SidebarItem = withInstall(stdin_default$s);
|
13470 | const [name$j, bem$i, t$2] = createNamespace("signature");
|
13471 | const signatureProps = {
|
13472 | tips: String,
|
13473 | type: makeStringProp("png"),
|
13474 | penColor: makeStringProp("#000"),
|
13475 | lineWidth: makeNumberProp(3),
|
13476 | clearButtonText: String,
|
13477 | backgroundColor: makeStringProp(""),
|
13478 | confirmButtonText: String
|
13479 | };
|
13480 | const hasCanvasSupport = () => {
|
13481 | var _a;
|
13482 | const canvas = document.createElement("canvas");
|
13483 | return !!((_a = canvas.getContext) == null ? void 0 : _a.call(canvas, "2d"));
|
13484 | };
|
13485 | var stdin_default$r = defineComponent({
|
13486 | name: name$j,
|
13487 | props: signatureProps,
|
13488 | emits: ["submit", "clear", "start", "end", "signing"],
|
13489 | setup(props2, {
|
13490 | emit
|
13491 | }) {
|
13492 | const canvasRef = ref();
|
13493 | const wrapRef = ref();
|
13494 | const ctx = computed(() => {
|
13495 | if (!canvasRef.value)
|
13496 | return null;
|
13497 | return canvasRef.value.getContext("2d");
|
13498 | });
|
13499 | const isRenderCanvas = inBrowser ? hasCanvasSupport() : true;
|
13500 | let canvasWidth = 0;
|
13501 | let canvasHeight = 0;
|
13502 | let canvasRect;
|
13503 | const touchStart = () => {
|
13504 | if (!ctx.value) {
|
13505 | return false;
|
13506 | }
|
13507 | ctx.value.beginPath();
|
13508 | ctx.value.lineWidth = props2.lineWidth;
|
13509 | ctx.value.strokeStyle = props2.penColor;
|
13510 | canvasRect = useRect(canvasRef);
|
13511 | emit("start");
|
13512 | };
|
13513 | const touchMove = (event) => {
|
13514 | if (!ctx.value) {
|
13515 | return false;
|
13516 | }
|
13517 | preventDefault(event);
|
13518 | const touch = event.touches[0];
|
13519 | const mouseX = touch.clientX - ((canvasRect == null ? void 0 : canvasRect.left) || 0);
|
13520 | const mouseY = touch.clientY - ((canvasRect == null ? void 0 : canvasRect.top) || 0);
|
13521 | ctx.value.lineCap = "round";
|
13522 | ctx.value.lineJoin = "round";
|
13523 | ctx.value.lineTo(mouseX, mouseY);
|
13524 | ctx.value.stroke();
|
13525 | emit("signing", event);
|
13526 | };
|
13527 | const touchEnd = (event) => {
|
13528 | preventDefault(event);
|
13529 | emit("end");
|
13530 | };
|
13531 | const isCanvasEmpty = (canvas) => {
|
13532 | const empty = document.createElement("canvas");
|
13533 | empty.width = canvas.width;
|
13534 | empty.height = canvas.height;
|
13535 | if (props2.backgroundColor) {
|
13536 | const emptyCtx = empty.getContext("2d");
|
13537 | setCanvasBgColor(emptyCtx);
|
13538 | }
|
13539 | return canvas.toDataURL() === empty.toDataURL();
|
13540 | };
|
13541 | const setCanvasBgColor = (ctx2) => {
|
13542 | if (ctx2 && props2.backgroundColor) {
|
13543 | ctx2.fillStyle = props2.backgroundColor;
|
13544 | ctx2.fillRect(0, 0, canvasWidth, canvasHeight);
|
13545 | }
|
13546 | };
|
13547 | const submit = () => {
|
13548 | var _a, _b;
|
13549 | const canvas = canvasRef.value;
|
13550 | if (!canvas) {
|
13551 | return;
|
13552 | }
|
13553 | const isEmpty = isCanvasEmpty(canvas);
|
13554 | const image = isEmpty ? "" : ((_b = (_a = {
|
13555 | jpg: () => canvas.toDataURL("image/jpeg", 0.8),
|
13556 | jpeg: () => canvas.toDataURL("image/jpeg", 0.8)
|
13557 | })[props2.type]) == null ? void 0 : _b.call(_a)) || canvas.toDataURL(`image/${props2.type}`);
|
13558 | emit("submit", {
|
13559 | image,
|
13560 | canvas
|
13561 | });
|
13562 | };
|
13563 | const clear = () => {
|
13564 | if (ctx.value) {
|
13565 | ctx.value.clearRect(0, 0, canvasWidth, canvasHeight);
|
13566 | ctx.value.closePath();
|
13567 | setCanvasBgColor(ctx.value);
|
13568 | }
|
13569 | emit("clear");
|
13570 | };
|
13571 | const initialize = () => {
|
13572 | var _a, _b, _c;
|
13573 | if (isRenderCanvas && canvasRef.value) {
|
13574 | const canvas = canvasRef.value;
|
13575 | const dpr = inBrowser ? window.devicePixelRatio : 1;
|
13576 | canvasWidth = canvas.width = (((_a = wrapRef.value) == null ? void 0 : _a.offsetWidth) || 0) * dpr;
|
13577 | canvasHeight = canvas.height = (((_b = wrapRef.value) == null ? void 0 : _b.offsetHeight) || 0) * dpr;
|
13578 | (_c = ctx.value) == null ? void 0 : _c.scale(dpr, dpr);
|
13579 | setCanvasBgColor(ctx.value);
|
13580 | }
|
13581 | };
|
13582 | const resize = () => {
|
13583 | if (ctx.value) {
|
13584 | const data = ctx.value.getImageData(0, 0, canvasWidth, canvasHeight);
|
13585 | initialize();
|
13586 | ctx.value.putImageData(data, 0, 0);
|
13587 | }
|
13588 | };
|
13589 | watch(windowWidth, resize);
|
13590 | onMounted(initialize);
|
13591 | useExpose({
|
13592 | resize,
|
13593 | clear,
|
13594 | submit
|
13595 | });
|
13596 | return () => createVNode("div", {
|
13597 | "class": bem$i()
|
13598 | }, [createVNode("div", {
|
13599 | "class": bem$i("content"),
|
13600 | "ref": wrapRef
|
13601 | }, [isRenderCanvas ? createVNode("canvas", {
|
13602 | "ref": canvasRef,
|
13603 | "onTouchstartPassive": touchStart,
|
13604 | "onTouchmove": touchMove,
|
13605 | "onTouchend": touchEnd
|
13606 | }, null) : createVNode("p", null, [props2.tips])]), createVNode("div", {
|
13607 | "class": bem$i("footer")
|
13608 | }, [createVNode(Button, {
|
13609 | "size": "small",
|
13610 | "onClick": clear
|
13611 | }, {
|
13612 | default: () => [props2.clearButtonText || t$2("clear")]
|
13613 | }), createVNode(Button, {
|
13614 | "type": "primary",
|
13615 | "size": "small",
|
13616 | "onClick": submit
|
13617 | }, {
|
13618 | default: () => [props2.confirmButtonText || t$2("confirm")]
|
13619 | })])]);
|
13620 | }
|
13621 | });
|
13622 | const Signature = withInstall(stdin_default$r);
|
13623 | const [name$i, bem$h] = createNamespace("skeleton-title");
|
13624 | const skeletonTitleProps = {
|
13625 | round: Boolean,
|
13626 | titleWidth: numericProp
|
13627 | };
|
13628 | var stdin_default$q = defineComponent({
|
13629 | name: name$i,
|
13630 | props: skeletonTitleProps,
|
13631 | setup(props2) {
|
13632 | return () => createVNode("h3", {
|
13633 | "class": bem$h([{
|
13634 | round: props2.round
|
13635 | }]),
|
13636 | "style": {
|
13637 | width: addUnit(props2.titleWidth)
|
13638 | }
|
13639 | }, null);
|
13640 | }
|
13641 | });
|
13642 | const SkeletonTitle = withInstall(stdin_default$q);
|
13643 | var stdin_default$p = SkeletonTitle;
|
13644 | const [name$h, bem$g] = createNamespace("skeleton-avatar");
|
13645 | const skeletonAvatarProps = {
|
13646 | avatarSize: numericProp,
|
13647 | avatarShape: makeStringProp("round")
|
13648 | };
|
13649 | var stdin_default$o = defineComponent({
|
13650 | name: name$h,
|
13651 | props: skeletonAvatarProps,
|
13652 | setup(props2) {
|
13653 | return () => createVNode("div", {
|
13654 | "class": bem$g([props2.avatarShape]),
|
13655 | "style": getSizeStyle(props2.avatarSize)
|
13656 | }, null);
|
13657 | }
|
13658 | });
|
13659 | const SkeletonAvatar = withInstall(stdin_default$o);
|
13660 | var stdin_default$n = SkeletonAvatar;
|
13661 | const DEFAULT_ROW_WIDTH = "100%";
|
13662 | const skeletonParagraphProps = {
|
13663 | round: Boolean,
|
13664 | rowWidth: {
|
13665 | type: numericProp,
|
13666 | default: DEFAULT_ROW_WIDTH
|
13667 | }
|
13668 | };
|
13669 | const [name$g, bem$f] = createNamespace("skeleton-paragraph");
|
13670 | var stdin_default$m = defineComponent({
|
13671 | name: name$g,
|
13672 | props: skeletonParagraphProps,
|
13673 | setup(props2) {
|
13674 | return () => createVNode("div", {
|
13675 | "class": bem$f([{
|
13676 | round: props2.round
|
13677 | }]),
|
13678 | "style": {
|
13679 | width: props2.rowWidth
|
13680 | }
|
13681 | }, null);
|
13682 | }
|
13683 | });
|
13684 | const SkeletonParagraph = withInstall(stdin_default$m);
|
13685 | var stdin_default$l = SkeletonParagraph;
|
13686 | const [name$f, bem$e] = createNamespace("skeleton");
|
13687 | const DEFAULT_LAST_ROW_WIDTH = "60%";
|
13688 | const skeletonProps = {
|
13689 | row: makeNumericProp(0),
|
13690 | round: Boolean,
|
13691 | title: Boolean,
|
13692 | titleWidth: numericProp,
|
13693 | avatar: Boolean,
|
13694 | avatarSize: numericProp,
|
13695 | avatarShape: makeStringProp("round"),
|
13696 | loading: truthProp,
|
13697 | animate: truthProp,
|
13698 | rowWidth: {
|
13699 | type: [Number, String, Array],
|
13700 | default: DEFAULT_ROW_WIDTH
|
13701 | }
|
13702 | };
|
13703 | var stdin_default$k = defineComponent({
|
13704 | name: name$f,
|
13705 | inheritAttrs: false,
|
13706 | props: skeletonProps,
|
13707 | setup(props2, {
|
13708 | slots,
|
13709 | attrs
|
13710 | }) {
|
13711 | const renderAvatar = () => {
|
13712 | if (props2.avatar) {
|
13713 | return createVNode(stdin_default$n, {
|
13714 | "avatarShape": props2.avatarShape,
|
13715 | "avatarSize": props2.avatarSize
|
13716 | }, null);
|
13717 | }
|
13718 | };
|
13719 | const renderTitle = () => {
|
13720 | if (props2.title) {
|
13721 | return createVNode(stdin_default$p, {
|
13722 | "round": props2.round,
|
13723 | "titleWidth": props2.titleWidth
|
13724 | }, null);
|
13725 | }
|
13726 | };
|
13727 | const getRowWidth = (index) => {
|
13728 | const {
|
13729 | rowWidth
|
13730 | } = props2;
|
13731 | if (rowWidth === DEFAULT_ROW_WIDTH && index === +props2.row - 1) {
|
13732 | return DEFAULT_LAST_ROW_WIDTH;
|
13733 | }
|
13734 | if (Array.isArray(rowWidth)) {
|
13735 | return rowWidth[index];
|
13736 | }
|
13737 | return rowWidth;
|
13738 | };
|
13739 | const renderRows = () => Array(+props2.row).fill("").map((_, i) => createVNode(stdin_default$l, {
|
13740 | "key": i,
|
13741 | "round": props2.round,
|
13742 | "rowWidth": addUnit(getRowWidth(i))
|
13743 | }, null));
|
13744 | const renderContents = () => {
|
13745 | if (slots.template) {
|
13746 | return slots.template();
|
13747 | }
|
13748 | return createVNode(Fragment, null, [renderAvatar(), createVNode("div", {
|
13749 | "class": bem$e("content")
|
13750 | }, [renderTitle(), renderRows()])]);
|
13751 | };
|
13752 | return () => {
|
13753 | var _a;
|
13754 | if (!props2.loading) {
|
13755 | return (_a = slots.default) == null ? void 0 : _a.call(slots);
|
13756 | }
|
13757 | return createVNode("div", mergeProps({
|
13758 | "class": bem$e({
|
13759 | animate: props2.animate,
|
13760 | round: props2.round
|
13761 | })
|
13762 | }, attrs), [renderContents()]);
|
13763 | };
|
13764 | }
|
13765 | });
|
13766 | const Skeleton = withInstall(stdin_default$k);
|
13767 | const [name$e, bem$d] = createNamespace("skeleton-image");
|
13768 | const skeletonImageProps = {
|
13769 | imageSize: numericProp,
|
13770 | imageShape: makeStringProp("square")
|
13771 | };
|
13772 | var stdin_default$j = defineComponent({
|
13773 | name: name$e,
|
13774 | props: skeletonImageProps,
|
13775 | setup(props2) {
|
13776 | return () => createVNode("div", {
|
13777 | "class": bem$d([props2.imageShape]),
|
13778 | "style": getSizeStyle(props2.imageSize)
|
13779 | }, [createVNode(Icon, {
|
13780 | "name": "photo",
|
13781 | "class": bem$d("icon")
|
13782 | }, null)]);
|
13783 | }
|
13784 | });
|
13785 | const SkeletonImage = withInstall(stdin_default$j);
|
13786 | const [name$d, bem$c] = createNamespace("slider");
|
13787 | const sliderProps = {
|
13788 | min: makeNumericProp(0),
|
13789 | max: makeNumericProp(100),
|
13790 | step: makeNumericProp(1),
|
13791 | range: Boolean,
|
13792 | reverse: Boolean,
|
13793 | disabled: Boolean,
|
13794 | readonly: Boolean,
|
13795 | vertical: Boolean,
|
13796 | barHeight: numericProp,
|
13797 | buttonSize: numericProp,
|
13798 | activeColor: String,
|
13799 | inactiveColor: String,
|
13800 | modelValue: {
|
13801 | type: [Number, Array],
|
13802 | default: 0
|
13803 | }
|
13804 | };
|
13805 | var stdin_default$i = defineComponent({
|
13806 | name: name$d,
|
13807 | props: sliderProps,
|
13808 | emits: ["change", "dragEnd", "dragStart", "update:modelValue"],
|
13809 | setup(props2, {
|
13810 | emit,
|
13811 | slots
|
13812 | }) {
|
13813 | let buttonIndex;
|
13814 | let current2;
|
13815 | let startValue;
|
13816 | const root = ref();
|
13817 | const slider = [ref(), ref()];
|
13818 | const dragStatus = ref();
|
13819 | const touch = useTouch();
|
13820 | const scope = computed(() => Number(props2.max) - Number(props2.min));
|
13821 | const wrapperStyle = computed(() => {
|
13822 | const crossAxis = props2.vertical ? "width" : "height";
|
13823 | return {
|
13824 | background: props2.inactiveColor,
|
13825 | [crossAxis]: addUnit(props2.barHeight)
|
13826 | };
|
13827 | });
|
13828 | const isRange = (val) => props2.range && Array.isArray(val);
|
13829 | const calcMainAxis = () => {
|
13830 | const {
|
13831 | modelValue,
|
13832 | min
|
13833 | } = props2;
|
13834 | if (isRange(modelValue)) {
|
13835 | return `${(modelValue[1] - modelValue[0]) * 100 / scope.value}%`;
|
13836 | }
|
13837 | return `${(modelValue - Number(min)) * 100 / scope.value}%`;
|
13838 | };
|
13839 | const calcOffset = () => {
|
13840 | const {
|
13841 | modelValue,
|
13842 | min
|
13843 | } = props2;
|
13844 | if (isRange(modelValue)) {
|
13845 | return `${(modelValue[0] - Number(min)) * 100 / scope.value}%`;
|
13846 | }
|
13847 | return "0%";
|
13848 | };
|
13849 | const barStyle = computed(() => {
|
13850 | const mainAxis = props2.vertical ? "height" : "width";
|
13851 | const style = {
|
13852 | [mainAxis]: calcMainAxis(),
|
13853 | background: props2.activeColor
|
13854 | };
|
13855 | if (dragStatus.value) {
|
13856 | style.transition = "none";
|
13857 | }
|
13858 | const getPositionKey = () => {
|
13859 | if (props2.vertical) {
|
13860 | return props2.reverse ? "bottom" : "top";
|
13861 | }
|
13862 | return props2.reverse ? "right" : "left";
|
13863 | };
|
13864 | style[getPositionKey()] = calcOffset();
|
13865 | return style;
|
13866 | });
|
13867 | const format2 = (value) => {
|
13868 | const min = +props2.min;
|
13869 | const max = +props2.max;
|
13870 | const step = +props2.step;
|
13871 | value = clamp(value, min, max);
|
13872 | const diff = Math.round((value - min) / step) * step;
|
13873 | return addNumber(min, diff);
|
13874 | };
|
13875 | const updateStartValue = () => {
|
13876 | const current22 = props2.modelValue;
|
13877 | if (isRange(current22)) {
|
13878 | startValue = current22.map(format2);
|
13879 | } else {
|
13880 | startValue = format2(current22);
|
13881 | }
|
13882 | };
|
13883 | const handleRangeValue = (value) => {
|
13884 | var _a, _b;
|
13885 | const left = (_a = value[0]) != null ? _a : Number(props2.min);
|
13886 | const right = (_b = value[1]) != null ? _b : Number(props2.max);
|
13887 | return left > right ? [right, left] : [left, right];
|
13888 | };
|
13889 | const updateValue = (value, end) => {
|
13890 | if (isRange(value)) {
|
13891 | value = handleRangeValue(value).map(format2);
|
13892 | } else {
|
13893 | value = format2(value);
|
13894 | }
|
13895 | if (!isSameValue(value, props2.modelValue)) {
|
13896 | emit("update:modelValue", value);
|
13897 | }
|
13898 | if (end && !isSameValue(value, startValue)) {
|
13899 | emit("change", value);
|
13900 | }
|
13901 | };
|
13902 | const onClick = (event) => {
|
13903 | event.stopPropagation();
|
13904 | if (props2.disabled || props2.readonly) {
|
13905 | return;
|
13906 | }
|
13907 | updateStartValue();
|
13908 | const {
|
13909 | min,
|
13910 | reverse,
|
13911 | vertical,
|
13912 | modelValue
|
13913 | } = props2;
|
13914 | const rect = useRect(root);
|
13915 | const getDelta = () => {
|
13916 | if (vertical) {
|
13917 | if (reverse) {
|
13918 | return rect.bottom - event.clientY;
|
13919 | }
|
13920 | return event.clientY - rect.top;
|
13921 | }
|
13922 | if (reverse) {
|
13923 | return rect.right - event.clientX;
|
13924 | }
|
13925 | return event.clientX - rect.left;
|
13926 | };
|
13927 | const total = vertical ? rect.height : rect.width;
|
13928 | const value = Number(min) + getDelta() / total * scope.value;
|
13929 | if (isRange(modelValue)) {
|
13930 | const [left, right] = modelValue;
|
13931 | const middle = (left + right) / 2;
|
13932 | if (value <= middle) {
|
13933 | updateValue([value, right], true);
|
13934 | } else {
|
13935 | updateValue([left, value], true);
|
13936 | }
|
13937 | } else {
|
13938 | updateValue(value, true);
|
13939 | }
|
13940 | };
|
13941 | const onTouchStart = (event) => {
|
13942 | if (props2.disabled || props2.readonly) {
|
13943 | return;
|
13944 | }
|
13945 | touch.start(event);
|
13946 | current2 = props2.modelValue;
|
13947 | updateStartValue();
|
13948 | dragStatus.value = "start";
|
13949 | };
|
13950 | const onTouchMove = (event) => {
|
13951 | if (props2.disabled || props2.readonly) {
|
13952 | return;
|
13953 | }
|
13954 | if (dragStatus.value === "start") {
|
13955 | emit("dragStart", event);
|
13956 | }
|
13957 | preventDefault(event, true);
|
13958 | touch.move(event);
|
13959 | dragStatus.value = "dragging";
|
13960 | const rect = useRect(root);
|
13961 | const delta = props2.vertical ? touch.deltaY.value : touch.deltaX.value;
|
13962 | const total = props2.vertical ? rect.height : rect.width;
|
13963 | let diff = delta / total * scope.value;
|
13964 | if (props2.reverse) {
|
13965 | diff = -diff;
|
13966 | }
|
13967 | if (isRange(startValue)) {
|
13968 | const index = props2.reverse ? 1 - buttonIndex : buttonIndex;
|
13969 | current2[index] = startValue[index] + diff;
|
13970 | } else {
|
13971 | current2 = startValue + diff;
|
13972 | }
|
13973 | updateValue(current2);
|
13974 | };
|
13975 | const onTouchEnd = (event) => {
|
13976 | if (props2.disabled || props2.readonly) {
|
13977 | return;
|
13978 | }
|
13979 | if (dragStatus.value === "dragging") {
|
13980 | updateValue(current2, true);
|
13981 | emit("dragEnd", event);
|
13982 | }
|
13983 | dragStatus.value = "";
|
13984 | };
|
13985 | const getButtonClassName = (index) => {
|
13986 | if (typeof index === "number") {
|
13987 | const position = ["left", "right"];
|
13988 | return bem$c(`button-wrapper`, position[index]);
|
13989 | }
|
13990 | return bem$c("button-wrapper", props2.reverse ? "left" : "right");
|
13991 | };
|
13992 | const renderButtonContent = (value, index) => {
|
13993 | const dragging = dragStatus.value === "dragging";
|
13994 | if (typeof index === "number") {
|
13995 | const slot = slots[index === 0 ? "left-button" : "right-button"];
|
13996 | let dragIndex;
|
13997 | if (dragging && Array.isArray(current2)) {
|
13998 | dragIndex = current2[0] > current2[1] ? buttonIndex ^ 1 : buttonIndex;
|
13999 | }
|
14000 | if (slot) {
|
14001 | return slot({
|
14002 | value,
|
14003 | dragging,
|
14004 | dragIndex
|
14005 | });
|
14006 | }
|
14007 | }
|
14008 | if (slots.button) {
|
14009 | return slots.button({
|
14010 | value,
|
14011 | dragging
|
14012 | });
|
14013 | }
|
14014 | return createVNode("div", {
|
14015 | "class": bem$c("button"),
|
14016 | "style": getSizeStyle(props2.buttonSize)
|
14017 | }, null);
|
14018 | };
|
14019 | const renderButton = (index) => {
|
14020 | const current22 = typeof index === "number" ? props2.modelValue[index] : props2.modelValue;
|
14021 | return createVNode("div", {
|
14022 | "ref": slider[index != null ? index : 0],
|
14023 | "role": "slider",
|
14024 | "class": getButtonClassName(index),
|
14025 | "tabindex": props2.disabled ? void 0 : 0,
|
14026 | "aria-valuemin": props2.min,
|
14027 | "aria-valuenow": current22,
|
14028 | "aria-valuemax": props2.max,
|
14029 | "aria-disabled": props2.disabled || void 0,
|
14030 | "aria-readonly": props2.readonly || void 0,
|
14031 | "aria-orientation": props2.vertical ? "vertical" : "horizontal",
|
14032 | "onTouchstartPassive": (event) => {
|
14033 | if (typeof index === "number") {
|
14034 | buttonIndex = index;
|
14035 | }
|
14036 | onTouchStart(event);
|
14037 | },
|
14038 | "onTouchend": onTouchEnd,
|
14039 | "onTouchcancel": onTouchEnd,
|
14040 | "onClick": stopPropagation
|
14041 | }, [renderButtonContent(current22, index)]);
|
14042 | };
|
14043 | updateValue(props2.modelValue);
|
14044 | useCustomFieldValue(() => props2.modelValue);
|
14045 | slider.forEach((item) => {
|
14046 | useEventListener("touchmove", onTouchMove, {
|
14047 | target: item
|
14048 | });
|
14049 | });
|
14050 | return () => createVNode("div", {
|
14051 | "ref": root,
|
14052 | "style": wrapperStyle.value,
|
14053 | "class": bem$c({
|
14054 | vertical: props2.vertical,
|
14055 | disabled: props2.disabled
|
14056 | }),
|
14057 | "onClick": onClick
|
14058 | }, [createVNode("div", {
|
14059 | "class": bem$c("bar"),
|
14060 | "style": barStyle.value
|
14061 | }, [props2.range ? [renderButton(0), renderButton(1)] : renderButton()])]);
|
14062 | }
|
14063 | });
|
14064 | const Slider = withInstall(stdin_default$i);
|
14065 | const [name$c, bem$b] = createNamespace("space");
|
14066 | const spaceProps = {
|
14067 | align: String,
|
14068 | direction: {
|
14069 | type: String,
|
14070 | default: "horizontal"
|
14071 | },
|
14072 | size: {
|
14073 | type: [Number, String, Array],
|
14074 | default: 8
|
14075 | },
|
14076 | wrap: Boolean,
|
14077 | fill: Boolean
|
14078 | };
|
14079 | function filterEmpty(children = []) {
|
14080 | const nodes = [];
|
14081 | children.forEach((child) => {
|
14082 | if (Array.isArray(child)) {
|
14083 | nodes.push(...child);
|
14084 | } else if (child.type === Fragment) {
|
14085 | nodes.push(...filterEmpty(child.children));
|
14086 | } else {
|
14087 | nodes.push(child);
|
14088 | }
|
14089 | });
|
14090 | return nodes.filter((c) => {
|
14091 | var _a;
|
14092 | return !(c && (c.type === Comment || c.type === Fragment && ((_a = c.children) == null ? void 0 : _a.length) === 0 || c.type === Text && c.children.trim() === ""));
|
14093 | });
|
14094 | }
|
14095 | var stdin_default$h = defineComponent({
|
14096 | name: name$c,
|
14097 | props: spaceProps,
|
14098 | setup(props2, {
|
14099 | slots
|
14100 | }) {
|
14101 | const mergedAlign = computed(() => {
|
14102 | var _a;
|
14103 | return (_a = props2.align) != null ? _a : props2.direction === "horizontal" ? "center" : "";
|
14104 | });
|
14105 | const getMargin = (size) => {
|
14106 | if (typeof size === "number") {
|
14107 | return size + "px";
|
14108 | }
|
14109 | return size;
|
14110 | };
|
14111 | const getMarginStyle = (isLast) => {
|
14112 | const style = {};
|
14113 | const marginRight = `${getMargin(Array.isArray(props2.size) ? props2.size[0] : props2.size)}`;
|
14114 | const marginBottom = `${getMargin(Array.isArray(props2.size) ? props2.size[1] : props2.size)}`;
|
14115 | if (isLast) {
|
14116 | return props2.wrap ? {
|
14117 | marginBottom
|
14118 | } : {};
|
14119 | }
|
14120 | if (props2.direction === "horizontal") {
|
14121 | style.marginRight = marginRight;
|
14122 | }
|
14123 | if (props2.direction === "vertical" || props2.wrap) {
|
14124 | style.marginBottom = marginBottom;
|
14125 | }
|
14126 | return style;
|
14127 | };
|
14128 | return () => {
|
14129 | var _a;
|
14130 | const children = filterEmpty((_a = slots.default) == null ? void 0 : _a.call(slots));
|
14131 | return createVNode("div", {
|
14132 | "class": [bem$b({
|
14133 | [props2.direction]: props2.direction,
|
14134 | [`align-${mergedAlign.value}`]: mergedAlign.value,
|
14135 | wrap: props2.wrap,
|
14136 | fill: props2.fill
|
14137 | })]
|
14138 | }, [children.map((c, i) => createVNode("div", {
|
14139 | "key": `item-${i}`,
|
14140 | "class": `${name$c}-item`,
|
14141 | "style": getMarginStyle(i === children.length - 1)
|
14142 | }, [c]))]);
|
14143 | };
|
14144 | }
|
14145 | });
|
14146 | const Space = withInstall(stdin_default$h);
|
14147 | const [name$b, bem$a] = createNamespace("steps");
|
14148 | const stepsProps = {
|
14149 | active: makeNumericProp(0),
|
14150 | direction: makeStringProp("horizontal"),
|
14151 | activeIcon: makeStringProp("checked"),
|
14152 | iconPrefix: String,
|
14153 | finishIcon: String,
|
14154 | activeColor: String,
|
14155 | inactiveIcon: String,
|
14156 | inactiveColor: String
|
14157 | };
|
14158 | const STEPS_KEY = Symbol(name$b);
|
14159 | var stdin_default$g = defineComponent({
|
14160 | name: name$b,
|
14161 | props: stepsProps,
|
14162 | emits: ["clickStep"],
|
14163 | setup(props2, {
|
14164 | emit,
|
14165 | slots
|
14166 | }) {
|
14167 | const {
|
14168 | linkChildren
|
14169 | } = useChildren(STEPS_KEY);
|
14170 | const onClickStep = (index) => emit("clickStep", index);
|
14171 | linkChildren({
|
14172 | props: props2,
|
14173 | onClickStep
|
14174 | });
|
14175 | return () => {
|
14176 | var _a;
|
14177 | return createVNode("div", {
|
14178 | "class": bem$a([props2.direction])
|
14179 | }, [createVNode("div", {
|
14180 | "class": bem$a("items")
|
14181 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
|
14182 | };
|
14183 | }
|
14184 | });
|
14185 | const [name$a, bem$9] = createNamespace("step");
|
14186 | var stdin_default$f = defineComponent({
|
14187 | name: name$a,
|
14188 | setup(props2, {
|
14189 | slots
|
14190 | }) {
|
14191 | const {
|
14192 | parent,
|
14193 | index
|
14194 | } = useParent(STEPS_KEY);
|
14195 | if (!parent) {
|
14196 | if (process.env.NODE_ENV !== "production") {
|
14197 | console.error("[Vant] <Step> must be a child component of <Steps>.");
|
14198 | }
|
14199 | return;
|
14200 | }
|
14201 | const parentProps = parent.props;
|
14202 | const getStatus = () => {
|
14203 | const active = +parentProps.active;
|
14204 | if (index.value < active) {
|
14205 | return "finish";
|
14206 | }
|
14207 | return index.value === active ? "process" : "waiting";
|
14208 | };
|
14209 | const isActive = () => getStatus() === "process";
|
14210 | const lineStyle = computed(() => ({
|
14211 | background: getStatus() === "finish" ? parentProps.activeColor : parentProps.inactiveColor
|
14212 | }));
|
14213 | const titleStyle = computed(() => {
|
14214 | if (isActive()) {
|
14215 | return {
|
14216 | color: parentProps.activeColor
|
14217 | };
|
14218 | }
|
14219 | if (getStatus() === "waiting") {
|
14220 | return {
|
14221 | color: parentProps.inactiveColor
|
14222 | };
|
14223 | }
|
14224 | });
|
14225 | const onClickStep = () => parent.onClickStep(index.value);
|
14226 | const renderCircle = () => {
|
14227 | const {
|
14228 | iconPrefix,
|
14229 | finishIcon,
|
14230 | activeIcon,
|
14231 | activeColor,
|
14232 | inactiveIcon
|
14233 | } = parentProps;
|
14234 | if (isActive()) {
|
14235 | if (slots["active-icon"]) {
|
14236 | return slots["active-icon"]();
|
14237 | }
|
14238 | return createVNode(Icon, {
|
14239 | "class": bem$9("icon", "active"),
|
14240 | "name": activeIcon,
|
14241 | "color": activeColor,
|
14242 | "classPrefix": iconPrefix
|
14243 | }, null);
|
14244 | }
|
14245 | if (getStatus() === "finish" && (finishIcon || slots["finish-icon"])) {
|
14246 | if (slots["finish-icon"]) {
|
14247 | return slots["finish-icon"]();
|
14248 | }
|
14249 | return createVNode(Icon, {
|
14250 | "class": bem$9("icon", "finish"),
|
14251 | "name": finishIcon,
|
14252 | "color": activeColor,
|
14253 | "classPrefix": iconPrefix
|
14254 | }, null);
|
14255 | }
|
14256 | if (slots["inactive-icon"]) {
|
14257 | return slots["inactive-icon"]();
|
14258 | }
|
14259 | if (inactiveIcon) {
|
14260 | return createVNode(Icon, {
|
14261 | "class": bem$9("icon"),
|
14262 | "name": inactiveIcon,
|
14263 | "classPrefix": iconPrefix
|
14264 | }, null);
|
14265 | }
|
14266 | return createVNode("i", {
|
14267 | "class": bem$9("circle"),
|
14268 | "style": lineStyle.value
|
14269 | }, null);
|
14270 | };
|
14271 | return () => {
|
14272 | var _a;
|
14273 | const status = getStatus();
|
14274 | return createVNode("div", {
|
14275 | "class": [BORDER, bem$9([parentProps.direction, {
|
14276 | [status]: status
|
14277 | }])]
|
14278 | }, [createVNode("div", {
|
14279 | "class": bem$9("title", {
|
14280 | active: isActive()
|
14281 | }),
|
14282 | "style": titleStyle.value,
|
14283 | "onClick": onClickStep
|
14284 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), createVNode("div", {
|
14285 | "class": bem$9("circle-container"),
|
14286 | "onClick": onClickStep
|
14287 | }, [renderCircle()]), createVNode("div", {
|
14288 | "class": bem$9("line"),
|
14289 | "style": lineStyle.value
|
14290 | }, null)]);
|
14291 | };
|
14292 | }
|
14293 | });
|
14294 | const Step = withInstall(stdin_default$f);
|
14295 | const [name$9, bem$8] = createNamespace("stepper");
|
14296 | const LONG_PRESS_INTERVAL = 200;
|
14297 | const isEqual = (value1, value2) => String(value1) === String(value2);
|
14298 | const stepperProps = {
|
14299 | min: makeNumericProp(1),
|
14300 | max: makeNumericProp(Infinity),
|
14301 | name: makeNumericProp(""),
|
14302 | step: makeNumericProp(1),
|
14303 | theme: String,
|
14304 | integer: Boolean,
|
14305 | disabled: Boolean,
|
14306 | showPlus: truthProp,
|
14307 | showMinus: truthProp,
|
14308 | showInput: truthProp,
|
14309 | longPress: truthProp,
|
14310 | autoFixed: truthProp,
|
14311 | allowEmpty: Boolean,
|
14312 | modelValue: numericProp,
|
14313 | inputWidth: numericProp,
|
14314 | buttonSize: numericProp,
|
14315 | placeholder: String,
|
14316 | disablePlus: Boolean,
|
14317 | disableMinus: Boolean,
|
14318 | disableInput: Boolean,
|
14319 | beforeChange: Function,
|
14320 | defaultValue: makeNumericProp(1),
|
14321 | decimalLength: numericProp
|
14322 | };
|
14323 | var stdin_default$e = defineComponent({
|
14324 | name: name$9,
|
14325 | props: stepperProps,
|
14326 | emits: ["plus", "blur", "minus", "focus", "change", "overlimit", "update:modelValue"],
|
14327 | setup(props2, {
|
14328 | emit
|
14329 | }) {
|
14330 | const format2 = (value, autoFixed = true) => {
|
14331 | const {
|
14332 | min,
|
14333 | max,
|
14334 | allowEmpty,
|
14335 | decimalLength
|
14336 | } = props2;
|
14337 | if (allowEmpty && value === "") {
|
14338 | return value;
|
14339 | }
|
14340 | value = formatNumber(String(value), !props2.integer);
|
14341 | value = value === "" ? 0 : +value;
|
14342 | value = Number.isNaN(value) ? +min : value;
|
14343 | value = autoFixed ? Math.max(Math.min(+max, value), +min) : value;
|
14344 | if (isDef(decimalLength)) {
|
14345 | value = value.toFixed(+decimalLength);
|
14346 | }
|
14347 | return value;
|
14348 | };
|
14349 | const getInitialValue = () => {
|
14350 | var _a;
|
14351 | const defaultValue = (_a = props2.modelValue) != null ? _a : props2.defaultValue;
|
14352 | const value = format2(defaultValue);
|
14353 | if (!isEqual(value, props2.modelValue)) {
|
14354 | emit("update:modelValue", value);
|
14355 | }
|
14356 | return value;
|
14357 | };
|
14358 | let actionType;
|
14359 | const inputRef = ref();
|
14360 | const current2 = ref(getInitialValue());
|
14361 | const minusDisabled = computed(() => props2.disabled || props2.disableMinus || +current2.value <= +props2.min);
|
14362 | const plusDisabled = computed(() => props2.disabled || props2.disablePlus || +current2.value >= +props2.max);
|
14363 | const inputStyle = computed(() => ({
|
14364 | width: addUnit(props2.inputWidth),
|
14365 | height: addUnit(props2.buttonSize)
|
14366 | }));
|
14367 | const buttonStyle = computed(() => getSizeStyle(props2.buttonSize));
|
14368 | const check = () => {
|
14369 | const value = format2(current2.value);
|
14370 | if (!isEqual(value, current2.value)) {
|
14371 | current2.value = value;
|
14372 | }
|
14373 | };
|
14374 | const setValue = (value) => {
|
14375 | if (props2.beforeChange) {
|
14376 | callInterceptor(props2.beforeChange, {
|
14377 | args: [value],
|
14378 | done() {
|
14379 | current2.value = value;
|
14380 | }
|
14381 | });
|
14382 | } else {
|
14383 | current2.value = value;
|
14384 | }
|
14385 | };
|
14386 | const onChange = () => {
|
14387 | if (actionType === "plus" && plusDisabled.value || actionType === "minus" && minusDisabled.value) {
|
14388 | emit("overlimit", actionType);
|
14389 | return;
|
14390 | }
|
14391 | const diff = actionType === "minus" ? -props2.step : +props2.step;
|
14392 | const value = format2(addNumber(+current2.value, diff));
|
14393 | setValue(value);
|
14394 | emit(actionType);
|
14395 | };
|
14396 | const onInput = (event) => {
|
14397 | const input = event.target;
|
14398 | const {
|
14399 | value
|
14400 | } = input;
|
14401 | const {
|
14402 | decimalLength
|
14403 | } = props2;
|
14404 | let formatted = formatNumber(String(value), !props2.integer);
|
14405 | if (isDef(decimalLength) && formatted.includes(".")) {
|
14406 | const pair = formatted.split(".");
|
14407 | formatted = `${pair[0]}.${pair[1].slice(0, +decimalLength)}`;
|
14408 | }
|
14409 | if (props2.beforeChange) {
|
14410 | input.value = String(current2.value);
|
14411 | } else if (!isEqual(value, formatted)) {
|
14412 | input.value = formatted;
|
14413 | }
|
14414 | const isNumeric2 = formatted === String(+formatted);
|
14415 | setValue(isNumeric2 ? +formatted : formatted);
|
14416 | };
|
14417 | const onFocus = (event) => {
|
14418 | var _a;
|
14419 | if (props2.disableInput) {
|
14420 | (_a = inputRef.value) == null ? void 0 : _a.blur();
|
14421 | } else {
|
14422 | emit("focus", event);
|
14423 | }
|
14424 | };
|
14425 | const onBlur = (event) => {
|
14426 | const input = event.target;
|
14427 | const value = format2(input.value, props2.autoFixed);
|
14428 | input.value = String(value);
|
14429 | current2.value = value;
|
14430 | nextTick(() => {
|
14431 | emit("blur", event);
|
14432 | resetScroll();
|
14433 | });
|
14434 | };
|
14435 | let isLongPress;
|
14436 | let longPressTimer;
|
14437 | const longPressStep = () => {
|
14438 | longPressTimer = setTimeout(() => {
|
14439 | onChange();
|
14440 | longPressStep();
|
14441 | }, LONG_PRESS_INTERVAL);
|
14442 | };
|
14443 | const onTouchStart = () => {
|
14444 | if (props2.longPress) {
|
14445 | isLongPress = false;
|
14446 | clearTimeout(longPressTimer);
|
14447 | longPressTimer = setTimeout(() => {
|
14448 | isLongPress = true;
|
14449 | onChange();
|
14450 | longPressStep();
|
14451 | }, LONG_PRESS_START_TIME);
|
14452 | }
|
14453 | };
|
14454 | const onTouchEnd = (event) => {
|
14455 | if (props2.longPress) {
|
14456 | clearTimeout(longPressTimer);
|
14457 | if (isLongPress) {
|
14458 | preventDefault(event);
|
14459 | }
|
14460 | }
|
14461 | };
|
14462 | const onMousedown = (event) => {
|
14463 | if (props2.disableInput) {
|
14464 | preventDefault(event);
|
14465 | }
|
14466 | };
|
14467 | const createListeners = (type) => ({
|
14468 | onClick: (event) => {
|
14469 | preventDefault(event);
|
14470 | actionType = type;
|
14471 | onChange();
|
14472 | },
|
14473 | onTouchstartPassive: () => {
|
14474 | actionType = type;
|
14475 | onTouchStart();
|
14476 | },
|
14477 | onTouchend: onTouchEnd,
|
14478 | onTouchcancel: onTouchEnd
|
14479 | });
|
14480 | watch(() => [props2.max, props2.min, props2.integer, props2.decimalLength], check);
|
14481 | watch(() => props2.modelValue, (value) => {
|
14482 | if (!isEqual(value, current2.value)) {
|
14483 | current2.value = format2(value);
|
14484 | }
|
14485 | });
|
14486 | watch(current2, (value) => {
|
14487 | emit("update:modelValue", value);
|
14488 | emit("change", value, {
|
14489 | name: props2.name
|
14490 | });
|
14491 | });
|
14492 | useCustomFieldValue(() => props2.modelValue);
|
14493 | return () => createVNode("div", {
|
14494 | "role": "group",
|
14495 | "class": bem$8([props2.theme])
|
14496 | }, [withDirectives(createVNode("button", mergeProps({
|
14497 | "type": "button",
|
14498 | "style": buttonStyle.value,
|
14499 | "class": [bem$8("minus", {
|
14500 | disabled: minusDisabled.value
|
14501 | }), {
|
14502 | [HAPTICS_FEEDBACK]: !minusDisabled.value
|
14503 | }],
|
14504 | "aria-disabled": minusDisabled.value || void 0
|
14505 | }, createListeners("minus")), null), [[vShow, props2.showMinus]]), withDirectives(createVNode("input", {
|
14506 | "ref": inputRef,
|
14507 | "type": props2.integer ? "tel" : "text",
|
14508 | "role": "spinbutton",
|
14509 | "class": bem$8("input"),
|
14510 | "value": current2.value,
|
14511 | "style": inputStyle.value,
|
14512 | "disabled": props2.disabled,
|
14513 | "readonly": props2.disableInput,
|
14514 | "inputmode": props2.integer ? "numeric" : "decimal",
|
14515 | "placeholder": props2.placeholder,
|
14516 | "aria-valuemax": props2.max,
|
14517 | "aria-valuemin": props2.min,
|
14518 | "aria-valuenow": current2.value,
|
14519 | "onBlur": onBlur,
|
14520 | "onInput": onInput,
|
14521 | "onFocus": onFocus,
|
14522 | "onMousedown": onMousedown
|
14523 | }, null), [[vShow, props2.showInput]]), withDirectives(createVNode("button", mergeProps({
|
14524 | "type": "button",
|
14525 | "style": buttonStyle.value,
|
14526 | "class": [bem$8("plus", {
|
14527 | disabled: plusDisabled.value
|
14528 | }), {
|
14529 | [HAPTICS_FEEDBACK]: !plusDisabled.value
|
14530 | }],
|
14531 | "aria-disabled": plusDisabled.value || void 0
|
14532 | }, createListeners("plus")), null), [[vShow, props2.showPlus]])]);
|
14533 | }
|
14534 | });
|
14535 | const Stepper = withInstall(stdin_default$e);
|
14536 | const Steps = withInstall(stdin_default$g);
|
14537 | const [name$8, bem$7, t$1] = createNamespace("submit-bar");
|
14538 | const submitBarProps = {
|
14539 | tip: String,
|
14540 | label: String,
|
14541 | price: Number,
|
14542 | tipIcon: String,
|
14543 | loading: Boolean,
|
14544 | currency: makeStringProp("¥"),
|
14545 | disabled: Boolean,
|
14546 | textAlign: String,
|
14547 | buttonText: String,
|
14548 | buttonType: makeStringProp("danger"),
|
14549 | buttonColor: String,
|
14550 | suffixLabel: String,
|
14551 | placeholder: Boolean,
|
14552 | decimalLength: makeNumericProp(2),
|
14553 | safeAreaInsetBottom: truthProp
|
14554 | };
|
14555 | var stdin_default$d = defineComponent({
|
14556 | name: name$8,
|
14557 | props: submitBarProps,
|
14558 | emits: ["submit"],
|
14559 | setup(props2, {
|
14560 | emit,
|
14561 | slots
|
14562 | }) {
|
14563 | const root = ref();
|
14564 | const renderPlaceholder = usePlaceholder(root, bem$7);
|
14565 | const renderText = () => {
|
14566 | const {
|
14567 | price,
|
14568 | label,
|
14569 | currency,
|
14570 | textAlign,
|
14571 | suffixLabel,
|
14572 | decimalLength
|
14573 | } = props2;
|
14574 | if (typeof price === "number") {
|
14575 | const pricePair = (price / 100).toFixed(+decimalLength).split(".");
|
14576 | const decimal = decimalLength ? `.${pricePair[1]}` : "";
|
14577 | return createVNode("div", {
|
14578 | "class": bem$7("text"),
|
14579 | "style": {
|
14580 | textAlign
|
14581 | }
|
14582 | }, [createVNode("span", null, [label || t$1("label")]), createVNode("span", {
|
14583 | "class": bem$7("price")
|
14584 | }, [currency, createVNode("span", {
|
14585 | "class": bem$7("price-integer")
|
14586 | }, [pricePair[0]]), decimal]), suffixLabel && createVNode("span", {
|
14587 | "class": bem$7("suffix-label")
|
14588 | }, [suffixLabel])]);
|
14589 | }
|
14590 | };
|
14591 | const renderTip = () => {
|
14592 | var _a;
|
14593 | const {
|
14594 | tip,
|
14595 | tipIcon
|
14596 | } = props2;
|
14597 | if (slots.tip || tip) {
|
14598 | return createVNode("div", {
|
14599 | "class": bem$7("tip")
|
14600 | }, [tipIcon && createVNode(Icon, {
|
14601 | "class": bem$7("tip-icon"),
|
14602 | "name": tipIcon
|
14603 | }, null), tip && createVNode("span", {
|
14604 | "class": bem$7("tip-text")
|
14605 | }, [tip]), (_a = slots.tip) == null ? void 0 : _a.call(slots)]);
|
14606 | }
|
14607 | };
|
14608 | const onClickButton = () => emit("submit");
|
14609 | const renderButton = () => {
|
14610 | if (slots.button) {
|
14611 | return slots.button();
|
14612 | }
|
14613 | return createVNode(Button, {
|
14614 | "round": true,
|
14615 | "type": props2.buttonType,
|
14616 | "text": props2.buttonText,
|
14617 | "class": bem$7("button", props2.buttonType),
|
14618 | "color": props2.buttonColor,
|
14619 | "loading": props2.loading,
|
14620 | "disabled": props2.disabled,
|
14621 | "onClick": onClickButton
|
14622 | }, null);
|
14623 | };
|
14624 | const renderSubmitBar = () => {
|
14625 | var _a, _b;
|
14626 | return createVNode("div", {
|
14627 | "ref": root,
|
14628 | "class": [bem$7(), {
|
14629 | "van-safe-area-bottom": props2.safeAreaInsetBottom
|
14630 | }]
|
14631 | }, [(_a = slots.top) == null ? void 0 : _a.call(slots), renderTip(), createVNode("div", {
|
14632 | "class": bem$7("bar")
|
14633 | }, [(_b = slots.default) == null ? void 0 : _b.call(slots), renderText(), renderButton()])]);
|
14634 | };
|
14635 | return () => {
|
14636 | if (props2.placeholder) {
|
14637 | return renderPlaceholder(renderSubmitBar);
|
14638 | }
|
14639 | return renderSubmitBar();
|
14640 | };
|
14641 | }
|
14642 | });
|
14643 | const SubmitBar = withInstall(stdin_default$d);
|
14644 | const [name$7, bem$6] = createNamespace("swipe-cell");
|
14645 | const swipeCellProps = {
|
14646 | name: makeNumericProp(""),
|
14647 | disabled: Boolean,
|
14648 | leftWidth: numericProp,
|
14649 | rightWidth: numericProp,
|
14650 | beforeClose: Function,
|
14651 | stopPropagation: Boolean
|
14652 | };
|
14653 | var stdin_default$c = defineComponent({
|
14654 | name: name$7,
|
14655 | props: swipeCellProps,
|
14656 | emits: ["open", "close", "click"],
|
14657 | setup(props2, {
|
14658 | emit,
|
14659 | slots
|
14660 | }) {
|
14661 | let opened;
|
14662 | let lockClick2;
|
14663 | let startOffset;
|
14664 | let isInBeforeClosing;
|
14665 | const root = ref();
|
14666 | const leftRef = ref();
|
14667 | const rightRef = ref();
|
14668 | const state = reactive({
|
14669 | offset: 0,
|
14670 | dragging: false
|
14671 | });
|
14672 | const touch = useTouch();
|
14673 | const getWidthByRef = (ref2) => ref2.value ? useRect(ref2).width : 0;
|
14674 | const leftWidth = computed(() => isDef(props2.leftWidth) ? +props2.leftWidth : getWidthByRef(leftRef));
|
14675 | const rightWidth = computed(() => isDef(props2.rightWidth) ? +props2.rightWidth : getWidthByRef(rightRef));
|
14676 | const open = (side) => {
|
14677 | state.offset = side === "left" ? leftWidth.value : -rightWidth.value;
|
14678 | if (!opened) {
|
14679 | opened = true;
|
14680 | emit("open", {
|
14681 | name: props2.name,
|
14682 | position: side
|
14683 | });
|
14684 | }
|
14685 | };
|
14686 | const close = (position) => {
|
14687 | state.offset = 0;
|
14688 | if (opened) {
|
14689 | opened = false;
|
14690 | emit("close", {
|
14691 | name: props2.name,
|
14692 | position
|
14693 | });
|
14694 | }
|
14695 | };
|
14696 | const toggle = (side) => {
|
14697 | const offset = Math.abs(state.offset);
|
14698 | const THRESHOLD = 0.15;
|
14699 | const threshold = opened ? 1 - THRESHOLD : THRESHOLD;
|
14700 | const width = side === "left" ? leftWidth.value : rightWidth.value;
|
14701 | if (width && offset > width * threshold) {
|
14702 | open(side);
|
14703 | } else {
|
14704 | close(side);
|
14705 | }
|
14706 | };
|
14707 | const onTouchStart = (event) => {
|
14708 | if (!props2.disabled) {
|
14709 | startOffset = state.offset;
|
14710 | touch.start(event);
|
14711 | }
|
14712 | };
|
14713 | const onTouchMove = (event) => {
|
14714 | if (props2.disabled) {
|
14715 | return;
|
14716 | }
|
14717 | const {
|
14718 | deltaX
|
14719 | } = touch;
|
14720 | touch.move(event);
|
14721 | if (touch.isHorizontal()) {
|
14722 | lockClick2 = true;
|
14723 | state.dragging = true;
|
14724 | const isEdge = !opened || deltaX.value * startOffset < 0;
|
14725 | if (isEdge) {
|
14726 | preventDefault(event, props2.stopPropagation);
|
14727 | }
|
14728 | state.offset = clamp(deltaX.value + startOffset, -rightWidth.value, leftWidth.value);
|
14729 | }
|
14730 | };
|
14731 | const onTouchEnd = () => {
|
14732 | if (state.dragging) {
|
14733 | state.dragging = false;
|
14734 | toggle(state.offset > 0 ? "left" : "right");
|
14735 | setTimeout(() => {
|
14736 | lockClick2 = false;
|
14737 | }, 0);
|
14738 | }
|
14739 | };
|
14740 | const onClick = (position = "outside") => {
|
14741 | if (isInBeforeClosing)
|
14742 | return;
|
14743 | emit("click", position);
|
14744 | if (opened && !lockClick2) {
|
14745 | isInBeforeClosing = true;
|
14746 | callInterceptor(props2.beforeClose, {
|
14747 | args: [{
|
14748 | name: props2.name,
|
14749 | position
|
14750 | }],
|
14751 | done: () => {
|
14752 | isInBeforeClosing = false;
|
14753 | close(position);
|
14754 | },
|
14755 | canceled: () => isInBeforeClosing = false,
|
14756 | error: () => isInBeforeClosing = false
|
14757 | });
|
14758 | }
|
14759 | };
|
14760 | const getClickHandler = (position, stop) => (event) => {
|
14761 | if (stop) {
|
14762 | event.stopPropagation();
|
14763 | }
|
14764 | onClick(position);
|
14765 | };
|
14766 | const renderSideContent = (side, ref2) => {
|
14767 | const contentSlot = slots[side];
|
14768 | if (contentSlot) {
|
14769 | return createVNode("div", {
|
14770 | "ref": ref2,
|
14771 | "class": bem$6(side),
|
14772 | "onClick": getClickHandler(side, true)
|
14773 | }, [contentSlot()]);
|
14774 | }
|
14775 | };
|
14776 | useExpose({
|
14777 | open,
|
14778 | close
|
14779 | });
|
14780 | useClickAway(root, () => onClick("outside"), {
|
14781 | eventName: "touchstart"
|
14782 | });
|
14783 | useEventListener("touchmove", onTouchMove, {
|
14784 | target: root
|
14785 | });
|
14786 | return () => {
|
14787 | var _a;
|
14788 | const wrapperStyle = {
|
14789 | transform: `translate3d(${state.offset}px, 0, 0)`,
|
14790 | transitionDuration: state.dragging ? "0s" : ".6s"
|
14791 | };
|
14792 | return createVNode("div", {
|
14793 | "ref": root,
|
14794 | "class": bem$6(),
|
14795 | "onClick": getClickHandler("cell", lockClick2),
|
14796 | "onTouchstartPassive": onTouchStart,
|
14797 | "onTouchend": onTouchEnd,
|
14798 | "onTouchcancel": onTouchEnd
|
14799 | }, [createVNode("div", {
|
14800 | "class": bem$6("wrapper"),
|
14801 | "style": wrapperStyle
|
14802 | }, [renderSideContent("left", leftRef), (_a = slots.default) == null ? void 0 : _a.call(slots), renderSideContent("right", rightRef)])]);
|
14803 | };
|
14804 | }
|
14805 | });
|
14806 | const SwipeCell = withInstall(stdin_default$c);
|
14807 | const [name$6, bem$5] = createNamespace("tabbar");
|
14808 | const tabbarProps = {
|
14809 | route: Boolean,
|
14810 | fixed: truthProp,
|
14811 | border: truthProp,
|
14812 | zIndex: numericProp,
|
14813 | placeholder: Boolean,
|
14814 | activeColor: String,
|
14815 | beforeChange: Function,
|
14816 | inactiveColor: String,
|
14817 | modelValue: makeNumericProp(0),
|
14818 | safeAreaInsetBottom: {
|
14819 | type: Boolean,
|
14820 | default: null
|
14821 | }
|
14822 | };
|
14823 | const TABBAR_KEY = Symbol(name$6);
|
14824 | var stdin_default$b = defineComponent({
|
14825 | name: name$6,
|
14826 | props: tabbarProps,
|
14827 | emits: ["change", "update:modelValue"],
|
14828 | setup(props2, {
|
14829 | emit,
|
14830 | slots
|
14831 | }) {
|
14832 | const root = ref();
|
14833 | const {
|
14834 | linkChildren
|
14835 | } = useChildren(TABBAR_KEY);
|
14836 | const renderPlaceholder = usePlaceholder(root, bem$5);
|
14837 | const enableSafeArea = () => {
|
14838 | var _a;
|
14839 | return (_a = props2.safeAreaInsetBottom) != null ? _a : props2.fixed;
|
14840 | };
|
14841 | const renderTabbar = () => {
|
14842 | var _a;
|
14843 | const {
|
14844 | fixed,
|
14845 | zIndex,
|
14846 | border
|
14847 | } = props2;
|
14848 | return createVNode("div", {
|
14849 | "ref": root,
|
14850 | "role": "tablist",
|
14851 | "style": getZIndexStyle(zIndex),
|
14852 | "class": [bem$5({
|
14853 | fixed
|
14854 | }), {
|
14855 | [BORDER_TOP_BOTTOM]: border,
|
14856 | "van-safe-area-bottom": enableSafeArea()
|
14857 | }]
|
14858 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
14859 | };
|
14860 | const setActive = (active, afterChange) => {
|
14861 | callInterceptor(props2.beforeChange, {
|
14862 | args: [active],
|
14863 | done() {
|
14864 | emit("update:modelValue", active);
|
14865 | emit("change", active);
|
14866 | afterChange();
|
14867 | }
|
14868 | });
|
14869 | };
|
14870 | linkChildren({
|
14871 | props: props2,
|
14872 | setActive
|
14873 | });
|
14874 | return () => {
|
14875 | if (props2.fixed && props2.placeholder) {
|
14876 | return renderPlaceholder(renderTabbar);
|
14877 | }
|
14878 | return renderTabbar();
|
14879 | };
|
14880 | }
|
14881 | });
|
14882 | const Tabbar = withInstall(stdin_default$b);
|
14883 | const [name$5, bem$4] = createNamespace("tabbar-item");
|
14884 | const tabbarItemProps = extend({}, routeProps, {
|
14885 | dot: Boolean,
|
14886 | icon: String,
|
14887 | name: numericProp,
|
14888 | badge: numericProp,
|
14889 | badgeProps: Object,
|
14890 | iconPrefix: String
|
14891 | });
|
14892 | var stdin_default$a = defineComponent({
|
14893 | name: name$5,
|
14894 | props: tabbarItemProps,
|
14895 | emits: ["click"],
|
14896 | setup(props2, {
|
14897 | emit,
|
14898 | slots
|
14899 | }) {
|
14900 | const route2 = useRoute();
|
14901 | const vm = getCurrentInstance().proxy;
|
14902 | const {
|
14903 | parent,
|
14904 | index
|
14905 | } = useParent(TABBAR_KEY);
|
14906 | if (!parent) {
|
14907 | if (process.env.NODE_ENV !== "production") {
|
14908 | console.error("[Vant] <TabbarItem> must be a child component of <Tabbar>.");
|
14909 | }
|
14910 | return;
|
14911 | }
|
14912 | const active = computed(() => {
|
14913 | var _a;
|
14914 | const {
|
14915 | route: route22,
|
14916 | modelValue
|
14917 | } = parent.props;
|
14918 | if (route22 && "$route" in vm) {
|
14919 | const {
|
14920 | $route
|
14921 | } = vm;
|
14922 | const {
|
14923 | to
|
14924 | } = props2;
|
14925 | const config = isObject(to) ? to : {
|
14926 | path: to
|
14927 | };
|
14928 | return !!$route.matched.find((val) => {
|
14929 | const pathMatched = "path" in config && config.path === val.path;
|
14930 | const nameMatched = "name" in config && config.name === val.name;
|
14931 | return pathMatched || nameMatched;
|
14932 | });
|
14933 | }
|
14934 | return ((_a = props2.name) != null ? _a : index.value) === modelValue;
|
14935 | });
|
14936 | const onClick = (event) => {
|
14937 | var _a;
|
14938 | if (!active.value) {
|
14939 | parent.setActive((_a = props2.name) != null ? _a : index.value, route2);
|
14940 | }
|
14941 | emit("click", event);
|
14942 | };
|
14943 | const renderIcon = () => {
|
14944 | if (slots.icon) {
|
14945 | return slots.icon({
|
14946 | active: active.value
|
14947 | });
|
14948 | }
|
14949 | if (props2.icon) {
|
14950 | return createVNode(Icon, {
|
14951 | "name": props2.icon,
|
14952 | "classPrefix": props2.iconPrefix
|
14953 | }, null);
|
14954 | }
|
14955 | };
|
14956 | return () => {
|
14957 | var _a;
|
14958 | const {
|
14959 | dot,
|
14960 | badge
|
14961 | } = props2;
|
14962 | const {
|
14963 | activeColor,
|
14964 | inactiveColor
|
14965 | } = parent.props;
|
14966 | const color = active.value ? activeColor : inactiveColor;
|
14967 | return createVNode("div", {
|
14968 | "role": "tab",
|
14969 | "class": bem$4({
|
14970 | active: active.value
|
14971 | }),
|
14972 | "style": {
|
14973 | color
|
14974 | },
|
14975 | "tabindex": 0,
|
14976 | "aria-selected": active.value,
|
14977 | "onClick": onClick
|
14978 | }, [createVNode(Badge, mergeProps({
|
14979 | "dot": dot,
|
14980 | "class": bem$4("icon"),
|
14981 | "content": badge
|
14982 | }, props2.badgeProps), {
|
14983 | default: renderIcon
|
14984 | }), createVNode("div", {
|
14985 | "class": bem$4("text")
|
14986 | }, [(_a = slots.default) == null ? void 0 : _a.call(slots, {
|
14987 | active: active.value
|
14988 | })])]);
|
14989 | };
|
14990 | }
|
14991 | });
|
14992 | const TabbarItem = withInstall(stdin_default$a);
|
14993 | const [name$4, bem$3] = createNamespace("text-ellipsis");
|
14994 | const textEllipsisProps = {
|
14995 | rows: makeNumericProp(1),
|
14996 | dots: makeStringProp("..."),
|
14997 | content: makeStringProp(""),
|
14998 | expandText: makeStringProp(""),
|
14999 | collapseText: makeStringProp(""),
|
15000 | position: makeStringProp("end")
|
15001 | };
|
15002 | var stdin_default$9 = defineComponent({
|
15003 | name: name$4,
|
15004 | props: textEllipsisProps,
|
15005 | emits: ["clickAction"],
|
15006 | setup(props2, {
|
15007 | emit,
|
15008 | slots
|
15009 | }) {
|
15010 | const text = ref("");
|
15011 | const expanded = ref(false);
|
15012 | const hasAction = ref(false);
|
15013 | const root = ref();
|
15014 | const actionText = computed(() => expanded.value ? props2.collapseText : props2.expandText);
|
15015 | const pxToNum = (value) => {
|
15016 | if (!value)
|
15017 | return 0;
|
15018 | const match = value.match(/^\d*(\.\d*)?/);
|
15019 | return match ? Number(match[0]) : 0;
|
15020 | };
|
15021 | const calcEllipsised = () => {
|
15022 | const cloneContainer = () => {
|
15023 | if (!root.value)
|
15024 | return;
|
15025 | const originStyle = window.getComputedStyle(root.value);
|
15026 | const container2 = document.createElement("div");
|
15027 | const styleNames = Array.prototype.slice.apply(originStyle);
|
15028 | styleNames.forEach((name2) => {
|
15029 | container2.style.setProperty(name2, originStyle.getPropertyValue(name2));
|
15030 | });
|
15031 | container2.style.position = "fixed";
|
15032 | container2.style.zIndex = "-9999";
|
15033 | container2.style.top = "-9999px";
|
15034 | container2.style.height = "auto";
|
15035 | container2.style.minHeight = "auto";
|
15036 | container2.style.maxHeight = "auto";
|
15037 | container2.innerText = props2.content;
|
15038 | document.body.appendChild(container2);
|
15039 | return container2;
|
15040 | };
|
15041 | const calcEllipsisText = (container2, maxHeight2) => {
|
15042 | const {
|
15043 | content,
|
15044 | position,
|
15045 | dots
|
15046 | } = props2;
|
15047 | const end = content.length;
|
15048 | const calcEllipse = () => {
|
15049 | const tail = (left, right) => {
|
15050 | if (right - left <= 1) {
|
15051 | if (position === "end") {
|
15052 | return content.slice(0, left) + dots;
|
15053 | }
|
15054 | return dots + content.slice(right, end);
|
15055 | }
|
15056 | const middle2 = Math.round((left + right) / 2);
|
15057 | if (position === "end") {
|
15058 | container2.innerText = content.slice(0, middle2) + dots + actionText.value;
|
15059 | } else {
|
15060 | container2.innerText = dots + content.slice(middle2, end) + actionText.value;
|
15061 | }
|
15062 | if (container2.offsetHeight > maxHeight2) {
|
15063 | if (position === "end") {
|
15064 | return tail(left, middle2);
|
15065 | }
|
15066 | return tail(middle2, right);
|
15067 | }
|
15068 | if (position === "end") {
|
15069 | return tail(middle2, right);
|
15070 | }
|
15071 | return tail(left, middle2);
|
15072 | };
|
15073 | container2.innerText = tail(0, end);
|
15074 | };
|
15075 | const middleTail = (leftPart, rightPart) => {
|
15076 | if (leftPart[1] - leftPart[0] <= 1 && rightPart[1] - rightPart[0] <= 1) {
|
15077 | return content.slice(0, leftPart[0]) + dots + content.slice(rightPart[1], end);
|
15078 | }
|
15079 | const leftMiddle = Math.floor((leftPart[0] + leftPart[1]) / 2);
|
15080 | const rightMiddle = Math.ceil((rightPart[0] + rightPart[1]) / 2);
|
15081 | container2.innerText = props2.content.slice(0, leftMiddle) + props2.dots + props2.content.slice(rightMiddle, end) + props2.expandText;
|
15082 | if (container2.offsetHeight >= maxHeight2) {
|
15083 | return middleTail([leftPart[0], leftMiddle], [rightMiddle, rightPart[1]]);
|
15084 | }
|
15085 | return middleTail([leftMiddle, leftPart[1]], [rightPart[0], rightMiddle]);
|
15086 | };
|
15087 | const middle = 0 + end >> 1;
|
15088 | props2.position === "middle" ? container2.innerText = middleTail([0, middle], [middle, end]) : calcEllipse();
|
15089 | return container2.innerText;
|
15090 | };
|
15091 | const container = cloneContainer();
|
15092 | if (!container)
|
15093 | return;
|
15094 | const {
|
15095 | paddingBottom,
|
15096 | paddingTop,
|
15097 | lineHeight
|
15098 | } = container.style;
|
15099 | const maxHeight = Math.ceil((Number(props2.rows) + 0.5) * pxToNum(lineHeight) + pxToNum(paddingTop) + pxToNum(paddingBottom));
|
15100 | if (maxHeight < container.offsetHeight) {
|
15101 | hasAction.value = true;
|
15102 | text.value = calcEllipsisText(container, maxHeight);
|
15103 | } else {
|
15104 | hasAction.value = false;
|
15105 | text.value = props2.content;
|
15106 | }
|
15107 | document.body.removeChild(container);
|
15108 | };
|
15109 | const toggle = (isExpanded = !expanded.value) => {
|
15110 | expanded.value = isExpanded;
|
15111 | };
|
15112 | const onClickAction = (event) => {
|
15113 | toggle();
|
15114 | emit("clickAction", event);
|
15115 | };
|
15116 | const renderAction = () => {
|
15117 | const action = slots.action ? slots.action({
|
15118 | expanded: expanded.value
|
15119 | }) : actionText.value;
|
15120 | return createVNode("span", {
|
15121 | "class": bem$3("action"),
|
15122 | "onClick": onClickAction
|
15123 | }, [action]);
|
15124 | };
|
15125 | onMounted(calcEllipsised);
|
15126 | watch([windowWidth, () => [props2.content, props2.rows, props2.position]], calcEllipsised);
|
15127 | useExpose({
|
15128 | toggle
|
15129 | });
|
15130 | return () => createVNode("div", {
|
15131 | "ref": root,
|
15132 | "class": bem$3()
|
15133 | }, [expanded.value ? props2.content : text.value, hasAction.value ? renderAction() : null]);
|
15134 | }
|
15135 | });
|
15136 | const TextEllipsis = withInstall(stdin_default$9);
|
15137 | const [name$3] = createNamespace("time-picker");
|
15138 | const validateTime = (val) => /^([01]\d|2[0-3]):([0-5]\d):([0-5]\d)$/.test(val);
|
15139 | const fullColumns = ["hour", "minute", "second"];
|
15140 | const timePickerProps = extend({}, sharedProps, {
|
15141 | minHour: makeNumericProp(0),
|
15142 | maxHour: makeNumericProp(23),
|
15143 | minMinute: makeNumericProp(0),
|
15144 | maxMinute: makeNumericProp(59),
|
15145 | minSecond: makeNumericProp(0),
|
15146 | maxSecond: makeNumericProp(59),
|
15147 | minTime: {
|
15148 | type: String,
|
15149 | validator: validateTime
|
15150 | },
|
15151 | maxTime: {
|
15152 | type: String,
|
15153 | validator: validateTime
|
15154 | },
|
15155 | columnsType: {
|
15156 | type: Array,
|
15157 | default: () => ["hour", "minute"]
|
15158 | },
|
15159 | filter: Function
|
15160 | });
|
15161 | var stdin_default$8 = defineComponent({
|
15162 | name: name$3,
|
15163 | props: timePickerProps,
|
15164 | emits: ["confirm", "cancel", "change", "update:modelValue"],
|
15165 | setup(props2, {
|
15166 | emit,
|
15167 | slots
|
15168 | }) {
|
15169 | const currentValues = ref(props2.modelValue);
|
15170 | const getValidTime = (time) => {
|
15171 | const timeLimitArr = time.split(":");
|
15172 | return fullColumns.map((col, i) => props2.columnsType.includes(col) ? timeLimitArr[i] : "00");
|
15173 | };
|
15174 | const columns = computed(() => {
|
15175 | let {
|
15176 | minHour,
|
15177 | maxHour,
|
15178 | minMinute,
|
15179 | maxMinute,
|
15180 | minSecond,
|
15181 | maxSecond
|
15182 | } = props2;
|
15183 | if (props2.minTime || props2.maxTime) {
|
15184 | const fullTime = {
|
15185 | hour: 0,
|
15186 | minute: 0,
|
15187 | second: 0
|
15188 | };
|
15189 | props2.columnsType.forEach((col, i) => {
|
15190 | var _a;
|
15191 | fullTime[col] = (_a = currentValues.value[i]) != null ? _a : 0;
|
15192 | });
|
15193 | const {
|
15194 | hour,
|
15195 | minute
|
15196 | } = fullTime;
|
15197 | if (props2.minTime) {
|
15198 | const [minH, minM, minS] = getValidTime(props2.minTime);
|
15199 | minHour = minH;
|
15200 | minMinute = +hour <= +minHour ? minM : "00";
|
15201 | minSecond = +hour <= +minHour && +minute <= +minMinute ? minS : "00";
|
15202 | }
|
15203 | if (props2.maxTime) {
|
15204 | const [maxH, maxM, maxS] = getValidTime(props2.maxTime);
|
15205 | maxHour = maxH;
|
15206 | maxMinute = +hour >= +maxHour ? maxM : "59";
|
15207 | maxSecond = +hour >= +maxHour && +minute >= +maxMinute ? maxS : "59";
|
15208 | }
|
15209 | }
|
15210 | return props2.columnsType.map((type) => {
|
15211 | const {
|
15212 | filter,
|
15213 | formatter
|
15214 | } = props2;
|
15215 | switch (type) {
|
15216 | case "hour":
|
15217 | return genOptions(+minHour, +maxHour, type, formatter, filter, currentValues.value);
|
15218 | case "minute":
|
15219 | return genOptions(+minMinute, +maxMinute, type, formatter, filter, currentValues.value);
|
15220 | case "second":
|
15221 | return genOptions(+minSecond, +maxSecond, type, formatter, filter, currentValues.value);
|
15222 | default:
|
15223 | if (process.env.NODE_ENV !== "production") {
|
15224 | throw new Error(`[Vant] DatePicker: unsupported columns type: ${type}`);
|
15225 | }
|
15226 | return [];
|
15227 | }
|
15228 | });
|
15229 | });
|
15230 | watch(currentValues, (newValues) => {
|
15231 | if (!isSameValue(newValues, props2.modelValue)) {
|
15232 | emit("update:modelValue", newValues);
|
15233 | }
|
15234 | });
|
15235 | watch(() => props2.modelValue, (newValues) => {
|
15236 | newValues = formatValueRange(newValues, columns.value);
|
15237 | if (!isSameValue(newValues, currentValues.value)) {
|
15238 | currentValues.value = newValues;
|
15239 | }
|
15240 | }, {
|
15241 | immediate: true
|
15242 | });
|
15243 | const onChange = (...args) => emit("change", ...args);
|
15244 | const onCancel = (...args) => emit("cancel", ...args);
|
15245 | const onConfirm = (...args) => emit("confirm", ...args);
|
15246 | return () => createVNode(Picker, mergeProps({
|
15247 | "modelValue": currentValues.value,
|
15248 | "onUpdate:modelValue": ($event) => currentValues.value = $event,
|
15249 | "columns": columns.value,
|
15250 | "onChange": onChange,
|
15251 | "onCancel": onCancel,
|
15252 | "onConfirm": onConfirm
|
15253 | }, pick(props2, pickerInheritKeys)), slots);
|
15254 | }
|
15255 | });
|
15256 | const TimePicker = withInstall(stdin_default$8);
|
15257 | const [name$2, bem$2] = createNamespace("tree-select");
|
15258 | const treeSelectProps = {
|
15259 | max: makeNumericProp(Infinity),
|
15260 | items: makeArrayProp(),
|
15261 | height: makeNumericProp(300),
|
15262 | selectedIcon: makeStringProp("success"),
|
15263 | mainActiveIndex: makeNumericProp(0),
|
15264 | activeId: {
|
15265 | type: [Number, String, Array],
|
15266 | default: 0
|
15267 | }
|
15268 | };
|
15269 | var stdin_default$7 = defineComponent({
|
15270 | name: name$2,
|
15271 | props: treeSelectProps,
|
15272 | emits: ["clickNav", "clickItem", "update:activeId", "update:mainActiveIndex"],
|
15273 | setup(props2, {
|
15274 | emit,
|
15275 | slots
|
15276 | }) {
|
15277 | const isActiveItem = (id) => Array.isArray(props2.activeId) ? props2.activeId.includes(id) : props2.activeId === id;
|
15278 | const renderSubItem = (item) => {
|
15279 | const onClick = () => {
|
15280 | if (item.disabled) {
|
15281 | return;
|
15282 | }
|
15283 | let activeId;
|
15284 | if (Array.isArray(props2.activeId)) {
|
15285 | activeId = props2.activeId.slice();
|
15286 | const index = activeId.indexOf(item.id);
|
15287 | if (index !== -1) {
|
15288 | activeId.splice(index, 1);
|
15289 | } else if (activeId.length < +props2.max) {
|
15290 | activeId.push(item.id);
|
15291 | }
|
15292 | } else {
|
15293 | activeId = item.id;
|
15294 | }
|
15295 | emit("update:activeId", activeId);
|
15296 | emit("clickItem", item);
|
15297 | };
|
15298 | return createVNode("div", {
|
15299 | "key": item.id,
|
15300 | "class": ["van-ellipsis", bem$2("item", {
|
15301 | active: isActiveItem(item.id),
|
15302 | disabled: item.disabled
|
15303 | })],
|
15304 | "onClick": onClick
|
15305 | }, [item.text, isActiveItem(item.id) && createVNode(Icon, {
|
15306 | "name": props2.selectedIcon,
|
15307 | "class": bem$2("selected")
|
15308 | }, null)]);
|
15309 | };
|
15310 | const onSidebarChange = (index) => {
|
15311 | emit("update:mainActiveIndex", index);
|
15312 | };
|
15313 | const onClickSidebarItem = (index) => emit("clickNav", index);
|
15314 | const renderSidebar = () => {
|
15315 | const Items = props2.items.map((item) => createVNode(SidebarItem, {
|
15316 | "dot": item.dot,
|
15317 | "badge": item.badge,
|
15318 | "class": [bem$2("nav-item"), item.className],
|
15319 | "disabled": item.disabled,
|
15320 | "onClick": onClickSidebarItem
|
15321 | }, {
|
15322 | title: () => slots["nav-text"] ? slots["nav-text"](item) : item.text
|
15323 | }));
|
15324 | return createVNode(Sidebar, {
|
15325 | "class": bem$2("nav"),
|
15326 | "modelValue": props2.mainActiveIndex,
|
15327 | "onChange": onSidebarChange
|
15328 | }, {
|
15329 | default: () => [Items]
|
15330 | });
|
15331 | };
|
15332 | const renderContent = () => {
|
15333 | if (slots.content) {
|
15334 | return slots.content();
|
15335 | }
|
15336 | const selected = props2.items[+props2.mainActiveIndex] || {};
|
15337 | if (selected.children) {
|
15338 | return selected.children.map(renderSubItem);
|
15339 | }
|
15340 | };
|
15341 | return () => createVNode("div", {
|
15342 | "class": bem$2(),
|
15343 | "style": {
|
15344 | height: addUnit(props2.height)
|
15345 | }
|
15346 | }, [renderSidebar(), createVNode("div", {
|
15347 | "class": bem$2("content")
|
15348 | }, [renderContent()])]);
|
15349 | }
|
15350 | });
|
15351 | const TreeSelect = withInstall(stdin_default$7);
|
15352 | const [name$1, bem$1, t] = createNamespace("uploader");
|
15353 | function readFileContent(file, resultType) {
|
15354 | return new Promise((resolve) => {
|
15355 | if (resultType === "file") {
|
15356 | resolve();
|
15357 | return;
|
15358 | }
|
15359 | const reader = new FileReader();
|
15360 | reader.onload = (event) => {
|
15361 | resolve(event.target.result);
|
15362 | };
|
15363 | if (resultType === "dataUrl") {
|
15364 | reader.readAsDataURL(file);
|
15365 | } else if (resultType === "text") {
|
15366 | reader.readAsText(file);
|
15367 | }
|
15368 | });
|
15369 | }
|
15370 | function isOversize(items, maxSize) {
|
15371 | return toArray(items).some((item) => {
|
15372 | if (item.file) {
|
15373 | if (isFunction(maxSize)) {
|
15374 | return maxSize(item.file);
|
15375 | }
|
15376 | return item.file.size > +maxSize;
|
15377 | }
|
15378 | return false;
|
15379 | });
|
15380 | }
|
15381 | function filterFiles(items, maxSize) {
|
15382 | const valid = [];
|
15383 | const invalid = [];
|
15384 | items.forEach((item) => {
|
15385 | if (isOversize(item, maxSize)) {
|
15386 | invalid.push(item);
|
15387 | } else {
|
15388 | valid.push(item);
|
15389 | }
|
15390 | });
|
15391 | return { valid, invalid };
|
15392 | }
|
15393 | const IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg|avif)/i;
|
15394 | const isImageUrl = (url) => IMAGE_REGEXP.test(url);
|
15395 | function isImageFile(item) {
|
15396 | if (item.isImage) {
|
15397 | return true;
|
15398 | }
|
15399 | if (item.file && item.file.type) {
|
15400 | return item.file.type.indexOf("image") === 0;
|
15401 | }
|
15402 | if (item.url) {
|
15403 | return isImageUrl(item.url);
|
15404 | }
|
15405 | if (typeof item.content === "string") {
|
15406 | return item.content.indexOf("data:image") === 0;
|
15407 | }
|
15408 | return false;
|
15409 | }
|
15410 | var stdin_default$6 = defineComponent({
|
15411 | props: {
|
15412 | name: numericProp,
|
15413 | item: makeRequiredProp(Object),
|
15414 | index: Number,
|
15415 | imageFit: String,
|
15416 | lazyLoad: Boolean,
|
15417 | deletable: Boolean,
|
15418 | reupload: Boolean,
|
15419 | previewSize: [Number, String, Array],
|
15420 | beforeDelete: Function
|
15421 | },
|
15422 | emits: ["delete", "preview", "reupload"],
|
15423 | setup(props2, {
|
15424 | emit,
|
15425 | slots
|
15426 | }) {
|
15427 | const renderMask = () => {
|
15428 | const {
|
15429 | status,
|
15430 | message
|
15431 | } = props2.item;
|
15432 | if (status === "uploading" || status === "failed") {
|
15433 | const MaskIcon = status === "failed" ? createVNode(Icon, {
|
15434 | "name": "close",
|
15435 | "class": bem$1("mask-icon")
|
15436 | }, null) : createVNode(Loading, {
|
15437 | "class": bem$1("loading")
|
15438 | }, null);
|
15439 | const showMessage = isDef(message) && message !== "";
|
15440 | return createVNode("div", {
|
15441 | "class": bem$1("mask")
|
15442 | }, [MaskIcon, showMessage && createVNode("div", {
|
15443 | "class": bem$1("mask-message")
|
15444 | }, [message])]);
|
15445 | }
|
15446 | };
|
15447 | const onDelete = (event) => {
|
15448 | const {
|
15449 | name: name2,
|
15450 | item,
|
15451 | index,
|
15452 | beforeDelete
|
15453 | } = props2;
|
15454 | event.stopPropagation();
|
15455 | callInterceptor(beforeDelete, {
|
15456 | args: [item, {
|
15457 | name: name2,
|
15458 | index
|
15459 | }],
|
15460 | done: () => emit("delete")
|
15461 | });
|
15462 | };
|
15463 | const onPreview = () => emit("preview");
|
15464 | const onReupload = () => emit("reupload");
|
15465 | const renderDeleteIcon = () => {
|
15466 | if (props2.deletable && props2.item.status !== "uploading") {
|
15467 | const slot = slots["preview-delete"];
|
15468 | return createVNode("div", {
|
15469 | "role": "button",
|
15470 | "class": bem$1("preview-delete", {
|
15471 | shadow: !slot
|
15472 | }),
|
15473 | "tabindex": 0,
|
15474 | "aria-label": t("delete"),
|
15475 | "onClick": onDelete
|
15476 | }, [slot ? slot() : createVNode(Icon, {
|
15477 | "name": "cross",
|
15478 | "class": bem$1("preview-delete-icon")
|
15479 | }, null)]);
|
15480 | }
|
15481 | };
|
15482 | const renderCover = () => {
|
15483 | if (slots["preview-cover"]) {
|
15484 | const {
|
15485 | index,
|
15486 | item
|
15487 | } = props2;
|
15488 | return createVNode("div", {
|
15489 | "class": bem$1("preview-cover")
|
15490 | }, [slots["preview-cover"](extend({
|
15491 | index
|
15492 | }, item))]);
|
15493 | }
|
15494 | };
|
15495 | const renderPreview = () => {
|
15496 | const {
|
15497 | item,
|
15498 | lazyLoad,
|
15499 | imageFit,
|
15500 | previewSize,
|
15501 | reupload
|
15502 | } = props2;
|
15503 | if (isImageFile(item)) {
|
15504 | return createVNode(Image$1, {
|
15505 | "fit": imageFit,
|
15506 | "src": item.objectUrl || item.content || item.url,
|
15507 | "class": bem$1("preview-image"),
|
15508 | "width": Array.isArray(previewSize) ? previewSize[0] : previewSize,
|
15509 | "height": Array.isArray(previewSize) ? previewSize[1] : previewSize,
|
15510 | "lazyLoad": lazyLoad,
|
15511 | "onClick": reupload ? onReupload : onPreview
|
15512 | }, {
|
15513 | default: renderCover
|
15514 | });
|
15515 | }
|
15516 | return createVNode("div", {
|
15517 | "class": bem$1("file"),
|
15518 | "style": getSizeStyle(props2.previewSize)
|
15519 | }, [createVNode(Icon, {
|
15520 | "class": bem$1("file-icon"),
|
15521 | "name": "description"
|
15522 | }, null), createVNode("div", {
|
15523 | "class": [bem$1("file-name"), "van-ellipsis"]
|
15524 | }, [item.file ? item.file.name : item.url]), renderCover()]);
|
15525 | };
|
15526 | return () => createVNode("div", {
|
15527 | "class": bem$1("preview")
|
15528 | }, [renderPreview(), renderMask(), renderDeleteIcon()]);
|
15529 | }
|
15530 | });
|
15531 | const uploaderProps = {
|
15532 | name: makeNumericProp(""),
|
15533 | accept: makeStringProp("image/*"),
|
15534 | capture: String,
|
15535 | multiple: Boolean,
|
15536 | disabled: Boolean,
|
15537 | readonly: Boolean,
|
15538 | lazyLoad: Boolean,
|
15539 | maxCount: makeNumericProp(Infinity),
|
15540 | imageFit: makeStringProp("cover"),
|
15541 | resultType: makeStringProp("dataUrl"),
|
15542 | uploadIcon: makeStringProp("photograph"),
|
15543 | uploadText: String,
|
15544 | deletable: truthProp,
|
15545 | reupload: Boolean,
|
15546 | afterRead: Function,
|
15547 | showUpload: truthProp,
|
15548 | modelValue: makeArrayProp(),
|
15549 | beforeRead: Function,
|
15550 | beforeDelete: Function,
|
15551 | previewSize: [Number, String, Array],
|
15552 | previewImage: truthProp,
|
15553 | previewOptions: Object,
|
15554 | previewFullImage: truthProp,
|
15555 | maxSize: {
|
15556 | type: [Number, String, Function],
|
15557 | default: Infinity
|
15558 | }
|
15559 | };
|
15560 | var stdin_default$5 = defineComponent({
|
15561 | name: name$1,
|
15562 | props: uploaderProps,
|
15563 | emits: ["delete", "oversize", "clickUpload", "closePreview", "clickPreview", "clickReupload", "update:modelValue"],
|
15564 | setup(props2, {
|
15565 | emit,
|
15566 | slots
|
15567 | }) {
|
15568 | const inputRef = ref();
|
15569 | const urls = [];
|
15570 | const reuploadIndex = ref(-1);
|
15571 | const isReuploading = ref(false);
|
15572 | const getDetail = (index = props2.modelValue.length) => ({
|
15573 | name: props2.name,
|
15574 | index
|
15575 | });
|
15576 | const resetInput = () => {
|
15577 | if (inputRef.value) {
|
15578 | inputRef.value.value = "";
|
15579 | }
|
15580 | };
|
15581 | const onAfterRead = (items) => {
|
15582 | resetInput();
|
15583 | if (isOversize(items, props2.maxSize)) {
|
15584 | if (Array.isArray(items)) {
|
15585 | const result = filterFiles(items, props2.maxSize);
|
15586 | items = result.valid;
|
15587 | emit("oversize", result.invalid, getDetail());
|
15588 | if (!items.length) {
|
15589 | return;
|
15590 | }
|
15591 | } else {
|
15592 | emit("oversize", items, getDetail());
|
15593 | return;
|
15594 | }
|
15595 | }
|
15596 | items = reactive(items);
|
15597 | if (reuploadIndex.value > -1) {
|
15598 | const arr = [...props2.modelValue];
|
15599 | arr.splice(reuploadIndex.value, 1, items);
|
15600 | emit("update:modelValue", arr);
|
15601 | reuploadIndex.value = -1;
|
15602 | } else {
|
15603 | emit("update:modelValue", [...props2.modelValue, ...toArray(items)]);
|
15604 | }
|
15605 | if (props2.afterRead) {
|
15606 | props2.afterRead(items, getDetail());
|
15607 | }
|
15608 | };
|
15609 | const readFile = (files) => {
|
15610 | const {
|
15611 | maxCount,
|
15612 | modelValue,
|
15613 | resultType
|
15614 | } = props2;
|
15615 | if (Array.isArray(files)) {
|
15616 | const remainCount = +maxCount - modelValue.length;
|
15617 | if (files.length > remainCount) {
|
15618 | files = files.slice(0, remainCount);
|
15619 | }
|
15620 | Promise.all(files.map((file) => readFileContent(file, resultType))).then((contents) => {
|
15621 | const fileList = files.map((file, index) => {
|
15622 | const result = {
|
15623 | file,
|
15624 | status: "",
|
15625 | message: "",
|
15626 | objectUrl: URL.createObjectURL(file)
|
15627 | };
|
15628 | if (contents[index]) {
|
15629 | result.content = contents[index];
|
15630 | }
|
15631 | return result;
|
15632 | });
|
15633 | onAfterRead(fileList);
|
15634 | });
|
15635 | } else {
|
15636 | readFileContent(files, resultType).then((content) => {
|
15637 | const result = {
|
15638 | file: files,
|
15639 | status: "",
|
15640 | message: "",
|
15641 | objectUrl: URL.createObjectURL(files)
|
15642 | };
|
15643 | if (content) {
|
15644 | result.content = content;
|
15645 | }
|
15646 | onAfterRead(result);
|
15647 | });
|
15648 | }
|
15649 | };
|
15650 | const onChange = (event) => {
|
15651 | const {
|
15652 | files
|
15653 | } = event.target;
|
15654 | if (props2.disabled || !files || !files.length) {
|
15655 | return;
|
15656 | }
|
15657 | const file = files.length === 1 ? files[0] : [].slice.call(files);
|
15658 | if (props2.beforeRead) {
|
15659 | const response = props2.beforeRead(file, getDetail());
|
15660 | if (!response) {
|
15661 | resetInput();
|
15662 | return;
|
15663 | }
|
15664 | if (isPromise(response)) {
|
15665 | response.then((data) => {
|
15666 | if (data) {
|
15667 | readFile(data);
|
15668 | } else {
|
15669 | readFile(file);
|
15670 | }
|
15671 | }).catch(resetInput);
|
15672 | return;
|
15673 | }
|
15674 | }
|
15675 | readFile(file);
|
15676 | };
|
15677 | let imagePreview;
|
15678 | const onClosePreview = () => emit("closePreview");
|
15679 | const previewImage = (item) => {
|
15680 | if (props2.previewFullImage) {
|
15681 | const imageFiles = props2.modelValue.filter(isImageFile);
|
15682 | const images = imageFiles.map((item2) => {
|
15683 | if (item2.objectUrl && !item2.url && item2.status !== "failed") {
|
15684 | item2.url = item2.objectUrl;
|
15685 | urls.push(item2.url);
|
15686 | }
|
15687 | return item2.url;
|
15688 | }).filter(Boolean);
|
15689 | imagePreview = showImagePreview(extend({
|
15690 | images,
|
15691 | startPosition: imageFiles.indexOf(item),
|
15692 | onClose: onClosePreview
|
15693 | }, props2.previewOptions));
|
15694 | }
|
15695 | };
|
15696 | const closeImagePreview = () => {
|
15697 | if (imagePreview) {
|
15698 | imagePreview.close();
|
15699 | }
|
15700 | };
|
15701 | const deleteFile = (item, index) => {
|
15702 | const fileList = props2.modelValue.slice(0);
|
15703 | fileList.splice(index, 1);
|
15704 | emit("update:modelValue", fileList);
|
15705 | emit("delete", item, getDetail(index));
|
15706 | };
|
15707 | const reuploadImage = (index) => {
|
15708 | isReuploading.value = true;
|
15709 | reuploadIndex.value = index;
|
15710 | nextTick(() => chooseFile());
|
15711 | };
|
15712 | const onInputClick = () => {
|
15713 | if (!isReuploading.value) {
|
15714 | reuploadIndex.value = -1;
|
15715 | }
|
15716 | isReuploading.value = false;
|
15717 | };
|
15718 | const renderPreviewItem = (item, index) => {
|
15719 | const needPickData = ["imageFit", "deletable", "reupload", "previewSize", "beforeDelete"];
|
15720 | const previewData = extend(pick(props2, needPickData), pick(item, needPickData, true));
|
15721 | return createVNode(stdin_default$6, mergeProps({
|
15722 | "item": item,
|
15723 | "index": index,
|
15724 | "onClick": () => emit(props2.reupload ? "clickReupload" : "clickPreview", item, getDetail(index)),
|
15725 | "onDelete": () => deleteFile(item, index),
|
15726 | "onPreview": () => previewImage(item),
|
15727 | "onReupload": () => reuploadImage(index)
|
15728 | }, pick(props2, ["name", "lazyLoad"]), previewData), pick(slots, ["preview-cover", "preview-delete"]));
|
15729 | };
|
15730 | const renderPreviewList = () => {
|
15731 | if (props2.previewImage) {
|
15732 | return props2.modelValue.map(renderPreviewItem);
|
15733 | }
|
15734 | };
|
15735 | const onClickUpload = (event) => emit("clickUpload", event);
|
15736 | const renderUpload = () => {
|
15737 | if (props2.modelValue.length >= +props2.maxCount && !props2.reupload) {
|
15738 | return;
|
15739 | }
|
15740 | const hideUploader = props2.modelValue.length >= +props2.maxCount && props2.reupload;
|
15741 | const Input = props2.readonly ? null : createVNode("input", {
|
15742 | "ref": inputRef,
|
15743 | "type": "file",
|
15744 | "class": bem$1("input"),
|
15745 | "accept": props2.accept,
|
15746 | "capture": props2.capture,
|
15747 | "multiple": props2.multiple && reuploadIndex.value === -1,
|
15748 | "disabled": props2.disabled,
|
15749 | "onChange": onChange,
|
15750 | "onClick": onInputClick
|
15751 | }, null);
|
15752 | if (slots.default) {
|
15753 | return withDirectives(createVNode("div", {
|
15754 | "class": bem$1("input-wrapper"),
|
15755 | "onClick": onClickUpload
|
15756 | }, [slots.default(), Input]), [[vShow, !hideUploader]]);
|
15757 | }
|
15758 | return withDirectives(createVNode("div", {
|
15759 | "class": bem$1("upload", {
|
15760 | readonly: props2.readonly
|
15761 | }),
|
15762 | "style": getSizeStyle(props2.previewSize),
|
15763 | "onClick": onClickUpload
|
15764 | }, [createVNode(Icon, {
|
15765 | "name": props2.uploadIcon,
|
15766 | "class": bem$1("upload-icon")
|
15767 | }, null), props2.uploadText && createVNode("span", {
|
15768 | "class": bem$1("upload-text")
|
15769 | }, [props2.uploadText]), Input]), [[vShow, props2.showUpload && !hideUploader]]);
|
15770 | };
|
15771 | const chooseFile = () => {
|
15772 | if (inputRef.value && !props2.disabled) {
|
15773 | inputRef.value.click();
|
15774 | }
|
15775 | };
|
15776 | onBeforeUnmount(() => {
|
15777 | urls.forEach((url) => URL.revokeObjectURL(url));
|
15778 | });
|
15779 | useExpose({
|
15780 | chooseFile,
|
15781 | closeImagePreview
|
15782 | });
|
15783 | useCustomFieldValue(() => props2.modelValue);
|
15784 | return () => createVNode("div", {
|
15785 | "class": bem$1()
|
15786 | }, [createVNode("div", {
|
15787 | "class": bem$1("wrapper", {
|
15788 | disabled: props2.disabled
|
15789 | })
|
15790 | }, [renderPreviewList(), renderUpload()])]);
|
15791 | }
|
15792 | });
|
15793 | const Uploader = withInstall(stdin_default$5);
|
15794 | const [name, bem] = createNamespace("watermark");
|
15795 | const watermarkProps = {
|
15796 | gapX: makeNumberProp(0),
|
15797 | gapY: makeNumberProp(0),
|
15798 | image: String,
|
15799 | width: makeNumberProp(100),
|
15800 | height: makeNumberProp(100),
|
15801 | rotate: makeNumericProp(-22),
|
15802 | zIndex: numericProp,
|
15803 | content: String,
|
15804 | opacity: numericProp,
|
15805 | fullPage: truthProp,
|
15806 | textColor: makeStringProp("#dcdee0")
|
15807 | };
|
15808 | var stdin_default$4 = defineComponent({
|
15809 | name,
|
15810 | props: watermarkProps,
|
15811 | setup(props2, {
|
15812 | slots
|
15813 | }) {
|
15814 | const svgElRef = ref();
|
15815 | const watermarkUrl = ref("");
|
15816 | const imageBase64 = ref("");
|
15817 | const renderWatermark = () => {
|
15818 | const rotateStyle = {
|
15819 | transformOrigin: "center",
|
15820 | transform: `rotate(${props2.rotate}deg)`
|
15821 | };
|
15822 | const svgInner = () => {
|
15823 | if (props2.image && !slots.content) {
|
15824 | return createVNode("image", {
|
15825 | "href": imageBase64.value,
|
15826 | "xlink:href": imageBase64.value,
|
15827 | "x": "0",
|
15828 | "y": "0",
|
15829 | "width": props2.width,
|
15830 | "height": props2.height,
|
15831 | "style": rotateStyle
|
15832 | }, null);
|
15833 | }
|
15834 | return createVNode("foreignObject", {
|
15835 | "x": "0",
|
15836 | "y": "0",
|
15837 | "width": props2.width,
|
15838 | "height": props2.height
|
15839 | }, [createVNode("div", {
|
15840 | "xmlns": "http://www.w3.org/1999/xhtml",
|
15841 | "style": rotateStyle
|
15842 | }, [slots.content ? slots.content() : createVNode("span", {
|
15843 | "style": {
|
15844 | color: props2.textColor
|
15845 | }
|
15846 | }, [props2.content])])]);
|
15847 | };
|
15848 | const svgWidth = props2.width + props2.gapX;
|
15849 | const svgHeight = props2.height + props2.gapY;
|
15850 | return createVNode("svg", {
|
15851 | "viewBox": `0 0 ${svgWidth} ${svgHeight}`,
|
15852 | "width": svgWidth,
|
15853 | "height": svgHeight,
|
15854 | "xmlns": "http://www.w3.org/2000/svg",
|
15855 | "xmlns:xlink": "http://www.w3.org/1999/xlink",
|
15856 | "style": {
|
15857 | padding: `0 ${props2.gapX}px ${props2.gapY}px 0`,
|
15858 | opacity: props2.opacity
|
15859 | }
|
15860 | }, [svgInner()]);
|
15861 | };
|
15862 | const makeImageToBase64 = (url) => {
|
15863 | const canvas = document.createElement("canvas");
|
15864 | const image = new Image();
|
15865 | image.crossOrigin = "anonymous";
|
15866 | image.referrerPolicy = "no-referrer";
|
15867 | image.onload = () => {
|
15868 | canvas.width = image.naturalWidth;
|
15869 | canvas.height = image.naturalHeight;
|
15870 | const ctx = canvas.getContext("2d");
|
15871 | ctx == null ? void 0 : ctx.drawImage(image, 0, 0);
|
15872 | imageBase64.value = canvas.toDataURL();
|
15873 | };
|
15874 | image.src = url;
|
15875 | };
|
15876 | const makeSvgToBlobUrl = (svgStr) => {
|
15877 | const svgBlob = new Blob([svgStr], {
|
15878 | type: "image/svg+xml"
|
15879 | });
|
15880 | return URL.createObjectURL(svgBlob);
|
15881 | };
|
15882 | watchEffect(() => {
|
15883 | if (props2.image) {
|
15884 | makeImageToBase64(props2.image);
|
15885 | }
|
15886 | });
|
15887 | watch(() => [imageBase64.value, props2.content, props2.textColor, props2.height, props2.width, props2.rotate, props2.gapX, props2.gapY], () => {
|
15888 | nextTick(() => {
|
15889 | if (svgElRef.value) {
|
15890 | if (watermarkUrl.value) {
|
15891 | URL.revokeObjectURL(watermarkUrl.value);
|
15892 | }
|
15893 | watermarkUrl.value = makeSvgToBlobUrl(svgElRef.value.innerHTML);
|
15894 | }
|
15895 | });
|
15896 | }, {
|
15897 | immediate: true
|
15898 | });
|
15899 | onUnmounted(() => {
|
15900 | if (watermarkUrl.value) {
|
15901 | URL.revokeObjectURL(watermarkUrl.value);
|
15902 | }
|
15903 | });
|
15904 | return () => {
|
15905 | const style = extend({
|
15906 | backgroundImage: `url(${watermarkUrl.value})`
|
15907 | }, getZIndexStyle(props2.zIndex));
|
15908 | return createVNode("div", {
|
15909 | "class": bem({
|
15910 | full: props2.fullPage
|
15911 | }),
|
15912 | "style": style
|
15913 | }, [createVNode("div", {
|
15914 | "class": bem("wrapper"),
|
15915 | "ref": svgElRef
|
15916 | }, [renderWatermark()])]);
|
15917 | };
|
15918 | }
|
15919 | });
|
15920 | const Watermark = withInstall(stdin_default$4);
|
15921 | class ReactiveListener {
|
15922 | constructor({
|
15923 | el,
|
15924 | src,
|
15925 | error,
|
15926 | loading,
|
15927 | bindType,
|
15928 | $parent,
|
15929 | options,
|
15930 | cors,
|
15931 | elRenderer,
|
15932 | imageCache
|
15933 | }) {
|
15934 | this.el = el;
|
15935 | this.src = src;
|
15936 | this.error = error;
|
15937 | this.loading = loading;
|
15938 | this.bindType = bindType;
|
15939 | this.attempt = 0;
|
15940 | this.cors = cors;
|
15941 | this.naturalHeight = 0;
|
15942 | this.naturalWidth = 0;
|
15943 | this.options = options;
|
15944 | this.$parent = $parent;
|
15945 | this.elRenderer = elRenderer;
|
15946 | this.imageCache = imageCache;
|
15947 | this.performanceData = {
|
15948 | loadStart: 0,
|
15949 | loadEnd: 0
|
15950 | };
|
15951 | this.filter();
|
15952 | this.initState();
|
15953 | this.render("loading", false);
|
15954 | }
|
15955 | |
15956 |
|
15957 |
|
15958 |
|
15959 | initState() {
|
15960 | if ("dataset" in this.el) {
|
15961 | this.el.dataset.src = this.src;
|
15962 | } else {
|
15963 | this.el.setAttribute("data-src", this.src);
|
15964 | }
|
15965 | this.state = {
|
15966 | loading: false,
|
15967 | error: false,
|
15968 | loaded: false,
|
15969 | rendered: false
|
15970 | };
|
15971 | }
|
15972 | |
15973 |
|
15974 |
|
15975 |
|
15976 | record(event) {
|
15977 | this.performanceData[event] = Date.now();
|
15978 | }
|
15979 | |
15980 |
|
15981 |
|
15982 |
|
15983 |
|
15984 |
|
15985 |
|
15986 | update({ src, loading, error }) {
|
15987 | const oldSrc = this.src;
|
15988 | this.src = src;
|
15989 | this.loading = loading;
|
15990 | this.error = error;
|
15991 | this.filter();
|
15992 | if (oldSrc !== this.src) {
|
15993 | this.attempt = 0;
|
15994 | this.initState();
|
15995 | }
|
15996 | }
|
15997 | |
15998 |
|
15999 |
|
16000 |
|
16001 | checkInView() {
|
16002 | const rect = useRect(this.el);
|
16003 | return rect.top < window.innerHeight * this.options.preLoad && rect.bottom > this.options.preLoadTop && rect.left < window.innerWidth * this.options.preLoad && rect.right > 0;
|
16004 | }
|
16005 | |
16006 |
|
16007 |
|
16008 | filter() {
|
16009 | Object.keys(this.options.filter).forEach((key) => {
|
16010 | this.options.filter[key](this, this.options);
|
16011 | });
|
16012 | }
|
16013 | |
16014 |
|
16015 |
|
16016 |
|
16017 |
|
16018 | renderLoading(cb) {
|
16019 | this.state.loading = true;
|
16020 | loadImageAsync(
|
16021 | {
|
16022 | src: this.loading,
|
16023 | cors: this.cors
|
16024 | },
|
16025 | () => {
|
16026 | this.render("loading", false);
|
16027 | this.state.loading = false;
|
16028 | cb();
|
16029 | },
|
16030 | () => {
|
16031 | cb();
|
16032 | this.state.loading = false;
|
16033 | if (process.env.NODE_ENV !== "production" && !this.options.silent)
|
16034 | console.warn(
|
16035 | `[@vant/lazyload] load failed with loading image(${this.loading})`
|
16036 | );
|
16037 | }
|
16038 | );
|
16039 | }
|
16040 | |
16041 |
|
16042 |
|
16043 |
|
16044 | load(onFinish = noop) {
|
16045 | if (this.attempt > this.options.attempt - 1 && this.state.error) {
|
16046 | if (process.env.NODE_ENV !== "production" && !this.options.silent) {
|
16047 | console.log(
|
16048 | `[@vant/lazyload] ${this.src} tried too more than ${this.options.attempt} times`
|
16049 | );
|
16050 | }
|
16051 | onFinish();
|
16052 | return;
|
16053 | }
|
16054 | if (this.state.rendered && this.state.loaded)
|
16055 | return;
|
16056 | if (this.imageCache.has(this.src)) {
|
16057 | this.state.loaded = true;
|
16058 | this.render("loaded", true);
|
16059 | this.state.rendered = true;
|
16060 | return onFinish();
|
16061 | }
|
16062 | this.renderLoading(() => {
|
16063 | var _a, _b;
|
16064 | this.attempt++;
|
16065 | (_b = (_a = this.options.adapter).beforeLoad) == null ? void 0 : _b.call(_a, this, this.options);
|
16066 | this.record("loadStart");
|
16067 | loadImageAsync(
|
16068 | {
|
16069 | src: this.src,
|
16070 | cors: this.cors
|
16071 | },
|
16072 | (data) => {
|
16073 | this.naturalHeight = data.naturalHeight;
|
16074 | this.naturalWidth = data.naturalWidth;
|
16075 | this.state.loaded = true;
|
16076 | this.state.error = false;
|
16077 | this.record("loadEnd");
|
16078 | this.render("loaded", false);
|
16079 | this.state.rendered = true;
|
16080 | this.imageCache.add(this.src);
|
16081 | onFinish();
|
16082 | },
|
16083 | (err) => {
|
16084 | !this.options.silent && console.error(err);
|
16085 | this.state.error = true;
|
16086 | this.state.loaded = false;
|
16087 | this.render("error", false);
|
16088 | }
|
16089 | );
|
16090 | });
|
16091 | }
|
16092 | |
16093 |
|
16094 |
|
16095 |
|
16096 |
|
16097 |
|
16098 | render(state, cache) {
|
16099 | this.elRenderer(this, state, cache);
|
16100 | }
|
16101 | |
16102 |
|
16103 |
|
16104 |
|
16105 | performance() {
|
16106 | let state = "loading";
|
16107 | let time = 0;
|
16108 | if (this.state.loaded) {
|
16109 | state = "loaded";
|
16110 | time = (this.performanceData.loadEnd - this.performanceData.loadStart) / 1e3;
|
16111 | }
|
16112 | if (this.state.error)
|
16113 | state = "error";
|
16114 | return {
|
16115 | src: this.src,
|
16116 | state,
|
16117 | time
|
16118 | };
|
16119 | }
|
16120 | |
16121 |
|
16122 |
|
16123 |
|
16124 | $destroy() {
|
16125 | this.el = null;
|
16126 | this.src = null;
|
16127 | this.error = null;
|
16128 | this.loading = null;
|
16129 | this.bindType = null;
|
16130 | this.attempt = 0;
|
16131 | }
|
16132 | }
|
16133 | const DEFAULT_URL = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
|
16134 | const DEFAULT_EVENTS = [
|
16135 | "scroll",
|
16136 | "wheel",
|
16137 | "mousewheel",
|
16138 | "resize",
|
16139 | "animationend",
|
16140 | "transitionend",
|
16141 | "touchmove"
|
16142 | ];
|
16143 | const DEFAULT_OBSERVER_OPTIONS = {
|
16144 | rootMargin: "0px",
|
16145 | threshold: 0
|
16146 | };
|
16147 | function stdin_default$3() {
|
16148 | return class Lazy {
|
16149 | constructor({
|
16150 | preLoad,
|
16151 | error,
|
16152 | throttleWait,
|
16153 | preLoadTop,
|
16154 | dispatchEvent,
|
16155 | loading,
|
16156 | attempt,
|
16157 | silent = true,
|
16158 | scale,
|
16159 | listenEvents,
|
16160 | filter,
|
16161 | adapter,
|
16162 | observer,
|
16163 | observerOptions
|
16164 | }) {
|
16165 | this.mode = modeType.event;
|
16166 | this.listeners = [];
|
16167 | this.targetIndex = 0;
|
16168 | this.targets = [];
|
16169 | this.options = {
|
16170 | silent,
|
16171 | dispatchEvent: !!dispatchEvent,
|
16172 | throttleWait: throttleWait || 200,
|
16173 | preLoad: preLoad || 1.3,
|
16174 | preLoadTop: preLoadTop || 0,
|
16175 | error: error || DEFAULT_URL,
|
16176 | loading: loading || DEFAULT_URL,
|
16177 | attempt: attempt || 3,
|
16178 | scale: scale || getDPR(scale),
|
16179 | ListenEvents: listenEvents || DEFAULT_EVENTS,
|
16180 | supportWebp: supportWebp(),
|
16181 | filter: filter || {},
|
16182 | adapter: adapter || {},
|
16183 | observer: !!observer,
|
16184 | observerOptions: observerOptions || DEFAULT_OBSERVER_OPTIONS
|
16185 | };
|
16186 | this.initEvent();
|
16187 | this.imageCache = new ImageCache({ max: 200 });
|
16188 | this.lazyLoadHandler = throttle(
|
16189 | this.lazyLoadHandler.bind(this),
|
16190 | this.options.throttleWait
|
16191 | );
|
16192 | this.setMode(this.options.observer ? modeType.observer : modeType.event);
|
16193 | }
|
16194 | |
16195 |
|
16196 |
|
16197 |
|
16198 |
|
16199 | config(options = {}) {
|
16200 | Object.assign(this.options, options);
|
16201 | }
|
16202 | |
16203 |
|
16204 |
|
16205 |
|
16206 | performance() {
|
16207 | return this.listeners.map((item) => item.performance());
|
16208 | }
|
16209 | |
16210 |
|
16211 |
|
16212 |
|
16213 |
|
16214 | addLazyBox(vm) {
|
16215 | this.listeners.push(vm);
|
16216 | if (inBrowser$1) {
|
16217 | this.addListenerTarget(window);
|
16218 | this.observer && this.observer.observe(vm.el);
|
16219 | if (vm.$el && vm.$el.parentNode) {
|
16220 | this.addListenerTarget(vm.$el.parentNode);
|
16221 | }
|
16222 | }
|
16223 | }
|
16224 | |
16225 |
|
16226 |
|
16227 |
|
16228 |
|
16229 |
|
16230 |
|
16231 | add(el, binding, vnode) {
|
16232 | if (this.listeners.some((item) => item.el === el)) {
|
16233 | this.update(el, binding);
|
16234 | return nextTick(this.lazyLoadHandler);
|
16235 | }
|
16236 | const value = this.valueFormatter(binding.value);
|
16237 | let { src } = value;
|
16238 | nextTick(() => {
|
16239 | src = getBestSelectionFromSrcset(el, this.options.scale) || src;
|
16240 | this.observer && this.observer.observe(el);
|
16241 | const container = Object.keys(binding.modifiers)[0];
|
16242 | let $parent;
|
16243 | if (container) {
|
16244 | $parent = vnode.context.$refs[container];
|
16245 | $parent = $parent ? $parent.$el || $parent : document.getElementById(container);
|
16246 | }
|
16247 | if (!$parent) {
|
16248 | $parent = getScrollParent(el);
|
16249 | }
|
16250 | const newListener = new ReactiveListener({
|
16251 | bindType: binding.arg,
|
16252 | $parent,
|
16253 | el,
|
16254 | src,
|
16255 | loading: value.loading,
|
16256 | error: value.error,
|
16257 | cors: value.cors,
|
16258 | elRenderer: this.elRenderer.bind(this),
|
16259 | options: this.options,
|
16260 | imageCache: this.imageCache
|
16261 | });
|
16262 | this.listeners.push(newListener);
|
16263 | if (inBrowser$1) {
|
16264 | this.addListenerTarget(window);
|
16265 | this.addListenerTarget($parent);
|
16266 | }
|
16267 | this.lazyLoadHandler();
|
16268 | nextTick(() => this.lazyLoadHandler());
|
16269 | });
|
16270 | }
|
16271 | |
16272 |
|
16273 |
|
16274 |
|
16275 |
|
16276 |
|
16277 | update(el, binding, vnode) {
|
16278 | const value = this.valueFormatter(binding.value);
|
16279 | let { src } = value;
|
16280 | src = getBestSelectionFromSrcset(el, this.options.scale) || src;
|
16281 | const exist = this.listeners.find((item) => item.el === el);
|
16282 | if (!exist) {
|
16283 | this.add(el, binding, vnode);
|
16284 | } else {
|
16285 | exist.update({
|
16286 | src,
|
16287 | error: value.error,
|
16288 | loading: value.loading
|
16289 | });
|
16290 | }
|
16291 | if (this.observer) {
|
16292 | this.observer.unobserve(el);
|
16293 | this.observer.observe(el);
|
16294 | }
|
16295 | this.lazyLoadHandler();
|
16296 | nextTick(() => this.lazyLoadHandler());
|
16297 | }
|
16298 | |
16299 |
|
16300 |
|
16301 |
|
16302 |
|
16303 | remove(el) {
|
16304 | if (!el)
|
16305 | return;
|
16306 | this.observer && this.observer.unobserve(el);
|
16307 | const existItem = this.listeners.find((item) => item.el === el);
|
16308 | if (existItem) {
|
16309 | this.removeListenerTarget(existItem.$parent);
|
16310 | this.removeListenerTarget(window);
|
16311 | remove(this.listeners, existItem);
|
16312 | existItem.$destroy();
|
16313 | }
|
16314 | }
|
16315 | |
16316 |
|
16317 |
|
16318 |
|
16319 |
|
16320 | removeComponent(vm) {
|
16321 | if (!vm)
|
16322 | return;
|
16323 | remove(this.listeners, vm);
|
16324 | this.observer && this.observer.unobserve(vm.el);
|
16325 | if (vm.$parent && vm.$el.parentNode) {
|
16326 | this.removeListenerTarget(vm.$el.parentNode);
|
16327 | }
|
16328 | this.removeListenerTarget(window);
|
16329 | }
|
16330 | setMode(mode) {
|
16331 | if (!hasIntersectionObserver && mode === modeType.observer) {
|
16332 | mode = modeType.event;
|
16333 | }
|
16334 | this.mode = mode;
|
16335 | if (mode === modeType.event) {
|
16336 | if (this.observer) {
|
16337 | this.listeners.forEach((listener) => {
|
16338 | this.observer.unobserve(listener.el);
|
16339 | });
|
16340 | this.observer = null;
|
16341 | }
|
16342 | this.targets.forEach((target) => {
|
16343 | this.initListen(target.el, true);
|
16344 | });
|
16345 | } else {
|
16346 | this.targets.forEach((target) => {
|
16347 | this.initListen(target.el, false);
|
16348 | });
|
16349 | this.initIntersectionObserver();
|
16350 | }
|
16351 | }
|
16352 | |
16353 |
|
16354 |
|
16355 | |
16356 |
|
16357 |
|
16358 |
|
16359 |
|
16360 | addListenerTarget(el) {
|
16361 | if (!el)
|
16362 | return;
|
16363 | let target = this.targets.find((target2) => target2.el === el);
|
16364 | if (!target) {
|
16365 | target = {
|
16366 | el,
|
16367 | id: ++this.targetIndex,
|
16368 | childrenCount: 1,
|
16369 | listened: true
|
16370 | };
|
16371 | this.mode === modeType.event && this.initListen(target.el, true);
|
16372 | this.targets.push(target);
|
16373 | } else {
|
16374 | target.childrenCount++;
|
16375 | }
|
16376 | return this.targetIndex;
|
16377 | }
|
16378 | |
16379 |
|
16380 |
|
16381 |
|
16382 |
|
16383 | removeListenerTarget(el) {
|
16384 | this.targets.forEach((target, index) => {
|
16385 | if (target.el === el) {
|
16386 | target.childrenCount--;
|
16387 | if (!target.childrenCount) {
|
16388 | this.initListen(target.el, false);
|
16389 | this.targets.splice(index, 1);
|
16390 | target = null;
|
16391 | }
|
16392 | }
|
16393 | });
|
16394 | }
|
16395 | |
16396 |
|
16397 |
|
16398 |
|
16399 |
|
16400 |
|
16401 | initListen(el, start) {
|
16402 | this.options.ListenEvents.forEach(
|
16403 | (evt) => (start ? on : off)(el, evt, this.lazyLoadHandler)
|
16404 | );
|
16405 | }
|
16406 | initEvent() {
|
16407 | this.Event = {
|
16408 | listeners: {
|
16409 | loading: [],
|
16410 | loaded: [],
|
16411 | error: []
|
16412 | }
|
16413 | };
|
16414 | this.$on = (event, func) => {
|
16415 | if (!this.Event.listeners[event])
|
16416 | this.Event.listeners[event] = [];
|
16417 | this.Event.listeners[event].push(func);
|
16418 | };
|
16419 | this.$once = (event, func) => {
|
16420 | const on2 = (...args) => {
|
16421 | this.$off(event, on2);
|
16422 | func.apply(this, args);
|
16423 | };
|
16424 | this.$on(event, on2);
|
16425 | };
|
16426 | this.$off = (event, func) => {
|
16427 | if (!func) {
|
16428 | if (!this.Event.listeners[event])
|
16429 | return;
|
16430 | this.Event.listeners[event].length = 0;
|
16431 | return;
|
16432 | }
|
16433 | remove(this.Event.listeners[event], func);
|
16434 | };
|
16435 | this.$emit = (event, context, inCache) => {
|
16436 | if (!this.Event.listeners[event])
|
16437 | return;
|
16438 | this.Event.listeners[event].forEach((func) => func(context, inCache));
|
16439 | };
|
16440 | }
|
16441 | |
16442 |
|
16443 |
|
16444 |
|
16445 | lazyLoadHandler() {
|
16446 | const freeList = [];
|
16447 | this.listeners.forEach((listener) => {
|
16448 | if (!listener.el || !listener.el.parentNode) {
|
16449 | freeList.push(listener);
|
16450 | }
|
16451 | const catIn = listener.checkInView();
|
16452 | if (!catIn)
|
16453 | return;
|
16454 | listener.load();
|
16455 | });
|
16456 | freeList.forEach((item) => {
|
16457 | remove(this.listeners, item);
|
16458 | item.$destroy();
|
16459 | });
|
16460 | }
|
16461 | |
16462 |
|
16463 |
|
16464 |
|
16465 |
|
16466 | initIntersectionObserver() {
|
16467 | if (!hasIntersectionObserver) {
|
16468 | return;
|
16469 | }
|
16470 | this.observer = new IntersectionObserver(
|
16471 | this.observerHandler.bind(this),
|
16472 | this.options.observerOptions
|
16473 | );
|
16474 | if (this.listeners.length) {
|
16475 | this.listeners.forEach((listener) => {
|
16476 | this.observer.observe(listener.el);
|
16477 | });
|
16478 | }
|
16479 | }
|
16480 | |
16481 |
|
16482 |
|
16483 |
|
16484 | observerHandler(entries) {
|
16485 | entries.forEach((entry) => {
|
16486 | if (entry.isIntersecting) {
|
16487 | this.listeners.forEach((listener) => {
|
16488 | if (listener.el === entry.target) {
|
16489 | if (listener.state.loaded)
|
16490 | return this.observer.unobserve(listener.el);
|
16491 | listener.load();
|
16492 | }
|
16493 | });
|
16494 | }
|
16495 | });
|
16496 | }
|
16497 | |
16498 |
|
16499 |
|
16500 |
|
16501 |
|
16502 |
|
16503 |
|
16504 | elRenderer(listener, state, cache) {
|
16505 | if (!listener.el)
|
16506 | return;
|
16507 | const { el, bindType } = listener;
|
16508 | let src;
|
16509 | switch (state) {
|
16510 | case "loading":
|
16511 | src = listener.loading;
|
16512 | break;
|
16513 | case "error":
|
16514 | src = listener.error;
|
16515 | break;
|
16516 | default:
|
16517 | ({ src } = listener);
|
16518 | break;
|
16519 | }
|
16520 | if (bindType) {
|
16521 | el.style[bindType] = 'url("' + src + '")';
|
16522 | } else if (el.getAttribute("src") !== src) {
|
16523 | el.setAttribute("src", src);
|
16524 | }
|
16525 | el.setAttribute("lazy", state);
|
16526 | this.$emit(state, listener, cache);
|
16527 | this.options.adapter[state] && this.options.adapter[state](listener, this.options);
|
16528 | if (this.options.dispatchEvent) {
|
16529 | const event = new CustomEvent(state, {
|
16530 | detail: listener
|
16531 | });
|
16532 | el.dispatchEvent(event);
|
16533 | }
|
16534 | }
|
16535 | |
16536 |
|
16537 |
|
16538 |
|
16539 |
|
16540 | valueFormatter(value) {
|
16541 | let src = value;
|
16542 | let { loading, error } = this.options;
|
16543 | if (isObject(value)) {
|
16544 | if (process.env.NODE_ENV !== "production" && !value.src && !this.options.silent) {
|
16545 | console.error("[@vant/lazyload] miss src with " + value);
|
16546 | }
|
16547 | ({ src } = value);
|
16548 | loading = value.loading || this.options.loading;
|
16549 | error = value.error || this.options.error;
|
16550 | }
|
16551 | return {
|
16552 | src,
|
16553 | loading,
|
16554 | error
|
16555 | };
|
16556 | }
|
16557 | };
|
16558 | }
|
16559 | var stdin_default$2 = (lazy) => ({
|
16560 | props: {
|
16561 | tag: {
|
16562 | type: String,
|
16563 | default: "div"
|
16564 | }
|
16565 | },
|
16566 | emits: ["show"],
|
16567 | render() {
|
16568 | return h(
|
16569 | this.tag,
|
16570 | this.show && this.$slots.default ? this.$slots.default() : null
|
16571 | );
|
16572 | },
|
16573 | data() {
|
16574 | return {
|
16575 | el: null,
|
16576 | state: {
|
16577 | loaded: false
|
16578 | },
|
16579 | show: false
|
16580 | };
|
16581 | },
|
16582 | mounted() {
|
16583 | this.el = this.$el;
|
16584 | lazy.addLazyBox(this);
|
16585 | lazy.lazyLoadHandler();
|
16586 | },
|
16587 | beforeUnmount() {
|
16588 | lazy.removeComponent(this);
|
16589 | },
|
16590 | methods: {
|
16591 | checkInView() {
|
16592 | const rect = useRect(this.$el);
|
16593 | return inBrowser$1 && rect.top < window.innerHeight * lazy.options.preLoad && rect.bottom > 0 && rect.left < window.innerWidth * lazy.options.preLoad && rect.right > 0;
|
16594 | },
|
16595 | load() {
|
16596 | this.show = true;
|
16597 | this.state.loaded = true;
|
16598 | this.$emit("show", this);
|
16599 | },
|
16600 | destroy() {
|
16601 | return this.$destroy;
|
16602 | }
|
16603 | }
|
16604 | });
|
16605 | const defaultOptions = {
|
16606 | selector: "img"
|
16607 | };
|
16608 | class LazyContainer {
|
16609 | constructor({ el, binding, vnode, lazy }) {
|
16610 | this.el = null;
|
16611 | this.vnode = vnode;
|
16612 | this.binding = binding;
|
16613 | this.options = {};
|
16614 | this.lazy = lazy;
|
16615 | this.queue = [];
|
16616 | this.update({ el, binding });
|
16617 | }
|
16618 | update({ el, binding }) {
|
16619 | this.el = el;
|
16620 | this.options = Object.assign({}, defaultOptions, binding.value);
|
16621 | const imgs = this.getImgs();
|
16622 | imgs.forEach((el2) => {
|
16623 | this.lazy.add(
|
16624 | el2,
|
16625 | Object.assign({}, this.binding, {
|
16626 | value: {
|
16627 | src: "dataset" in el2 ? el2.dataset.src : el2.getAttribute("data-src"),
|
16628 | error: ("dataset" in el2 ? el2.dataset.error : el2.getAttribute("data-error")) || this.options.error,
|
16629 | loading: ("dataset" in el2 ? el2.dataset.loading : el2.getAttribute("data-loading")) || this.options.loading
|
16630 | }
|
16631 | }),
|
16632 | this.vnode
|
16633 | );
|
16634 | });
|
16635 | }
|
16636 | getImgs() {
|
16637 | return Array.from(this.el.querySelectorAll(this.options.selector));
|
16638 | }
|
16639 | clear() {
|
16640 | const imgs = this.getImgs();
|
16641 | imgs.forEach((el) => this.lazy.remove(el));
|
16642 | this.vnode = null;
|
16643 | this.binding = null;
|
16644 | this.lazy = null;
|
16645 | }
|
16646 | }
|
16647 | class LazyContainerManager {
|
16648 | constructor({ lazy }) {
|
16649 | this.lazy = lazy;
|
16650 | this.queue = [];
|
16651 | }
|
16652 | bind(el, binding, vnode) {
|
16653 | const container = new LazyContainer({
|
16654 | el,
|
16655 | binding,
|
16656 | vnode,
|
16657 | lazy: this.lazy
|
16658 | });
|
16659 | this.queue.push(container);
|
16660 | }
|
16661 | update(el, binding, vnode) {
|
16662 | const container = this.queue.find((item) => item.el === el);
|
16663 | if (!container)
|
16664 | return;
|
16665 | container.update({ el, binding, vnode });
|
16666 | }
|
16667 | unbind(el) {
|
16668 | const container = this.queue.find((item) => item.el === el);
|
16669 | if (!container)
|
16670 | return;
|
16671 | container.clear();
|
16672 | remove(this.queue, container);
|
16673 | }
|
16674 | }
|
16675 | var stdin_default$1 = (lazyManager) => ({
|
16676 | props: {
|
16677 | src: [String, Object],
|
16678 | tag: {
|
16679 | type: String,
|
16680 | default: "img"
|
16681 | }
|
16682 | },
|
16683 | render() {
|
16684 | var _a, _b;
|
16685 | return h(
|
16686 | this.tag,
|
16687 | {
|
16688 | src: this.renderSrc
|
16689 | },
|
16690 | (_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a)
|
16691 | );
|
16692 | },
|
16693 | data() {
|
16694 | return {
|
16695 | el: null,
|
16696 | options: {
|
16697 | src: "",
|
16698 | error: "",
|
16699 | loading: "",
|
16700 | attempt: lazyManager.options.attempt
|
16701 | },
|
16702 | state: {
|
16703 | loaded: false,
|
16704 | error: false,
|
16705 | attempt: 0
|
16706 | },
|
16707 | renderSrc: ""
|
16708 | };
|
16709 | },
|
16710 | watch: {
|
16711 | src() {
|
16712 | this.init();
|
16713 | lazyManager.addLazyBox(this);
|
16714 | lazyManager.lazyLoadHandler();
|
16715 | }
|
16716 | },
|
16717 | created() {
|
16718 | this.init();
|
16719 | },
|
16720 | mounted() {
|
16721 | this.el = this.$el;
|
16722 | lazyManager.addLazyBox(this);
|
16723 | lazyManager.lazyLoadHandler();
|
16724 | },
|
16725 | beforeUnmount() {
|
16726 | lazyManager.removeComponent(this);
|
16727 | },
|
16728 | methods: {
|
16729 | init() {
|
16730 | const { src, loading, error } = lazyManager.valueFormatter(this.src);
|
16731 | this.state.loaded = false;
|
16732 | this.options.src = src;
|
16733 | this.options.error = error;
|
16734 | this.options.loading = loading;
|
16735 | this.renderSrc = this.options.loading;
|
16736 | },
|
16737 | checkInView() {
|
16738 | const rect = useRect(this.$el);
|
16739 | return rect.top < window.innerHeight * lazyManager.options.preLoad && rect.bottom > 0 && rect.left < window.innerWidth * lazyManager.options.preLoad && rect.right > 0;
|
16740 | },
|
16741 | load(onFinish = noop) {
|
16742 | if (this.state.attempt > this.options.attempt - 1 && this.state.error) {
|
16743 | if (process.env.NODE_ENV !== "production" && !lazyManager.options.silent) {
|
16744 | console.log(
|
16745 | `[@vant/lazyload] ${this.options.src} tried too more than ${this.options.attempt} times`
|
16746 | );
|
16747 | }
|
16748 | onFinish();
|
16749 | return;
|
16750 | }
|
16751 | const { src } = this.options;
|
16752 | loadImageAsync(
|
16753 | { src },
|
16754 | ({ src: src2 }) => {
|
16755 | this.renderSrc = src2;
|
16756 | this.state.loaded = true;
|
16757 | },
|
16758 | () => {
|
16759 | this.state.attempt++;
|
16760 | this.renderSrc = this.options.error;
|
16761 | this.state.error = true;
|
16762 | }
|
16763 | );
|
16764 | }
|
16765 | }
|
16766 | });
|
16767 | const Lazyload = {
|
16768 | |
16769 |
|
16770 |
|
16771 |
|
16772 |
|
16773 | install(app, options = {}) {
|
16774 | const LazyClass = stdin_default$3();
|
16775 | const lazy = new LazyClass(options);
|
16776 | const lazyContainer = new LazyContainerManager({ lazy });
|
16777 | app.config.globalProperties.$Lazyload = lazy;
|
16778 | if (options.lazyComponent) {
|
16779 | app.component("LazyComponent", stdin_default$2(lazy));
|
16780 | }
|
16781 | if (options.lazyImage) {
|
16782 | app.component("LazyImage", stdin_default$1(lazy));
|
16783 | }
|
16784 | app.directive("lazy", {
|
16785 | beforeMount: lazy.add.bind(lazy),
|
16786 | updated: lazy.update.bind(lazy),
|
16787 | unmounted: lazy.remove.bind(lazy)
|
16788 | });
|
16789 | app.directive("lazy-container", {
|
16790 | beforeMount: lazyContainer.bind.bind(lazyContainer),
|
16791 | updated: lazyContainer.update.bind(lazyContainer),
|
16792 | unmounted: lazyContainer.unbind.bind(lazyContainer)
|
16793 | });
|
16794 | }
|
16795 | };
|
16796 | const version = "4.8.7";
|
16797 | function install(app) {
|
16798 | const components = [
|
16799 | ActionBar,
|
16800 | ActionBarButton,
|
16801 | ActionBarIcon,
|
16802 | ActionSheet,
|
16803 | AddressEdit,
|
16804 | AddressList,
|
16805 | Area,
|
16806 | BackTop,
|
16807 | Badge,
|
16808 | Barrage,
|
16809 | Button,
|
16810 | Calendar,
|
16811 | Card,
|
16812 | Cascader,
|
16813 | Cell,
|
16814 | CellGroup,
|
16815 | Checkbox,
|
16816 | CheckboxGroup,
|
16817 | Circle,
|
16818 | Col,
|
16819 | Collapse,
|
16820 | CollapseItem,
|
16821 | ConfigProvider,
|
16822 | ContactCard,
|
16823 | ContactEdit,
|
16824 | ContactList,
|
16825 | CountDown,
|
16826 | Coupon,
|
16827 | CouponCell,
|
16828 | CouponList,
|
16829 | DatePicker,
|
16830 | Dialog,
|
16831 | Divider,
|
16832 | DropdownItem,
|
16833 | DropdownMenu,
|
16834 | Empty,
|
16835 | Field,
|
16836 | FloatingBubble,
|
16837 | FloatingPanel,
|
16838 | Form,
|
16839 | Grid,
|
16840 | GridItem,
|
16841 | Highlight,
|
16842 | Icon,
|
16843 | Image$1,
|
16844 | ImagePreview,
|
16845 | IndexAnchor,
|
16846 | IndexBar,
|
16847 | List,
|
16848 | Loading,
|
16849 | Locale,
|
16850 | NavBar,
|
16851 | NoticeBar,
|
16852 | Notify,
|
16853 | NumberKeyboard,
|
16854 | Overlay,
|
16855 | Pagination,
|
16856 | PasswordInput,
|
16857 | Picker,
|
16858 | PickerGroup,
|
16859 | Popover,
|
16860 | Popup,
|
16861 | Progress,
|
16862 | PullRefresh,
|
16863 | Radio,
|
16864 | RadioGroup,
|
16865 | Rate,
|
16866 | RollingText,
|
16867 | Row,
|
16868 | Search,
|
16869 | ShareSheet,
|
16870 | Sidebar,
|
16871 | SidebarItem,
|
16872 | Signature,
|
16873 | Skeleton,
|
16874 | SkeletonAvatar,
|
16875 | SkeletonImage,
|
16876 | SkeletonParagraph,
|
16877 | SkeletonTitle,
|
16878 | Slider,
|
16879 | Space,
|
16880 | Step,
|
16881 | Stepper,
|
16882 | Steps,
|
16883 | Sticky,
|
16884 | SubmitBar,
|
16885 | Swipe,
|
16886 | SwipeCell,
|
16887 | SwipeItem,
|
16888 | Switch,
|
16889 | Tab,
|
16890 | Tabbar,
|
16891 | TabbarItem,
|
16892 | Tabs,
|
16893 | Tag,
|
16894 | TextEllipsis,
|
16895 | TimePicker,
|
16896 | Toast,
|
16897 | TreeSelect,
|
16898 | Uploader,
|
16899 | Watermark
|
16900 | ];
|
16901 | components.forEach((item) => {
|
16902 | if (item.install) {
|
16903 | app.use(item);
|
16904 | } else if (item.name) {
|
16905 | app.component(item.name, item);
|
16906 | }
|
16907 | });
|
16908 | }
|
16909 | var stdin_default = {
|
16910 | install,
|
16911 | version
|
16912 | };
|
16913 | export {
|
16914 | ActionBar,
|
16915 | ActionBarButton,
|
16916 | ActionBarIcon,
|
16917 | ActionSheet,
|
16918 | AddressEdit,
|
16919 | AddressList,
|
16920 | Area,
|
16921 | BackTop,
|
16922 | Badge,
|
16923 | Barrage,
|
16924 | Button,
|
16925 | Calendar,
|
16926 | Card,
|
16927 | Cascader,
|
16928 | Cell,
|
16929 | CellGroup,
|
16930 | Checkbox,
|
16931 | CheckboxGroup,
|
16932 | Circle,
|
16933 | Col,
|
16934 | Collapse,
|
16935 | CollapseItem,
|
16936 | ConfigProvider,
|
16937 | ContactCard,
|
16938 | ContactEdit,
|
16939 | ContactList,
|
16940 | CountDown,
|
16941 | Coupon,
|
16942 | CouponCell,
|
16943 | CouponList,
|
16944 | DEFAULT_ROW_WIDTH,
|
16945 | DatePicker,
|
16946 | Dialog,
|
16947 | Divider,
|
16948 | DropdownItem,
|
16949 | DropdownMenu,
|
16950 | Empty,
|
16951 | Field,
|
16952 | FloatingBubble,
|
16953 | FloatingPanel,
|
16954 | Form,
|
16955 | Grid,
|
16956 | GridItem,
|
16957 | Highlight,
|
16958 | Icon,
|
16959 | Image$1 as Image,
|
16960 | ImagePreview,
|
16961 | IndexAnchor,
|
16962 | IndexBar,
|
16963 | Lazyload,
|
16964 | List,
|
16965 | Loading,
|
16966 | Locale,
|
16967 | NavBar,
|
16968 | NoticeBar,
|
16969 | Notify,
|
16970 | NumberKeyboard,
|
16971 | Overlay,
|
16972 | Pagination,
|
16973 | PasswordInput,
|
16974 | Picker,
|
16975 | PickerGroup,
|
16976 | Popover,
|
16977 | Popup,
|
16978 | Progress,
|
16979 | PullRefresh,
|
16980 | Radio,
|
16981 | RadioGroup,
|
16982 | Rate,
|
16983 | RollingText,
|
16984 | Row,
|
16985 | Search,
|
16986 | ShareSheet,
|
16987 | Sidebar,
|
16988 | SidebarItem,
|
16989 | Signature,
|
16990 | Skeleton,
|
16991 | SkeletonAvatar,
|
16992 | SkeletonImage,
|
16993 | SkeletonParagraph,
|
16994 | SkeletonTitle,
|
16995 | Slider,
|
16996 | Space,
|
16997 | Step,
|
16998 | Stepper,
|
16999 | Steps,
|
17000 | Sticky,
|
17001 | SubmitBar,
|
17002 | Swipe,
|
17003 | SwipeCell,
|
17004 | SwipeItem,
|
17005 | Switch,
|
17006 | Tab,
|
17007 | Tabbar,
|
17008 | TabbarItem,
|
17009 | Tabs,
|
17010 | Tag,
|
17011 | TextEllipsis,
|
17012 | TimePicker,
|
17013 | Toast,
|
17014 | TreeSelect,
|
17015 | Uploader,
|
17016 | Watermark,
|
17017 | actionBarButtonProps,
|
17018 | actionBarIconProps,
|
17019 | actionBarProps,
|
17020 | actionSheetProps,
|
17021 | addressEditProps,
|
17022 | addressListProps,
|
17023 | allowMultipleToast,
|
17024 | areaProps,
|
17025 | backTopProps,
|
17026 | badgeProps,
|
17027 | barrageProps,
|
17028 | buttonProps,
|
17029 | calendarProps,
|
17030 | cardProps,
|
17031 | cascaderProps,
|
17032 | cellGroupProps,
|
17033 | cellProps,
|
17034 | checkboxGroupProps,
|
17035 | checkboxProps,
|
17036 | circleProps,
|
17037 | closeDialog,
|
17038 | closeNotify,
|
17039 | closeToast,
|
17040 | colProps,
|
17041 | collapseItemProps,
|
17042 | collapseProps,
|
17043 | configProviderProps,
|
17044 | contactCardProps,
|
17045 | contactEditProps,
|
17046 | contactListProps,
|
17047 | countDownProps,
|
17048 | couponCellProps,
|
17049 | couponListProps,
|
17050 | datePickerProps,
|
17051 | stdin_default as default,
|
17052 | dialogProps,
|
17053 | dividerProps,
|
17054 | dropdownItemProps,
|
17055 | dropdownMenuProps,
|
17056 | emptyProps,
|
17057 | fieldProps,
|
17058 | floatingBubbleProps,
|
17059 | floatingPanelProps,
|
17060 | formProps,
|
17061 | gridItemProps,
|
17062 | gridProps,
|
17063 | highlightProps,
|
17064 | iconProps,
|
17065 | imagePreviewProps,
|
17066 | imageProps,
|
17067 | indexAnchorProps,
|
17068 | indexBarProps,
|
17069 | install,
|
17070 | listProps,
|
17071 | loadingProps,
|
17072 | navBarProps,
|
17073 | noticeBarProps,
|
17074 | notifyProps,
|
17075 | numberKeyboardProps,
|
17076 | overlayProps,
|
17077 | paginationProps,
|
17078 | passwordInputProps,
|
17079 | pickerGroupProps,
|
17080 | pickerProps,
|
17081 | popoverProps,
|
17082 | popupProps$2 as popupProps,
|
17083 | progressProps,
|
17084 | pullRefreshProps,
|
17085 | radioGroupProps,
|
17086 | radioProps,
|
17087 | rateProps,
|
17088 | resetDialogDefaultOptions,
|
17089 | resetNotifyDefaultOptions,
|
17090 | resetToastDefaultOptions,
|
17091 | rollingTextProps,
|
17092 | rowProps,
|
17093 | searchProps,
|
17094 | setDialogDefaultOptions,
|
17095 | setNotifyDefaultOptions,
|
17096 | setToastDefaultOptions,
|
17097 | shareSheetProps,
|
17098 | showConfirmDialog,
|
17099 | showDialog,
|
17100 | showFailToast,
|
17101 | showImagePreview,
|
17102 | showLoadingToast,
|
17103 | showNotify,
|
17104 | showSuccessToast,
|
17105 | showToast,
|
17106 | sidebarItemProps,
|
17107 | sidebarProps,
|
17108 | skeletonAvatarProps,
|
17109 | skeletonImageProps,
|
17110 | skeletonParagraphProps,
|
17111 | skeletonProps,
|
17112 | skeletonTitleProps,
|
17113 | sliderProps,
|
17114 | spaceProps,
|
17115 | stepperProps,
|
17116 | stepsProps,
|
17117 | stickyProps,
|
17118 | submitBarProps,
|
17119 | swipeCellProps,
|
17120 | swipeProps,
|
17121 | switchProps,
|
17122 | tabProps,
|
17123 | tabbarItemProps,
|
17124 | tabbarProps,
|
17125 | tabsProps,
|
17126 | tagProps,
|
17127 | textEllipsisProps,
|
17128 | timePickerProps,
|
17129 | toastProps,
|
17130 | treeSelectProps,
|
17131 | uploaderProps,
|
17132 | useCurrentLang,
|
17133 | version,
|
17134 | watermarkProps
|
17135 | };
|