From 62227d823b3d7a3eabe059959b76d640e3f40de4 Mon Sep 17 00:00:00 2001 From: DCloud_LXH <283700113@qq.com> Date: Thu, 27 May 2021 19:25:32 +0800 Subject: [PATCH] refactor: picker --- packages/uni-h5/dist/uni-h5.cjs.js | 1553 ++++++++-------- packages/uni-h5/dist/uni-h5.es.js | 1555 ++++++++--------- packages/uni-h5/src/view/components/index.ts | 2 +- .../src/view/components/picker/index.tsx | 953 ++++++++++ .../src/view/components/picker/index.vue | 785 --------- packages/uni-h5/style/picker.css | 6 +- 6 files changed, 2498 insertions(+), 2356 deletions(-) create mode 100644 packages/uni-h5/src/view/components/picker/index.tsx delete mode 100644 packages/uni-h5/src/view/components/picker/index.vue diff --git a/packages/uni-h5/dist/uni-h5.cjs.js b/packages/uni-h5/dist/uni-h5.cjs.js index f5d2aa808..3eddd34e8 100644 --- a/packages/uni-h5/dist/uni-h5.cjs.js +++ b/packages/uni-h5/dist/uni-h5.cjs.js @@ -164,6 +164,8 @@ const ViewJSBridge = /* @__PURE__ */ initBridge("view"); uniShared.passive(true); const onEventPrevent = /* @__PURE__ */ vue.withModifiers(() => { }, ["prevent"]); +const onEventStop = /* @__PURE__ */ vue.withModifiers(() => { +}, ["stop"]); function updateCssVar(cssVars) { const style = document.documentElement.style; Object.keys(cssVars).forEach((name) => { @@ -867,7 +869,7 @@ function throttle(fn, wait) { }; return newFn; } -const _sfc_main$2 = { +const _sfc_main$1 = { name: "Audio", mixins: [subscriber], props: { @@ -992,7 +994,7 @@ const _hoisted_3$1 = {class: "uni-audio-time"}; const _hoisted_4$1 = {class: "uni-audio-info"}; const _hoisted_5 = {class: "uni-audio-name"}; const _hoisted_6 = {class: "uni-audio-author"}; -function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) { +function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) { return vue.openBlock(), vue.createBlock("uni-audio", vue.mergeProps({ id: $props.id, controls: !!$props.controls @@ -1022,7 +1024,7 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) { ]) ], 16, ["id", "controls"]); } -_sfc_main$2.render = _sfc_render$2; +_sfc_main$1.render = _sfc_render$1; function converPx(value) { if (/^-?\d+[ur]px$/i.test(value)) { return value.replace(/(^-?\d+)[ur]px$/i, (text, num) => { @@ -1254,7 +1256,7 @@ function normalizeCustomEvent(name, domEvt, el, detail) { }; } const uniFormKey = PolySymbol(process.env.NODE_ENV !== "production" ? "uniForm" : "uf"); -var index$x = /* @__PURE__ */ defineBuiltInComponent({ +var index$y = /* @__PURE__ */ defineBuiltInComponent({ name: "Form", setup(_props, { slots, @@ -1294,15 +1296,15 @@ function provideForm(emit2) { return fields2; } const uniLabelKey = PolySymbol(process.env.NODE_ENV !== "production" ? "uniLabel" : "ul"); -const props$u = { +const props$v = { for: { type: String, default: "" } }; -var index$w = /* @__PURE__ */ defineBuiltInComponent({ +var index$x = /* @__PURE__ */ defineBuiltInComponent({ name: "Label", - props: props$u, + props: props$v, setup(props2, { slots }) { @@ -1344,7 +1346,7 @@ function useProvideLabel() { }); return handlers; } -var index$v = /* @__PURE__ */ defineBuiltInComponent({ +var index$w = /* @__PURE__ */ defineBuiltInComponent({ name: "Button", props: { id: { @@ -1543,7 +1545,7 @@ function getTempCanvas(width = 0, height = 0) { tempCanvas.height = height; return tempCanvas; } -const props$t = { +const props$u = { canvasId: { type: String, default: "" @@ -1553,13 +1555,13 @@ const props$t = { default: false } }; -var index$u = /* @__PURE__ */ defineBuiltInComponent({ +var index$v = /* @__PURE__ */ defineBuiltInComponent({ inheritAttrs: false, name: "Canvas", compatConfig: { MODE: 3 }, - props: props$t, + props: props$u, computed: { id() { return this.canvasId; @@ -2035,15 +2037,15 @@ function useMethods(canvasRef, actionsWaiting) { }); } const uniCheckGroupKey = PolySymbol(process.env.NODE_ENV !== "production" ? "uniCheckGroup" : "ucg"); -const props$s = { +const props$t = { name: { type: String, default: "" } }; -var index$t = /* @__PURE__ */ defineBuiltInComponent({ +var index$u = /* @__PURE__ */ defineBuiltInComponent({ name: "CheckboxGroup", - props: props$s, + props: props$t, emits: ["change"], setup(props2, { emit: emit2, @@ -2095,7 +2097,7 @@ function useProvideCheckGroup(props2, trigger) { } return getFieldsValue; } -const props$r = { +const props$s = { checked: { type: [Boolean, String], default: false @@ -2117,9 +2119,9 @@ const props$r = { default: "" } }; -var index$s = /* @__PURE__ */ defineBuiltInComponent({ +var index$t = /* @__PURE__ */ defineBuiltInComponent({ name: "Checkbox", - props: props$r, + props: props$s, setup(props2, { slots }) { @@ -2188,7 +2190,7 @@ function useCheckboxInject(checkboxChecked, checkboxValue, reset) { let resetTimer; function iosHideKeyboard() { } -const props$q = { +const props$r = { cursorSpacing: { type: [Number, String], default: 0 @@ -2374,7 +2376,7 @@ function useQuill(props2, rootRef, trigger) { } }, id, true); } -const props$p = /* @__PURE__ */ shared.extend({}, props$q, { +const props$q = /* @__PURE__ */ shared.extend({}, props$r, { id: { type: String, default: "" @@ -2400,9 +2402,9 @@ const props$p = /* @__PURE__ */ shared.extend({}, props$q, { default: false } }); -var index$r = /* @__PURE__ */ defineBuiltInComponent({ +var index$s = /* @__PURE__ */ defineBuiltInComponent({ name: "Editor", - props: props$p, + props: props$q, emit: ["ready", "focus", "blur", "input", "statuschange", ...emit$1], setup(props2, { emit: emit2 @@ -2461,7 +2463,7 @@ const ICONS = { c: GREY_COLOR } }; -var index$q = /* @__PURE__ */ defineBuiltInComponent({ +var index$r = /* @__PURE__ */ defineBuiltInComponent({ name: "Icon", props: { type: { @@ -2488,7 +2490,7 @@ var index$q = /* @__PURE__ */ defineBuiltInComponent({ }; } }); -const props$o = { +const props$p = { src: { type: String, default: "" @@ -2525,9 +2527,9 @@ const IMAGE_MODES = { "bottom left": ["left bottom"], "bottom right": ["right bottom"] }; -var index$p = /* @__PURE__ */ defineBuiltInComponent({ +var index$q = /* @__PURE__ */ defineBuiltInComponent({ name: "Image", - props: props$o, + props: props$p, setup(props2, { emit: emit2 }) { @@ -2762,7 +2764,7 @@ const UniViewJSBridgeSubscribe = function() { function getValueString(value) { return value === null ? "" : String(value); } -const props$n = /* @__PURE__ */ shared.extend({}, { +const props$o = /* @__PURE__ */ shared.extend({}, { name: { type: String, default: "" @@ -2827,7 +2829,7 @@ const props$n = /* @__PURE__ */ shared.extend({}, { type: String, default: "done" } -}, props$q); +}, props$r); const emit = [ "input", "focus", @@ -3014,7 +3016,7 @@ function useField(props2, rootRef, emit2, beforeInput) { trigger }; } -const props$m = /* @__PURE__ */ shared.extend({}, props$n, { +const props$n = /* @__PURE__ */ shared.extend({}, props$o, { placeholderClass: { type: String, default: "input-placeholder" @@ -3022,7 +3024,7 @@ const props$m = /* @__PURE__ */ shared.extend({}, props$n, { }); var Input = /* @__PURE__ */ defineBuiltInComponent({ name: "Input", - props: props$m, + props: props$n, emits: ["confirm", ...emit], setup(props2, { emit: emit2 @@ -3177,16 +3179,16 @@ function flatVNode(nodes) { } return array; } -const props$l = { +const props$m = { scaleArea: { type: Boolean, default: false } }; -var index$o = /* @__PURE__ */ defineBuiltInComponent({ +var index$p = /* @__PURE__ */ defineBuiltInComponent({ inheritAttrs: false, name: "MovableArea", - props: props$l, + props: props$m, setup(props2, { slots }) { @@ -3485,7 +3487,7 @@ function useTouchtrack(element, method, useCancel) { function e(e2, t2, n) { return e2 > t2 - n && e2 < t2 + n; } -function t$1(t2, n) { +function t(t2, n) { return e(t2, 0, n); } function Friction$1(e2, t2) { @@ -3662,23 +3664,23 @@ Spring$1.prototype.setEnd = function(e2, n, i) { if (!i) { i = new Date().getTime(); } - if (e2 !== this._endPosition || !t$1(n, 0.1)) { + if (e2 !== this._endPosition || !t(n, 0.1)) { n = n || 0; var r = this._endPosition; if (this._solution) { - if (t$1(n, 0.1)) { + if (t(n, 0.1)) { n = this._solution.dx((i - this._startTime) / 1e3); } r = this._solution.x((i - this._startTime) / 1e3); - if (t$1(n, 0.1)) { + if (t(n, 0.1)) { n = 0; } - if (t$1(r, 0.1)) { + if (t(r, 0.1)) { r = 0; } r += this._endPosition; } - if (!(this._solution && t$1(r - e2, 0.1) && t$1(n, 0.1))) { + 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; @@ -3701,7 +3703,7 @@ Spring$1.prototype.done = function(n) { if (!n) { n = new Date().getTime(); } - return e(this.x(), this._endPosition, 0.1) && t$1(this.dx(), 0.1); + return e(this.x(), this._endPosition, 0.1) && t(this.dx(), 0.1); }; Spring$1.prototype.reconfigure = function(m, t2, c) { this._m = m; @@ -3772,7 +3774,7 @@ STD.prototype.reconfigure = function(e2, t2, n) { this._springY.reconfigure(e2, t2, n); this._springScale.reconfigure(e2, t2, n); }; -const props$k = { +const props$l = { direction: { type: String, default: "none" @@ -3826,9 +3828,9 @@ const props$k = { default: true } }; -var index$n = /* @__PURE__ */ defineBuiltInComponent({ +var index$o = /* @__PURE__ */ defineBuiltInComponent({ name: "MovableView", - props: props$k, + props: props$l, emits: ["change", "scale"], setup(props2, { slots, @@ -4200,7 +4202,7 @@ function useMovableViewState(props2, trigger, rootRef) { }; } const OPEN_TYPES = ["navigate", "redirect", "switchTab", "reLaunch", "navigateBack"]; -const props$j = { +const props$k = { hoverClass: { type: String, default: "navigator-hover" @@ -4237,12 +4239,12 @@ const props$j = { default: false } }; -var index$m = /* @__PURE__ */ defineBuiltInComponent({ +var index$n = /* @__PURE__ */ defineBuiltInComponent({ name: "Navigator", compatConfig: { MODE: 3 }, - props: props$j, + props: props$k, setup(props2, { slots }) { @@ -4297,7 +4299,7 @@ var index$m = /* @__PURE__ */ defineBuiltInComponent({ }; } }); -const props$i = { +const props$j = { value: { type: Array, default() { @@ -4344,7 +4346,7 @@ function useState$2(props2) { } var PickerView = /* @__PURE__ */ defineBuiltInComponent({ name: "PickerView", - props: props$i, + props: props$j, emits: ["change", "pickstart", "pickend", "update:value"], setup(props2, { slots, @@ -5189,7 +5191,7 @@ const VALUES = { backgroundColor: "#EBEBEB", activeMode: "backwards" }; -const props$h = { +const props$i = { percent: { type: [Number, String], default: 0, @@ -5236,9 +5238,9 @@ const props$h = { } } }; -var index$l = /* @__PURE__ */ defineBuiltInComponent({ +var index$m = /* @__PURE__ */ defineBuiltInComponent({ name: "Progress", - props: props$h, + props: props$i, setup(props2) { const state = useProgressState(props2); _activeAnimation(state, props2); @@ -5309,15 +5311,15 @@ function _activeAnimation(state, props2) { } } const uniRadioGroupKey = PolySymbol(process.env.NODE_ENV !== "production" ? "uniCheckGroup" : "ucg"); -const props$g = { +const props$h = { name: { type: String, default: "" } }; -var index$k = /* @__PURE__ */ defineBuiltInComponent({ +var index$l = /* @__PURE__ */ defineBuiltInComponent({ name: "RadioGroup", - props: props$g, + props: props$h, setup(props2, { emit: emit2, slots @@ -5393,7 +5395,7 @@ function useProvideRadioGroup(props2, trigger) { } return fields2; } -const props$f = { +const props$g = { checked: { type: [Boolean, String], default: false @@ -5415,9 +5417,9 @@ const props$f = { default: "" } }; -var index$j = /* @__PURE__ */ defineBuiltInComponent({ +var index$k = /* @__PURE__ */ defineBuiltInComponent({ name: "Radio", - props: props$f, + props: props$g, setup(props2, { slots }) { @@ -5701,7 +5703,7 @@ function parseNodes(nodes, parentNode) { }); return parentNode; } -const props$e = { +const props$f = { nodes: { type: [Array, String], default: function() { @@ -5709,12 +5711,12 @@ const props$e = { } } }; -var index$i = /* @__PURE__ */ defineBuiltInComponent({ +var index$j = /* @__PURE__ */ defineBuiltInComponent({ name: "RichText", compatConfig: { MODE: 3 }, - props: props$e, + props: props$f, setup(props2) { const rootRef = vue.ref(null); function _renderNodes(nodes) { @@ -5736,7 +5738,7 @@ var index$i = /* @__PURE__ */ defineBuiltInComponent({ } }); uniShared.passive(true); -const props$d = { +const props$e = { scrollX: { type: [Boolean, String], default: false @@ -5794,12 +5796,12 @@ const props$d = { default: false } }; -var index$h = /* @__PURE__ */ defineBuiltInComponent({ +var index$i = /* @__PURE__ */ defineBuiltInComponent({ name: "ScrollView", compatConfig: { MODE: 3 }, - props: props$d, + props: props$e, emits: ["scroll", "scrolltoupper", "scrolltolower", "refresherrefresh", "refresherrestore", "refresherpulling", "refresherabort"], setup(props2, { emit: emit2, @@ -6050,7 +6052,7 @@ function useScrollViewLoader(props2, state, scrollTopNumber, scrollLeftNumber, t } }); } -const props$c = { +const props$d = { name: { type: String, default: "" @@ -6104,9 +6106,9 @@ const props$c = { default: false } }; -var index$g = /* @__PURE__ */ defineBuiltInComponent({ +var index$h = /* @__PURE__ */ defineBuiltInComponent({ name: "Slider", - props: props$c, + props: props$d, emits: ["changing", "change"], setup(props2, { emit: emit2 @@ -6268,7 +6270,7 @@ var computeController = { return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m); } }; -const props$b = { +const props$c = { indicatorDots: { type: [Boolean, String], default: false @@ -6649,9 +6651,9 @@ function useLayout(props2, state, swiperContexts, slideFrameRef, emit2, trigger) onSwiperDotClick }; } -var index$f = /* @__PURE__ */ defineBuiltInComponent({ +var index$g = /* @__PURE__ */ defineBuiltInComponent({ name: "Swiper", - props: props$b, + props: props$c, emits: ["change", "transition", "animationfinish", "update:current", "update:currentItemId"], setup(props2, { slots, @@ -6746,15 +6748,15 @@ var index$f = /* @__PURE__ */ defineBuiltInComponent({ }; } }); -const props$a = { +const props$b = { itemId: { type: String, default: "" } }; -var index$e = /* @__PURE__ */ defineBuiltInComponent({ +var index$f = /* @__PURE__ */ defineBuiltInComponent({ name: "SwiperItem", - props: props$a, + props: props$b, setup(props2, { slots }) { @@ -6771,7 +6773,7 @@ var index$e = /* @__PURE__ */ defineBuiltInComponent({ }; } }); -const props$9 = { +const props$a = { name: { type: String, default: "" @@ -6797,9 +6799,9 @@ const props$9 = { default: "#007aff" } }; -var index$d = /* @__PURE__ */ defineBuiltInComponent({ +var index$e = /* @__PURE__ */ defineBuiltInComponent({ name: "Switch", - props: props$9, + props: props$a, emits: ["change"], setup(props2, { emit: emit2 @@ -6887,7 +6889,7 @@ function normalizeText(text, { } return text.replace(/ /g, SPACE_UNICODE.nbsp).replace(/ /g, SPACE_UNICODE.ensp).replace(/ /g, SPACE_UNICODE.emsp).replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&").replace(/"/g, '"').replace(/'/g, "'"); } -var index$c = /* @__PURE__ */ defineBuiltInComponent({ +var index$d = /* @__PURE__ */ defineBuiltInComponent({ name: "Text", props: { selectable: { @@ -6940,7 +6942,7 @@ var index$c = /* @__PURE__ */ defineBuiltInComponent({ }; } }); -const props$8 = /* @__PURE__ */ shared.extend({}, props$n, { +const props$9 = /* @__PURE__ */ shared.extend({}, props$o, { placeholderClass: { type: String, default: "input-placeholder" @@ -6954,9 +6956,9 @@ const props$8 = /* @__PURE__ */ shared.extend({}, props$n, { default: "" } }); -var index$b = /* @__PURE__ */ defineBuiltInComponent({ +var index$c = /* @__PURE__ */ defineBuiltInComponent({ name: "Textarea", - props: props$8, + props: props$9, emit: ["confirm", "linechange", ...emit], setup(props2, { emit: emit2 @@ -7074,7 +7076,7 @@ var index$b = /* @__PURE__ */ defineBuiltInComponent({ }; } }); -var index$a = /* @__PURE__ */ defineBuiltInComponent({ +var index$b = /* @__PURE__ */ defineBuiltInComponent({ name: "View", props: shared.extend({}, hoverProps), setup(props2, { @@ -7102,13 +7104,13 @@ function useSubscribe(callback, name, multiple) { } function useOn(name, callback) { } -let index$9 = 0; +let index$a = 0; function useContextInfo(_id) { const page = useCurrentPageId(); const instance = vue.getCurrentInstance(); const vm = instance.proxy; const type = vm.$options.name.toLowerCase(); - const id = _id || vm.id || `context${index$9++}`; + const id = _id || vm.id || `context${index$a++}`; return `${page}.${type}.${id}`; } function getContextInfo(el) { @@ -7477,7 +7479,7 @@ function initHistory() { return vueRouter.createMemoryHistory(base); } } -var index$8 = { +var index$9 = { install(app) { initApp$1(app); if (__UNI_FEATURE_PAGES__) { @@ -8037,7 +8039,7 @@ function useContext(play, pause, seek, sendDanmu, playbackRate, requestFullScree } }, id, true); } -const props$7 = { +const props$8 = { id: { type: String, default: "" @@ -8121,9 +8123,9 @@ const props$7 = { default: true } }; -var index$7 = /* @__PURE__ */ defineBuiltInComponent({ +var index$8 = /* @__PURE__ */ defineBuiltInComponent({ name: "Video", - props: props$7, + props: props$8, emits: ["fullscreenchange", "progress", "loadedmetadata", "waiting", "error", "play", "pause", "ended", "timeupdate"], setup(props2, { emit: emit2, @@ -8344,16 +8346,16 @@ const onWebInvokeAppService = ({name, arg}, pageId) => { } }; const Invoke = /* @__PURE__ */ uniShared.once(() => UniServiceJSBridge.on("onWebInvokeAppService", onWebInvokeAppService)); -const props$6 = { +const props$7 = { src: { type: String, default: "" } }; -var index$6 = /* @__PURE__ */ defineBuiltInComponent({ +var index$7 = /* @__PURE__ */ defineBuiltInComponent({ inheritAttrs: false, name: "WebView", - props: props$6, + props: props$7, setup(props2, { attrs }) { @@ -8404,7 +8406,7 @@ function useWebViewSize(rootRef, iframeRef) { }; return _resize; } -const props$5 = { +const props$6 = { id: { type: [Number, String], default: "" @@ -8468,7 +8470,7 @@ const props$5 = { }; var MapMarker = /* @__PURE__ */ defineSystemComponent({ name: "MapMarker", - props: props$5, + props: props$6, setup(props2) { const id = String(Number(props2.id) !== NaN ? props2.id : ""); const onMapReady = vue.inject("onMapReady"); @@ -8666,7 +8668,7 @@ var MapMarker = /* @__PURE__ */ defineSystemComponent({ }; } }); -const props$4 = { +const props$5 = { points: { type: Array, require: true @@ -8712,7 +8714,7 @@ const props$4 = { }; var MapPolyline = /* @__PURE__ */ defineSystemComponent({ name: "MapPolyline", - props: props$4, + props: props$5, setup(props2) { const onMapReady = vue.inject("onMapReady"); let polyline; @@ -8764,7 +8766,7 @@ var MapPolyline = /* @__PURE__ */ defineSystemComponent({ }; } }); -const props$3 = { +const props$4 = { latitude: { type: [Number, String], require: true @@ -8796,7 +8798,7 @@ const props$3 = { }; var MapCircle = /* @__PURE__ */ defineSystemComponent({ name: "MapCircle", - props: props$3, + props: props$4, setup(props2) { const onMapReady = vue.inject("onMapReady"); let circle; @@ -8839,7 +8841,7 @@ var MapCircle = /* @__PURE__ */ defineSystemComponent({ }; } }); -const props$2 = { +const props$3 = { id: { type: [Number, String], default: "" @@ -8859,7 +8861,7 @@ const props$2 = { }; var MapControl = /* @__PURE__ */ defineSystemComponent({ name: "MapControl", - props: props$2, + props: props$3, setup(props2) { const onMapReady = vue.inject("onMapReady"); let control; @@ -8936,7 +8938,7 @@ var MapLocation = /* @__PURE__ */ defineSystemComponent({ }; } }); -const props$1 = { +const props$2 = { id: { type: String, default: "" @@ -9146,9 +9148,9 @@ function useMap(props2, rootRef, emit2) { mapRef }; } -var index$5 = /* @__PURE__ */ defineBuiltInComponent({ +var index$6 = /* @__PURE__ */ defineBuiltInComponent({ name: "Map", - props: props$1, + props: props$2, emits: ["markertap", "labeltap", "callouttap", "controltap", "regionchange", "tap", "click", "updated", "update:scale", "update:latitude", "update:longitude"], setup(props2, { emit: emit2, @@ -9173,18 +9175,18 @@ var index$5 = /* @__PURE__ */ defineBuiltInComponent({ }; } }); -const props = { +const props$1 = { scrollTop: { type: [String, Number], default: 0 } }; -var index$4 = /* @__PURE__ */ defineBuiltInComponent({ +var index$5 = /* @__PURE__ */ defineBuiltInComponent({ name: "CoverView", compatConfig: { MODE: 3 }, - props, + props: props$1, setup(props2, { slots }) { @@ -9217,7 +9219,7 @@ var index$4 = /* @__PURE__ */ defineBuiltInComponent({ }; } }); -var index$3 = /* @__PURE__ */ defineBuiltInComponent({ +var index$4 = /* @__PURE__ */ defineBuiltInComponent({ name: "CoverImage", compatConfig: { MODE: 3 @@ -9257,14 +9259,6 @@ var index$3 = /* @__PURE__ */ defineBuiltInComponent({ }; } }); -function useKeyboard() { - const key = vue.ref(""); - const disable = vue.ref(false); - return { - key, - disable - }; -} function usePopupStyle(props2) { const popupWidth = vue.ref(0); const popupHeight = vue.ref(0); @@ -9331,14 +9325,24 @@ function usePopupStyle(props2) { popupStyle }; } -const {t, getLocale} = useI18n(); -function getDefaultStartValue() { - if (this.mode === mode.TIME) { +function useKeyboard() { + const key = vue.ref(""); + const disable = vue.ref(false); + return { + key, + disable + }; +} +function _isSlot(s) { + return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !vue.isVNode(s); +} +function getDefaultStartValue(props2) { + if (props2.mode === mode.TIME) { return "00:00"; } - if (this.mode === mode.DATE) { + if (props2.mode === mode.DATE) { const year = new Date().getFullYear() - 100; - switch (this.fields) { + switch (props2.fields) { case fields.YEAR: return year.toString(); case fields.MONTH: @@ -9349,13 +9353,13 @@ function getDefaultStartValue() { } return ""; } -function getDefaultEndValue() { - if (this.mode === mode.TIME) { +function getDefaultEndValue(props2) { + if (props2.mode === mode.TIME) { return "23:59"; } - if (this.mode === mode.DATE) { + if (props2.mode === mode.DATE) { const year = new Date().getFullYear() + 100; - switch (this.fields) { + switch (props2.fields) { case fields.YEAR: return year.toString(); case fields.MONTH: @@ -9366,6 +9370,36 @@ function getDefaultEndValue() { } return ""; } +function getDateValueArray(props2, state, valueStr, defaultValue) { + const splitStr = props2.mode === mode.DATE ? "-" : ":"; + const array = props2.mode === mode.DATE ? state.dateArray : state.timeArray; + let max; + if (props2.mode === mode.TIME) { + max = 2; + } else { + switch (props2.fields) { + case fields.YEAR: + max = 1; + break; + case fields.MONTH: + max = 2; + break; + default: + max = 3; + break; + } + } + const inputArray = String(valueStr).split(splitStr); + let value = []; + for (let i = 0; i < max; i++) { + const val = inputArray[i]; + value.push(array[i].indexOf(val)); + } + if (value.indexOf(-1) >= 0) { + value = defaultValue ? getDateValueArray(props2, state, defaultValue) : value.map(() => 0); + } + return value; +} const mode = { SELECTOR: "selector", MULTISELECTOR: "multiSelector", @@ -9381,564 +9415,627 @@ const selectorType = { PICKER: "picker", SELECT: "select" }; -var _sfc_main$1 = { - name: "Picker", - compatConfig: { - MODE: 3 +const props = { + name: { + type: String, + default: "" }, - components: {PickerView, PickerViewColumn}, - props: { - 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).includes(val); - } - }, - fields: { - type: String, - default: "" - }, - start: { - type: String, - default: (props2) => { - return getDefaultStartValue.call(props2); - } - }, - end: { - type: String, - default: (props2) => { - return getDefaultEndValue.call(props2); - } - }, - disabled: { - type: [Boolean, String], - default: false - }, - selectorType: { - type: String, - default: "" + range: { + type: Array, + default() { + return []; } }, - data() { - return { - valueSync: null, - visible: false, - contentVisible: false, - popover: null, - valueChangeSource: "", - timeArray: [], - dateArray: [], - valueArray: [], - oldValueArray: [], - isDesktop: false, - popupStyle: { - content: {}, - triangle: {} - } - }; + rangeKey: { + type: String, + default: "" }, - computed: { - rangeArray() { - var val = this.range; - switch (this.mode) { - case mode.SELECTOR: - return [val]; - case mode.MULTISELECTOR: - return val; - case mode.TIME: - return this.timeArray; - case mode.DATE: { - const dateArray = this.dateArray; - switch (this.fields) { - case fields.YEAR: - return [dateArray[0]]; - case fields.MONTH: - return [dateArray[0], dateArray[1]]; - default: - return [dateArray[0], dateArray[1], dateArray[2]]; - } - } - } - return []; - }, - startArray() { - return this._getDateValueArray(this.start, getDefaultStartValue.bind(this)()); - }, - endArray() { - return this._getDateValueArray(this.end, getDefaultEndValue.bind(this)()); - }, - selectorTypeComputed() { - const type = this.selectorType; - if (Object.values(selectorType).includes(type)) { - return type; - } - return String(navigator.vendor).indexOf("Apple") === 0 && navigator.maxTouchPoints > 0 ? selectorType.PICKER : selectorType.SELECT; - }, - system() { - if (this.mode === mode.DATE && !Object.values(fields).includes(this.fields) && this.isDesktop && /win|mac/i.test(navigator.platform)) { - if (navigator.vendor === "Google Inc.") { - return "chrome"; - } else if (/Firefox/.test(navigator.userAgent)) { - return "firefox"; - } - } - return ""; + value: { + type: [Number, String, Array], + default: 0 + }, + mode: { + type: String, + default: mode.SELECTOR, + validator(val) { + return Object.values(mode).includes(val); } }, - watch: { - visible(val) { - if (val) { - clearTimeout(this.__contentVisibleDelay); - this.contentVisible = val; - this._select(); - } else { - this.__contentVisibleDelay = setTimeout(() => { - this.contentVisible = val; - }, 300); - } - }, - value: { - deep: true, - handler() { - this._setValueSync(); - } - }, - mode() { - this._setValueSync(); - }, - range: { - deep: true, - handler() { - this._setValueSync(); - } - }, - valueSync: { - deep: true, - handler() { - this._setValueArray(); + fields: { + type: String, + default: "" + }, + start: { + type: String, + default: (props2) => { + return getDefaultStartValue(props2); + } + }, + end: { + type: String, + default: (props2) => { + return getDefaultEndValue(props2); + } + }, + disabled: { + type: [Boolean, String], + default: false + }, + selectorType: { + type: String, + default: "" + } +}; +var index$3 = /* @__PURE__ */ defineBuiltInComponent({ + name: "Picker", + compatConfig: { + MODE: 3 + }, + props, + emits: ["change", "cancel", "columnchange"], + setup(props2, { + emit: emit2, + slots + }) { + initI18nPickerMsgsOnce(); + const { + t: t2 + } = useI18n(); + const rootRef = vue.ref(null); + const pickerRef = vue.ref(null); + const selectRef = vue.ref(null); + const inputRef = vue.ref(null); + const { + state, + rangeArray + } = usePickerState(props2); + const trigger = useCustomEvent(rootRef, emit2); + const { + system, + selectorTypeComputed, + _show, + _l10nColumn, + _l10nItem, + _input, + _fixInputPosition, + _pickerViewChange, + _cancel, + _change, + _resetFormData, + _getFormData, + _createTime, + _createDate, + _setValueSync + } = usePickerMethods(props2, state, trigger, rootRef, pickerRef, selectRef, inputRef); + usePickerWatch(state, _cancel, _change); + usePickerForm(_resetFormData, _getFormData); + _createTime(); + _createDate(); + _setValueSync(); + const popup = usePopupStyle(props2); + vue.watchEffect(() => { + state.isDesktop = popup.isDesktop.value; + state.popupStyle = popup.popupStyle.value; + }); + return () => { + let _slot2; + const { + visible, + contentVisible, + valueArray, + popupStyle, + valueSync + } = state; + const { + rangeKey, + mode: mode2, + start, + end + } = props2; + const booleanAttrs = useBooleanAttr(props2, "disabled"); + return vue.createVNode("uni-picker", vue.mergeProps({ + "ref": rootRef + }, booleanAttrs, { + "onClick": withWebEvent(_show) + }), [vue.createVNode("div", { + "ref": pickerRef, + "class": ["uni-picker-container", `uni-${mode2}-${selectorTypeComputed.value}`], + "onWheel": onEventPrevent, + "onTouchmove": onEventPrevent + }, [vue.createVNode(vue.Transition, { + "name": "uni-fade" + }, { + default: () => [vue.withDirectives(vue.createVNode("div", { + "class": "uni-mask uni-picker-mask", + "onClick": withWebEvent(_cancel), + "onMousemove": _fixInputPosition + }, null, 40, ["onClick", "onMousemove"]), [[vue.vShow, visible]])] + }), !system.value ? vue.createVNode("div", { + "class": [{ + "uni-picker-toggle": visible + }, "uni-picker-custom"], + "style": popupStyle.content + }, [vue.createVNode("div", { + "class": "uni-picker-header", + "onClick": onEventStop + }, [vue.createVNode("div", { + "class": "uni-picker-action uni-picker-action-cancel", + "onClick": withWebEvent(_cancel) + }, [t2("uni.picker.cancel")], 8, ["onClick"]), vue.createVNode("div", { + "class": "uni-picker-action uni-picker-action-confirm", + "onClick": _change + }, [t2("uni.picker.done")], 8, ["onClick"])], 8, ["onClick"]), contentVisible ? vue.createVNode(PickerView, { + "value": _l10nColumn(valueArray), + "class": "uni-picker-content", + "onChange": _pickerViewChange + }, _isSlot(_slot2 = vue.renderList(_l10nColumn(rangeArray.value), (rangeItem, index0) => { + let _slot; + return vue.createVNode(PickerViewColumn, { + "key": index0 + }, _isSlot(_slot = vue.renderList(rangeItem, (item, index2) => vue.createVNode("div", { + "key": index2, + "class": "uni-picker-item" + }, [typeof item === "object" ? item[rangeKey] || "" : _l10nItem(item, index0)]))) ? _slot : { + default: () => [_slot], + _: 1 + }); + })) ? _slot2 : { + default: () => [_slot2], + _: 1 + }, 8, ["value", "onChange"]) : null, vue.createVNode("div", { + "ref": selectRef, + "class": "uni-picker-select", + "onWheel": onEventStop, + "onTouchmove": onEventStop + }, [vue.renderList(rangeArray.value[0], (item, index2) => vue.createVNode("div", { + "key": index2, + "class": ["uni-picker-item", { + selected: valueArray[0] === index2 + }], + "onClick": () => { + valueArray[0] = index2; + _change(); + } + }, [typeof item === "object" ? item[rangeKey] || "" : item], 10, ["onClick"]))], 40, ["onWheel", "onTouchmove"]), vue.createVNode("div", { + "style": popupStyle.triangle + }, null, 4)], 6) : null], 40, ["onWheel", "onTouchmove"]), vue.createVNode("div", null, [slots.default && slots.default()]), system.value ? vue.createVNode("div", { + "class": "uni-picker-system", + "onMousemove": withWebEvent(_fixInputPosition) + }, [vue.createVNode("input", { + "class": ["uni-picker-system_input", system.value], + "ref": inputRef, + "value": valueSync, + "type": mode2, + "tabindex": "-1", + "min": start, + "max": end, + "onChange": ($event) => { + _input($event); + onEventStop($event); + } + }, null, 42, ["value", "type", "min", "max", "onChange"])], 40, ["onMousemove"]) : null], 16, ["onClick"]); + }; + } +}); +function usePickerState(props2) { + const state = vue.reactive({ + valueSync: void 0, + visible: false, + contentVisible: false, + popover: null, + valueChangeSource: "", + timeArray: [], + dateArray: [], + valueArray: [], + oldValueArray: [], + isDesktop: false, + popupStyle: { + content: {}, + triangle: {} + } + }); + const rangeArray = vue.computed(() => { + let val = props2.range; + switch (props2.mode) { + case mode.SELECTOR: + return [val]; + case mode.MULTISELECTOR: + return val; + case mode.TIME: + return state.timeArray; + case mode.DATE: { + const dateArray = state.dateArray; + switch (props2.fields) { + case fields.YEAR: + return [dateArray[0]]; + case fields.MONTH: + return [dateArray[0], dateArray[1]]; + default: + return [dateArray[0], dateArray[1], dateArray[2]]; + } } - }, - valueArray: { - deep: true, - handler(val) { - if (this.mode === mode.TIME || this.mode === mode.DATE) { - const getValue = this.mode === mode.TIME ? this._getTimeValue : this._getDateValue; - const valueArray = this.valueArray; - const startArray = this.startArray; - const endArray = this.endArray; - if (this.mode === mode.DATE) { - const dateArray = this.dateArray; - const max = dateArray[2].length; - const day = Number(dateArray[2][valueArray[2]]) || 1; - const realDay = new Date(`${dateArray[0][valueArray[0]]}/${dateArray[1][valueArray[1]]}/${day}`).getDate(); - if (realDay < day) { - valueArray[2] -= realDay + max - day; - } + } + return []; + }); + return { + state, + rangeArray + }; +} +let __contentVisibleDelay; +function usePickerMethods(props2, state, trigger, rootRef, pickerRef, selectRef, inputRef) { + const selectorTypeComputed = vue.computed(() => { + const type = props2.selectorType; + if (Object.values(selectorType).includes(type)) { + return type; + } + return String(navigator.vendor).indexOf("Apple") === 0 && navigator.maxTouchPoints > 0 ? selectorType.PICKER : selectorType.SELECT; + }); + const system = vue.computed(() => { + return ""; + }); + const startArray = vue.computed(() => { + return getDateValueArray(props2, state, props2.start, getDefaultStartValue(props2)); + }); + const endArray = vue.computed(() => { + return getDateValueArray(props2, state, props2.end, getDefaultEndValue(props2)); + }); + function _show(event) { + if (props2.disabled) { + return; + } + state.valueChangeSource = ""; + let $picker = pickerRef.value; + let _currentTarget = event.currentTarget; + $picker.remove(); + (document.querySelector("uni-app") || document.body).appendChild($picker); + $picker.style.display = "block"; + const rect = _currentTarget.getBoundingClientRect(); + state.popover = { + top: rect.top, + left: rect.left, + width: rect.width, + height: rect.height + }; + setTimeout(() => { + state.visible = true; + }, 20); + } + function _getFormData() { + return { + value: state.valueSync, + key: props2.name + }; + } + function _resetFormData() { + switch (props2.mode) { + case mode.SELECTOR: + state.valueSync = 0; + break; + case mode.MULTISELECTOR: + state.valueSync = props2.value.map((val) => 0); + break; + case mode.DATE: + case mode.TIME: + state.valueSync = ""; + break; + } + } + function _createTime() { + let hours = []; + let minutes = []; + for (let i = 0; i < 24; i++) { + hours.push((i < 10 ? "0" : "") + i); + } + for (let i = 0; i < 60; i++) { + minutes.push((i < 10 ? "0" : "") + i); + } + state.timeArray.push(hours, minutes); + } + function _createDate() { + let years = []; + let year = new Date().getFullYear(); + for (let i = year - 150, end = year + 150; i <= end; i++) { + years.push(String(i)); + } + let months = []; + for (let i = 1; i <= 12; i++) { + months.push((i < 10 ? "0" : "") + i); + } + let days = []; + for (let i = 1; i <= 31; i++) { + days.push((i < 10 ? "0" : "") + i); + } + state.dateArray.push(years, months, days); + } + function _getTimeValue(val) { + return val[0] * 60 + val[1]; + } + function _getDateValue(val) { + const DAY = 31; + return val[0] * DAY * 12 + (val[1] || 0) * DAY + (val[2] || 0); + } + function _cloneArray(val1, val2) { + for (let i = 0; i < val1.length && i < val2.length; i++) { + val1[i] = val2[i]; + } + } + function _setValueSync() { + let val = props2.value; + switch (props2.mode) { + case mode.MULTISELECTOR: + { + if (!Array.isArray(val)) { + val = []; } - if (getValue(valueArray) < getValue(startArray)) { - this._cloneArray(valueArray, startArray); - } else if (getValue(valueArray) > getValue(endArray)) { - this._cloneArray(valueArray, endArray); + if (!Array.isArray(state.valueSync)) { + state.valueSync = []; } - } - val.forEach((value, column) => { - if (value !== this.oldValueArray[column]) { - this.oldValueArray[column] = value; - if (this.mode === mode.MULTISELECTOR) { - this.$trigger("columnchange", {}, { - column, - value - }); - } + const length = state.valueSync.length = Math.max(val.length, props2.range.length); + for (let index2 = 0; index2 < length; index2++) { + const val0 = Number(val[index2]); + const val1 = Number(state.valueSync[index2]); + const val2 = isNaN(val0) ? isNaN(val1) ? 0 : val1 : val0; + const maxVal = props2.range[index2] ? props2.range[index2].length - 1 : 0; + state.valueSync.splice(index2, 1, val2 < 0 || val2 > maxVal ? 0 : val2); } - }); + } + break; + case mode.TIME: + case mode.DATE: + state.valueSync = String(val); + break; + default: { + const valueSync = Number(val); + state.valueSync = valueSync < 0 ? 0 : valueSync; + break; } } - }, - created() { - initI18nPickerMsgsOnce(); - this._createTime(); - this._createDate(); - this._setValueSync(); - usePickerWatch.call(this); - usePickerForm.call(this); - const popup = usePopupStyle(this); - this.isDesktop = popup.isDesktop; - this.popupStyle = popup.popupStyle; - }, - mounted() { - this.$trigger = useCustomEvent({value: this.$refs.root}, this.$emit); - }, - beforeUnmount() { - this.$refs.picker.remove(); - }, - methods: { - withWebEvent, - $$t: t, - _show(event) { - if (this.disabled) { + } + function _setValueArray() { + let val = state.valueSync; + let valueArray; + switch (props2.mode) { + case mode.MULTISELECTOR: + valueArray = [...val]; + break; + case mode.TIME: + valueArray = getDateValueArray(props2, state, val, uniShared.formatDateTime({ + mode: mode.TIME + })); + break; + case mode.DATE: + valueArray = getDateValueArray(props2, state, val, uniShared.formatDateTime({ + mode: mode.DATE + })); + break; + default: + valueArray = [val]; + break; + } + state.oldValueArray = [...valueArray]; + state.valueArray = [...valueArray]; + } + function _getValue() { + let val = state.valueArray; + switch (props2.mode) { + case mode.SELECTOR: + return val[0]; + case mode.MULTISELECTOR: + return val.map((val2) => val2); + case mode.TIME: + return state.valueArray.map((val2, i) => state.timeArray[i][val2]).join(":"); + case mode.DATE: + return state.valueArray.map((val2, i) => state.dateArray[i][val2]).join("-"); + } + } + function _change() { + _close(); + state.valueChangeSource = "click"; + const value = _getValue(); + state.valueSync = Array.isArray(value) ? value.map((val) => val) : value; + trigger("change", {}, { + value + }); + } + function _cancel($event) { + if (system.value === "firefox" && $event) { + const { + top, + left, + width, + height + } = state.popover; + const { + pageX, + pageY + } = $event; + if (pageX > left && pageX < left + width && pageY > top && pageY < top + height) { return; } - this.valueChangeSource = ""; - var $picker = this.$refs.picker; + } + _close(); + trigger("cancel", {}, {}); + } + function _close() { + state.visible = false; + setTimeout(() => { + let $picker = pickerRef.value; $picker.remove(); - (document.querySelector("uni-app") || document.body).appendChild($picker); - $picker.style.display = "block"; - const rect = event.currentTarget.getBoundingClientRect(); - this.popover = { - top: rect.top, - left: rect.left, - width: rect.width, - height: rect.height - }; - setTimeout(() => { - this.visible = true; - }, 20); - }, - _getFormData() { - return { - value: this.valueSync, - key: this.name - }; - }, - _resetFormData() { - switch (this.mode) { - case mode.SELECTOR: - this.valueSync = 0; - break; - case mode.MULTISELECTOR: - this.valueSync = this.value.map((val) => 0); - break; - case mode.DATE: - case mode.TIME: - this.valueSync = ""; - break; - } - }, - _createTime() { - var hours = []; - var minutes = []; - hours.splice(0, hours.length); - for (let i = 0; i < 24; i++) { - hours.push((i < 10 ? "0" : "") + i); - } - minutes.splice(0, minutes.length); - for (let i = 0; i < 60; i++) { - minutes.push((i < 10 ? "0" : "") + i); - } - this.timeArray.push(hours, minutes); - }, - _createDate() { - var years = []; - var year = new Date().getFullYear(); - for (let i = year - 150, end = year + 150; i <= end; i++) { - years.push(String(i)); - } - var months = []; - for (let i = 1; i <= 12; i++) { - months.push((i < 10 ? "0" : "") + i); - } - var days = []; - for (let i = 1; i <= 31; i++) { - days.push((i < 10 ? "0" : "") + i); - } - this.dateArray.push(years, months, days); - }, - _getTimeValue(val) { - return val[0] * 60 + val[1]; - }, - _getDateValue(val) { - const DAY = 31; - return val[0] * DAY * 12 + (val[1] || 0) * DAY + (val[2] || 0); - }, - _cloneArray(val1, val2) { - for (let i = 0; i < val1.length && i < val2.length; i++) { - val1[i] = val2[i]; - } - }, - _setValueSync() { - let val = this.value; - switch (this.mode) { - case mode.MULTISELECTOR: - { - if (!Array.isArray(val)) { - val = []; - } - if (!Array.isArray(this.valueSync)) { - this.valueSync = []; - } - const length = this.valueSync.length = Math.max(val.length, this.range.length); - for (let index2 = 0; index2 < length; index2++) { - const val0 = Number(val[index2]); - const val1 = Number(this.valueSync[index2]); - const val2 = isNaN(val0) ? isNaN(val1) ? 0 : val1 : val0; - const maxVal = this.range[index2] ? this.range[index2].length - 1 : 0; - this.valueSync.splice(index2, 1, val2 < 0 || val2 > maxVal ? 0 : val2); + rootRef.value.prepend($picker); + $picker.style.display = "none"; + }, 260); + } + function _select() { + if (props2.mode === mode.SELECTOR && selectorTypeComputed.value === selectorType.SELECT) { + selectRef.value.scrollTop = state.valueArray[0] * 34; + } + } + function _input($event) { + const EventTarget = $event.target; + state.valueSync = EventTarget.value; + vue.nextTick(() => { + _change(); + }); + } + function _fixInputPosition($event) { + if (system.value === "chrome") { + const rect = rootRef.value.getBoundingClientRect(); + const fontSize = 32; + inputRef.value.style.left = `${$event.clientX - rect.left - fontSize * 1.5}px`; + inputRef.value.style.top = `${$event.clientY - rect.top - fontSize * 0.5}px`; + } + } + function _pickerViewChange(event) { + state.valueArray = _l10nColumn(event.detail.value, true); + } + function _l10nColumn(array, normalize) { + const { + getLocale + } = useI18n(); + if (props2.mode === mode.DATE) { + const locale = getLocale(); + if (!locale.startsWith("zh")) { + switch (props2.fields) { + case fields.YEAR: + return array; + case fields.MONTH: + return [array[1], array[0]]; + default: + switch (locale) { + case "es": + case "fr": + return [array[2], array[1], array[0]]; + default: + return normalize ? [array[2], array[0], array[1]] : [array[1], array[2], array[0]]; } - } - break; - case mode.TIME: - case mode.DATE: - this.valueSync = String(val); - break; - default: { - const valueSync = Number(val); - this.valueSync = valueSync < 0 ? 0 : valueSync; - break; } } - }, - _setValueArray() { - var val = this.valueSync; - var valueArray; - switch (this.mode) { - case mode.MULTISELECTOR: - valueArray = [...val]; - break; - case mode.TIME: - valueArray = this._getDateValueArray(val, uniShared.formatDateTime({ - mode: mode.TIME - })); - break; - case mode.DATE: - valueArray = this._getDateValueArray(val, uniShared.formatDateTime({ - mode: mode.DATE - })); - break; - default: - valueArray = [val]; - break; - } - this.oldValueArray = [...valueArray]; - this.valueArray = [...valueArray]; - }, - _getValue() { - var val = this.valueArray; - switch (this.mode) { - case mode.SELECTOR: - return val[0]; - case mode.MULTISELECTOR: - return val.map((val2) => val2); - case mode.TIME: - return this.valueArray.map((val2, i) => this.timeArray[i][val2]).join(":"); - case mode.DATE: - return this.valueArray.map((val2, i) => this.dateArray[i][val2]).join("-"); - } - }, - _getDateValueArray(valueStr, defaultValue) { - const splitStr = this.mode === mode.DATE ? "-" : ":"; - const array = this.mode === mode.DATE ? this.dateArray : this.timeArray; - let max; - if (this.mode === mode.TIME) { - max = 2; - } else { - switch (this.fields) { - case fields.YEAR: - max = 1; + } + return array; + } + function _l10nItem(item, index2) { + const { + getLocale + } = useI18n(); + if (props2.mode === mode.DATE) { + const locale = getLocale(); + if (locale.startsWith("zh")) { + const array = ["\u5E74", "\u6708", "\u65E5"]; + return item + array[index2]; + } else if (props2.fields !== fields.YEAR && index2 === (props2.fields !== fields.MONTH && (locale === "es" || locale === "fr") ? 1 : 0)) { + let array; + switch (locale) { + case "es": + array = ["enero", "febrero", "marzo", "abril", "mayo", "junio", "\u200B\u200Bjulio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"]; break; - case fields.MONTH: - max = 2; + case "fr": + array = ["janvier", "f\xE9vrier", "mars", "avril", "mai", "juin", "juillet", "ao\xFBt", "septembre", "octobre", "novembre", "d\xE9cembre"]; break; default: - max = 3; + array = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; break; } + return array[Number(item) - 1]; } - const inputArray = String(valueStr).split(splitStr); - let value = []; - for (let i = 0; i < max; i++) { - const val = inputArray[i]; - value.push(array[i].indexOf(val)); - } - if (value.indexOf(-1) >= 0) { - value = defaultValue ? this._getDateValueArray(defaultValue) : value.map(() => 0); - } - return value; - }, - _change() { - this._close(); - this.valueChangeSource = "click"; - const value = this._getValue(); - this.valueSync = Array.isArray(value) ? value.map((val) => val) : value; - this.$trigger("change", {}, { - value - }); - }, - _cancel($event) { - if (this.system === "firefox") { - const {top, left, width, height} = this.popover; - const {pageX, pageY} = $event; - if (pageX > left && pageX < left + width && pageY > top && pageY < top + height) { - return; + } + return item; + } + vue.watch(() => state.visible, (val) => { + if (val) { + clearTimeout(__contentVisibleDelay); + state.contentVisible = val; + _select(); + } else { + __contentVisibleDelay = setTimeout(() => { + state.contentVisible = val; + }, 300); + } + }); + vue.watch([() => props2.mode, () => props2.value, () => props2.range], _setValueSync, { + deep: true + }); + vue.watch(() => state.valueSync, _setValueArray, { + deep: true + }); + vue.watch(() => state.valueArray, (val) => { + if (props2.mode === mode.TIME || props2.mode === mode.DATE) { + const getValue = props2.mode === mode.TIME ? _getTimeValue : _getDateValue; + const valueArray = state.valueArray; + const _startArray = startArray.value; + const _endArray = endArray.value; + if (props2.mode === mode.DATE) { + const dateArray = state.dateArray; + const max = dateArray[2].length; + const day = Number(dateArray[2][valueArray[2]]) || 1; + const realDay = new Date(`${dateArray[0][valueArray[0]]}/${dateArray[1][valueArray[1]]}/${day}`).getDate(); + if (realDay < day) { + valueArray[2] -= realDay + max - day; } } - this._close(); - this.$trigger("cancel", {}, {}); - }, - _close() { - this.visible = false; - setTimeout(() => { - var $picker = this.$refs.picker; - $picker.remove(); - this.$el.prepend($picker); - $picker.style.display = "none"; - }, 260); - }, - _select() { - if (this.mode === mode.SELECTOR && this.selectorTypeComputed === selectorType.SELECT) { - this.$refs.select.scrollTop = this.valueArray[0] * 34; + if (getValue(valueArray) < getValue(_startArray)) { + _cloneArray(valueArray, _startArray); + } else if (getValue(valueArray) > getValue(_endArray)) { + _cloneArray(valueArray, _endArray); } - }, - _input($event) { - this.valueSync = $event.target.value; - this.$nextTick(() => { - this._change(); - }); - }, - _fixInputPosition($event) { - if (this.system === "chrome") { - const rect = this.$el.getBoundingClientRect(); - const style = this.$refs.input.style; - const fontSize = 32; - style.left = `${$event.clientX - rect.left - fontSize * 1.5}px`; - style.top = `${$event.clientY - rect.top - fontSize * 0.5}px`; - } - }, - _pickerViewChange(event) { - this.valueArray = this._l10nColumn(event.detail.value, true); - }, - _l10nColumn(array, normalize) { - if (this.mode === mode.DATE) { - const locale = getLocale(); - if (!locale.startsWith("zh")) { - switch (this.fields) { - case fields.YEAR: - return array; - case fields.MONTH: - return [array[1], array[0]]; - default: - switch (locale) { - case "es": - case "fr": - return [array[2], array[1], array[0]]; - default: - return normalize ? [array[2], array[0], array[1]] : [array[1], array[2], array[0]]; - } - } - } - } - return array; - }, - _l10nItem(item, index2) { - if (this.mode === mode.DATE) { - const locale = getLocale(); - if (locale.startsWith("zh")) { - const array = ["\u5E74", "\u6708", "\u65E5"]; - return item + array[index2]; - } else if (this.fields !== fields.YEAR && index2 === (this.fields !== fields.MONTH && (locale === "es" || locale === "fr") ? 1 : 0)) { - let array; - switch (locale) { - case "es": - array = [ - "enero", - "febrero", - "marzo", - "abril", - "mayo", - "junio", - "\u200B\u200Bjulio", - "agosto", - "septiembre", - "octubre", - "noviembre", - "diciembre" - ]; - break; - case "fr": - array = [ - "janvier", - "f\xE9vrier", - "mars", - "avril", - "mai", - "juin", - "juillet", - "ao\xFBt", - "septembre", - "octobre", - "novembre", - "d\xE9cembre" - ]; - break; - default: - array = [ - "January", - "February", - "March", - "April", - "May", - "June", - "July", - "August", - "September", - "October", - "November", - "December" - ]; - break; - } - return array[Number(item) - 1]; + } + val.forEach((value, column) => { + if (value !== state.oldValueArray[column]) { + state.oldValueArray[column] = value; + if (props2.mode === mode.MULTISELECTOR) { + trigger("columnchange", {}, { + column, + value + }); } } - return item; - } - }, - setup(props2) { - const booleanAttrs = useBooleanAttr(props2, "disabled"); - return { - booleanAttrs - }; - } -}; -function usePickerWatch() { - const {key, disable} = useKeyboard(); - vue.watch(() => this.visible, (value) => disable.value = !value); + }); + }); + return { + selectorTypeComputed, + system, + _show, + _cancel, + _change, + _l10nColumn, + _l10nItem, + _input, + _resetFormData, + _getFormData, + _createTime, + _createDate, + _setValueSync, + _fixInputPosition, + _pickerViewChange + }; +} +function usePickerWatch(state, _cancel, _change) { + const { + key, + disable + } = useKeyboard(); vue.watchEffect(() => { - const {value} = key; + disable.value = !state.visible; + }); + vue.watch(key, (value) => { if (value === "esc") { - this._cancel && this._cancel(); + _cancel(); } else if (value === "enter") { - this._change && this._change(); + _change(); } }); } -function usePickerForm() { +function usePickerForm(_resetFormData, _getFormData) { const uniForm = vue.inject(uniFormKey, false); - if (!!uniForm) { + if (uniForm) { const field = { - reset: this._resetFormData, + reset: _resetFormData, submit: () => { const data = ["", null]; - const {key, value} = this._getFormData(); + const { + key, + value + } = _getFormData(); if (key !== "") { data[0] = key; data[1] = value; @@ -9949,120 +10046,6 @@ function usePickerForm() { uniForm.addField(field); } } -function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) { - const _component_PickerViewColumn = vue.resolveComponent("PickerViewColumn"); - const _component_PickerView = vue.resolveComponent("PickerView"); - return vue.openBlock(), vue.createBlock("uni-picker", vue.mergeProps({ref: "root"}, $setup.booleanAttrs, { - onClick: _cache[13] || (_cache[13] = (() => $options.withWebEvent($options._show))()) - }), [ - vue.createVNode("div", { - ref: "picker", - class: ["uni-picker-container", `uni-${$props.mode}-${$options.selectorTypeComputed}`], - onWheel: _cache[9] || (_cache[9] = vue.withModifiers(() => { - }, ["prevent"])), - onTouchmove: _cache[10] || (_cache[10] = vue.withModifiers(() => { - }, ["prevent"])) - }, [ - vue.createVNode(vue.Transition, {name: "uni-fade"}, { - default: vue.withCtx(() => [ - vue.withDirectives(vue.createVNode("div", { - class: "uni-mask uni-picker-mask", - onClick: _cache[1] || (_cache[1] = (() => $options.withWebEvent($options._cancel))()), - onMousemove: _cache[2] || (_cache[2] = (...args) => $options._fixInputPosition && $options._fixInputPosition(...args)) - }, null, 544), [ - [vue.vShow, $data.visible] - ]) - ]), - _: 1 - }), - !$options.system ? (vue.openBlock(), vue.createBlock("div", { - key: 0, - class: [{"uni-picker-toggle": $data.visible}, "uni-picker-custom"], - style: $data.popupStyle.content - }, [ - vue.createVNode("div", { - class: "uni-picker-header", - onClick: _cache[5] || (_cache[5] = vue.withModifiers(() => { - }, ["stop"])) - }, [ - vue.createVNode("div", { - class: "uni-picker-action uni-picker-action-cancel", - onClick: _cache[3] || (_cache[3] = (() => $options.withWebEvent($options._cancel))()) - }, vue.toDisplayString($options.$$t("uni.picker.cancel")), 1), - vue.createVNode("div", { - class: "uni-picker-action uni-picker-action-confirm", - onClick: _cache[4] || (_cache[4] = (...args) => $options._change && $options._change(...args)) - }, vue.toDisplayString($options.$$t("uni.picker.done")), 1) - ]), - $data.contentVisible ? (vue.openBlock(), vue.createBlock(_component_PickerView, { - key: 0, - value: $options._l10nColumn($data.valueArray), - class: "uni-picker-content", - onChange: _cache[6] || (_cache[6] = (() => $options.withWebEvent($options._pickerViewChange))()) - }, { - default: vue.withCtx(() => [ - (vue.openBlock(true), vue.createBlock(vue.Fragment, null, vue.renderList($options._l10nColumn($options.rangeArray), (rangeItem, index0) => { - return vue.openBlock(), vue.createBlock(_component_PickerViewColumn, {key: index0}, { - default: vue.withCtx(() => [ - (vue.openBlock(true), vue.createBlock(vue.Fragment, null, vue.renderList(rangeItem, (item, index2) => { - return vue.openBlock(), vue.createBlock("div", { - key: index2, - class: "uni-picker-item" - }, vue.toDisplayString(typeof item === "object" ? item[$props.rangeKey] || "" : $options._l10nItem(item, index0)), 1); - }), 128)) - ]), - _: 2 - }, 1024); - }), 128)) - ]), - _: 1 - }, 8, ["value"])) : vue.createCommentVNode("", true), - vue.createVNode("div", { - ref: "select", - class: "uni-picker-select", - onWheel: _cache[7] || (_cache[7] = vue.withModifiers(() => { - }, ["stop"])), - onTouchmove: _cache[8] || (_cache[8] = vue.withModifiers(() => { - }, ["stop"])) - }, [ - (vue.openBlock(true), vue.createBlock(vue.Fragment, null, vue.renderList($options.rangeArray[0], (item, index2) => { - return vue.openBlock(), vue.createBlock("div", { - key: index2, - class: ["uni-picker-item", {selected: $data.valueArray[0] === index2}], - onClick: ($event) => { - $data.valueArray[0] = index2; - $options._change(); - } - }, vue.toDisplayString(typeof item === "object" ? item[$props.rangeKey] || "" : item), 11, ["onClick"]); - }), 128)) - ], 544), - vue.createVNode("div", { - style: $data.popupStyle.triangle - }, null, 4) - ], 6)) : vue.createCommentVNode("", true) - ], 34), - vue.createVNode("div", null, [ - vue.renderSlot(_ctx.$slots, "default") - ]), - $options.system ? (vue.openBlock(), vue.createBlock("div", { - key: 0, - class: "uni-picker-system", - onMousemove: _cache[12] || (_cache[12] = (() => $options.withWebEvent($options._fixInputPosition))()) - }, [ - vue.createVNode("input", { - ref: "input", - value: $data.valueSync, - type: $props.mode, - tabindex: "-1", - min: $props.start, - max: $props.end, - class: [$options.system, $data.popupStyle.dock], - onChange: _cache[11] || (_cache[11] = vue.withModifiers((() => $options.withWebEvent($options._input))(), ["stop"])) - }, null, 42, ["value", "type", "min", "max"]) - ], 32)) : vue.createCommentVNode("", true) - ], 16); -} -_sfc_main$1.render = _sfc_render$1; const UniViewJSBridge$1 = /* @__PURE__ */ shared.extend(ViewJSBridge, { publishHandler(event, args, pageId) { UniServiceJSBridge.subscribeHandler(event, args, pageId); @@ -11377,48 +11360,48 @@ var index = /* @__PURE__ */ defineSystemComponent({ }); exports.AsyncErrorComponent = index$1; exports.AsyncLoadingComponent = index; -exports.Audio = _sfc_main$2; -exports.Button = index$v; -exports.Canvas = index$u; -exports.Checkbox = index$s; -exports.CheckboxGroup = index$t; -exports.CoverImage = index$3; -exports.CoverView = index$4; -exports.Editor = index$r; -exports.Form = index$x; +exports.Audio = _sfc_main$1; +exports.Button = index$w; +exports.Canvas = index$v; +exports.Checkbox = index$t; +exports.CheckboxGroup = index$u; +exports.CoverImage = index$4; +exports.CoverView = index$5; +exports.Editor = index$s; +exports.Form = index$y; exports.Friction = Friction; -exports.Icon = index$q; -exports.Image = index$p; +exports.Icon = index$r; +exports.Image = index$q; exports.Input = Input; -exports.Label = index$w; +exports.Label = index$x; exports.LayoutComponent = LayoutComponent; -exports.Map = index$5; -exports.MovableArea = index$o; -exports.MovableView = index$n; -exports.Navigator = index$m; +exports.Map = index$6; +exports.MovableArea = index$p; +exports.MovableView = index$o; +exports.Navigator = index$n; exports.PageComponent = index$2; -exports.Picker = _sfc_main$1; +exports.Picker = index$3; exports.PickerView = PickerView; exports.PickerViewColumn = PickerViewColumn; -exports.Progress = index$l; -exports.Radio = index$j; -exports.RadioGroup = index$k; +exports.Progress = index$m; +exports.Radio = index$k; +exports.RadioGroup = index$l; exports.ResizeSensor = ResizeSensor; -exports.RichText = index$i; -exports.ScrollView = index$h; +exports.RichText = index$j; +exports.ScrollView = index$i; exports.Scroller = Scroller; -exports.Slider = index$g; +exports.Slider = index$h; exports.Spring = Spring; -exports.Swiper = index$f; -exports.SwiperItem = index$e; -exports.Switch = index$d; -exports.Text = index$c; -exports.Textarea = index$b; +exports.Swiper = index$g; +exports.SwiperItem = index$f; +exports.Switch = index$e; +exports.Text = index$d; +exports.Textarea = index$c; exports.UniServiceJSBridge = UniServiceJSBridge$1; exports.UniViewJSBridge = UniViewJSBridge$1; -exports.Video = index$7; -exports.View = index$a; -exports.WebView = index$6; +exports.Video = index$8; +exports.View = index$b; +exports.WebView = index$7; exports.clearStorage = clearStorage; exports.clearStorageSync = clearStorageSync; exports.defineBuiltInComponent = defineBuiltInComponent; @@ -11434,7 +11417,7 @@ exports.getStorageInfoSync = getStorageInfoSync; exports.getStorageSync = getStorageSync; exports.getSystemInfoSync = getSystemInfoSync; exports.initScrollBounce = initScrollBounce; -exports.plugin = index$8; +exports.plugin = index$9; exports.removeStorage = removeStorage; exports.removeStorageSync = removeStorageSync; exports.request = request; diff --git a/packages/uni-h5/dist/uni-h5.es.js b/packages/uni-h5/dist/uni-h5.es.js index 8bde7f892..80f14a076 100644 --- a/packages/uni-h5/dist/uni-h5.es.js +++ b/packages/uni-h5/dist/uni-h5.es.js @@ -1,5 +1,5 @@ import {isFunction, extend, hyphenate, isPlainObject, isString, isArray, hasOwn, isObject, capitalize, toRawType, makeMap as makeMap$1, isPromise, invokeArrayFns as invokeArrayFns$1} from "@vue/shared"; -import {injectHook, withModifiers, createVNode, getCurrentInstance, inject, provide, reactive, openBlock, createBlock, mergeProps, toDisplayString, defineComponent, ref, computed, watch, onUnmounted, onBeforeUnmount, onActivated, onMounted, nextTick, onBeforeMount, withDirectives, vShow, shallowRef, watchEffect, isVNode, Fragment, markRaw, createTextVNode, onBeforeActivate, onBeforeDeactivate, renderList, onDeactivated, Teleport, createApp, Transition, withCtx, KeepAlive, resolveDynamicComponent, resolveComponent, createCommentVNode, renderSlot, useSSRContext} from "vue"; +import {injectHook, withModifiers, createVNode, getCurrentInstance, inject, provide, reactive, openBlock, createBlock, mergeProps, toDisplayString, defineComponent, ref, computed, watch, onUnmounted, onBeforeUnmount, onActivated, onMounted, nextTick, onBeforeMount, withDirectives, vShow, shallowRef, watchEffect, isVNode, Fragment, markRaw, createTextVNode, onBeforeActivate, onBeforeDeactivate, renderList, onDeactivated, Teleport, createApp, Transition, withCtx, KeepAlive, resolveDynamicComponent, useSSRContext, renderSlot} from "vue"; import {once, passive, normalizeTarget, isBuiltInComponent, initCustomDataset, invokeArrayFns, NAVBAR_HEIGHT, parseQuery, PRIMARY_COLOR, debounce, getCustomDataset, callOptions, removeLeadingSlash, getLen, ON_REACH_BOTTOM_DISTANCE, decodedQuery, updateElementStyle, addFont, scrollTo, RESPONSIVE_MIN_WIDTH, formatDateTime} from "@dcloudio/uni-shared"; import {initVueI18n, LOCALE_EN, LOCALE_ES, LOCALE_FR, LOCALE_ZH_HANS, LOCALE_ZH_HANT} from "@dcloudio/uni-i18n"; import {useRoute, createRouter, createWebHistory, createWebHashHistory, useRouter, isNavigationFailure, RouterView} from "vue-router"; @@ -485,7 +485,7 @@ var safeAreaInsets = { onChange, offChange }; -var out = safeAreaInsets; +var D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out = safeAreaInsets; const onEventPrevent = /* @__PURE__ */ withModifiers(() => { }, ["prevent"]); const onEventStop = /* @__PURE__ */ withModifiers(() => { @@ -497,10 +497,10 @@ function getWindowOffset() { const left = parseInt(style.getPropertyValue("--window-left")); const right = parseInt(style.getPropertyValue("--window-right")); return { - top: top ? top + out.top : 0, - bottom: bottom ? bottom + out.bottom : 0, - left: left ? left + out.left : 0, - right: right ? right + out.right : 0 + top: top ? top + D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top : 0, + bottom: bottom ? bottom + D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.bottom : 0, + left: left ? left + D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.left : 0, + right: right ? right + D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.right : 0 }; } function updateCssVar(cssVars) { @@ -1220,7 +1220,7 @@ function normalizePageMeta(pageMeta) { let offset = rpx2px(refreshOptions.offset); const {type} = navigationBar; if (type !== "transparent" && type !== "none") { - offset += NAVBAR_HEIGHT + out.top; + offset += NAVBAR_HEIGHT + D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top; } refreshOptions.offset = offset; refreshOptions.height = rpx2px(refreshOptions.height); @@ -1881,7 +1881,7 @@ function throttle(fn, wait) { }; return newFn; } -const _sfc_main$2 = { +const _sfc_main$1 = { name: "Audio", mixins: [subscriber], props: { @@ -2006,7 +2006,7 @@ const _hoisted_3$1 = {class: "uni-audio-time"}; const _hoisted_4$1 = {class: "uni-audio-info"}; const _hoisted_5 = {class: "uni-audio-name"}; const _hoisted_6 = {class: "uni-audio-author"}; -function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) { +function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) { return openBlock(), createBlock("uni-audio", mergeProps({ id: $props.id, controls: !!$props.controls @@ -2036,7 +2036,7 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) { ]) ], 16, ["id", "controls"]); } -_sfc_main$2.render = _sfc_render$2; +_sfc_main$1.render = _sfc_render$1; function converPx(value) { if (/^-?\d+[ur]px$/i.test(value)) { return value.replace(/(^-?\d+)[ur]px$/i, (text2, num) => { @@ -2268,7 +2268,7 @@ function normalizeCustomEvent(name, domEvt, el, detail) { }; } const uniFormKey = PolySymbol(process.env.NODE_ENV !== "production" ? "uniForm" : "uf"); -var index$t = /* @__PURE__ */ defineBuiltInComponent({ +var index$u = /* @__PURE__ */ defineBuiltInComponent({ name: "Form", setup(_props, { slots, @@ -2308,15 +2308,15 @@ function provideForm(emit2) { return fields2; } const uniLabelKey = PolySymbol(process.env.NODE_ENV !== "production" ? "uniLabel" : "ul"); -const props$B = { +const props$C = { for: { type: String, default: "" } }; -var index$s = /* @__PURE__ */ defineBuiltInComponent({ +var index$t = /* @__PURE__ */ defineBuiltInComponent({ name: "Label", - props: props$B, + props: props$C, setup(props2, { slots }) { @@ -2412,7 +2412,7 @@ function _removeListeners(id2, listeners, watch2) { } }); } -var index$r = /* @__PURE__ */ defineBuiltInComponent({ +var index$s = /* @__PURE__ */ defineBuiltInComponent({ name: "Button", props: { id: { @@ -2738,7 +2738,7 @@ function getTempCanvas(width = 0, height = 0) { tempCanvas.height = height; return tempCanvas; } -const props$A = { +const props$B = { canvasId: { type: String, default: "" @@ -2748,13 +2748,13 @@ const props$A = { default: false } }; -var index$q = /* @__PURE__ */ defineBuiltInComponent({ +var index$r = /* @__PURE__ */ defineBuiltInComponent({ inheritAttrs: false, name: "Canvas", compatConfig: { MODE: 3 }, - props: props$A, + props: props$B, computed: { id() { return this.canvasId; @@ -3233,15 +3233,15 @@ function useMethods(canvasRef, actionsWaiting) { }); } const uniCheckGroupKey = PolySymbol(process.env.NODE_ENV !== "production" ? "uniCheckGroup" : "ucg"); -const props$z = { +const props$A = { name: { type: String, default: "" } }; -var index$p = /* @__PURE__ */ defineBuiltInComponent({ +var index$q = /* @__PURE__ */ defineBuiltInComponent({ name: "CheckboxGroup", - props: props$z, + props: props$A, emits: ["change"], setup(props2, { emit: emit2, @@ -3293,7 +3293,7 @@ function useProvideCheckGroup(props2, trigger) { } return getFieldsValue; } -const props$y = { +const props$z = { checked: { type: [Boolean, String], default: false @@ -3315,9 +3315,9 @@ const props$y = { default: "" } }; -var index$o = /* @__PURE__ */ defineBuiltInComponent({ +var index$p = /* @__PURE__ */ defineBuiltInComponent({ name: "Checkbox", - props: props$y, + props: props$z, setup(props2, { slots }) { @@ -3396,7 +3396,7 @@ function useCheckboxInject(checkboxChecked, checkboxValue, reset) { let resetTimer; function iosHideKeyboard() { } -const props$x = { +const props$y = { cursorSpacing: { type: [Number, String], default: 0 @@ -4146,7 +4146,7 @@ function useQuill(props2, rootRef, trigger) { } }, id2, true); } -const props$w = /* @__PURE__ */ extend({}, props$x, { +const props$x = /* @__PURE__ */ extend({}, props$y, { id: { type: String, default: "" @@ -4172,9 +4172,9 @@ const props$w = /* @__PURE__ */ extend({}, props$x, { default: false } }); -var index$n = /* @__PURE__ */ defineBuiltInComponent({ +var index$o = /* @__PURE__ */ defineBuiltInComponent({ name: "Editor", - props: props$w, + props: props$x, emit: ["ready", "focus", "blur", "input", "statuschange", ...emit$1], setup(props2, { emit: emit2 @@ -4234,7 +4234,7 @@ const ICONS = { c: GREY_COLOR } }; -var index$m = /* @__PURE__ */ defineBuiltInComponent({ +var index$n = /* @__PURE__ */ defineBuiltInComponent({ name: "Icon", props: { type: { @@ -4261,7 +4261,7 @@ var index$m = /* @__PURE__ */ defineBuiltInComponent({ }; } }); -const props$v = { +const props$w = { src: { type: String, default: "" @@ -4298,9 +4298,9 @@ const IMAGE_MODES = { "bottom left": ["left bottom"], "bottom right": ["right bottom"] }; -var index$l = /* @__PURE__ */ defineBuiltInComponent({ +var index$m = /* @__PURE__ */ defineBuiltInComponent({ name: "Image", - props: props$v, + props: props$w, setup(props2, { emit: emit2 }) { @@ -4602,7 +4602,7 @@ const UniViewJSBridgeSubscribe = function() { function getValueString(value) { return value === null ? "" : String(value); } -const props$u = /* @__PURE__ */ extend({}, { +const props$v = /* @__PURE__ */ extend({}, { name: { type: String, default: "" @@ -4667,7 +4667,7 @@ const props$u = /* @__PURE__ */ extend({}, { type: String, default: "done" } -}, props$x); +}, props$y); const emit = [ "input", "focus", @@ -4863,7 +4863,7 @@ function useField(props2, rootRef, emit2, beforeInput) { trigger }; } -const props$t = /* @__PURE__ */ extend({}, props$u, { +const props$u = /* @__PURE__ */ extend({}, props$v, { placeholderClass: { type: String, default: "input-placeholder" @@ -4871,7 +4871,7 @@ const props$t = /* @__PURE__ */ extend({}, props$u, { }); var Input = /* @__PURE__ */ defineBuiltInComponent({ name: "Input", - props: props$t, + props: props$u, emits: ["confirm", ...emit], setup(props2, { emit: emit2 @@ -5026,7 +5026,7 @@ function flatVNode(nodes) { } return array; } -const props$s = { +const props$t = { scaleArea: { type: Boolean, default: false @@ -5035,7 +5035,7 @@ const props$s = { var MovableArea = /* @__PURE__ */ defineBuiltInComponent({ inheritAttrs: false, name: "MovableArea", - props: props$s, + props: props$t, setup(props2, { slots }) { @@ -5344,7 +5344,7 @@ function useTouchtrack(element, method, useCancel) { function e(e2, t2, n) { return e2 > t2 - n && e2 < t2 + n; } -function t$1(t2, n) { +function t(t2, n) { return e(t2, 0, n); } function Decline() { @@ -5526,23 +5526,23 @@ Spring$1.prototype.setEnd = function(e2, n, i) { if (!i) { i = new Date().getTime(); } - if (e2 !== this._endPosition || !t$1(n, 0.1)) { + if (e2 !== this._endPosition || !t(n, 0.1)) { n = n || 0; var r = this._endPosition; if (this._solution) { - if (t$1(n, 0.1)) { + if (t(n, 0.1)) { n = this._solution.dx((i - this._startTime) / 1e3); } r = this._solution.x((i - this._startTime) / 1e3); - if (t$1(n, 0.1)) { + if (t(n, 0.1)) { n = 0; } - if (t$1(r, 0.1)) { + if (t(r, 0.1)) { r = 0; } r += this._endPosition; } - if (!(this._solution && t$1(r - e2, 0.1) && t$1(n, 0.1))) { + 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; @@ -5565,7 +5565,7 @@ Spring$1.prototype.done = function(n) { if (!n) { n = new Date().getTime(); } - return e(this.x(), this._endPosition, 0.1) && t$1(this.dx(), 0.1); + return e(this.x(), this._endPosition, 0.1) && t(this.dx(), 0.1); }; Spring$1.prototype.reconfigure = function(m, t2, c) { this._m = m; @@ -5636,7 +5636,7 @@ STD.prototype.reconfigure = function(e2, t2, n) { this._springY.reconfigure(e2, t2, n); this._springScale.reconfigure(e2, t2, n); }; -const props$r = { +const props$s = { direction: { type: String, default: "none" @@ -5692,7 +5692,7 @@ const props$r = { }; var MovableView = /* @__PURE__ */ defineBuiltInComponent({ name: "MovableView", - props: props$r, + props: props$s, emits: ["change", "scale"], setup(props2, { slots, @@ -6275,7 +6275,7 @@ function useMovableViewState(props2, trigger, rootRef) { }; } const OPEN_TYPES = ["navigate", "redirect", "switchTab", "reLaunch", "navigateBack"]; -const props$q = { +const props$r = { hoverClass: { type: String, default: "navigator-hover" @@ -6312,12 +6312,12 @@ const props$q = { default: false } }; -var index$k = /* @__PURE__ */ defineBuiltInComponent({ +var index$l = /* @__PURE__ */ defineBuiltInComponent({ name: "Navigator", compatConfig: { MODE: 3 }, - props: props$q, + props: props$r, setup(props2, { slots }) { @@ -6372,7 +6372,7 @@ var index$k = /* @__PURE__ */ defineBuiltInComponent({ }; } }); -const props$p = { +const props$q = { value: { type: Array, default() { @@ -6419,7 +6419,7 @@ function useState$3(props2) { } var PickerView = /* @__PURE__ */ defineBuiltInComponent({ name: "PickerView", - props: props$p, + props: props$q, emits: ["change", "pickstart", "pickend", "update:value"], setup(props2, { slots, @@ -7345,7 +7345,7 @@ const VALUES = { backgroundColor: "#EBEBEB", activeMode: "backwards" }; -const props$o = { +const props$p = { percent: { type: [Number, String], default: 0, @@ -7392,9 +7392,9 @@ const props$o = { } } }; -var index$j = /* @__PURE__ */ defineBuiltInComponent({ +var index$k = /* @__PURE__ */ defineBuiltInComponent({ name: "Progress", - props: props$o, + props: props$p, setup(props2) { const state2 = useProgressState(props2); _activeAnimation(state2, props2); @@ -7465,15 +7465,15 @@ function _activeAnimation(state2, props2) { } } const uniRadioGroupKey = PolySymbol(process.env.NODE_ENV !== "production" ? "uniCheckGroup" : "ucg"); -const props$n = { +const props$o = { name: { type: String, default: "" } }; -var index$i = /* @__PURE__ */ defineBuiltInComponent({ +var index$j = /* @__PURE__ */ defineBuiltInComponent({ name: "RadioGroup", - props: props$n, + props: props$o, setup(props2, { emit: emit2, slots @@ -7549,7 +7549,7 @@ function useProvideRadioGroup(props2, trigger) { } return fields2; } -const props$m = { +const props$n = { checked: { type: [Boolean, String], default: false @@ -7571,9 +7571,9 @@ const props$m = { default: "" } }; -var index$h = /* @__PURE__ */ defineBuiltInComponent({ +var index$i = /* @__PURE__ */ defineBuiltInComponent({ name: "Radio", - props: props$m, + props: props$n, setup(props2, { slots }) { @@ -7867,7 +7867,7 @@ function parseNodes(nodes, parentNode) { }); return parentNode; } -const props$l = { +const props$m = { nodes: { type: [Array, String], default: function() { @@ -7875,12 +7875,12 @@ const props$l = { } } }; -var index$g = /* @__PURE__ */ defineBuiltInComponent({ +var index$h = /* @__PURE__ */ defineBuiltInComponent({ name: "RichText", compatConfig: { MODE: 3 }, - props: props$l, + props: props$m, setup(props2) { const rootRef = ref(null); function _renderNodes(nodes) { @@ -7905,7 +7905,7 @@ var index$g = /* @__PURE__ */ defineBuiltInComponent({ } }); const passiveOptions = passive(true); -const props$k = { +const props$l = { scrollX: { type: [Boolean, String], default: false @@ -7968,7 +7968,7 @@ var ScrollView = /* @__PURE__ */ defineBuiltInComponent({ compatConfig: { MODE: 3 }, - props: props$k, + props: props$l, emits: ["scroll", "scrolltoupper", "scrolltolower", "refresherrefresh", "refresherrestore", "refresherpulling", "refresherabort"], setup(props2, { emit: emit2, @@ -8367,7 +8367,7 @@ function useScrollViewLoader(props2, state2, scrollTopNumber, scrollLeftNumber, } }); } -const props$j = { +const props$k = { name: { type: String, default: "" @@ -8421,9 +8421,9 @@ const props$j = { default: false } }; -var index$f = /* @__PURE__ */ defineBuiltInComponent({ +var index$g = /* @__PURE__ */ defineBuiltInComponent({ name: "Slider", - props: props$j, + props: props$k, emits: ["changing", "change"], setup(props2, { emit: emit2 @@ -8591,7 +8591,7 @@ var computeController = { return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m); } }; -const props$i = { +const props$j = { indicatorDots: { type: [Boolean, String], default: false @@ -9080,7 +9080,7 @@ function useLayout(props2, state2, swiperContexts, slideFrameRef, emit2, trigger } var Swiper = /* @__PURE__ */ defineBuiltInComponent({ name: "Swiper", - props: props$i, + props: props$j, emits: ["change", "transition", "animationfinish", "update:current", "update:currentItemId"], setup(props2, { slots, @@ -9175,7 +9175,7 @@ var Swiper = /* @__PURE__ */ defineBuiltInComponent({ }; } }); -const props$h = { +const props$i = { itemId: { type: String, default: "" @@ -9183,7 +9183,7 @@ const props$h = { }; var SwiperItem = /* @__PURE__ */ defineBuiltInComponent({ name: "SwiperItem", - props: props$h, + props: props$i, setup(props2, { slots }) { @@ -9232,7 +9232,7 @@ var SwiperItem = /* @__PURE__ */ defineBuiltInComponent({ }; } }); -const props$g = { +const props$h = { name: { type: String, default: "" @@ -9258,9 +9258,9 @@ const props$g = { default: "#007aff" } }; -var index$e = /* @__PURE__ */ defineBuiltInComponent({ +var index$f = /* @__PURE__ */ defineBuiltInComponent({ name: "Switch", - props: props$g, + props: props$h, emits: ["change"], setup(props2, { emit: emit2 @@ -9357,7 +9357,7 @@ function normalizeText(text2, { } return text2.replace(/ /g, SPACE_UNICODE.nbsp).replace(/ /g, SPACE_UNICODE.ensp).replace(/ /g, SPACE_UNICODE.emsp).replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&").replace(/"/g, '"').replace(/'/g, "'"); } -var index$d = /* @__PURE__ */ defineBuiltInComponent({ +var index$e = /* @__PURE__ */ defineBuiltInComponent({ name: "Text", props: { selectable: { @@ -9410,7 +9410,7 @@ var index$d = /* @__PURE__ */ defineBuiltInComponent({ }; } }); -const props$f = /* @__PURE__ */ extend({}, props$u, { +const props$g = /* @__PURE__ */ extend({}, props$v, { placeholderClass: { type: String, default: "input-placeholder" @@ -9424,9 +9424,9 @@ const props$f = /* @__PURE__ */ extend({}, props$u, { default: "" } }); -var index$c = /* @__PURE__ */ defineBuiltInComponent({ +var index$d = /* @__PURE__ */ defineBuiltInComponent({ name: "Textarea", - props: props$f, + props: props$g, emit: ["confirm", "linechange", ...emit], setup(props2, { emit: emit2 @@ -9544,7 +9544,7 @@ var index$c = /* @__PURE__ */ defineBuiltInComponent({ }; } }); -var index$b = /* @__PURE__ */ defineBuiltInComponent({ +var index$c = /* @__PURE__ */ defineBuiltInComponent({ name: "View", props: extend({}, hoverProps), setup(props2, { @@ -9609,13 +9609,13 @@ function useOn(name, callback) { onMounted(() => UniViewJSBridge.on(name, callback)); onBeforeUnmount(() => UniViewJSBridge.off(name)); } -let index$a = 0; +let index$b = 0; function useContextInfo(_id) { const page = useCurrentPageId(); const instance2 = getCurrentInstance(); const vm = instance2.proxy; const type = vm.$options.name.toLowerCase(); - const id2 = _id || vm.id || `context${index$a++}`; + const id2 = _id || vm.id || `context${index$b++}`; onMounted(() => { const el = vm.$el; el.__uniContextInfo = { @@ -11201,12 +11201,12 @@ const createMediaQueryObserver = /* @__PURE__ */ defineSyncApi("createMediaQuery return new ServiceMediaQueryObserver(getCurrentPageVm()); }); let eventReady = false; -let index$9 = 0; +let index$a = 0; let optionsCache = {}; function operateEditor(componentId, pageId, type, options) { const data = {}; if (options && ("success" in options || "fail" in options || "complete" in options)) { - const callbackId = String(index$9++); + const callbackId = String(index$a++); data.callbackId = callbackId; optionsCache[callbackId] = options; if (!eventReady) { @@ -13224,7 +13224,7 @@ function initHistory() { }); return history2; } -var index$8 = { +var index$9 = { install(app) { initApp$1(app); initView(app); @@ -13899,7 +13899,7 @@ function useContext(play, pause, seek, sendDanmu, playbackRate, requestFullScree } }, id2, true); } -const props$e = { +const props$f = { id: { type: String, default: "" @@ -13983,9 +13983,9 @@ const props$e = { default: true } }; -var index$7 = /* @__PURE__ */ defineBuiltInComponent({ +var index$8 = /* @__PURE__ */ defineBuiltInComponent({ name: "Video", - props: props$e, + props: props$f, emits: ["fullscreenchange", "progress", "loadedmetadata", "waiting", "error", "play", "pause", "ended", "timeupdate"], setup(props2, { emit: emit2, @@ -14206,16 +14206,16 @@ const onWebInvokeAppService = ({name, arg}, pageId) => { } }; const Invoke = /* @__PURE__ */ once(() => UniServiceJSBridge.on("onWebInvokeAppService", onWebInvokeAppService)); -const props$d = { +const props$e = { src: { type: String, default: "" } }; -var index$6 = /* @__PURE__ */ defineBuiltInComponent({ +var index$7 = /* @__PURE__ */ defineBuiltInComponent({ inheritAttrs: false, name: "WebView", - props: props$d, + props: props$e, setup(props2, { attrs: attrs2 }) { @@ -14402,7 +14402,7 @@ function loadMaps(callback) { document.body.appendChild(script); } } -const props$c = { +const props$d = { id: { type: [Number, String], default: "" @@ -14466,7 +14466,7 @@ const props$c = { }; var MapMarker = /* @__PURE__ */ defineSystemComponent({ name: "MapMarker", - props: props$c, + props: props$d, setup(props2) { const id2 = String(Number(props2.id) !== NaN ? props2.id : ""); const onMapReady = inject("onMapReady"); @@ -14677,7 +14677,7 @@ var MapMarker = /* @__PURE__ */ defineSystemComponent({ }; } }); -const props$b = { +const props$c = { points: { type: Array, require: true @@ -14723,7 +14723,7 @@ const props$b = { }; var MapPolyline = /* @__PURE__ */ defineSystemComponent({ name: "MapPolyline", - props: props$b, + props: props$c, setup(props2) { const onMapReady = inject("onMapReady"); let polyline; @@ -14776,7 +14776,7 @@ var MapPolyline = /* @__PURE__ */ defineSystemComponent({ }; } }); -const props$a = { +const props$b = { latitude: { type: [Number, String], require: true @@ -14808,7 +14808,7 @@ const props$a = { }; var MapCircle = /* @__PURE__ */ defineSystemComponent({ name: "MapCircle", - props: props$a, + props: props$b, setup(props2) { const onMapReady = inject("onMapReady"); let circle; @@ -14852,7 +14852,7 @@ var MapCircle = /* @__PURE__ */ defineSystemComponent({ }; } }); -const props$9 = { +const props$a = { id: { type: [Number, String], default: "" @@ -14872,7 +14872,7 @@ const props$9 = { }; var MapControl = /* @__PURE__ */ defineSystemComponent({ name: "MapControl", - props: props$9, + props: props$a, setup(props2) { const onMapReady = inject("onMapReady"); let control; @@ -15087,7 +15087,7 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", () const windowWidth = getWindowWidth(screenWidth); let windowHeight = window.innerHeight; const language = navigator.language; - const statusBarHeight = out.top; + const statusBarHeight = D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top; let osname; let osversion; let model; @@ -15200,12 +15200,12 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", () const system = `${osname} ${osversion}`; const platform = osname.toLocaleLowerCase(); const safeArea = { - left: out.left, - right: windowWidth - out.right, - top: out.top, - bottom: windowHeight - out.bottom, - width: windowWidth - out.left - out.right, - height: windowHeight - out.top - out.bottom + left: D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.left, + right: windowWidth - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.right, + top: D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top, + bottom: windowHeight - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.bottom, + width: windowWidth - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.left - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.right, + height: windowHeight - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.bottom }; const {top: windowTop, bottom: windowBottom} = getWindowOffset(); windowHeight -= windowTop; @@ -15225,10 +15225,10 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", () model, safeArea, safeAreaInsets: { - top: out.top, - right: out.right, - bottom: out.bottom, - left: out.left + top: D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top, + right: D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.right, + bottom: D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.bottom, + left: D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.left } }; }); @@ -15817,13 +15817,13 @@ function usePopup(props2, { }); return visible; } -let index$5 = 0; +let index$6 = 0; let overflow = ""; function preventScroll(prevent) { - let before = index$5; - index$5 += prevent ? 1 : -1; - index$5 = Math.max(0, index$5); - if (index$5 > 0) { + let before = index$6; + index$6 += prevent ? 1 : -1; + index$6 = Math.max(0, index$6); + if (index$6 > 0) { if (before === 0) { overflow = document.body.style.overflow; document.body.style.overflow = "hidden"; @@ -15837,7 +15837,7 @@ function usePreventScroll() { onMounted(() => preventScroll(true)); onUnmounted(() => preventScroll(false)); } -const props$8 = { +const props$9 = { src: { type: String, default: "" @@ -15845,7 +15845,7 @@ const props$8 = { }; var ImageView = /* @__PURE__ */ defineSystemComponent({ name: "ImageView", - props: props$8, + props: props$9, setup(props2) { const state2 = reactive({ direction: "none" @@ -15932,10 +15932,10 @@ var ImageView = /* @__PURE__ */ defineSystemComponent({ }; } }); -function _isSlot$1(s) { +function _isSlot$2(s) { return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s); } -const props$7 = { +const props$8 = { urls: { type: Array, default() { @@ -15954,7 +15954,7 @@ function getIndex(props2) { } var ImagePreview = /* @__PURE__ */ defineSystemComponent({ name: "ImagePreview", - props: props$7, + props: props$8, emits: ["close"], setup(props2, { emit: emit2 @@ -16017,7 +16017,7 @@ var ImagePreview = /* @__PURE__ */ defineSystemComponent({ width: "100%", height: "100%" } - }, _isSlot$1(_slot = props2.urls.map((src) => createVNode(SwiperItem, null, { + }, _isSlot$2(_slot = props2.urls.map((src) => createVNode(SwiperItem, null, { default: () => [createVNode(ImageView, { "src": src }, null, 8, ["src"])] @@ -16665,7 +16665,7 @@ const getLocation = /* @__PURE__ */ defineAsyncApi(API_GET_LOCATION, ({type, alt reject(error.message); }); }, GetLocationProtocol, GetLocationOptions); -const props$6 = { +const props$7 = { latitude: { type: Number }, @@ -16687,7 +16687,7 @@ const props$6 = { }; var LocationView = /* @__PURE__ */ defineSystemComponent({ name: "LocationView", - props: props$6, + props: props$7, emits: ["close"], setup(props2, { emit: emit2 @@ -16775,11 +16775,11 @@ const openLocation = /* @__PURE__ */ defineAsyncApi(API_OPEN_LOCATION, (args, {r } resolve(); }, OpenLocationProtocol, OpenLocationOptions); -function _isSlot(s) { +function _isSlot$1(s) { return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s); } const ICON_PATH_LOCTAION = "M13.3334375 16 q0.033125 1.1334375 0.783125 1.8834375 q0.75 0.75 1.8834375 0.75 q1.1334375 0 1.8834375 -0.75 q0.75 -0.75 0.75 -1.8834375 q0 -1.1334375 -0.75 -1.8834375 q-0.75 -0.75 -1.8834375 -0.75 q-1.1334375 0 -1.8834375 0.75 q-0.75 0.75 -0.783125 1.8834375 ZM30.9334375 14.9334375 l-1.1334375 0 q-0.5 -5.2 -4.0165625 -8.716875 q-3.516875 -3.5165625 -8.716875 -4.0165625 l0 -1.1334375 q0 -0.4665625 -0.3 -0.7665625 q-0.3 -0.3 -0.7665625 -0.3 q-0.4665625 0 -0.7665625 0.3 q-0.3 0.3 -0.3 0.7665625 l0 1.1334375 q-5.2 0.5 -8.716875 4.0165625 q-3.5165625 3.516875 -4.0165625 8.716875 l-1.1334375 0 q-0.4665625 0 -0.7665625 0.3 q-0.3 0.3 -0.3 0.7665625 q0 0.4665625 0.3 0.7665625 q0.3 0.3 0.7665625 0.3 l1.1334375 0 q0.5 5.2 4.0165625 8.716875 q3.516875 3.5165625 8.716875 4.0165625 l0 1.1334375 q0 0.4665625 0.3 0.7665625 q0.3 0.3 0.7665625 0.3 q0.4665625 0 0.7665625 -0.3 q0.3 -0.3 0.3 -0.7665625 l0 -1.1334375 q5.2 -0.5 8.716875 -4.0165625 q3.5165625 -3.516875 4.0165625 -8.716875 l1.1334375 0 q0.4665625 0 0.7665625 -0.3 q0.3 -0.3 0.3 -0.7665625 q0 -0.4665625 -0.3 -0.7665625 q-0.3 -0.3 -0.7665625 -0.3 ZM17.0665625 27.6665625 l0 -2.0665625 q0 -0.4665625 -0.3 -0.7665625 q-0.3 -0.3 -0.7665625 -0.3 q-0.4665625 0 -0.7665625 0.3 q-0.3 0.3 -0.3 0.7665625 l0 2.0665625 q-4.3 -0.4665625 -7.216875 -3.383125 q-2.916875 -2.916875 -3.3834375 -7.216875 l2.0665625 0 q0.4665625 0 0.7665625 -0.3 q0.3 -0.3 0.3 -0.7665625 q0 -0.4665625 -0.3 -0.7665625 q-0.3 -0.3 -0.7665625 -0.3 l-2.0665625 0 q0.4665625 -4.3 3.3834375 -7.216875 q2.9165625 -2.916875 7.216875 -3.3834375 l0 2.0665625 q0 0.4665625 0.3 0.7665625 q0.3 0.3 0.7665625 0.3 q0.4665625 0 0.7665625 -0.3 q0.3 -0.3 0.3 -0.7665625 l0 -2.0665625 q4.3 0.4665625 7.216875 3.3834375 q2.9165625 2.9165625 3.383125 7.216875 l-2.0665625 0 q-0.4665625 0 -0.7665625 0.3 q-0.3 0.3 -0.3 0.7665625 q0 0.4665625 0.3 0.7665625 q0.3 0.3 0.7665625 0.3 l2.0665625 0 q-0.4665625 4.3 -3.383125 7.216875 q-2.916875 2.9165625 -7.216875 3.383125 Z"; -const props$5 = { +const props$6 = { latitude: { type: Number }, @@ -16879,7 +16879,7 @@ function useList(state2) { } var LoctaionPicker = /* @__PURE__ */ defineSystemComponent({ name: "LoctaionPicker", - props: props$5, + props: props$6, emits: ["close"], setup(props2, { emit: emit2 @@ -17021,7 +17021,7 @@ var LoctaionPicker = /* @__PURE__ */ defineSystemComponent({ "scroll-y": true, "class": "list", "onScrolltolower": loadMore - }, _isSlot(content) ? content : { + }, _isSlot$1(content) ? content : { default: () => [content], _: 2 }, 8, ["scroll-y", "onScrolltolower"])])]); @@ -17142,7 +17142,7 @@ const preloadPage = /* @__PURE__ */ defineAsyncApi(API_PRELOAD_PAGE, ({url}, {re reject(`${url} ${String(err)}`); }); }, PreloadPageProtocol); -const props$4 = { +const props$5 = { title: { type: String, default: "" @@ -17176,7 +17176,7 @@ const props$4 = { } }; var modal = /* @__PURE__ */ defineComponent({ - props: props$4, + props: props$5, setup(props2, { emit: emit2 }) { @@ -17248,7 +17248,7 @@ const showModal = /* @__PURE__ */ defineAsyncApi(API_SHOW_MODAL, (args, {resolve showModalState.visible = true; } }, ShowModalProtocol, ShowModalOptions); -const props$3 = { +const props$4 = { title: { type: String, default: "" @@ -17278,7 +17278,7 @@ const props$3 = { const ToastIconClassName = "uni-toast__icon"; var Toast = /* @__PURE__ */ defineComponent({ name: "Toast", - props: props$3, + props: props$4, setup(props2) { initI18nShowToastMsgsOnce(); initI18nShowLoadingMsgsOnce(); @@ -17480,7 +17480,7 @@ function usePopupStyle(props2) { popupStyle }; } -const props$2 = { +const props$3 = { title: { type: String, default: "" @@ -17506,7 +17506,7 @@ const props$2 = { }; var actionSheet = /* @__PURE__ */ defineComponent({ name: "ActionSheet", - props: props$2, + props: props$3, emits: ["close"], setup(props2, { emit: emit2 @@ -18785,7 +18785,7 @@ var MapLocation = /* @__PURE__ */ defineSystemComponent({ }; } }); -const props$1 = { +const props$2 = { id: { type: String, default: "" @@ -19109,7 +19109,7 @@ function useMap(props2, rootRef, emit2) { } var Map$1 = /* @__PURE__ */ defineBuiltInComponent({ name: "Map", - props: props$1, + props: props$2, emits: ["markertap", "labeltap", "callouttap", "controltap", "regionchange", "tap", "click", "updated", "update:scale", "update:latitude", "update:longitude"], setup(props2, { emit: emit2, @@ -19134,18 +19134,18 @@ var Map$1 = /* @__PURE__ */ defineBuiltInComponent({ }; } }); -const props = { +const props$1 = { scrollTop: { type: [String, Number], default: 0 } }; -var index$4 = /* @__PURE__ */ defineBuiltInComponent({ +var index$5 = /* @__PURE__ */ defineBuiltInComponent({ name: "CoverView", compatConfig: { MODE: 3 }, - props, + props: props$1, setup(props2, { slots }) { @@ -19181,7 +19181,7 @@ var index$4 = /* @__PURE__ */ defineBuiltInComponent({ }; } }); -var index$3 = /* @__PURE__ */ defineBuiltInComponent({ +var index$4 = /* @__PURE__ */ defineBuiltInComponent({ name: "CoverImage", compatConfig: { MODE: 3 @@ -19221,14 +19221,16 @@ var index$3 = /* @__PURE__ */ defineBuiltInComponent({ }; } }); -const {t, getLocale} = useI18n(); -function getDefaultStartValue() { - if (this.mode === mode.TIME) { +function _isSlot(s) { + return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s); +} +function getDefaultStartValue(props2) { + if (props2.mode === mode.TIME) { return "00:00"; } - if (this.mode === mode.DATE) { + if (props2.mode === mode.DATE) { const year = new Date().getFullYear() - 100; - switch (this.fields) { + switch (props2.fields) { case fields.YEAR: return year.toString(); case fields.MONTH: @@ -19239,13 +19241,13 @@ function getDefaultStartValue() { } return ""; } -function getDefaultEndValue() { - if (this.mode === mode.TIME) { +function getDefaultEndValue(props2) { + if (props2.mode === mode.TIME) { return "23:59"; } - if (this.mode === mode.DATE) { + if (props2.mode === mode.DATE) { const year = new Date().getFullYear() + 100; - switch (this.fields) { + switch (props2.fields) { case fields.YEAR: return year.toString(); case fields.MONTH: @@ -19256,6 +19258,36 @@ function getDefaultEndValue() { } return ""; } +function getDateValueArray(props2, state2, valueStr, defaultValue) { + const splitStr = props2.mode === mode.DATE ? "-" : ":"; + const array = props2.mode === mode.DATE ? state2.dateArray : state2.timeArray; + let max; + if (props2.mode === mode.TIME) { + max = 2; + } else { + switch (props2.fields) { + case fields.YEAR: + max = 1; + break; + case fields.MONTH: + max = 2; + break; + default: + max = 3; + break; + } + } + const inputArray = String(valueStr).split(splitStr); + let value = []; + for (let i = 0; i < max; i++) { + const val = inputArray[i]; + value.push(array[i].indexOf(val)); + } + if (value.indexOf(-1) >= 0) { + value = defaultValue ? getDateValueArray(props2, state2, defaultValue) : value.map(() => 0); + } + return value; +} const mode = { SELECTOR: "selector", MULTISELECTOR: "multiSelector", @@ -19271,564 +19303,637 @@ const selectorType = { PICKER: "picker", SELECT: "select" }; -var _sfc_main$1 = { - name: "Picker", - compatConfig: { - MODE: 3 +const props = { + name: { + type: String, + default: "" }, - components: {PickerView, PickerViewColumn}, - props: { - 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).includes(val); - } - }, - fields: { - type: String, - default: "" - }, - start: { - type: String, - default: (props2) => { - return getDefaultStartValue.call(props2); - } - }, - end: { - type: String, - default: (props2) => { - return getDefaultEndValue.call(props2); - } - }, - disabled: { - type: [Boolean, String], - default: false - }, - selectorType: { - type: String, - default: "" + range: { + type: Array, + default() { + return []; } }, - data() { - return { - valueSync: null, - visible: false, - contentVisible: false, - popover: null, - valueChangeSource: "", - timeArray: [], - dateArray: [], - valueArray: [], - oldValueArray: [], - isDesktop: false, - popupStyle: { - content: {}, - triangle: {} - } - }; + rangeKey: { + type: String, + default: "" }, - computed: { - rangeArray() { - var val = this.range; - switch (this.mode) { - case mode.SELECTOR: - return [val]; - case mode.MULTISELECTOR: - return val; - case mode.TIME: - return this.timeArray; - case mode.DATE: { - const dateArray = this.dateArray; - switch (this.fields) { - case fields.YEAR: - return [dateArray[0]]; - case fields.MONTH: - return [dateArray[0], dateArray[1]]; - default: - return [dateArray[0], dateArray[1], dateArray[2]]; - } - } - } - return []; - }, - startArray() { - return this._getDateValueArray(this.start, getDefaultStartValue.bind(this)()); - }, - endArray() { - return this._getDateValueArray(this.end, getDefaultEndValue.bind(this)()); - }, - selectorTypeComputed() { - const type = this.selectorType; - if (Object.values(selectorType).includes(type)) { - return type; - } - return String(navigator.vendor).indexOf("Apple") === 0 && navigator.maxTouchPoints > 0 ? selectorType.PICKER : selectorType.SELECT; - }, - system() { - if (this.mode === mode.DATE && !Object.values(fields).includes(this.fields) && this.isDesktop && /win|mac/i.test(navigator.platform)) { - if (navigator.vendor === "Google Inc.") { - return "chrome"; - } else if (/Firefox/.test(navigator.userAgent)) { - return "firefox"; - } - } - return ""; + value: { + type: [Number, String, Array], + default: 0 + }, + mode: { + type: String, + default: mode.SELECTOR, + validator(val) { + return Object.values(mode).includes(val); } }, - watch: { - visible(val) { - if (val) { - clearTimeout(this.__contentVisibleDelay); - this.contentVisible = val; - this._select(); - } else { - this.__contentVisibleDelay = setTimeout(() => { - this.contentVisible = val; - }, 300); - } - }, - value: { - deep: true, - handler() { - this._setValueSync(); - } - }, - mode() { - this._setValueSync(); - }, - range: { - deep: true, - handler() { - this._setValueSync(); + fields: { + type: String, + default: "" + }, + start: { + type: String, + default: (props2) => { + return getDefaultStartValue(props2); + } + }, + end: { + type: String, + default: (props2) => { + return getDefaultEndValue(props2); + } + }, + disabled: { + type: [Boolean, String], + default: false + }, + selectorType: { + type: String, + default: "" + } +}; +var index$3 = /* @__PURE__ */ defineBuiltInComponent({ + name: "Picker", + compatConfig: { + MODE: 3 + }, + props, + emits: ["change", "cancel", "columnchange"], + setup(props2, { + emit: emit2, + slots + }) { + initI18nPickerMsgsOnce(); + const { + t: t2 + } = useI18n(); + const rootRef = ref(null); + const pickerRef = ref(null); + const selectRef = ref(null); + const inputRef = ref(null); + const { + state: state2, + rangeArray + } = usePickerState(props2); + const trigger = useCustomEvent(rootRef, emit2); + const { + system, + selectorTypeComputed, + _show, + _l10nColumn, + _l10nItem, + _input, + _fixInputPosition, + _pickerViewChange, + _cancel, + _change, + _resetFormData, + _getFormData, + _createTime, + _createDate, + _setValueSync + } = usePickerMethods(props2, state2, trigger, rootRef, pickerRef, selectRef, inputRef); + usePickerWatch(state2, _cancel, _change); + usePickerForm(_resetFormData, _getFormData); + _createTime(); + _createDate(); + _setValueSync(); + const popup = usePopupStyle(props2); + watchEffect(() => { + state2.isDesktop = popup.isDesktop.value; + state2.popupStyle = popup.popupStyle.value; + }); + onBeforeUnmount(() => { + pickerRef.value && pickerRef.value.remove(); + }); + return () => { + let _slot2; + const { + visible, + contentVisible, + valueArray, + popupStyle, + valueSync + } = state2; + const { + rangeKey, + mode: mode2, + start, + end + } = props2; + const booleanAttrs = useBooleanAttr(props2, "disabled"); + return createVNode("uni-picker", mergeProps({ + "ref": rootRef + }, booleanAttrs, { + "onClick": withWebEvent(_show) + }), [createVNode("div", { + "ref": pickerRef, + "class": ["uni-picker-container", `uni-${mode2}-${selectorTypeComputed.value}`], + "onWheel": onEventPrevent, + "onTouchmove": onEventPrevent + }, [createVNode(Transition, { + "name": "uni-fade" + }, { + default: () => [withDirectives(createVNode("div", { + "class": "uni-mask uni-picker-mask", + "onClick": withWebEvent(_cancel), + "onMousemove": _fixInputPosition + }, null, 40, ["onClick", "onMousemove"]), [[vShow, visible]])] + }), !system.value ? createVNode("div", { + "class": [{ + "uni-picker-toggle": visible + }, "uni-picker-custom"], + "style": popupStyle.content + }, [createVNode("div", { + "class": "uni-picker-header", + "onClick": onEventStop + }, [createVNode("div", { + "class": "uni-picker-action uni-picker-action-cancel", + "onClick": withWebEvent(_cancel) + }, [t2("uni.picker.cancel")], 8, ["onClick"]), createVNode("div", { + "class": "uni-picker-action uni-picker-action-confirm", + "onClick": _change + }, [t2("uni.picker.done")], 8, ["onClick"])], 8, ["onClick"]), contentVisible ? createVNode(PickerView, { + "value": _l10nColumn(valueArray), + "class": "uni-picker-content", + "onChange": _pickerViewChange + }, _isSlot(_slot2 = renderList(_l10nColumn(rangeArray.value), (rangeItem, index0) => { + let _slot; + return createVNode(PickerViewColumn, { + "key": index0 + }, _isSlot(_slot = renderList(rangeItem, (item, index2) => createVNode("div", { + "key": index2, + "class": "uni-picker-item" + }, [typeof item === "object" ? item[rangeKey] || "" : _l10nItem(item, index0)]))) ? _slot : { + default: () => [_slot], + _: 1 + }); + })) ? _slot2 : { + default: () => [_slot2], + _: 1 + }, 8, ["value", "onChange"]) : null, createVNode("div", { + "ref": selectRef, + "class": "uni-picker-select", + "onWheel": onEventStop, + "onTouchmove": onEventStop + }, [renderList(rangeArray.value[0], (item, index2) => createVNode("div", { + "key": index2, + "class": ["uni-picker-item", { + selected: valueArray[0] === index2 + }], + "onClick": () => { + valueArray[0] = index2; + _change(); + } + }, [typeof item === "object" ? item[rangeKey] || "" : item], 10, ["onClick"]))], 40, ["onWheel", "onTouchmove"]), createVNode("div", { + "style": popupStyle.triangle + }, null, 4)], 6) : null], 40, ["onWheel", "onTouchmove"]), createVNode("div", null, [slots.default && slots.default()]), system.value ? createVNode("div", { + "class": "uni-picker-system", + "onMousemove": withWebEvent(_fixInputPosition) + }, [createVNode("input", { + "class": ["uni-picker-system_input", system.value], + "ref": inputRef, + "value": valueSync, + "type": mode2, + "tabindex": "-1", + "min": start, + "max": end, + "onChange": ($event) => { + _input($event); + onEventStop($event); + } + }, null, 42, ["value", "type", "min", "max", "onChange"])], 40, ["onMousemove"]) : null], 16, ["onClick"]); + }; + } +}); +function usePickerState(props2) { + const state2 = reactive({ + valueSync: void 0, + visible: false, + contentVisible: false, + popover: null, + valueChangeSource: "", + timeArray: [], + dateArray: [], + valueArray: [], + oldValueArray: [], + isDesktop: false, + popupStyle: { + content: {}, + triangle: {} + } + }); + const rangeArray = computed(() => { + let val = props2.range; + switch (props2.mode) { + case mode.SELECTOR: + return [val]; + case mode.MULTISELECTOR: + return val; + case mode.TIME: + return state2.timeArray; + case mode.DATE: { + const dateArray = state2.dateArray; + switch (props2.fields) { + case fields.YEAR: + return [dateArray[0]]; + case fields.MONTH: + return [dateArray[0], dateArray[1]]; + default: + return [dateArray[0], dateArray[1], dateArray[2]]; + } } - }, - valueSync: { - deep: true, - handler() { - this._setValueArray(); + } + return []; + }); + return { + state: state2, + rangeArray + }; +} +let __contentVisibleDelay; +function usePickerMethods(props2, state2, trigger, rootRef, pickerRef, selectRef, inputRef) { + const selectorTypeComputed = computed(() => { + const type = props2.selectorType; + if (Object.values(selectorType).includes(type)) { + return type; + } + return String(navigator.vendor).indexOf("Apple") === 0 && navigator.maxTouchPoints > 0 ? selectorType.PICKER : selectorType.SELECT; + }); + const system = computed(() => { + if (props2.mode === mode.DATE && !Object.values(fields).includes(props2.fields) && state2.isDesktop && /win|mac/i.test(navigator.platform)) { + if (navigator.vendor === "Google Inc.") { + return "chrome"; + } else if (/Firefox/.test(navigator.userAgent)) { + return "firefox"; } - }, - valueArray: { - deep: true, - handler(val) { - if (this.mode === mode.TIME || this.mode === mode.DATE) { - const getValue = this.mode === mode.TIME ? this._getTimeValue : this._getDateValue; - const valueArray = this.valueArray; - const startArray = this.startArray; - const endArray = this.endArray; - if (this.mode === mode.DATE) { - const dateArray = this.dateArray; - const max = dateArray[2].length; - const day = Number(dateArray[2][valueArray[2]]) || 1; - const realDay = new Date(`${dateArray[0][valueArray[0]]}/${dateArray[1][valueArray[1]]}/${day}`).getDate(); - if (realDay < day) { - valueArray[2] -= realDay + max - day; - } + } + return ""; + }); + const startArray = computed(() => { + return getDateValueArray(props2, state2, props2.start, getDefaultStartValue(props2)); + }); + const endArray = computed(() => { + return getDateValueArray(props2, state2, props2.end, getDefaultEndValue(props2)); + }); + function _show(event) { + if (props2.disabled) { + return; + } + state2.valueChangeSource = ""; + let $picker = pickerRef.value; + let _currentTarget = event.currentTarget; + $picker.remove(); + (document.querySelector("uni-app") || document.body).appendChild($picker); + $picker.style.display = "block"; + const rect = _currentTarget.getBoundingClientRect(); + state2.popover = { + top: rect.top, + left: rect.left, + width: rect.width, + height: rect.height + }; + setTimeout(() => { + state2.visible = true; + }, 20); + } + function _getFormData() { + return { + value: state2.valueSync, + key: props2.name + }; + } + function _resetFormData() { + switch (props2.mode) { + case mode.SELECTOR: + state2.valueSync = 0; + break; + case mode.MULTISELECTOR: + state2.valueSync = props2.value.map((val) => 0); + break; + case mode.DATE: + case mode.TIME: + state2.valueSync = ""; + break; + } + } + function _createTime() { + let hours = []; + let minutes = []; + for (let i = 0; i < 24; i++) { + hours.push((i < 10 ? "0" : "") + i); + } + for (let i = 0; i < 60; i++) { + minutes.push((i < 10 ? "0" : "") + i); + } + state2.timeArray.push(hours, minutes); + } + function _createDate() { + let years = []; + let year = new Date().getFullYear(); + for (let i = year - 150, end = year + 150; i <= end; i++) { + years.push(String(i)); + } + let months = []; + for (let i = 1; i <= 12; i++) { + months.push((i < 10 ? "0" : "") + i); + } + let days = []; + for (let i = 1; i <= 31; i++) { + days.push((i < 10 ? "0" : "") + i); + } + state2.dateArray.push(years, months, days); + } + function _getTimeValue(val) { + return val[0] * 60 + val[1]; + } + function _getDateValue(val) { + const DAY = 31; + return val[0] * DAY * 12 + (val[1] || 0) * DAY + (val[2] || 0); + } + function _cloneArray(val1, val2) { + for (let i = 0; i < val1.length && i < val2.length; i++) { + val1[i] = val2[i]; + } + } + function _setValueSync() { + let val = props2.value; + switch (props2.mode) { + case mode.MULTISELECTOR: + { + if (!Array.isArray(val)) { + val = []; } - if (getValue(valueArray) < getValue(startArray)) { - this._cloneArray(valueArray, startArray); - } else if (getValue(valueArray) > getValue(endArray)) { - this._cloneArray(valueArray, endArray); + if (!Array.isArray(state2.valueSync)) { + state2.valueSync = []; } - } - val.forEach((value, column) => { - if (value !== this.oldValueArray[column]) { - this.oldValueArray[column] = value; - if (this.mode === mode.MULTISELECTOR) { - this.$trigger("columnchange", {}, { - column, - value - }); - } + const length = state2.valueSync.length = Math.max(val.length, props2.range.length); + for (let index2 = 0; index2 < length; index2++) { + const val0 = Number(val[index2]); + const val1 = Number(state2.valueSync[index2]); + const val2 = isNaN(val0) ? isNaN(val1) ? 0 : val1 : val0; + const maxVal = props2.range[index2] ? props2.range[index2].length - 1 : 0; + state2.valueSync.splice(index2, 1, val2 < 0 || val2 > maxVal ? 0 : val2); } - }); + } + break; + case mode.TIME: + case mode.DATE: + state2.valueSync = String(val); + break; + default: { + const valueSync = Number(val); + state2.valueSync = valueSync < 0 ? 0 : valueSync; + break; } } - }, - created() { - initI18nPickerMsgsOnce(); - this._createTime(); - this._createDate(); - this._setValueSync(); - usePickerWatch.call(this); - usePickerForm.call(this); - const popup = usePopupStyle(this); - this.isDesktop = popup.isDesktop; - this.popupStyle = popup.popupStyle; - }, - mounted() { - this.$trigger = useCustomEvent({value: this.$refs.root}, this.$emit); - }, - beforeUnmount() { - this.$refs.picker.remove(); - }, - methods: { - withWebEvent, - $$t: t, - _show(event) { - if (this.disabled) { + } + function _setValueArray() { + let val = state2.valueSync; + let valueArray; + switch (props2.mode) { + case mode.MULTISELECTOR: + valueArray = [...val]; + break; + case mode.TIME: + valueArray = getDateValueArray(props2, state2, val, formatDateTime({ + mode: mode.TIME + })); + break; + case mode.DATE: + valueArray = getDateValueArray(props2, state2, val, formatDateTime({ + mode: mode.DATE + })); + break; + default: + valueArray = [val]; + break; + } + state2.oldValueArray = [...valueArray]; + state2.valueArray = [...valueArray]; + } + function _getValue() { + let val = state2.valueArray; + switch (props2.mode) { + case mode.SELECTOR: + return val[0]; + case mode.MULTISELECTOR: + return val.map((val2) => val2); + case mode.TIME: + return state2.valueArray.map((val2, i) => state2.timeArray[i][val2]).join(":"); + case mode.DATE: + return state2.valueArray.map((val2, i) => state2.dateArray[i][val2]).join("-"); + } + } + function _change() { + _close(); + state2.valueChangeSource = "click"; + const value = _getValue(); + state2.valueSync = Array.isArray(value) ? value.map((val) => val) : value; + trigger("change", {}, { + value + }); + } + function _cancel($event) { + if (system.value === "firefox" && $event) { + const { + top, + left, + width, + height + } = state2.popover; + const { + pageX, + pageY + } = $event; + if (pageX > left && pageX < left + width && pageY > top && pageY < top + height) { return; } - this.valueChangeSource = ""; - var $picker = this.$refs.picker; + } + _close(); + trigger("cancel", {}, {}); + } + function _close() { + state2.visible = false; + setTimeout(() => { + let $picker = pickerRef.value; $picker.remove(); - (document.querySelector("uni-app") || document.body).appendChild($picker); - $picker.style.display = "block"; - const rect = event.currentTarget.getBoundingClientRect(); - this.popover = { - top: rect.top, - left: rect.left, - width: rect.width, - height: rect.height - }; - setTimeout(() => { - this.visible = true; - }, 20); - }, - _getFormData() { - return { - value: this.valueSync, - key: this.name - }; - }, - _resetFormData() { - switch (this.mode) { - case mode.SELECTOR: - this.valueSync = 0; - break; - case mode.MULTISELECTOR: - this.valueSync = this.value.map((val) => 0); - break; - case mode.DATE: - case mode.TIME: - this.valueSync = ""; - break; - } - }, - _createTime() { - var hours = []; - var minutes = []; - hours.splice(0, hours.length); - for (let i = 0; i < 24; i++) { - hours.push((i < 10 ? "0" : "") + i); - } - minutes.splice(0, minutes.length); - for (let i = 0; i < 60; i++) { - minutes.push((i < 10 ? "0" : "") + i); - } - this.timeArray.push(hours, minutes); - }, - _createDate() { - var years = []; - var year = new Date().getFullYear(); - for (let i = year - 150, end = year + 150; i <= end; i++) { - years.push(String(i)); - } - var months = []; - for (let i = 1; i <= 12; i++) { - months.push((i < 10 ? "0" : "") + i); - } - var days = []; - for (let i = 1; i <= 31; i++) { - days.push((i < 10 ? "0" : "") + i); - } - this.dateArray.push(years, months, days); - }, - _getTimeValue(val) { - return val[0] * 60 + val[1]; - }, - _getDateValue(val) { - const DAY = 31; - return val[0] * DAY * 12 + (val[1] || 0) * DAY + (val[2] || 0); - }, - _cloneArray(val1, val2) { - for (let i = 0; i < val1.length && i < val2.length; i++) { - val1[i] = val2[i]; - } - }, - _setValueSync() { - let val = this.value; - switch (this.mode) { - case mode.MULTISELECTOR: - { - if (!Array.isArray(val)) { - val = []; - } - if (!Array.isArray(this.valueSync)) { - this.valueSync = []; - } - const length = this.valueSync.length = Math.max(val.length, this.range.length); - for (let index2 = 0; index2 < length; index2++) { - const val0 = Number(val[index2]); - const val1 = Number(this.valueSync[index2]); - const val2 = isNaN(val0) ? isNaN(val1) ? 0 : val1 : val0; - const maxVal = this.range[index2] ? this.range[index2].length - 1 : 0; - this.valueSync.splice(index2, 1, val2 < 0 || val2 > maxVal ? 0 : val2); + rootRef.value.prepend($picker); + $picker.style.display = "none"; + }, 260); + } + function _select() { + if (props2.mode === mode.SELECTOR && selectorTypeComputed.value === selectorType.SELECT) { + selectRef.value.scrollTop = state2.valueArray[0] * 34; + } + } + function _input($event) { + const EventTarget = $event.target; + state2.valueSync = EventTarget.value; + nextTick(() => { + _change(); + }); + } + function _fixInputPosition($event) { + if (system.value === "chrome") { + const rect = rootRef.value.getBoundingClientRect(); + const fontSize = 32; + inputRef.value.style.left = `${$event.clientX - rect.left - fontSize * 1.5}px`; + inputRef.value.style.top = `${$event.clientY - rect.top - fontSize * 0.5}px`; + } + } + function _pickerViewChange(event) { + state2.valueArray = _l10nColumn(event.detail.value, true); + } + function _l10nColumn(array, normalize) { + const { + getLocale + } = useI18n(); + if (props2.mode === mode.DATE) { + const locale = getLocale(); + if (!locale.startsWith("zh")) { + switch (props2.fields) { + case fields.YEAR: + return array; + case fields.MONTH: + return [array[1], array[0]]; + default: + switch (locale) { + case "es": + case "fr": + return [array[2], array[1], array[0]]; + default: + return normalize ? [array[2], array[0], array[1]] : [array[1], array[2], array[0]]; } - } - break; - case mode.TIME: - case mode.DATE: - this.valueSync = String(val); - break; - default: { - const valueSync = Number(val); - this.valueSync = valueSync < 0 ? 0 : valueSync; - break; } } - }, - _setValueArray() { - var val = this.valueSync; - var valueArray; - switch (this.mode) { - case mode.MULTISELECTOR: - valueArray = [...val]; - break; - case mode.TIME: - valueArray = this._getDateValueArray(val, formatDateTime({ - mode: mode.TIME - })); - break; - case mode.DATE: - valueArray = this._getDateValueArray(val, formatDateTime({ - mode: mode.DATE - })); - break; - default: - valueArray = [val]; - break; - } - this.oldValueArray = [...valueArray]; - this.valueArray = [...valueArray]; - }, - _getValue() { - var val = this.valueArray; - switch (this.mode) { - case mode.SELECTOR: - return val[0]; - case mode.MULTISELECTOR: - return val.map((val2) => val2); - case mode.TIME: - return this.valueArray.map((val2, i) => this.timeArray[i][val2]).join(":"); - case mode.DATE: - return this.valueArray.map((val2, i) => this.dateArray[i][val2]).join("-"); - } - }, - _getDateValueArray(valueStr, defaultValue) { - const splitStr = this.mode === mode.DATE ? "-" : ":"; - const array = this.mode === mode.DATE ? this.dateArray : this.timeArray; - let max; - if (this.mode === mode.TIME) { - max = 2; - } else { - switch (this.fields) { - case fields.YEAR: - max = 1; + } + return array; + } + function _l10nItem(item, index2) { + const { + getLocale + } = useI18n(); + if (props2.mode === mode.DATE) { + const locale = getLocale(); + if (locale.startsWith("zh")) { + const array = ["\u5E74", "\u6708", "\u65E5"]; + return item + array[index2]; + } else if (props2.fields !== fields.YEAR && index2 === (props2.fields !== fields.MONTH && (locale === "es" || locale === "fr") ? 1 : 0)) { + let array; + switch (locale) { + case "es": + array = ["enero", "febrero", "marzo", "abril", "mayo", "junio", "\u200B\u200Bjulio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"]; break; - case fields.MONTH: - max = 2; + case "fr": + array = ["janvier", "f\xE9vrier", "mars", "avril", "mai", "juin", "juillet", "ao\xFBt", "septembre", "octobre", "novembre", "d\xE9cembre"]; break; default: - max = 3; + array = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; break; } + return array[Number(item) - 1]; } - const inputArray = String(valueStr).split(splitStr); - let value = []; - for (let i = 0; i < max; i++) { - const val = inputArray[i]; - value.push(array[i].indexOf(val)); - } - if (value.indexOf(-1) >= 0) { - value = defaultValue ? this._getDateValueArray(defaultValue) : value.map(() => 0); - } - return value; - }, - _change() { - this._close(); - this.valueChangeSource = "click"; - const value = this._getValue(); - this.valueSync = Array.isArray(value) ? value.map((val) => val) : value; - this.$trigger("change", {}, { - value - }); - }, - _cancel($event) { - if (this.system === "firefox") { - const {top, left, width, height} = this.popover; - const {pageX, pageY} = $event; - if (pageX > left && pageX < left + width && pageY > top && pageY < top + height) { - return; + } + return item; + } + watch(() => state2.visible, (val) => { + if (val) { + clearTimeout(__contentVisibleDelay); + state2.contentVisible = val; + _select(); + } else { + __contentVisibleDelay = setTimeout(() => { + state2.contentVisible = val; + }, 300); + } + }); + watch([() => props2.mode, () => props2.value, () => props2.range], _setValueSync, { + deep: true + }); + watch(() => state2.valueSync, _setValueArray, { + deep: true + }); + watch(() => state2.valueArray, (val) => { + if (props2.mode === mode.TIME || props2.mode === mode.DATE) { + const getValue = props2.mode === mode.TIME ? _getTimeValue : _getDateValue; + const valueArray = state2.valueArray; + const _startArray = startArray.value; + const _endArray = endArray.value; + if (props2.mode === mode.DATE) { + const dateArray = state2.dateArray; + const max = dateArray[2].length; + const day = Number(dateArray[2][valueArray[2]]) || 1; + const realDay = new Date(`${dateArray[0][valueArray[0]]}/${dateArray[1][valueArray[1]]}/${day}`).getDate(); + if (realDay < day) { + valueArray[2] -= realDay + max - day; } } - this._close(); - this.$trigger("cancel", {}, {}); - }, - _close() { - this.visible = false; - setTimeout(() => { - var $picker = this.$refs.picker; - $picker.remove(); - this.$el.prepend($picker); - $picker.style.display = "none"; - }, 260); - }, - _select() { - if (this.mode === mode.SELECTOR && this.selectorTypeComputed === selectorType.SELECT) { - this.$refs.select.scrollTop = this.valueArray[0] * 34; + if (getValue(valueArray) < getValue(_startArray)) { + _cloneArray(valueArray, _startArray); + } else if (getValue(valueArray) > getValue(_endArray)) { + _cloneArray(valueArray, _endArray); } - }, - _input($event) { - this.valueSync = $event.target.value; - this.$nextTick(() => { - this._change(); - }); - }, - _fixInputPosition($event) { - if (this.system === "chrome") { - const rect = this.$el.getBoundingClientRect(); - const style = this.$refs.input.style; - const fontSize = 32; - style.left = `${$event.clientX - rect.left - fontSize * 1.5}px`; - style.top = `${$event.clientY - rect.top - fontSize * 0.5}px`; - } - }, - _pickerViewChange(event) { - this.valueArray = this._l10nColumn(event.detail.value, true); - }, - _l10nColumn(array, normalize) { - if (this.mode === mode.DATE) { - const locale = getLocale(); - if (!locale.startsWith("zh")) { - switch (this.fields) { - case fields.YEAR: - return array; - case fields.MONTH: - return [array[1], array[0]]; - default: - switch (locale) { - case "es": - case "fr": - return [array[2], array[1], array[0]]; - default: - return normalize ? [array[2], array[0], array[1]] : [array[1], array[2], array[0]]; - } - } - } - } - return array; - }, - _l10nItem(item, index2) { - if (this.mode === mode.DATE) { - const locale = getLocale(); - if (locale.startsWith("zh")) { - const array = ["\u5E74", "\u6708", "\u65E5"]; - return item + array[index2]; - } else if (this.fields !== fields.YEAR && index2 === (this.fields !== fields.MONTH && (locale === "es" || locale === "fr") ? 1 : 0)) { - let array; - switch (locale) { - case "es": - array = [ - "enero", - "febrero", - "marzo", - "abril", - "mayo", - "junio", - "\u200B\u200Bjulio", - "agosto", - "septiembre", - "octubre", - "noviembre", - "diciembre" - ]; - break; - case "fr": - array = [ - "janvier", - "f\xE9vrier", - "mars", - "avril", - "mai", - "juin", - "juillet", - "ao\xFBt", - "septembre", - "octobre", - "novembre", - "d\xE9cembre" - ]; - break; - default: - array = [ - "January", - "February", - "March", - "April", - "May", - "June", - "July", - "August", - "September", - "October", - "November", - "December" - ]; - break; - } - return array[Number(item) - 1]; + } + val.forEach((value, column) => { + if (value !== state2.oldValueArray[column]) { + state2.oldValueArray[column] = value; + if (props2.mode === mode.MULTISELECTOR) { + trigger("columnchange", {}, { + column, + value + }); } } - return item; - } - }, - setup(props2) { - const booleanAttrs = useBooleanAttr(props2, "disabled"); - return { - booleanAttrs - }; - } -}; -function usePickerWatch() { - const {key, disable} = useKeyboard(); - watch(() => this.visible, (value) => disable.value = !value); + }); + }); + return { + selectorTypeComputed, + system, + _show, + _cancel, + _change, + _l10nColumn, + _l10nItem, + _input, + _resetFormData, + _getFormData, + _createTime, + _createDate, + _setValueSync, + _fixInputPosition, + _pickerViewChange + }; +} +function usePickerWatch(state2, _cancel, _change) { + const { + key, + disable + } = useKeyboard(); watchEffect(() => { - const {value} = key; + disable.value = !state2.visible; + }); + watch(key, (value) => { if (value === "esc") { - this._cancel && this._cancel(); + _cancel(); } else if (value === "enter") { - this._change && this._change(); + _change(); } }); } -function usePickerForm() { +function usePickerForm(_resetFormData, _getFormData) { const uniForm = inject(uniFormKey, false); - if (!!uniForm) { + if (uniForm) { const field = { - reset: this._resetFormData, + reset: _resetFormData, submit: () => { const data = ["", null]; - const {key, value} = this._getFormData(); + const { + key, + value + } = _getFormData(); if (key !== "") { data[0] = key; data[1] = value; @@ -19842,120 +19947,6 @@ function usePickerForm() { }); } } -function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) { - const _component_PickerViewColumn = resolveComponent("PickerViewColumn"); - const _component_PickerView = resolveComponent("PickerView"); - return openBlock(), createBlock("uni-picker", mergeProps({ref: "root"}, $setup.booleanAttrs, { - onClick: _cache[13] || (_cache[13] = (() => $options.withWebEvent($options._show))()) - }), [ - createVNode("div", { - ref: "picker", - class: ["uni-picker-container", `uni-${$props.mode}-${$options.selectorTypeComputed}`], - onWheel: _cache[9] || (_cache[9] = withModifiers(() => { - }, ["prevent"])), - onTouchmove: _cache[10] || (_cache[10] = withModifiers(() => { - }, ["prevent"])) - }, [ - createVNode(Transition, {name: "uni-fade"}, { - default: withCtx(() => [ - withDirectives(createVNode("div", { - class: "uni-mask uni-picker-mask", - onClick: _cache[1] || (_cache[1] = (() => $options.withWebEvent($options._cancel))()), - onMousemove: _cache[2] || (_cache[2] = (...args) => $options._fixInputPosition && $options._fixInputPosition(...args)) - }, null, 544), [ - [vShow, $data.visible] - ]) - ]), - _: 1 - }), - !$options.system ? (openBlock(), createBlock("div", { - key: 0, - class: [{"uni-picker-toggle": $data.visible}, "uni-picker-custom"], - style: $data.popupStyle.content - }, [ - createVNode("div", { - class: "uni-picker-header", - onClick: _cache[5] || (_cache[5] = withModifiers(() => { - }, ["stop"])) - }, [ - createVNode("div", { - class: "uni-picker-action uni-picker-action-cancel", - onClick: _cache[3] || (_cache[3] = (() => $options.withWebEvent($options._cancel))()) - }, toDisplayString($options.$$t("uni.picker.cancel")), 1), - createVNode("div", { - class: "uni-picker-action uni-picker-action-confirm", - onClick: _cache[4] || (_cache[4] = (...args) => $options._change && $options._change(...args)) - }, toDisplayString($options.$$t("uni.picker.done")), 1) - ]), - $data.contentVisible ? (openBlock(), createBlock(_component_PickerView, { - key: 0, - value: $options._l10nColumn($data.valueArray), - class: "uni-picker-content", - onChange: _cache[6] || (_cache[6] = (() => $options.withWebEvent($options._pickerViewChange))()) - }, { - default: withCtx(() => [ - (openBlock(true), createBlock(Fragment, null, renderList($options._l10nColumn($options.rangeArray), (rangeItem, index0) => { - return openBlock(), createBlock(_component_PickerViewColumn, {key: index0}, { - default: withCtx(() => [ - (openBlock(true), createBlock(Fragment, null, renderList(rangeItem, (item, index2) => { - return openBlock(), createBlock("div", { - key: index2, - class: "uni-picker-item" - }, toDisplayString(typeof item === "object" ? item[$props.rangeKey] || "" : $options._l10nItem(item, index0)), 1); - }), 128)) - ]), - _: 2 - }, 1024); - }), 128)) - ]), - _: 1 - }, 8, ["value"])) : createCommentVNode("", true), - createVNode("div", { - ref: "select", - class: "uni-picker-select", - onWheel: _cache[7] || (_cache[7] = withModifiers(() => { - }, ["stop"])), - onTouchmove: _cache[8] || (_cache[8] = withModifiers(() => { - }, ["stop"])) - }, [ - (openBlock(true), createBlock(Fragment, null, renderList($options.rangeArray[0], (item, index2) => { - return openBlock(), createBlock("div", { - key: index2, - class: ["uni-picker-item", {selected: $data.valueArray[0] === index2}], - onClick: ($event) => { - $data.valueArray[0] = index2; - $options._change(); - } - }, toDisplayString(typeof item === "object" ? item[$props.rangeKey] || "" : item), 11, ["onClick"]); - }), 128)) - ], 544), - createVNode("div", { - style: $data.popupStyle.triangle - }, null, 4) - ], 6)) : createCommentVNode("", true) - ], 34), - createVNode("div", null, [ - renderSlot(_ctx.$slots, "default") - ]), - $options.system ? (openBlock(), createBlock("div", { - key: 0, - class: "uni-picker-system", - onMousemove: _cache[12] || (_cache[12] = (() => $options.withWebEvent($options._fixInputPosition))()) - }, [ - createVNode("input", { - ref: "input", - value: $data.valueSync, - type: $props.mode, - tabindex: "-1", - min: $props.start, - max: $props.end, - class: [$options.system, $data.popupStyle.dock], - onChange: _cache[11] || (_cache[11] = withModifiers((() => $options.withWebEvent($options._input))(), ["stop"])) - }, null, 42, ["value", "type", "min", "max"]) - ], 32)) : createCommentVNode("", true) - ], 16); -} -_sfc_main$1.render = _sfc_render$1; const UniViewJSBridge$1 = /* @__PURE__ */ extend(ViewJSBridge, { publishHandler(event, args, pageId) { UniServiceJSBridge.subscribeHandler(event, args, pageId); @@ -20726,4 +20717,4 @@ var index = /* @__PURE__ */ defineSystemComponent({ return openBlock(), createBlock("div", clazz, [loadingVNode]); } }); -export {$emit, $off, $on, $once, index$1 as AsyncErrorComponent, index as AsyncLoadingComponent, _sfc_main$2 as Audio, index$r as Button, index$q as Canvas, index$o as Checkbox, index$p as CheckboxGroup, index$3 as CoverImage, index$4 as CoverView, index$n as Editor, index$t as Form, Friction, index$m as Icon, index$l as Image, Input, index$s as Label, LayoutComponent, Map$1 as Map, MovableArea, MovableView, index$k as Navigator, index$2 as PageComponent, _sfc_main$1 as Picker, PickerView, PickerViewColumn, index$j as Progress, index$h as Radio, index$i as RadioGroup, ResizeSensor, index$g as RichText, ScrollView, Scroller, index$f as Slider, Spring, Swiper, SwiperItem, index$e as Switch, index$d as Text, index$c as Textarea, UniServiceJSBridge$1 as UniServiceJSBridge, UniViewJSBridge$1 as UniViewJSBridge, index$7 as Video, index$b as View, index$6 as WebView, addInterceptor, addPhoneContact, arrayBufferToBase64, base64ToArrayBuffer, canIUse, canvasGetImageData, canvasPutImageData, canvasToTempFilePath, chooseFile, chooseImage, chooseLocation, chooseVideo, clearStorage, clearStorageSync, closeSocket, connectSocket, createAnimation, createCameraContext, createCanvasContext, createInnerAudioContext, createIntersectionObserver, createLivePlayerContext, createMapContext, createMediaQueryObserver, createSelectorQuery, createVideoContext, cssBackdropFilter, cssConstant, cssEnv, cssVar, defineBuiltInComponent, defineSystemComponent, disableScrollBounce, downloadFile, getApp$1 as getApp, getContextInfo, getCurrentPages$1 as getCurrentPages, getFileInfo, getImageInfo, getLeftWindowStyle, getLocation, getNetworkType, getProvider, getRealPath, getRecorderManager, getRightWindowStyle, getSavedFileInfo, getSavedFileList, getScreenBrightness, getSelectedTextRange, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getTopWindowStyle, getVideoInfo, hideKeyboard, hideLeftWindow, hideLoading, hideNavigationBarLoading, hideRightWindow, hideTabBar, hideTabBarRedDot, hideToast, hideTopWindow, initScrollBounce, loadFontFace, login, makePhoneCall, navigateBack, navigateTo, offAccelerometerChange, offCompassChange, offNetworkStatusChange, offWindowResize, onAccelerometerChange, onCompassChange, onGyroscopeChange, onMemoryWarning, onNetworkStatusChange, onSocketClose, onSocketError, onSocketMessage, onSocketOpen, onTabBarMidButtonTap, onUserCaptureScreen, onWindowResize, openDocument, openLocation, pageScrollTo, index$8 as plugin, preloadPage, previewImage, promiseInterceptor, reLaunch, redirectTo, removeInterceptor, removeSavedFileInfo, removeStorage, removeStorageSync, removeTabBarBadge, request, saveFile, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, sendSocketMessage, setKeepScreenOn, setLeftWindowStyle, setNavigationBarColor, setNavigationBarTitle, setRightWindowStyle, setScreenBrightness, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setTopWindowStyle, setupApp, setupPage, showActionSheet, showLeftWindow, showLoading, showModal, showNavigationBarLoading, showRightWindow, showTabBar, showTabBarRedDot, showToast, showTopWindow, startAccelerometer, startCompass, startGyroscope, startPullDownRefresh, stopAccelerometer, stopCompass, stopGyroscope, stopPullDownRefresh, switchTab, uni$1 as uni, uniFormKey, uploadFile, upx2px, useAttrs, useBooleanAttr, useContextInfo, useCustomEvent, useNativeEvent, useOn, useScroller, useSubscribe, useTabBar, useTouchtrack, useUserAction, vibrateLong, vibrateShort, withWebEvent}; +export {$emit, $off, $on, $once, index$1 as AsyncErrorComponent, index as AsyncLoadingComponent, _sfc_main$1 as Audio, index$s as Button, index$r as Canvas, index$p as Checkbox, index$q as CheckboxGroup, index$4 as CoverImage, index$5 as CoverView, index$o as Editor, index$u as Form, Friction, index$n as Icon, index$m as Image, Input, index$t as Label, LayoutComponent, Map$1 as Map, MovableArea, MovableView, index$l as Navigator, index$2 as PageComponent, index$3 as Picker, PickerView, PickerViewColumn, index$k as Progress, index$i as Radio, index$j as RadioGroup, ResizeSensor, index$h as RichText, ScrollView, Scroller, index$g as Slider, Spring, Swiper, SwiperItem, index$f as Switch, index$e as Text, index$d as Textarea, UniServiceJSBridge$1 as UniServiceJSBridge, UniViewJSBridge$1 as UniViewJSBridge, index$8 as Video, index$c as View, index$7 as WebView, addInterceptor, addPhoneContact, arrayBufferToBase64, base64ToArrayBuffer, canIUse, canvasGetImageData, canvasPutImageData, canvasToTempFilePath, chooseFile, chooseImage, chooseLocation, chooseVideo, clearStorage, clearStorageSync, closeSocket, connectSocket, createAnimation, createCameraContext, createCanvasContext, createInnerAudioContext, createIntersectionObserver, createLivePlayerContext, createMapContext, createMediaQueryObserver, createSelectorQuery, createVideoContext, cssBackdropFilter, cssConstant, cssEnv, cssVar, defineBuiltInComponent, defineSystemComponent, disableScrollBounce, downloadFile, getApp$1 as getApp, getContextInfo, getCurrentPages$1 as getCurrentPages, getFileInfo, getImageInfo, getLeftWindowStyle, getLocation, getNetworkType, getProvider, getRealPath, getRecorderManager, getRightWindowStyle, getSavedFileInfo, getSavedFileList, getScreenBrightness, getSelectedTextRange, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getTopWindowStyle, getVideoInfo, hideKeyboard, hideLeftWindow, hideLoading, hideNavigationBarLoading, hideRightWindow, hideTabBar, hideTabBarRedDot, hideToast, hideTopWindow, initScrollBounce, loadFontFace, login, makePhoneCall, navigateBack, navigateTo, offAccelerometerChange, offCompassChange, offNetworkStatusChange, offWindowResize, onAccelerometerChange, onCompassChange, onGyroscopeChange, onMemoryWarning, onNetworkStatusChange, onSocketClose, onSocketError, onSocketMessage, onSocketOpen, onTabBarMidButtonTap, onUserCaptureScreen, onWindowResize, openDocument, openLocation, pageScrollTo, index$9 as plugin, preloadPage, previewImage, promiseInterceptor, reLaunch, redirectTo, removeInterceptor, removeSavedFileInfo, removeStorage, removeStorageSync, removeTabBarBadge, request, saveFile, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, sendSocketMessage, setKeepScreenOn, setLeftWindowStyle, setNavigationBarColor, setNavigationBarTitle, setRightWindowStyle, setScreenBrightness, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setTopWindowStyle, setupApp, setupPage, showActionSheet, showLeftWindow, showLoading, showModal, showNavigationBarLoading, showRightWindow, showTabBar, showTabBarRedDot, showToast, showTopWindow, startAccelerometer, startCompass, startGyroscope, startPullDownRefresh, stopAccelerometer, stopCompass, stopGyroscope, stopPullDownRefresh, switchTab, uni$1 as uni, uniFormKey, uploadFile, upx2px, useAttrs, useBooleanAttr, useContextInfo, useCustomEvent, useNativeEvent, useOn, useScroller, useSubscribe, useTabBar, useTouchtrack, useUserAction, vibrateLong, vibrateShort, withWebEvent}; diff --git a/packages/uni-h5/src/view/components/index.ts b/packages/uni-h5/src/view/components/index.ts index cf7499a89..84a2d33c7 100644 --- a/packages/uni-h5/src/view/components/index.ts +++ b/packages/uni-h5/src/view/components/index.ts @@ -3,6 +3,6 @@ import WebView from './web-view/index' import Map from './map/index' import CoverView from './cover-view' import CoverImage from './cover-image' -import Picker from './picker/index.vue' +import Picker from './picker/index' export { Video, WebView, Map, CoverView, CoverImage, Picker } diff --git a/packages/uni-h5/src/view/components/picker/index.tsx b/packages/uni-h5/src/view/components/picker/index.tsx new file mode 100644 index 000000000..732b88e44 --- /dev/null +++ b/packages/uni-h5/src/view/components/picker/index.tsx @@ -0,0 +1,953 @@ +import { + watch, + watchEffect, + onBeforeUnmount, + inject, + reactive, + computed, + ref, + nextTick, + renderList, + Transition, + Ref, + ExtractPropTypes, +} from 'vue' +import { + useBooleanAttr, + useCustomEvent, + withWebEvent, + PickerView, + PickerViewColumn, + UniFormCtx, + uniFormKey, + defineBuiltInComponent, + CustomEventTrigger, + EmitEvent, +} from '@dcloudio/uni-components' +import { formatDateTime } from '@dcloudio/uni-shared' +import { usePopupStyle } from '../../../helpers/usePopupStyle' +import { useKeyboard } from '../../../helpers/useKeyboard' +import { + initI18nPickerMsgsOnce, + useI18n, + onEventPrevent, + onEventStop, +} from '@dcloudio/uni-core' + +function getDefaultStartValue(props: Props) { + if (props.mode === mode.TIME) { + return '00:00' + } + if (props.mode === mode.DATE) { + const year = new Date().getFullYear() - 100 + switch (props.fields) { + case fields.YEAR: + return year.toString() + case fields.MONTH: + return year + '-01' + default: + return year + '-01-01' + } + } + return '' +} +function getDefaultEndValue(props: Props) { + if (props.mode === mode.TIME) { + return '23:59' + } + if (props.mode === mode.DATE) { + const year = new Date().getFullYear() + 100 + switch (props.fields) { + case fields.YEAR: + return year.toString() + case fields.MONTH: + return year + '-12' + default: + return year + '-12-31' + } + } + return '' +} +function getDateValueArray( + props: Props, + state: State, + valueStr?: string, + defaultValue?: string +): number[] { + const splitStr = props.mode === mode.DATE ? '-' : ':' + const array = props.mode === mode.DATE ? state.dateArray : state.timeArray + let max + if (props.mode === mode.TIME) { + max = 2 + } else { + switch (props.fields) { + case fields.YEAR: + max = 1 + break + case fields.MONTH: + max = 2 + break + default: + max = 3 + break + } + } + const inputArray = String(valueStr).split(splitStr) + let value = [] + for (let i = 0; i < max; i++) { + const val = inputArray[i] + value.push(array[i].indexOf(val)) + } + if (value.indexOf(-1) >= 0) { + value = defaultValue + ? getDateValueArray(props, state, defaultValue) + : value.map(() => 0) + } + return value +} + +const mode = { + SELECTOR: 'selector', + MULTISELECTOR: 'multiSelector', + TIME: 'time', + DATE: 'date', + // 暂不支持城市选择 + // REGION: 'region' +} +const fields = { + YEAR: 'year', + MONTH: 'month', + DAY: 'day', +} +const selectorType = { + PICKER: 'picker', + SELECT: 'select', +} + +const props = { + 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: string) { + return Object.values(mode).includes(val) + }, + }, + fields: { + type: String, + default: '', + }, + start: { + type: String, + default: (props: any) => { + return getDefaultStartValue(props) + }, + }, + end: { + type: String, + default: (props: any) => { + return getDefaultEndValue(props) + }, + }, + disabled: { + type: [Boolean, String], + default: false, + }, + selectorType: { + type: String, + default: '', + }, +} + +type HTMLRef = Ref +type Props = ExtractPropTypes +type TwoDimensionArray = [string[], string[]] +type ThreeDimensionArray = [string[], string[], string[]] +type State = { + valueSync: undefined | number | string | number[] + visible: boolean + contentVisible: boolean + popover: null | { + top: number + left: number + width: number + height: number + } + valueChangeSource: string + timeArray: [] | TwoDimensionArray + dateArray: [] | ThreeDimensionArray + valueArray: number[] + oldValueArray: number[] + isDesktop: boolean + popupStyle: { + content: Data + triangle: Data + } +} + +export default /*#__PURE__*/ defineBuiltInComponent({ + name: 'Picker', + compatConfig: { + MODE: 3, + }, + props, + emits: ['change', 'cancel', 'columnchange'], + setup(props, { emit, slots }) { + initI18nPickerMsgsOnce() + const { t } = useI18n() + + const rootRef: HTMLRef = ref(null) + const pickerRef: HTMLRef = ref(null) + const selectRef: HTMLRef = ref(null) + const inputRef: HTMLRef = ref(null) + const { state, rangeArray } = usePickerState(props) + const trigger = useCustomEvent>(rootRef, emit) + const { + system, + selectorTypeComputed, + _show, + _l10nColumn, + _l10nItem, + _input, + _fixInputPosition, + _pickerViewChange, + + _cancel, + _change, + + _resetFormData, + _getFormData, + + _createTime, + _createDate, + _setValueSync, + } = usePickerMethods( + props, + state, + trigger, + rootRef, + pickerRef, + selectRef, + inputRef + ) + usePickerWatch(state, _cancel, _change) + usePickerForm(_resetFormData, _getFormData) + + _createTime() + _createDate() + _setValueSync() + + const popup = usePopupStyle(props) + watchEffect(() => { + state.isDesktop = popup.isDesktop.value + state.popupStyle = popup.popupStyle.value + }) + + onBeforeUnmount(() => { + pickerRef.value && pickerRef.value.remove() + }) + + return () => { + const { visible, contentVisible, valueArray, popupStyle, valueSync } = + state + const { rangeKey, mode, start, end } = props + const booleanAttrs = useBooleanAttr(props, 'disabled') + + return ( + +
+ +
+ + {!system.value ? ( +
+
+
+ {t('uni.picker.cancel')} +
+
+ {t('uni.picker.done')} +
+
+ {contentVisible ? ( + + {renderList( + _l10nColumn(rangeArray.value as []), + (rangeItem, index0) => ( + + {renderList(rangeItem, (item, index) => ( +
+ {typeof item === 'object' + ? item[rangeKey] || '' + : _l10nItem(item, index0)} +
+ ))} +
+ ) + )} +
+ ) : null} +
+ {renderList(rangeArray.value[0], (item, index) => ( +
{ + valueArray[0] = index + _change() + }} + > + {typeof item === 'object' + ? (item as any)[rangeKey] || '' + : item} +
+ ))} +
+
+
+ ) : null} +
+
{slots.default && slots.default()}
+ {system.value ? ( +
+ { + _input($event) + onEventStop($event) + }} + /> +
+ ) : null} + + ) + } + }, +}) + +function usePickerState(props: Props) { + const state: State = reactive({ + valueSync: undefined, + visible: false, + contentVisible: false, + popover: null, + valueChangeSource: '', + timeArray: [], + dateArray: [], + valueArray: [], + oldValueArray: [], + isDesktop: false, + popupStyle: { + content: {}, + triangle: {}, + }, + }) + + const rangeArray = computed(() => { + let val = props.range + switch (props.mode) { + case mode.SELECTOR: + return [val] + case mode.MULTISELECTOR: + return val + case mode.TIME: + return state.timeArray + case mode.DATE: { + const dateArray = state.dateArray + switch (props.fields) { + case fields.YEAR: + return [dateArray[0]] + case fields.MONTH: + return [dateArray[0], dateArray[1]] + default: + return [dateArray[0], dateArray[1], dateArray[2]] + } + } + } + return [] + }) + + return { + state, + rangeArray, + } +} + +let __contentVisibleDelay: number +function usePickerMethods( + props: Props, + state: State, + trigger: CustomEventTrigger, + rootRef: HTMLRef, + pickerRef: HTMLRef, + selectRef: HTMLRef, + inputRef: HTMLRef +) { + const selectorTypeComputed = computed(() => { + const type = props.selectorType + if (Object.values(selectorType).includes(type)) { + return type + } + return String(navigator.vendor).indexOf('Apple') === 0 && + navigator.maxTouchPoints > 0 + ? selectorType.PICKER + : selectorType.SELECT + }) + const system = computed(() => { + if (__NODE_JS__) return '' + if ( + props.mode === mode.DATE && + !Object.values(fields).includes(props.fields) && + state.isDesktop && + /win|mac/i.test(navigator.platform) + ) { + if (navigator.vendor === 'Google Inc.') { + return 'chrome' + } else if (/Firefox/.test(navigator.userAgent)) { + return 'firefox' + } + } + return '' + }) + const startArray = computed(() => { + return getDateValueArray( + props, + state, + props.start, + getDefaultStartValue(props) + ) + }) + const endArray = computed(() => { + return getDateValueArray(props, state, props.end, getDefaultEndValue(props)) + }) + + function _show(event: MouseEvent) { + if (props.disabled) { + return + } + state.valueChangeSource = '' + let $picker = pickerRef.value! + let _currentTarget = event.currentTarget as HTMLElement + $picker.remove() + ;(document.querySelector('uni-app') || document.body).appendChild($picker) + $picker.style.display = 'block' + const rect = _currentTarget.getBoundingClientRect() + state.popover = { + top: rect.top, + left: rect.left, + width: rect.width, + height: rect.height, + } + setTimeout(() => { + state.visible = true + }, 20) + } + function _getFormData() { + return { + value: state.valueSync, + key: props.name, + } + } + function _resetFormData() { + switch (props.mode) { + case mode.SELECTOR: + state.valueSync = 0 + break + case mode.MULTISELECTOR: + state.valueSync = (props.value as []).map((val) => 0) + break + case mode.DATE: + case mode.TIME: + state.valueSync = '' + break + default: + break + } + } + function _createTime() { + let hours: string[] = [] + let minutes: string[] = [] + for (let i = 0; i < 24; i++) { + hours.push((i < 10 ? '0' : '') + i) + } + for (let i = 0; i < 60; i++) { + minutes.push((i < 10 ? '0' : '') + i) + } + ;(state.timeArray as TwoDimensionArray).push(hours, minutes) + } + function _createDate() { + let years: string[] = [] + let year = new Date().getFullYear() + for (let i = year - 150, end = year + 150; i <= end; i++) { + years.push(String(i)) + } + let months: string[] = [] + for (let i = 1; i <= 12; i++) { + months.push((i < 10 ? '0' : '') + i) + } + let days: string[] = [] + for (let i = 1; i <= 31; i++) { + days.push((i < 10 ? '0' : '') + i) + } + ;(state.dateArray as ThreeDimensionArray).push(years, months, days) + } + function _getTimeValue(val: number[]) { + return val[0] * 60 + val[1] + } + function _getDateValue(val: number[]) { + const DAY = 31 + return val[0] * DAY * 12 + (val[1] || 0) * DAY + (val[2] || 0) + } + /** + * 将右侧数组值同步到左侧(交集部分) + */ + function _cloneArray(val1: number[], val2: number[]) { + for (let i = 0; i < val1.length && i < val2.length; i++) { + val1[i] = val2[i] + } + } + function _setValueSync() { + let val = props.value + switch (props.mode) { + case mode.MULTISELECTOR: + { + if (!Array.isArray(val)) { + val = [] + } + if (!Array.isArray(state.valueSync)) { + state.valueSync = [] + } + const length = (state.valueSync.length = Math.max( + val.length, + props.range.length + )) + for (let index = 0; index < length; index++) { + const val0 = Number(val[index]) + const val1 = Number(state.valueSync[index]) + const val2 = isNaN(val0) ? (isNaN(val1) ? 0 : val1) : val0 + const maxVal = props.range[index] + ? (props.range[index] as []).length - 1 + : 0 + state.valueSync.splice( + index, + 1, + val2 < 0 || val2 > maxVal ? 0 : val2 + ) + } + } + break + case mode.TIME: + case mode.DATE: + state.valueSync = String(val) + break + default: { + const valueSync = Number(val) + state.valueSync = valueSync < 0 ? 0 : valueSync + break + } + } + } + function _setValueArray() { + let val = state.valueSync + let valueArray + switch (props.mode) { + case mode.MULTISELECTOR: + valueArray = [...(val as number[])] + break + case mode.TIME: + valueArray = getDateValueArray( + props, + state, + val as string, + formatDateTime({ + mode: mode.TIME, + }) + ) + break + case mode.DATE: + valueArray = getDateValueArray( + props, + state, + val as string, + formatDateTime({ + mode: mode.DATE, + }) + ) + break + default: + valueArray = [val] + break + } + state.oldValueArray = [...valueArray] as number[] + state.valueArray = [...valueArray] as number[] + } + function _getValue() { + let val = state.valueArray + switch (props.mode) { + case mode.SELECTOR: + return val[0] + case mode.MULTISELECTOR: + return val.map((val) => val) + case mode.TIME: + return state.valueArray + .map((val, i) => state.timeArray[i][val]) + .join(':') + case mode.DATE: + return state.valueArray + .map((val, i) => state.dateArray[i][val]) + .join('-') + } + } + function _change() { + _close() + state.valueChangeSource = 'click' + const value = _getValue() + state.valueSync = Array.isArray(value) ? value.map((val) => val) : value + trigger('change', {} as Event, { + value, + }) + } + function _cancel($event?: MouseEvent) { + if (system.value === 'firefox' && $event) { + // Firefox 在 input 同位置区域点击无法隐藏控件 + const { top, left, width, height } = state.popover! + const { pageX, pageY } = $event + if ( + pageX > left && + pageX < left + width && + pageY > top && + pageY < top + height + ) { + return + } + } + _close() + trigger('cancel', {} as Event, {}) + } + function _close() { + state.visible = false + setTimeout(() => { + let $picker = pickerRef.value! + $picker.remove() + rootRef.value!.prepend($picker) + $picker.style.display = 'none' + }, 260) + } + function _select() { + if ( + props.mode === mode.SELECTOR && + selectorTypeComputed.value === selectorType.SELECT + ) { + selectRef.value!.scrollTop = state.valueArray[0] * 34 + } + } + function _input($event: Event) { + const EventTarget = $event.target as HTMLInputElement + state.valueSync = EventTarget.value + nextTick(() => { + _change() + }) + } + function _fixInputPosition($event: MouseEvent) { + if (system.value === 'chrome') { + const rect = rootRef.value!.getBoundingClientRect() + const fontSize = 32 + inputRef.value!.style.left = `${ + $event.clientX - rect.left - fontSize * 1.5 + }px` + inputRef.value!.style.top = `${ + $event.clientY - rect.top - fontSize * 0.5 + }px` + } + } + function _pickerViewChange(event: { detail: { value: number[] } }) { + state.valueArray = _l10nColumn(event.detail.value, true) + } + function _l10nColumn(array: number[], normalize?: boolean) { + const { getLocale } = useI18n() + if (props.mode === mode.DATE) { + const locale = getLocale() + if (!locale.startsWith('zh')) { + switch (props.fields) { + case fields.YEAR: + return array + case fields.MONTH: + return [array[1], array[0]] + default: + switch (locale) { + case 'es': + case 'fr': + return [array[2], array[1], array[0]] + // case 'en': + default: + return normalize + ? [array[2], array[0], array[1]] + : [array[1], array[2], array[0]] + } + } + } + } + return array + } + function _l10nItem(item: string | number, index: number) { + const { getLocale } = useI18n() + if (props.mode === mode.DATE) { + const locale = getLocale() + if (locale.startsWith('zh')) { + const array = ['年', '月', '日'] + return item + array[index] + } else if ( + props.fields !== fields.YEAR && + index === + (props.fields !== fields.MONTH && (locale === 'es' || locale === 'fr') + ? 1 + : 0) + ) { + let array + switch (locale) { + case 'es': + array = [ + 'enero', + 'febrero', + 'marzo', + 'abril', + 'mayo', + 'junio', + '​​julio', + 'agosto', + 'septiembre', + 'octubre', + 'noviembre', + 'diciembre', + ] + break + case 'fr': + array = [ + 'janvier', + 'février', + 'mars', + 'avril', + 'mai', + 'juin', + 'juillet', + 'août', + 'septembre', + 'octobre', + 'novembre', + 'décembre', + ] + break + // case 'en': + default: + array = [ + 'January', + 'February', + 'March', + 'April', + 'May', + 'June', + 'July', + 'August', + 'September', + 'October', + 'November', + 'December', + ] + break + } + return array[Number(item) - 1] + } + } + return item + } + + watch( + () => state.visible, + (val) => { + if (val) { + clearTimeout(__contentVisibleDelay) + state.contentVisible = val + _select() + } else { + __contentVisibleDelay = setTimeout(() => { + state.contentVisible = val + }, 300) + } + } + ) + watch( + [() => props.mode, () => props.value, () => props.range], + _setValueSync, + { deep: true } + ) + watch(() => state.valueSync, _setValueArray, { deep: true }) + watch( + () => state.valueArray, + (val) => { + if (props.mode === mode.TIME || props.mode === mode.DATE) { + const getValue = + props.mode === mode.TIME ? _getTimeValue : _getDateValue + const valueArray = state.valueArray + const _startArray = startArray.value + const _endArray = endArray.value + if (props.mode === mode.DATE) { + const dateArray = state.dateArray as ThreeDimensionArray + const max = dateArray[2].length + const day = Number(dateArray[2][valueArray[2]]) || 1 + const realDay = new Date( + `${dateArray[0][valueArray[0]]}/${ + dateArray[1][valueArray[1]] + }/${day}` + ).getDate() + if (realDay < day) { + valueArray[2] -= realDay + max - day + } + } + if (getValue(valueArray) < getValue(_startArray)) { + _cloneArray(valueArray, _startArray) + } else if (getValue(valueArray) > getValue(_endArray)) { + _cloneArray(valueArray, _endArray) + } + } + val.forEach((value, column) => { + if (value !== state.oldValueArray[column]) { + state.oldValueArray[column] = value + if (props.mode === mode.MULTISELECTOR) { + trigger('columnchange', {} as Event, { + column, + value, + }) + } + } + }) + } + ) + + return { + selectorTypeComputed, + system, + _show, + _cancel, + _change, + _l10nColumn, + _l10nItem, + _input, + _resetFormData, + _getFormData, + _createTime, + _createDate, + _setValueSync, + _fixInputPosition, + _pickerViewChange, + } +} + +function usePickerWatch( + state: State, + _cancel: () => void, + _change: () => void +) { + const { key, disable } = useKeyboard() + watchEffect(() => { + disable.value = !state.visible + }) + watch(key, (value) => { + if (value === 'esc') { + _cancel() + } else if (value === 'enter') { + _change() + } + }) +} + +function usePickerForm( + _resetFormData: () => void, + _getFormData: () => { key: string; value: any } +) { + const uniForm = inject(uniFormKey, false as unknown as UniFormCtx) + if (uniForm) { + const field = { + reset: _resetFormData, + submit: () => { + const data: [string, any] = ['', null] + const { key, value } = _getFormData() + if (key !== '') { + data[0] = key + data[1] = value + } + return data + }, + } + uniForm.addField(field) + onBeforeUnmount(() => { + uniForm.removeField(field) + }) + } +} diff --git a/packages/uni-h5/src/view/components/picker/index.vue b/packages/uni-h5/src/view/components/picker/index.vue deleted file mode 100644 index 595eed755..000000000 --- a/packages/uni-h5/src/view/components/picker/index.vue +++ /dev/null @@ -1,785 +0,0 @@ - - - diff --git a/packages/uni-h5/style/picker.css b/packages/uni-h5/style/picker.css index e5c8bc65c..54ce79bad 100644 --- a/packages/uni-h5/style/picker.css +++ b/packages/uni-h5/style/picker.css @@ -127,7 +127,7 @@ uni-picker[disabled] { overflow: hidden; } -.uni-picker-system > input { +.uni-picker-system > .uni-picker-system_input { position: absolute; border: none; height: 100%; @@ -136,13 +136,13 @@ uni-picker[disabled] { cursor: pointer; } -.uni-picker-system > input.firefox { +.uni-picker-system > .uni-picker-system_input.firefox { top: 0; left: 0; width: 100%; } -.uni-picker-system > input.chrome { +.uni-picker-system > .uni-picker-system_input.chrome { /* 日历空白位置宽度 32px */ top: 0; left: 0; -- GitLab