components.js 116.3 KB
Newer Older
fxy060608's avatar
fxy060608 已提交
1
import { createElementVNode, defineComponent, createVNode, mergeProps, getCurrentInstance, provide, watch, onUnmounted, shallowRef, reactive, watchEffect, ref, inject, onBeforeUnmount, computed, Text as Text$1, isVNode, Fragment, onMounted, Comment, resolveComponent, parseClassList } from "vue";
2
import { extend, hasOwn, isFunction, isPlainObject, isArray, isString } from "@vue/shared";
fxy060608's avatar
fxy060608 已提交
3
import { cacheStringFunction, PRIMARY_COLOR } from "@dcloudio/uni-shared";
fxy060608's avatar
fxy060608 已提交
4 5 6 7 8 9 10
const OPEN_TYPES = [
  "navigate",
  "redirect",
  "switchTab",
  "reLaunch",
  "navigateBack"
];
fxy060608's avatar
fxy060608 已提交
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
const ANIMATION_IN = [
  "slide-in-right",
  "slide-in-left",
  "slide-in-top",
  "slide-in-bottom",
  "fade-in",
  "zoom-out",
  "zoom-fade-out",
  "pop-in",
  "none"
];
const ANIMATION_OUT = [
  "slide-out-right",
  "slide-out-left",
  "slide-out-top",
  "slide-out-bottom",
  "fade-out",
  "zoom-in",
  "zoom-fade-in",
  "pop-out",
  "none"
];
fxy060608's avatar
fxy060608 已提交
33 34 35 36 37 38 39 40 41 42 43 44 45 46
const navigatorProps = {
  hoverClass: {
    type: String,
    default: "navigator-hover"
  },
  url: {
    type: String,
    default: ""
  },
  openType: {
    type: String,
    default: "navigate",
    validator(value) {
      return Boolean(~OPEN_TYPES.indexOf(value));
fxy060608's avatar
fxy060608 已提交
47
    }
fxy060608's avatar
fxy060608 已提交
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
  },
  delta: {
    type: Number,
    default: 1
  },
  hoverStartTime: {
    type: [Number, String],
    default: 50
  },
  hoverStayTime: {
    type: [Number, String],
    default: 600
  },
  exists: {
    type: String,
    default: ""
  },
  hoverStopPropagation: {
    type: Boolean,
    default: false
fxy060608's avatar
fxy060608 已提交
68 69 70
  },
  animationType: {
    type: String,
71
    default: "",
fxy060608's avatar
fxy060608 已提交
72 73 74 75 76 77 78
    validator(value) {
      return !value || ANIMATION_IN.concat(ANIMATION_OUT).includes(value);
    }
  },
  animationDuration: {
    type: [String, Number],
    default: 300
fxy060608's avatar
fxy060608 已提交
79 80
  }
};
D
DCloud_LXH 已提交
81
function createNavigatorOnClick(props2) {
fxy060608's avatar
fxy060608 已提交
82
  return () => {
D
DCloud_LXH 已提交
83
    if (props2.openType !== "navigateBack" && !props2.url) {
fxy060608's avatar
fxy060608 已提交
84 85
      console.error("<navigator/> should have url attribute when using navigateTo, redirectTo, reLaunch or switchTab");
      return;
fxy060608's avatar
fxy060608 已提交
86
    }
fxy060608's avatar
fxy060608 已提交
87
    const animationDuration = parseInt(props2.animationDuration);
D
DCloud_LXH 已提交
88
    switch (props2.openType) {
fxy060608's avatar
fxy060608 已提交
89 90
      case "navigate":
        uni.navigateTo({
fxy060608's avatar
fxy060608 已提交
91 92 93
          url: props2.url,
          animationType: props2.animationType || "pop-in",
          animationDuration
fxy060608's avatar
fxy060608 已提交
94 95 96 97
        });
        break;
      case "redirect":
        uni.redirectTo({
D
DCloud_LXH 已提交
98 99
          url: props2.url,
          exists: props2.exists
fxy060608's avatar
fxy060608 已提交
100 101 102 103
        });
        break;
      case "switchTab":
        uni.switchTab({
D
DCloud_LXH 已提交
104
          url: props2.url
fxy060608's avatar
fxy060608 已提交
105 106 107 108
        });
        break;
      case "reLaunch":
        uni.reLaunch({
D
DCloud_LXH 已提交
109
          url: props2.url
fxy060608's avatar
fxy060608 已提交
110 111 112 113
        });
        break;
      case "navigateBack":
        uni.navigateBack({
fxy060608's avatar
fxy060608 已提交
114 115 116
          delta: props2.delta,
          animationType: props2.animationType || "pop-out",
          animationDuration
fxy060608's avatar
fxy060608 已提交
117 118 119 120 121
        });
        break;
    }
  };
}
D
DCloud_LXH 已提交
122 123 124
function useHoverClass(props2) {
  if (props2.hoverClass && props2.hoverClass !== "none") {
    const hoverAttrs = { hoverClass: props2.hoverClass };
fxy060608's avatar
fxy060608 已提交
125
    if (hasOwn(props2, "hoverStartTime")) {
D
DCloud_LXH 已提交
126
      hoverAttrs.hoverStartTime = props2.hoverStartTime;
fxy060608's avatar
fxy060608 已提交
127
    }
fxy060608's avatar
fxy060608 已提交
128
    if (hasOwn(props2, "hoverStayTime")) {
D
DCloud_LXH 已提交
129
      hoverAttrs.hoverStayTime = props2.hoverStayTime;
fxy060608's avatar
fxy060608 已提交
130
    }
fxy060608's avatar
fxy060608 已提交
131
    if (hasOwn(props2, "hoverStopPropagation")) {
D
DCloud_LXH 已提交
132
      hoverAttrs.hoverStopPropagation = props2.hoverStopPropagation;
fxy060608's avatar
fxy060608 已提交
133 134 135 136
    }
    return hoverAttrs;
  }
  return {};
fxy060608's avatar
fxy060608 已提交
137
}
fxy060608's avatar
fxy060608 已提交
138 139 140
function createNVueTextVNode(text, attrs) {
  return createElementVNode("u-text", extend({ appendAsTree: true }, attrs), text);
}
fxy060608's avatar
fxy060608 已提交
141 142
const navigatorStyles = [{
  "navigator-hover": {
fxy060608's avatar
fxy060608 已提交
143 144 145 146
    "": {
      backgroundColor: "rgba(0,0,0,0.1)",
      opacity: 0.7
    }
fxy060608's avatar
fxy060608 已提交
147 148 149 150 151 152
  }
}];
var Navigator = defineComponent({
  name: "Navigator",
  props: navigatorProps,
  styles: navigatorStyles,
D
DCloud_LXH 已提交
153
  setup(props2, {
fxy060608's avatar
fxy060608 已提交
154 155
    slots
  }) {
D
DCloud_LXH 已提交
156
    const onClick = createNavigatorOnClick(props2);
fxy060608's avatar
fxy060608 已提交
157
    return () => {
D
DCloud_LXH 已提交
158
      return createVNode("view", mergeProps(useHoverClass(props2), {
fxy060608's avatar
fxy060608 已提交
159 160 161 162 163
        "onClick": onClick
      }), [slots.default && slots.default()]);
    };
  }
});
fxy060608's avatar
fxy060608 已提交
164 165 166 167 168 169
function PolySymbol(name) {
  return Symbol(process.env.NODE_ENV !== "production" ? "[uni-app]: " + name : name);
}
function useCurrentPageId() {
  return getCurrentInstance().root.proxy.$page.id;
}
D
DCloud_LXH 已提交
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
let plus_;
let weex_;
let BroadcastChannel_;
function getRuntime() {
  return typeof window === "object" && typeof navigator === "object" && typeof document === "object" ? "webview" : "v8";
}
function getPageId() {
  return plus_.webview.currentWebview().id;
}
let channel;
let globalEvent;
const callbacks = {};
function onPlusMessage(res) {
  const message = res.data && res.data.__message;
  if (!message || !message.__page) {
    return;
  }
  const pageId = message.__page;
  const callback = callbacks[pageId];
  callback && callback(message);
  if (!message.keep) {
    delete callbacks[pageId];
  }
}
function addEventListener(pageId, callback) {
  if (getRuntime() === "v8") {
    if (BroadcastChannel_) {
      channel && channel.close();
      channel = new BroadcastChannel_(getPageId());
      channel.onmessage = onPlusMessage;
    } else if (!globalEvent) {
      globalEvent = weex_.requireModule("globalEvent");
      globalEvent.addEventListener("plusMessage", onPlusMessage);
    }
  } else {
    window.__plusMessage = onPlusMessage;
  }
  callbacks[pageId] = callback;
}
class Page {
  constructor(webview) {
    this.webview = webview;
  }
  sendMessage(data) {
    const message = JSON.parse(JSON.stringify({
      __message: {
        data
      }
    }));
    const id = this.webview.id;
    if (BroadcastChannel_) {
      const channel2 = new BroadcastChannel_(id);
      channel2.postMessage(message);
    } else {
      plus_.webview.postMessageToUniNView && plus_.webview.postMessageToUniNView(message, id);
    }
  }
  close() {
    this.webview.close();
  }
}
function showPage({
  context = {},
  url,
  data = {},
  style = {},
  onMessage,
  onClose
}) {
  plus_ = context.plus || plus;
  weex_ = context.weex || (typeof weex === "object" ? weex : null);
  BroadcastChannel_ = context.BroadcastChannel || (typeof BroadcastChannel === "object" ? BroadcastChannel : null);
  const titleNView = {
    autoBackButton: true,
    titleSize: "17px"
  };
  const pageId = `page${Date.now()}`;
  style = extend({}, style);
  if (style.titleNView !== false && style.titleNView !== "none") {
    style.titleNView = extend(titleNView, style.titleNView);
  }
  const defaultStyle = {
    top: 0,
    bottom: 0,
    usingComponents: {},
    popGesture: "close",
    scrollIndicator: "none",
    animationType: "pop-in",
    animationDuration: 200,
    uniNView: {
fxy060608's avatar
fxy060608 已提交
260
      path: `/${url}.js`,
D
DCloud_LXH 已提交
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
      defaultFontSize: 16,
      viewport: plus_.screen.resolutionWidth
    }
  };
  style = extend(defaultStyle, style);
  const page = plus_.webview.create("", pageId, style, {
    extras: {
      from: getPageId(),
      runtime: getRuntime(),
      data,
      useGlobalEvent: !BroadcastChannel_
    }
  });
  page.addEventListener("close", onClose);
  addEventListener(pageId, (message) => {
276
    if (isFunction(onMessage)) {
D
DCloud_LXH 已提交
277 278 279 280 281 282 283 284 285
      onMessage(message.data);
    }
    if (!message.keep) {
      page.close("auto");
    }
  });
  page.show(style.animationType, style.animationDuration);
  return new Page(page);
}
fxy060608's avatar
fxy060608 已提交
286
const labelProps = {
fxy060608's avatar
fxy060608 已提交
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
  for: {
    type: String,
    default: ""
  }
};
const uniLabelKey = PolySymbol(process.env.NODE_ENV !== "production" ? "uniLabel" : "ul");
function useProvideLabel() {
  const handlers = [];
  provide(uniLabelKey, {
    addHandler(handler) {
      handlers.push(handler);
    },
    removeHandler(handler) {
      handlers.splice(handlers.indexOf(handler), 1);
    }
  });
  return handlers;
}
var Label = /* @__PURE__ */ defineComponent({
  name: "Label",
fxy060608's avatar
fxy060608 已提交
307
  props: labelProps,
fxy060608's avatar
fxy060608 已提交
308
  styles: [],
D
DCloud_LXH 已提交
309
  setup(props2, {
fxy060608's avatar
fxy060608 已提交
310 311 312 313 314
    slots
  }) {
    const pageId = useCurrentPageId();
    const handlers = useProvideLabel();
    const _onClick = ($event) => {
D
DCloud_LXH 已提交
315 316
      if (props2.for) {
        UniViewJSBridge.emit(`uni-label-click-${pageId}-${props2.for}`, $event, true);
fxy060608's avatar
fxy060608 已提交
317 318 319 320
      } else {
        handlers.length && handlers[0]($event, true);
      }
    };
fxy060608's avatar
fxy060608 已提交
321
    return () => createVNode("view", {
fxy060608's avatar
fxy060608 已提交
322 323 324 325
      "onClick": _onClick
    }, [slots.default && slots.default()]);
  }
});
D
DCloud_LXH 已提交
326 327 328
function useListeners(props2, listeners) {
  _addListeners(props2.id, listeners);
  watch(() => props2.id, (newId, oldId) => {
fxy060608's avatar
fxy060608 已提交
329 330 331 332
    _removeListeners(oldId, listeners, true);
    _addListeners(newId, listeners, true);
  });
  onUnmounted(() => {
D
DCloud_LXH 已提交
333
    _removeListeners(props2.id, listeners);
fxy060608's avatar
fxy060608 已提交
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379
  });
}
function _addListeners(id, listeners, watch2) {
  const pageId = useCurrentPageId();
  if (watch2 && !id) {
    return;
  }
  if (!isPlainObject(listeners)) {
    return;
  }
  Object.keys(listeners).forEach((name) => {
    if (watch2) {
      if (name.indexOf("@") !== 0 && name.indexOf("uni-") !== 0) {
        UniViewJSBridge.on(`uni-${name}-${pageId}-${id}`, listeners[name]);
      }
    } else {
      if (name.indexOf("uni-") === 0) {
        UniViewJSBridge.on(name, listeners[name]);
      } else if (id) {
        UniViewJSBridge.on(`uni-${name}-${pageId}-${id}`, listeners[name]);
      }
    }
  });
}
function _removeListeners(id, listeners, watch2) {
  const pageId = useCurrentPageId();
  if (watch2 && !id) {
    return;
  }
  if (!isPlainObject(listeners)) {
    return;
  }
  Object.keys(listeners).forEach((name) => {
    if (watch2) {
      if (name.indexOf("@") !== 0 && name.indexOf("uni-") !== 0) {
        UniViewJSBridge.off(`uni-${name}-${pageId}-${id}`, listeners[name]);
      }
    } else {
      if (name.indexOf("uni-") === 0) {
        UniViewJSBridge.off(name, listeners[name]);
      } else if (id) {
        UniViewJSBridge.off(`uni-${name}-${pageId}-${id}`, listeners[name]);
      }
    }
  });
}
fxy060608's avatar
fxy060608 已提交
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416
function entries(obj) {
  return Object.keys(obj).map((key) => [key, obj[key]]);
}
const DEFAULT_EXCLUDE_KEYS = ["class", "style"];
const LISTENER_PREFIX = /^on[A-Z]+/;
const useAttrs = (params = {}) => {
  const { excludeListeners = false, excludeKeys = [] } = params;
  const instance = getCurrentInstance();
  const attrs = shallowRef({});
  const listeners = shallowRef({});
  const excludeAttrs = shallowRef({});
  const allExcludeKeys = excludeKeys.concat(DEFAULT_EXCLUDE_KEYS);
  instance.attrs = reactive(instance.attrs);
  watchEffect(() => {
    const res = entries(instance.attrs).reduce((acc, [key, val]) => {
      if (allExcludeKeys.includes(key)) {
        acc.exclude[key] = val;
      } else if (LISTENER_PREFIX.test(key)) {
        if (!excludeListeners) {
          acc.attrs[key] = val;
        }
        acc.listeners[key] = val;
      } else {
        acc.attrs[key] = val;
      }
      return acc;
    }, {
      exclude: {},
      attrs: {},
      listeners: {}
    });
    attrs.value = res.attrs;
    listeners.value = res.listeners;
    excludeAttrs.value = res.exclude;
  });
  return { $attrs: attrs, $listeners: listeners, $excludeAttrs: excludeAttrs };
};
fxy060608's avatar
fxy060608 已提交
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458
const buttonProps = {
  id: {
    type: String,
    default: ""
  },
  hoverClass: {
    type: String,
    default: "button-hover"
  },
  hoverStartTime: {
    type: [Number, String],
    default: 20
  },
  hoverStayTime: {
    type: [Number, String],
    default: 70
  },
  hoverStopPropagation: {
    type: Boolean,
    default: false
  },
  disabled: {
    type: [Boolean, String],
    default: false
  },
  formType: {
    type: String,
    default: ""
  },
  openType: {
    type: String,
    default: ""
  },
  loading: {
    type: [Boolean, String],
    default: false
  },
  plain: {
    type: [Boolean, String],
    default: false
  }
};
D
DCloud_LXH 已提交
459
const uniFormKey = PolySymbol(process.env.NODE_ENV !== "production" ? "uniForm" : "uf");
fxy060608's avatar
fxy060608 已提交
460 461
const buttonStyle = [{
  ub: {
fxy060608's avatar
fxy060608 已提交
462 463 464 465 466 467 468 469 470 471 472 473 474 475 476
    "": {
      flexDirection: "row",
      alignItems: "center",
      justifyContent: "center",
      position: "relative",
      paddingLeft: "5",
      paddingRight: "5",
      overflow: "hidden",
      color: "#000000",
      backgroundColor: "#f8f8f8",
      borderRadius: "5",
      borderStyle: "solid",
      borderWidth: "1",
      borderColor: "#dbdbdb"
    }
fxy060608's avatar
fxy060608 已提交
477 478
  },
  "ub-t": {
fxy060608's avatar
fxy060608 已提交
479 480 481 482 483 484
    "": {
      color: "#000000",
      fontSize: "18",
      textDecoration: "none",
      lineHeight: "46"
    }
fxy060608's avatar
fxy060608 已提交
485 486
  },
  "ub-d": {
fxy060608's avatar
fxy060608 已提交
487 488 489
    "": {
      backgroundColor: "#f8f8f8"
    }
fxy060608's avatar
fxy060608 已提交
490 491
  },
  "ub-p": {
fxy060608's avatar
fxy060608 已提交
492 493 494 495
    "": {
      backgroundColor: "#007aff",
      borderColor: "#0062cc"
    }
fxy060608's avatar
fxy060608 已提交
496 497
  },
  "ub-w": {
fxy060608's avatar
fxy060608 已提交
498 499 500 501
    "": {
      backgroundColor: "#e64340",
      borderColor: "#b83633"
    }
fxy060608's avatar
fxy060608 已提交
502 503
  },
  "ub-d-t": {
fxy060608's avatar
fxy060608 已提交
504 505 506
    "": {
      color: "#000000"
    }
fxy060608's avatar
fxy060608 已提交
507 508
  },
  "ub-p-t": {
fxy060608's avatar
fxy060608 已提交
509 510 511
    "": {
      color: "#ffffff"
    }
fxy060608's avatar
fxy060608 已提交
512 513
  },
  "ub-w-t": {
fxy060608's avatar
fxy060608 已提交
514 515 516
    "": {
      color: "#ffffff"
    }
fxy060608's avatar
fxy060608 已提交
517 518
  },
  "ub-d-d": {
fxy060608's avatar
fxy060608 已提交
519 520 521
    "": {
      backgroundColor: "#f7f7f7"
    }
fxy060608's avatar
fxy060608 已提交
522 523
  },
  "ub-p-d": {
fxy060608's avatar
fxy060608 已提交
524 525 526 527
    "": {
      backgroundColor: "#63acfc",
      borderColor: "#4f8aca"
    }
fxy060608's avatar
fxy060608 已提交
528 529
  },
  "ub-w-d": {
fxy060608's avatar
fxy060608 已提交
530 531 532 533
    "": {
      backgroundColor: "#ec8b89",
      borderColor: "#bd6f6e"
    }
fxy060608's avatar
fxy060608 已提交
534 535
  },
  "ub-d-t-d": {
fxy060608's avatar
fxy060608 已提交
536 537 538
    "": {
      color: "#cccccc"
    }
fxy060608's avatar
fxy060608 已提交
539 540
  },
  "ub-p-t-d": {
fxy060608's avatar
fxy060608 已提交
541 542 543
    "": {
      color: "rgba(255,255,255,0.6)"
    }
fxy060608's avatar
fxy060608 已提交
544 545
  },
  "ub-w-t-d": {
fxy060608's avatar
fxy060608 已提交
546 547 548
    "": {
      color: "rgba(255,255,255,0.6)"
    }
fxy060608's avatar
fxy060608 已提交
549 550
  },
  "ub-d-plain": {
fxy060608's avatar
fxy060608 已提交
551 552 553 554
    "": {
      borderColor: "#353535",
      backgroundColor: "rgba(0,0,0,0)"
    }
fxy060608's avatar
fxy060608 已提交
555 556
  },
  "ub-p-plain": {
fxy060608's avatar
fxy060608 已提交
557 558 559 560
    "": {
      borderColor: "#007aff",
      backgroundColor: "rgba(0,0,0,0)"
    }
fxy060608's avatar
fxy060608 已提交
561 562
  },
  "ub-w-plain": {
fxy060608's avatar
fxy060608 已提交
563 564 565 566
    "": {
      borderColor: "#e64340",
      backgroundColor: "rgba(0,0,0,0)"
    }
fxy060608's avatar
fxy060608 已提交
567 568
  },
  "ub-d-t-plain": {
fxy060608's avatar
fxy060608 已提交
569 570 571
    "": {
      color: "#353535"
    }
fxy060608's avatar
fxy060608 已提交
572 573
  },
  "ub-p-t-plain": {
fxy060608's avatar
fxy060608 已提交
574 575 576
    "": {
      color: "#007aff"
    }
fxy060608's avatar
fxy060608 已提交
577 578
  },
  "ub-w-t-plain": {
fxy060608's avatar
fxy060608 已提交
579 580 581
    "": {
      color: "#e64340"
    }
fxy060608's avatar
fxy060608 已提交
582 583
  },
  "ub-d-d-plain": {
fxy060608's avatar
fxy060608 已提交
584 585 586 587
    "": {
      borderColor: "#c6c6c6",
      backgroundColor: "rgba(0,0,0,0)"
    }
fxy060608's avatar
fxy060608 已提交
588 589
  },
  "ub-p-d-plain": {
fxy060608's avatar
fxy060608 已提交
590 591 592 593
    "": {
      borderColor: "#c6c6c6",
      backgroundColor: "rgba(0,0,0,0)"
    }
fxy060608's avatar
fxy060608 已提交
594 595
  },
  "ub-w-d-plain": {
fxy060608's avatar
fxy060608 已提交
596 597 598 599
    "": {
      borderColor: "#c6c6c6",
      backgroundColor: "rgba(0,0,0,0)"
    }
fxy060608's avatar
fxy060608 已提交
600 601
  },
  "ub-d-t-d-plain": {
fxy060608's avatar
fxy060608 已提交
602 603 604
    "": {
      color: "rgba(0,0,0,0.2)"
    }
fxy060608's avatar
fxy060608 已提交
605 606
  },
  "ub-p-t-d-plain": {
fxy060608's avatar
fxy060608 已提交
607 608 609
    "": {
      color: "rgba(0,0,0,0.2)"
    }
fxy060608's avatar
fxy060608 已提交
610 611
  },
  "ub-w-t-d-plain": {
fxy060608's avatar
fxy060608 已提交
612 613 614
    "": {
      color: "rgba(0,0,0,0.2)"
    }
fxy060608's avatar
fxy060608 已提交
615 616
  },
  "ub-mini": {
fxy060608's avatar
fxy060608 已提交
617 618 619 620 621 622 623 624
    "": {
      lineHeight: "30",
      fontSize: "13",
      paddingTop: 0,
      paddingRight: "17.5",
      paddingBottom: 0,
      paddingLeft: "17.5"
    }
fxy060608's avatar
fxy060608 已提交
625 626
  },
  "ub-loading": {
fxy060608's avatar
fxy060608 已提交
627 628 629 630 631
    "": {
      width: "18",
      height: "18",
      marginRight: "10"
    }
fxy060608's avatar
fxy060608 已提交
632 633
  },
  "ub-d-loading": {
fxy060608's avatar
fxy060608 已提交
634 635 636 637
    "": {
      color: "rgba(255,255,255,0.6)",
      backgroundColor: "rgba(0,0,0,0)"
    }
fxy060608's avatar
fxy060608 已提交
638 639
  },
  "ub-p-loading": {
fxy060608's avatar
fxy060608 已提交
640 641 642 643
    "": {
      color: "rgba(255,255,255,0.6)",
      backgroundColor: "rgba(0,0,0,0)"
    }
fxy060608's avatar
fxy060608 已提交
644 645
  },
  "ub-w-loading": {
fxy060608's avatar
fxy060608 已提交
646 647 648 649
    "": {
      color: "rgba(255,255,255,0.6)",
      backgroundColor: "rgba(0,0,0,0)"
    }
fxy060608's avatar
fxy060608 已提交
650 651
  },
  "ub-d-loading-plain": {
fxy060608's avatar
fxy060608 已提交
652 653 654
    "": {
      color: "#353535"
    }
fxy060608's avatar
fxy060608 已提交
655 656
  },
  "ub-p-loading-plain": {
fxy060608's avatar
fxy060608 已提交
657 658 659 660
    "": {
      color: "#007aff",
      backgroundColor: "#0062cc"
    }
fxy060608's avatar
fxy060608 已提交
661 662
  },
  "ub-w-loading-plain": {
fxy060608's avatar
fxy060608 已提交
663 664 665 666
    "": {
      color: "#e64340",
      backgroundColor: "rgba(0,0,0,0)"
    }
fxy060608's avatar
fxy060608 已提交
667 668
  },
  "ub-d-hover": {
fxy060608's avatar
fxy060608 已提交
669 670 671 672
    "": {
      opacity: 0.8,
      backgroundColor: "#dedede"
    }
fxy060608's avatar
fxy060608 已提交
673 674
  },
  "ub-p-hover": {
fxy060608's avatar
fxy060608 已提交
675 676 677 678
    "": {
      opacity: 0.8,
      backgroundColor: "#0062cc"
    }
fxy060608's avatar
fxy060608 已提交
679 680
  },
  "ub-w-hover": {
fxy060608's avatar
fxy060608 已提交
681 682 683 684
    "": {
      opacity: 0.8,
      backgroundColor: "#ce3c39"
    }
fxy060608's avatar
fxy060608 已提交
685 686
  },
  "ub-d-t-hover": {
fxy060608's avatar
fxy060608 已提交
687 688 689
    "": {
      color: "rgba(0,0,0,0.6)"
    }
fxy060608's avatar
fxy060608 已提交
690 691
  },
  "ub-p-t-hover": {
fxy060608's avatar
fxy060608 已提交
692 693 694
    "": {
      color: "rgba(255,255,255,0.6)"
    }
fxy060608's avatar
fxy060608 已提交
695 696
  },
  "ub-w-t-hover": {
fxy060608's avatar
fxy060608 已提交
697 698 699
    "": {
      color: "rgba(255,255,255,0.6)"
    }
fxy060608's avatar
fxy060608 已提交
700 701
  },
  "ub-d-hover-plain": {
fxy060608's avatar
fxy060608 已提交
702 703 704 705 706
    "": {
      color: "rgba(53,53,53,0.6)",
      borderColor: "rgba(53,53,53,0.6)",
      backgroundColor: "rgba(0,0,0,0)"
    }
fxy060608's avatar
fxy060608 已提交
707 708
  },
  "ub-p-hover-plain": {
fxy060608's avatar
fxy060608 已提交
709 710 711 712 713
    "": {
      color: "rgba(26,173,25,0.6)",
      borderColor: "rgba(0,122,255,0.6)",
      backgroundColor: "rgba(0,0,0,0)"
    }
fxy060608's avatar
fxy060608 已提交
714 715
  },
  "ub-w-hover-plain": {
fxy060608's avatar
fxy060608 已提交
716 717 718 719 720
    "": {
      color: "rgba(230,67,64,0.6)",
      borderColor: "rgba(230,67,64,0.6)",
      backgroundColor: "rgba(0,0,0,0)"
    }
fxy060608's avatar
fxy060608 已提交
721 722 723 724 725 726 727 728
  }
}];
const TYPES = {
  default: "d",
  primary: "p",
  warn: "w"
};
var Button = defineComponent({
fxy060608's avatar
fxy060608 已提交
729
  inheritAttrs: false,
fxy060608's avatar
fxy060608 已提交
730 731 732 733 734 735 736 737 738 739 740 741
  name: "Button",
  props: extend(buttonProps, {
    type: {
      type: String,
      default: "default"
    },
    size: {
      type: String,
      default: "default"
    }
  }),
  styles: buttonStyle,
D
DCloud_LXH 已提交
742
  setup(props2, {
fxy060608's avatar
fxy060608 已提交
743 744 745
    slots,
    attrs
  }) {
fxy060608's avatar
fxy060608 已提交
746 747 748 749 750 751 752
    const {
      $attrs,
      $excludeAttrs,
      $listeners
    } = useAttrs({
      excludeListeners: true
    });
D
DCloud_LXH 已提交
753
    const type = props2.type;
fxy060608's avatar
fxy060608 已提交
754
    const rootRef = ref(null);
D
DCloud_LXH 已提交
755
    const uniForm = inject(uniFormKey, false);
fxy060608's avatar
fxy060608 已提交
756
    const onClick = (e2, isLabelClick) => {
fxy060608's avatar
fxy060608 已提交
757 758
      const _onClick = $listeners.value.onClick || (() => {
      });
D
DCloud_LXH 已提交
759
      if (props2.disabled) {
fxy060608's avatar
fxy060608 已提交
760 761
        return;
      }
fxy060608's avatar
fxy060608 已提交
762
      _onClick(e2);
D
DCloud_LXH 已提交
763 764 765 766 767 768 769 770 771 772 773
      const formType = props2.formType;
      if (formType) {
        if (!uniForm) {
          return;
        }
        if (formType === "submit") {
          uniForm.submit(e2);
        } else if (formType === "reset") {
          uniForm.reset(e2);
        }
      }
fxy060608's avatar
fxy060608 已提交
774 775 776
    };
    const _getClass = (t2) => {
      let cl = "ub-" + TYPES[type] + t2;
D
DCloud_LXH 已提交
777 778 779
      props2.disabled && (cl += "-d");
      props2.plain && (cl += "-plain");
      props2.size === "mini" && t2 === "-t" && (cl += " ub-mini");
fxy060608's avatar
fxy060608 已提交
780 781 782
      return cl;
    };
    const _getHoverClass = (t2) => {
D
DCloud_LXH 已提交
783
      if (props2.disabled) {
fxy060608's avatar
fxy060608 已提交
784 785 786
        return "";
      }
      let cl = "ub-" + TYPES[type] + t2 + "-hover";
D
DCloud_LXH 已提交
787
      props2.plain && (cl += "-plain");
fxy060608's avatar
fxy060608 已提交
788 789 790 791 792 793 794 795 796
      return cl;
    };
    const uniLabel = inject(uniLabelKey, false);
    if (uniLabel) {
      uniLabel.addHandler(onClick);
      onBeforeUnmount(() => {
        uniLabel.removeHandler(onClick);
      });
    }
D
DCloud_LXH 已提交
797
    useListeners(props2, {
fxy060608's avatar
fxy060608 已提交
798 799
      "label-click": onClick
    });
fxy060608's avatar
fxy060608 已提交
800 801 802 803 804 805 806 807 808
    const _listeners = computed(() => {
      const obj = {};
      for (const eventName in $listeners.value) {
        const event = $listeners.value[eventName];
        if (eventName !== "onClick")
          obj[eventName] = event;
      }
      return obj;
    });
fxy060608's avatar
fxy060608 已提交
809 810 811
    const wrapSlots = () => {
      if (!slots.default)
        return [];
fxy060608's avatar
fxy060608 已提交
812
      const vnodes = slots.default();
D
DCloud_LXH 已提交
813
      if (vnodes.length === 1 && vnodes[0].type === Text$1) {
fxy060608's avatar
fxy060608 已提交
814 815 816 817 818
        return [createNVueTextVNode(vnodes[0].children, {
          class: "ub-t " + _getClass("-t")
        })];
      }
      return vnodes;
fxy060608's avatar
fxy060608 已提交
819 820
    };
    return () => {
D
DCloud_LXH 已提交
821
      const _attrs = extend({}, useHoverClass(props2), {
fxy060608's avatar
fxy060608 已提交
822 823
        hoverClass: _getHoverClass("")
      }, $attrs.value, $excludeAttrs.value, _listeners.value);
D
DCloud_LXH 已提交
824
      return createVNode("view", mergeProps({
fxy060608's avatar
fxy060608 已提交
825
        "ref": rootRef,
fxy060608's avatar
fxy060608 已提交
826
        "class": ["ub", _getClass("")],
fxy060608's avatar
fxy060608 已提交
827
        "onClick": onClick
D
DCloud_LXH 已提交
828
      }, _attrs), [props2.loading ? createVNode("loading-indicator", mergeProps({
fxy060608's avatar
fxy060608 已提交
829 830 831 832 833 834 835 836
        "class": ["ub-loading", `ub-${TYPES[type]}-loading`]
      }, {
        arrow: "false",
        animating: "true"
      }), null) : null, ...wrapSlots()]);
    };
  }
});
fxy060608's avatar
fxy060608 已提交
837
const movableAreaProps = {
fxy060608's avatar
fxy060608 已提交
838 839 840 841 842 843 844
  scaleArea: {
    type: Boolean,
    default: false
  }
};
function flatVNode(nodes) {
  const array = [];
fxy060608's avatar
fxy060608 已提交
845
  if (isArray(nodes)) {
fxy060608's avatar
fxy060608 已提交
846 847 848 849 850 851 852
    nodes.forEach((vnode) => {
      if (isVNode(vnode)) {
        if (vnode.type === Fragment) {
          array.push(...flatVNode(vnode.children));
        } else {
          array.push(vnode);
        }
fxy060608's avatar
fxy060608 已提交
853
      } else if (isArray(vnode)) {
fxy060608's avatar
fxy060608 已提交
854 855 856 857 858 859
        array.push(...flatVNode(vnode));
      }
    });
  }
  return array;
}
D
DCloud_LXH 已提交
860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878
function cached(fn) {
  const cache = /* @__PURE__ */ Object.create(null);
  return function cachedFn(str) {
    const hit = cache[str];
    return hit || (cache[str] = fn(str));
  };
}
const parseStyleText = cached(function(cssText) {
  const res = {};
  const listDelimiter = /;(?![^(]*\))/g;
  const propertyDelimiter = /:(.+)/;
  cssText.split(listDelimiter).forEach(function(item) {
    if (item) {
      const tmp = item.split(propertyDelimiter);
      tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
    }
  });
  return res;
});
fxy060608's avatar
fxy060608 已提交
879
const getComponentSize = (el) => {
fxy060608's avatar
fxy060608 已提交
880 881 882 883
  return new Promise((resolve, reject) => {
    if (!el)
      return resolve({ width: 0, height: 0, top: 0, left: 0 });
    const dom2 = weex.requireModule("dom");
D
DCloud_LXH 已提交
884
    dom2.getComponentRect(el, ({ size }) => {
fxy060608's avatar
fxy060608 已提交
885 886 887 888 889 890
      resolve(size);
    });
  });
};
var MovableArea = defineComponent({
  name: "MovableArea",
fxy060608's avatar
fxy060608 已提交
891
  props: movableAreaProps,
fxy060608's avatar
fxy060608 已提交
892 893
  styles: [{
    "uni-movable-area": {
D
DCloud_LXH 已提交
894
      "": {
895
        overflow: "hidden",
D
DCloud_LXH 已提交
896 897 898
        width: "10px",
        height: "10px"
      }
fxy060608's avatar
fxy060608 已提交
899 900
    }
  }],
D
DCloud_LXH 已提交
901
  setup(props2, {
fxy060608's avatar
fxy060608 已提交
902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950
    slots
  }) {
    const width = ref(0);
    const height = ref(0);
    const top = ref(0);
    const left = ref(0);
    const _isMounted = ref(false);
    const rootRef = ref(null);
    const originMovableViewContexts = [];
    let touchMovableView = null;
    const setTouchMovableViewContext = (movableview) => {
      touchMovableView = movableview;
    };
    const _getWH = () => {
      return getComponentSize(rootRef.value).then(({
        width: _width,
        height: _height,
        top: _top,
        left: _left
      }) => {
        width.value = _width;
        height.value = _height;
        top.value = _top;
        left.value = _left;
      });
    };
    const _resize = () => {
      _getWH().then(() => {
        originMovableViewContexts.forEach(function(item) {
          item.setParent();
        });
      });
    };
    onMounted(() => {
      setTimeout(() => {
        _isMounted.value = true;
        _resize();
      }, 200);
    });
    const listeners = {
      onPanstart(e2) {
        touchMovableView && touchMovableView.touchstart(e2);
      },
      onPanmove(e2) {
        e2.stopPropagation();
        touchMovableView && touchMovableView.touchmove(e2);
      },
      onPanend(e2) {
        touchMovableView && touchMovableView.touchend(e2);
951
        touchMovableView = null;
fxy060608's avatar
fxy060608 已提交
952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975
      }
    };
    const addMovableViewContext = (movableViewContext) => {
      originMovableViewContexts.push(movableViewContext);
    };
    const removeMovableViewContext = (movableViewContext) => {
      const index = originMovableViewContexts.indexOf(movableViewContext);
      if (index >= 0) {
        originMovableViewContexts.splice(index, 1);
      }
    };
    provide("_isMounted", _isMounted);
    provide("parentSize", {
      width,
      height,
      top,
      left
    });
    provide("addMovableViewContext", addMovableViewContext);
    provide("removeMovableViewContext", removeMovableViewContext);
    provide("setTouchMovableViewContext", setTouchMovableViewContext);
    return () => {
      const defaultSlots = slots.default && slots.default();
      const movableViewItems = flatVNode(defaultSlots);
976
      return createVNode("view", mergeProps({
fxy060608's avatar
fxy060608 已提交
977
        "ref": rootRef,
fxy060608's avatar
fxy060608 已提交
978 979 980 981 982
        "class": "uni-movable-area"
      }, listeners), [movableViewItems]);
    };
  }
});
D
DCloud_LXH 已提交
983 984 985 986 987 988
function useTouchtrack(method) {
  const __event = {};
  function callback(type, $event) {
    if (__event[type]) {
      __event[type]($event);
    }
fxy060608's avatar
fxy060608 已提交
989
  }
D
DCloud_LXH 已提交
990 991
  function addListener(type, callback2) {
    __event[type] = function($event) {
992
      if (isFunction(callback2)) {
D
DCloud_LXH 已提交
993 994 995 996
        $event.touches = $event.changedTouches;
        if (callback2($event) === false) {
          $event.stopPropagation();
        }
fxy060608's avatar
fxy060608 已提交
997
      }
D
DCloud_LXH 已提交
998 999
    };
  }
fxy060608's avatar
fxy060608 已提交
1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047
  let x0 = 0;
  let y0 = 0;
  let x1 = 0;
  let y1 = 0;
  const fn = function($event, state, x, y) {
    if (method({
      target: $event.target,
      currentTarget: $event.currentTarget,
      stopPropagation: $event.stopPropagation.bind($event),
      touches: $event.touches,
      changedTouches: $event.changedTouches,
      detail: {
        state,
        x,
        y,
        dx: x - x0,
        dy: y - y0,
        ddx: x - x1,
        ddy: y - y1,
        timeStamp: $event.timeStamp || Date.now()
      }
    }) === false) {
      return false;
    }
  };
  let $eventOld = null;
  addListener("touchstart", function($event) {
    if (!$eventOld) {
      $eventOld = $event;
      x0 = x1 = $event.touches[0].pageX;
      y0 = y1 = $event.touches[0].pageY;
      return fn($event, "start", x0, y0);
    }
  });
  addListener("touchmove", function($event) {
    if ($eventOld) {
      const res = fn($event, "move", $event.touches[0].pageX, $event.touches[0].pageY);
      x1 = $event.touches[0].pageX;
      y1 = $event.touches[0].pageY;
      return res;
    }
  });
  addListener("touchend", function($event) {
    if ($eventOld) {
      $eventOld = null;
      return fn($event, "end", $event.changedTouches[0].pageX, $event.changedTouches[0].pageY);
    }
  });
D
DCloud_LXH 已提交
1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058
  return {
    touchstart: function($event) {
      callback("touchstart", $event);
    },
    touchmove: function($event) {
      callback("touchmove", $event);
    },
    touchend: function($event) {
      callback("touchend", $event);
    }
  };
fxy060608's avatar
fxy060608 已提交
1059
}
fxy060608's avatar
fxy060608 已提交
1060
function useCustomEvent(ref2, emit) {
fxy060608's avatar
fxy060608 已提交
1061 1062
  return (name, detail) => {
    if (ref2.value) {
fxy060608's avatar
fxy060608 已提交
1063
      emit(name, normalizeCustomEvent(name, ref2.value, detail || {}));
fxy060608's avatar
fxy060608 已提交
1064 1065 1066
    }
  };
}
fxy060608's avatar
fxy060608 已提交
1067
function normalizeCustomEvent(name, target, detail = {}) {
fxy060608's avatar
fxy060608 已提交
1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081
  target = processTarget(target);
  return {
    type: name,
    timeStamp: Date.now(),
    target,
    currentTarget: target,
    detail
  };
}
const firstLetterToLowerCase = cacheStringFunction((str) => {
  return str.charAt(0).toLowerCase() + str.slice(1);
});
function processTarget(weexTarget) {
  const { offsetLeft, offsetTop } = weexTarget;
D
DCloud_LXH 已提交
1082
  const attr2 = weexTarget.attr;
fxy060608's avatar
fxy060608 已提交
1083
  const dataset = {};
D
DCloud_LXH 已提交
1084
  Object.keys(attr2 || {}).forEach((key) => {
fxy060608's avatar
fxy060608 已提交
1085
    if (key.indexOf("data") === 0) {
D
DCloud_LXH 已提交
1086
      dataset[firstLetterToLowerCase(key.replace("data", ""))] = attr2[key];
fxy060608's avatar
fxy060608 已提交
1087 1088 1089
    }
  });
  return {
D
DCloud_LXH 已提交
1090
    id: attr2 && attr2.id || "",
fxy060608's avatar
fxy060608 已提交
1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390
    dataset,
    offsetLeft: offsetLeft || 0,
    offsetTop: offsetTop || 0
  };
}
function e(e2, t2, n) {
  return e2 > t2 - n && e2 < t2 + n;
}
function t(t2, n) {
  return e(t2, 0, n);
}
function Decline() {
}
Decline.prototype.x = function(e2) {
  return Math.sqrt(e2);
};
function Friction(e2, t2) {
  this._m = e2;
  this._f = 1e3 * t2;
  this._startTime = 0;
  this._v = 0;
}
Friction.prototype.setV = function(x, y) {
  const n = Math.pow(Math.pow(x, 2) + Math.pow(y, 2), 0.5);
  this._x_v = x;
  this._y_v = y;
  this._x_a = -this._f * this._x_v / n;
  this._y_a = -this._f * this._y_v / n;
  this._t = Math.abs(x / this._x_a) || Math.abs(y / this._y_a);
  this._lastDt = null;
  this._startTime = new Date().getTime();
};
Friction.prototype.setS = function(x, y) {
  this._x_s = x;
  this._y_s = y;
};
Friction.prototype.s = function(t2) {
  if (t2 === void 0) {
    t2 = (new Date().getTime() - this._startTime) / 1e3;
  }
  if (t2 > this._t) {
    t2 = this._t;
    this._lastDt = t2;
  }
  let x = this._x_v * t2 + 0.5 * this._x_a * Math.pow(t2, 2) + this._x_s;
  let y = this._y_v * t2 + 0.5 * this._y_a * Math.pow(t2, 2) + this._y_s;
  if (this._x_a > 0 && x < this._endPositionX || this._x_a < 0 && x > this._endPositionX) {
    x = this._endPositionX;
  }
  if (this._y_a > 0 && y < this._endPositionY || this._y_a < 0 && y > this._endPositionY) {
    y = this._endPositionY;
  }
  return {
    x,
    y
  };
};
Friction.prototype.ds = function(t2) {
  if (t2 === void 0) {
    t2 = (new Date().getTime() - this._startTime) / 1e3;
  }
  if (t2 > this._t) {
    t2 = this._t;
  }
  return {
    dx: this._x_v + this._x_a * t2,
    dy: this._y_v + this._y_a * t2
  };
};
Friction.prototype.delta = function() {
  return {
    x: -1.5 * Math.pow(this._x_v, 2) / this._x_a || 0,
    y: -1.5 * Math.pow(this._y_v, 2) / this._y_a || 0
  };
};
Friction.prototype.dt = function() {
  return -this._x_v / this._x_a;
};
Friction.prototype.done = function() {
  const t2 = e(this.s().x, this._endPositionX) || e(this.s().y, this._endPositionY) || this._lastDt === this._t;
  this._lastDt = null;
  return t2;
};
Friction.prototype.setEnd = function(x, y) {
  this._endPositionX = x;
  this._endPositionY = y;
};
Friction.prototype.reconfigure = function(m, f) {
  this._m = m;
  this._f = 1e3 * f;
};
function Spring(m, k, c) {
  this._m = m;
  this._k = k;
  this._c = c;
  this._solution = null;
  this._endPosition = 0;
  this._startTime = 0;
}
Spring.prototype._solve = function(e2, t2) {
  const n = this._c;
  const i = this._m;
  const r = this._k;
  const o = n * n - 4 * i * r;
  if (o === 0) {
    const a = -n / (2 * i);
    const s = e2;
    const l = t2 / (a * e2);
    return {
      x: function(e3) {
        return (s + l * e3) * Math.pow(Math.E, a * e3);
      },
      dx: function(e3) {
        const t3 = Math.pow(Math.E, a * e3);
        return a * (s + l * e3) * t3 + l * t3;
      }
    };
  }
  if (o > 0) {
    const c = (-n - Math.sqrt(o)) / (2 * i);
    const u = (-n + Math.sqrt(o)) / (2 * i);
    const d = (t2 - c * e2) / (u - c);
    const h = e2 - d;
    return {
      x: function(e3) {
        let t3;
        let n2;
        if (e3 === this._t) {
          t3 = this._powER1T;
          n2 = this._powER2T;
        }
        this._t = e3;
        if (!t3) {
          t3 = this._powER1T = Math.pow(Math.E, c * e3);
        }
        if (!n2) {
          n2 = this._powER2T = Math.pow(Math.E, u * e3);
        }
        return h * t3 + d * n2;
      },
      dx: function(e3) {
        let t3;
        let n2;
        if (e3 === this._t) {
          t3 = this._powER1T;
          n2 = this._powER2T;
        }
        this._t = e3;
        if (!t3) {
          t3 = this._powER1T = Math.pow(Math.E, c * e3);
        }
        if (!n2) {
          n2 = this._powER2T = Math.pow(Math.E, u * e3);
        }
        return h * c * t3 + d * u * n2;
      }
    };
  }
  const p = Math.sqrt(4 * i * r - n * n) / (2 * i);
  const f = -n / 2 * i;
  const v2 = e2;
  const g2 = (t2 - f * e2) / p;
  return {
    x: function(e3) {
      return Math.pow(Math.E, f * e3) * (v2 * Math.cos(p * e3) + g2 * Math.sin(p * e3));
    },
    dx: function(e3) {
      const t3 = Math.pow(Math.E, f * e3);
      const n2 = Math.cos(p * e3);
      const i2 = Math.sin(p * e3);
      return t3 * (g2 * p * n2 - v2 * p * i2) + f * t3 * (g2 * i2 + v2 * n2);
    }
  };
};
Spring.prototype.x = function(e2) {
  if (e2 === void 0) {
    e2 = (new Date().getTime() - this._startTime) / 1e3;
  }
  return this._solution ? this._endPosition + this._solution.x(e2) : 0;
};
Spring.prototype.dx = function(e2) {
  if (e2 === void 0) {
    e2 = (new Date().getTime() - this._startTime) / 1e3;
  }
  return this._solution ? this._solution.dx(e2) : 0;
};
Spring.prototype.setEnd = function(e2, n, i) {
  if (!i) {
    i = new Date().getTime();
  }
  if (e2 !== this._endPosition || !t(n, 0.1)) {
    n = n || 0;
    let r = this._endPosition;
    if (this._solution) {
      if (t(n, 0.1)) {
        n = this._solution.dx((i - this._startTime) / 1e3);
      }
      r = this._solution.x((i - this._startTime) / 1e3);
      if (t(n, 0.1)) {
        n = 0;
      }
      if (t(r, 0.1)) {
        r = 0;
      }
      r += this._endPosition;
    }
    if (!(this._solution && t(r - e2, 0.1) && t(n, 0.1))) {
      this._endPosition = e2;
      this._solution = this._solve(r - this._endPosition, n);
      this._startTime = i;
    }
  }
};
Spring.prototype.snap = function(e2) {
  this._startTime = new Date().getTime();
  this._endPosition = e2;
  this._solution = {
    x: function() {
      return 0;
    },
    dx: function() {
      return 0;
    }
  };
};
Spring.prototype.done = function(n) {
  if (!n) {
    n = new Date().getTime();
  }
  return e(this.x(), this._endPosition, 0.1) && t(this.dx(), 0.1);
};
Spring.prototype.reconfigure = function(m, t2, c) {
  this._m = m;
  this._k = t2;
  this._c = c;
  if (!this.done()) {
    this._solution = this._solve(this.x() - this._endPosition, this.dx());
    this._startTime = new Date().getTime();
  }
};
Spring.prototype.springConstant = function() {
  return this._k;
};
Spring.prototype.damping = function() {
  return this._c;
};
Spring.prototype.configuration = function() {
  function e2(e3, t3) {
    e3.reconfigure(1, t3, e3.damping());
  }
  function t2(e3, t3) {
    e3.reconfigure(1, e3.springConstant(), t3);
  }
  return [
    {
      label: "Spring Constant",
      read: this.springConstant.bind(this),
      write: e2.bind(this, this),
      min: 100,
      max: 1e3
    },
    {
      label: "Damping",
      read: this.damping.bind(this),
      write: t2.bind(this, this),
      min: 1,
      max: 500
    }
  ];
};
function STD(e2, t2, n) {
  this._springX = new Spring(e2, t2, n);
  this._springY = new Spring(e2, t2, n);
  this._springScale = new Spring(e2, t2, n);
  this._startTime = 0;
}
STD.prototype.setEnd = function(e2, t2, n, i) {
  const r = new Date().getTime();
  this._springX.setEnd(e2, i, r);
  this._springY.setEnd(t2, i, r);
  this._springScale.setEnd(n, i, r);
  this._startTime = r;
};
STD.prototype.x = function() {
  const e2 = (new Date().getTime() - this._startTime) / 1e3;
  return {
    x: this._springX.x(e2),
    y: this._springY.x(e2),
    scale: this._springScale.x(e2)
  };
};
STD.prototype.done = function() {
  const e2 = new Date().getTime();
  return this._springX.done(e2) && this._springY.done(e2) && this._springScale.done(e2);
};
STD.prototype.reconfigure = function(e2, t2, n) {
  this._springX.reconfigure(e2, t2, n);
  this._springY.reconfigure(e2, t2, n);
  this._springScale.reconfigure(e2, t2, n);
};
fxy060608's avatar
fxy060608 已提交
1391
const movableViewProps = {
fxy060608's avatar
fxy060608 已提交
1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490
  direction: {
    type: String,
    default: "none"
  },
  inertia: {
    type: [Boolean, String],
    default: false
  },
  outOfBounds: {
    type: [Boolean, String],
    default: false
  },
  x: {
    type: [Number, String],
    default: 0
  },
  y: {
    type: [Number, String],
    default: 0
  },
  damping: {
    type: [Number, String],
    default: 20
  },
  friction: {
    type: [Number, String],
    default: 2
  },
  disabled: {
    type: [Boolean, String],
    default: false
  },
  scale: {
    type: [Boolean, String],
    default: false
  },
  scaleMin: {
    type: [Number, String],
    default: 0.5
  },
  scaleMax: {
    type: [Number, String],
    default: 10
  },
  scaleValue: {
    type: [Number, String],
    default: 1
  },
  animation: {
    type: [Boolean, String],
    default: true
  }
};
function v(a, b) {
  return +((1e3 * a - 1e3 * b) / 1e3).toFixed(1);
}
function g(friction, execute, endCallback) {
  let record = {
    id: 0,
    cancelled: false
  };
  let cancel = function(record2) {
    if (record2 && record2.id) {
      cancelAnimationFrame(record2.id);
    }
    if (record2) {
      record2.cancelled = true;
    }
  };
  function fn(record2, friction2, execute2, endCallback2) {
    if (!record2 || !record2.cancelled) {
      execute2(friction2);
      let isDone = friction2.done();
      if (!isDone) {
        if (!record2.cancelled) {
          record2.id = requestAnimationFrame(fn.bind(null, record2, friction2, execute2, endCallback2));
        }
      }
      if (isDone && endCallback2) {
        endCallback2(friction2);
      }
    }
  }
  fn(record, friction, execute, endCallback);
  return {
    cancel: cancel.bind(null, record),
    model: friction
  };
}
let requesting = false;
function _requestAnimationFrame(e2) {
  if (!requesting) {
    requesting = true;
    requestAnimationFrame(function() {
      e2();
      requesting = false;
    });
  }
}
D
DCloud_LXH 已提交
1491 1492
function requestAnimationFrame(callback) {
  return setTimeout(callback, 16);
fxy060608's avatar
fxy060608 已提交
1493 1494 1495 1496 1497 1498 1499
}
function cancelAnimationFrame(id) {
  clearTimeout(id);
}
const animation = weex.requireModule("animation");
var MovableView = defineComponent({
  name: "MovableView",
fxy060608's avatar
fxy060608 已提交
1500
  props: movableViewProps,
fxy060608's avatar
fxy060608 已提交
1501 1502 1503
  emits: ["change", "scale"],
  styles: [{
    "uni-movable-view": {
D
DCloud_LXH 已提交
1504 1505 1506 1507 1508 1509 1510
      "": {
        position: "absolute",
        top: "0px",
        left: "0px",
        width: "10px",
        height: "10px"
      }
fxy060608's avatar
fxy060608 已提交
1511 1512
    }
  }],
D
DCloud_LXH 已提交
1513
  setup(props2, {
fxy060608's avatar
fxy060608 已提交
1514 1515 1516 1517
    emit,
    slots
  }) {
    const rootRef = ref(null);
fxy060608's avatar
fxy060608 已提交
1518
    const trigger = useCustomEvent(rootRef, emit);
fxy060608's avatar
fxy060608 已提交
1519 1520
    const setTouchMovableViewContext = inject("setTouchMovableViewContext", () => {
    });
D
DCloud_LXH 已提交
1521
    const touchStart = useMovableViewState(props2, trigger, rootRef, setTouchMovableViewContext);
fxy060608's avatar
fxy060608 已提交
1522 1523 1524 1525
    return () => {
      const attrs = {
        preventGesture: true
      };
fxy060608's avatar
fxy060608 已提交
1526
      return createVNode("view", mergeProps({
fxy060608's avatar
fxy060608 已提交
1527 1528 1529 1530 1531 1532 1533 1534
        "ref": rootRef,
        "onTouchstart": touchStart,
        "class": "uni-movable-view",
        "style": "transform-origin: center;"
      }, attrs), [slots.default && slots.default()]);
    };
  }
});
D
DCloud_LXH 已提交
1535
function useMovableViewState(props2, trigger, rootRef, setTouchMovableViewContext) {
fxy060608's avatar
fxy060608 已提交
1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546
  const _isMounted = inject("_isMounted", ref(false));
  const parentSize = inject("parentSize", {
    width: ref(0),
    height: ref(0),
    top: ref(0),
    left: ref(0)
  });
  const addMovableViewContext = inject("addMovableViewContext", () => {
  });
  const removeMovableViewContext = inject("removeMovableViewContext", () => {
  });
D
DCloud_LXH 已提交
1547 1548 1549 1550 1551 1552 1553 1554
  let movableViewContext = {
    touchstart: () => {
    },
    touchmove: () => {
    },
    touchend: () => {
    }
  };
fxy060608's avatar
fxy060608 已提交
1555 1556 1557 1558 1559 1560 1561
  function _getPx(val) {
    return Number(val) || 0;
  }
  function _getScaleNumber(val) {
    val = Number(val);
    return isNaN(val) ? 1 : val;
  }
D
DCloud_LXH 已提交
1562 1563 1564
  const xSync = ref(_getPx(props2.x));
  const ySync = ref(_getPx(props2.y));
  const scaleValueSync = ref(_getScaleNumber(Number(props2.scaleValue)));
fxy060608's avatar
fxy060608 已提交
1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602
  const width = ref(0);
  const height = ref(0);
  const minX = ref(0);
  const minY = ref(0);
  const maxX = ref(0);
  const maxY = ref(0);
  let _SFA = null;
  let _FA = null;
  const _offset = {
    x: 0,
    y: 0
  };
  const _scaleOffset = {
    x: 0,
    y: 0
  };
  let _scale = 1;
  let _translateX = 0;
  let _translateY = 0;
  let _isTouching = false;
  let __baseX;
  let __baseY;
  let _checkCanMove = null;
  let _firstMoveDirection = null;
  let _rect = {
    top: 0,
    left: 0,
    width: 0,
    height: 0
  };
  const _declineX = new Decline();
  const _declineY = new Decline();
  const __touchInfo = {
    historyX: [0, 0],
    historyY: [0, 0],
    historyT: [0, 0]
  };
  const dampingNumber = computed(() => {
D
DCloud_LXH 已提交
1603
    let val = Number(props2.damping);
fxy060608's avatar
fxy060608 已提交
1604 1605 1606
    return isNaN(val) ? 20 : val;
  });
  const frictionNumber = computed(() => {
D
DCloud_LXH 已提交
1607
    let val = Number(props2.friction);
fxy060608's avatar
fxy060608 已提交
1608 1609 1610
    return isNaN(val) || val <= 0 ? 2 : val;
  });
  const scaleMinNumber = computed(() => {
D
DCloud_LXH 已提交
1611
    let val = Number(props2.scaleMin);
fxy060608's avatar
fxy060608 已提交
1612 1613 1614
    return isNaN(val) ? 0.5 : val;
  });
  const scaleMaxNumber = computed(() => {
D
DCloud_LXH 已提交
1615
    let val = Number(props2.scaleMax);
fxy060608's avatar
fxy060608 已提交
1616 1617
    return isNaN(val) ? 10 : val;
  });
D
DCloud_LXH 已提交
1618 1619
  const xMove = computed(() => props2.direction === "all" || props2.direction === "horizontal");
  const yMove = computed(() => props2.direction === "all" || props2.direction === "vertical");
fxy060608's avatar
fxy060608 已提交
1620 1621
  const _STD = new STD(1, 9 * Math.pow(dampingNumber.value, 2) / 40, dampingNumber.value);
  const _friction = new Friction(1, frictionNumber.value);
D
DCloud_LXH 已提交
1622
  watch(() => props2.x, (val) => {
fxy060608's avatar
fxy060608 已提交
1623 1624
    xSync.value = _getPx(val);
  });
D
DCloud_LXH 已提交
1625
  watch(() => props2.y, (val) => {
fxy060608's avatar
fxy060608 已提交
1626 1627
    ySync.value = _getPx(val);
  });
D
DCloud_LXH 已提交
1628
  watch(() => props2.scaleValue, (val) => {
fxy060608's avatar
fxy060608 已提交
1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670
    scaleValueSync.value = _getScaleNumber(Number(val));
  });
  watch(xSync, _setX);
  watch(ySync, _setY);
  watch(scaleValueSync, _setScaleValue);
  watch(scaleMinNumber, _setScaleMinOrMax);
  watch(scaleMaxNumber, _setScaleMinOrMax);
  function FAandSFACancel() {
    if (_FA) {
      _FA.cancel();
    }
    if (_SFA) {
      _SFA.cancel();
    }
  }
  function _setX(val) {
    if (xMove.value) {
      if (val + _scaleOffset.x === _translateX) {
        return _translateX;
      } else {
        if (_SFA) {
          _SFA.cancel();
        }
        _animationTo(val + _scaleOffset.x, ySync.value + _scaleOffset.y, _scale);
      }
    }
    return val;
  }
  function _setY(val) {
    if (yMove.value) {
      if (val + _scaleOffset.y === _translateY) {
        return _translateY;
      } else {
        if (_SFA) {
          _SFA.cancel();
        }
        _animationTo(xSync.value + _scaleOffset.x, val + _scaleOffset.y, _scale);
      }
    }
    return val;
  }
  function _setScaleMinOrMax() {
D
DCloud_LXH 已提交
1671
    if (!props2.scale) {
fxy060608's avatar
fxy060608 已提交
1672 1673 1674 1675 1676
      return false;
    }
    _updateScale(_scale, true);
  }
  function _setScaleValue(scale) {
D
DCloud_LXH 已提交
1677
    if (!props2.scale) {
fxy060608's avatar
fxy060608 已提交
1678 1679 1680 1681 1682 1683 1684 1685
      return false;
    }
    scale = _adjustScale(scale);
    _updateScale(scale, true);
    return scale;
  }
  function __handleTouchStart() {
    {
D
DCloud_LXH 已提交
1686
      if (!props2.disabled) {
fxy060608's avatar
fxy060608 已提交
1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703
        FAandSFACancel();
        __touchInfo.historyX = [0, 0];
        __touchInfo.historyY = [0, 0];
        __touchInfo.historyT = [0, 0];
        if (xMove.value) {
          __baseX = _translateX;
        }
        if (yMove.value) {
          __baseY = _translateY;
        }
        _checkCanMove = null;
        _firstMoveDirection = null;
        _isTouching = true;
      }
    }
  }
  function __handleTouchMove(event) {
D
DCloud_LXH 已提交
1704
    if (!props2.disabled && _isTouching) {
fxy060608's avatar
fxy060608 已提交
1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730
      let x = _translateX;
      let y = _translateY;
      if (_firstMoveDirection === null) {
        _firstMoveDirection = Math.abs(event.detail.dx / event.detail.dy) > 1 ? "htouchmove" : "vtouchmove";
      }
      if (xMove.value) {
        x = event.detail.dx + __baseX;
        __touchInfo.historyX.shift();
        __touchInfo.historyX.push(x);
        if (!yMove.value && _checkCanMove === null) {
          _checkCanMove = Math.abs(event.detail.dx / event.detail.dy) < 1;
        }
      }
      if (yMove.value) {
        y = event.detail.dy + __baseY;
        __touchInfo.historyY.shift();
        __touchInfo.historyY.push(y);
        if (!xMove.value && _checkCanMove === null) {
          _checkCanMove = Math.abs(event.detail.dy / event.detail.dx) < 1;
        }
      }
      __touchInfo.historyT.shift();
      __touchInfo.historyT.push(event.detail.timeStamp);
      if (!_checkCanMove) {
        let source = "touch";
        if (x < minX.value) {
D
DCloud_LXH 已提交
1731
          if (props2.outOfBounds) {
fxy060608's avatar
fxy060608 已提交
1732 1733 1734 1735 1736 1737
            source = "touch-out-of-bounds";
            x = minX.value - _declineX.x(minX.value - x);
          } else {
            x = minX.value;
          }
        } else if (x > maxX.value) {
D
DCloud_LXH 已提交
1738
          if (props2.outOfBounds) {
fxy060608's avatar
fxy060608 已提交
1739 1740 1741 1742 1743 1744 1745
            source = "touch-out-of-bounds";
            x = maxX.value + _declineX.x(x - maxX.value);
          } else {
            x = maxX.value;
          }
        }
        if (y < minY.value) {
D
DCloud_LXH 已提交
1746
          if (props2.outOfBounds) {
fxy060608's avatar
fxy060608 已提交
1747 1748 1749 1750 1751 1752 1753
            source = "touch-out-of-bounds";
            y = minY.value - _declineY.x(minY.value - y);
          } else {
            y = minY.value;
          }
        } else {
          if (y > maxY.value) {
D
DCloud_LXH 已提交
1754
            if (props2.outOfBounds) {
fxy060608's avatar
fxy060608 已提交
1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768
              source = "touch-out-of-bounds";
              y = maxY.value + _declineY.x(y - maxY.value);
            } else {
              y = maxY.value;
            }
          }
        }
        _requestAnimationFrame(function() {
          _setTransform(x, y, _scale, source);
        });
      }
    }
  }
  function __handleTouchEnd() {
D
DCloud_LXH 已提交
1769
    if (!props2.disabled && _isTouching) {
fxy060608's avatar
fxy060608 已提交
1770
      _isTouching = false;
D
DCloud_LXH 已提交
1771
      if (!_checkCanMove && !_revise("out-of-bounds") && props2.inertia) {
fxy060608's avatar
fxy060608 已提交
1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860
        const xv = 1e3 * (__touchInfo.historyX[1] - __touchInfo.historyX[0]) / (__touchInfo.historyT[1] - __touchInfo.historyT[0]);
        const yv = 1e3 * (__touchInfo.historyY[1] - __touchInfo.historyY[0]) / (__touchInfo.historyT[1] - __touchInfo.historyT[0]);
        _friction.setV(xv, yv);
        _friction.setS(_translateX, _translateY);
        const x0 = _friction.delta().x;
        const y0 = _friction.delta().y;
        let x = x0 + _translateX;
        let y = y0 + _translateY;
        if (x < minX.value) {
          x = minX.value;
          y = _translateY + (minX.value - _translateX) * y0 / x0;
        } else {
          if (x > maxX.value) {
            x = maxX.value;
            y = _translateY + (maxX.value - _translateX) * y0 / x0;
          }
        }
        if (y < minY.value) {
          y = minY.value;
          x = _translateX + (minY.value - _translateY) * x0 / y0;
        } else {
          if (y > maxY.value) {
            y = maxY.value;
            x = _translateX + (maxY.value - _translateY) * x0 / y0;
          }
        }
        _friction.setEnd(x, y);
        _FA = g(_friction, function() {
          let t2 = _friction.s();
          let x2 = t2.x;
          let y2 = t2.y;
          _setTransform(x2, y2, _scale, "friction");
        }, function() {
          _FA.cancel();
        });
      }
    }
  }
  function _getLimitXY(x, y) {
    let outOfBounds = false;
    if (x > maxX.value) {
      x = maxX.value;
      outOfBounds = true;
    } else {
      if (x < minX.value) {
        x = minX.value;
        outOfBounds = true;
      }
    }
    if (y > maxY.value) {
      y = maxY.value;
      outOfBounds = true;
    } else {
      if (y < minY.value) {
        y = minY.value;
        outOfBounds = true;
      }
    }
    return {
      x,
      y,
      outOfBounds
    };
  }
  function _updateOffset() {
    _offset.x = _rect.left - parentSize.left.value;
    _offset.y = _rect.top - parentSize.top.value;
  }
  function _updateWH(scale) {
    scale = scale || _scale;
    scale = _adjustScale(scale);
    height.value = _rect.height / _scale;
    width.value = _rect.width / _scale;
    let _height = height.value * scale;
    let _width = width.value * scale;
    _scaleOffset.x = (_width - width.value) / 2;
    _scaleOffset.y = (_height - height.value) / 2;
  }
  function _updateBoundary() {
    let x = 0 - _offset.x + _scaleOffset.x;
    let _width = parentSize.width.value - width.value - _offset.x - _scaleOffset.x;
    minX.value = Math.min(x, _width);
    maxX.value = Math.max(x, _width);
    let y = 0 - _offset.y + _scaleOffset.y;
    let _height = parentSize.height.value - height.value - _offset.y - _scaleOffset.y;
    minY.value = Math.min(y, _height);
    maxY.value = Math.max(y, _height);
  }
  function _updateScale(scale, animat) {
D
DCloud_LXH 已提交
1861
    if (props2.scale) {
fxy060608's avatar
fxy060608 已提交
1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889
      scale = _adjustScale(scale);
      _updateWH(scale);
      _updateBoundary();
      const limitXY = _getLimitXY(_translateX, _translateY);
      const x = limitXY.x;
      const y = limitXY.y;
      if (animat) {
        _animationTo(x, y, scale, "", true, true);
      } else {
        _requestAnimationFrame(function() {
          _setTransform(x, y, scale, "", true, true);
        });
      }
    }
  }
  function _adjustScale(scale) {
    scale = Math.max(0.5, scaleMinNumber.value, scale);
    scale = Math.min(10, scaleMaxNumber.value, scale);
    return scale;
  }
  function _animationTo(x, y, scale, source, r, o) {
    FAandSFACancel();
    if (!xMove.value) {
      x = _translateX;
    }
    if (!yMove.value) {
      y = _translateY;
    }
D
DCloud_LXH 已提交
1890
    if (!props2.scale) {
fxy060608's avatar
fxy060608 已提交
1891 1892 1893 1894 1895
      scale = _scale;
    }
    let limitXY = _getLimitXY(x, y);
    x = limitXY.x;
    y = limitXY.y;
D
DCloud_LXH 已提交
1896
    if (!props2.animation) {
fxy060608's avatar
fxy060608 已提交
1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945
      _setTransform(x, y, scale, source, r, o);
      return;
    }
    _STD._springX._solution = null;
    _STD._springY._solution = null;
    _STD._springScale._solution = null;
    _STD._springX._endPosition = _translateX;
    _STD._springY._endPosition = _translateY;
    _STD._springScale._endPosition = _scale;
    _STD.setEnd(x, y, scale, 1);
    _SFA = g(_STD, function() {
      let data = _STD.x();
      let x2 = data.x;
      let y2 = data.y;
      let scale2 = data.scale;
      _setTransform(x2, y2, scale2, source, r, o);
    }, function() {
      _SFA.cancel();
    });
  }
  function _revise(source) {
    let limitXY = _getLimitXY(_translateX, _translateY);
    let x = limitXY.x;
    let y = limitXY.y;
    let outOfBounds = limitXY.outOfBounds;
    if (outOfBounds) {
      _animationTo(x, y, _scale, source);
    }
    return outOfBounds;
  }
  function _setTransform(x, y, scale, source = "", r, o) {
    if (!(x !== null && x.toString() !== "NaN" && typeof x === "number")) {
      x = _translateX || 0;
    }
    if (!(y !== null && y.toString() !== "NaN" && typeof y === "number")) {
      y = _translateY || 0;
    }
    x = Number(x.toFixed(1));
    y = Number(y.toFixed(1));
    scale = Number(scale.toFixed(1));
    if (!(_translateX === x && _translateY === y)) {
      if (!r) {
        trigger("change", {
          x: v(x, _scaleOffset.x),
          y: v(y, _scaleOffset.y),
          source
        });
      }
    }
D
DCloud_LXH 已提交
1946
    if (!props2.scale) {
fxy060608's avatar
fxy060608 已提交
1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979
      scale = _scale;
    }
    scale = _adjustScale(scale);
    scale = +scale.toFixed(3);
    if (o && scale !== _scale) {
      trigger("scale", {
        x,
        y,
        scale
      });
    }
    const transform = `translate(${x}px, ${y}px) scale(${scale})`;
    animation.transition(rootRef.value, {
      styles: {
        transform
      },
      duration: 0,
      delay: 0
    });
    _translateX = x;
    _translateY = y;
    _scale = scale;
  }
  function _updateRect() {
    return getComponentSize(rootRef.value).then((rect) => {
      _rect = rect;
    });
  }
  function setParent() {
    if (!_isMounted.value) {
      return;
    }
    FAandSFACancel();
D
DCloud_LXH 已提交
1980
    let scale = props2.scale ? scaleValueSync.value : 1;
fxy060608's avatar
fxy060608 已提交
1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991
    _updateOffset();
    _updateWH(scale);
    _updateBoundary();
    _translateX = xSync.value + _scaleOffset.x;
    _translateY = ySync.value + _scaleOffset.y;
    let limitXY = _getLimitXY(_translateX, _translateY);
    let x = limitXY.x;
    let y = limitXY.y;
    _setTransform(x, y, scale, "", true);
  }
  onMounted(() => {
D
DCloud_LXH 已提交
1992
    movableViewContext = useTouchtrack((event) => {
fxy060608's avatar
fxy060608 已提交
1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021
      switch (event.detail.state) {
        case "start":
          __handleTouchStart();
          break;
        case "move":
          __handleTouchMove(event);
          break;
        case "end":
          __handleTouchEnd();
      }
    });
    setTimeout(() => {
      _updateRect().then(() => {
        setParent();
      });
    }, 100);
    _friction.reconfigure(1, frictionNumber.value);
    _STD.reconfigure(1, 9 * Math.pow(dampingNumber.value, 2) / 40, dampingNumber.value);
    const context = {
      setParent
    };
    addMovableViewContext(context);
    onUnmounted(() => {
      removeMovableViewContext(context);
    });
  });
  onUnmounted(() => {
    FAandSFACancel();
  });
D
DCloud_LXH 已提交
2022 2023 2024 2025
  const touchStart = () => {
    setTouchMovableViewContext(movableViewContext);
  };
  return touchStart;
fxy060608's avatar
fxy060608 已提交
2026
}
fxy060608's avatar
fxy060608 已提交
2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081
const FONT_SIZE = 16;
const PROGRESS_VALUES = {
  activeColor: PRIMARY_COLOR,
  backgroundColor: "#EBEBEB",
  activeMode: "backwards"
};
const progressProps = {
  percent: {
    type: [Number, String],
    default: 0,
    validator(value) {
      return !isNaN(parseFloat(value));
    }
  },
  fontSize: {
    type: [String, Number],
    default: FONT_SIZE
  },
  showInfo: {
    type: [Boolean, String],
    default: false
  },
  strokeWidth: {
    type: [Number, String],
    default: 6,
    validator(value) {
      return !isNaN(parseFloat(value));
    }
  },
  color: {
    type: String,
    default: PROGRESS_VALUES.activeColor
  },
  activeColor: {
    type: String,
    default: PROGRESS_VALUES.activeColor
  },
  backgroundColor: {
    type: String,
    default: PROGRESS_VALUES.backgroundColor
  },
  active: {
    type: [Boolean, String],
    default: false
  },
  activeMode: {
    type: String,
    default: PROGRESS_VALUES.activeMode
  },
  duration: {
    type: [Number, String],
    default: 30,
    validator(value) {
      return !isNaN(parseFloat(value));
    }
fxy060608's avatar
fxy060608 已提交
2082 2083 2084 2085
  },
  borderRadius: {
    type: [Number, String],
    default: 0
fxy060608's avatar
fxy060608 已提交
2086 2087 2088 2089
  }
};
const progressStyles = [{
  "uni-progress": {
D
DCloud_LXH 已提交
2090 2091 2092 2093 2094
    "": {
      flex: 1,
      flexDirection: "row",
      alignItems: "center"
    }
fxy060608's avatar
fxy060608 已提交
2095 2096
  },
  "uni-progress-bar": {
D
DCloud_LXH 已提交
2097 2098 2099
    "": {
      flex: 1
    }
fxy060608's avatar
fxy060608 已提交
2100 2101
  },
  "uni-progress-inner-bar": {
D
DCloud_LXH 已提交
2102 2103 2104
    "": {
      position: "absolute"
    }
fxy060608's avatar
fxy060608 已提交
2105 2106
  },
  "uni-progress-info": {
D
DCloud_LXH 已提交
2107 2108 2109
    "": {
      marginLeft: "15px"
    }
fxy060608's avatar
fxy060608 已提交
2110 2111 2112 2113 2114 2115 2116
  }
}];
var Progress = defineComponent({
  name: "Progress",
  props: progressProps,
  styles: progressStyles,
  emits: ["activeend"],
D
DCloud_LXH 已提交
2117
  setup(props2, {
fxy060608's avatar
fxy060608 已提交
2118 2119 2120 2121
    emit
  }) {
    const progressRef = ref(null);
    const progressBarRef = ref(null);
fxy060608's avatar
fxy060608 已提交
2122
    const trigger = useCustomEvent(progressRef, emit);
D
DCloud_LXH 已提交
2123
    const state = useProgressState(props2);
fxy060608's avatar
fxy060608 已提交
2124 2125
    watch(() => state.realPercent, (newValue, oldValue) => {
      state.lastPercent = oldValue || 0;
D
DCloud_LXH 已提交
2126
      _activeAnimation(state, props2, trigger);
fxy060608's avatar
fxy060608 已提交
2127 2128 2129 2130 2131 2132 2133
    });
    onMounted(() => {
      setTimeout(() => {
        getComponentSize(progressBarRef.value).then(({
          width
        }) => {
          state.progressWidth = width || 0;
D
DCloud_LXH 已提交
2134
          _activeAnimation(state, props2, trigger);
fxy060608's avatar
fxy060608 已提交
2135 2136 2137 2138 2139 2140 2141
        });
      }, 50);
    });
    return () => {
      const {
        showInfo,
        fontSize
D
DCloud_LXH 已提交
2142
      } = props2;
fxy060608's avatar
fxy060608 已提交
2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166
      const {
        outerBarStyle,
        innerBarStyle,
        currentPercent
      } = state;
      return createVNode("div", {
        "ref": progressRef,
        "class": "uni-progress"
      }, [createVNode("div", {
        "ref": progressBarRef,
        "style": outerBarStyle,
        "class": "uni-progress-bar"
      }, [createVNode("div", {
        "style": innerBarStyle,
        "class": "uni-progress-inner-bar"
      }, null)]), showInfo ? createNVueTextVNode(currentPercent + "%", {
        class: "uni-progress-info",
        style: {
          fontSize
        }
      }) : null]);
    };
  }
});
D
DCloud_LXH 已提交
2167
function useProgressState(props2) {
fxy060608's avatar
fxy060608 已提交
2168 2169 2170
  const currentPercent = ref(0);
  const progressWidth = ref(0);
  const outerBarStyle = computed(() => ({
D
DCloud_LXH 已提交
2171
    backgroundColor: props2.backgroundColor,
fxy060608's avatar
fxy060608 已提交
2172
    borderRadius: props2.borderRadius,
D
DCloud_LXH 已提交
2173
    height: props2.strokeWidth
fxy060608's avatar
fxy060608 已提交
2174 2175
  }));
  const innerBarStyle = computed(() => {
D
DCloud_LXH 已提交
2176
    const backgroundColor = props2.color !== PROGRESS_VALUES.activeColor && props2.activeColor === PROGRESS_VALUES.activeColor ? props2.color : props2.activeColor;
fxy060608's avatar
fxy060608 已提交
2177 2178
    return {
      width: currentPercent.value * progressWidth.value / 100,
D
DCloud_LXH 已提交
2179
      height: props2.strokeWidth,
fxy060608's avatar
fxy060608 已提交
2180 2181
      backgroundColor,
      borderRadius: props2.borderRadius
fxy060608's avatar
fxy060608 已提交
2182 2183 2184
    };
  });
  const realPercent = computed(() => {
D
DCloud_LXH 已提交
2185
    let realValue = parseFloat(props2.percent);
fxy060608's avatar
fxy060608 已提交
2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200
    realValue < 0 && (realValue = 0);
    realValue > 100 && (realValue = 100);
    return realValue;
  });
  const state = reactive({
    outerBarStyle,
    innerBarStyle,
    realPercent,
    currentPercent,
    strokeTimer: 0,
    lastPercent: 0,
    progressWidth
  });
  return state;
}
D
DCloud_LXH 已提交
2201
function _activeAnimation(state, props2, trigger) {
fxy060608's avatar
fxy060608 已提交
2202
  state.strokeTimer && clearInterval(state.strokeTimer);
D
DCloud_LXH 已提交
2203 2204
  if (props2.active) {
    state.currentPercent = props2.activeMode === PROGRESS_VALUES.activeMode ? 0 : state.lastPercent;
fxy060608's avatar
fxy060608 已提交
2205 2206 2207 2208 2209 2210 2211 2212
    state.strokeTimer = setInterval(() => {
      if (state.currentPercent + 1 > state.realPercent) {
        state.currentPercent = state.realPercent;
        state.strokeTimer && clearInterval(state.strokeTimer);
        trigger("activeend", {});
      } else {
        state.currentPercent += 1;
      }
D
DCloud_LXH 已提交
2213
    }, parseFloat(props2.duration));
fxy060608's avatar
fxy060608 已提交
2214 2215 2216 2217
  } else {
    state.currentPercent = state.realPercent;
  }
}
D
DCloud_LXH 已提交
2218 2219 2220 2221 2222 2223 2224
const pickerViewProps = {
  value: {
    type: Array,
    default() {
      return [];
    },
    validator: function(val) {
fxy060608's avatar
fxy060608 已提交
2225
      return isArray(val) && val.filter((val2) => typeof val2 === "number").length === val.length;
D
DCloud_LXH 已提交
2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260
    }
  },
  indicatorStyle: {
    type: String,
    default: ""
  },
  indicatorClass: {
    type: String,
    default: ""
  },
  maskStyle: {
    type: String,
    default: ""
  },
  maskClass: {
    type: String,
    default: ""
  }
};
const nvuePickerViewProps = extend({}, pickerViewProps, {
  height: {
    type: [Number, String],
    default: 0
  }
});
var PickerView = defineComponent({
  name: "PickerView",
  props: nvuePickerViewProps,
  emits: ["change", "update:value"],
  setup(props2, {
    slots,
    emit
  }) {
    const rootRef = ref(null);
    const state = useState(props2);
fxy060608's avatar
fxy060608 已提交
2261
    const trigger = useCustomEvent(rootRef, emit);
D
DCloud_LXH 已提交
2262
    let columnVNodes = [];
fxy060608's avatar
fxy060608 已提交
2263 2264 2265
    const getItemIndex = (vnode) => {
      return Array.prototype.indexOf.call(columnVNodes.filter((vnode2) => vnode2.type !== Comment), vnode);
    };
D
DCloud_LXH 已提交
2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295
    const getPickerViewColumn = (columnInstance) => {
      return computed({
        get() {
          const index = getItemIndex(columnInstance.vnode);
          return state.value[index] || 0;
        },
        set(current) {
          if (!columnInstance.data._isMounted)
            return;
          const index = getItemIndex(columnInstance.vnode);
          if (index < 0) {
            return;
          }
          const oldCurrent = state.value[index];
          if (oldCurrent !== current) {
            state.value[index] = current;
            const value = state.value.map((val) => val);
            emit("update:value", value);
            trigger("change", {
              value
            });
          }
        }
      });
    };
    provide("getPickerViewColumn", getPickerViewColumn);
    provide("pickerViewProps", props2);
    return () => {
      const defaultSlots = slots.default && slots.default();
      columnVNodes = flatVNode(defaultSlots);
fxy060608's avatar
fxy060608 已提交
2296 2297 2298
      const style = props2.height ? {
        height: `${parseFloat(props2.height)}px`
      } : {};
D
DCloud_LXH 已提交
2299 2300
      return createVNode("view", mergeProps({
        "ref": rootRef,
fxy060608's avatar
fxy060608 已提交
2301 2302
        "class": "uni-picker-view",
        "style": style
D
DCloud_LXH 已提交
2303 2304 2305 2306
      }, {
        preventGesture: true
      }), [createVNode("view", {
        "class": "uni-picker-view-wrapper"
fxy060608's avatar
fxy060608 已提交
2307
      }, [columnVNodes])]);
D
DCloud_LXH 已提交
2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345
    };
  },
  styles: [{
    "uni-picker-view": {
      "": {
        position: "relative"
      }
    },
    "uni-picker-view-wrapper": {
      "": {
        display: "flex",
        flexDirection: "row",
        position: "absolute",
        top: 0,
        left: 0,
        right: 0,
        bottom: 0,
        overflow: "hidden"
      }
    }
  }]
});
function useState(props2) {
  const value = reactive([...props2.value]);
  const state = reactive({
    value
  });
  watch(() => props2.value, (val) => {
    state.value.length = val.length;
    val.forEach((val2, index) => {
      if (val2 !== state.value[index]) {
        state.value.splice(index, 1, val2);
      }
    });
  });
  return state;
}
const dom = weex.requireModule("dom");
2346
const isAndroid$1 = weex.config.env.platform.toLowerCase() === "android";
D
DCloud_LXH 已提交
2347
function getStyle(val) {
2348
  return extend({}, isString(val) ? parseStyleText(val) : val);
D
DCloud_LXH 已提交
2349
}
fxy060608's avatar
fxy060608 已提交
2350 2351 2352 2353 2354 2355
const props$2 = {
  length: {
    type: [Number, String],
    default: 0
  }
};
D
DCloud_LXH 已提交
2356 2357
var PickerViewColumn = defineComponent({
  name: "PickerViewColumn",
fxy060608's avatar
fxy060608 已提交
2358
  props: props$2,
D
DCloud_LXH 已提交
2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378
  data: () => ({
    _isMounted: false
  }),
  setup(props2, {
    slots
  }) {
    const instance = getCurrentInstance();
    const rootRef = ref(null);
    const contentRef = ref(null);
    const scrollViewItemRef = ref(null);
    const indicatorRef = ref(null);
    const pickerViewProps2 = inject("pickerViewProps");
    const getPickerViewColumn = inject("getPickerViewColumn");
    const current = getPickerViewColumn(instance);
    const indicatorStyle = computed(() => getStyle(pickerViewProps2.indicatorStyle));
    const maskStyle = computed(() => getStyle(pickerViewProps2.maskStyle));
    let indicatorHeight = ref(0);
    indicatorHeight.value = getHeight(indicatorStyle.value);
    let pickerViewHeight = ref(0);
    pickerViewHeight.value = parseFloat(pickerViewProps2.height);
fxy060608's avatar
fxy060608 已提交
2379 2380 2381 2382
    const {
      setCurrent,
      onScrollend
    } = usePickerColumnScroll(props2, current, contentRef, indicatorHeight);
D
DCloud_LXH 已提交
2383 2384 2385 2386 2387 2388 2389 2390
    const checkMounted = () => {
      let height_;
      let indicatorHeight_;
      setTimeout(() => {
        Promise.all([getComponentSize(rootRef.value).then(({
          height
        }) => {
          height_ = pickerViewHeight.value = height;
2391
        }), isAndroid$1 && props2.length ? getComponentSize(scrollViewItemRef.value).then(({
D
DCloud_LXH 已提交
2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402
          height
        }) => {
          indicatorHeight_ = indicatorHeight.value = height / parseFloat(props2.length);
        }) : getComponentSize(indicatorRef.value).then(({
          height
        }) => {
          indicatorHeight_ = indicatorHeight.value = height;
        })]).then(() => {
          if (height_ && indicatorHeight_) {
            setTimeout(() => {
              instance.data._isMounted = true;
fxy060608's avatar
fxy060608 已提交
2403
              setCurrent(current.value, false, true);
D
DCloud_LXH 已提交
2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414
            }, 50);
          } else {
            checkMounted();
          }
        });
      }, 50);
    };
    onMounted(checkMounted);
    const createScrollViewChild = (item) => {
      if (!item)
        return null;
2415
      return isAndroid$1 ? createVNode("div", {
D
DCloud_LXH 已提交
2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429
        "ref": scrollViewItemRef,
        "style": "flex-direction:column;"
      }, [item]) : item;
    };
    return () => {
      const children = slots.default && slots.default();
      let padding = (pickerViewHeight.value - indicatorHeight.value) / 2;
      const maskPosition = `${pickerViewHeight.value - padding}px`;
      const scrollOptions = {
        showScrollbar: false,
        scrollToBegin: false,
        decelerationRate: 0.3,
        scrollY: true
      };
2430
      if (!isAndroid$1) {
D
DCloud_LXH 已提交
2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446
        scrollOptions.scrollTop = current.value * indicatorHeight.value;
      }
      return createVNode("view", {
        "ref": rootRef,
        "class": "uni-picker-view-column"
      }, [createVNode("scroll-view", mergeProps({
        "class": "uni-picker-view-group",
        "style": "flex-direction:column;",
        "onScrollend": onScrollend
      }, scrollOptions), [createVNode("view", {
        "ref": contentRef,
        "class": "uni-picker-view-content",
        "style": {
          paddingTop: `${padding}px`,
          paddingBottom: `${padding}px`
        }
fxy060608's avatar
fxy060608 已提交
2447
      }, [createScrollViewChild(children)])]), createVNode("u-scalable", {
D
DCloud_LXH 已提交
2448 2449
        "class": "uni-picker-view-mask",
        "style": maskStyle.value
fxy060608's avatar
fxy060608 已提交
2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460
      }, [createVNode("u-scalable", {
        "class": "uni-picker-view-mask uni-picker-view-mask-top",
        "style": {
          bottom: maskPosition
        }
      }, null), createVNode("u-scalable", {
        "class": "uni-picker-view-mask uni-picker-view-mask-bottom",
        "style": {
          top: maskPosition
        }
      }, null)]), createVNode("u-scalable", {
D
DCloud_LXH 已提交
2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510
        "ref": indicatorRef,
        "class": "uni-picker-view-indicator",
        "style": extend({}, indicatorStyle.value, {
          top: `${padding}px`
        })
      }, null)]);
    };
  },
  styles: [{
    "uni-picker-view-column": {
      "": {
        flex: 1,
        position: "relative",
        alignItems: "stretch",
        overflow: "hidden"
      }
    },
    "uni-picker-view-mask": {
      "": {
        position: "absolute",
        top: 0,
        left: 0,
        right: 0,
        bottom: 0,
        pointerEvents: "none"
      }
    },
    "uni-picker-view-mask-top": {
      "": {
        bottom: 0,
        backgroundImage: "linear-gradient(to bottom,rgba(255, 255, 255, 0.95),rgba(255, 255, 255, 0.6))"
      }
    },
    "uni-picker-view-mask-bottom": {
      "": {
        top: 0,
        backgroundImage: "linear-gradient(to top,rgba(255, 255, 255, 0.95),rgba(255, 255, 255, 0.6))"
      }
    },
    "uni-picker-view-group": {
      "": {
        position: "absolute",
        top: 0,
        left: 0,
        right: 0,
        bottom: 0
      }
    },
    "uni-picker-view-content": {
      "": {
fxy060608's avatar
fxy060608 已提交
2511
        flexDirection: "column",
D
DCloud_LXH 已提交
2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541
        paddingTop: 0,
        paddingRight: 0,
        paddingBottom: 0,
        paddingLeft: 0
      }
    },
    "uni-picker-view-indicator": {
      "": {
        position: "absolute",
        left: 0,
        right: 0,
        top: 0,
        height: "34px",
        pointerEvents: "none",
        borderColor: "#e5e5e5",
        borderTopWidth: "1px",
        borderBottomWidth: "1px"
      }
    }
  }]
});
function getHeight(style) {
  const height = style.height || style.lineHeight || "";
  const res = height.match(/(-?[\d\.]+)px/);
  let value = 0;
  if (res) {
    value = parseFloat(res[1]);
  }
  return value;
}
fxy060608's avatar
fxy060608 已提交
2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585
function usePickerColumnScroll(props2, current, contentRef, indicatorHeight) {
  let scrollToElementTime;
  watch(() => props2.length, () => {
    setTimeout(() => {
      setCurrent(current.value, true, true);
    }, 150);
  });
  watch(() => current.value, (_current) => {
    dom.scrollToElement(contentRef.value, {
      offset: _current * indicatorHeight.value,
      animated: true
    });
    scrollToElementTime = Date.now();
  });
  const setCurrent = (_current, animated = true, force) => {
    if (current.value === _current && !force) {
      return;
    }
    dom.scrollToElement(contentRef.value, {
      offset: _current * indicatorHeight.value,
      animated
    });
    current.value = _current;
    if (animated) {
      scrollToElementTime = Date.now();
    }
  };
  const onScrollend = (event) => {
    if (Date.now() - scrollToElementTime < 340) {
      return;
    }
    const y = event.detail.contentOffset.y;
    const _current = Math.round(y / indicatorHeight.value);
    if (y % indicatorHeight.value) {
      setCurrent(_current, true, true);
    } else {
      current.value = _current;
    }
  };
  return {
    setCurrent,
    onScrollend
  };
}
D
DCloud_LXH 已提交
2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649
const mode = {
  SELECTOR: "selector",
  MULTISELECTOR: "multiSelector",
  TIME: "time",
  DATE: "date"
};
const fields = {
  YEAR: "year",
  MONTH: "month",
  DAY: "day"
};
function padLeft(num) {
  return num > 9 ? num : `0${num}`;
}
function getDate(str, _mode) {
  str = String(str || "");
  const date = new Date();
  if (_mode === mode.TIME) {
    const strs = str.split(":");
    if (strs.length === 2) {
      date.setHours(parseInt(strs[0]), parseInt(strs[1]));
    }
  } else {
    const strs = str.split("-");
    if (strs.length === 3) {
      date.setFullYear(parseInt(strs[0]), parseInt(String(parseFloat(strs[1]) - 1)), parseInt(strs[2]));
    }
  }
  return date;
}
function getDefaultStartValue(props2) {
  if (props2.mode === mode.TIME) {
    return "00:00";
  }
  if (props2.mode === mode.DATE) {
    const year = new Date().getFullYear() - 100;
    switch (props2.fields) {
      case fields.YEAR:
        return year;
      case fields.MONTH:
        return year + "-01";
      default:
        return year + "-01-01";
    }
  }
  return "";
}
function getDefaultEndValue(props2) {
  if (props2.mode === mode.TIME) {
    return "23:59";
  }
  if (props2.mode === mode.DATE) {
    const year = new Date().getFullYear() + 100;
    switch (props2.fields) {
      case fields.YEAR:
        return year;
      case fields.MONTH:
        return year + "-12";
      default:
        return year + "-12-31";
    }
  }
  return "";
}
fxy060608's avatar
fxy060608 已提交
2650
const props$1 = {
D
DCloud_LXH 已提交
2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694
  name: {
    type: String,
    default: ""
  },
  range: {
    type: Array,
    default() {
      return [];
    }
  },
  rangeKey: {
    type: String,
    default: ""
  },
  value: {
    type: [Number, String, Array],
    default: 0
  },
  mode: {
    type: String,
    default: mode.SELECTOR,
    validator(val) {
      return Object.values(mode).indexOf(val) >= 0;
    }
  },
  fields: {
    type: String,
    default: ""
  },
  start: {
    type: String,
    default: getDefaultStartValue
  },
  end: {
    type: String,
    default: getDefaultEndValue
  },
  disabled: {
    type: [Boolean, String],
    default: false
  }
};
var Picker = /* @__PURE__ */ defineComponent({
  name: "Picker",
fxy060608's avatar
fxy060608 已提交
2695
  props: props$1,
D
DCloud_LXH 已提交
2696 2697 2698 2699 2700 2701
  emits: ["change", "cancel", "columnchange"],
  setup(props2, {
    slots,
    emit
  }) {
    const rootRef = ref(null);
fxy060608's avatar
fxy060608 已提交
2702
    const trigger = useCustomEvent(rootRef, emit);
D
DCloud_LXH 已提交
2703 2704 2705 2706 2707 2708 2709
    const valueSync = ref(null);
    const page = ref(null);
    const _setValueSync = () => {
      let val = props2.value;
      switch (props2.mode) {
        case mode.MULTISELECTOR:
          {
fxy060608's avatar
fxy060608 已提交
2710
            if (!isArray(val)) {
D
DCloud_LXH 已提交
2711 2712
              val = [];
            }
fxy060608's avatar
fxy060608 已提交
2713
            if (!isArray(valueSync.value)) {
D
DCloud_LXH 已提交
2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801
              valueSync.value = [];
            }
            const length = valueSync.value.length = Math.max(val.length, props2.range.length);
            for (let index = 0; index < length; index++) {
              const val0 = Number(val[index]);
              const val1 = Number(valueSync.value[index]);
              const val2 = isNaN(val0) ? isNaN(val1) ? 0 : val1 : val0;
              valueSync.value.splice(index, 1, val2 < 0 ? 0 : val2);
            }
          }
          break;
        case mode.TIME:
        case mode.DATE:
          valueSync.value = String(val);
          break;
        default: {
          const _valueSync = Number(val);
          valueSync.value = _valueSync < 0 ? 0 : _valueSync;
          break;
        }
      }
    };
    const _updatePicker = (data) => {
      page.value && page.value.sendMessage(data);
    };
    const _showWeexPicker = (data) => {
      let res = {
        event: "cancel"
      };
      page.value = showPage({
        url: "__uniapppicker",
        data,
        style: {
          titleNView: false,
          animationType: "none",
          animationDuration: 0,
          background: "rgba(0,0,0,0)",
          popGesture: "none"
        },
        onMessage: (message) => {
          const event = message.event;
          if (event === "created") {
            _updatePicker(data);
            return;
          }
          if (event === "columnchange") {
            delete message.event;
            trigger(event, message);
            return;
          }
          res = message;
        },
        onClose: () => {
          page.value = null;
          const event = res.event;
          delete res.event;
          event && trigger(event, res);
        }
      });
    };
    const _showNativePicker = (data) => {
      plus.nativeUI[props2.mode === mode.TIME ? "pickTime" : "pickDate"]((res) => {
        const date = res.date;
        trigger("change", {
          value: props2.mode === mode.TIME ? `${padLeft(date.getHours())}:${padLeft(date.getMinutes())}` : `${date.getFullYear()}-${padLeft(date.getMonth() + 1)}-${padLeft(date.getDate())}`
        });
      }, () => {
        trigger("cancel", {});
      }, props2.mode === mode.TIME ? {
        time: getDate(props2.value, mode.TIME)
      } : {
        date: getDate(props2.value, mode.DATE),
        minDate: getDate(props2.start, mode.DATE),
        maxDate: getDate(props2.end, mode.DATE)
      });
    };
    const _showPicker = (data) => {
      if ((data.mode === mode.TIME || data.mode === mode.DATE) && !data.fields) {
        _showNativePicker();
      } else {
        data.fields = Object.values(fields).includes(data.fields) ? data.fields : fields.DAY;
        _showWeexPicker(data);
      }
    };
    const _show = (event) => {
      if (props2.disabled) {
        return;
      }
fxy060608's avatar
fxy060608 已提交
2802
      _showPicker(extend({}, props2, {
D
DCloud_LXH 已提交
2803
        value: valueSync.value,
fxy060608's avatar
fxy060608 已提交
2804
        locale: uni.getLocale()
D
DCloud_LXH 已提交
2805 2806
      }));
    };
fxy060608's avatar
fxy060608 已提交
2807 2808 2809 2810 2811 2812 2813 2814 2815
    const uniForm = inject(uniFormKey, false);
    const formField = {
      submit: () => [props2.name, valueSync.value],
      reset: () => {
        switch (props2.mode) {
          case mode.SELECTOR:
            valueSync.value = 0;
            break;
          case mode.MULTISELECTOR:
fxy060608's avatar
fxy060608 已提交
2816
            isArray(props2.value) && (valueSync.value = props2.value.map((val) => 0));
fxy060608's avatar
fxy060608 已提交
2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828
            break;
          case mode.DATE:
          case mode.TIME:
            valueSync.value = "";
            break;
        }
      }
    };
    if (uniForm) {
      uniForm.addField(formField);
      onBeforeUnmount(() => uniForm.removeField(formField));
    }
D
DCloud_LXH 已提交
2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842
    Object.keys(props2).forEach((key) => {
      watch(() => props2[key], (val) => {
        const data = {};
        data[key] = val;
        _updatePicker(data);
      }, {
        deep: true
      });
    });
    watch(() => props2.value, _setValueSync, {
      deep: true
    });
    _setValueSync();
    return () => {
fxy060608's avatar
fxy060608 已提交
2843
      return createVNode("view", {
D
DCloud_LXH 已提交
2844 2845
        "ref": rootRef,
        "onClick": _show
fxy060608's avatar
fxy060608 已提交
2846
      }, [slots.default && slots.default()]);
D
DCloud_LXH 已提交
2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978
    };
  }
});
const sliderProps = {
  name: {
    type: String,
    default: ""
  },
  min: {
    type: [Number, String],
    default: 0
  },
  max: {
    type: [Number, String],
    default: 100
  },
  value: {
    type: [Number, String],
    default: 0
  },
  step: {
    type: [Number, String],
    default: 1
  },
  disabled: {
    type: [Boolean, String],
    default: false
  },
  color: {
    type: String,
    default: "#e9e9e9"
  },
  backgroundColor: {
    type: String,
    default: "#e9e9e9"
  },
  activeColor: {
    type: String,
    default: "#007aff"
  },
  selectedColor: {
    type: String,
    default: "#007aff"
  },
  blockColor: {
    type: String,
    default: "#ffffff"
  },
  blockSize: {
    type: [Number, String],
    default: 28
  },
  showValue: {
    type: [Boolean, String],
    default: false
  }
};
const slierStyles = [{
  "uni-slider": {
    "": {
      flex: 1,
      flexDirection: "column",
      marginTop: "12",
      marginRight: 0,
      marginBottom: "12",
      marginLeft: 0,
      paddingTop: 0,
      paddingRight: 0,
      paddingBottom: 0,
      paddingLeft: 0
    }
  },
  "uni-slider-wrapper": {
    "": {
      flexDirection: "row",
      alignItems: "center",
      minHeight: "30"
    }
  },
  "uni-slider-tap-area": {
    "": {
      position: "relative",
      flex: 1,
      flexDirection: "column",
      paddingTop: "15",
      paddingRight: 0,
      paddingBottom: "15",
      paddingLeft: 0
    }
  },
  "uni-slider-handle-wrapper": {
    "": {
      position: "relative",
      marginTop: 0,
      marginRight: "18",
      marginBottom: 0,
      marginLeft: "18",
      height: "2",
      borderRadius: "5",
      backgroundColor: "#e9e9e9",
      transitionProperty: "backgroundColor",
      transitionDuration: 300,
      transitionTimingFunction: "ease"
    }
  },
  "uni-slider-track": {
    "": {
      height: "2",
      borderRadius: "6",
      backgroundColor: "#007aff",
      transitionProperty: "backgroundColor",
      transitionDuration: 300,
      transitionTimingFunction: "ease"
    }
  },
  "uni-slider-thumb": {
    "": {
      position: "absolute",
      width: "28",
      height: "28",
      borderRadius: 50,
      boxShadow: "0 0 4px #ebebeb",
      transitionProperty: "borderColor",
      transitionDuration: 300,
      transitionTimingFunction: "ease"
    }
  },
  "uni-slider-step": {
    "": {
      position: "absolute",
      width: 100,
      height: "2",
fxy060608's avatar
fxy060608 已提交
2979
      background: "transparent"
D
DCloud_LXH 已提交
2980 2981 2982 2983 2984 2985
    }
  },
  "uni-slider-value": {
    "": {
      color: "#888888",
      fontSize: "14",
fxy060608's avatar
fxy060608 已提交
2986
      marginLeft: "14"
D
DCloud_LXH 已提交
2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998
    }
  }
}];
var USlider = defineComponent({
  name: "USlider",
  props: sliderProps,
  styles: slierStyles,
  setup(props2, {
    emit
  }) {
    const sliderRef = ref(null);
    const sliderTrackRef = ref(null);
fxy060608's avatar
fxy060608 已提交
2999
    const trigger = useCustomEvent(sliderRef, emit);
D
DCloud_LXH 已提交
3000 3001
    const state = useSliderState(props2);
    const listeners = useSliderListeners(props2, state, trigger);
fxy060608's avatar
fxy060608 已提交
3002
    useSliderInject(props2, state);
D
DCloud_LXH 已提交
3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042
    watch(() => props2.value, (val) => {
      state.sliderValue = Number(val);
    });
    onMounted(() => {
      setTimeout(() => {
        getComponentSize(sliderRef.value).then(({
          width
        }) => {
          state.sliderWidth = width || 0;
          state.sliderValue = Number(props2.value);
        });
      }, 100);
    });
    return () => {
      const {
        showValue
      } = props2;
      const {
        trackStyle,
        trackActiveStyle,
        thumbStyle,
        sliderValue
      } = state;
      return createVNode("div", {
        "class": "uni-slider",
        "ref": sliderRef
      }, [createVNode("div", {
        "class": "uni-slider-wrapper"
      }, [createVNode("div", mergeProps({
        "class": "uni-slider-tap-area"
      }, listeners), [createVNode("div", {
        "class": "uni-slider-handle-wrapper",
        "ref": sliderTrackRef,
        "style": trackStyle
      }, [createVNode("div", {
        "class": "uni-slider-track",
        "style": trackActiveStyle
      }, null)]), createVNode("div", {
        "class": "uni-slider-thumb",
        "style": thumbStyle
fxy060608's avatar
fxy060608 已提交
3043
      }, null)]), showValue ? createNVueTextVNode(sliderValue + "", {
D
DCloud_LXH 已提交
3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060
        class: "uni-slider-value"
      }) : null])]);
    };
  }
});
function useSliderState(props2) {
  const sliderWidth = ref(0);
  const sliderValue = ref(0);
  const _getBgColor = () => {
    return props2.backgroundColor !== "#e9e9e9" ? props2.backgroundColor : props2.color !== "#007aff" ? props2.color : "#007aff";
  };
  const _getActiveColor = () => {
    return props2.activeColor !== "#007aff" ? props2.activeColor : props2.selectedColor !== "#e9e9e9" ? props2.selectedColor : "#e9e9e9";
  };
  const _getValueWidth = () => {
    const max = Number(props2.max);
    const min = Number(props2.min);
fxy060608's avatar
fxy060608 已提交
3061
    return (sliderValue.value - min) / (max - min) * sliderWidth.value;
D
DCloud_LXH 已提交
3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136
  };
  const state = reactive({
    sliderWidth,
    sliderValue,
    trackStyle: computed(() => ({
      backgroundColor: _getBgColor()
    })),
    trackActiveStyle: computed(() => ({
      backgroundColor: _getActiveColor(),
      width: _getValueWidth()
    })),
    thumbStyle: computed(() => ({
      width: props2.blockSize,
      height: props2.blockSize,
      marginTop: -props2.blockSize / 2,
      left: _getValueWidth(),
      backgroundColor: props2.blockColor
    }))
  });
  return state;
}
function useSliderListeners(props2, state, trigger) {
  let eventOld = null;
  function onTrack(action, x) {
    if (!props2.disabled) {
      if (action === "move") {
        changedValue(x);
        trigger("changing", {
          value: state.sliderValue
        });
      } else if (action === "end") {
        changedValue(x);
        trigger("change", {
          value: state.sliderValue
        });
      }
    }
  }
  function changedValue(x) {
    if (x < 0) {
      x = 0;
    }
    if (x > state.sliderWidth) {
      x = state.sliderWidth;
    }
    const max = Number(props2.max);
    const min = Number(props2.min);
    const step = Number(props2.step);
    let value = x / state.sliderWidth * max - min;
    if (step > 0 && value > step && value % step / step !== 0) {
      value -= value % step;
    }
    state.sliderValue = value + min;
  }
  const listeners = {
    onTouchstart(e2) {
      if (e2.changedTouches.length === 1 && !eventOld) {
        eventOld = e2;
        onTrack("start", e2.changedTouches[0].pageX);
      }
    },
    onTouchmove(e2) {
      if (e2.changedTouches.length === 1 && eventOld) {
        onTrack("move", e2.changedTouches[0].pageX);
      }
    },
    onTouchend(e2) {
      if (e2.changedTouches.length === 1 && eventOld) {
        eventOld = null;
        onTrack("end", e2.changedTouches[0].pageX);
      }
    }
  };
  return listeners;
}
fxy060608's avatar
fxy060608 已提交
3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158
function useSliderInject(props2, state) {
  const uniForm = inject(uniFormKey, false);
  const formField = {
    submit: () => {
      const data = ["", null];
      if (props2.name) {
        data[0] = props2.name;
        data[1] = state.sliderValue;
      }
      return data;
    },
    reset: () => {
      state.sliderValue = Number(props2.value);
    }
  };
  if (!!uniForm) {
    uniForm.addField(formField);
    onUnmounted(() => {
      uniForm.removeField(formField);
    });
  }
}
D
DCloud_LXH 已提交
3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202
const switchProps = {
  name: {
    type: String,
    default: ""
  },
  checked: {
    type: [Boolean, String],
    default: false
  },
  type: {
    type: String,
    default: "switch"
  },
  id: {
    type: String,
    default: ""
  },
  disabled: {
    type: [Boolean, String],
    default: false
  },
  color: {
    type: String,
    default: "#007aff"
  }
};
const SwitchType = {
  switch: "switch",
  checkbox: "checkbox"
};
const DCSwitchSize = {
  width: 52,
  height: 32
};
var Switch = defineComponent({
  name: "Switch",
  props: switchProps,
  emits: ["change"],
  setup(props2, {
    emit
  }) {
    const rootRef = ref(null);
    const switchChecked = ref(props2.checked);
    const uniLabel = useSwitchInject(props2, switchChecked);
fxy060608's avatar
fxy060608 已提交
3203
    const trigger = useCustomEvent(rootRef, emit);
D
DCloud_LXH 已提交
3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214
    watch(() => props2.checked, (val) => {
      switchChecked.value = val;
    });
    const listeners = {
      onChange(e2) {
        switchChecked.value = e2.detail.value;
        trigger("change", {
          value: switchChecked.value
        });
      }
    };
fxy060608's avatar
fxy060608 已提交
3215
    const _onClick = ($event, isLabelClick) => {
D
DCloud_LXH 已提交
3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242
      if (props2.disabled) {
        return;
      }
      switchChecked.value = !switchChecked.value;
      trigger("change", {
        value: switchChecked.value
      });
    };
    if (!!uniLabel) {
      uniLabel.addHandler(_onClick);
      onBeforeUnmount(() => {
        uniLabel.removeHandler(_onClick);
      });
    }
    useListeners(props2, {
      "label-click": _onClick
    });
    return () => {
      const {
        color,
        type
      } = props2;
      return createVNode("div", {
        "ref": rootRef
      }, [type === SwitchType.switch ? createVNode("dc-switch", mergeProps({
        dataUncType: "uni-switch"
      }, listeners, {
fxy060608's avatar
fxy060608 已提交
3243 3244
        checked: switchChecked.value,
        color
D
DCloud_LXH 已提交
3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302
      }, {
        "style": DCSwitchSize
      }), null) : null, type === SwitchType.checkbox ? createVNode(resolveComponent("checkbox"), mergeProps({
        "style": {
          color
        }
      }, {
        checked: switchChecked.value
      }, listeners), null) : null]);
    };
  }
});
function useSwitchInject(props2, switchChecked) {
  const uniForm = inject(uniFormKey, false);
  const uniLabel = inject(uniLabelKey, false);
  const formField = {
    submit: () => {
      const data = ["", null];
      if (props2.name) {
        data[0] = props2.name;
        data[1] = switchChecked.value;
      }
      return data;
    },
    reset: () => {
      switchChecked.value = false;
    }
  };
  if (!!uniForm) {
    uniForm.addField(formField);
    onUnmounted(() => {
      uniForm.removeField(formField);
    });
  }
  return uniLabel;
}
const checkboxProps = {
  checked: {
    type: [Boolean, String],
    default: false
  },
  id: {
    type: String,
    default: ""
  },
  disabled: {
    type: [Boolean, String],
    default: false
  },
  color: {
    type: String,
    default: "#007aff"
  },
  value: {
    type: String,
    default: ""
  }
};
fxy060608's avatar
fxy060608 已提交
3303 3304 3305 3306 3307 3308 3309
const uniCheckGroupKey = PolySymbol(process.env.NODE_ENV !== "production" ? "uniCheckGroup" : "ucg");
const checkboxGroupProps = {
  name: {
    type: String,
    default: ""
  }
};
D
DCloud_LXH 已提交
3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366
const checkboxStyles = [{
  "uni-checkbox": {
    "": {
      flexDirection: "row",
      alignItems: "center"
    }
  },
  "uni-checkbox-input": {
    "": {
      justifyContent: "center",
      alignItems: "center",
      position: "relative",
      borderWidth: "1",
      borderColor: "#d1d1d1",
      borderStyle: "solid",
      backgroundColor: "#ffffff",
      borderRadius: "3",
      width: "22",
      height: "22"
    }
  },
  "uni-icon": {
    "": {
      fontFamily: "unincomponents",
      fontSize: "16",
      marginLeft: "2",
      marginTop: "2",
      color: "#007aff"
    }
  },
  "uni-checkbox-input-disabled": {
    "": {
      backgroundColor: "#e1e1e1"
    }
  },
  "uni-checkbox-input-disabled-before": {
    "": {
      color: "#adadad"
    }
  },
  "uni-checkbox-slot": {
    "": {
      fontSize: "16",
      marginLeft: "5"
    }
  }
}];
var Checkbox = defineComponent({
  name: "Checkbox",
  props: checkboxProps,
  styles: checkboxStyles,
  setup(props2, {
    slots
  }) {
    const rootRef = ref(null);
    const checkboxChecked = ref(props2.checked);
    const checkboxValue = ref(props2.value);
fxy060608's avatar
fxy060608 已提交
3367 3368 3369 3370 3371
    const checkboxColor = computed(() => props2.disabled ? "#adadad" : props2.color);
    const reset = () => {
      checkboxChecked.value = false;
    };
    const _onClick = ($event, isLabelClick) => {
D
DCloud_LXH 已提交
3372 3373 3374 3375
      if (props2.disabled) {
        return;
      }
      checkboxChecked.value = !checkboxChecked.value;
fxy060608's avatar
fxy060608 已提交
3376
      uniCheckGroup && uniCheckGroup.checkboxChange($event);
D
DCloud_LXH 已提交
3377
    };
fxy060608's avatar
fxy060608 已提交
3378 3379 3380 3381
    const {
      uniCheckGroup,
      uniLabel
    } = useCheckboxInject(checkboxChecked, checkboxValue, reset);
D
DCloud_LXH 已提交
3382
    if (uniLabel) {
fxy060608's avatar
fxy060608 已提交
3383
      uniLabel.addHandler(_onClick);
D
DCloud_LXH 已提交
3384
      onBeforeUnmount(() => {
fxy060608's avatar
fxy060608 已提交
3385
        uniLabel.removeHandler(_onClick);
D
DCloud_LXH 已提交
3386 3387 3388
      });
    }
    useListeners(props2, {
fxy060608's avatar
fxy060608 已提交
3389 3390 3391 3392 3393
      "label-click": _onClick
    });
    watch([() => props2.checked, () => props2.value], ([newChecked, newModelValue]) => {
      checkboxChecked.value = newChecked;
      checkboxValue.value = newModelValue;
D
DCloud_LXH 已提交
3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411
    });
    const wrapSlots = () => {
      if (!slots.default)
        return [];
      const vnodes = slots.default();
      if (vnodes.length === 1 && vnodes[0].type === Text) {
        return [createNVueTextVNode(vnodes[0].children, {
          class: "uni-checkbox-slot"
        })];
      }
      return vnodes;
    };
    return () => {
      return createVNode("div", mergeProps({
        "ref": rootRef
      }, {
        dataUncType: "uni-checkbox"
      }, {
fxy060608's avatar
fxy060608 已提交
3412
        "onClick": _onClick,
D
DCloud_LXH 已提交
3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426
        "class": "uni-checkbox"
      }), [createVNode("div", {
        "class": ["uni-checkbox-input", {
          "uni-checkbox-input-disabled": props2.disabled
        }]
      }, [checkboxChecked.value ? createNVueTextVNode("\uEA08", {
        class: "uni-icon",
        style: {
          color: checkboxColor.value
        }
      }) : null]), ...wrapSlots()]);
    };
  }
});
fxy060608's avatar
fxy060608 已提交
3427 3428 3429 3430 3431 3432 3433
function useCheckboxInject(checkboxChecked, checkboxValue, reset) {
  const field = computed(() => ({
    checkboxChecked: Boolean(checkboxChecked.value),
    value: checkboxValue.value
  }));
  const formField = {
    reset
D
DCloud_LXH 已提交
3434
  };
fxy060608's avatar
fxy060608 已提交
3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447
  const uniCheckGroup = inject(uniCheckGroupKey, false);
  if (!!uniCheckGroup) {
    uniCheckGroup.addField(field);
  }
  const uniForm = inject(uniFormKey, false);
  if (!!uniForm) {
    uniForm.addField(formField);
  }
  const uniLabel = inject(uniLabelKey, false);
  onBeforeUnmount(() => {
    uniCheckGroup && uniCheckGroup.removeField(field);
    uniForm && uniForm.removeField(formField);
  });
D
DCloud_LXH 已提交
3448
  return {
fxy060608's avatar
fxy060608 已提交
3449 3450 3451
    uniCheckGroup,
    uniForm,
    uniLabel
D
DCloud_LXH 已提交
3452 3453 3454 3455
  };
}
var CheckboxGroup = defineComponent({
  name: "CheckboxGroup",
fxy060608's avatar
fxy060608 已提交
3456
  props: checkboxGroupProps,
D
DCloud_LXH 已提交
3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488
  emits: ["change"],
  setup(props2, {
    slots,
    emit
  }) {
    const rootRef = ref(null);
    const trigger = useCustomEvent(rootRef, emit);
    useProvideCheckGroup(props2, trigger);
    return () => {
      return createVNode("div", {
        "ref": rootRef,
        "class": "uni-checkbox-group"
      }, [slots.default && slots.default()]);
    };
  }
});
function useProvideCheckGroup(props2, trigger) {
  const fields2 = [];
  const getFieldsValue = () => fields2.reduce((res, field) => {
    if (field.value.checkboxChecked) {
      res.push(field.value.value);
    }
    return res;
  }, new Array());
  provide(uniCheckGroupKey, {
    addField(field) {
      fields2.push(field);
    },
    removeField(field) {
      fields2.splice(fields2.indexOf(field), 1);
    },
    checkboxChange($event) {
fxy060608's avatar
fxy060608 已提交
3489
      trigger("change", {
D
DCloud_LXH 已提交
3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530
        value: getFieldsValue()
      });
    }
  });
  const uniForm = inject(uniFormKey, false);
  if (uniForm) {
    uniForm.addField({
      submit: () => {
        let data = ["", null];
        if (props2.name !== "") {
          data[0] = props2.name;
          data[1] = getFieldsValue();
        }
        return data;
      }
    });
  }
  return getFieldsValue;
}
const radioProps = {
  checked: {
    type: [Boolean, String],
    default: false
  },
  id: {
    type: String,
    default: ""
  },
  disabled: {
    type: [Boolean, String],
    default: false
  },
  color: {
    type: String,
    default: "#007aff"
  },
  value: {
    type: String,
    default: ""
  }
};
fxy060608's avatar
fxy060608 已提交
3531 3532 3533 3534 3535 3536 3537
const uniRadioGroupKey = PolySymbol(process.env.NODE_ENV !== "production" ? "uniRadioGroup" : "ucg");
const radioGroupProps = {
  name: {
    type: String,
    default: ""
  }
};
D
DCloud_LXH 已提交
3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589
const radioStyles = [{
  "uni-radio": {
    "": {
      alignItems: "center",
      flexDirection: "row"
    }
  },
  "uni-radio-input": {
    "": {
      position: "relative",
      alignItems: "center",
      justifyContent: "center",
      marginRight: "5",
      borderStyle: "solid",
      borderWidth: "1",
      borderColor: "#d1d1d1",
      borderRadius: 50,
      width: "22",
      height: "22",
      outline: 0
    }
  },
  "uni-radio-input-icon": {
    "": {
      fontFamily: "unincomponents",
      fontSize: "14",
      color: "#ffffff"
    }
  },
  "uni-radio-input-disabled": {
    "": {
      backgroundColor: "#e1e1e1",
      borderColor: "#d1d1d1",
      color: "#adadad"
    }
  },
  "uni-radio-slot": {
    "": {
      fontSize: "16",
      marginLeft: "5"
    }
  }
}];
var Radio = defineComponent({
  name: "Radio",
  props: radioProps,
  styles: radioStyles,
  emits: ["change"],
  setup(props2, {
    slots
  }) {
    const rootRef = ref(null);
fxy060608's avatar
fxy060608 已提交
3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612
    const radioChecked = ref(props2.checked);
    const radioValue = ref(props2.value);
    const radioStyle = computed(() => {
      const color = props2.disabled ? "#adadad" : props2.color;
      if (radioChecked.value) {
        return {
          backgroundColor: color,
          borderColor: color
        };
      }
      return {
        borderColor: "#d1d1d1"
      };
    });
    const reset = () => {
      radioChecked.value = false;
    };
    const {
      uniCheckGroup,
      uniLabel,
      field
    } = useRadioInject(radioChecked, radioValue, reset);
    const _onClick = ($event, isLabelClick) => {
D
DCloud_LXH 已提交
3613 3614 3615
      if (props2.disabled) {
        return;
      }
fxy060608's avatar
fxy060608 已提交
3616 3617
      radioChecked.value = !radioChecked.value;
      uniCheckGroup && uniCheckGroup.radioChange($event, field);
D
DCloud_LXH 已提交
3618 3619
    };
    if (uniLabel) {
fxy060608's avatar
fxy060608 已提交
3620
      uniLabel.addHandler(_onClick);
D
DCloud_LXH 已提交
3621
      onBeforeUnmount(() => {
fxy060608's avatar
fxy060608 已提交
3622
        uniLabel.removeHandler(_onClick);
D
DCloud_LXH 已提交
3623 3624 3625
      });
    }
    useListeners(props2, {
fxy060608's avatar
fxy060608 已提交
3626
      "label-click": _onClick
D
DCloud_LXH 已提交
3627 3628
    });
    watch([() => props2.checked, () => props2.value], ([newChecked, newModelValue]) => {
fxy060608's avatar
fxy060608 已提交
3629 3630
      radioChecked.value = newChecked;
      radioValue.value = newModelValue;
D
DCloud_LXH 已提交
3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651
    });
    const wrapSlots = () => {
      if (!slots.default)
        return [];
      const vnodes = slots.default();
      if (vnodes.length === 1 && vnodes[0].type === Text) {
        return [createNVueTextVNode(vnodes[0].children, {
          class: "uni-radio-slot"
        })];
      }
      return vnodes;
    };
    return () => {
      const {
        disabled
      } = props2;
      return createVNode("div", mergeProps({
        "ref": rootRef
      }, {
        dataUncType: "uni-radio"
      }, {
fxy060608's avatar
fxy060608 已提交
3652
        "onClick": _onClick,
D
DCloud_LXH 已提交
3653 3654
        "class": "uni-radio"
      }), [createVNode("div", {
fxy060608's avatar
fxy060608 已提交
3655
        "style": radioStyle.value,
D
DCloud_LXH 已提交
3656 3657 3658
        "class": ["uni-radio-input", {
          "uni-radio-input-disabled": disabled
        }]
fxy060608's avatar
fxy060608 已提交
3659
      }, [radioChecked.value ? createNVueTextVNode("\uEA08", {
D
DCloud_LXH 已提交
3660 3661 3662 3663 3664
        class: "uni-radio-input-icon"
      }) : null]), ...wrapSlots()]);
    };
  }
});
fxy060608's avatar
fxy060608 已提交
3665 3666 3667 3668 3669 3670 3671 3672 3673 3674
function useRadioInject(radioChecked, radioValue, reset) {
  const field = computed({
    get: () => ({
      radioChecked: Boolean(radioChecked.value),
      value: radioValue.value
    }),
    set: ({
      radioChecked: checked
    }) => {
      radioChecked.value = checked;
D
DCloud_LXH 已提交
3675 3676
    }
  });
fxy060608's avatar
fxy060608 已提交
3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691
  const formField = {
    reset
  };
  const uniCheckGroup = inject(uniRadioGroupKey, false);
  if (!!uniCheckGroup) {
    uniCheckGroup.addField(field);
  }
  const uniForm = inject(uniFormKey, false);
  if (!!uniForm) {
    uniForm.addField(formField);
  }
  const uniLabel = inject(uniLabelKey, false);
  onBeforeUnmount(() => {
    uniCheckGroup && uniCheckGroup.removeField(field);
    uniForm && uniForm.removeField(formField);
D
DCloud_LXH 已提交
3692
  });
fxy060608's avatar
fxy060608 已提交
3693 3694 3695 3696 3697 3698
  return {
    uniCheckGroup,
    uniForm,
    uniLabel,
    field
  };
D
DCloud_LXH 已提交
3699 3700 3701
}
var RadioGroup = defineComponent({
  name: "RadioGroup",
fxy060608's avatar
fxy060608 已提交
3702
  props: radioGroupProps,
D
DCloud_LXH 已提交
3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719
  emits: ["change"],
  setup(props2, {
    slots,
    emit
  }) {
    const rootRef = ref(null);
    const trigger = useCustomEvent(rootRef, emit);
    useProvideRadioGroup(props2, trigger);
    return () => {
      return createVNode("div", {
        "ref": rootRef
      }, [slots.default && slots.default()]);
    };
  }
});
function useProvideRadioGroup(props2, trigger) {
  const fields2 = [];
fxy060608's avatar
fxy060608 已提交
3720 3721 3722 3723 3724 3725 3726
  onMounted(() => {
    _resetRadioGroupValue(fields2.length - 1);
  });
  const getFieldsValue = () => {
    var _a;
    return (_a = fields2.find((field) => field.value.radioChecked)) == null ? void 0 : _a.value.value;
  };
D
DCloud_LXH 已提交
3727 3728 3729 3730 3731 3732 3733
  provide(uniRadioGroupKey, {
    addField(field) {
      fields2.push(field);
    },
    removeField(field) {
      fields2.splice(fields2.indexOf(field), 1);
    },
fxy060608's avatar
fxy060608 已提交
3734 3735 3736 3737
    radioChange($event, field) {
      const index = fields2.indexOf(field);
      _resetRadioGroupValue(index, true);
      trigger("change", {
D
DCloud_LXH 已提交
3738 3739 3740 3741 3742
        value: getFieldsValue()
      });
    }
  });
  const uniForm = inject(uniFormKey, false);
fxy060608's avatar
fxy060608 已提交
3743 3744 3745 3746 3747 3748 3749 3750 3751 3752
  const formField = {
    submit: () => {
      let data = ["", null];
      if (props2.name !== "") {
        data[0] = props2.name;
        data[1] = getFieldsValue();
      }
      return data;
    }
  };
D
DCloud_LXH 已提交
3753
  if (uniForm) {
fxy060608's avatar
fxy060608 已提交
3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771
    uniForm.addField(formField);
    onBeforeUnmount(() => {
      uniForm.removeField(formField);
    });
  }
  function setFieldChecked(field, radioChecked) {
    field.value = {
      radioChecked,
      value: field.value.value
    };
  }
  function _resetRadioGroupValue(key, change) {
    fields2.forEach((value, index) => {
      if (index === key) {
        return;
      }
      if (change) {
        setFieldChecked(fields2[index], false);
D
DCloud_LXH 已提交
3772 3773 3774
      }
    });
  }
fxy060608's avatar
fxy060608 已提交
3775
  return fields2;
D
DCloud_LXH 已提交
3776 3777 3778 3779 3780 3781 3782 3783 3784 3785
}
const NATIVE_COMPONENTS = ["u-input", "u-textarea"];
var Form = defineComponent({
  name: "Form",
  emits: ["submit", "reset"],
  setup({}, {
    slots,
    emit
  }) {
    const rootRef = ref(null);
fxy060608's avatar
fxy060608 已提交
3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816
    const trigger = useCustomEvent(rootRef, emit);
    const fields2 = [];
    let resetNative;
    provide(uniFormKey, {
      addField(field) {
        fields2.push(field);
      },
      removeField(field) {
        fields2.splice(fields2.indexOf(field), 1);
      },
      submit(evt) {
        let outFormData = {};
        resetNative && resetNative(outFormData);
        let formData = fields2.reduce((res, field) => {
          if (field.submit) {
            const [name, value] = field.submit();
            name && (res[name] = value);
          }
          return res;
        }, /* @__PURE__ */ Object.create(null));
        Object.assign(outFormData, formData);
        trigger("submit", {
          value: outFormData
        });
      },
      reset(evt) {
        resetNative && resetNative();
        fields2.forEach((field) => field.reset && field.reset());
        trigger("reset", evt);
      }
    });
D
DCloud_LXH 已提交
3817
    return () => {
fxy060608's avatar
fxy060608 已提交
3818 3819
      const vnodes = slots.default && slots.default();
      resetNative = useResetNative(vnodes);
D
DCloud_LXH 已提交
3820 3821 3822 3823 3824 3825
      return createVNode("view", {
        "ref": rootRef
      }, [vnodes]);
    };
  }
});
fxy060608's avatar
fxy060608 已提交
3826
function useResetNative(children) {
D
DCloud_LXH 已提交
3827
  const modulePlus = weex.requireModule("plus");
fxy060608's avatar
fxy060608 已提交
3828 3829 3830
  const getOrClearNativeValue = (outResult, nodes) => {
    (nodes || children || []).forEach(function(node) {
      if (NATIVE_COMPONENTS.indexOf(String(node.type)) >= 0 && node.el && node.el.attr && node.el.attr.name) {
D
DCloud_LXH 已提交
3831 3832 3833 3834 3835 3836
        if (outResult) {
          outResult[node.el.attr.name] = modulePlus.getValue(node.el.nodeId);
        } else {
          node.el.setValue("");
        }
      }
fxy060608's avatar
fxy060608 已提交
3837
      if (isArray(node.children) && node.children && node.children.length) {
fxy060608's avatar
fxy060608 已提交
3838
        getOrClearNativeValue(outResult, node.children);
D
DCloud_LXH 已提交
3839 3840 3841
      }
    });
  };
fxy060608's avatar
fxy060608 已提交
3842
  return getOrClearNativeValue;
D
DCloud_LXH 已提交
3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976
}
const iconProps = {
  type: {
    type: String,
    default: ""
  },
  size: {
    type: [String, Number],
    default: 23
  },
  color: {
    type: String,
    default: ""
  }
};
const iconColors = {
  success: "#09bb07",
  info: "#10aeff",
  warn: "#f76260",
  waiting: "#10aeff",
  safe_success: "#09bb07",
  safe_warn: "#ffbe00",
  success_circle: "#09bb07",
  success_no_circle: "#09bb07",
  waiting_circle: "#10aeff",
  circle: "#c9c9c9",
  download: "#09bb07",
  info_circle: "#09bb07",
  cancel: "#f43530",
  search: "#b2b2b2",
  clear: "#b2b2b2"
};
const iconChars = {
  success: "\uEA06",
  info: "\uEA03",
  warn: "\uEA0B",
  waiting: "\uEA09",
  safe_success: "\uEA04",
  safe_warn: "\uEA05",
  success_circle: "\uEA07",
  success_no_circle: "\uEA08",
  waiting_circle: "\uEA0A",
  circle: "\uEA01",
  download: "\uEA02",
  info_circle: "\uEA0C",
  cancel: "\uEA0D",
  search: "\uEA0E",
  clear: "\uEA0F"
};
const iconStyles = [{
  "uni-icon": {
    "": {
      fontFamily: "unincomponents"
    }
  }
}];
var Icon = defineComponent({
  name: "Icon",
  props: iconProps,
  styles: iconStyles,
  setup(props2, {}) {
    return () => {
      return createNVueTextVNode(iconChars[props2.type], {
        class: "uni-icon",
        style: {
          color: props2.color || iconColors[props2.type],
          fontSize: props2.size
        }
      });
    };
  }
});
const swiperProps = {
  indicatorDots: {
    type: [Boolean, String],
    default: false
  },
  vertical: {
    type: [Boolean, String],
    default: false
  },
  autoplay: {
    type: [Boolean, String],
    default: false
  },
  circular: {
    type: [Boolean, String],
    default: false
  },
  interval: {
    type: [Number, String],
    default: 5e3
  },
  duration: {
    type: [Number, String],
    default: 500
  },
  current: {
    type: [Number, String],
    default: 0
  },
  indicatorColor: {
    type: String,
    default: "rgba(0,0,0,.3)"
  },
  indicatorActiveColor: {
    type: String,
    default: "#000000"
  },
  previousMargin: {
    type: String,
    default: ""
  },
  nextMargin: {
    type: String,
    default: ""
  },
  currentItemId: {
    type: String,
    default: ""
  },
  skipHiddenItemLayout: {
    type: [Boolean, String],
    default: false
  },
  displayMultipleItems: {
    type: [Number, String],
    default: 1
  },
  disableTouch: {
    type: [Boolean, String],
    default: false
  }
};
3977
const isAndroid = weex.config.env.platform.toLowerCase() === "android";
D
DCloud_LXH 已提交
3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014
const swiperStyles = [{
  "uni-swiper": {
    "": {
      position: "relative",
      height: "150px"
    }
  },
  "uni-swiper-slider": {
    "": {
      position: "absolute",
      left: 0,
      top: 0,
      right: 0,
      bottom: 0
    }
  },
  "uni-swiper-dots": {
    "": {
      position: "absolute",
      left: 0,
      right: 0,
      bottom: "10",
      height: "10"
    }
  }
}];
var Swiper = defineComponent({
  name: "Swiper",
  props: swiperProps,
  styles: swiperStyles,
  emits: ["change", "transition", "animationfinish"],
  setup(props2, {
    slots,
    emit
  }) {
    const rootRef = ref(null);
    let swiperItems = [];
fxy060608's avatar
fxy060608 已提交
4015
    const trigger = useCustomEvent(rootRef, emit);
D
DCloud_LXH 已提交
4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041
    const state = useSwiperState(props2);
    const listeners = useSwiperListeners(state, props2, swiperItems, trigger);
    watch([() => props2.current, () => props2.currentItemId], ([newChecked, newModelValue]) => {
      currentCheck(state, props2, swiperItems);
    });
    onMounted(() => {
      setTimeout(() => {
        getComponentSize(rootRef.value).then(({
          width,
          height
        }) => {
          state.swiperWidth = width;
          state.swiperHeight = height;
        });
      }, 50);
    });
    return () => {
      const defaultSlots = slots.default && slots.default();
      const {
        indicatorStyle,
        currentSync
      } = state;
      swiperItems = flatVNode(defaultSlots);
      return createVNode("div", {
        "ref": rootRef,
        "class": "uni-swiper"
fxy060608's avatar
fxy060608 已提交
4042
      }, [createVNode("slider", mergeProps({
D
DCloud_LXH 已提交
4043 4044 4045 4046 4047 4048 4049 4050 4051 4052
        "class": "uni-swiper-slider"
      }, {
        autoPlay: props2.autoplay,
        interval: props2.interval,
        index: currentSync,
        keepIndex: true,
        showIndicators: props2.indicatorDots,
        infinite: props2.circular,
        vertical: props2.vertical,
        scrollable: !props2.disableTouch
fxy060608's avatar
fxy060608 已提交
4053 4054
      }, listeners), [swiperItems, createVNode("indicator", {
        "class": "uni-swiper-dots",
4055
        "style": indicatorStyle
fxy060608's avatar
fxy060608 已提交
4056
      }, null)])]);
D
DCloud_LXH 已提交
4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082
    };
  }
});
function useSwiperState(props2) {
  let swiperWidth = ref(0);
  let swiperHeight = ref(0);
  const currentSync = ref(props2.current);
  const currentChangeSource = ref("autoplay");
  const indicatorStyle = computed(() => ({
    itemColor: props2.indicatorColor,
    itemSelectedColor: props2.indicatorActiveColor,
    itemSize: 8,
    opacity: props2.indicatorDots ? 1 : 0
  }));
  const state = reactive({
    swiperWidth,
    swiperHeight,
    indicatorStyle,
    currentSync,
    currentChangeSource
  });
  return state;
}
function useSwiperListeners(state, props2, swiperItems, trigger) {
  let lastOffsetRatio = 0;
  const onScroll = (event) => {
fxy060608's avatar
fxy060608 已提交
4083 4084 4085
    const detail = event.detail;
    const isVertical = props2.vertical;
    let offsetRatio = (isVertical ? detail.offsetYRatio : detail.offsetXRatio) || 0;
fxy060608's avatar
fxy060608 已提交
4086
    if (event.drag || event.drag) {
D
DCloud_LXH 已提交
4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098
      state.currentChangeSource = "touch";
    }
    if (offsetRatio === 0) {
      const lastOffsetRatio2 = Math.abs(lastOffsetRatio);
      if (lastOffsetRatio2 === 1) {
        return;
      } else if (lastOffsetRatio2 > 0.5) {
        offsetRatio = 1;
      }
    }
    lastOffsetRatio = offsetRatio;
    trigger("transition", {
fxy060608's avatar
fxy060608 已提交
4099 4100
      dx: isVertical ? 0 : -state.swiperWidth * offsetRatio,
      dy: isVertical ? -state.swiperHeight * offsetRatio : 0
D
DCloud_LXH 已提交
4101 4102
    });
  };
4103
  const onScrollend = (event) => {
D
DCloud_LXH 已提交
4104 4105 4106 4107
    const end = () => {
      trigger("animationfinish", getDetail());
      state.currentChangeSource = "autoplay";
    };
4108
    if (isAndroid) {
D
DCloud_LXH 已提交
4109
      end();
4110 4111
    } else {
      setTimeout(end, 50);
D
DCloud_LXH 已提交
4112 4113 4114
    }
  };
  const onChange = (event) => {
4115
    if (isString(event.detail.source)) {
fxy060608's avatar
fxy060608 已提交
4116
      state.currentChangeSource = event.detail.source;
D
DCloud_LXH 已提交
4117
    }
fxy060608's avatar
fxy060608 已提交
4118
    state.currentSync = event.detail.index;
D
DCloud_LXH 已提交
4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135
    lastOffsetRatio = 0;
  };
  function getDetail() {
    const current = Number(state.currentSync);
    const currentItem = swiperItems[current] || {};
    const currentItemId = currentItem.componentInstance && currentItem.componentInstance.itemId || "";
    return {
      current,
      currentItemId,
      source: state.currentChangeSource
    };
  }
  watch(() => state.currentSync, (val) => {
    trigger("change", getDetail());
  });
  const listeners = {
    onScroll,
4136
    onScrollend,
D
DCloud_LXH 已提交
4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320
    onChange
  };
  return listeners;
}
function currentCheck(state, props2, swiperItems) {
  let current = -1;
  if (props2.currentItemId) {
    for (let i = 0, items = swiperItems; i < items.length; i++) {
      const componentInstance = items[i].componentInstance;
      if (componentInstance && componentInstance.itemId === props2.currentItemId) {
        current = i;
        break;
      }
    }
  }
  if (current < 0) {
    current = Math.round(Number(props2.current)) || 0;
  }
  current = current < 0 ? 0 : current;
  if (state.currentSync !== current) {
    state.currentChangeSource = "";
    state.currentSync = current;
  }
}
const swiperItemProps = {
  itemId: {
    type: String,
    default: ""
  }
};
var SwiperItem = defineComponent({
  name: "SwiperItem",
  props: swiperItemProps,
  setup(props2, {
    slots
  }) {
    return () => {
      return createVNode("div", {
        "class": "uni-swiper-item",
        "style": {
          position: "absolute",
          left: 0,
          top: 0,
          right: 0,
          bottom: 0,
          overflow: "hidden"
        }
      }, [slots.default && slots.default()]);
    };
  }
});
var startTag = /^<([-A-Za-z0-9_]+)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/;
var endTag = /^<\/([-A-Za-z0-9_]+)[^>]*>/;
var attr = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g;
var empty = /* @__PURE__ */ makeMap("area,base,basefont,br,col,frame,hr,img,input,link,meta,param,embed,command,keygen,source,track,wbr");
var block = /* @__PURE__ */ makeMap("a,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video");
var inline = /* @__PURE__ */ makeMap("abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var");
var closeSelf = /* @__PURE__ */ makeMap("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr");
var fillAttrs = /* @__PURE__ */ makeMap("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected");
var special = /* @__PURE__ */ makeMap("script,style");
function HTMLParser(html, handler) {
  var index;
  var chars;
  var match;
  var stack = [];
  var last = html;
  stack.last = function() {
    return this[this.length - 1];
  };
  while (html) {
    chars = true;
    if (!stack.last() || !special[stack.last()]) {
      if (html.indexOf("<!--") == 0) {
        index = html.indexOf("-->");
        if (index >= 0) {
          if (handler.comment) {
            handler.comment(html.substring(4, index));
          }
          html = html.substring(index + 3);
          chars = false;
        }
      } else if (html.indexOf("</") == 0) {
        match = html.match(endTag);
        if (match) {
          html = html.substring(match[0].length);
          match[0].replace(endTag, parseEndTag);
          chars = false;
        }
      } else if (html.indexOf("<") == 0) {
        match = html.match(startTag);
        if (match) {
          html = html.substring(match[0].length);
          match[0].replace(startTag, parseStartTag);
          chars = false;
        }
      }
      if (chars) {
        index = html.indexOf("<");
        var text = index < 0 ? html : html.substring(0, index);
        html = index < 0 ? "" : html.substring(index);
        if (handler.chars) {
          handler.chars(text);
        }
      }
    } else {
      html = html.replace(new RegExp("([\\s\\S]*?)</" + stack.last() + "[^>]*>"), function(all, text2) {
        text2 = text2.replace(/<!--([\s\S]*?)-->|<!\[CDATA\[([\s\S]*?)]]>/g, "$1$2");
        if (handler.chars) {
          handler.chars(text2);
        }
        return "";
      });
      parseEndTag("", stack.last());
    }
    if (html == last) {
      throw "Parse Error: " + html;
    }
    last = html;
  }
  parseEndTag();
  function parseStartTag(tag, tagName, rest, unary) {
    tagName = tagName.toLowerCase();
    if (block[tagName]) {
      while (stack.last() && inline[stack.last()]) {
        parseEndTag("", stack.last());
      }
    }
    if (closeSelf[tagName] && stack.last() == tagName) {
      parseEndTag("", tagName);
    }
    unary = empty[tagName] || !!unary;
    if (!unary) {
      stack.push(tagName);
    }
    if (handler.start) {
      var attrs = [];
      rest.replace(attr, function(match2, name) {
        var value = arguments[2] ? arguments[2] : arguments[3] ? arguments[3] : arguments[4] ? arguments[4] : fillAttrs[name] ? name : "";
        attrs.push({
          name,
          value,
          escaped: value.replace(/(^|[^\\])"/g, '$1\\"')
        });
      });
      if (handler.start) {
        handler.start(tagName, attrs, unary);
      }
    }
  }
  function parseEndTag(tag, tagName) {
    if (!tagName) {
      var pos = 0;
    } else {
      for (var pos = stack.length - 1; pos >= 0; pos--) {
        if (stack[pos] == tagName) {
          break;
        }
      }
    }
    if (pos >= 0) {
      for (var i = stack.length - 1; i >= pos; i--) {
        if (handler.end) {
          handler.end(stack[i]);
        }
      }
      stack.length = pos;
    }
  }
}
function makeMap(str) {
  var obj = {};
  var items = str.split(",");
  for (var i = 0; i < items.length; i++) {
    obj[items[i]] = true;
  }
  return obj;
}
function removeDOCTYPE(html) {
  return html.replace(/<\?xml.*\?>\n/, "").replace(/<!doctype.*>\n/, "").replace(/<!DOCTYPE.*>\n/, "");
}
function parseAttrs(attrs) {
  return attrs.reduce(function(pre, attr2) {
    let value = attr2.value;
    const name = attr2.name;
fxy060608's avatar
fxy060608 已提交
4321
    if (value.match(/ /) && ["style", "src"].indexOf(name) === -1) {
D
DCloud_LXH 已提交
4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419
      value = value.split(" ");
    }
    if (pre[name]) {
      if (Array.isArray(pre[name])) {
        pre[name].push(value);
      } else {
        pre[name] = [pre[name], value];
      }
    } else {
      pre[name] = value;
    }
    return pre;
  }, {});
}
function parseHtml(html) {
  html = removeDOCTYPE(html);
  const stacks = [];
  const results = {
    node: "root",
    children: []
  };
  HTMLParser(html, {
    start: function(tag, attrs, unary) {
      const node = {
        name: tag
      };
      if (attrs.length !== 0) {
        node.attrs = parseAttrs(attrs);
      }
      if (unary) {
        const parent = stacks[0] || results;
        if (!parent.children) {
          parent.children = [];
        }
        parent.children.push(node);
      } else {
        stacks.unshift(node);
      }
    },
    end: function(tag) {
      const node = stacks.shift();
      if (node.name !== tag)
        console.error("invalid state: mismatch end tag");
      if (stacks.length === 0) {
        results.children.push(node);
      } else {
        const parent = stacks[0];
        if (!parent.children) {
          parent.children = [];
        }
        parent.children.push(node);
      }
    },
    chars: function(text) {
      const node = {
        type: "text",
        text
      };
      if (stacks.length === 0) {
        results.children.push(node);
      } else {
        const parent = stacks[0];
        if (!parent.children) {
          parent.children = [];
        }
        parent.children.push(node);
      }
    },
    comment: function(text) {
      const node = {
        node: "comment",
        text
      };
      const parent = stacks[0];
      if (!parent.children) {
        parent.children = [];
      }
      parent.children.push(node);
    }
  });
  return results.children;
}
const props = {
  nodes: {
    type: [Array, String],
    default: function() {
      return [];
    }
  }
};
const defaultFontSize = 16;
var RichText = defineComponent({
  name: "RichText",
  props,
  setup(props2) {
    const instance = getCurrentInstance();
    return () => {
      let nodes = props2.nodes;
4420
      if (isString(nodes)) {
D
DCloud_LXH 已提交
4421 4422
        nodes = parseHtml(nodes);
      }
fxy060608's avatar
fxy060608 已提交
4423
      return createVNode("u-rich-text", {
D
DCloud_LXH 已提交
4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563
        value: normalizeNodes(nodes || [], instance.root, {
          defaultFontSize
        })
      }, null);
    };
  }
});
function normalizeNodes(nodes, instance, options) {
  const TAGS = ["span", "a", "image", "img"];
  const strategies = {
    blockquote: block2,
    br,
    div: block2,
    dl: block2,
    h1: createHeading(2),
    h2: createHeading(1.5),
    h3: createHeading(1.17),
    h4: createHeading(1),
    h5: createHeading(0.83),
    h6: createHeading(0.67),
    hr: block2,
    ol: block2,
    p: block2,
    strong: bold,
    table: block2,
    tbody: block2,
    tfoot: block2,
    thead: block2,
    ul: block2
  };
  const HTML_RE = /&(amp|gt|lt|nbsp|quot|apos);/g;
  const CHARS = {
    amp: "&",
    gt: ">",
    lt: "<",
    nbsp: " ",
    quot: '"',
    apos: "'"
  };
  const breakNode = {
    type: "span",
    __type: "break",
    attr: {
      value: "\n"
    }
  };
  let lastNode = {
    __block: true,
    __break: true,
    children: []
  };
  let breakNodes = null;
  function parseStyle(node) {
    const styles = /* @__PURE__ */ Object.create(null);
    if (node.attrs) {
      const classList = (node.attrs.class || "").split(" ");
      Object.assign(styles, parseClassList(classList, instance), parseStyleText(node.attrs.style || ""));
    }
    if (node.name === "img" || node.name === "image") {
      const attrs = node.attrs;
      styles.width = styles.width || attrs.width;
      styles.height = styles.height || attrs.height;
    }
    return styles;
  }
  function block2(node) {
    node.__block = true;
    return node;
  }
  function heading(node, em) {
    if (node.style)
      !node.style.fontSize && (node.style.fontSize = options.defaultFontSize * em);
    return block2(bold(node));
  }
  function createHeading(em) {
    return function(node) {
      return heading(node, em);
    };
  }
  function bold(node) {
    if (node.style)
      !node.style.fontWeight && (node.style.fontWeight = "bold");
    return node;
  }
  function br(node) {
    node.__value = " ";
    return block2(node);
  }
  function normalizeText(str) {
    return str.replace(HTML_RE, function(match, entity) {
      return CHARS[entity];
    });
  }
  function normalizeNode(node) {
    let type = (node.name || "").toLowerCase();
    const __type = type;
    const strategy = strategies[type];
    if (TAGS.indexOf(type) === -1) {
      type = "span";
    }
    if (type === "img") {
      type = "image";
    }
    const nvueNode = {
      type,
      __type,
      attr: /* @__PURE__ */ Object.create(null)
    };
    if (node.type === "text" || node.text) {
      nvueNode.__value = nvueNode.attr.value = normalizeText((node.text || "").trim());
    }
    if (node.attrs) {
      Object.keys(node.attrs).forEach((name) => {
        if (name !== "class" && name !== "style") {
          nvueNode.attr[name] = node.attrs[name];
        }
      });
    }
    nvueNode.style = parseStyle(node);
    if (strategy) {
      strategy(nvueNode);
    }
    if (lastNode.__block || nvueNode.__block) {
      if (!breakNodes) {
        lastNode.children.push(breakNode);
        breakNodes = [lastNode, breakNode];
      }
    }
    lastNode = nvueNode;
    if (lastNode.__value || lastNode.type === "image" && lastNode.attr.src) {
      breakNodes = null;
    }
    nvueNode.children = normalizeNodes2(node.children);
    lastNode = nvueNode;
    if (lastNode.__block && lastNode.style.height && !/^0(px)?$/.test(lastNode.style.height)) {
      breakNodes = null;
    }
    return nvueNode;
  }
  function normalizeNodes2(nodes2) {
fxy060608's avatar
fxy060608 已提交
4564
    if (isArray(nodes2)) {
D
DCloud_LXH 已提交
4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577
      return nodes2.map((node) => normalizeNode(node));
    }
    return [];
  }
  const nvueNodes = normalizeNodes2(nodes);
  if (breakNodes) {
    const [lastNode2, breakNode2] = breakNodes;
    const children = lastNode2.children;
    const index = children.indexOf(breakNode2);
    children.splice(index, 1);
  }
  return nvueNodes;
}
fxy060608's avatar
fxy060608 已提交
4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629
const _adDataCache$1 = {};
function getAdData$1(data, onsuccess, onerror) {
  const { adpid, width } = data;
  const key = adpid + "-" + width;
  const adDataList = _adDataCache$1[key];
  if (adDataList && adDataList.length > 0) {
    onsuccess(adDataList.splice(0, 1)[0]);
    return;
  }
  plus.ad.getAds(data, (res) => {
    const list = res.ads;
    onsuccess(list.splice(0, 1)[0]);
    _adDataCache$1[key] = adDataList ? adDataList.concat(list) : list;
  }, (err) => {
    onerror({
      errCode: err.code,
      errMsg: err.message
    });
  });
}
const adProps = {
  adpid: {
    type: [Number, String],
    default: ""
  },
  data: {
    type: String,
    default: ""
  },
  width: {
    type: String,
    default: ""
  },
  channel: {
    type: String,
    default: ""
  }
};
const AdEventType$1 = {
  load: "load",
  close: "close",
  error: "error",
  downloadchange: "downloadchange"
};
var Ad = defineComponent({
  name: "Ad",
  props: adProps,
  emits: [AdEventType$1.load, AdEventType$1.close, AdEventType$1.error, AdEventType$1.downloadchange],
  setup(props2, {
    emit
  }) {
    const adRef = ref(null);
fxy060608's avatar
fxy060608 已提交
4630
    const trigger = useCustomEvent(adRef, emit);
fxy060608's avatar
fxy060608 已提交
4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734
    const state = useAdState();
    watch(() => props2.adpid, (value) => {
      _loadAdData$1(state, props2, trigger);
    });
    watch(() => props2.data, (value) => {
      state.data = value;
    });
    onMounted(() => {
      setTimeout(() => {
        getComponentSize(adRef.value).then(({
          width
        }) => {
          state.width = width === 0 ? -1 : width;
          _loadAdData$1(state, props2, trigger);
        });
      }, 50);
    });
    const listeners = {
      onDownloadchange(e2) {
        trigger(AdEventType$1.downloadchange, e2);
      },
      onDislike(e2) {
        trigger(AdEventType$1.close, e2);
      }
    };
    return () => {
      return createVNode("u-ad", mergeProps({
        "ref": adRef
      }, {
        data: state.data,
        rendering: true
      }, listeners), null);
    };
  }
});
function useAdState(props2) {
  const data = ref("");
  const state = reactive({
    width: 0,
    data
  });
  return state;
}
function _loadAdData$1(state, props2, trigger) {
  getAdData$1({
    adpid: props2.adpid,
    width: state.width
  }, (res) => {
    state.data = res;
    trigger(AdEventType$1.load, {});
  }, (err) => {
    trigger(AdEventType$1.error, err);
  });
}
const _adDataCache = {};
function getAdData(adpid, width, height, onsuccess, onerror) {
  const key = adpid + "-" + width;
  const adDataList = _adDataCache[key];
  if (adDataList && adDataList.length > 0) {
    onsuccess(adDataList.splice(0, 1)[0]);
    return;
  }
  plus.ad.getDrawAds({
    adpid: String(adpid),
    count: 3,
    width
  }, (res) => {
    const list = res.ads;
    onsuccess(list.splice(0, 1)[0]);
    _adDataCache[key] = adDataList ? adDataList.concat(list) : list;
  }, (err) => {
    onerror({
      errCode: err.code,
      errMsg: err.message
    });
  });
}
const adDrawProps = {
  adpid: {
    type: [Number, String],
    default: ""
  },
  data: {
    type: String,
    default: ""
  },
  width: {
    type: String,
    default: ""
  }
};
const AdEventType = {
  load: "load",
  close: "close",
  error: "error"
};
var AdDraw = defineComponent({
  name: "AdDraw",
  props: adDrawProps,
  emits: [AdEventType.load, AdEventType.close, AdEventType.error],
  setup(props2, {
    emit
  }) {
    const adRef = ref(null);
fxy060608's avatar
fxy060608 已提交
4735
    const trigger = useCustomEvent(adRef, emit);
fxy060608's avatar
fxy060608 已提交
4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789
    const state = useAdDrawState();
    watch(() => props2.adpid, (value) => {
      _loadAdData(state, props2, trigger);
    });
    watch(() => props2.data, (value) => {
      state.data = value;
    });
    const listeners = {
      onDislike(e2) {
        trigger(AdEventType.close, e2);
      }
    };
    onMounted(() => {
      setTimeout(() => {
        getComponentSize(adRef.value).then(({
          width,
          height
        }) => {
          state.width = width === 0 ? -1 : width;
          state.height = height === 0 ? -1 : height;
          _loadAdData(state, props2, trigger);
        });
      }, 50);
    });
    return () => {
      const {
        data
      } = state;
      return createVNode("u-ad-draw", mergeProps({
        "ref": adRef
      }, {
        data,
        rendering: true
      }, listeners), null);
    };
  }
});
function useAdDrawState(props2) {
  const data = ref("");
  const state = reactive({
    width: 0,
    height: 0,
    data
  });
  return state;
}
function _loadAdData(state, props2, trigger) {
  getAdData(props2.adpid, state.width, state.height, (res) => {
    state.data = res;
    trigger(AdEventType.load, {});
  }, (err) => {
    trigger(AdEventType.error, err);
  });
}
fxy060608's avatar
fxy060608 已提交
4790
var components = {
fxy060608's avatar
fxy060608 已提交
4791 4792 4793 4794
  Navigator,
  Label,
  Button,
  MovableArea,
fxy060608's avatar
fxy060608 已提交
4795
  MovableView,
D
DCloud_LXH 已提交
4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809
  Progress,
  PickerView,
  PickerViewColumn,
  Picker,
  USlider,
  Switch,
  Checkbox,
  CheckboxGroup,
  Radio,
  RadioGroup,
  Form,
  Icon,
  Swiper,
  SwiperItem,
fxy060608's avatar
fxy060608 已提交
4810 4811 4812
  RichText,
  Ad,
  AdDraw
fxy060608's avatar
fxy060608 已提交
4813 4814
};
export { components as default };