diff --git a/package.json b/package.json index e541fa17e7232146e2eb42ef647eacc5363ea6de..f792521475743c484bbbc84e45cd08c94eb65dc0 100644 --- a/package.json +++ b/package.json @@ -50,8 +50,7 @@ "@types/puppeteer": "^5.4.2", "@typescript-eslint/parser": "^4.12.0", "@vitejs/plugin-vue": "^1.2.1", - "@vitejs/plugin-vue-jsx": "^1.1.2", - "@vue/compiler-sfc": "^3.0.10", + "@vitejs/plugin-vue-jsx": "^1.1.3", "eslint": "^7.17.0", "fs-extra": "^9.0.1", "jest": "^26.6.3", @@ -71,7 +70,7 @@ "ts-jest": "^26.4.4", "typescript": "~4.1.3", "vite": "^2.1.5", - "vue": "3.0.10", + "vue": "3.0.11", "yorkie": "^2.0.0" } } diff --git a/packages/uni-api/src/helpers/intersection-observer.js b/packages/uni-api/src/helpers/intersection-observer.js new file mode 100644 index 0000000000000000000000000000000000000000..d29e35d85b84d5d5489761ca1420c32f55705035 --- /dev/null +++ b/packages/uni-api/src/helpers/intersection-observer.js @@ -0,0 +1,1010 @@ +/** + * Copyright 2016 Google Inc. All Rights Reserved. + * + * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE. + * + * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document + * + */ +export const initIntersectionObserverPolyfill = function () { + 'use strict' + + // Exit early if we're not running in a browser. + if (typeof window !== 'object') { + return + } + + // Exit early if all IntersectionObserver and IntersectionObserverEntry + // features are natively supported. + if ( + 'IntersectionObserver' in window && + 'IntersectionObserverEntry' in window && + 'intersectionRatio' in window.IntersectionObserverEntry.prototype + ) { + // Minimal polyfill for Edge 15's lack of `isIntersecting` + // See: https://github.com/w3c/IntersectionObserver/issues/211 + if (!('isIntersecting' in window.IntersectionObserverEntry.prototype)) { + Object.defineProperty( + window.IntersectionObserverEntry.prototype, + 'isIntersecting', + { + get: function () { + return this.intersectionRatio > 0 + }, + } + ) + } + return + } + + /** + * Returns the embedding frame element, if any. + * @param {!Document} doc + * @return {!Element} + */ + function getFrameElement(doc) { + try { + return (doc.defaultView && doc.defaultView.frameElement) || null + } catch (e) { + // Ignore the error. + return null + } + } + + /** + * A local reference to the root document. + */ + var document = (function (startDoc) { + var doc = startDoc + var frame = getFrameElement(doc) + while (frame) { + doc = frame.ownerDocument + frame = getFrameElement(doc) + } + return doc + })(window.document) + + /** + * An IntersectionObserver registry. This registry exists to hold a strong + * reference to IntersectionObserver instances currently observing a target + * element. Without this registry, instances without another reference may be + * garbage collected. + */ + var registry = [] + + /** + * The signal updater for cross-origin intersection. When not null, it means + * that the polyfill is configured to work in a cross-origin mode. + * @type {function(DOMRect|ClientRect, DOMRect|ClientRect)} + */ + var crossOriginUpdater = null + + /** + * The current cross-origin intersection. Only used in the cross-origin mode. + * @type {DOMRect|ClientRect} + */ + var crossOriginRect = null + + /** + * Creates the global IntersectionObserverEntry constructor. + * https://w3c.github.io/IntersectionObserver/#intersection-observer-entry + * @param {Object} entry A dictionary of instance properties. + * @constructor + */ + function IntersectionObserverEntry(entry) { + this.time = entry.time + this.target = entry.target + this.rootBounds = ensureDOMRect(entry.rootBounds) + this.boundingClientRect = ensureDOMRect(entry.boundingClientRect) + this.intersectionRect = ensureDOMRect( + entry.intersectionRect || getEmptyRect() + ) + this.isIntersecting = !!entry.intersectionRect + + // Calculates the intersection ratio. + var targetRect = this.boundingClientRect + var targetArea = targetRect.width * targetRect.height + var intersectionRect = this.intersectionRect + var intersectionArea = intersectionRect.width * intersectionRect.height + + // Sets intersection ratio. + if (targetArea) { + // Round the intersection ratio to avoid floating point math issues: + // https://github.com/w3c/IntersectionObserver/issues/324 + this.intersectionRatio = Number( + (intersectionArea / targetArea).toFixed(4) + ) + } else { + // If area is zero and is intersecting, sets to 1, otherwise to 0 + this.intersectionRatio = this.isIntersecting ? 1 : 0 + } + } + + /** + * Creates the global IntersectionObserver constructor. + * https://w3c.github.io/IntersectionObserver/#intersection-observer-interface + * @param {Function} callback The function to be invoked after intersection + * changes have queued. The function is not invoked if the queue has + * been emptied by calling the `takeRecords` method. + * @param {Object=} opt_options Optional configuration options. + * @constructor + */ + function IntersectionObserver(callback, opt_options) { + var options = opt_options || {} + + if (typeof callback != 'function') { + throw new Error('callback must be a function') + } + + if ( + options.root && + options.root.nodeType != 1 && + options.root.nodeType != 9 + ) { + throw new Error('root must be a Document or Element') + } + + // Binds and throttles `this._checkForIntersections`. + this._checkForIntersections = throttle( + this._checkForIntersections.bind(this), + this.THROTTLE_TIMEOUT + ) + + // Private properties. + this._callback = callback + this._observationTargets = [] + this._queuedEntries = [] + this._rootMarginValues = this._parseRootMargin(options.rootMargin) + + // Public properties. + this.thresholds = this._initThresholds(options.threshold) + this.root = options.root || null + this.rootMargin = this._rootMarginValues + .map(function (margin) { + return margin.value + margin.unit + }) + .join(' ') + + /** @private @const {!Array} */ + this._monitoringDocuments = [] + /** @private @const {!Array} */ + this._monitoringUnsubscribes = [] + } + + /** + * The minimum interval within which the document will be checked for + * intersection changes. + */ + IntersectionObserver.prototype.THROTTLE_TIMEOUT = 100 + + /** + * The frequency in which the polyfill polls for intersection changes. + * this can be updated on a per instance basis and must be set prior to + * calling `observe` on the first target. + */ + IntersectionObserver.prototype.POLL_INTERVAL = null + + /** + * Use a mutation observer on the root element + * to detect intersection changes. + */ + IntersectionObserver.prototype.USE_MUTATION_OBSERVER = true + + /** + * Sets up the polyfill in the cross-origin mode. The result is the + * updater function that accepts two arguments: `boundingClientRect` and + * `intersectionRect` - just as these fields would be available to the + * parent via `IntersectionObserverEntry`. This function should be called + * each time the iframe receives intersection information from the parent + * window, e.g. via messaging. + * @return {function(DOMRect|ClientRect, DOMRect|ClientRect)} + */ + IntersectionObserver._setupCrossOriginUpdater = function () { + if (!crossOriginUpdater) { + /** + * @param {DOMRect|ClientRect} boundingClientRect + * @param {DOMRect|ClientRect} intersectionRect + */ + crossOriginUpdater = function (boundingClientRect, intersectionRect) { + if (!boundingClientRect || !intersectionRect) { + crossOriginRect = getEmptyRect() + } else { + crossOriginRect = convertFromParentRect( + boundingClientRect, + intersectionRect + ) + } + registry.forEach(function (observer) { + observer._checkForIntersections() + }) + } + } + return crossOriginUpdater + } + + /** + * Resets the cross-origin mode. + */ + IntersectionObserver._resetCrossOriginUpdater = function () { + crossOriginUpdater = null + crossOriginRect = null + } + + /** + * Starts observing a target element for intersection changes based on + * the thresholds values. + * @param {Element} target The DOM element to observe. + */ + IntersectionObserver.prototype.observe = function (target) { + var isTargetAlreadyObserved = this._observationTargets.some(function ( + item + ) { + return item.element == target + }) + + if (isTargetAlreadyObserved) { + return + } + + if (!(target && target.nodeType == 1)) { + throw new Error('target must be an Element') + } + + this._registerInstance() + this._observationTargets.push({ element: target, entry: null }) + this._monitorIntersections(target.ownerDocument) + this._checkForIntersections() + } + + /** + * Stops observing a target element for intersection changes. + * @param {Element} target The DOM element to observe. + */ + IntersectionObserver.prototype.unobserve = function (target) { + this._observationTargets = this._observationTargets.filter(function (item) { + return item.element != target + }) + this._unmonitorIntersections(target.ownerDocument) + if (this._observationTargets.length == 0) { + this._unregisterInstance() + } + } + + /** + * Stops observing all target elements for intersection changes. + */ + IntersectionObserver.prototype.disconnect = function () { + this._observationTargets = [] + this._unmonitorAllIntersections() + this._unregisterInstance() + } + + /** + * Returns any queue entries that have not yet been reported to the + * callback and clears the queue. This can be used in conjunction with the + * callback to obtain the absolute most up-to-date intersection information. + * @return {Array} The currently queued entries. + */ + IntersectionObserver.prototype.takeRecords = function () { + var records = this._queuedEntries.slice() + this._queuedEntries = [] + return records + } + + /** + * Accepts the threshold value from the user configuration object and + * returns a sorted array of unique threshold values. If a value is not + * between 0 and 1 and error is thrown. + * @private + * @param {Array|number=} opt_threshold An optional threshold value or + * a list of threshold values, defaulting to [0]. + * @return {Array} A sorted list of unique and valid threshold values. + */ + IntersectionObserver.prototype._initThresholds = function (opt_threshold) { + var threshold = opt_threshold || [0] + if (!Array.isArray(threshold)) threshold = [threshold] + + return threshold.sort().filter(function (t, i, a) { + if (typeof t != 'number' || isNaN(t) || t < 0 || t > 1) { + throw new Error( + 'threshold must be a number between 0 and 1 inclusively' + ) + } + return t !== a[i - 1] + }) + } + + /** + * Accepts the rootMargin value from the user configuration object + * and returns an array of the four margin values as an object containing + * the value and unit properties. If any of the values are not properly + * formatted or use a unit other than px or %, and error is thrown. + * @private + * @param {string=} opt_rootMargin An optional rootMargin value, + * defaulting to '0px'. + * @return {Array} An array of margin objects with the keys + * value and unit. + */ + IntersectionObserver.prototype._parseRootMargin = function (opt_rootMargin) { + var marginString = opt_rootMargin || '0px' + var margins = marginString.split(/\s+/).map(function (margin) { + var parts = /^(-?\d*\.?\d+)(px|%)$/.exec(margin) + if (!parts) { + throw new Error('rootMargin must be specified in pixels or percent') + } + return { value: parseFloat(parts[1]), unit: parts[2] } + }) + + // Handles shorthand. + margins[1] = margins[1] || margins[0] + margins[2] = margins[2] || margins[0] + margins[3] = margins[3] || margins[1] + + return margins + } + + /** + * Starts polling for intersection changes if the polling is not already + * happening, and if the page's visibility state is visible. + * @param {!Document} doc + * @private + */ + IntersectionObserver.prototype._monitorIntersections = function (doc) { + var win = doc.defaultView + if (!win) { + // Already destroyed. + return + } + if (this._monitoringDocuments.indexOf(doc) != -1) { + // Already monitoring. + return + } + + // Private state for monitoring. + var callback = this._checkForIntersections + var monitoringInterval = null + var domObserver = null + + // If a poll interval is set, use polling instead of listening to + // resize and scroll events or DOM mutations. + if (this.POLL_INTERVAL) { + monitoringInterval = win.setInterval(callback, this.POLL_INTERVAL) + } else { + addEvent(win, 'resize', callback, true) + addEvent(doc, 'scroll', callback, true) + if (this.USE_MUTATION_OBSERVER && 'MutationObserver' in win) { + domObserver = new win.MutationObserver(callback) + domObserver.observe(doc, { + attributes: true, + childList: true, + characterData: true, + subtree: true, + }) + } + } + + this._monitoringDocuments.push(doc) + this._monitoringUnsubscribes.push(function () { + // Get the window object again. When a friendly iframe is destroyed, it + // will be null. + var win = doc.defaultView + + if (win) { + if (monitoringInterval) { + win.clearInterval(monitoringInterval) + } + removeEvent(win, 'resize', callback, true) + } + + removeEvent(doc, 'scroll', callback, true) + if (domObserver) { + domObserver.disconnect() + } + }) + + // Also monitor the parent. + var rootDoc = + (this.root && (this.root.ownerDocument || this.root)) || document + if (doc != rootDoc) { + var frame = getFrameElement(doc) + if (frame) { + this._monitorIntersections(frame.ownerDocument) + } + } + } + + /** + * Stops polling for intersection changes. + * @param {!Document} doc + * @private + */ + IntersectionObserver.prototype._unmonitorIntersections = function (doc) { + var index = this._monitoringDocuments.indexOf(doc) + if (index == -1) { + return + } + + var rootDoc = + (this.root && (this.root.ownerDocument || this.root)) || document + + // Check if any dependent targets are still remaining. + var hasDependentTargets = this._observationTargets.some(function (item) { + var itemDoc = item.element.ownerDocument + // Target is in this context. + if (itemDoc == doc) { + return true + } + // Target is nested in this context. + while (itemDoc && itemDoc != rootDoc) { + var frame = getFrameElement(itemDoc) + itemDoc = frame && frame.ownerDocument + if (itemDoc == doc) { + return true + } + } + return false + }) + if (hasDependentTargets) { + return + } + + // Unsubscribe. + var unsubscribe = this._monitoringUnsubscribes[index] + this._monitoringDocuments.splice(index, 1) + this._monitoringUnsubscribes.splice(index, 1) + unsubscribe() + + // Also unmonitor the parent. + if (doc != rootDoc) { + var frame = getFrameElement(doc) + if (frame) { + this._unmonitorIntersections(frame.ownerDocument) + } + } + } + + /** + * Stops polling for intersection changes. + * @param {!Document} doc + * @private + */ + IntersectionObserver.prototype._unmonitorAllIntersections = function () { + var unsubscribes = this._monitoringUnsubscribes.slice(0) + this._monitoringDocuments.length = 0 + this._monitoringUnsubscribes.length = 0 + for (var i = 0; i < unsubscribes.length; i++) { + unsubscribes[i]() + } + } + + /** + * Scans each observation target for intersection changes and adds them + * to the internal entries queue. If new entries are found, it + * schedules the callback to be invoked. + * @private + */ + IntersectionObserver.prototype._checkForIntersections = function () { + if (!this.root && crossOriginUpdater && !crossOriginRect) { + // Cross origin monitoring, but no initial data available yet. + return + } + + var rootIsInDom = this._rootIsInDom() + var rootRect = rootIsInDom ? this._getRootRect() : getEmptyRect() + + this._observationTargets.forEach(function (item) { + var target = item.element + var targetRect = getBoundingClientRect(target) + var rootContainsTarget = this._rootContainsTarget(target) + var oldEntry = item.entry + var intersectionRect = + rootIsInDom && + rootContainsTarget && + this._computeTargetAndRootIntersection(target, targetRect, rootRect) + + var rootBounds = null + if (!this._rootContainsTarget(target)) { + rootBounds = getEmptyRect() + } else if (!crossOriginUpdater || this.root) { + rootBounds = rootRect + } + + var newEntry = (item.entry = new IntersectionObserverEntry({ + time: now(), + target: target, + boundingClientRect: targetRect, + rootBounds: rootBounds, + intersectionRect: intersectionRect, + })) + + if (!oldEntry) { + this._queuedEntries.push(newEntry) + } else if (rootIsInDom && rootContainsTarget) { + // If the new entry intersection ratio has crossed any of the + // thresholds, add a new entry. + if (this._hasCrossedThreshold(oldEntry, newEntry)) { + this._queuedEntries.push(newEntry) + } + } else { + // If the root is not in the DOM or target is not contained within + // root but the previous entry for this target had an intersection, + // add a new record indicating removal. + if (oldEntry && oldEntry.isIntersecting) { + this._queuedEntries.push(newEntry) + } + } + }, this) + + if (this._queuedEntries.length) { + this._callback(this.takeRecords(), this) + } + } + + /** + * Accepts a target and root rect computes the intersection between then + * following the algorithm in the spec. + * TODO(philipwalton): at this time clip-path is not considered. + * https://w3c.github.io/IntersectionObserver/#calculate-intersection-rect-algo + * @param {Element} target The target DOM element + * @param {Object} targetRect The bounding rect of the target. + * @param {Object} rootRect The bounding rect of the root after being + * expanded by the rootMargin value. + * @return {?Object} The final intersection rect object or undefined if no + * intersection is found. + * @private + */ + IntersectionObserver.prototype._computeTargetAndRootIntersection = function ( + target, + targetRect, + rootRect + ) { + // If the element isn't displayed, an intersection can't happen. + if (window.getComputedStyle(target).display == 'none') return + + var intersectionRect = targetRect + var parent = getParentNode(target) + var atRoot = false + + while (!atRoot && parent) { + var parentRect = null + var parentComputedStyle = + parent.nodeType == 1 ? window.getComputedStyle(parent) : {} + + // If the parent isn't displayed, an intersection can't happen. + if (parentComputedStyle.display == 'none') return null + + if (parent == this.root || parent.nodeType == /* DOCUMENT */ 9) { + atRoot = true + if (parent == this.root || parent == document) { + if (crossOriginUpdater && !this.root) { + if ( + !crossOriginRect || + (crossOriginRect.width == 0 && crossOriginRect.height == 0) + ) { + // A 0-size cross-origin intersection means no-intersection. + parent = null + parentRect = null + intersectionRect = null + } else { + parentRect = crossOriginRect + } + } else { + parentRect = rootRect + } + } else { + // Check if there's a frame that can be navigated to. + var frame = getParentNode(parent) + var frameRect = frame && getBoundingClientRect(frame) + var frameIntersect = + frame && + this._computeTargetAndRootIntersection(frame, frameRect, rootRect) + if (frameRect && frameIntersect) { + parent = frame + parentRect = convertFromParentRect(frameRect, frameIntersect) + } else { + parent = null + intersectionRect = null + } + } + } else { + // If the element has a non-visible overflow, and it's not the + // or element, update the intersection rect. + // Note: and cannot be clipped to a rect that's not also + // the document rect, so no need to compute a new intersection. + var doc = parent.ownerDocument + if ( + parent != doc.body && + parent != doc.documentElement && + parentComputedStyle.overflow != 'visible' + ) { + parentRect = getBoundingClientRect(parent) + } + } + + // If either of the above conditionals set a new parentRect, + // calculate new intersection data. + if (parentRect) { + intersectionRect = computeRectIntersection(parentRect, intersectionRect) + } + if (!intersectionRect) break + parent = parent && getParentNode(parent) + } + return intersectionRect + } + + /** + * Returns the root rect after being expanded by the rootMargin value. + * @return {ClientRect} The expanded root rect. + * @private + */ + IntersectionObserver.prototype._getRootRect = function () { + var rootRect + if (this.root && !isDoc(this.root)) { + rootRect = getBoundingClientRect(this.root) + } else { + // Use / instead of window since scroll bars affect size. + var doc = isDoc(this.root) ? this.root : document + var html = doc.documentElement + var body = doc.body + rootRect = { + top: 0, + left: 0, + right: html.clientWidth || body.clientWidth, + width: html.clientWidth || body.clientWidth, + bottom: html.clientHeight || body.clientHeight, + height: html.clientHeight || body.clientHeight, + } + } + return this._expandRectByRootMargin(rootRect) + } + + /** + * Accepts a rect and expands it by the rootMargin value. + * @param {DOMRect|ClientRect} rect The rect object to expand. + * @return {ClientRect} The expanded rect. + * @private + */ + IntersectionObserver.prototype._expandRectByRootMargin = function (rect) { + var margins = this._rootMarginValues.map(function (margin, i) { + return margin.unit == 'px' + ? margin.value + : (margin.value * (i % 2 ? rect.width : rect.height)) / 100 + }) + var newRect = { + top: rect.top - margins[0], + right: rect.right + margins[1], + bottom: rect.bottom + margins[2], + left: rect.left - margins[3], + } + newRect.width = newRect.right - newRect.left + newRect.height = newRect.bottom - newRect.top + + return newRect + } + + /** + * Accepts an old and new entry and returns true if at least one of the + * threshold values has been crossed. + * @param {?IntersectionObserverEntry} oldEntry The previous entry for a + * particular target element or null if no previous entry exists. + * @param {IntersectionObserverEntry} newEntry The current entry for a + * particular target element. + * @return {boolean} Returns true if a any threshold has been crossed. + * @private + */ + IntersectionObserver.prototype._hasCrossedThreshold = function ( + oldEntry, + newEntry + ) { + // To make comparing easier, an entry that has a ratio of 0 + // but does not actually intersect is given a value of -1 + var oldRatio = + oldEntry && oldEntry.isIntersecting ? oldEntry.intersectionRatio || 0 : -1 + var newRatio = newEntry.isIntersecting + ? newEntry.intersectionRatio || 0 + : -1 + + // Ignore unchanged ratios + if (oldRatio === newRatio) return + + for (var i = 0; i < this.thresholds.length; i++) { + var threshold = this.thresholds[i] + + // Return true if an entry matches a threshold or if the new ratio + // and the old ratio are on the opposite sides of a threshold. + if ( + threshold == oldRatio || + threshold == newRatio || + threshold < oldRatio !== threshold < newRatio + ) { + return true + } + } + } + + /** + * Returns whether or not the root element is an element and is in the DOM. + * @return {boolean} True if the root element is an element and is in the DOM. + * @private + */ + IntersectionObserver.prototype._rootIsInDom = function () { + return !this.root || containsDeep(document, this.root) + } + + /** + * Returns whether or not the target element is a child of root. + * @param {Element} target The target element to check. + * @return {boolean} True if the target element is a child of root. + * @private + */ + IntersectionObserver.prototype._rootContainsTarget = function (target) { + var rootDoc = + (this.root && (this.root.ownerDocument || this.root)) || document + return ( + containsDeep(rootDoc, target) && + (!this.root || rootDoc == target.ownerDocument) + ) + } + + /** + * Adds the instance to the global IntersectionObserver registry if it isn't + * already present. + * @private + */ + IntersectionObserver.prototype._registerInstance = function () { + if (registry.indexOf(this) < 0) { + registry.push(this) + } + } + + /** + * Removes the instance from the global IntersectionObserver registry. + * @private + */ + IntersectionObserver.prototype._unregisterInstance = function () { + var index = registry.indexOf(this) + if (index != -1) registry.splice(index, 1) + } + + /** + * Returns the result of the performance.now() method or null in browsers + * that don't support the API. + * @return {number} The elapsed time since the page was requested. + */ + function now() { + return window.performance && performance.now && performance.now() + } + + /** + * Throttles a function and delays its execution, so it's only called at most + * once within a given time period. + * @param {Function} fn The function to throttle. + * @param {number} timeout The amount of time that must pass before the + * function can be called again. + * @return {Function} The throttled function. + */ + function throttle(fn, timeout) { + var timer = null + return function () { + if (!timer) { + timer = setTimeout(function () { + fn() + timer = null + }, timeout) + } + } + } + + /** + * Adds an event handler to a DOM node ensuring cross-browser compatibility. + * @param {Node} node The DOM node to add the event handler to. + * @param {string} event The event name. + * @param {Function} fn The event handler to add. + * @param {boolean} opt_useCapture Optionally adds the even to the capture + * phase. Note: this only works in modern browsers. + */ + function addEvent(node, event, fn, opt_useCapture) { + if (typeof node.addEventListener == 'function') { + node.addEventListener(event, fn, opt_useCapture || false) + } else if (typeof node.attachEvent == 'function') { + node.attachEvent('on' + event, fn) + } + } + + /** + * Removes a previously added event handler from a DOM node. + * @param {Node} node The DOM node to remove the event handler from. + * @param {string} event The event name. + * @param {Function} fn The event handler to remove. + * @param {boolean} opt_useCapture If the event handler was added with this + * flag set to true, it should be set to true here in order to remove it. + */ + function removeEvent(node, event, fn, opt_useCapture) { + if (typeof node.removeEventListener == 'function') { + node.removeEventListener(event, fn, opt_useCapture || false) + } else if (typeof node.detatchEvent == 'function') { + node.detatchEvent('on' + event, fn) + } + } + + /** + * Returns the intersection between two rect objects. + * @param {Object} rect1 The first rect. + * @param {Object} rect2 The second rect. + * @return {?Object|?ClientRect} The intersection rect or undefined if no + * intersection is found. + */ + function computeRectIntersection(rect1, rect2) { + var top = Math.max(rect1.top, rect2.top) + var bottom = Math.min(rect1.bottom, rect2.bottom) + var left = Math.max(rect1.left, rect2.left) + var right = Math.min(rect1.right, rect2.right) + var width = right - left + var height = bottom - top + + return ( + (width >= 0 && + height >= 0 && { + top: top, + bottom: bottom, + left: left, + right: right, + width: width, + height: height, + }) || + null + ) + } + + /** + * Shims the native getBoundingClientRect for compatibility with older IE. + * @param {Element} el The element whose bounding rect to get. + * @return {DOMRect|ClientRect} The (possibly shimmed) rect of the element. + */ + function getBoundingClientRect(el) { + var rect + + try { + rect = el.getBoundingClientRect() + } catch (err) { + // Ignore Windows 7 IE11 "Unspecified error" + // https://github.com/w3c/IntersectionObserver/pull/205 + } + + if (!rect) return getEmptyRect() + + // Older IE + if (!(rect.width && rect.height)) { + rect = { + top: rect.top, + right: rect.right, + bottom: rect.bottom, + left: rect.left, + width: rect.right - rect.left, + height: rect.bottom - rect.top, + } + } + return rect + } + + /** + * Returns an empty rect object. An empty rect is returned when an element + * is not in the DOM. + * @return {ClientRect} The empty rect. + */ + function getEmptyRect() { + return { + top: 0, + bottom: 0, + left: 0, + right: 0, + width: 0, + height: 0, + } + } + + /** + * Ensure that the result has all of the necessary fields of the DOMRect. + * Specifically this ensures that `x` and `y` fields are set. + * + * @param {?DOMRect|?ClientRect} rect + * @return {?DOMRect} + */ + function ensureDOMRect(rect) { + // A `DOMRect` object has `x` and `y` fields. + if (!rect || 'x' in rect) { + return rect + } + // A IE's `ClientRect` type does not have `x` and `y`. The same is the case + // for internally calculated Rect objects. For the purposes of + // `IntersectionObserver`, it's sufficient to simply mirror `left` and `top` + // for these fields. + return { + top: rect.top, + y: rect.top, + bottom: rect.bottom, + left: rect.left, + x: rect.left, + right: rect.right, + width: rect.width, + height: rect.height, + } + } + + /** + * Inverts the intersection and bounding rect from the parent (frame) BCR to + * the local BCR space. + * @param {DOMRect|ClientRect} parentBoundingRect The parent's bound client rect. + * @param {DOMRect|ClientRect} parentIntersectionRect The parent's own intersection rect. + * @return {ClientRect} The local root bounding rect for the parent's children. + */ + function convertFromParentRect(parentBoundingRect, parentIntersectionRect) { + var top = parentIntersectionRect.top - parentBoundingRect.top + var left = parentIntersectionRect.left - parentBoundingRect.left + return { + top: top, + left: left, + height: parentIntersectionRect.height, + width: parentIntersectionRect.width, + bottom: top + parentIntersectionRect.height, + right: left + parentIntersectionRect.width, + } + } + + /** + * Checks to see if a parent element contains a child element (including inside + * shadow DOM). + * @param {Node} parent The parent element. + * @param {Node} child The child element. + * @return {boolean} True if the parent node contains the child node. + */ + function containsDeep(parent, child) { + var node = child + while (node) { + if (node == parent) return true + + node = getParentNode(node) + } + return false + } + + /** + * Gets the parent node of an element or its host element if the parent node + * is a shadow root. + * @param {Node} node The node whose parent to get. + * @return {Node|null} The parent node or null if no parent exists. + */ + function getParentNode(node) { + var parent = node.parentNode + + if (node.nodeType == /* DOCUMENT */ 9 && node != document) { + // If this node is a document node, look for the embedding frame. + return getFrameElement(node) + } + + // If the parent has element that is assigned through shadow root slot + if (parent && parent.assignedSlot) { + parent = parent.assignedSlot.parentNode + } + + if (parent && parent.nodeType == 11 && parent.host) { + // If the parent is a shadow root, return the host element. + return parent.host + } + + return parent + } + + /** + * Returns true if `node` is a Document. + * @param {!Node} node + * @returns {boolean} + */ + function isDoc(node) { + return node && node.nodeType === 9 + } + + // Exposes the constructors globally. + window.IntersectionObserver = IntersectionObserver + window.IntersectionObserverEntry = IntersectionObserverEntry +} diff --git a/packages/uni-api/src/helpers/requestComponentObserver.ts b/packages/uni-api/src/helpers/requestComponentObserver.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc0c6c8bc0a6219c6c9b9537bab75c692a9aede7 --- /dev/null +++ b/packages/uni-api/src/helpers/requestComponentObserver.ts @@ -0,0 +1,70 @@ +import { initIntersectionObserverPolyfill } from './intersection-observer' + +export interface RequestComponentObserverOptions { + selector?: string + rootMargin?: string + relativeToSelector?: string +} + +function normalizeRect(rect: DOMRect) { + const { bottom, height, left, right, top, width } = rect || {} + return { + bottom, + height, + left, + right, + top, + width, + } +} + +export function requestComponentObserver( + $el: HTMLElement, + options: UniApp.CreateIntersectionObserverOptions & + RequestComponentObserverOptions, + callback: WechatMiniprogram.IntersectionObserverObserveCallback +) { + // 为了摇树优化,不直接引入该polyfill + initIntersectionObserverPolyfill() + const root = options.relativeToSelector + ? $el.querySelector(options.relativeToSelector) + : null + const intersectionObserver = new IntersectionObserver( + (entries) => { + entries.forEach((entrie) => { + callback({ + intersectionRatio: entrie.intersectionRatio, + intersectionRect: normalizeRect(entrie.intersectionRect), + boundingClientRect: normalizeRect(entrie.boundingClientRect), + relativeRect: normalizeRect(entrie.rootBounds!), + time: Date.now(), + // dataset: normalizeDataset(entrie.target), + // id: entrie.target.id, + }) + }) + }, + { + root, + rootMargin: options.rootMargin, + threshold: options.thresholds, + } + ) + if (options.observeAll) { + ;(intersectionObserver as any).USE_MUTATION_OBSERVER = true + const nodeList = $el.querySelectorAll(options.selector!) + for (let i = 0; i < nodeList.length; i++) { + intersectionObserver.observe(nodeList[i]) + } + } else { + ;(intersectionObserver as any).USE_MUTATION_OBSERVER = false + const el = $el.querySelector(options.selector!) + if (!el) { + console.warn( + `Node ${options.selector} is not found. Intersection observer will not trigger.` + ) + } else { + intersectionObserver.observe(el) + } + } + return intersectionObserver +} diff --git a/packages/uni-api/src/index.ts b/packages/uni-api/src/index.ts index a0d5141d125ea774c7b717f33b9f16aeb64b484e..2270063f47635d2070d605534f0159fcb016c8b9 100644 --- a/packages/uni-api/src/index.ts +++ b/packages/uni-api/src/index.ts @@ -38,3 +38,4 @@ export { getCurrentPageVm } from './helpers/utils' export { handlePromise } from './helpers/api/promise' export { invokeApi, wrapperReturnValue } from './helpers/interceptor' +export { requestComponentObserver } from './helpers/requestComponentObserver' diff --git a/packages/uni-api/src/service/ui/createIntersectionObserver.ts b/packages/uni-api/src/service/ui/createIntersectionObserver.ts index 39c7ae3ffcabec0188e845b308e83a72aa263b2d..560f03cb55e05d583f5fb7503722b1c0e3938612 100644 --- a/packages/uni-api/src/service/ui/createIntersectionObserver.ts +++ b/packages/uni-api/src/service/ui/createIntersectionObserver.ts @@ -1,130 +1,107 @@ -import { extend } from '@vue/shared' - +import { ComponentPublicInstance } from 'vue' +import { extend, isFunction } from '@vue/shared' +import { + addIntersectionObserver, + removeIntersectionObserver, +} from '@dcloudio/uni-platform' import { defineSyncApi } from '../../helpers/api' import { getCurrentPageVm } from '../../helpers/utils' +import { RequestComponentObserverOptions } from '../../helpers/requestComponentObserver' -const defaultOptions = { - thresholds: [0], - initialRatio: 0, - observeAll: false, -} - -interface Margins { - bottom?: number - left?: number - right?: number - top?: number -} - -interface RelativeInfo { - selector: string - margins: Margins +export interface AddIntersectionObserverArgs { + reqId: number + component: ComponentPublicInstance + options: ServiceIntersectionObserverOptions + callback: WechatMiniprogram.IntersectionObserverObserveCallback } -type ObserveResultCallback = (result: UniApp.ObserveResult) => void - -interface requestComponentObserver { +export interface RemoveIntersectionObserverArgs { reqId: number - reqEnd: boolean - res: UniApp.ObserveResult + component: ComponentPublicInstance } -let reqComponentObserverId = 1 +type ServiceIntersectionObserverOptions = UniApp.CreateIntersectionObserverOptions & + RequestComponentObserverOptions -const reqComponentObserverCallbacks: Record = {} +const defaultOptions = { + thresholds: [0], + initialRatio: 0, + observeAll: false, +} -export const API_CREATE_INTERSECTION_OBSERVER = 'createIntersectionObserver' +const MARGINS = ['top', 'right', 'bottom', 'left'] -UniServiceJSBridge.subscribe( - 'requestComponentObserver', - ({ reqId, reqEnd, res }: requestComponentObserver) => { - const callback = reqComponentObserverCallbacks[reqId] - if (callback) { - if (reqEnd) { - return delete reqComponentObserverCallbacks[reqId] - } - callback(res) - } - } -) +let reqComponentObserverId = 1 +function normalizeRootMargin(margins: WechatMiniprogram.Margins = {}) { + return MARGINS.map( + (name) => + `${Number(margins[name as keyof WechatMiniprogram.Margins]) || 0}px` + ).join(' ') +} class ServiceIntersectionObserver { private _reqId?: number - private _options: UniApp.CreateIntersectionObserverOptions - private _component: any private _pageId: number - - private _relativeInfo: RelativeInfo[] - + private _component: ComponentPublicInstance + private _options: ServiceIntersectionObserverOptions constructor( - component: any, + component: ComponentPublicInstance, options: UniApp.CreateIntersectionObserverOptions ) { - this._pageId = component.$page.id - this._component = component._$id || component // app-plus 平台传输_$id - this._options = extend({}, defaultOptions, options || {}) - this._relativeInfo = [] + this._pageId = component.$page && component.$page.id + this._component = component + this._options = extend({}, defaultOptions, options) } - relativeTo(selector: string, margins: Margins) { - if (this._reqId) { - throw new Error( - 'Relative nodes cannot be added after "observe" call in IntersectionObserver' - ) - } - this._relativeInfo.push({ - selector, - margins, - }) + relativeTo(selector: string, margins?: WechatMiniprogram.Margins) { + this._options.relativeToSelector = selector + this._options.rootMargin = normalizeRootMargin(margins) return this } - relativeToViewport(margins: Margins) { - return this.relativeTo((null as unknown) as string, margins) + relativeToViewport(margins?: WechatMiniprogram.Margins) { + this._options.relativeToSelector = undefined + this._options.rootMargin = normalizeRootMargin(margins) + return this } - observe(selector: string, callback: ObserveResultCallback) { - if (typeof callback !== 'function') { + observe( + selector: string, + callback: WechatMiniprogram.IntersectionObserverObserveCallback + ) { + if (!isFunction(callback)) { return } - if (this._reqId) { - throw new Error( - '"observe" call can be only called once in IntersectionObserver' - ) - } - + this._options.selector = selector this._reqId = reqComponentObserverId++ - reqComponentObserverCallbacks[this._reqId] = callback - - UniServiceJSBridge.publishHandler( - 'addIntersectionObserver', + addIntersectionObserver( { - selector, reqId: this._reqId, component: this._component, options: this._options, - relativeInfo: this._relativeInfo, + callback, }, this._pageId ) } disconnect() { - UniServiceJSBridge.publishHandler( - 'removeIntersectionObserver', - { - reqId: this._reqId, - }, - this._pageId - ) + this._reqId && + removeIntersectionObserver( + { reqId: this._reqId, component: this._component }, + this._pageId + ) } } - export const createIntersectionObserver = defineSyncApi< typeof uni.createIntersectionObserver ->(API_CREATE_INTERSECTION_OBSERVER, (context?, options?) => { - if (!context) { - context = getCurrentPageVm() +>('createIntersectionObserver', (context?, options?) => { + if (context && !context.$page) { + options = context + context = null + } + if (context) { + return new ServiceIntersectionObserver(context, options) } - return new ServiceIntersectionObserver(context, options) + return new ServiceIntersectionObserver(getCurrentPageVm(), options) }) diff --git a/packages/uni-components/src/components/scroll-view/index.vue b/packages/uni-components/src/components/scroll-view/index.vue index a426ce02851c2782fe086cd7deac0b9837bf996b..088d846e7c235942dd308101b19d97b3989a19dc 100644 --- a/packages/uni-components/src/components/scroll-view/index.vue +++ b/packages/uni-components/src/components/scroll-view/index.vue @@ -19,10 +19,7 @@ }" class="uni-scroll-view-refresher" > -
+
- + \ No newline at end of file diff --git a/packages/uni-core/package.json b/packages/uni-core/package.json index 4618ddd43d3e0d4571cd90d67e7e785d35ffae79..77d773ffcc6ab31f6fe9960ab55540807d35bbc8 100644 --- a/packages/uni-core/package.json +++ b/packages/uni-core/package.json @@ -1,13 +1,13 @@ { "private": true, - "name": "@dcloudio/uni-view", + "name": "@dcloudio/uni-core", "version": "3.0.0", - "description": "@dcloudio/uni-view", + "description": "@dcloudio/uni-core", "sideEffects": false, "repository": { "type": "git", "url": "git+https://github.com/dcloudio/uni-app.git", - "directory": "packages/uni-view" + "directory": "packages/uni-core" }, "license": "Apache-2.0", "bugs": { diff --git a/packages/uni-core/src/view/helpers/getWindowOffset.ts b/packages/uni-core/src/helpers/getWindowOffset.ts similarity index 100% rename from packages/uni-core/src/view/helpers/getWindowOffset.ts rename to packages/uni-core/src/helpers/getWindowOffset.ts diff --git a/packages/uni-core/src/helpers/index.ts b/packages/uni-core/src/helpers/index.ts index 8e17bd05715028bb82d819d3d86dbbbcc2b90a59..44af56a36823079db8c8a15866f2c6f5aeb5ac07 100644 --- a/packages/uni-core/src/helpers/index.ts +++ b/packages/uni-core/src/helpers/index.ts @@ -1,3 +1,4 @@ export * from './util' export * from './icon' export * from './getRealRoute' +export * from './getWindowOffset' diff --git a/packages/uni-core/src/view/index.ts b/packages/uni-core/src/view/index.ts index a7cdbe24db23a496b817a60f5d53935e99be9443..f0352f23d7fb7c45f59a99fac126075fe2ce1ce9 100644 --- a/packages/uni-core/src/view/index.ts +++ b/packages/uni-core/src/view/index.ts @@ -1,3 +1,2 @@ export * from './bridge' export * from './plugin' -export { getWindowOffset } from './helpers/getWindowOffset' diff --git a/packages/uni-core/src/view/plugin/componentEvents.ts b/packages/uni-core/src/view/plugin/componentEvents.ts index f0fe81e97d60784cb32d987452009661fd50ea6b..b5a0aa02182f5b6289850c9965a21cbed17f98a2 100644 --- a/packages/uni-core/src/view/plugin/componentEvents.ts +++ b/packages/uni-core/src/view/plugin/componentEvents.ts @@ -1,6 +1,6 @@ import { extend } from '@vue/shared' -import { getWindowOffset } from '../helpers/getWindowOffset' +import { getWindowOffset } from '../../helpers/getWindowOffset' export function findUniTarget($event: Event, $el: HTMLElement): HTMLElement { let target = $event.target as HTMLElement diff --git a/packages/uni-core/src/view/plugin/longPress.ts b/packages/uni-core/src/view/plugin/longPress.ts index e05f62447b79c0b31d67b3331f781ef9dfa275e0..e68c3b09bb12c8a1e1962b7d6dedfb5e8d76cbf2 100644 --- a/packages/uni-core/src/view/plugin/longPress.ts +++ b/packages/uni-core/src/view/plugin/longPress.ts @@ -1,7 +1,9 @@ +import { passive } from '@dcloudio/uni-shared' + const LONGPRESS_TIMEOUT = 350 const LONGPRESS_THRESHOLD = 10 -const passiveOptions = { passive: true } // TODO caniuse? +const passiveOptions = passive(true) let longPressTimer = 0 diff --git a/packages/uni-h5/dist/assets/index-de6d6907.css b/packages/uni-h5/dist/assets/index-de6d6907.css new file mode 100644 index 0000000000000000000000000000000000000000..21c83a133562b5c7e64d4dffc0f8a63c30f0ad44 --- /dev/null +++ b/packages/uni-h5/dist/assets/index-de6d6907.css @@ -0,0 +1,743 @@ + +uni-canvas { + width: 300px; + height: 150px; + display: block; + position: relative; +} +uni-canvas > canvas { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; +} + +uni-checkbox-group[hidden] { + display: none; +} +.ql-container { + display: block; + position: relative; + box-sizing: border-box; + -webkit-user-select: text; + user-select: text; + outline: none; + overflow: hidden; + width: 100%; + height: 200px; + min-height: 200px; +} +.ql-container[hidden] { + display: none; +} +.ql-container .ql-editor { + position: relative; + font-size: inherit; + line-height: inherit; + font-family: inherit; + min-height: inherit; + width: 100%; + height: 100%; + padding: 0; + overflow-x: hidden; + overflow-y: auto; + -webkit-tap-highlight-color: transparent; + -webkit-touch-callout: none; + -webkit-overflow-scrolling: touch; +} +.ql-container .ql-editor::-webkit-scrollbar { + width: 0 !important; +} +.ql-container .ql-editor.scroll-disabled { + overflow: hidden; +} +.ql-container .ql-image-overlay { + display: flex; + position: absolute; + box-sizing: border-box; + border: 1px dashed #ccc; + justify-content: center; + align-items: center; + -webkit-user-select: none; + user-select: none; +} +.ql-container .ql-image-overlay .ql-image-size { + position: absolute; + padding: 4px 8px; + text-align: center; + background-color: #fff; + color: #888; + border: 1px solid #ccc; + box-sizing: border-box; + opacity: 0.8; + right: 4px; + top: 4px; + font-size: 12px; + display: inline-block; + width: auto; +} +.ql-container .ql-image-overlay .ql-image-toolbar { + position: relative; + text-align: center; + box-sizing: border-box; + background: #000; + border-radius: 5px; + color: #fff; + font-size: 0; + min-height: 24px; + z-index: 100; +} +.ql-container .ql-image-overlay .ql-image-toolbar span { + display: inline-block; + cursor: pointer; + padding: 5px; + font-size: 12px; + border-right: 1px solid #fff; +} +.ql-container .ql-image-overlay .ql-image-toolbar span:last-child { + border-right: 0; +} +.ql-container .ql-image-overlay .ql-image-toolbar span.triangle-up { + padding: 0; + position: absolute; + top: -12px; + left: 50%; + transform: translatex(-50%); + width: 0; + height: 0; + border-width: 6px; + border-style: solid; + border-color: transparent transparent black transparent; +} +.ql-container .ql-image-overlay .ql-image-handle { + position: absolute; + height: 12px; + width: 12px; + border-radius: 50%; + border: 1px solid #ccc; + box-sizing: border-box; + background: #fff; +} +.ql-container img { + display: inline-block; + max-width: 100%; +} +.ql-clipboard p { + margin: 0; + padding: 0; +} +.ql-editor { + box-sizing: border-box; + height: 100%; + outline: none; + overflow-y: auto; + tab-size: 4; + -moz-tab-size: 4; + text-align: left; + white-space: pre-wrap; + word-wrap: break-word; +} +.ql-editor > * { + cursor: text; +} +.ql-editor p, +.ql-editor ol, +.ql-editor ul, +.ql-editor pre, +.ql-editor blockquote, +.ql-editor h1, +.ql-editor h2, +.ql-editor h3, +.ql-editor h4, +.ql-editor h5, +.ql-editor h6 { + margin: 0; + padding: 0; + counter-reset: list-1 list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9; +} +.ql-editor ol > li, +.ql-editor ul > li { + list-style-type: none; +} +.ql-editor ul > li::before { + content: '\2022'; +} +.ql-editor ul[data-checked=true], +.ql-editor ul[data-checked=false] { + pointer-events: none; +} +.ql-editor ul[data-checked=true] > li *, +.ql-editor ul[data-checked=false] > li * { + pointer-events: all; +} +.ql-editor ul[data-checked=true] > li::before, +.ql-editor ul[data-checked=false] > li::before { + color: #777; + cursor: pointer; + pointer-events: all; +} +.ql-editor ul[data-checked=true] > li::before { + content: '\2611'; +} +.ql-editor ul[data-checked=false] > li::before { + content: '\2610'; +} +.ql-editor li::before { + display: inline-block; + white-space: nowrap; + width: 2em; +} +.ql-editor ol li { + counter-reset: list-1 list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9; + counter-increment: list-0; +} +.ql-editor ol li:before { + content: counter(list-0, decimal) '. '; +} +.ql-editor ol li.ql-indent-1 { + counter-increment: list-1; +} +.ql-editor ol li.ql-indent-1:before { + content: counter(list-1, lower-alpha) '. '; +} +.ql-editor ol li.ql-indent-1 { + counter-reset: list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9; +} +.ql-editor ol li.ql-indent-2 { + counter-increment: list-2; +} +.ql-editor ol li.ql-indent-2:before { + content: counter(list-2, lower-roman) '. '; +} +.ql-editor ol li.ql-indent-2 { + counter-reset: list-3 list-4 list-5 list-6 list-7 list-8 list-9; +} +.ql-editor ol li.ql-indent-3 { + counter-increment: list-3; +} +.ql-editor ol li.ql-indent-3:before { + content: counter(list-3, decimal) '. '; +} +.ql-editor ol li.ql-indent-3 { + counter-reset: list-4 list-5 list-6 list-7 list-8 list-9; +} +.ql-editor ol li.ql-indent-4 { + counter-increment: list-4; +} +.ql-editor ol li.ql-indent-4:before { + content: counter(list-4, lower-alpha) '. '; +} +.ql-editor ol li.ql-indent-4 { + counter-reset: list-5 list-6 list-7 list-8 list-9; +} +.ql-editor ol li.ql-indent-5 { + counter-increment: list-5; +} +.ql-editor ol li.ql-indent-5:before { + content: counter(list-5, lower-roman) '. '; +} +.ql-editor ol li.ql-indent-5 { + counter-reset: list-6 list-7 list-8 list-9; +} +.ql-editor ol li.ql-indent-6 { + counter-increment: list-6; +} +.ql-editor ol li.ql-indent-6:before { + content: counter(list-6, decimal) '. '; +} +.ql-editor ol li.ql-indent-6 { + counter-reset: list-7 list-8 list-9; +} +.ql-editor ol li.ql-indent-7 { + counter-increment: list-7; +} +.ql-editor ol li.ql-indent-7:before { + content: counter(list-7, lower-alpha) '. '; +} +.ql-editor ol li.ql-indent-7 { + counter-reset: list-8 list-9; +} +.ql-editor ol li.ql-indent-8 { + counter-increment: list-8; +} +.ql-editor ol li.ql-indent-8:before { + content: counter(list-8, lower-roman) '. '; +} +.ql-editor ol li.ql-indent-8 { + counter-reset: list-9; +} +.ql-editor ol li.ql-indent-9 { + counter-increment: list-9; +} +.ql-editor ol li.ql-indent-9:before { + content: counter(list-9, decimal) '. '; +} +.ql-editor .ql-indent-1:not(.ql-direction-rtl) { + padding-left: 2em; +} +.ql-editor li.ql-indent-1:not(.ql-direction-rtl) { + padding-left: 2em; +} +.ql-editor .ql-indent-1.ql-direction-rtl.ql-align-right { + padding-right: 2em; +} +.ql-editor li.ql-indent-1.ql-direction-rtl.ql-align-right { + padding-right: 2em; +} +.ql-editor .ql-indent-2:not(.ql-direction-rtl) { + padding-left: 4em; +} +.ql-editor li.ql-indent-2:not(.ql-direction-rtl) { + padding-left: 4em; +} +.ql-editor .ql-indent-2.ql-direction-rtl.ql-align-right { + padding-right: 4em; +} +.ql-editor li.ql-indent-2.ql-direction-rtl.ql-align-right { + padding-right: 4em; +} +.ql-editor .ql-indent-3:not(.ql-direction-rtl) { + padding-left: 6em; +} +.ql-editor li.ql-indent-3:not(.ql-direction-rtl) { + padding-left: 6em; +} +.ql-editor .ql-indent-3.ql-direction-rtl.ql-align-right { + padding-right: 6em; +} +.ql-editor li.ql-indent-3.ql-direction-rtl.ql-align-right { + padding-right: 6em; +} +.ql-editor .ql-indent-4:not(.ql-direction-rtl) { + padding-left: 8em; +} +.ql-editor li.ql-indent-4:not(.ql-direction-rtl) { + padding-left: 8em; +} +.ql-editor .ql-indent-4.ql-direction-rtl.ql-align-right { + padding-right: 8em; +} +.ql-editor li.ql-indent-4.ql-direction-rtl.ql-align-right { + padding-right: 8em; +} +.ql-editor .ql-indent-5:not(.ql-direction-rtl) { + padding-left: 10em; +} +.ql-editor li.ql-indent-5:not(.ql-direction-rtl) { + padding-left: 10em; +} +.ql-editor .ql-indent-5.ql-direction-rtl.ql-align-right { + padding-right: 10em; +} +.ql-editor li.ql-indent-5.ql-direction-rtl.ql-align-right { + padding-right: 10em; +} +.ql-editor .ql-indent-6:not(.ql-direction-rtl) { + padding-left: 12em; +} +.ql-editor li.ql-indent-6:not(.ql-direction-rtl) { + padding-left: 12em; +} +.ql-editor .ql-indent-6.ql-direction-rtl.ql-align-right { + padding-right: 12em; +} +.ql-editor li.ql-indent-6.ql-direction-rtl.ql-align-right { + padding-right: 12em; +} +.ql-editor .ql-indent-7:not(.ql-direction-rtl) { + padding-left: 14em; +} +.ql-editor li.ql-indent-7:not(.ql-direction-rtl) { + padding-left: 14em; +} +.ql-editor .ql-indent-7.ql-direction-rtl.ql-align-right { + padding-right: 14em; +} +.ql-editor li.ql-indent-7.ql-direction-rtl.ql-align-right { + padding-right: 14em; +} +.ql-editor .ql-indent-8:not(.ql-direction-rtl) { + padding-left: 16em; +} +.ql-editor li.ql-indent-8:not(.ql-direction-rtl) { + padding-left: 16em; +} +.ql-editor .ql-indent-8.ql-direction-rtl.ql-align-right { + padding-right: 16em; +} +.ql-editor li.ql-indent-8.ql-direction-rtl.ql-align-right { + padding-right: 16em; +} +.ql-editor .ql-indent-9:not(.ql-direction-rtl) { + padding-left: 18em; +} +.ql-editor li.ql-indent-9:not(.ql-direction-rtl) { + padding-left: 18em; +} +.ql-editor .ql-indent-9.ql-direction-rtl.ql-align-right { + padding-right: 18em; +} +.ql-editor li.ql-indent-9.ql-direction-rtl.ql-align-right { + padding-right: 18em; +} +.ql-editor .ql-direction-rtl { + direction: rtl; + text-align: inherit; +} +.ql-editor .ql-align-center { + text-align: center; +} +.ql-editor .ql-align-justify { + text-align: justify; +} +.ql-editor .ql-align-right { + text-align: right; +} +.ql-editor.ql-blank::before { + color: rgba(0, 0, 0, 0.6); + content: attr(data-placeholder); + font-style: italic; + pointer-events: none; + position: absolute; +} +.ql-container.ql-disabled .ql-editor ul[data-checked] > li::before { + pointer-events: none; +} +.ql-clipboard { + left: -100000px; + height: 1px; + overflow-y: hidden; + position: absolute; + top: 50%; +} + + + +@keyframes once-show { +from { + top: 0; +} +} +uni-resize-sensor, +uni-resize-sensor > div { + position: absolute; + left: 0; + top: 0; + right: 0; + bottom: 0; + overflow: hidden; +} +uni-resize-sensor { + display: block; + z-index: -1; + visibility: hidden; + animation: once-show 1ms; +} +uni-resize-sensor > div > div { + position: absolute; + left: 0; + top: 0; +} +uni-resize-sensor > div:first-child > div { + width: 100000px; + height: 100000px; +} +uni-resize-sensor > div:last-child > div { + width: 200%; + height: 200%; +} + +.uni-label-pointer { + cursor: pointer; +} + +uni-movable-view { + display: inline-block; + width: 10px; + height: 10px; + top: 0px; + left: 0px; + position: absolute; + cursor: grab; +} +uni-movable-view[hidden] { + display: none; +} + +uni-radio { + -webkit-tap-highlight-color: transparent; + display: inline-block; + cursor: pointer; +} +uni-radio[hidden] { + display: none; +} +uni-radio[disabled] { + cursor: not-allowed; +} +uni-radio .uni-radio-wrapper { + display: -webkit-inline-flex; + display: inline-flex; + -webkit-align-items: center; + align-items: center; + vertical-align: middle; +} +uni-radio .uni-radio-input { + -webkit-appearance: none; + appearance: none; + margin-right: 5px; + outline: 0; + border: 1px solid #D1D1D1; + background-color: #ffffff; + border-radius: 50%; + width: 22px; + height: 22px; + position: relative; +} +uni-radio:not([disabled]) .uni-radio-input:hover { + border-color: #007aff; +} +uni-radio .uni-radio-input.uni-radio-input-checked:before { + font: normal normal normal 14px/1 "uni"; + content: "\EA08"; + color: #ffffff; + font-size: 18px; + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -48%) scale(0.73); + -webkit-transform: translate(-50%, -48%) scale(0.73); +} +uni-radio .uni-radio-input.uni-radio-input-disabled { + background-color: #E1E1E1; + border-color: #D1D1D1; +} +uni-radio .uni-radio-input.uni-radio-input-disabled:before { + color: #ADADAD; +} +uni-radio-group { + display: block; +} + +uni-radio-group[hidden] { + display: none; +} + +uni-swiper-item { + display: block; + overflow: hidden; + will-change: transform; + position: absolute; + width: 100%; + height: 100%; + cursor: grab; +} +uni-swiper-item[hidden] { + display: none; +} + +uni-switch { + -webkit-tap-highlight-color: transparent; + display: inline-block; + cursor: pointer; +} +uni-switch[hidden] { + display: none; +} +uni-switch[disabled] { + cursor: not-allowed; +} +uni-switch .uni-switch-wrapper { + display: -webkit-inline-flex; + display: inline-flex; + -webkit-align-items: center; + align-items: center; + vertical-align: middle; +} +uni-switch .uni-switch-input { + -webkit-appearance: none; + appearance: none; + position: relative; + width: 52px; + height: 32px; + margin-right: 5px; + border: 1px solid #DFDFDF; + outline: 0; + border-radius: 16px; + box-sizing: border-box; + background-color: #DFDFDF; + transition: background-color 0.1s, border 0.1s; +} +uni-switch[disabled] .uni-switch-input { + opacity: .7; +} +uni-switch .uni-switch-input:before { + content: " "; + position: absolute; + top: 0; + left: 0; + width: 50px; + height: 30px; + border-radius: 15px; + background-color: #FDFDFD; + transition: -webkit-transform 0.3s; + transition: transform 0.3s; + transition: transform 0.3s, -webkit-transform 0.3s; +} +uni-switch .uni-switch-input:after { + content: " "; + position: absolute; + top: 0; + left: 0; + width: 30px; + height: 30px; + border-radius: 15px; + background-color: #FFFFFF; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); + transition: -webkit-transform 0.3s; + transition: transform 0.3s; + transition: transform 0.3s, -webkit-transform 0.3s; +} +uni-switch .uni-switch-input.uni-switch-input-checked { + border-color: #007aff; + background-color: #007aff; +} +uni-switch .uni-switch-input.uni-switch-input-checked:before { + -webkit-transform: scale(0); + transform: scale(0); +} +uni-switch .uni-switch-input.uni-switch-input-checked:after { + -webkit-transform: translateX(20px); + transform: translateX(20px); +} +uni-switch .uni-checkbox-input { + margin-right: 5px; + -webkit-appearance: none; + appearance: none; + outline: 0; + border: 1px solid #D1D1D1; + background-color: #FFFFFF; + border-radius: 3px; + width: 22px; + height: 22px; + position: relative; + color: #007aff; +} +uni-switch:not([disabled]) .uni-checkbox-input:hover { + border-color: #007aff; +} +uni-switch .uni-checkbox-input.uni-checkbox-input-checked:before { + font: normal normal normal 14px/1 "uni"; + content: "\EA08"; + color: inherit; + font-size: 22px; + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -48%) scale(0.73); + -webkit-transform: translate(-50%, -48%) scale(0.73); +} +uni-switch .uni-checkbox-input.uni-checkbox-input-disabled { + background-color: #E1E1E1; +} +uni-switch .uni-checkbox-input.uni-checkbox-input-disabled:before { + color: #ADADAD; +} + +uni-textarea { + width: 300px; + height: 150px; + display: block; + position: relative; + font-size: 16px; + line-height: normal; + white-space: pre-wrap; + word-break: break-all; +} +uni-textarea[hidden] { + display: none; +} +.uni-textarea-wrapper, +.uni-textarea-placeholder, +.uni-textarea-line, +.uni-textarea-compute, +.uni-textarea-textarea { + outline: none; + border: none; + padding: 0; + margin: 0; + text-decoration: inherit; +} +.uni-textarea-wrapper { + display: block; + position: relative; + width: 100%; + height: 100%; +} +.uni-textarea-placeholder, +.uni-textarea-line, +.uni-textarea-compute, +.uni-textarea-textarea { + position: absolute; + width: 100%; + height: 100%; + left: 0; + top: 0; + white-space: inherit; + word-break: inherit; +} +.uni-textarea-placeholder { + color: grey; + overflow: hidden; +} +.uni-textarea-line, +.uni-textarea-compute { + visibility: hidden; + height: auto; +} +.uni-textarea-line { + width: 1em; +} +.uni-textarea-textarea { + resize: none; + background: none; + color: inherit; + opacity: 1; + -webkit-text-fill-color: currentcolor; + font: inherit; + line-height: inherit; + letter-spacing: inherit; + text-align: inherit; + text-indent: inherit; + text-transform: inherit; + text-shadow: inherit; +} +/* 用于解决 iOS textarea 内部默认边距 */ +.uni-textarea-textarea-fix-margin { + width: auto; + right: 0; + margin: 0 -3px; +} + +.uni-async-error { + position: absolute; + left: 0; + right: 0; + top: 0; + bottom: 0; + color: #999; + padding: 100px 10px; + text-align: center; +} + +.uni-async-loading { + box-sizing: border-box; + width: 100%; + padding: 50px; + text-align: center; +} +.uni-async-loading .uni-loading { + width: 30px; + height: 30px; +} diff --git a/packages/uni-h5/dist/uni-h5.esm.js b/packages/uni-h5/dist/uni-h5.esm.js index fd49f726f78cd516ce83e382deb7bb228b6b73fd..563c36a55c9dd03cb152a7e5619f9b8513ac1161 100644 --- a/packages/uni-h5/dist/uni-h5.esm.js +++ b/packages/uni-h5/dist/uni-h5.esm.js @@ -1,7 +1,7 @@ import {isFunction, extend, isPlainObject, hasOwn as hasOwn$1, hyphenate, isArray, isObject as isObject$1, capitalize, toRawType, makeMap as makeMap$1, isPromise} from "@vue/shared"; import {injectHook, createVNode, defineComponent, inject, provide, reactive, computed, nextTick, withDirectives, vShow, withCtx, openBlock, createBlock, KeepAlive, resolveDynamicComponent, resolveComponent, onMounted, ref, mergeProps, toDisplayString, toHandlers, renderSlot, createCommentVNode, withModifiers, vModelDynamic, createTextVNode, Fragment, renderList, vModelText} from "vue"; +import {passive, NAVBAR_HEIGHT, COMPONENT_NAME_PREFIX, plusReady, debounce, PRIMARY_COLOR} from "@dcloudio/uni-shared"; import {createRouter, createWebHistory, createWebHashHistory, useRoute, RouterView, isNavigationFailure} from "vue-router"; -import {NAVBAR_HEIGHT, COMPONENT_NAME_PREFIX, plusReady, debounce, PRIMARY_COLOR} from "@dcloudio/uni-shared"; function applyOptions(options, instance2, publicThis) { Object.keys(options).forEach((name) => { if (name.indexOf("on") === 0) { @@ -26,8 +26,8 @@ function callHook(name, args) { const hooks = this.$[name]; let ret; if (hooks) { - for (let i = 0; i < hooks.length; i++) { - ret = hooks[i](args); + for (let i2 = 0; i2 < hooks.length; i2++) { + ret = hooks[i2](args); } } return ret; @@ -78,10 +78,10 @@ E.prototype = { emit: function(name) { var data = [].slice.call(arguments, 1); var evtArr = ((this.e || (this.e = {}))[name] || []).slice(); - var i = 0; + var i2 = 0; var len = evtArr.length; - for (i; i < len; i++) { - evtArr[i].fn.apply(evtArr[i].ctx, data); + for (i2; i2 < len; i2++) { + evtArr[i2].fn.apply(evtArr[i2].ctx, data); } return this; }, @@ -90,9 +90,9 @@ E.prototype = { var evts = e2[name]; var liveEvents = []; if (evts && callback) { - for (var i = 0, len = evts.length; i < len; i++) { - if (evts[i].fn !== callback && evts[i].fn._ !== callback) - liveEvents.push(evts[i]); + for (var i2 = 0, len = evts.length; i2 < len; i2++) { + if (evts[i2].fn !== callback && evts[i2].fn._ !== callback) + liveEvents.push(evts[i2]); } } liveEvents.length ? e2[name] = liveEvents : delete e2[name]; @@ -119,7 +119,7 @@ function initBridge(namespace) { const ViewJSBridge = initBridge("view"); const LONGPRESS_TIMEOUT = 350; const LONGPRESS_THRESHOLD = 10; -const passiveOptions$1 = {passive: true}; +const passiveOptions$1 = passive(true); let longPressTimer = 0; function clearLongPressTimer() { if (longPressTimer) { @@ -450,8 +450,8 @@ function normalizeTouchList(touches) { if (touches && touches instanceof TouchList) { const res = []; const {top} = getWindowOffset(); - for (let i = 0; i < touches.length; i++) { - const touch = touches[i]; + for (let i2 = 0; i2 < touches.length; i2++) { + const touch = touches[i2]; res.push({ identifier: touch.identifier, pageX: touch.pageX, @@ -534,8 +534,8 @@ class ComponentDescriptor { } const descriptors = []; const els = this.$el.querySelectorAll(selector); - for (let i = 0; i < els.length; i++) { - const el = els[i]; + for (let i2 = 0; i2 < els.length; i2++) { + const el = els[i2]; el.__vue__ && descriptors.push(createComponentDescriptor(el.__vue__, false)); } return descriptors; @@ -771,13 +771,13 @@ function getRealRoute(fromRoute, toRoute) { } const toRouteArray = toRoute.split("/"); const toRouteLength = toRouteArray.length; - let i = 0; - for (; i < toRouteLength && toRouteArray[i] === ".."; i++) { + let i2 = 0; + for (; i2 < toRouteLength && toRouteArray[i2] === ".."; i2++) { } - toRouteArray.splice(0, i); + toRouteArray.splice(0, i2); toRoute = toRouteArray.join("/"); const fromRouteArray = fromRoute.length > 0 ? fromRoute.split("/") : []; - fromRouteArray.splice(fromRouteArray.length - i - 1, i + 1); + fromRouteArray.splice(fromRouteArray.length - i2 - 1, i2 + 1); return "/" + fromRouteArray.concat(toRouteArray).join("/"); } function initRouter(app) { @@ -1183,8 +1183,8 @@ var index$3 = { function broadcast(componentName, eventName, ...params) { const children = this.$children; const len = children.length; - for (let i = 0; i < len; i++) { - const child = children[i]; + for (let i2 = 0; i2 < len; i2++) { + const child = children[i2]; const name = child.$options.name && child.$options.name.substr(4); if (~componentName.indexOf(name)) { child.$emit.apply(child, [eventName].concat(params)); @@ -1768,8 +1768,8 @@ if (pixelRatio !== 1) { return a2 * pixelRatio; }); } else if (Array.isArray(value)) { - for (let i = 0; i < value.length; i++) { - args[value[i]] *= pixelRatio; + for (let i2 = 0; i2 < value.length; i2++) { + args[value[i2]] *= pixelRatio; } } return _super.apply(this, args); @@ -1834,7 +1834,7 @@ function wrapper(canvas) { canvas.height = canvas.offsetHeight * pixelRatio; canvas.getContext("2d").__hidpi__ = true; } -var index_vue_vue_type_style_index_0_lang$d = "\nuni-canvas {\r\n width: 300px;\r\n height: 150px;\r\n display: block;\r\n position: relative;\n}\nuni-canvas > canvas {\r\n position: absolute;\r\n top: 0;\r\n left: 0;\r\n width: 100%;\r\n height: 100%;\n}\r\n"; +var index_vue_vue_type_style_index_0_lang$c = "\nuni-canvas {\r\n width: 300px;\r\n height: 150px;\r\n display: block;\r\n position: relative;\n}\nuni-canvas > canvas {\r\n position: absolute;\r\n top: 0;\r\n left: 0;\r\n width: 100%;\r\n height: 100%;\n}\r\n"; function resolveColor(color) { color = color.slice(0); color[3] = color[3] / 255; @@ -2469,7 +2469,7 @@ function _sfc_render$l(_ctx, _cache, $props, $setup, $data, $options) { ], 16, ["disabled"]); } _sfc_main$m.render = _sfc_render$l; -var index_vue_vue_type_style_index_0_lang$c = "\nuni-checkbox-group[hidden] {\r\n display: none;\n}\r\n"; +var index_vue_vue_type_style_index_0_lang$b = "\nuni-checkbox-group[hidden] {\r\n display: none;\n}\r\n"; const _sfc_main$l = { name: "CheckboxGroup", mixins: [emitter, listeners], @@ -2651,9 +2651,9 @@ function HTMLParser(html, handler) { } } if (pos >= 0) { - for (var i = stack.length - 1; i >= pos; i--) { + for (var i2 = stack.length - 1; i2 >= pos; i2--) { if (handler.end) { - handler.end(stack[i]); + handler.end(stack[i2]); } } stack.length = pos; @@ -2663,8 +2663,8 @@ function HTMLParser(html, handler) { function makeMap(str) { var obj = {}; var items = str.split(","); - for (var i = 0; i < items.length; i++) { - obj[items[i]] = true; + for (var i2 = 0; i2 < items.length; i2++) { + obj[items[i2]] = true; } return obj; } @@ -3255,7 +3255,7 @@ function _sfc_render$j(_ctx, _cache, $props, $setup, $data, $options) { }, _ctx.$attrs), null, 16, ["id"]); } _sfc_main$k.render = _sfc_render$j; -var index_vue_vue_type_style_index_0_lang$b = "\r\n"; +var index_vue_vue_type_style_index_0_lang$a = "\r\n"; const _sfc_main$j = { name: "Form", mixins: [listeners], @@ -3369,7 +3369,7 @@ var index$2 = defineComponent({ return () => createVNode("uni-icon", null, [path.value.d && createSvgIconVNode(path.value.d, props.color || path.value.c, rpx2px(props.size))]); } }); -var index_vue_vue_type_style_index_0_lang$a = "\n@keyframes once-show {\nfrom {\n top: 0;\n}\n}\nuni-resize-sensor,\nuni-resize-sensor > div {\n position: absolute;\n left: 0;\n top: 0;\n right: 0;\n bottom: 0;\n overflow: hidden;\n}\nuni-resize-sensor {\n display: block;\n z-index: -1;\n visibility: hidden;\n animation: once-show 1ms;\n}\nuni-resize-sensor > div > div {\n position: absolute;\n left: 0;\n top: 0;\n}\nuni-resize-sensor > div:first-child > div {\n width: 100000px;\n height: 100000px;\n}\nuni-resize-sensor > div:last-child > div {\n width: 200%;\n height: 200%;\n}\n"; +var index_vue_vue_type_style_index_0_lang$9 = "\n@keyframes once-show {\nfrom {\n top: 0;\n}\n}\nuni-resize-sensor,\nuni-resize-sensor > div {\n position: absolute;\n left: 0;\n top: 0;\n right: 0;\n bottom: 0;\n overflow: hidden;\n}\nuni-resize-sensor {\n display: block;\n z-index: -1;\n visibility: hidden;\n animation: once-show 1ms;\n}\nuni-resize-sensor > div > div {\n position: absolute;\n left: 0;\n top: 0;\n}\nuni-resize-sensor > div:first-child > div {\n width: 100000px;\n height: 100000px;\n}\nuni-resize-sensor > div:last-child > div {\n width: 200%;\n height: 200%;\n}\n"; const _sfc_main$i = { name: "ResizeSensor", props: { @@ -3443,6 +3443,9 @@ const _sfc_main$i = { ]); } }; +function findElem(vm) { + return vm.$el; +} const SCHEME_RE = /^([a-z-]+:)?\/\//i; const DATA_RE = /^data:.*,.*/; function addBase(filePath) { @@ -3504,1808 +3507,1764 @@ function getBaseSystemInfo() { windowWidth }; } -const _sfc_main$h = { - name: "Image", - props: { - src: { - type: String, - default: "" - }, - mode: { - type: String, - default: "scaleToFill" - }, - lazyLoad: { - type: [Boolean, String], - default: false +var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +var lookup = new Uint8Array(256); +for (var i$1 = 0; i$1 < chars.length; i$1++) { + lookup[chars.charCodeAt(i$1)] = i$1; +} +function encode$1(arraybuffer) { + var bytes = new Uint8Array(arraybuffer), i2, len = bytes.length, base64 = ""; + for (i2 = 0; i2 < len; i2 += 3) { + base64 += chars[bytes[i2] >> 2]; + base64 += chars[(bytes[i2] & 3) << 4 | bytes[i2 + 1] >> 4]; + base64 += chars[(bytes[i2 + 1] & 15) << 2 | bytes[i2 + 2] >> 6]; + base64 += chars[bytes[i2 + 2] & 63]; + } + if (len % 3 === 2) { + base64 = base64.substring(0, base64.length - 1) + "="; + } else if (len % 3 === 1) { + base64 = base64.substring(0, base64.length - 2) + "=="; + } + return base64; +} +function decode(base64) { + var bufferLength = base64.length * 0.75, len = base64.length, i2, p2 = 0, encoded1, encoded2, encoded3, encoded4; + if (base64[base64.length - 1] === "=") { + bufferLength--; + if (base64[base64.length - 2] === "=") { + bufferLength--; } - }, - data() { - return { - originalWidth: 0, - originalHeight: 0, - availHeight: "" - }; - }, - computed: { - ratio() { - return this.originalWidth && this.originalHeight ? this.originalWidth / this.originalHeight : 0; - }, - realImagePath() { - return getRealPath(this.src); - }, - modeStyle() { - let size = "auto"; - let position = ""; - const repeat = "no-repeat"; - switch (this.mode) { - case "aspectFit": - size = "contain"; - position = "center center"; - break; - case "aspectFill": - size = "cover"; - position = "center center"; - break; - case "widthFix": - size = "100% 100%"; - break; - case "top": - position = "center top"; - break; - case "bottom": - position = "center bottom"; - break; - case "center": - position = "center center"; - break; - case "left": - position = "left center"; - break; - case "right": - position = "right center"; - break; - case "top left": - position = "left top"; - break; - case "top right": - position = "right top"; - break; - case "bottom left": - position = "left bottom"; - break; - case "bottom right": - position = "right bottom"; - break; - default: - size = "100% 100%"; - position = "0% 0%"; - break; - } - return `background-position:${position};background-size:${size};background-repeat:${repeat};`; + } + var arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer); + for (i2 = 0; i2 < len; i2 += 4) { + encoded1 = lookup[base64.charCodeAt(i2)]; + encoded2 = lookup[base64.charCodeAt(i2 + 1)]; + encoded3 = lookup[base64.charCodeAt(i2 + 2)]; + encoded4 = lookup[base64.charCodeAt(i2 + 3)]; + bytes[p2++] = encoded1 << 2 | encoded2 >> 4; + bytes[p2++] = (encoded2 & 15) << 4 | encoded3 >> 2; + bytes[p2++] = (encoded3 & 3) << 6 | encoded4 & 63; + } + return arraybuffer; +} +const API_TYPE_ON_PROTOCOLS = [ + { + name: "callback", + type: Function, + required: true + } +]; +function validateProtocolFail(name, msg) { + const errMsg = `${name}:fail ${msg}`; + { + console.error(errMsg); + } + return { + errMsg + }; +} +function validateProtocol(name, data, protocol) { + for (const key in protocol) { + const errMsg = validateProp(key, data[key], protocol[key], !hasOwn$1(data, key)); + if (errMsg) { + return validateProtocolFail(name, errMsg); } - }, - watch: { - src(newValue, oldValue) { - this._setContentImage(); - this._loadImage(); - }, - mode(newValue, oldValue) { - if (oldValue === "widthFix") { - this.$el.style.height = this.availHeight; + } +} +function validateProtocols(name, args, protocol) { + if (!protocol) { + return; + } + if (isArray(protocol)) { + const len = protocol.length; + const argsLen = args.length; + for (let i2 = 0; i2 < len; i2++) { + const opts = protocol[i2]; + const data = Object.create(null); + if (argsLen > i2) { + data[opts.name] = args[i2]; } - if (newValue === "widthFix" && this.ratio) { - this._fixSize(); + const errMsg = validateProtocol(name, data, {[opts.name]: opts}); + if (errMsg) { + return errMsg; } } - }, - components: { - ResizeSensor: _sfc_main$i - }, - mounted() { - this.availHeight = this.$el.style.height || ""; - this._setContentImage(); - if (!this.realImagePath) { - return; + return; + } + return validateProtocol(name, args[0] || Object.create(null), protocol); +} +function validateProp(name, value, prop, isAbsent) { + const {type, required, validator} = prop; + if (required && isAbsent) { + return 'Missing required args: "' + name + '"'; + } + if (value == null && !prop.required) { + return; + } + if (type != null && type !== true) { + let isValid = false; + const types = isArray(type) ? type : [type]; + const expectedTypes = []; + for (let i2 = 0; i2 < types.length && !isValid; i2++) { + const {valid, expectedType} = assertType(value, types[i2]); + expectedTypes.push(expectedType || ""); + isValid = valid; } - this._loadImage(); - }, - methods: { - _resize() { - if (this.mode === "widthFix") { - this._fixSize(); - } - }, - _fixSize() { - const elWidth = this._getWidth(); - if (elWidth) { - let height = elWidth / this.ratio; - if (typeof navigator && navigator.vendor === "Google Inc." && height > 10) { - height = Math.round(height / 2) * 2; - } - this.$el.style.height = height + "px"; - } - }, - _setContentImage() { - this.$refs.content.style.backgroundImage = this.src ? `url("${this.realImagePath}")` : "none"; - }, - _loadImage() { - const _self = this; - const img = new Image(); - img.onload = function($event) { - _self.originalWidth = this.width; - _self.originalHeight = this.height; - if (_self.mode === "widthFix") { - _self._fixSize(); - } - _self.$trigger("load", $event, { - width: this.width, - height: this.height - }); - }; - img.onerror = function($event) { - _self.$trigger("error", $event, { - errMsg: `GET ${_self.src} 404 (Not Found)` - }); - }; - img.src = this.realImagePath; - }, - _getWidth() { - const computedStyle = window.getComputedStyle(this.$el); - const borderWidth = (parseFloat(computedStyle.borderLeftWidth, 10) || 0) + (parseFloat(computedStyle.borderRightWidth, 10) || 0); - const paddingWidth = (parseFloat(computedStyle.paddingLeft, 10) || 0) + (parseFloat(computedStyle.paddingRight, 10) || 0); - return this.$el.offsetWidth - borderWidth - paddingWidth; + if (!isValid) { + return getInvalidTypeMessage(name, value, expectedTypes); } } -}; -function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) { - const _component_ResizeSensor = resolveComponent("ResizeSensor"); - return openBlock(), createBlock("uni-image", _ctx.$attrs, [ - createVNode("div", { - ref: "content", - style: $options.modeStyle - }, null, 4), - createVNode("img", {src: $options.realImagePath}, null, 8, ["src"]), - $props.mode === "widthFix" ? (openBlock(), createBlock(_component_ResizeSensor, { - key: 0, - ref: "sensor", - onResize: $options._resize - }, null, 8, ["onResize"])) : createCommentVNode("", true) - ], 16); + if (validator && !validator(value)) { + return 'Invalid args: custom validator check failed for args "' + name + '".'; + } } -_sfc_main$h.render = _sfc_render$h; -const INPUT_TYPES = ["text", "number", "idcard", "digit", "password"]; -const NUMBER_TYPES = ["number", "digit"]; -const _sfc_main$g = { - name: "Input", - mixins: [baseInput], - props: { - name: { - type: String, - default: "" - }, - type: { - type: String, - default: "text" - }, - password: { - type: [Boolean, String], - default: false - }, - placeholder: { - type: String, - default: "" - }, - placeholderStyle: { - type: String, - default: "" - }, - placeholderClass: { - type: String, - default: "input-placeholder" - }, - disabled: { - type: [Boolean, String], - default: false - }, - maxlength: { - type: [Number, String], - default: 140 - }, - focus: { - type: [Boolean, String], - default: false - }, - confirmType: { - type: String, - default: "done" - } - }, - data() { - return { - composing: false, - wrapperHeight: 0, - cachedValue: "" - }; - }, - computed: { - inputType: function() { - let type = ""; - switch (this.type) { - case "text": - this.confirmType === "search" && (type = "search"); - break; - case "idcard": - type = "text"; - break; - case "digit": - type = "number"; - break; - default: - type = ~INPUT_TYPES.indexOf(this.type) ? this.type : "text"; - break; - } - return this.password ? "password" : type; - }, - step() { - return ~NUMBER_TYPES.indexOf(this.type) ? "0.000000000000000001" : ""; +const isSimpleType = /* @__PURE__ */ makeMap$1("String,Number,Boolean,Function,Symbol"); +function assertType(value, type) { + let valid; + const expectedType = getType(type); + if (isSimpleType(expectedType)) { + const t2 = typeof value; + valid = t2 === expectedType.toLowerCase(); + if (!valid && t2 === "object") { + valid = value instanceof type; } - }, - watch: { - focus(val) { - this.$refs.input && this.$refs.input[val ? "focus" : "blur"](); - }, - maxlength(value) { - const realValue = this.valueSync.slice(0, parseInt(value, 10)); - realValue !== this.valueSync && (this.valueSync = realValue); + } else if (expectedType === "Object") { + valid = isObject$1(value); + } else if (expectedType === "Array") { + valid = isArray(value); + } else { + { + valid = value instanceof type; } - }, - created() { - this.$dispatch("Form", "uni-form-group-update", { - type: "add", - vm: this - }); - }, - mounted() { - if (this.confirmType === "search") { - const formElem = document.createElement("form"); - formElem.action = ""; - formElem.onsubmit = function() { - return false; - }; - formElem.className = "uni-input-form"; - formElem.appendChild(this.$refs.input); - this.$refs.wrapper.appendChild(formElem); + } + return { + valid, + expectedType + }; +} +function getInvalidTypeMessage(name, value, expectedTypes) { + let message = `Invalid args: type check failed for args "${name}". Expected ${expectedTypes.map(capitalize).join(", ")}`; + const expectedType = expectedTypes[0]; + const receivedType = toRawType(value); + const expectedValue = styleValue(value, expectedType); + const receivedValue = styleValue(value, receivedType); + if (expectedTypes.length === 1 && isExplicable(expectedType) && !isBoolean(expectedType, receivedType)) { + message += ` with value ${expectedValue}`; + } + message += `, got ${receivedType} `; + if (isExplicable(receivedType)) { + message += `with value ${receivedValue}.`; + } + return message; +} +function getType(ctor) { + const match = ctor && ctor.toString().match(/^\s*function (\w+)/); + return match ? match[1] : ""; +} +function styleValue(value, type) { + if (type === "String") { + return `"${value}"`; + } else if (type === "Number") { + return `${Number(value)}`; + } else { + return `${value}`; + } +} +function isExplicable(type) { + const explicitTypes = ["string", "number", "boolean"]; + return explicitTypes.some((elem) => type.toLowerCase() === elem); +} +function isBoolean(...args) { + return args.some((elem) => elem.toLowerCase() === "boolean"); +} +function tryCatch(fn) { + return function() { + try { + return fn.apply(fn, arguments); + } catch (e2) { + console.error(e2); } - let $vm = this; - while ($vm) { - const scopeId = $vm.$options._scopeId; - if (scopeId) { - this.$refs.placeholder.setAttribute(scopeId, ""); + }; +} +let invokeCallbackId = 1; +const invokeCallbacks = {}; +function addInvokeCallback(id2, name, callback, keepAlive = false) { + invokeCallbacks[id2] = { + name, + keepAlive, + callback + }; + return id2; +} +function invokeCallback(id2, res, extras) { + if (typeof id2 === "number") { + const opts = invokeCallbacks[id2]; + if (opts) { + if (!opts.keepAlive) { + delete invokeCallbacks[id2]; } - $vm = $vm.$parent; + return opts.callback(res, extras); } - this.initKeyboard(this.$refs.input); - }, - beforeDestroy() { - this.$dispatch("Form", "uni-form-group-update", { - type: "remove", - vm: this - }); - }, - methods: { - _onKeyup($event) { - if ($event.keyCode === 13) { - this.$trigger("confirm", $event, { - value: $event.target.value - }); - } - }, - _onInput($event) { - if (this.composing) { - return; - } - if (~NUMBER_TYPES.indexOf(this.type)) { - if (this.$refs.input.validity && !this.$refs.input.validity.valid) { - $event.target.value = this.cachedValue; - this.valueSync = $event.target.value; - return; - } else { - this.cachedValue = this.valueSync; - } - } - if (this.inputType === "number") { - const maxlength = parseInt(this.maxlength, 10); - if (maxlength > 0 && $event.target.value.length > maxlength) { - $event.target.value = $event.target.value.slice(0, maxlength); - this.valueSync = $event.target.value; - return; - } - } - this.$triggerInput($event, { - value: this.valueSync - }); - }, - _onFocus($event) { - this.$trigger("focus", $event, { - value: $event.target.value - }); - }, - _onBlur($event) { - this.$trigger("blur", $event, { - value: $event.target.value - }); - }, - _onComposition($event) { - if ($event.type === "compositionstart") { - this.composing = true; - } else { - this.composing = false; - } - }, - _resetFormData() { - this.valueSync = ""; - }, - _getFormData() { - return this.name ? { - value: this.valueSync, - key: this.name - } : {}; + } + return res; +} +function findInvokeCallbackByName(name) { + for (const key in invokeCallbacks) { + if (invokeCallbacks[key].name === name) { + return true; } } -}; -const _hoisted_1$a = { - ref: "wrapper", - class: "uni-input-wrapper" -}; -function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) { - return openBlock(), createBlock("uni-input", mergeProps({ - onChange: _cache[8] || (_cache[8] = withModifiers(() => { - }, ["stop"])) - }, _ctx.$attrs), [ - createVNode("div", _hoisted_1$a, [ - withDirectives(createVNode("div", { - ref: "placeholder", - style: $props.placeholderStyle, - class: [$props.placeholderClass, "uni-input-placeholder"], - textContent: toDisplayString($props.placeholder) - }, null, 14, ["textContent"]), [ - [vShow, !($data.composing || _ctx.valueSync.length)] - ]), - withDirectives(createVNode("input", { - ref: "input", - "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => _ctx.valueSync = $event), - disabled: $props.disabled, - type: $options.inputType, - maxlength: $props.maxlength, - step: $options.step, - autofocus: $props.focus, - class: "uni-input-input", - autocomplete: "off", - onFocus: _cache[2] || (_cache[2] = (...args) => $options._onFocus && $options._onFocus(...args)), - onBlur: _cache[3] || (_cache[3] = (...args) => $options._onBlur && $options._onBlur(...args)), - onInput: _cache[4] || (_cache[4] = withModifiers((...args) => $options._onInput && $options._onInput(...args), ["stop"])), - onCompositionstart: _cache[5] || (_cache[5] = (...args) => $options._onComposition && $options._onComposition(...args)), - onCompositionend: _cache[6] || (_cache[6] = (...args) => $options._onComposition && $options._onComposition(...args)), - onKeyup: _cache[7] || (_cache[7] = withModifiers((...args) => $options._onKeyup && $options._onKeyup(...args), ["stop"])) - }, null, 40, ["disabled", "type", "maxlength", "step", "autofocus"]), [ - [vModelDynamic, _ctx.valueSync] - ]) - ], 512) - ], 16); + return false; } -_sfc_main$g.render = _sfc_render$g; -var index_vue_vue_type_style_index_0_lang$9 = "\n.uni-label-pointer {\r\n cursor: pointer;\n}\r\n"; -const _sfc_main$f = { - name: "Label", - mixins: [emitter], - props: { - for: { - type: String, - default: "" - } - }, - computed: { - pointer() { - return this.for || this.$slots.default && this.$slots.default.length; - } - }, - methods: { - _onClick($event) { - let stopPropagation = /^uni-(checkbox|radio|switch)-/.test($event.target.className); - if (!stopPropagation) { - stopPropagation = /^uni-(checkbox|radio|switch|button)$/i.test($event.target.tagName); - } - if (stopPropagation) { - return; - } - if (this.for) { - UniViewJSBridge.emit("uni-label-click-" + this.$page.id + "-" + this.for, $event, true); - } else { - this.$broadcast(["Checkbox", "Radio", "Switch", "Button"], "uni-label-click", $event, true); - } +function removeKeepAliveApiCallback(name, callback) { + for (const key in invokeCallbacks) { + const item = invokeCallbacks[key]; + if (item.callback === callback && item.name === name) { + delete invokeCallbacks[key]; } } -}; -function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) { - return openBlock(), createBlock("uni-label", mergeProps({ - class: {"uni-label-pointer": $options.pointer} - }, _ctx.$attrs, { - onClick: _cache[1] || (_cache[1] = (...args) => $options._onClick && $options._onClick(...args)) - }), [ - renderSlot(_ctx.$slots, "default") - ], 16); } -_sfc_main$f.render = _sfc_render$f; -const addListenerToElement = function(element, type, callback, capture) { - element.addEventListener(type, ($event) => { - if (typeof callback === "function") { - if (callback($event) === false) { - $event.preventDefault(); - $event.stopPropagation(); +function offKeepAliveApiCallback(name) { + UniServiceJSBridge.off("api." + name); +} +function onKeepAliveApiCallback(name) { + UniServiceJSBridge.on("api." + name, (res) => { + for (const key in invokeCallbacks) { + const opts = invokeCallbacks[key]; + if (opts.name === name) { + opts.callback(res); } } - }, { - passive: false }); -}; -var touchtrack = { - beforeDestroy() { - document.removeEventListener("mousemove", this.__mouseMoveEventListener); - document.removeEventListener("mouseup", this.__mouseUpEventListener); - }, - methods: { - touchtrack: function(element, method, useCancel) { - const self = this; - let x0 = 0; - let y0 = 0; - let x1 = 0; - let y1 = 0; - const fn = function($event, state, x, y) { - if (self[method]({ - target: $event.target, - currentTarget: $event.currentTarget, - preventDefault: $event.preventDefault.bind($event), - stopPropagation: $event.stopPropagation.bind($event), - touches: $event.touches, - changedTouches: $event.changedTouches, - detail: { - state, - x0: x, - y0: y, - dx: x - x0, - dy: y - y0, - ddx: x - x1, - ddy: y - y1, - timeStamp: $event.timeStamp - } - }) === false) { - return false; - } - }; - let $eventOld = null; - let hasTouchStart; - let hasMouseDown; - addListenerToElement(element, "touchstart", function($event) { - hasTouchStart = true; - if ($event.touches.length === 1 && !$eventOld) { - $eventOld = $event; - x0 = x1 = $event.touches[0].pageX; - y0 = y1 = $event.touches[0].pageY; - return fn($event, "start", x0, y0); - } - }); - addListenerToElement(element, "mousedown", function($event) { - hasMouseDown = true; - if (!hasTouchStart && !$eventOld) { - $eventOld = $event; - x0 = x1 = $event.pageX; - y0 = y1 = $event.pageY; - return fn($event, "start", x0, y0); - } - }); - addListenerToElement(element, "touchmove", function($event) { - if ($event.touches.length === 1 && $eventOld) { - const res = fn($event, "move", $event.touches[0].pageX, $event.touches[0].pageY); - x1 = $event.touches[0].pageX; - y1 = $event.touches[0].pageY; - return res; - } - }); - const mouseMoveEventListener = this.__mouseMoveEventListener = function($event) { - if (!hasTouchStart && hasMouseDown && $eventOld) { - const res = fn($event, "move", $event.pageX, $event.pageY); - x1 = $event.pageX; - y1 = $event.pageY; - return res; - } - }; - document.addEventListener("mousemove", mouseMoveEventListener); - addListenerToElement(element, "touchend", function($event) { - if ($event.touches.length === 0 && $eventOld) { - hasTouchStart = false; - $eventOld = null; - return fn($event, "end", $event.changedTouches[0].pageX, $event.changedTouches[0].pageY); - } - }); - const mouseUpEventListener = this.__mouseUpEventListener = function($event) { - hasMouseDown = false; - if (!hasTouchStart && $eventOld) { - $eventOld = null; - return fn($event, "end", $event.pageX, $event.pageY); - } - }; - document.addEventListener("mouseup", mouseUpEventListener); - addListenerToElement(element, "touchcancel", function($event) { - if ($eventOld) { - hasTouchStart = false; - const $eventTemp = $eventOld; - $eventOld = null; - return fn($event, useCancel ? "cancel" : "end", $eventTemp.touches[0].pageX, $eventTemp.touches[0].pageY); - } - }); +} +function createKeepAliveApiCallback(name, callback) { + return addInvokeCallback(invokeCallbackId++, name, callback, true); +} +const API_SUCCESS = "success"; +const API_FAIL = "fail"; +const API_COMPLETE = "complete"; +function getApiCallbacks(args) { + const apiCallbacks = {}; + for (const name in args) { + const fn = args[name]; + if (isFunction(fn)) { + apiCallbacks[name] = tryCatch(fn); + delete args[name]; } } -}; -function e(e2, t2, n) { - return e2 > t2 - n && e2 < t2 + n; + return apiCallbacks; } -function t(t2, n) { - return e(t2, 0, n); +function normalizeErrMsg(errMsg, name) { + if (!errMsg || errMsg.indexOf(":fail") === -1) { + return name + ":ok"; + } + return name + errMsg.substring(errMsg.indexOf(":fail")); } -function Decline() { +function createAsyncApiCallback(name, args = {}, {beforeAll, beforeSuccess} = {}) { + if (!isPlainObject(args)) { + args = {}; + } + const {success, fail, complete} = getApiCallbacks(args); + const hasSuccess = isFunction(success); + const hasFail = isFunction(fail); + const hasComplete = isFunction(complete); + const callbackId = invokeCallbackId++; + addInvokeCallback(callbackId, name, (res) => { + res = res || {}; + res.errMsg = normalizeErrMsg(res.errMsg, name); + isFunction(beforeAll) && beforeAll(res); + if (res.errMsg === name + ":ok") { + isFunction(beforeSuccess) && beforeSuccess(res); + hasSuccess && success(res); + } else { + hasFail && fail(res); + } + hasComplete && complete(res); + }); + return callbackId; } -Decline.prototype.x = function(e2) { - return Math.sqrt(e2); -}; -function Friction$1(e2, t2) { - this._m = e2; - this._f = 1e3 * t2; - this._startTime = 0; - this._v = 0; +const callbacks = [API_SUCCESS, API_FAIL, API_COMPLETE]; +function hasCallback(args) { + if (isPlainObject(args) && callbacks.find((cb) => isFunction(args[cb]))) { + return true; + } + return false; } -Friction$1.prototype.setV = function(x, y) { - var n = Math.pow(Math.pow(x, 2) + Math.pow(y, 2), 0.5); - this._x_v = x; - this._y_v = y; - this._x_a = -this._f * this._x_v / n; - this._y_a = -this._f * this._y_v / n; - this._t = Math.abs(x / this._x_a) || Math.abs(y / this._y_a); - this._lastDt = null; - this._startTime = new Date().getTime(); -}; -Friction$1.prototype.setS = function(x, y) { - this._x_s = x; - this._y_s = y; -}; -Friction$1.prototype.s = function(t2) { - if (t2 === void 0) { - t2 = (new Date().getTime() - this._startTime) / 1e3; - } - if (t2 > this._t) { - t2 = this._t; - this._lastDt = t2; - } - var x = this._x_v * t2 + 0.5 * this._x_a * Math.pow(t2, 2) + this._x_s; - var y = this._y_v * t2 + 0.5 * this._y_a * Math.pow(t2, 2) + this._y_s; - if (this._x_a > 0 && x < this._endPositionX || this._x_a < 0 && x > this._endPositionX) { - x = this._endPositionX; - } - if (this._y_a > 0 && y < this._endPositionY || this._y_a < 0 && y > this._endPositionY) { - y = this._endPositionY; +function handlePromise(promise) { + if (__UNI_FEATURE_PROMISE__) { + return promise.then((data) => { + return [null, data]; + }).catch((err) => [err]); } - return { - x, - y + return promise; +} +function promisify(fn) { + return (args = {}) => { + if (hasCallback(args)) { + return fn(args); + } + return handlePromise(new Promise((resolve, reject) => { + fn(Object.assign(args, {success: resolve, fail: reject})); + })); }; -}; -Friction$1.prototype.ds = function(t2) { - if (t2 === void 0) { - t2 = (new Date().getTime() - this._startTime) / 1e3; - } - if (t2 > this._t) { - t2 = this._t; +} +function formatApiArgs(args, options) { + const params = args[0]; + if (!options || !isPlainObject(options.formatArgs) && isPlainObject(params)) { + return args; } - return { - dx: this._x_v + this._x_a * t2, - dy: this._y_v + this._y_a * t2 + const formatArgs = options.formatArgs; + Object.keys(formatArgs).forEach((name) => { + formatArgs[name](args[0][name], params); + }); + return args; +} +function wrapperOnApi(name, fn) { + return (callback) => { + const isFirstInvokeOnApi = !findInvokeCallbackByName(name); + createKeepAliveApiCallback(name, callback); + if (isFirstInvokeOnApi) { + onKeepAliveApiCallback(name); + fn(); + } }; -}; -Friction$1.prototype.delta = function() { - return { - x: -1.5 * Math.pow(this._x_v, 2) / this._x_a || 0, - y: -1.5 * Math.pow(this._y_v, 2) / this._y_a || 0 +} +function wrapperOffApi(name, fn) { + return (callback) => { + name = name.replace("off", "on"); + removeKeepAliveApiCallback(name, callback); + const hasInvokeOnApi = findInvokeCallbackByName(name); + if (!hasInvokeOnApi) { + offKeepAliveApiCallback(name); + fn(); + } }; -}; -Friction$1.prototype.dt = function() { - return -this._x_v / this._x_a; -}; -Friction$1.prototype.done = function() { - var t2 = e(this.s().x, this._endPositionX) || e(this.s().y, this._endPositionY) || this._lastDt === this._t; - this._lastDt = null; - return t2; -}; -Friction$1.prototype.setEnd = function(x, y) { - this._endPositionX = x; - this._endPositionY = y; -}; -Friction$1.prototype.reconfigure = function(m, f2) { - this._m = m; - this._f = 1e3 * f2; -}; -function Spring$1(m, k, c) { - this._m = m; - this._k = k; - this._c = c; - this._solution = null; - this._endPosition = 0; - this._startTime = 0; } -Spring$1.prototype._solve = function(e2, t2) { - var n = this._c; - var i = this._m; - var r = this._k; - var o2 = n * n - 4 * i * r; - if (o2 === 0) { - const a2 = -n / (2 * i); - const s = e2; - const l = t2 / (a2 * e2); - return { - x: function(e3) { - return (s + l * e3) * Math.pow(Math.E, a2 * e3); - }, - dx: function(e3) { - var t3 = Math.pow(Math.E, a2 * e3); - return a2 * (s + l * e3) * t3 + l * t3; - } - }; - } - if (o2 > 0) { - const c = (-n - Math.sqrt(o2)) / (2 * i); - const u = (-n + Math.sqrt(o2)) / (2 * i); - const d = (t2 - c * e2) / (u - c); - const h = e2 - d; - return { - x: function(e3) { - var t3; - var n2; - if (e3 === this._t) { - t3 = this._powER1T; - n2 = this._powER2T; - } - this._t = e3; - if (!t3) { - t3 = this._powER1T = Math.pow(Math.E, c * e3); - } - if (!n2) { - n2 = this._powER2T = Math.pow(Math.E, u * e3); - } - return h * t3 + d * n2; - }, - dx: function(e3) { - var t3; - var n2; - if (e3 === this._t) { - t3 = this._powER1T; - n2 = this._powER2T; - } - this._t = e3; - if (!t3) { - t3 = this._powER1T = Math.pow(Math.E, c * e3); - } - if (!n2) { - n2 = this._powER2T = Math.pow(Math.E, u * e3); - } - return h * c * t3 + d * u * n2; +function invokeSuccess(id2, name, res) { + return invokeCallback(id2, extend(res || {}, {errMsg: name + ":ok"})); +} +function invokeFail(id2, name, err) { + return invokeCallback(id2, {errMsg: name + ":fail" + (err ? " " + err : "")}); +} +function wrapperTaskApi(name, fn, options) { + return (args) => { + const id2 = createAsyncApiCallback(name, args, options); + return fn(args, { + resolve: (res) => invokeSuccess(id2, name, res), + reject: (err) => invokeFail(id2, name, err) + }); + }; +} +function wrapperSyncApi(fn) { + return (...args) => fn.apply(null, args); +} +function wrapperAsyncApi(name, fn, options) { + return wrapperTaskApi(name, fn, options); +} +function wrapperApi(fn, name, protocol, options) { + return function(...args) { + if (process.env.NODE_ENV !== "production") { + const errMsg = validateProtocols(name, args, protocol); + if (errMsg) { + return errMsg; } - }; - } - var p2 = Math.sqrt(4 * i * r - n * n) / (2 * i); - var f2 = -n / 2 * i; - var v2 = e2; - var g2 = (t2 - f2 * e2) / p2; - return { - x: function(e3) { - return Math.pow(Math.E, f2 * e3) * (v2 * Math.cos(p2 * e3) + g2 * Math.sin(p2 * e3)); - }, - dx: function(e3) { - var t3 = Math.pow(Math.E, f2 * e3); - var n2 = Math.cos(p2 * e3); - var i2 = Math.sin(p2 * e3); - return t3 * (g2 * p2 * n2 - v2 * p2 * i2) + f2 * t3 * (g2 * i2 + v2 * n2); } + return fn.apply(null, formatApiArgs(args, options)); }; -}; -Spring$1.prototype.x = function(e2) { - if (e2 === void 0) { - e2 = (new Date().getTime() - this._startTime) / 1e3; +} +function defineOnApi(name, fn, options) { + return wrapperApi(wrapperOnApi(name, fn), name, process.env.NODE_ENV !== "production" ? API_TYPE_ON_PROTOCOLS : void 0, options); +} +function defineOffApi(name, fn, options) { + return wrapperApi(wrapperOffApi(name, fn), name, process.env.NODE_ENV !== "production" ? API_TYPE_ON_PROTOCOLS : void 0, options); +} +function defineTaskApi(name, fn, protocol, options) { + return promisify(wrapperApi(wrapperTaskApi(name, fn), name, process.env.NODE_ENV !== "production" ? protocol : void 0, options)); +} +function defineSyncApi(name, fn, protocol, options) { + return wrapperApi(wrapperSyncApi(fn), name, process.env.NODE_ENV !== "production" ? protocol : void 0, options); +} +function defineAsyncApi(name, fn, protocol, options) { + return promisify(wrapperApi(wrapperAsyncApi(name, fn, options), name, process.env.NODE_ENV !== "production" ? protocol : void 0, options)); +} +const API_BASE64_TO_ARRAY_BUFFER = "base64ToArrayBuffer"; +const API_ARRAY_BUFFER_TO_BASE64 = "arrayBufferToBase64"; +const Base64ToArrayBufferProtocol = [ + { + name: "base64", + type: String, + required: true } - return this._solution ? this._endPosition + this._solution.x(e2) : 0; -}; -Spring$1.prototype.dx = function(e2) { - if (e2 === void 0) { - e2 = (new Date().getTime() - this._startTime) / 1e3; +]; +const ArrayBufferToBase64Protocol = [ + { + name: "arrayBuffer", + type: [ArrayBuffer, Uint8Array], + required: true } - return this._solution ? this._solution.dx(e2) : 0; -}; -Spring$1.prototype.setEnd = function(e2, n, i) { - if (!i) { - i = new Date().getTime(); +]; +const base64ToArrayBuffer = defineSyncApi(API_BASE64_TO_ARRAY_BUFFER, (base64) => { + return decode(base64); +}, Base64ToArrayBufferProtocol); +const arrayBufferToBase64 = defineSyncApi(API_ARRAY_BUFFER_TO_BASE64, (arrayBuffer) => { + return encode$1(arrayBuffer); +}, ArrayBufferToBase64Protocol); +const API_UPX2PX = "upx2px"; +const Upx2pxProtocol = [ + { + name: "upx", + type: [Number, String], + required: true } - if (e2 !== this._endPosition || !t(n, 0.1)) { - n = n || 0; - var r = this._endPosition; - if (this._solution) { - if (t(n, 0.1)) { - n = this._solution.dx((i - this._startTime) / 1e3); - } - r = this._solution.x((i - this._startTime) / 1e3); - if (t(n, 0.1)) { - n = 0; - } - if (t(r, 0.1)) { - r = 0; - } - r += this._endPosition; - } - if (!(this._solution && t(r - e2, 0.1) && t(n, 0.1))) { - this._endPosition = e2; - this._solution = this._solve(r - this._endPosition, n); - this._startTime = i; - } +]; +const EPS = 1e-4; +const BASE_DEVICE_WIDTH = 750; +let isIOS = false; +let deviceWidth = 0; +let deviceDPR = 0; +function checkDeviceWidth() { + const {platform, pixelRatio: pixelRatio2, windowWidth} = getBaseSystemInfo(); + deviceWidth = windowWidth; + deviceDPR = pixelRatio2; + isIOS = platform === "ios"; +} +const upx2px = defineSyncApi(API_UPX2PX, (number, newDeviceWidth) => { + if (deviceWidth === 0) { + checkDeviceWidth(); } -}; -Spring$1.prototype.snap = function(e2) { - this._startTime = new Date().getTime(); - this._endPosition = e2; - this._solution = { - x: function() { - return 0; - }, - dx: function() { - return 0; - } - }; -}; -Spring$1.prototype.done = function(n) { - if (!n) { - n = new Date().getTime(); + number = Number(number); + if (number === 0) { + return 0; } - return e(this.x(), this._endPosition, 0.1) && t(this.dx(), 0.1); -}; -Spring$1.prototype.reconfigure = function(m, t2, c) { - this._m = m; - this._k = t2; - this._c = c; - if (!this.done()) { - this._solution = this._solve(this.x() - this._endPosition, this.dx()); - this._startTime = new Date().getTime(); + let result = number / BASE_DEVICE_WIDTH * (newDeviceWidth || deviceWidth); + if (result < 0) { + result = -result; } -}; -Spring$1.prototype.springConstant = function() { - return this._k; -}; -Spring$1.prototype.damping = function() { - return this._c; -}; -Spring$1.prototype.configuration = function() { - function e2(e3, t3) { - e3.reconfigure(1, t3, e3.damping()); + result = Math.floor(result + EPS); + if (result === 0) { + if (deviceDPR === 1 || !isIOS) { + result = 1; + } else { + result = 0.5; + } } - function t2(e3, t3) { - e3.reconfigure(1, e3.springConstant(), t3); + return number < 0 ? -result : result; +}, Upx2pxProtocol); +var HOOKS; +(function(HOOKS2) { + HOOKS2["INVOKE"] = "invoke"; + HOOKS2["SUCCESS"] = "success"; + HOOKS2["FAIL"] = "fail"; + HOOKS2["COMPLETE"] = "complete"; + HOOKS2["RETURN_VALUE"] = "returnValue"; +})(HOOKS || (HOOKS = {})); +const globalInterceptors = {}; +const scopedInterceptors = {}; +const API_ADD_INTERCEPTOR = "addInterceptor"; +const API_REMOVE_INTERCEPTOR = "removeInterceptor"; +const AddInterceptorProtocol = [ + { + name: "method", + type: [String, Object], + required: true } - return [ - { - label: "Spring Constant", - read: this.springConstant.bind(this), - write: e2.bind(this, this), - min: 100, - max: 1e3 - }, - { - label: "Damping", - read: this.damping.bind(this), - write: t2.bind(this, this), - min: 1, - max: 500 +]; +const RemoveInterceptorProtocol = AddInterceptorProtocol; +function mergeInterceptorHook(interceptors, interceptor) { + Object.keys(interceptor).forEach((hook) => { + if (isFunction(interceptor[hook])) { + interceptors[hook] = mergeHook(interceptors[hook], interceptor[hook]); } - ]; -}; -function STD(e2, t2, n) { - this._springX = new Spring$1(e2, t2, n); - this._springY = new Spring$1(e2, t2, n); - this._springScale = new Spring$1(e2, t2, n); - this._startTime = 0; + }); } -STD.prototype.setEnd = function(e2, t2, n, i) { - var r = new Date().getTime(); - this._springX.setEnd(e2, i, r); - this._springY.setEnd(t2, i, r); - this._springScale.setEnd(n, i, r); - this._startTime = r; -}; -STD.prototype.x = function() { - var e2 = (new Date().getTime() - this._startTime) / 1e3; - return { - x: this._springX.x(e2), - y: this._springY.x(e2), - scale: this._springScale.x(e2) - }; -}; -STD.prototype.done = function() { - var e2 = new Date().getTime(); - return this._springX.done(e2) && this._springY.done(e2) && this._springScale.done(e2); -}; -STD.prototype.reconfigure = function(e2, t2, n) { - this._springX.reconfigure(e2, t2, n); - this._springY.reconfigure(e2, t2, n); - this._springScale.reconfigure(e2, t2, n); -}; -var index_vue_vue_type_style_index_0_lang$8 = "\nuni-movable-view {\n display: inline-block;\n width: 10px;\n height: 10px;\n top: 0px;\n left: 0px;\n position: absolute;\n cursor: grab;\n}\nuni-movable-view[hidden] {\n display: none;\n}\n"; -var requesting = false; -function _requestAnimationFrame(e2) { - if (!requesting) { - requesting = true; - requestAnimationFrame(function() { - e2(); - requesting = false; - }); +function removeInterceptorHook(interceptors, interceptor) { + if (!interceptors || !interceptor) { + return; } + Object.keys(interceptor).forEach((hook) => { + if (isFunction(interceptor[hook])) { + removeHook(interceptors[hook], interceptor[hook]); + } + }); } -function p(t2, n) { - if (t2 === n) { - return 0; - } - var i = t2.offsetLeft; - return t2.offsetParent ? i += p(t2.offsetParent, n) : 0; +function mergeHook(parentVal, childVal) { + const res = childVal ? parentVal ? parentVal.concat(childVal) : isArray(childVal) ? childVal : [childVal] : parentVal; + return res ? dedupeHooks(res) : res; } -function f(t2, n) { - if (t2 === n) { - return 0; +function dedupeHooks(hooks) { + const res = []; + for (let i2 = 0; i2 < hooks.length; i2++) { + if (res.indexOf(hooks[i2]) === -1) { + res.push(hooks[i2]); + } } - var i = t2.offsetTop; - return t2.offsetParent ? i += f(t2.offsetParent, n) : 0; + return res; } -function v(a2, b) { - return +((1e3 * a2 - 1e3 * b) / 1e3).toFixed(1); +function removeHook(hooks, hook) { + if (!hooks) { + return; + } + const index2 = hooks.indexOf(hook); + if (index2 !== -1) { + hooks.splice(index2, 1); + } } -function g(e2, t2, n) { - var i = function(e3) { - if (e3 && e3.id) { - cancelAnimationFrame(e3.id); - } - if (e3) { - e3.cancelled = true; +const addInterceptor = defineSyncApi(API_ADD_INTERCEPTOR, (method, interceptor) => { + if (typeof method === "string" && isPlainObject(interceptor)) { + mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor); + } else if (isPlainObject(method)) { + mergeInterceptorHook(globalInterceptors, method); + } +}, AddInterceptorProtocol); +const removeInterceptor = defineSyncApi(API_REMOVE_INTERCEPTOR, (method, interceptor) => { + if (typeof method === "string") { + if (isPlainObject(interceptor)) { + removeInterceptorHook(scopedInterceptors[method], interceptor); + } else { + delete scopedInterceptors[method]; } - }; - var r = { - id: 0, - cancelled: false - }; - function fn(n2, i2, r2, o2) { - if (!n2 || !n2.cancelled) { - r2(i2); - var a2 = e2.done(); - if (!a2) { - if (!n2.cancelled) { - n2.id = requestAnimationFrame(fn.bind(null, n2, i2, r2, o2)); - } - } - if (a2 && o2) { - o2(i2); - } + } else if (isPlainObject(method)) { + removeInterceptorHook(globalInterceptors, method); + } +}, RemoveInterceptorProtocol); +const promiseInterceptor = { + returnValue(res) { + if (!isPromise(res)) { + return res; } + return res.then((res2) => { + return res2[1]; + }).catch((res2) => { + return res2[0]; + }); } - fn(r, e2, t2, n); - return { - cancel: i.bind(null, r), - model: e2 - }; +}; +function getCurrentPageVm() { + const pages = getCurrentPages(); + const len = pages.length; + const page = pages[len - 1]; + return page && page.$vm; } -const _sfc_main$e = { - name: "MovableView", - mixins: [touchtrack], - props: { - direction: { - type: String, - default: "none" - }, - inertia: { - type: [Boolean, String], - default: false - }, - outOfBounds: { - type: [Boolean, String], - default: false - }, - x: { - type: [Number, String], - default: 0 - }, - y: { - type: [Number, String], - default: 0 - }, - damping: { - type: [Number, String], - default: 20 - }, - friction: { - type: [Number, String], - default: 2 - }, - disabled: { - type: [Boolean, String], - default: false - }, - scale: { - type: [Boolean, String], - default: false - }, - scaleMin: { - type: [Number, String], - default: 0.5 - }, - scaleMax: { - type: [Number, String], - default: 10 - }, - scaleValue: { - type: [Number, String], - default: 1 - }, - animation: { - type: [Boolean, String], - default: true +const defaultOptions = { + thresholds: [0], + initialRatio: 0, + observeAll: false +}; +const MARGINS = ["top", "right", "bottom", "left"]; +let reqComponentObserverId = 1; +function normalizeRootMargin(margins = {}) { + return MARGINS.map((name) => `${Number(margins[name]) || 0}px`).join(" "); +} +class ServiceIntersectionObserver { + constructor(component, options) { + this._pageId = component.$page && component.$page.id; + this._component = component; + this._options = extend({}, defaultOptions, options); + } + relativeTo(selector, margins) { + this._options.relativeToSelector = selector; + this._options.rootMargin = normalizeRootMargin(margins); + return this; + } + relativeToViewport(margins) { + this._options.relativeToSelector = void 0; + this._options.rootMargin = normalizeRootMargin(margins); + return this; + } + observe(selector, callback) { + if (!isFunction(callback)) { + return; } + this._options.selector = selector; + this._reqId = reqComponentObserverId++; + addIntersectionObserver({ + reqId: this._reqId, + component: this._component, + options: this._options, + callback + }, this._pageId); + } + disconnect() { + this._reqId && removeIntersectionObserver({reqId: this._reqId, component: this._component}, this._pageId); + } +} +const createIntersectionObserver = defineSyncApi("createIntersectionObserver", (context, options) => { + if (context && !context.$page) { + options = context; + context = null; + } + if (context) { + return new ServiceIntersectionObserver(context, options); + } + return new ServiceIntersectionObserver(getCurrentPageVm(), options); +}); +const createSelectorQuery = () => { +}; +const API_CAN_I_USE = "canIUse"; +const CanIUseProtocol = [ + { + name: "schema", + type: String, + required: true + } +]; +const API_MAKE_PHONE_CALL = "makePhoneCall"; +const MakePhoneCallProtocol = { + phoneNumber: { + type: String, + required: true, + validator(phoneNumber) { + if (!phoneNumber) { + return "parameter error: parameter.phoneNumber should not be empty String;"; + } + } + } +}; +const API_OPEN_DOCUMENT = "openDocument"; +const OpenDocumentProtocol = { + filePath: { + type: String, + required: true }, - data() { - return { - xSync: this._getPx(this.x), - ySync: this._getPx(this.y), - scaleValueSync: Number(this.scaleValue) || 1, - width: 0, - height: 0, - minX: 0, - minY: 0, - maxX: 0, - maxY: 0 - }; - }, - computed: { - dampingNumber() { - var val = Number(this.damping); - return isNaN(val) ? 20 : val; - }, - frictionNumber() { - var val = Number(this.friction); - return isNaN(val) || val <= 0 ? 2 : val; - }, - scaleMinNumber() { - var val = Number(this.scaleMin); - return isNaN(val) ? 0.5 : val; - }, - scaleMaxNumber() { - var val = Number(this.scaleMax); - return isNaN(val) ? 10 : val; - }, - xMove() { - return this.direction === "all" || this.direction === "horizontal"; - }, - yMove() { - return this.direction === "all" || this.direction === "vertical"; + fileType: { + type: String + } +}; +const API_GET_IMAGE_INFO = "getImageInfo"; +const GetImageInfoOptions = { + formatArgs: { + src(src, params) { + params.src = getRealPath(src); + } + } +}; +const GetImageInfoProtocol = { + src: { + type: String, + required: true + } +}; +const API_REQUEST = "request"; +const METHOD = [ + "GET", + "OPTIONS", + "HEAD", + "POST", + "PUT", + "DELETE", + "TRACE", + "CONNECT" +]; +const DEFAULT_METHOD = "GET"; +const dataType = { + JSON: "json" +}; +const RESPONSE_TYPE = ["text", "arraybuffer"]; +const DEFAULT_RESPONSE_TYPE = "text"; +const encode = encodeURIComponent; +function stringifyQuery(url, data) { + let str = url.split("#"); + const hash = str[1] || ""; + str = str[0].split("?"); + let query = str[1] || ""; + url = str[0]; + const search = query.split("&").filter((item) => item); + const params = {}; + search.forEach((item) => { + const part = item.split("="); + params[part[0]] = part[1]; + }); + for (const key in data) { + if (hasOwn$1(data, key)) { + let v2 = data[key]; + if (typeof v2 === "undefined" || v2 === null) { + v2 = ""; + } else if (isPlainObject(v2)) { + v2 = JSON.stringify(v2); + } + params[encode(key)] = encode(v2); } + } + query = Object.keys(params).map((item) => `${item}=${params[item]}`).join("&"); + return url + (query ? "?" + query : "") + (hash ? "#" + hash : ""); +} +const RequestProtocol = { + method: { + type: String }, - watch: { - x(val) { - this.xSync = this._getPx(val); - }, - xSync(val) { - this._setX(val); + data: { + type: [Object, String, Array, ArrayBuffer] + }, + url: { + type: String, + required: true + }, + header: { + type: Object + }, + dataType: { + type: String + }, + responseType: { + type: String + }, + withCredentials: { + type: Boolean + } +}; +const RequestOptions = { + formatArgs: { + method(value, params) { + params.method = (value || "").toUpperCase(); + if (METHOD.indexOf(params.method) === -1) { + params.method = DEFAULT_METHOD; + } }, - y(val) { - this.ySync = this._getPx(val); + data(value, params) { + params.data = value || ""; }, - ySync(val) { - this._setY(val); + url(value, params) { + if (params.method === DEFAULT_METHOD && isPlainObject(params.data) && Object.keys(params.data).length) { + params.url = stringifyQuery(value, params.data); + } }, - scaleValue(val) { - this.scaleValueSync = Number(val) || 0; + header(value, params) { + const header = params.header = value || {}; + if (params.method !== DEFAULT_METHOD) { + if (!Object.keys(header).find((key) => key.toLowerCase() === "content-type")) { + header["Content-Type"] = "application/json"; + } + } }, - scaleValueSync(val) { - this._setScaleValue(val); + dataType(value, params) { + params.dataType = (value || dataType.JSON).toLowerCase(); }, - scaleMinNumber() { - this._setScaleMinOrMax(); - }, - scaleMaxNumber() { - this._setScaleMinOrMax(); - } - }, - created: function() { - this._offset = { - x: 0, - y: 0 - }; - this._scaleOffset = { - x: 0, - y: 0 - }; - this._translateX = 0; - this._translateY = 0; - this._scale = 1; - this._oldScale = 1; - this._STD = new STD(1, 9 * Math.pow(this.dampingNumber, 2) / 40, this.dampingNumber); - this._friction = new Friction$1(1, this.frictionNumber); - this._declineX = new Decline(); - this._declineY = new Decline(); - this.__touchInfo = { - historyX: [0, 0], - historyY: [0, 0], - historyT: [0, 0] - }; - }, - mounted: function() { - this.touchtrack(this.$el, "_onTrack"); - this.setParent(); - this._friction.reconfigure(1, this.frictionNumber); - this._STD.reconfigure(1, 9 * Math.pow(this.dampingNumber, 2) / 40, this.dampingNumber); - this.$el.style.transformOrigin = "center"; - }, - methods: { - _getPx(val) { - if (/\d+[ur]px$/i.test(val)) { - return uni.upx2px(parseFloat(val)); + responseType(value, params) { + params.responseType = (value || "").toLowerCase(); + if (RESPONSE_TYPE.indexOf(params.responseType) === -1) { + params.responseType = DEFAULT_RESPONSE_TYPE; } - return Number(val) || 0; - }, - _setX: function(val) { - if (this.xMove) { - if (val + this._scaleOffset.x === this._translateX) { - return this._translateX; - } else { - if (this._SFA) { - this._SFA.cancel(); - } - this._animationTo(val + this._scaleOffset.x, this.ySync + this._scaleOffset.y, this._scale); + } + } +}; +function encodeQueryString(url) { + if (typeof url !== "string") { + return url; + } + const index2 = url.indexOf("?"); + if (index2 === -1) { + return url; + } + const query = url.substr(index2 + 1).trim().replace(/^(\?|#|&)/, ""); + if (!query) { + return url; + } + url = url.substr(0, index2); + const params = []; + query.split("&").forEach((param) => { + const parts = param.replace(/\+/g, " ").split("="); + const key = parts.shift(); + const val = parts.length > 0 ? parts.join("=") : ""; + params.push(key + "=" + encodeURIComponent(val)); + }); + return params.length ? url + "?" + params.join("&") : url; +} +const ANIMATION_IN = [ + "slide-in-right", + "slide-in-left", + "slide-in-top", + "slide-in-bottom", + "fade-in", + "zoom-out", + "zoom-fade-out", + "pop-in", + "none" +]; +const ANIMATION_OUT = [ + "slide-out-right", + "slide-out-left", + "slide-out-top", + "slide-out-bottom", + "fade-out", + "zoom-in", + "zoom-fade-in", + "pop-out", + "none" +]; +const BaseRouteProtocol = { + url: { + type: String, + required: true + } +}; +const API_NAVIGATE_TO = "navigateTo"; +const API_REDIRECT_TO = "redirectTo"; +const API_RE_LAUNCH = "reLaunch"; +const API_SWITCH_TAB = "switchTab"; +const API_NAVIGATE_BACK = "navigateBack"; +const API_PRELOAD_PAGE = "preloadPage"; +const API_UN_PRELOAD_PAGE = "unPreloadPage"; +const NavigateToProtocol = extend({}, BaseRouteProtocol, createAnimationProtocol(ANIMATION_IN)); +const NavigateBackProtocol = extend({ + delta: { + type: Number + } +}, createAnimationProtocol(ANIMATION_OUT)); +const RedirectToProtocol = BaseRouteProtocol; +const ReLaunchProtocol = BaseRouteProtocol; +const SwitchTabProtocol = BaseRouteProtocol; +const NavigateToOptions = /* @__PURE__ */ createRouteOptions(API_NAVIGATE_TO); +const RedirectToOptions = /* @__PURE__ */ createRouteOptions(API_REDIRECT_TO); +const ReLaunchOptions = /* @__PURE__ */ createRouteOptions(API_RE_LAUNCH); +const SwitchTabOptions = /* @__PURE__ */ createRouteOptions(API_SWITCH_TAB); +const NavigateBackOptions = { + formatArgs: { + delta(delta, params) { + delta = parseInt(delta) || 1; + params.delta = Math.min(getCurrentPages().length - 1, delta); + } + } +}; +function createAnimationProtocol(animationTypes) { + return { + animationType: { + type: String, + validator(type) { + if (type && animationTypes.indexOf(type) === -1) { + return "`" + type + "` is not supported for `animationType` (supported values are: `" + animationTypes.join("`|`") + "`)"; } } - return val; }, - _setY: function(val) { - if (this.yMove) { - if (val + this._scaleOffset.y === this._translateY) { - return this._translateY; - } else { - if (this._SFA) { - this._SFA.cancel(); - } - this._animationTo(this.xSync + this._scaleOffset.x, val + this._scaleOffset.y, this._scale); - } - } - return val; + animationDuration: { + type: Number + } + }; +} +let navigatorLock; +function beforeRoute() { + navigatorLock = ""; +} +function createRouteOptions(type) { + return { + formatArgs: { + url: createNormalizeUrl(type) }, - _setScaleMinOrMax: function() { - if (!this.scale) { - return false; + beforeAll: beforeRoute + }; +} +function createNormalizeUrl(type) { + return function normalizeUrl(url, params) { + url = getRealRoute(url); + const pagePath = url.split("?")[0]; + if (url === "/") { + url = __uniRoutes[0].path; + } + const routeOptions = __uniRoutes.find(({path}) => path === pagePath); + if (!routeOptions) { + return "page `" + url + "` is not found"; + } + if (type === API_NAVIGATE_TO || type === API_REDIRECT_TO) { + if (routeOptions.meta.isTabBar) { + return `can not ${type} a tabbar page`; } - this._updateScale(this._scale, true); - this._updateOldScale(this._scale); - }, - _setScaleValue: function(scale) { - if (!this.scale) { - return false; + } else if (type === API_SWITCH_TAB) { + if (!routeOptions.meta.isTabBar) { + return "can not switch to no-tabBar page"; } - scale = this._adjustScale(scale); - this._updateScale(scale, true); - this._updateOldScale(scale); - return scale; - }, - __handleTouchStart: function() { - if (!this._isScaling) { - if (!this.disabled) { - if (this._FA) { - this._FA.cancel(); - } - if (this._SFA) { - this._SFA.cancel(); - } - this.__touchInfo.historyX = [0, 0]; - this.__touchInfo.historyY = [0, 0]; - this.__touchInfo.historyT = [0, 0]; - if (this.xMove) { - this.__baseX = this._translateX; - } - if (this.yMove) { - this.__baseY = this._translateY; - } - this.$el.style.willChange = "transform"; - this._checkCanMove = null; - this._firstMoveDirection = null; - this._isTouching = true; + } + if ((type === API_SWITCH_TAB || type === API_PRELOAD_PAGE) && routeOptions.meta.isTabBar && params.openType !== "appLaunch") { + url = pagePath; + } + if (routeOptions.meta.isEntry) { + url = url.replace(routeOptions.path, "/"); + } + params.url = encodeQueryString(url); + if (type === API_UN_PRELOAD_PAGE) { + return; + } else if (type === API_PRELOAD_PAGE) { + if (routeOptions.meta.isTabBar) { + const pages = getCurrentPages(true); + const tabBarPagePath = routeOptions.path.substr(1); + if (pages.find((page) => page.route === tabBarPagePath)) { + return "tabBar page `" + tabBarPagePath + "` already exists"; } } - }, - __handleTouchMove: function(event2) { - var self = this; - if (!this._isScaling && !this.disabled && this._isTouching) { - let x = this._translateX; - let y = this._translateY; - if (this._firstMoveDirection === null) { - this._firstMoveDirection = Math.abs(event2.detail.dx / event2.detail.dy) > 1 ? "htouchmove" : "vtouchmove"; - } - if (this.xMove) { - x = event2.detail.dx + this.__baseX; - this.__touchInfo.historyX.shift(); - this.__touchInfo.historyX.push(x); - if (!this.yMove && this._checkCanMove === null) { - this._checkCanMove = Math.abs(event2.detail.dx / event2.detail.dy) < 1; - } + return; + } + if (navigatorLock === url && params.openType !== "appLaunch") { + return `${navigatorLock} locked`; + } + if (__uniConfig.ready) { + navigatorLock = url; + } + }; +} +const initIntersectionObserverPolyfill = function() { + if (typeof window !== "object") { + return; + } + if ("IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype) { + if (!("isIntersecting" in window.IntersectionObserverEntry.prototype)) { + Object.defineProperty(window.IntersectionObserverEntry.prototype, "isIntersecting", { + get: function() { + return this.intersectionRatio > 0; } - if (this.yMove) { - y = event2.detail.dy + this.__baseY; - this.__touchInfo.historyY.shift(); - this.__touchInfo.historyY.push(y); - if (!this.xMove && this._checkCanMove === null) { - this._checkCanMove = Math.abs(event2.detail.dy / event2.detail.dx) < 1; - } + }); + } + return; + } + function getFrameElement(doc) { + try { + return doc.defaultView && doc.defaultView.frameElement || null; + } catch (e2) { + return null; + } + } + var document2 = function(startDoc) { + var doc = startDoc; + var frame = getFrameElement(doc); + while (frame) { + doc = frame.ownerDocument; + frame = getFrameElement(doc); + } + return doc; + }(window.document); + var registry = []; + var crossOriginUpdater = null; + var crossOriginRect = null; + function IntersectionObserverEntry(entry) { + this.time = entry.time; + this.target = entry.target; + this.rootBounds = ensureDOMRect(entry.rootBounds); + this.boundingClientRect = ensureDOMRect(entry.boundingClientRect); + this.intersectionRect = ensureDOMRect(entry.intersectionRect || getEmptyRect()); + this.isIntersecting = !!entry.intersectionRect; + var targetRect = this.boundingClientRect; + var targetArea = targetRect.width * targetRect.height; + var intersectionRect = this.intersectionRect; + var intersectionArea = intersectionRect.width * intersectionRect.height; + if (targetArea) { + this.intersectionRatio = Number((intersectionArea / targetArea).toFixed(4)); + } else { + this.intersectionRatio = this.isIntersecting ? 1 : 0; + } + } + function IntersectionObserver2(callback, opt_options) { + var options = opt_options || {}; + if (typeof callback != "function") { + throw new Error("callback must be a function"); + } + if (options.root && options.root.nodeType != 1 && options.root.nodeType != 9) { + throw new Error("root must be a Document or Element"); + } + this._checkForIntersections = throttle2(this._checkForIntersections.bind(this), this.THROTTLE_TIMEOUT); + this._callback = callback; + this._observationTargets = []; + this._queuedEntries = []; + this._rootMarginValues = this._parseRootMargin(options.rootMargin); + this.thresholds = this._initThresholds(options.threshold); + this.root = options.root || null; + this.rootMargin = this._rootMarginValues.map(function(margin) { + return margin.value + margin.unit; + }).join(" "); + this._monitoringDocuments = []; + this._monitoringUnsubscribes = []; + } + IntersectionObserver2.prototype.THROTTLE_TIMEOUT = 100; + IntersectionObserver2.prototype.POLL_INTERVAL = null; + IntersectionObserver2.prototype.USE_MUTATION_OBSERVER = true; + IntersectionObserver2._setupCrossOriginUpdater = function() { + if (!crossOriginUpdater) { + crossOriginUpdater = function(boundingClientRect, intersectionRect) { + if (!boundingClientRect || !intersectionRect) { + crossOriginRect = getEmptyRect(); + } else { + crossOriginRect = convertFromParentRect(boundingClientRect, intersectionRect); } - this.__touchInfo.historyT.shift(); - this.__touchInfo.historyT.push(event2.detail.timeStamp); - if (!this._checkCanMove) { - event2.preventDefault(); - let source = "touch"; - if (x < this.minX) { - if (this.outOfBounds) { - source = "touch-out-of-bounds"; - x = this.minX - this._declineX.x(this.minX - x); - } else { - x = this.minX; - } - } else if (x > this.maxX) { - if (this.outOfBounds) { - source = "touch-out-of-bounds"; - x = this.maxX + this._declineX.x(x - this.maxX); - } else { - x = this.maxX; - } - } - if (y < this.minY) { - if (this.outOfBounds) { - source = "touch-out-of-bounds"; - y = this.minY - this._declineY.x(this.minY - y); - } else { - y = this.minY; - } - } else { - if (y > this.maxY) { - if (this.outOfBounds) { - source = "touch-out-of-bounds"; - y = this.maxY + this._declineY.x(y - this.maxY); - } else { - y = this.maxY; - } - } - } - _requestAnimationFrame(function() { - self._setTransform(x, y, self._scale, source); - }); + registry.forEach(function(observer) { + observer._checkForIntersections(); + }); + }; + } + return crossOriginUpdater; + }; + IntersectionObserver2._resetCrossOriginUpdater = function() { + crossOriginUpdater = null; + crossOriginRect = null; + }; + IntersectionObserver2.prototype.observe = function(target) { + var isTargetAlreadyObserved = this._observationTargets.some(function(item) { + return item.element == target; + }); + if (isTargetAlreadyObserved) { + return; + } + if (!(target && target.nodeType == 1)) { + throw new Error("target must be an Element"); + } + this._registerInstance(); + this._observationTargets.push({element: target, entry: null}); + this._monitorIntersections(target.ownerDocument); + this._checkForIntersections(); + }; + IntersectionObserver2.prototype.unobserve = function(target) { + this._observationTargets = this._observationTargets.filter(function(item) { + return item.element != target; + }); + this._unmonitorIntersections(target.ownerDocument); + if (this._observationTargets.length == 0) { + this._unregisterInstance(); + } + }; + IntersectionObserver2.prototype.disconnect = function() { + this._observationTargets = []; + this._unmonitorAllIntersections(); + this._unregisterInstance(); + }; + IntersectionObserver2.prototype.takeRecords = function() { + var records = this._queuedEntries.slice(); + this._queuedEntries = []; + return records; + }; + IntersectionObserver2.prototype._initThresholds = function(opt_threshold) { + var threshold = opt_threshold || [0]; + if (!Array.isArray(threshold)) + threshold = [threshold]; + return threshold.sort().filter(function(t2, i2, a2) { + if (typeof t2 != "number" || isNaN(t2) || t2 < 0 || t2 > 1) { + throw new Error("threshold must be a number between 0 and 1 inclusively"); + } + return t2 !== a2[i2 - 1]; + }); + }; + IntersectionObserver2.prototype._parseRootMargin = function(opt_rootMargin) { + var marginString = opt_rootMargin || "0px"; + var margins = marginString.split(/\s+/).map(function(margin) { + var parts = /^(-?\d*\.?\d+)(px|%)$/.exec(margin); + if (!parts) { + throw new Error("rootMargin must be specified in pixels or percent"); + } + return {value: parseFloat(parts[1]), unit: parts[2]}; + }); + margins[1] = margins[1] || margins[0]; + margins[2] = margins[2] || margins[0]; + margins[3] = margins[3] || margins[1]; + return margins; + }; + IntersectionObserver2.prototype._monitorIntersections = function(doc) { + var win = doc.defaultView; + if (!win) { + return; + } + if (this._monitoringDocuments.indexOf(doc) != -1) { + return; + } + var callback = this._checkForIntersections; + var monitoringInterval = null; + var domObserver = null; + if (this.POLL_INTERVAL) { + monitoringInterval = win.setInterval(callback, this.POLL_INTERVAL); + } else { + addEvent(win, "resize", callback, true); + addEvent(doc, "scroll", callback, true); + if (this.USE_MUTATION_OBSERVER && "MutationObserver" in win) { + domObserver = new win.MutationObserver(callback); + domObserver.observe(doc, { + attributes: true, + childList: true, + characterData: true, + subtree: true + }); + } + } + this._monitoringDocuments.push(doc); + this._monitoringUnsubscribes.push(function() { + var win2 = doc.defaultView; + if (win2) { + if (monitoringInterval) { + win2.clearInterval(monitoringInterval); } + removeEvent(win2, "resize", callback, true); } - }, - __handleTouchEnd: function() { - var self = this; - if (!this._isScaling && !this.disabled && this._isTouching) { - this.$el.style.willChange = "auto"; - this._isTouching = false; - if (!this._checkCanMove && !this._revise("out-of-bounds") && this.inertia) { - const xv = 1e3 * (this.__touchInfo.historyX[1] - this.__touchInfo.historyX[0]) / (this.__touchInfo.historyT[1] - this.__touchInfo.historyT[0]); - const yv = 1e3 * (this.__touchInfo.historyY[1] - this.__touchInfo.historyY[0]) / (this.__touchInfo.historyT[1] - this.__touchInfo.historyT[0]); - this._friction.setV(xv, yv); - this._friction.setS(this._translateX, this._translateY); - const x0 = this._friction.delta().x; - const y0 = this._friction.delta().y; - let x = x0 + this._translateX; - let y = y0 + this._translateY; - if (x < this.minX) { - x = this.minX; - y = this._translateY + (this.minX - this._translateX) * y0 / x0; - } else { - if (x > this.maxX) { - x = this.maxX; - y = this._translateY + (this.maxX - this._translateX) * y0 / x0; - } - } - if (y < this.minY) { - y = this.minY; - x = this._translateX + (this.minY - this._translateY) * x0 / y0; - } else { - if (y > this.maxY) { - y = this.maxY; - x = this._translateX + (this.maxY - this._translateY) * x0 / y0; - } - } - this._friction.setEnd(x, y); - this._FA = g(this._friction, function() { - var t2 = self._friction.s(); - var x2 = t2.x; - var y2 = t2.y; - self._setTransform(x2, y2, self._scale, "friction"); - }, function() { - self._FA.cancel(); - }); + removeEvent(doc, "scroll", callback, true); + if (domObserver) { + domObserver.disconnect(); + } + }); + var rootDoc = this.root && (this.root.ownerDocument || this.root) || document2; + if (doc != rootDoc) { + var frame = getFrameElement(doc); + if (frame) { + this._monitorIntersections(frame.ownerDocument); + } + } + }; + IntersectionObserver2.prototype._unmonitorIntersections = function(doc) { + var index2 = this._monitoringDocuments.indexOf(doc); + if (index2 == -1) { + return; + } + var rootDoc = this.root && (this.root.ownerDocument || this.root) || document2; + var hasDependentTargets = this._observationTargets.some(function(item) { + var itemDoc = item.element.ownerDocument; + if (itemDoc == doc) { + return true; + } + while (itemDoc && itemDoc != rootDoc) { + var frame2 = getFrameElement(itemDoc); + itemDoc = frame2 && frame2.ownerDocument; + if (itemDoc == doc) { + return true; } } - }, - _onTrack: function(event2) { - switch (event2.detail.state) { - case "start": - this.__handleTouchStart(); - break; - case "move": - this.__handleTouchMove(event2); - break; - case "end": - this.__handleTouchEnd(); + return false; + }); + if (hasDependentTargets) { + return; + } + var unsubscribe = this._monitoringUnsubscribes[index2]; + this._monitoringDocuments.splice(index2, 1); + this._monitoringUnsubscribes.splice(index2, 1); + unsubscribe(); + if (doc != rootDoc) { + var frame = getFrameElement(doc); + if (frame) { + this._unmonitorIntersections(frame.ownerDocument); } - }, - _getLimitXY: function(x, y) { - var outOfBounds = false; - if (x > this.maxX) { - x = this.maxX; - outOfBounds = true; + } + }; + IntersectionObserver2.prototype._unmonitorAllIntersections = function() { + var unsubscribes = this._monitoringUnsubscribes.slice(0); + this._monitoringDocuments.length = 0; + this._monitoringUnsubscribes.length = 0; + for (var i2 = 0; i2 < unsubscribes.length; i2++) { + unsubscribes[i2](); + } + }; + IntersectionObserver2.prototype._checkForIntersections = function() { + if (!this.root && crossOriginUpdater && !crossOriginRect) { + return; + } + var rootIsInDom = this._rootIsInDom(); + var rootRect = rootIsInDom ? this._getRootRect() : getEmptyRect(); + this._observationTargets.forEach(function(item) { + var target = item.element; + var targetRect = getBoundingClientRect(target); + var rootContainsTarget = this._rootContainsTarget(target); + var oldEntry = item.entry; + var intersectionRect = rootIsInDom && rootContainsTarget && this._computeTargetAndRootIntersection(target, targetRect, rootRect); + var rootBounds = null; + if (!this._rootContainsTarget(target)) { + rootBounds = getEmptyRect(); + } else if (!crossOriginUpdater || this.root) { + rootBounds = rootRect; + } + var newEntry = item.entry = new IntersectionObserverEntry({ + time: now(), + target, + boundingClientRect: targetRect, + rootBounds, + intersectionRect + }); + if (!oldEntry) { + this._queuedEntries.push(newEntry); + } else if (rootIsInDom && rootContainsTarget) { + if (this._hasCrossedThreshold(oldEntry, newEntry)) { + this._queuedEntries.push(newEntry); + } } else { - if (x < this.minX) { - x = this.minX; - outOfBounds = true; + if (oldEntry && oldEntry.isIntersecting) { + this._queuedEntries.push(newEntry); } } - if (y > this.maxY) { - y = this.maxY; - outOfBounds = true; + }, this); + if (this._queuedEntries.length) { + this._callback(this.takeRecords(), this); + } + }; + IntersectionObserver2.prototype._computeTargetAndRootIntersection = function(target, targetRect, rootRect) { + if (window.getComputedStyle(target).display == "none") + return; + var intersectionRect = targetRect; + var parent = getParentNode(target); + var atRoot = false; + while (!atRoot && parent) { + var parentRect = null; + var parentComputedStyle = parent.nodeType == 1 ? window.getComputedStyle(parent) : {}; + if (parentComputedStyle.display == "none") + return null; + if (parent == this.root || parent.nodeType == 9) { + atRoot = true; + if (parent == this.root || parent == document2) { + if (crossOriginUpdater && !this.root) { + if (!crossOriginRect || crossOriginRect.width == 0 && crossOriginRect.height == 0) { + parent = null; + parentRect = null; + intersectionRect = null; + } else { + parentRect = crossOriginRect; + } + } else { + parentRect = rootRect; + } + } else { + var frame = getParentNode(parent); + var frameRect = frame && getBoundingClientRect(frame); + var frameIntersect = frame && this._computeTargetAndRootIntersection(frame, frameRect, rootRect); + if (frameRect && frameIntersect) { + parent = frame; + parentRect = convertFromParentRect(frameRect, frameIntersect); + } else { + parent = null; + intersectionRect = null; + } + } } else { - if (y < this.minY) { - y = this.minY; - outOfBounds = true; + var doc = parent.ownerDocument; + if (parent != doc.body && parent != doc.documentElement && parentComputedStyle.overflow != "visible") { + parentRect = getBoundingClientRect(parent); } } - return { - x, - y, - outOfBounds - }; - }, - setParent: function() { - if (!this.$parent._isMounted) { - return; + if (parentRect) { + intersectionRect = computeRectIntersection(parentRect, intersectionRect); } - if (this._FA) { - this._FA.cancel(); + if (!intersectionRect) + break; + parent = parent && getParentNode(parent); + } + return intersectionRect; + }; + IntersectionObserver2.prototype._getRootRect = function() { + var rootRect; + if (this.root && !isDoc(this.root)) { + rootRect = getBoundingClientRect(this.root); + } else { + var doc = isDoc(this.root) ? this.root : document2; + var html = doc.documentElement; + var body = doc.body; + rootRect = { + top: 0, + left: 0, + right: html.clientWidth || body.clientWidth, + width: html.clientWidth || body.clientWidth, + bottom: html.clientHeight || body.clientHeight, + height: html.clientHeight || body.clientHeight + }; + } + return this._expandRectByRootMargin(rootRect); + }; + IntersectionObserver2.prototype._expandRectByRootMargin = function(rect) { + var margins = this._rootMarginValues.map(function(margin, i2) { + return margin.unit == "px" ? margin.value : margin.value * (i2 % 2 ? rect.width : rect.height) / 100; + }); + var newRect = { + top: rect.top - margins[0], + right: rect.right + margins[1], + bottom: rect.bottom + margins[2], + left: rect.left - margins[3] + }; + newRect.width = newRect.right - newRect.left; + newRect.height = newRect.bottom - newRect.top; + return newRect; + }; + IntersectionObserver2.prototype._hasCrossedThreshold = function(oldEntry, newEntry) { + var oldRatio = oldEntry && oldEntry.isIntersecting ? oldEntry.intersectionRatio || 0 : -1; + var newRatio = newEntry.isIntersecting ? newEntry.intersectionRatio || 0 : -1; + if (oldRatio === newRatio) + return; + for (var i2 = 0; i2 < this.thresholds.length; i2++) { + var threshold = this.thresholds[i2]; + if (threshold == oldRatio || threshold == newRatio || threshold < oldRatio !== threshold < newRatio) { + return true; } - if (this._SFA) { - this._SFA.cancel(); + } + }; + IntersectionObserver2.prototype._rootIsInDom = function() { + return !this.root || containsDeep(document2, this.root); + }; + IntersectionObserver2.prototype._rootContainsTarget = function(target) { + var rootDoc = this.root && (this.root.ownerDocument || this.root) || document2; + return containsDeep(rootDoc, target) && (!this.root || rootDoc == target.ownerDocument); + }; + IntersectionObserver2.prototype._registerInstance = function() { + if (registry.indexOf(this) < 0) { + registry.push(this); + } + }; + IntersectionObserver2.prototype._unregisterInstance = function() { + var index2 = registry.indexOf(this); + if (index2 != -1) + registry.splice(index2, 1); + }; + function now() { + return window.performance && performance.now && performance.now(); + } + function throttle2(fn, timeout) { + var timer = null; + return function() { + if (!timer) { + timer = setTimeout(function() { + fn(); + timer = null; + }, timeout); } - var scale = this.scale ? this.scaleValueSync : 1; - this._updateOffset(); - this._updateWH(scale); - this._updateBoundary(); - this._translateX = this.xSync + this._scaleOffset.x; - this._translateY = this.ySync + this._scaleOffset.y; - var limitXY = this._getLimitXY(this._translateX, this._translateY); - var x = limitXY.x; - var y = limitXY.y; - this._setTransform(x, y, scale, "", true); - this._updateOldScale(scale); - }, - _updateOffset: function() { - this._offset.x = p(this.$el, this.$parent.$el); - this._offset.y = f(this.$el, this.$parent.$el); - }, - _updateWH: function(scale) { - scale = scale || this._scale; - scale = this._adjustScale(scale); - var rect = this.$el.getBoundingClientRect(); - this.height = rect.height / this._scale; - this.width = rect.width / this._scale; - var height = this.height * scale; - var width = this.width * scale; - this._scaleOffset.x = (width - this.width) / 2; - this._scaleOffset.y = (height - this.height) / 2; - }, - _updateBoundary: function() { - var x = 0 - this._offset.x + this._scaleOffset.x; - var width = this.$parent.width - this.width - this._offset.x - this._scaleOffset.x; - this.minX = Math.min(x, width); - this.maxX = Math.max(x, width); - var y = 0 - this._offset.y + this._scaleOffset.y; - var height = this.$parent.height - this.height - this._offset.y - this._scaleOffset.y; - this.minY = Math.min(y, height); - this.maxY = Math.max(y, height); - }, - _beginScale: function() { - this._isScaling = true; - }, - _endScale: function() { - this._isScaling = false; - this._updateOldScale(this._scale); - }, - _setScale: function(scale) { - if (this.scale) { - scale = this._adjustScale(scale); - scale = this._oldScale * scale; - this._beginScale(); - this._updateScale(scale); - } - }, - _updateScale: function(scale, animat) { - var self = this; - if (this.scale) { - scale = this._adjustScale(scale); - this._updateWH(scale); - this._updateBoundary(); - const limitXY = this._getLimitXY(this._translateX, this._translateY); - const x = limitXY.x; - const y = limitXY.y; - if (animat) { - this._animationTo(x, y, scale, "", true, true); - } else { - _requestAnimationFrame(function() { - self._setTransform(x, y, scale, "", true, true); - }); - } - } - }, - _updateOldScale: function(scale) { - this._oldScale = scale; - }, - _adjustScale: function(scale) { - scale = Math.max(0.5, this.scaleMinNumber, scale); - scale = Math.min(10, this.scaleMaxNumber, scale); - return scale; - }, - _animationTo: function(x, y, scale, source, r, o2) { - var self = this; - if (this._FA) { - this._FA.cancel(); - } - if (this._SFA) { - this._SFA.cancel(); - } - if (!this.xMove) { - x = this._translateX; - } - if (!this.yMove) { - y = this._translateY; - } - if (!this.scale) { - scale = this._scale; - } - var limitXY = this._getLimitXY(x, y); - x = limitXY.x; - y = limitXY.y; - if (!this.animation) { - this._setTransform(x, y, scale, source, r, o2); - return; - } - this._STD._springX._solution = null; - this._STD._springY._solution = null; - this._STD._springScale._solution = null; - this._STD._springX._endPosition = this._translateX; - this._STD._springY._endPosition = this._translateY; - this._STD._springScale._endPosition = this._scale; - this._STD.setEnd(x, y, scale, 1); - this._SFA = g(this._STD, function() { - var data = self._STD.x(); - var x2 = data.x; - var y2 = data.y; - var scale2 = data.scale; - self._setTransform(x2, y2, scale2, source, r, o2); - }, function() { - self._SFA.cancel(); - }); - }, - _revise: function(source) { - var limitXY = this._getLimitXY(this._translateX, this._translateY); - var x = limitXY.x; - var y = limitXY.y; - var outOfBounds = limitXY.outOfBounds; - if (outOfBounds) { - this._animationTo(x, y, this._scale, source); - } - return outOfBounds; - }, - _setTransform: function(x, y, scale, source = "", r, o2) { - if (!(x !== null && x.toString() !== "NaN" && typeof x === "number")) { - x = this._translateX || 0; - } - if (!(y !== null && y.toString() !== "NaN" && typeof y === "number")) { - y = this._translateY || 0; - } - x = Number(x.toFixed(1)); - y = Number(y.toFixed(1)); - scale = Number(scale.toFixed(1)); - if (!(this._translateX === x && this._translateY === y)) { - if (!r) { - this.$trigger("change", {}, { - x: v(x, this._scaleOffset.x), - y: v(y, this._scaleOffset.y), - source - }); - } - } - if (!this.scale) { - scale = this._scale; - } - scale = this._adjustScale(scale); - scale = +scale.toFixed(3); - if (o2 && scale !== this._scale) { - this.$trigger("scale", {}, { - x, - y, - scale - }); - } - var transform = "translateX(" + x + "px) translateY(" + y + "px) translateZ(0px) scale(" + scale + ")"; - this.$el.style.transform = transform; - this.$el.style.webkitTransform = transform; - this._translateX = x; - this._translateY = y; - this._scale = scale; + }; + } + function addEvent(node, event2, fn, opt_useCapture) { + if (typeof node.addEventListener == "function") { + node.addEventListener(event2, fn, opt_useCapture || false); + } else if (typeof node.attachEvent == "function") { + node.attachEvent("on" + event2, fn); + } + } + function removeEvent(node, event2, fn, opt_useCapture) { + if (typeof node.removeEventListener == "function") { + node.removeEventListener(event2, fn, opt_useCapture || false); + } else if (typeof node.detatchEvent == "function") { + node.detatchEvent("on" + event2, fn); + } + } + function computeRectIntersection(rect1, rect2) { + var top = Math.max(rect1.top, rect2.top); + var bottom = Math.min(rect1.bottom, rect2.bottom); + var left = Math.max(rect1.left, rect2.left); + var right = Math.min(rect1.right, rect2.right); + var width = right - left; + var height = bottom - top; + return width >= 0 && height >= 0 && { + top, + bottom, + left, + right, + width, + height + } || null; + } + function getBoundingClientRect(el) { + var rect; + try { + rect = el.getBoundingClientRect(); + } catch (err) { + } + if (!rect) + return getEmptyRect(); + if (!(rect.width && rect.height)) { + rect = { + top: rect.top, + right: rect.right, + bottom: rect.bottom, + left: rect.left, + width: rect.right - rect.left, + height: rect.bottom - rect.top + }; + } + return rect; + } + function getEmptyRect() { + return { + top: 0, + bottom: 0, + left: 0, + right: 0, + width: 0, + height: 0 + }; + } + function ensureDOMRect(rect) { + if (!rect || "x" in rect) { + return rect; + } + return { + top: rect.top, + y: rect.top, + bottom: rect.bottom, + left: rect.left, + x: rect.left, + right: rect.right, + width: rect.width, + height: rect.height + }; + } + function convertFromParentRect(parentBoundingRect, parentIntersectionRect) { + var top = parentIntersectionRect.top - parentBoundingRect.top; + var left = parentIntersectionRect.left - parentBoundingRect.left; + return { + top, + left, + height: parentIntersectionRect.height, + width: parentIntersectionRect.width, + bottom: top + parentIntersectionRect.height, + right: left + parentIntersectionRect.width + }; + } + function containsDeep(parent, child) { + var node = child; + while (node) { + if (node == parent) + return true; + node = getParentNode(node); + } + return false; + } + function getParentNode(node) { + var parent = node.parentNode; + if (node.nodeType == 9 && node != document2) { + return getFrameElement(node); + } + if (parent && parent.assignedSlot) { + parent = parent.assignedSlot.parentNode; + } + if (parent && parent.nodeType == 11 && parent.host) { + return parent.host; } + return parent; } + function isDoc(node) { + return node && node.nodeType === 9; + } + window.IntersectionObserver = IntersectionObserver2; + window.IntersectionObserverEntry = IntersectionObserverEntry; }; -function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) { - const _component_v_uni_resize_sensor = resolveComponent("v-uni-resize-sensor"); - return openBlock(), createBlock("uni-movable-view", _ctx.$attrs, [ - createVNode(_component_v_uni_resize_sensor, {onResize: $options.setParent}, null, 8, ["onResize"]), - renderSlot(_ctx.$slots, "default") - ], 16); +function normalizeRect(rect) { + const {bottom, height, left, right, top, width} = rect || {}; + return { + bottom, + height, + left, + right, + top, + width + }; } -_sfc_main$e.render = _sfc_render$e; -const OPEN_TYPES = [ - "navigate", - "redirect", - "switchTab", - "reLaunch", - "navigateBack" -]; -const _sfc_main$d = { - name: "Navigator", - mixins: [hover], +function requestComponentObserver($el, options, callback) { + initIntersectionObserverPolyfill(); + const root = options.relativeToSelector ? $el.querySelector(options.relativeToSelector) : null; + const intersectionObserver = new IntersectionObserver((entries) => { + entries.forEach((entrie) => { + callback({ + intersectionRatio: entrie.intersectionRatio, + intersectionRect: normalizeRect(entrie.intersectionRect), + boundingClientRect: normalizeRect(entrie.boundingClientRect), + relativeRect: normalizeRect(entrie.rootBounds), + time: Date.now() + }); + }); + }, { + root, + rootMargin: options.rootMargin, + threshold: options.thresholds + }); + if (options.observeAll) { + intersectionObserver.USE_MUTATION_OBSERVER = true; + const nodeList = $el.querySelectorAll(options.selector); + for (let i2 = 0; i2 < nodeList.length; i2++) { + intersectionObserver.observe(nodeList[i2]); + } + } else { + intersectionObserver.USE_MUTATION_OBSERVER = false; + const el = $el.querySelector(options.selector); + if (!el) { + console.warn(`Node ${options.selector} is not found. Intersection observer will not trigger.`); + } else { + intersectionObserver.observe(el); + } + } + return intersectionObserver; +} +function addIntersectionObserver({reqId, component, options, callback}, _pageId) { + const $el = findElem(component); + ($el.__io || ($el.__io = {}))[reqId] = requestComponentObserver($el, options, callback); +} +function removeIntersectionObserver({reqId, component}, _pageId) { + const $el = findElem(component); + const intersectionObserver = $el.__io && $el.__io[reqId]; + if (intersectionObserver) { + intersectionObserver.disconnect(); + delete $el.__io[reqId]; + } +} +const _sfc_main$h = { + name: "Image", props: { - hoverClass: { - type: String, - default: "navigator-hover" - }, - url: { + src: { type: String, default: "" }, - openType: { + mode: { type: String, - default: "navigate", - validator(value) { - return ~OPEN_TYPES.indexOf(value); - } - }, - delta: { - type: Number, - default: 1 - }, - hoverStartTime: { - type: [Number, String], - default: 20 - }, - hoverStayTime: { - type: [Number, String], - default: 600 + default: "scaleToFill" }, - exists: { - type: String, - default: "" + lazyLoad: { + type: [Boolean, String], + default: false } }, - methods: { - _onClick($event) { - if (this.openType !== "navigateBack" && !this.url) { - console.error(" should have url attribute when using navigateTo, redirectTo, reLaunch or switchTab"); - return; - } - switch (this.openType) { - case "navigate": - uni.navigateTo({ - url: this.url - }); - break; - case "redirect": - uni.redirectTo({ - url: this.url, - exists: this.exists - }); - break; - case "switchTab": - uni.switchTab({ - url: this.url - }); - break; - case "reLaunch": - uni.reLaunch({ - url: this.url - }); + data() { + return { + originalWidth: 0, + originalHeight: 0, + availHeight: "" + }; + }, + computed: { + ratio() { + return this.originalWidth && this.originalHeight ? this.originalWidth / this.originalHeight : 0; + }, + realImagePath() { + return getRealPath(this.src); + }, + modeStyle() { + let size = "auto"; + let position = ""; + const repeat = "no-repeat"; + switch (this.mode) { + case "aspectFit": + size = "contain"; + position = "center center"; break; - case "navigateBack": - uni.navigateBack({ - delta: this.delta - }); + case "aspectFill": + size = "cover"; + position = "center center"; + break; + case "widthFix": + size = "100% 100%"; + break; + case "top": + position = "center top"; + break; + case "bottom": + position = "center bottom"; + break; + case "center": + position = "center center"; + break; + case "left": + position = "left center"; + break; + case "right": + position = "right center"; + break; + case "top left": + position = "left top"; + break; + case "top right": + position = "right top"; + break; + case "bottom left": + position = "left bottom"; + break; + case "bottom right": + position = "right bottom"; + break; + default: + size = "100% 100%"; + position = "0% 0%"; break; } + return `background-position:${position};background-size:${size};background-repeat:${repeat};`; + } + }, + watch: { + src(newValue, oldValue) { + this._setContentImage(); + this._loadImage(); + }, + mode(newValue, oldValue) { + if (oldValue === "widthFix") { + this.$el.style.height = this.availHeight; + } + if (newValue === "widthFix" && this.ratio) { + this._fixSize(); + } + } + }, + components: { + ResizeSensor: _sfc_main$i + }, + mounted() { + this.availHeight = this.$el.style.height || ""; + this._setContentImage(); + if (!this.realImagePath) { + return; + } + this._loadImage(); + }, + methods: { + _resize() { + if (this.mode === "widthFix") { + this._fixSize(); + } + }, + _fixSize() { + const elWidth = this._getWidth(); + if (elWidth) { + let height = elWidth / this.ratio; + if (typeof navigator && navigator.vendor === "Google Inc." && height > 10) { + height = Math.round(height / 2) * 2; + } + this.$el.style.height = height + "px"; + } + }, + _setContentImage() { + this.$refs.content.style.backgroundImage = this.src ? `url("${this.realImagePath}")` : "none"; + }, + _loadImage() { + const _self = this; + const img = new Image(); + img.onload = function($event) { + _self.originalWidth = this.width; + _self.originalHeight = this.height; + if (_self.mode === "widthFix") { + _self._fixSize(); + } + _self.$trigger("load", $event, { + width: this.width, + height: this.height + }); + }; + img.onerror = function($event) { + _self.$trigger("error", $event, { + errMsg: `GET ${_self.src} 404 (Not Found)` + }); + }; + img.src = this.realImagePath; + }, + _getWidth() { + const computedStyle = window.getComputedStyle(this.$el); + const borderWidth = (parseFloat(computedStyle.borderLeftWidth, 10) || 0) + (parseFloat(computedStyle.borderRightWidth, 10) || 0); + const paddingWidth = (parseFloat(computedStyle.paddingLeft, 10) || 0) + (parseFloat(computedStyle.paddingRight, 10) || 0); + return this.$el.offsetWidth - borderWidth - paddingWidth; } } }; -function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) { - return $props.hoverClass && $props.hoverClass !== "none" ? (openBlock(), createBlock("uni-navigator", { - key: 0, - class: [_ctx.hovering ? $props.hoverClass : ""], - onTouchstart: _cache[1] || (_cache[1] = (...args) => _ctx._hoverTouchStart && _ctx._hoverTouchStart(...args)), - onTouchend: _cache[2] || (_cache[2] = (...args) => _ctx._hoverTouchEnd && _ctx._hoverTouchEnd(...args)), - onTouchcancel: _cache[3] || (_cache[3] = (...args) => _ctx._hoverTouchCancel && _ctx._hoverTouchCancel(...args)), - onClick: _cache[4] || (_cache[4] = (...args) => $options._onClick && $options._onClick(...args)) - }, [ - renderSlot(_ctx.$slots, "default") - ], 34)) : (openBlock(), createBlock("uni-navigator", { - key: 1, - onClick: _cache[5] || (_cache[5] = (...args) => $options._onClick && $options._onClick(...args)) - }, [ - renderSlot(_ctx.$slots, "default") - ])); +function _sfc_render$h(_ctx, _cache, $props, $setup, $data, $options) { + const _component_ResizeSensor = resolveComponent("ResizeSensor"); + return openBlock(), createBlock("uni-image", _ctx.$attrs, [ + createVNode("div", { + ref: "content", + style: $options.modeStyle + }, null, 4), + createVNode("img", {src: $options.realImagePath}, null, 8, ["src"]), + $props.mode === "widthFix" ? (openBlock(), createBlock(_component_ResizeSensor, { + key: 0, + ref: "sensor", + onResize: $options._resize + }, null, 8, ["onResize"])) : createCommentVNode("", true) + ], 16); } -_sfc_main$d.render = _sfc_render$d; -const VALUES = { - activeColor: "#007AFF", - backgroundColor: "#EBEBEB", - activeMode: "backwards" -}; -const _sfc_main$c = { - name: "Progress", +_sfc_main$h.render = _sfc_render$h; +const INPUT_TYPES = ["text", "number", "idcard", "digit", "password"]; +const NUMBER_TYPES = ["number", "digit"]; +const _sfc_main$g = { + name: "Input", + mixins: [baseInput], props: { - percent: { - type: [Number, String], - default: 0, - validator(value) { - return !isNaN(parseFloat(value, 10)); - } + name: { + type: String, + default: "" }, - showInfo: { + type: { + type: String, + default: "text" + }, + password: { type: [Boolean, String], default: false }, - strokeWidth: { - type: [Number, String], - default: 6, - validator(value) { - return !isNaN(parseFloat(value, 10)); - } - }, - color: { + placeholder: { type: String, - default: VALUES.activeColor + default: "" }, - activeColor: { + placeholderStyle: { type: String, - default: VALUES.activeColor + default: "" }, - backgroundColor: { + placeholderClass: { type: String, - default: VALUES.backgroundColor + default: "input-placeholder" }, - active: { + disabled: { type: [Boolean, String], default: false }, - activeMode: { + maxlength: { + type: [Number, String], + default: 140 + }, + focus: { + type: [Boolean, String], + default: false + }, + confirmType: { type: String, - default: VALUES.activeMode + default: "done" } }, data() { return { - currentPercent: 0, - strokeTimer: 0, - lastPercent: 0 + composing: false, + wrapperHeight: 0, + cachedValue: "" }; }, computed: { - outerBarStyle() { - return `background-color: ${this.backgroundColor}; height: ${this.strokeWidth}px;`; + inputType: function() { + let type = ""; + switch (this.type) { + case "text": + this.confirmType === "search" && (type = "search"); + break; + case "idcard": + type = "text"; + break; + case "digit": + type = "number"; + break; + default: + type = ~INPUT_TYPES.indexOf(this.type) ? this.type : "text"; + break; + } + return this.password ? "password" : type; }, - innerBarStyle() { - let backgroundColor = ""; - if (this.color !== VALUES.activeColor && this.activeColor === VALUES.activeColor) { - backgroundColor = this.color; - } else { - backgroundColor = this.activeColor; - } - return `width: ${this.currentPercent}%;background-color: ${backgroundColor}`; - }, - realPercent() { - let realValue = parseFloat(this.percent, 10); - realValue < 0 && (realValue = 0); - realValue > 100 && (realValue = 100); - return realValue; - } - }, - watch: { - realPercent(newValue, oldValue) { - this.strokeTimer && clearInterval(this.strokeTimer); - this.lastPercent = oldValue || 0; - this._activeAnimation(); - } - }, - created() { - this._activeAnimation(); - }, - methods: { - _activeAnimation() { - if (this.active) { - this.currentPercent = this.activeMode === VALUES.activeMode ? 0 : this.lastPercent; - this.strokeTimer = setInterval(() => { - if (this.currentPercent + 1 > this.realPercent) { - this.currentPercent = this.realPercent; - this.strokeTimer && clearInterval(this.strokeTimer); - } else { - this.currentPercent += 1; - } - }, 30); - } else { - this.currentPercent = this.realPercent; - } - } - } -}; -const _hoisted_1$9 = { - key: 0, - class: "uni-progress-info" -}; -function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) { - return openBlock(), createBlock("uni-progress", mergeProps({class: "uni-progress"}, _ctx.$attrs), [ - createVNode("div", { - style: $options.outerBarStyle, - class: "uni-progress-bar" - }, [ - createVNode("div", { - style: $options.innerBarStyle, - class: "uni-progress-inner-bar" - }, null, 4) - ], 4), - $props.showInfo ? (openBlock(), createBlock("p", _hoisted_1$9, toDisplayString($data.currentPercent) + "% ", 1)) : createCommentVNode("", true) - ], 16); -} -_sfc_main$c.render = _sfc_render$c; -var index_vue_vue_type_style_index_0_lang$7 = '\nuni-radio {\r\n -webkit-tap-highlight-color: transparent;\r\n display: inline-block;\r\n cursor: pointer;\n}\nuni-radio[hidden] {\r\n display: none;\n}\nuni-radio[disabled] {\r\n cursor: not-allowed;\n}\nuni-radio .uni-radio-wrapper {\r\n display: -webkit-inline-flex;\r\n display: inline-flex;\r\n -webkit-align-items: center;\r\n align-items: center;\r\n vertical-align: middle;\n}\nuni-radio .uni-radio-input {\r\n -webkit-appearance: none;\r\n appearance: none;\r\n margin-right: 5px;\r\n outline: 0;\r\n border: 1px solid #D1D1D1;\r\n background-color: #ffffff;\r\n border-radius: 50%;\r\n width: 22px;\r\n height: 22px;\r\n position: relative;\n}\nuni-radio:not([disabled]) .uni-radio-input:hover {\r\n border-color: #007aff;\n}\nuni-radio .uni-radio-input.uni-radio-input-checked:before {\r\n font: normal normal normal 14px/1 "uni";\r\n content: "\\EA08";\r\n color: #ffffff;\r\n font-size: 18px;\r\n position: absolute;\r\n top: 50%;\r\n left: 50%;\r\n transform: translate(-50%, -48%) scale(0.73);\r\n -webkit-transform: translate(-50%, -48%) scale(0.73);\n}\nuni-radio .uni-radio-input.uni-radio-input-disabled {\r\n background-color: #E1E1E1;\r\n border-color: #D1D1D1;\n}\nuni-radio .uni-radio-input.uni-radio-input-disabled:before {\r\n color: #ADADAD;\n}\nuni-radio-group {\r\n display: block;\n}\r\n'; -const _sfc_main$b = { - name: "Radio", - mixins: [emitter, listeners], - props: { - checked: { - type: [Boolean, String], - default: false - }, - id: { - type: String, - default: "" - }, - disabled: { - type: [Boolean, String], - default: false - }, - color: { - type: String, - default: "#007AFF" - }, - value: { - type: String, - default: "" - } - }, - data() { - return { - radioChecked: this.checked, - radioValue: this.value - }; - }, - computed: { - checkedStyle() { - return `background-color: ${this.color};border-color: ${this.color};`; + step() { + return ~NUMBER_TYPES.indexOf(this.type) ? "0.000000000000000001" : ""; } }, watch: { - checked(val) { - this.radioChecked = val; + focus(val) { + this.$refs.input && this.$refs.input[val ? "focus" : "blur"](); }, - value(val) { - this.radioValue = val; + maxlength(value) { + const realValue = this.valueSync.slice(0, parseInt(value, 10)); + realValue !== this.valueSync && (this.valueSync = realValue); } }, - listeners: { - "label-click": "_onClick", - "@label-click": "_onClick" - }, created() { - this.$dispatch("RadioGroup", "uni-radio-group-update", { - type: "add", - vm: this - }); this.$dispatch("Form", "uni-form-group-update", { type: "add", vm: this }); }, - beforeDestroy() { - this.$dispatch("RadioGroup", "uni-radio-group-update", { - type: "remove", - vm: this - }); - this.$dispatch("Form", "uni-form-group-update", { - type: "remove", - vm: this - }); - }, - methods: { - _onClick($event) { - if (this.disabled || this.radioChecked) { - return; - } - this.radioChecked = true; - this.$dispatch("RadioGroup", "uni-radio-change", $event, this); - }, - _resetFormData() { - this.radioChecked = this.min; + mounted() { + if (this.confirmType === "search") { + const formElem = document.createElement("form"); + formElem.action = ""; + formElem.onsubmit = function() { + return false; + }; + formElem.className = "uni-input-form"; + formElem.appendChild(this.$refs.input); + this.$refs.wrapper.appendChild(formElem); } - } -}; -const _hoisted_1$8 = {class: "uni-radio-wrapper"}; -function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) { - return openBlock(), createBlock("uni-radio", mergeProps({disabled: $props.disabled}, _ctx.$attrs, { - onClick: _cache[1] || (_cache[1] = (...args) => $options._onClick && $options._onClick(...args)) - }), [ - createVNode("div", _hoisted_1$8, [ - createVNode("div", { - class: [$data.radioChecked ? "uni-radio-input-checked" : "", "uni-radio-input"], - style: $data.radioChecked ? $options.checkedStyle : "" - }, null, 6), - renderSlot(_ctx.$slots, "default") - ]) - ], 16, ["disabled"]); -} -_sfc_main$b.render = _sfc_render$b; -var index_vue_vue_type_style_index_0_lang$6 = "\nuni-radio-group[hidden] {\r\n display: none;\n}\r\n"; -const _sfc_main$a = { - name: "RadioGroup", - mixins: [emitter, listeners], - props: { - name: { - type: String, - default: "" + let $vm = this; + while ($vm) { + const scopeId = $vm.$options._scopeId; + if (scopeId) { + this.$refs.placeholder.setAttribute(scopeId, ""); + } + $vm = $vm.$parent; } - }, - data() { - return { - radioList: [] - }; - }, - listeners: { - "@radio-change": "_changeHandler", - "@radio-group-update": "_radioGroupUpdateHandler" - }, - mounted() { - this._resetRadioGroupValue(this.radioList.length - 1); - }, - created() { - this.$dispatch("Form", "uni-form-group-update", { - type: "add", - vm: this - }); + this.initKeyboard(this.$refs.input); }, beforeDestroy() { this.$dispatch("Form", "uni-form-group-update", { @@ -5314,407 +5273,381 @@ const _sfc_main$a = { }); }, methods: { - _changeHandler($event, vm) { - const index2 = this.radioList.indexOf(vm); - this._resetRadioGroupValue(index2, true); - this.$trigger("change", $event, { - value: vm.radioValue - }); - }, - _radioGroupUpdateHandler($event) { - if ($event.type === "add") { - this.radioList.push($event.vm); - } else { - const index2 = this.radioList.indexOf($event.vm); - this.radioList.splice(index2, 1); + _onKeyup($event) { + if ($event.keyCode === 13) { + this.$trigger("confirm", $event, { + value: $event.target.value + }); } }, - _resetRadioGroupValue(key, change) { - this.radioList.forEach((value, index2) => { - if (index2 === key) { + _onInput($event) { + if (this.composing) { + return; + } + if (~NUMBER_TYPES.indexOf(this.type)) { + if (this.$refs.input.validity && !this.$refs.input.validity.valid) { + $event.target.value = this.cachedValue; + this.valueSync = $event.target.value; return; - } - if (change) { - this.radioList[index2].radioChecked = false; } else { - this.radioList.forEach((v2, i) => { - if (index2 >= i) { - return; - } - if (this.radioList[i].radioChecked) { - this.radioList[index2].radioChecked = false; - } - }); + this.cachedValue = this.valueSync; + } + } + if (this.inputType === "number") { + const maxlength = parseInt(this.maxlength, 10); + if (maxlength > 0 && $event.target.value.length > maxlength) { + $event.target.value = $event.target.value.slice(0, maxlength); + this.valueSync = $event.target.value; + return; } + } + this.$triggerInput($event, { + value: this.valueSync }); }, - _getFormData() { - const data = {}; - if (this.name !== "") { - let value = ""; - this.radioList.forEach((vm) => { - if (vm.radioChecked) { - value = vm.value; - } - }); - data.value = value; - data.key = this.name; - } - return data; + _onFocus($event) { + this.$trigger("focus", $event, { + value: $event.target.value + }); + }, + _onBlur($event) { + this.$trigger("blur", $event, { + value: $event.target.value + }); + }, + _onComposition($event) { + if ($event.type === "compositionstart") { + this.composing = true; + } else { + this.composing = false; + } + }, + _resetFormData() { + this.valueSync = ""; + }, + _getFormData() { + return this.name ? { + value: this.valueSync, + key: this.name + } : {}; } } }; -function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) { - return openBlock(), createBlock("uni-radio-group", _ctx.$attrs, [ - renderSlot(_ctx.$slots, "default") +const _hoisted_1$a = { + ref: "wrapper", + class: "uni-input-wrapper" +}; +function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) { + return openBlock(), createBlock("uni-input", mergeProps({ + onChange: _cache[8] || (_cache[8] = withModifiers(() => { + }, ["stop"])) + }, _ctx.$attrs), [ + createVNode("div", _hoisted_1$a, [ + withDirectives(createVNode("div", { + ref: "placeholder", + style: $props.placeholderStyle, + class: [$props.placeholderClass, "uni-input-placeholder"], + textContent: toDisplayString($props.placeholder) + }, null, 14, ["textContent"]), [ + [vShow, !($data.composing || _ctx.valueSync.length)] + ]), + withDirectives(createVNode("input", { + ref: "input", + "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => _ctx.valueSync = $event), + disabled: $props.disabled, + type: $options.inputType, + maxlength: $props.maxlength, + step: $options.step, + autofocus: $props.focus, + class: "uni-input-input", + autocomplete: "off", + onFocus: _cache[2] || (_cache[2] = (...args) => $options._onFocus && $options._onFocus(...args)), + onBlur: _cache[3] || (_cache[3] = (...args) => $options._onBlur && $options._onBlur(...args)), + onInput: _cache[4] || (_cache[4] = withModifiers((...args) => $options._onInput && $options._onInput(...args), ["stop"])), + onCompositionstart: _cache[5] || (_cache[5] = (...args) => $options._onComposition && $options._onComposition(...args)), + onCompositionend: _cache[6] || (_cache[6] = (...args) => $options._onComposition && $options._onComposition(...args)), + onKeyup: _cache[7] || (_cache[7] = withModifiers((...args) => $options._onKeyup && $options._onKeyup(...args), ["stop"])) + }, null, 40, ["disabled", "type", "maxlength", "step", "autofocus"]), [ + [vModelDynamic, _ctx.valueSync] + ]) + ], 512) ], 16); } -_sfc_main$a.render = _sfc_render$a; -function removeDOCTYPE(html) { - return html.replace(/<\?xml.*\?>\n/, "").replace(/\n/, "").replace(/\n/, ""); -} -function parseAttrs(attrs2) { - return attrs2.reduce(function(pre, attr2) { - let value = attr2.value; - const name = attr2.name; - if (value.match(/ /) && name !== "style") { - value = value.split(" "); +_sfc_main$g.render = _sfc_render$g; +var index_vue_vue_type_style_index_0_lang$8 = "\n.uni-label-pointer {\r\n cursor: pointer;\n}\r\n"; +const _sfc_main$f = { + name: "Label", + mixins: [emitter], + props: { + for: { + type: String, + default: "" } - if (pre[name]) { - if (Array.isArray(pre[name])) { - pre[name].push(value); - } else { - pre[name] = [pre[name], value]; - } - } else { - pre[name] = value; + }, + computed: { + pointer() { + return this.for || this.$slots.default && this.$slots.default.length; } - return pre; - }, {}); -} -function parseHtml(html) { - html = removeDOCTYPE(html); - const stacks = []; - const results = { - node: "root", - children: [] - }; - HTMLParser(html, { - start: function(tag, attrs2, unary) { - const node = { - name: tag - }; - if (attrs2.length !== 0) { - node.attrs = parseAttrs(attrs2); - } - if (unary) { - const parent = stacks[0] || results; - if (!parent.children) { - parent.children = []; - } - parent.children.push(node); - } else { - stacks.unshift(node); + }, + methods: { + _onClick($event) { + let stopPropagation = /^uni-(checkbox|radio|switch)-/.test($event.target.className); + if (!stopPropagation) { + stopPropagation = /^uni-(checkbox|radio|switch|button)$/i.test($event.target.tagName); } - }, - end: function(tag) { - const node = stacks.shift(); - if (node.name !== tag) - console.error("invalid state: mismatch end tag"); - if (stacks.length === 0) { - results.children.push(node); - } else { - const parent = stacks[0]; - if (!parent.children) { - parent.children = []; - } - parent.children.push(node); + if (stopPropagation) { + return; } - }, - chars: function(text2) { - const node = { - type: "text", - text: text2 - }; - if (stacks.length === 0) { - results.children.push(node); + if (this.for) { + UniViewJSBridge.emit("uni-label-click-" + this.$page.id + "-" + this.for, $event, true); } else { - const parent = stacks[0]; - if (!parent.children) { - parent.children = []; - } - parent.children.push(node); + this.$broadcast(["Checkbox", "Radio", "Switch", "Button"], "uni-label-click", $event, true); } - }, - comment: function(text2) { - const node = { - node: "comment", - text: text2 - }; - const parent = stacks[0]; - if (!parent.children) { - parent.children = []; + } + } +}; +function _sfc_render$f(_ctx, _cache, $props, $setup, $data, $options) { + return openBlock(), createBlock("uni-label", mergeProps({ + class: {"uni-label-pointer": $options.pointer} + }, _ctx.$attrs, { + onClick: _cache[1] || (_cache[1] = (...args) => $options._onClick && $options._onClick(...args)) + }), [ + renderSlot(_ctx.$slots, "default") + ], 16); +} +_sfc_main$f.render = _sfc_render$f; +const addListenerToElement = function(element, type, callback, capture) { + element.addEventListener(type, ($event) => { + if (typeof callback === "function") { + if (callback($event) === false) { + $event.preventDefault(); + $event.stopPropagation(); } - parent.children.push(node); } + }, { + passive: false }); - return results.children; -} -const TAGS = { - a: "", - abbr: "", - b: "", - blockquote: "", - br: "", - code: "", - col: ["span", "width"], - colgroup: ["span", "width"], - dd: "", - del: "", - div: "", - dl: "", - dt: "", - em: "", - fieldset: "", - h1: "", - h2: "", - h3: "", - h4: "", - h5: "", - h6: "", - hr: "", - i: "", - img: ["alt", "src", "height", "width"], - ins: "", - label: "", - legend: "", - li: "", - ol: ["start", "type"], - p: "", - q: "", - span: "", - strong: "", - sub: "", - sup: "", - table: ["width"], - tbody: "", - td: ["colspan", "rowspan", "height", "width"], - tfoot: "", - th: ["colspan", "rowspan", "height", "width"], - thead: "", - tr: "", - ul: "" -}; -const CHARS = { - amp: "&", - gt: ">", - lt: "<", - nbsp: " ", - quot: '"', - apos: "'" }; -function decodeEntities(htmlString) { - return htmlString.replace(/&(([a-zA-Z]+)|(#x{0,1}[\da-zA-Z]+));/gi, function(match, stage) { - if (hasOwn$1(CHARS, stage) && CHARS[stage]) { - return CHARS[stage]; - } - if (/^#[0-9]{1,4}$/.test(stage)) { - return String.fromCharCode(stage.slice(1)); - } - if (/^#x[0-9a-f]{1,4}$/i.test(stage)) { - return String.fromCharCode("0" + stage.slice(1)); - } - const wrap = document.createElement("div"); - wrap.innerHTML = match; - return wrap.innerText || wrap.textContent; - }); -} -function parseNodes(nodes, parentNode) { - nodes.forEach(function(node) { - if (!isPlainObject(node)) { - return; - } - if (!hasOwn$1(node, "type") || node.type === "node") { - if (!(typeof node.name === "string" && node.name)) { - return; - } - const tagName = node.name.toLowerCase(); - if (!hasOwn$1(TAGS, tagName)) { - return; - } - const elem = document.createElement(tagName); - if (!elem) { - return; - } - const attrs2 = node.attrs; - if (isPlainObject(attrs2)) { - const tagAttrs = TAGS[tagName] || []; - Object.keys(attrs2).forEach(function(name) { - let value = attrs2[name]; - switch (name) { - case "class": - Array.isArray(value) && (value = value.join(" ")); - case "style": - elem.setAttribute(name, value); - break; - default: - if (tagAttrs.indexOf(name) !== -1) { - elem.setAttribute(name, value); - } - } - }); - } - const children = node.children; - if (Array.isArray(children) && children.length) { - parseNodes(node.children, elem); - } - parentNode.appendChild(elem); - } else { - if (node.type === "text" && typeof node.text === "string" && node.text !== "") { - parentNode.appendChild(document.createTextNode(decodeEntities(node.text))); - } - } - }); - return parentNode; -} -const _sfc_main$9 = { - name: "RichText", - props: { - nodes: { - type: [Array, String], - default: function() { - return []; - } - } - }, - watch: { - nodes(value) { - this._renderNodes(value); - } - }, - mounted() { - this._renderNodes(this.nodes); +var touchtrack = { + beforeDestroy() { + document.removeEventListener("mousemove", this.__mouseMoveEventListener); + document.removeEventListener("mouseup", this.__mouseUpEventListener); }, methods: { - _renderNodes(nodes) { - if (typeof nodes === "string") { - nodes = parseHtml(nodes); - } - const nodeList = parseNodes(nodes, document.createDocumentFragment()); - this.$el.firstChild.innerHTML = ""; - this.$el.firstChild.appendChild(nodeList); + touchtrack: function(element, method, useCancel) { + const self = this; + let x0 = 0; + let y0 = 0; + let x1 = 0; + let y1 = 0; + const fn = function($event, state, x, y) { + if (self[method]({ + target: $event.target, + currentTarget: $event.currentTarget, + preventDefault: $event.preventDefault.bind($event), + stopPropagation: $event.stopPropagation.bind($event), + touches: $event.touches, + changedTouches: $event.changedTouches, + detail: { + state, + x0: x, + y0: y, + dx: x - x0, + dy: y - y0, + ddx: x - x1, + ddy: y - y1, + timeStamp: $event.timeStamp + } + }) === false) { + return false; + } + }; + let $eventOld = null; + let hasTouchStart; + let hasMouseDown; + addListenerToElement(element, "touchstart", function($event) { + hasTouchStart = true; + if ($event.touches.length === 1 && !$eventOld) { + $eventOld = $event; + x0 = x1 = $event.touches[0].pageX; + y0 = y1 = $event.touches[0].pageY; + return fn($event, "start", x0, y0); + } + }); + addListenerToElement(element, "mousedown", function($event) { + hasMouseDown = true; + if (!hasTouchStart && !$eventOld) { + $eventOld = $event; + x0 = x1 = $event.pageX; + y0 = y1 = $event.pageY; + return fn($event, "start", x0, y0); + } + }); + addListenerToElement(element, "touchmove", function($event) { + if ($event.touches.length === 1 && $eventOld) { + const res = fn($event, "move", $event.touches[0].pageX, $event.touches[0].pageY); + x1 = $event.touches[0].pageX; + y1 = $event.touches[0].pageY; + return res; + } + }); + const mouseMoveEventListener = this.__mouseMoveEventListener = function($event) { + if (!hasTouchStart && hasMouseDown && $eventOld) { + const res = fn($event, "move", $event.pageX, $event.pageY); + x1 = $event.pageX; + y1 = $event.pageY; + return res; + } + }; + document.addEventListener("mousemove", mouseMoveEventListener); + addListenerToElement(element, "touchend", function($event) { + if ($event.touches.length === 0 && $eventOld) { + hasTouchStart = false; + $eventOld = null; + return fn($event, "end", $event.changedTouches[0].pageX, $event.changedTouches[0].pageY); + } + }); + const mouseUpEventListener = this.__mouseUpEventListener = function($event) { + hasMouseDown = false; + if (!hasTouchStart && $eventOld) { + $eventOld = null; + return fn($event, "end", $event.pageX, $event.pageY); + } + }; + document.addEventListener("mouseup", mouseUpEventListener); + addListenerToElement(element, "touchcancel", function($event) { + if ($eventOld) { + hasTouchStart = false; + const $eventTemp = $eventOld; + $eventOld = null; + return fn($event, useCancel ? "cancel" : "end", $eventTemp.touches[0].pageX, $eventTemp.touches[0].pageY); + } + }); } } }; -const _hoisted_1$7 = /* @__PURE__ */ createVNode("div", null, null, -1); -function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) { - return openBlock(), createBlock("uni-rich-text", _ctx.$attrs, [ - _hoisted_1$7 - ], 16); +function e(e2, t2, n) { + return e2 > t2 - n && e2 < t2 + n; } -_sfc_main$9.render = _sfc_render$9; -function Friction(e2) { - this._drag = e2; - this._dragLog = Math.log(e2); - this._x = 0; - this._v = 0; +function t(t2, n) { + return e(t2, 0, n); +} +function Decline() { +} +Decline.prototype.x = function(e2) { + return Math.sqrt(e2); +}; +function Friction$1(e2, t2) { + this._m = e2; + this._f = 1e3 * t2; this._startTime = 0; + this._v = 0; } -Friction.prototype.set = function(e2, t2) { - this._x = e2; - this._v = t2; +Friction$1.prototype.setV = function(x, y) { + var n = Math.pow(Math.pow(x, 2) + Math.pow(y, 2), 0.5); + this._x_v = x; + this._y_v = y; + this._x_a = -this._f * this._x_v / n; + this._y_a = -this._f * this._y_v / n; + this._t = Math.abs(x / this._x_a) || Math.abs(y / this._y_a); + this._lastDt = null; this._startTime = new Date().getTime(); }; -Friction.prototype.setVelocityByEnd = function(e2) { - this._v = (e2 - this._x) * this._dragLog / (Math.pow(this._drag, 100) - 1); +Friction$1.prototype.setS = function(x, y) { + this._x_s = x; + this._y_s = y; }; -Friction.prototype.x = function(e2) { - if (e2 === void 0) { - e2 = (new Date().getTime() - this._startTime) / 1e3; +Friction$1.prototype.s = function(t2) { + if (t2 === void 0) { + t2 = (new Date().getTime() - this._startTime) / 1e3; } - var t2; - t2 = e2 === this._dt && this._powDragDt ? this._powDragDt : this._powDragDt = Math.pow(this._drag, e2); - this._dt = e2; - return this._x + this._v * t2 / this._dragLog - this._v / this._dragLog; + if (t2 > this._t) { + t2 = this._t; + this._lastDt = t2; + } + var x = this._x_v * t2 + 0.5 * this._x_a * Math.pow(t2, 2) + this._x_s; + var y = this._y_v * t2 + 0.5 * this._y_a * Math.pow(t2, 2) + this._y_s; + if (this._x_a > 0 && x < this._endPositionX || this._x_a < 0 && x > this._endPositionX) { + x = this._endPositionX; + } + if (this._y_a > 0 && y < this._endPositionY || this._y_a < 0 && y > this._endPositionY) { + y = this._endPositionY; + } + return { + x, + y + }; }; -Friction.prototype.dx = function(e2) { - if (e2 === void 0) { - e2 = (new Date().getTime() - this._startTime) / 1e3; +Friction$1.prototype.ds = function(t2) { + if (t2 === void 0) { + t2 = (new Date().getTime() - this._startTime) / 1e3; } - var t2; - t2 = e2 === this._dt && this._powDragDt ? this._powDragDt : this._powDragDt = Math.pow(this._drag, e2); - this._dt = e2; - return this._v * t2; + if (t2 > this._t) { + t2 = this._t; + } + return { + dx: this._x_v + this._x_a * t2, + dy: this._y_v + this._y_a * t2 + }; }; -Friction.prototype.done = function() { - return Math.abs(this.dx()) < 3; +Friction$1.prototype.delta = function() { + return { + x: -1.5 * Math.pow(this._x_v, 2) / this._x_a || 0, + y: -1.5 * Math.pow(this._y_v, 2) / this._y_a || 0 + }; }; -Friction.prototype.reconfigure = function(e2) { - var t2 = this.x(); - var n = this.dx(); - this._drag = e2; - this._dragLog = Math.log(e2); - this.set(t2, n); +Friction$1.prototype.dt = function() { + return -this._x_v / this._x_a; }; -Friction.prototype.configuration = function() { - var e2 = this; - return [ - { - label: "Friction", - read: function() { - return e2._drag; - }, - write: function(t2) { - e2.reconfigure(t2); - }, - min: 1e-3, - max: 0.1, - step: 1e-3 - } - ]; +Friction$1.prototype.done = function() { + var t2 = e(this.s().x, this._endPositionX) || e(this.s().y, this._endPositionY) || this._lastDt === this._t; + this._lastDt = null; + return t2; }; -function o(e2, t2, n) { - return e2 > t2 - n && e2 < t2 + n; -} -function a(e2, t2) { - return o(e2, 0, t2); -} -function Spring(e2, t2, n) { - this._m = e2; - this._k = t2; - this._c = n; +Friction$1.prototype.setEnd = function(x, y) { + this._endPositionX = x; + this._endPositionY = y; +}; +Friction$1.prototype.reconfigure = function(m, f2) { + this._m = m; + this._f = 1e3 * f2; +}; +function Spring$1(m, k, c) { + this._m = m; + this._k = k; + this._c = c; this._solution = null; this._endPosition = 0; this._startTime = 0; } -Spring.prototype._solve = function(e2, t2) { +Spring$1.prototype._solve = function(e2, t2) { var n = this._c; - var i = this._m; + var i2 = this._m; var r = this._k; - var o2 = n * n - 4 * i * r; + var o2 = n * n - 4 * i2 * r; if (o2 === 0) { - const a3 = -n / (2 * i); - const s2 = e2; - const l2 = t2 / (a3 * e2); + const a2 = -n / (2 * i2); + const s = e2; + const l = t2 / (a2 * e2); return { x: function(e3) { - return (s2 + l2 * e3) * Math.pow(Math.E, a3 * e3); + return (s + l * e3) * Math.pow(Math.E, a2 * e3); }, dx: function(e3) { - var t3 = Math.pow(Math.E, a3 * e3); - return a3 * (s2 + l2 * e3) * t3 + l2 * t3; + var t3 = Math.pow(Math.E, a2 * e3); + return a2 * (s + l * e3) * t3 + l * t3; } }; } if (o2 > 0) { - const c = (-n - Math.sqrt(o2)) / (2 * i); - const u = (-n + Math.sqrt(o2)) / (2 * i); - const l2 = (t2 - c * e2) / (u - c); - const s2 = e2 - l2; + const c = (-n - Math.sqrt(o2)) / (2 * i2); + const u = (-n + Math.sqrt(o2)) / (2 * i2); + const d = (t2 - c * e2) / (u - c); + const h = e2 - d; return { x: function(e3) { - let t3; - let n2; + var t3; + var n2; if (e3 === this._t) { t3 = this._powER1T; n2 = this._powER2T; @@ -5726,11 +5659,11 @@ Spring.prototype._solve = function(e2, t2) { if (!n2) { n2 = this._powER2T = Math.pow(Math.E, u * e3); } - return s2 * t3 + l2 * n2; + return h * t3 + d * n2; }, dx: function(e3) { - let t3; - let n2; + var t3; + var n2; if (e3 === this._t) { t3 = this._powER1T; n2 = this._powER2T; @@ -5742,66 +5675,66 @@ Spring.prototype._solve = function(e2, t2) { if (!n2) { n2 = this._powER2T = Math.pow(Math.E, u * e3); } - return s2 * c * t3 + l2 * u * n2; + return h * c * t3 + d * u * n2; } }; } - var d = Math.sqrt(4 * i * r - n * n) / (2 * i); - var a2 = -n / 2 * i; - var s = e2; - var l = (t2 - a2 * e2) / d; + var p2 = Math.sqrt(4 * i2 * r - n * n) / (2 * i2); + var f2 = -n / 2 * i2; + var v2 = e2; + var g2 = (t2 - f2 * e2) / p2; return { x: function(e3) { - return Math.pow(Math.E, a2 * e3) * (s * Math.cos(d * e3) + l * Math.sin(d * e3)); + return Math.pow(Math.E, f2 * e3) * (v2 * Math.cos(p2 * e3) + g2 * Math.sin(p2 * e3)); }, dx: function(e3) { - var t3 = Math.pow(Math.E, a2 * e3); - var n2 = Math.cos(d * e3); - var i2 = Math.sin(d * e3); - return t3 * (l * d * n2 - s * d * i2) + a2 * t3 * (l * i2 + s * n2); + var t3 = Math.pow(Math.E, f2 * e3); + var n2 = Math.cos(p2 * e3); + var i3 = Math.sin(p2 * e3); + return t3 * (g2 * p2 * n2 - v2 * p2 * i3) + f2 * t3 * (g2 * i3 + v2 * n2); } }; }; -Spring.prototype.x = function(e2) { +Spring$1.prototype.x = function(e2) { if (e2 === void 0) { e2 = (new Date().getTime() - this._startTime) / 1e3; } return this._solution ? this._endPosition + this._solution.x(e2) : 0; }; -Spring.prototype.dx = function(e2) { +Spring$1.prototype.dx = function(e2) { if (e2 === void 0) { e2 = (new Date().getTime() - this._startTime) / 1e3; } return this._solution ? this._solution.dx(e2) : 0; }; -Spring.prototype.setEnd = function(e2, t2, n) { - if (!n) { - n = new Date().getTime(); +Spring$1.prototype.setEnd = function(e2, n, i2) { + if (!i2) { + i2 = new Date().getTime(); } - if (e2 !== this._endPosition || !a(t2, 0.4)) { - t2 = t2 || 0; - var i = this._endPosition; + if (e2 !== this._endPosition || !t(n, 0.1)) { + n = n || 0; + var r = this._endPosition; if (this._solution) { - if (a(t2, 0.4)) { - t2 = this._solution.dx((n - this._startTime) / 1e3); + if (t(n, 0.1)) { + n = this._solution.dx((i2 - this._startTime) / 1e3); } - i = this._solution.x((n - this._startTime) / 1e3); - if (a(t2, 0.4)) { - t2 = 0; + r = this._solution.x((i2 - this._startTime) / 1e3); + if (t(n, 0.1)) { + n = 0; } - if (a(i, 0.4)) { - i = 0; + if (t(r, 0.1)) { + r = 0; } - i += this._endPosition; + r += this._endPosition; } - if (!(this._solution && a(i - e2, 0.4) && a(t2, 0.4))) { + if (!(this._solution && t(r - e2, 0.1) && t(n, 0.1))) { this._endPosition = e2; - this._solution = this._solve(i - this._endPosition, t2); - this._startTime = n; + this._solution = this._solve(r - this._endPosition, n); + this._startTime = i2; } } }; -Spring.prototype.snap = function(e2) { +Spring$1.prototype.snap = function(e2) { this._startTime = new Date().getTime(); this._endPosition = e2; this._solution = { @@ -5813,28 +5746,28 @@ Spring.prototype.snap = function(e2) { } }; }; -Spring.prototype.done = function(e2) { - if (!e2) { - e2 = new Date().getTime(); +Spring$1.prototype.done = function(n) { + if (!n) { + n = new Date().getTime(); } - return o(this.x(), this._endPosition, 0.4) && a(this.dx(), 0.4); + return e(this.x(), this._endPosition, 0.1) && t(this.dx(), 0.1); }; -Spring.prototype.reconfigure = function(e2, t2, n) { - this._m = e2; +Spring$1.prototype.reconfigure = function(m, t2, c) { + this._m = m; this._k = t2; - this._c = n; + this._c = c; if (!this.done()) { this._solution = this._solve(this.x() - this._endPosition, this.dx()); this._startTime = new Date().getTime(); } }; -Spring.prototype.springConstant = function() { +Spring$1.prototype.springConstant = function() { return this._k; }; -Spring.prototype.damping = function() { +Spring$1.prototype.damping = function() { return this._c; }; -Spring.prototype.configuration = function() { +Spring$1.prototype.configuration = function() { function e2(e3, t3) { e3.reconfigure(1, t3, e3.damping()); } @@ -5858,1171 +5791,885 @@ Spring.prototype.configuration = function() { } ]; }; -function Scroll(extent, friction, spring) { - this._extent = extent; - this._friction = friction || new Friction(0.01); - this._spring = spring || new Spring(1, 90, 20); +function STD(e2, t2, n) { + this._springX = new Spring$1(e2, t2, n); + this._springY = new Spring$1(e2, t2, n); + this._springScale = new Spring$1(e2, t2, n); this._startTime = 0; - this._springing = false; - this._springOffset = 0; } -Scroll.prototype.snap = function(e2, t2) { - this._springOffset = 0; - this._springing = true; - this._spring.snap(e2); - this._spring.setEnd(t2); +STD.prototype.setEnd = function(e2, t2, n, i2) { + var r = new Date().getTime(); + this._springX.setEnd(e2, i2, r); + this._springY.setEnd(t2, i2, r); + this._springScale.setEnd(n, i2, r); + this._startTime = r; }; -Scroll.prototype.set = function(e2, t2) { - this._friction.set(e2, t2); - if (e2 > 0 && t2 >= 0) { - this._springOffset = 0; - this._springing = true; - this._spring.snap(e2); - this._spring.setEnd(0); - } else { - if (e2 < -this._extent && t2 <= 0) { - this._springOffset = 0; - this._springing = true; - this._spring.snap(e2); - this._spring.setEnd(-this._extent); - } else { - this._springing = false; - } - } - this._startTime = new Date().getTime(); +STD.prototype.x = function() { + var e2 = (new Date().getTime() - this._startTime) / 1e3; + return { + x: this._springX.x(e2), + y: this._springY.x(e2), + scale: this._springScale.x(e2) + }; }; -Scroll.prototype.x = function(e2) { - if (!this._startTime) { - return 0; +STD.prototype.done = function() { + var e2 = new Date().getTime(); + return this._springX.done(e2) && this._springY.done(e2) && this._springScale.done(e2); +}; +STD.prototype.reconfigure = function(e2, t2, n) { + this._springX.reconfigure(e2, t2, n); + this._springY.reconfigure(e2, t2, n); + this._springScale.reconfigure(e2, t2, n); +}; +var index_vue_vue_type_style_index_0_lang$7 = "\nuni-movable-view {\n display: inline-block;\n width: 10px;\n height: 10px;\n top: 0px;\n left: 0px;\n position: absolute;\n cursor: grab;\n}\nuni-movable-view[hidden] {\n display: none;\n}\n"; +var requesting = false; +function _requestAnimationFrame(e2) { + if (!requesting) { + requesting = true; + requestAnimationFrame(function() { + e2(); + requesting = false; + }); } - if (!e2) { - e2 = (new Date().getTime() - this._startTime) / 1e3; +} +function p(t2, n) { + if (t2 === n) { + return 0; } - if (this._springing) { - return this._spring.x() + this._springOffset; + var i2 = t2.offsetLeft; + return t2.offsetParent ? i2 += p(t2.offsetParent, n) : 0; +} +function f(t2, n) { + if (t2 === n) { + return 0; } - var t2 = this._friction.x(e2); - var n = this.dx(e2); - if (t2 > 0 && n >= 0 || t2 < -this._extent && n <= 0) { - this._springing = true; - this._spring.setEnd(0, n); - if (t2 < -this._extent) { - this._springOffset = -this._extent; - } else { - this._springOffset = 0; + var i2 = t2.offsetTop; + return t2.offsetParent ? i2 += f(t2.offsetParent, n) : 0; +} +function v(a2, b) { + return +((1e3 * a2 - 1e3 * b) / 1e3).toFixed(1); +} +function g(e2, t2, n) { + var i2 = function(e3) { + if (e3 && e3.id) { + cancelAnimationFrame(e3.id); + } + if (e3) { + e3.cancelled = true; + } + }; + var r = { + id: 0, + cancelled: false + }; + function fn(n2, i3, r2, o2) { + if (!n2 || !n2.cancelled) { + r2(i3); + var a2 = e2.done(); + if (!a2) { + if (!n2.cancelled) { + n2.id = requestAnimationFrame(fn.bind(null, n2, i3, r2, o2)); + } + } + if (a2 && o2) { + o2(i3); + } } - t2 = this._spring.x() + this._springOffset; } - return t2; -}; -Scroll.prototype.dx = function(e2) { - var t2 = 0; - t2 = this._lastTime === e2 ? this._lastDx : this._springing ? this._spring.dx(e2) : this._friction.dx(e2); - this._lastTime = e2; - this._lastDx = t2; - return t2; -}; -Scroll.prototype.done = function() { - return this._springing ? this._spring.done() : this._friction.done(); -}; -Scroll.prototype.setVelocityByEnd = function(e2) { - this._friction.setVelocityByEnd(e2); -}; -Scroll.prototype.configuration = function() { - var e2 = this._friction.configuration(); - e2.push.apply(e2, this._spring.configuration()); - return e2; -}; -function i$1(scroll, t2, n) { - function i(t3, scroll2, r2, o3) { - if (!t3 || !t3.cancelled) { - r2(scroll2); - var a2 = scroll2.done(); - if (!a2) { - if (!t3.cancelled) { - t3.id = requestAnimationFrame(i.bind(null, t3, scroll2, r2, o3)); - } - } - if (a2 && o3) { - o3(scroll2); - } - } - } - function r(scroll2) { - if (scroll2 && scroll2.id) { - cancelAnimationFrame(scroll2.id); - } - if (scroll2) { - scroll2.cancelled = true; - } - } - var o2 = { - id: 0, - cancelled: false - }; - i(o2, scroll, t2, n); + fn(r, e2, t2, n); return { - cancel: r.bind(null, o2), - model: scroll + cancel: i2.bind(null, r), + model: e2 }; } -function Scroller(element, options) { - options = options || {}; - this._element = element; - this._options = options; - this._enableSnap = options.enableSnap || false; - this._itemSize = options.itemSize || 0; - this._enableX = options.enableX || false; - this._enableY = options.enableY || false; - this._shouldDispatchScrollEvent = !!options.onScroll; - if (this._enableX) { - this._extent = (options.scrollWidth || this._element.offsetWidth) - this._element.parentElement.offsetWidth; - this._scrollWidth = options.scrollWidth; - } else { - this._extent = (options.scrollHeight || this._element.offsetHeight) - this._element.parentElement.offsetHeight; - this._scrollHeight = options.scrollHeight; - } - this._position = 0; - this._scroll = new Scroll(this._extent, options.friction, options.spring); - this._onTransitionEnd = this.onTransitionEnd.bind(this); - this.updatePosition(); -} -Scroller.prototype.onTouchStart = function() { - this._startPosition = this._position; - this._lastChangePos = this._startPosition; - if (this._startPosition > 0) { - this._startPosition /= 0.5; - } else { - if (this._startPosition < -this._extent) { - this._startPosition = (this._startPosition + this._extent) / 0.5 - this._extent; - } - } - if (this._animation) { - this._animation.cancel(); - this._scrolling = false; - } - this.updatePosition(); -}; -Scroller.prototype.onTouchMove = function(x, y) { - var startPosition = this._startPosition; - if (this._enableX) { - startPosition += x; - } else if (this._enableY) { - startPosition += y; - } - if (startPosition > 0) { - startPosition *= 0.5; - } else if (startPosition < -this._extent) { - startPosition = 0.5 * (startPosition + this._extent) - this._extent; - } - this._position = startPosition; - this.updatePosition(); - this.dispatchScroll(); -}; -Scroller.prototype.onTouchEnd = function(e2, r, o2) { - if (this._enableSnap && this._position > -this._extent && this._position < 0) { - if (this._enableY && (Math.abs(r) < this._itemSize && Math.abs(o2.y) < 300 || Math.abs(o2.y) < 150)) { - this.snap(); - return; - } - if (this._enableX && (Math.abs(e2) < this._itemSize && Math.abs(o2.x) < 300 || Math.abs(o2.x) < 150)) { - this.snap(); - return; - } - } - if (this._enableX) { - this._scroll.set(this._position, o2.x); - } else if (this._enableY) { - this._scroll.set(this._position, o2.y); - } - if (this._enableSnap) { - var s = this._scroll._friction.x(100); - var l = s % this._itemSize; - var c = Math.abs(l) > this._itemSize / 2 ? s - (this._itemSize - Math.abs(l)) : s - l; - if (c <= 0 && c >= -this._extent) { - this._scroll.setVelocityByEnd(c); - } - } - this._lastTime = Date.now(); - this._lastDelay = 0; - this._scrolling = true; - this._lastChangePos = this._position; - this._lastIdx = Math.floor(Math.abs(this._position / this._itemSize)); - this._animation = i$1(this._scroll, () => { - var e3 = Date.now(); - var i = (e3 - this._scroll._startTime) / 1e3; - var r2 = this._scroll.x(i); - this._position = r2; - this.updatePosition(); - var o3 = this._scroll.dx(i); - if (this._shouldDispatchScrollEvent && e3 - this._lastTime > this._lastDelay) { - this.dispatchScroll(); - this._lastDelay = Math.abs(2e3 / o3); - this._lastTime = e3; +const _sfc_main$e = { + name: "MovableView", + mixins: [touchtrack], + props: { + direction: { + type: String, + default: "none" + }, + inertia: { + type: [Boolean, String], + default: false + }, + outOfBounds: { + type: [Boolean, String], + default: false + }, + x: { + type: [Number, String], + default: 0 + }, + y: { + type: [Number, String], + default: 0 + }, + damping: { + type: [Number, String], + default: 20 + }, + friction: { + type: [Number, String], + default: 2 + }, + disabled: { + type: [Boolean, String], + default: false + }, + scale: { + type: [Boolean, String], + default: false + }, + scaleMin: { + type: [Number, String], + default: 0.5 + }, + scaleMax: { + type: [Number, String], + default: 10 + }, + scaleValue: { + type: [Number, String], + default: 1 + }, + animation: { + type: [Boolean, String], + default: true } - }, () => { - if (this._enableSnap) { - if (c <= 0 && c >= -this._extent) { - this._position = c; - this.updatePosition(); - } - if (typeof this._options.onSnap === "function") { - this._options.onSnap(Math.floor(Math.abs(this._position) / this._itemSize)); - } + }, + data() { + return { + xSync: this._getPx(this.x), + ySync: this._getPx(this.y), + scaleValueSync: Number(this.scaleValue) || 1, + width: 0, + height: 0, + minX: 0, + minY: 0, + maxX: 0, + maxY: 0 + }; + }, + computed: { + dampingNumber() { + var val = Number(this.damping); + return isNaN(val) ? 20 : val; + }, + frictionNumber() { + var val = Number(this.friction); + return isNaN(val) || val <= 0 ? 2 : val; + }, + scaleMinNumber() { + var val = Number(this.scaleMin); + return isNaN(val) ? 0.5 : val; + }, + scaleMaxNumber() { + var val = Number(this.scaleMax); + return isNaN(val) ? 10 : val; + }, + xMove() { + return this.direction === "all" || this.direction === "horizontal"; + }, + yMove() { + return this.direction === "all" || this.direction === "vertical"; } - if (this._shouldDispatchScrollEvent) { - this.dispatchScroll(); + }, + watch: { + x(val) { + this.xSync = this._getPx(val); + }, + xSync(val) { + this._setX(val); + }, + y(val) { + this.ySync = this._getPx(val); + }, + ySync(val) { + this._setY(val); + }, + scaleValue(val) { + this.scaleValueSync = Number(val) || 0; + }, + scaleValueSync(val) { + this._setScaleValue(val); + }, + scaleMinNumber() { + this._setScaleMinOrMax(); + }, + scaleMaxNumber() { + this._setScaleMinOrMax(); } - this._scrolling = false; - }); -}; -Scroller.prototype.onTransitionEnd = function() { - this._element.style.transition = ""; - this._element.style.webkitTransition = ""; - this._element.removeEventListener("transitionend", this._onTransitionEnd); - this._element.removeEventListener("webkitTransitionEnd", this._onTransitionEnd); - if (this._snapping) { - this._snapping = false; - } - this.dispatchScroll(); -}; -Scroller.prototype.snap = function() { - var e2 = this._itemSize; - var t2 = this._position % e2; - var i = Math.abs(t2) > this._itemSize / 2 ? this._position - (e2 - Math.abs(t2)) : this._position - t2; - if (this._position !== i) { - this._snapping = true; - this.scrollTo(-i); - if (typeof this._options.onSnap === "function") { - this._options.onSnap(Math.floor(Math.abs(this._position) / this._itemSize)); - } - } -}; -Scroller.prototype.scrollTo = function(e2, t2) { - if (this._animation) { - this._animation.cancel(); - this._scrolling = false; - } - if (typeof e2 === "number") { - this._position = -e2; - } - if (this._position < -this._extent) { - this._position = -this._extent; - } else { - if (this._position > 0) { - this._position = 0; - } - } - this._element.style.transition = "transform " + (t2 || 0.2) + "s ease-out"; - this._element.style.webkitTransition = "-webkit-transform " + (t2 || 0.2) + "s ease-out"; - this.updatePosition(); - this._element.addEventListener("transitionend", this._onTransitionEnd); - this._element.addEventListener("webkitTransitionEnd", this._onTransitionEnd); -}; -Scroller.prototype.dispatchScroll = function() { - if (typeof this._options.onScroll === "function" && Math.round(this._lastPos) !== Math.round(this._position)) { - this._lastPos = this._position; - var e2 = { - target: { - scrollLeft: this._enableX ? -this._position : 0, - scrollTop: this._enableY ? -this._position : 0, - scrollHeight: this._scrollHeight || this._element.offsetHeight, - scrollWidth: this._scrollWidth || this._element.offsetWidth, - offsetHeight: this._element.parentElement.offsetHeight, - offsetWidth: this._element.parentElement.offsetWidth - } + }, + created: function() { + this._offset = { + x: 0, + y: 0 }; - this._options.onScroll(e2); - } -}; -Scroller.prototype.update = function(e2, t2, n) { - var i = 0; - var r = this._position; - if (this._enableX) { - i = this._element.childNodes.length ? (t2 || this._element.offsetWidth) - this._element.parentElement.offsetWidth : 0; - this._scrollWidth = t2; - } else { - i = this._element.childNodes.length ? (t2 || this._element.offsetHeight) - this._element.parentElement.offsetHeight : 0; - this._scrollHeight = t2; - } - if (typeof e2 === "number") { - this._position = -e2; - } - if (this._position < -i) { - this._position = -i; - } else { - if (this._position > 0) { - this._position = 0; - } - } - this._itemSize = n || this._itemSize; - this.updatePosition(); - if (r !== this._position) { - this.dispatchScroll(); - if (typeof this._options.onSnap === "function") { - this._options.onSnap(Math.floor(Math.abs(this._position) / this._itemSize)); - } - } - this._extent = i; - this._scroll._extent = i; -}; -Scroller.prototype.updatePosition = function() { - var transform = ""; - if (this._enableX) { - transform = "translateX(" + this._position + "px) translateZ(0)"; - } else { - if (this._enableY) { - transform = "translateY(" + this._position + "px) translateZ(0)"; - } - } - this._element.style.webkitTransform = transform; - this._element.style.transform = transform; -}; -Scroller.prototype.isScrolling = function() { - return this._scrolling || this._snapping; -}; -var scroller = { + this._scaleOffset = { + x: 0, + y: 0 + }; + this._translateX = 0; + this._translateY = 0; + this._scale = 1; + this._oldScale = 1; + this._STD = new STD(1, 9 * Math.pow(this.dampingNumber, 2) / 40, this.dampingNumber); + this._friction = new Friction$1(1, this.frictionNumber); + this._declineX = new Decline(); + this._declineY = new Decline(); + this.__touchInfo = { + historyX: [0, 0], + historyY: [0, 0], + historyT: [0, 0] + }; + }, + mounted: function() { + this.touchtrack(this.$el, "_onTrack"); + this.setParent(); + this._friction.reconfigure(1, this.frictionNumber); + this._STD.reconfigure(1, 9 * Math.pow(this.dampingNumber, 2) / 40, this.dampingNumber); + this.$el.style.transformOrigin = "center"; + }, methods: { - initScroller: function(element, options) { - this._touchInfo = { - trackingID: -1, - maxDy: 0, - maxDx: 0 - }; - this._scroller = new Scroller(element, options); - this.__handleTouchStart = this._handleTouchStart.bind(this); - this.__handleTouchMove = this._handleTouchMove.bind(this); - this.__handleTouchEnd = this._handleTouchEnd.bind(this); - this._initedScroller = true; - }, - _findDelta: function(event2) { - var touchInfo = this._touchInfo; - return event2.detail.state === "move" || event2.detail.state === "end" ? { - x: event2.detail.dx, - y: event2.detail.dy - } : { - x: event2.screenX - touchInfo.x, - y: event2.screenY - touchInfo.y - }; + _getPx(val) { + if (/\d+[ur]px$/i.test(val)) { + return uni.upx2px(parseFloat(val)); + } + return Number(val) || 0; }, - _handleTouchStart: function(e2) { - var t2 = this._touchInfo; - var n = this._scroller; - if (n) { - if (e2.detail.state === "start") { - t2.trackingID = "touch"; - t2.x = e2.detail.x; - t2.y = e2.detail.y; + _setX: function(val) { + if (this.xMove) { + if (val + this._scaleOffset.x === this._translateX) { + return this._translateX; } else { - t2.trackingID = "mouse"; - t2.x = e2.screenX; - t2.y = e2.screenY; - } - t2.maxDx = 0; - t2.maxDy = 0; - t2.historyX = [0]; - t2.historyY = [0]; - t2.historyTime = [e2.detail.timeStamp]; - t2.listener = n; - if (n.onTouchStart) { - n.onTouchStart(); + if (this._SFA) { + this._SFA.cancel(); + } + this._animationTo(val + this._scaleOffset.x, this.ySync + this._scaleOffset.y, this._scale); } - event.preventDefault(); } + return val; }, - _handleTouchMove: function(event2) { - var touchInfo = this._touchInfo; - if (touchInfo.trackingID !== -1) { - event2.preventDefault(); - var delta = this._findDelta(event2); - if (delta) { - for (touchInfo.maxDy = Math.max(touchInfo.maxDy, Math.abs(delta.y)), touchInfo.maxDx = Math.max(touchInfo.maxDx, Math.abs(delta.x)), touchInfo.historyX.push(delta.x), touchInfo.historyY.push(delta.y), touchInfo.historyTime.push(event2.detail.timeStamp); touchInfo.historyTime.length > 10; ) { - touchInfo.historyTime.shift(); - touchInfo.historyX.shift(); - touchInfo.historyY.shift(); - } - if (touchInfo.listener && touchInfo.listener.onTouchMove) { - touchInfo.listener.onTouchMove(delta.x, delta.y, event2.detail.timeStamp); + _setY: function(val) { + if (this.yMove) { + if (val + this._scaleOffset.y === this._translateY) { + return this._translateY; + } else { + if (this._SFA) { + this._SFA.cancel(); } + this._animationTo(this.xSync + this._scaleOffset.x, val + this._scaleOffset.y, this._scale); } } + return val; }, - _handleTouchEnd: function(event2) { - var touchInfo = this._touchInfo; - if (touchInfo.trackingID !== -1) { - event2.preventDefault(); - var delta = this._findDelta(event2); - if (delta) { - var listener = touchInfo.listener; - touchInfo.trackingID = -1; - touchInfo.listener = null; - var r = touchInfo.historyTime.length; - var o2 = { - x: 0, - y: 0 - }; - if (r > 2) { - for (var a2 = touchInfo.historyTime.length - 1, s = touchInfo.historyTime[a2], l = touchInfo.historyX[a2], c = touchInfo.historyY[a2]; a2 > 0; ) { - a2--; - var u = touchInfo.historyTime[a2]; - var d = s - u; - if (d > 30 && d < 50) { - o2.x = (l - touchInfo.historyX[a2]) / (d / 1e3); - o2.y = (c - touchInfo.historyY[a2]) / (d / 1e3); - break; - } - } - } - touchInfo.historyTime = []; - touchInfo.historyX = []; - touchInfo.historyY = []; - if (listener && listener.onTouchEnd) { - listener.onTouchEnd(delta.x, delta.y, o2); - } - } + _setScaleMinOrMax: function() { + if (!this.scale) { + return false; } - } - } -}; -var index_vue_vue_type_style_index_0_lang$5 = "\nuni-scroll-view {\n display: block;\n width: 100%;\n}\nuni-scroll-view[hidden] {\n display: none;\n}\n.uni-scroll-view {\n position: relative;\n -webkit-overflow-scrolling: touch;\n width: 100%;\n /* display: flex; \u65F6\u5728\u5B89\u5353\u4E0B\u4F1A\u5BFC\u81F4scrollWidth\u548CoffsetWidth\u4E00\u6837 */\n height: 100%;\n max-height: inherit;\n}\n.uni-scroll-view-content {\n width: 100%;\n height: 100%;\n}\n.uni-scroll-view-refresher {\n position: relative;\n overflow: hidden;\n}\n.uni-scroll-view-refresh {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: flex;\n flex-direction: row;\n justify-content: center;\n align-items: center;\n}\n.uni-scroll-view-refresh-inner {\n display: flex;\n align-items: center;\n justify-content: center;\n line-height: 0;\n width: 40px;\n height: 40px;\n border-radius: 50%;\n background-color: #fff;\n box-shadow: 0 1px 6px rgba(0, 0, 0, 0.117647),\n 0 1px 4px rgba(0, 0, 0, 0.117647);\n}\n.uni-scroll-view-refresh__spinner {\n transform-origin: center center;\n animation: uni-scroll-view-refresh-rotate 2s linear infinite;\n}\n.uni-scroll-view-refresh__spinner > circle {\n stroke: currentColor;\n stroke-linecap: round;\n animation: uni-scroll-view-refresh-dash 2s linear infinite;\n}\n@keyframes uni-scroll-view-refresh-rotate {\n0% {\n transform: rotate(0deg);\n}\n100% {\n transform: rotate(360deg);\n}\n}\n@keyframes uni-scroll-view-refresh-dash {\n0% {\n stroke-dasharray: 1, 200;\n stroke-dashoffset: 0;\n}\n50% {\n stroke-dasharray: 89, 200;\n stroke-dashoffset: -35px;\n}\n100% {\n stroke-dasharray: 89, 200;\n stroke-dashoffset: -124px;\n}\n}\n"; -const passiveOptions = {passive: true}; -const _sfc_main$8 = { - name: "ScrollView", - mixins: [scroller], - props: { - scrollX: { - type: [Boolean, String], - default: false + this._updateScale(this._scale, true); + this._updateOldScale(this._scale); }, - scrollY: { - type: [Boolean, String], - default: false + _setScaleValue: function(scale) { + if (!this.scale) { + return false; + } + scale = this._adjustScale(scale); + this._updateScale(scale, true); + this._updateOldScale(scale); + return scale; }, - upperThreshold: { - type: [Number, String], - default: 50 + __handleTouchStart: function() { + if (!this._isScaling) { + if (!this.disabled) { + if (this._FA) { + this._FA.cancel(); + } + if (this._SFA) { + this._SFA.cancel(); + } + this.__touchInfo.historyX = [0, 0]; + this.__touchInfo.historyY = [0, 0]; + this.__touchInfo.historyT = [0, 0]; + if (this.xMove) { + this.__baseX = this._translateX; + } + if (this.yMove) { + this.__baseY = this._translateY; + } + this.$el.style.willChange = "transform"; + this._checkCanMove = null; + this._firstMoveDirection = null; + this._isTouching = true; + } + } }, - lowerThreshold: { - type: [Number, String], - default: 50 + __handleTouchMove: function(event2) { + var self = this; + if (!this._isScaling && !this.disabled && this._isTouching) { + let x = this._translateX; + let y = this._translateY; + if (this._firstMoveDirection === null) { + this._firstMoveDirection = Math.abs(event2.detail.dx / event2.detail.dy) > 1 ? "htouchmove" : "vtouchmove"; + } + if (this.xMove) { + x = event2.detail.dx + this.__baseX; + this.__touchInfo.historyX.shift(); + this.__touchInfo.historyX.push(x); + if (!this.yMove && this._checkCanMove === null) { + this._checkCanMove = Math.abs(event2.detail.dx / event2.detail.dy) < 1; + } + } + if (this.yMove) { + y = event2.detail.dy + this.__baseY; + this.__touchInfo.historyY.shift(); + this.__touchInfo.historyY.push(y); + if (!this.xMove && this._checkCanMove === null) { + this._checkCanMove = Math.abs(event2.detail.dy / event2.detail.dx) < 1; + } + } + this.__touchInfo.historyT.shift(); + this.__touchInfo.historyT.push(event2.detail.timeStamp); + if (!this._checkCanMove) { + event2.preventDefault(); + let source = "touch"; + if (x < this.minX) { + if (this.outOfBounds) { + source = "touch-out-of-bounds"; + x = this.minX - this._declineX.x(this.minX - x); + } else { + x = this.minX; + } + } else if (x > this.maxX) { + if (this.outOfBounds) { + source = "touch-out-of-bounds"; + x = this.maxX + this._declineX.x(x - this.maxX); + } else { + x = this.maxX; + } + } + if (y < this.minY) { + if (this.outOfBounds) { + source = "touch-out-of-bounds"; + y = this.minY - this._declineY.x(this.minY - y); + } else { + y = this.minY; + } + } else { + if (y > this.maxY) { + if (this.outOfBounds) { + source = "touch-out-of-bounds"; + y = this.maxY + this._declineY.x(y - this.maxY); + } else { + y = this.maxY; + } + } + } + _requestAnimationFrame(function() { + self._setTransform(x, y, self._scale, source); + }); + } + } }, - scrollTop: { - type: [Number, String], - default: 0 + __handleTouchEnd: function() { + var self = this; + if (!this._isScaling && !this.disabled && this._isTouching) { + this.$el.style.willChange = "auto"; + this._isTouching = false; + if (!this._checkCanMove && !this._revise("out-of-bounds") && this.inertia) { + const xv = 1e3 * (this.__touchInfo.historyX[1] - this.__touchInfo.historyX[0]) / (this.__touchInfo.historyT[1] - this.__touchInfo.historyT[0]); + const yv = 1e3 * (this.__touchInfo.historyY[1] - this.__touchInfo.historyY[0]) / (this.__touchInfo.historyT[1] - this.__touchInfo.historyT[0]); + this._friction.setV(xv, yv); + this._friction.setS(this._translateX, this._translateY); + const x0 = this._friction.delta().x; + const y0 = this._friction.delta().y; + let x = x0 + this._translateX; + let y = y0 + this._translateY; + if (x < this.minX) { + x = this.minX; + y = this._translateY + (this.minX - this._translateX) * y0 / x0; + } else { + if (x > this.maxX) { + x = this.maxX; + y = this._translateY + (this.maxX - this._translateX) * y0 / x0; + } + } + if (y < this.minY) { + y = this.minY; + x = this._translateX + (this.minY - this._translateY) * x0 / y0; + } else { + if (y > this.maxY) { + y = this.maxY; + x = this._translateX + (this.maxY - this._translateY) * x0 / y0; + } + } + this._friction.setEnd(x, y); + this._FA = g(this._friction, function() { + var t2 = self._friction.s(); + var x2 = t2.x; + var y2 = t2.y; + self._setTransform(x2, y2, self._scale, "friction"); + }, function() { + self._FA.cancel(); + }); + } + } }, - scrollLeft: { - type: [Number, String], - default: 0 + _onTrack: function(event2) { + switch (event2.detail.state) { + case "start": + this.__handleTouchStart(); + break; + case "move": + this.__handleTouchMove(event2); + break; + case "end": + this.__handleTouchEnd(); + } }, - scrollIntoView: { - type: String, - default: "" + _getLimitXY: function(x, y) { + var outOfBounds = false; + if (x > this.maxX) { + x = this.maxX; + outOfBounds = true; + } else { + if (x < this.minX) { + x = this.minX; + outOfBounds = true; + } + } + if (y > this.maxY) { + y = this.maxY; + outOfBounds = true; + } else { + if (y < this.minY) { + y = this.minY; + outOfBounds = true; + } + } + return { + x, + y, + outOfBounds + }; }, - scrollWithAnimation: { - type: [Boolean, String], - default: false + setParent: function() { + if (!this.$parent._isMounted) { + return; + } + if (this._FA) { + this._FA.cancel(); + } + if (this._SFA) { + this._SFA.cancel(); + } + var scale = this.scale ? this.scaleValueSync : 1; + this._updateOffset(); + this._updateWH(scale); + this._updateBoundary(); + this._translateX = this.xSync + this._scaleOffset.x; + this._translateY = this.ySync + this._scaleOffset.y; + var limitXY = this._getLimitXY(this._translateX, this._translateY); + var x = limitXY.x; + var y = limitXY.y; + this._setTransform(x, y, scale, "", true); + this._updateOldScale(scale); }, - enableBackToTop: { - type: [Boolean, String], - default: false + _updateOffset: function() { + this._offset.x = p(this.$el, this.$parent.$el); + this._offset.y = f(this.$el, this.$parent.$el); }, - refresherEnabled: { - type: [Boolean, String], - default: false + _updateWH: function(scale) { + scale = scale || this._scale; + scale = this._adjustScale(scale); + var rect = this.$el.getBoundingClientRect(); + this.height = rect.height / this._scale; + this.width = rect.width / this._scale; + var height = this.height * scale; + var width = this.width * scale; + this._scaleOffset.x = (width - this.width) / 2; + this._scaleOffset.y = (height - this.height) / 2; }, - refresherThreshold: { - type: Number, - default: 45 + _updateBoundary: function() { + var x = 0 - this._offset.x + this._scaleOffset.x; + var width = this.$parent.width - this.width - this._offset.x - this._scaleOffset.x; + this.minX = Math.min(x, width); + this.maxX = Math.max(x, width); + var y = 0 - this._offset.y + this._scaleOffset.y; + var height = this.$parent.height - this.height - this._offset.y - this._scaleOffset.y; + this.minY = Math.min(y, height); + this.maxY = Math.max(y, height); }, - refresherDefaultStyle: { - type: String, - default: "back" + _beginScale: function() { + this._isScaling = true; }, - refresherBackground: { - type: String, - default: "#fff" - }, - refresherTriggered: { - type: [Boolean, String], - default: false - } - }, - data() { - return { - lastScrollTop: this.scrollTopNumber, - lastScrollLeft: this.scrollLeftNumber, - lastScrollToUpperTime: 0, - lastScrollToLowerTime: 0, - refresherHeight: 0, - refreshRotate: 0, - refreshState: "" - }; - }, - computed: { - upperThresholdNumber() { - var val = Number(this.upperThreshold); - return isNaN(val) ? 50 : val; - }, - lowerThresholdNumber() { - var val = Number(this.lowerThreshold); - return isNaN(val) ? 50 : val; + _endScale: function() { + this._isScaling = false; + this._updateOldScale(this._scale); }, - scrollTopNumber() { - return Number(this.scrollTop) || 0; + _setScale: function(scale) { + if (this.scale) { + scale = this._adjustScale(scale); + scale = this._oldScale * scale; + this._beginScale(); + this._updateScale(scale); + } }, - scrollLeftNumber() { - return Number(this.scrollLeft) || 0; - } - }, - watch: { - scrollTopNumber(val) { - this._scrollTopChanged(val); + _updateScale: function(scale, animat) { + var self = this; + if (this.scale) { + scale = this._adjustScale(scale); + this._updateWH(scale); + this._updateBoundary(); + const limitXY = this._getLimitXY(this._translateX, this._translateY); + const x = limitXY.x; + const y = limitXY.y; + if (animat) { + this._animationTo(x, y, scale, "", true, true); + } else { + _requestAnimationFrame(function() { + self._setTransform(x, y, scale, "", true, true); + }); + } + } }, - scrollLeftNumber(val) { - this._scrollLeftChanged(val); + _updateOldScale: function(scale) { + this._oldScale = scale; }, - scrollIntoView(val) { - this._scrollIntoViewChanged(val); + _adjustScale: function(scale) { + scale = Math.max(0.5, this.scaleMinNumber, scale); + scale = Math.min(10, this.scaleMaxNumber, scale); + return scale; }, - refresherTriggered(val) { - if (val === true) { - this._setRefreshState("refreshing"); - } else if (val === false) { - this._setRefreshState("restore"); + _animationTo: function(x, y, scale, source, r, o2) { + var self = this; + if (this._FA) { + this._FA.cancel(); } - } - }, - mounted() { - var self = this; - this._attached = true; - this._scrollTopChanged(this.scrollTopNumber); - this._scrollLeftChanged(this.scrollLeftNumber); - this._scrollIntoViewChanged(this.scrollIntoView); - this.__handleScroll = function(e2) { - event.preventDefault(); - event.stopPropagation(); - self._handleScroll.bind(self, event)(); - }; - var touchStart = null; - var needStop = null; - this.__handleTouchMove = function(event2) { - var x = event2.touches[0].pageX; - var y = event2.touches[0].pageY; - var main = self.$refs.main; - if (needStop === null) { - if (Math.abs(x - touchStart.x) > Math.abs(y - touchStart.y)) { - if (self.scrollX) { - if (main.scrollLeft === 0 && x > touchStart.x) { - needStop = false; - return; - } else if (main.scrollWidth === main.offsetWidth + main.scrollLeft && x < touchStart.x) { - needStop = false; - return; - } - needStop = true; - } else { - needStop = false; - } - } else { - if (self.scrollY) { - if (main.scrollTop === 0 && y > touchStart.y) { - needStop = false; - return; - } else if (main.scrollHeight === main.offsetHeight + main.scrollTop && y < touchStart.y) { - needStop = false; - return; - } - needStop = true; - } else { - needStop = false; - } - } + if (this._SFA) { + this._SFA.cancel(); } - if (needStop) { - event2.stopPropagation(); + if (!this.xMove) { + x = this._translateX; } - if (self.refresherEnabled && self.refreshState === "pulling") { - const dy = y - touchStart.y; - self.refresherHeight = dy; - let rotate = dy / self.refresherThreshold; - if (rotate > 1) { - rotate = 1; - } else { - rotate = rotate * 360; - } - self.refreshRotate = rotate; - self.$trigger("refresherpulling", event2, { - deltaY: dy - }); + if (!this.yMove) { + y = this._translateY; } - }; - this.__handleTouchStart = function(event2) { - if (event2.touches.length === 1) { - needStop = null; - touchStart = { - x: event2.touches[0].pageX, - y: event2.touches[0].pageY - }; - if (self.refresherEnabled && self.refreshState !== "refreshing" && self.$refs.main.scrollTop === 0) { - self.refreshState = "pulling"; - } + if (!this.scale) { + scale = this._scale; } - }; - this.__handleTouchEnd = function(event2) { - touchStart = null; - if (self.refresherHeight >= self.refresherThreshold) { - self._setRefreshState("refreshing"); - } else { - self.refresherHeight = 0; - self.$trigger("refresherabort", event2, {}); + var limitXY = this._getLimitXY(x, y); + x = limitXY.x; + y = limitXY.y; + if (!this.animation) { + this._setTransform(x, y, scale, source, r, o2); + return; } - }; - this.$refs.main.addEventListener("touchstart", this.__handleTouchStart, passiveOptions); - this.$refs.main.addEventListener("touchmove", this.__handleTouchMove, passiveOptions); - this.$refs.main.addEventListener("scroll", this.__handleScroll, { - passive: false - }); - this.$refs.main.addEventListener("touchend", this.__handleTouchEnd, passiveOptions); - }, - activated() { - this.scrollY && (this.$refs.main.scrollTop = this.lastScrollTop); - this.scrollX && (this.$refs.main.scrollLeft = this.lastScrollLeft); - }, - beforeDestroy() { - this.$refs.main.removeEventListener("touchstart", this.__handleTouchStart, passiveOptions); - this.$refs.main.removeEventListener("touchmove", this.__handleTouchMove, passiveOptions); - this.$refs.main.removeEventListener("scroll", this.__handleScroll, { - passive: false - }); - this.$refs.main.removeEventListener("touchend", this.__handleTouchEnd, passiveOptions); - }, - methods: { - scrollTo: function(t2, n) { - var i = this.$refs.main; - t2 < 0 ? t2 = 0 : n === "x" && t2 > i.scrollWidth - i.offsetWidth ? t2 = i.scrollWidth - i.offsetWidth : n === "y" && t2 > i.scrollHeight - i.offsetHeight && (t2 = i.scrollHeight - i.offsetHeight); - var r = 0; - var o2 = ""; - n === "x" ? r = i.scrollLeft - t2 : n === "y" && (r = i.scrollTop - t2); - if (r !== 0) { - this.$refs.content.style.transition = "transform .3s ease-out"; - this.$refs.content.style.webkitTransition = "-webkit-transform .3s ease-out"; - if (n === "x") { - o2 = "translateX(" + r + "px) translateZ(0)"; - } else { - n === "y" && (o2 = "translateY(" + r + "px) translateZ(0)"); - } - this.$refs.content.removeEventListener("transitionend", this.__transitionEnd); - this.$refs.content.removeEventListener("webkitTransitionEnd", this.__transitionEnd); - this.__transitionEnd = this._transitionEnd.bind(this, t2, n); - this.$refs.content.addEventListener("transitionend", this.__transitionEnd); - this.$refs.content.addEventListener("webkitTransitionEnd", this.__transitionEnd); - if (n === "x") { - i.style.overflowX = "hidden"; - } else if (n === "y") { - i.style.overflowY = "hidden"; - } - this.$refs.content.style.transform = o2; - this.$refs.content.style.webkitTransform = o2; + this._STD._springX._solution = null; + this._STD._springY._solution = null; + this._STD._springScale._solution = null; + this._STD._springX._endPosition = this._translateX; + this._STD._springY._endPosition = this._translateY; + this._STD._springScale._endPosition = this._scale; + this._STD.setEnd(x, y, scale, 1); + this._SFA = g(this._STD, function() { + var data = self._STD.x(); + var x2 = data.x; + var y2 = data.y; + var scale2 = data.scale; + self._setTransform(x2, y2, scale2, source, r, o2); + }, function() { + self._SFA.cancel(); + }); + }, + _revise: function(source) { + var limitXY = this._getLimitXY(this._translateX, this._translateY); + var x = limitXY.x; + var y = limitXY.y; + var outOfBounds = limitXY.outOfBounds; + if (outOfBounds) { + this._animationTo(x, y, this._scale, source); } + return outOfBounds; }, - _handleTrack: function($event) { - if ($event.detail.state === "start") { - this._x = $event.detail.x; - this._y = $event.detail.y; - this._noBubble = null; - return; + _setTransform: function(x, y, scale, source = "", r, o2) { + if (!(x !== null && x.toString() !== "NaN" && typeof x === "number")) { + x = this._translateX || 0; } - if ($event.detail.state === "end") { - this._noBubble = false; + if (!(y !== null && y.toString() !== "NaN" && typeof y === "number")) { + y = this._translateY || 0; } - if (this._noBubble === null && this.scrollY) { - if (Math.abs(this._y - $event.detail.y) / Math.abs(this._x - $event.detail.x) > 1) { - this._noBubble = true; - } else { - this._noBubble = false; - } - } - if (this._noBubble === null && this.scrollX) { - if (Math.abs(this._x - $event.detail.x) / Math.abs(this._y - $event.detail.y) > 1) { - this._noBubble = true; - } else { - this._noBubble = false; + x = Number(x.toFixed(1)); + y = Number(y.toFixed(1)); + scale = Number(scale.toFixed(1)); + if (!(this._translateX === x && this._translateY === y)) { + if (!r) { + this.$trigger("change", {}, { + x: v(x, this._scaleOffset.x), + y: v(y, this._scaleOffset.y), + source + }); } } - this._x = $event.detail.x; - this._y = $event.detail.y; - if (this._noBubble) { - $event.stopPropagation(); + if (!this.scale) { + scale = this._scale; } - }, - _handleScroll: function($event) { - if (!($event.timeStamp - this._lastScrollTime < 20)) { - this._lastScrollTime = $event.timeStamp; - const target = $event.target; - this.$trigger("scroll", $event, { - scrollLeft: target.scrollLeft, - scrollTop: target.scrollTop, - scrollHeight: target.scrollHeight, - scrollWidth: target.scrollWidth, - deltaX: this.lastScrollLeft - target.scrollLeft, - deltaY: this.lastScrollTop - target.scrollTop + scale = this._adjustScale(scale); + scale = +scale.toFixed(3); + if (o2 && scale !== this._scale) { + this.$trigger("scale", {}, { + x, + y, + scale }); - if (this.scrollY) { - if (target.scrollTop <= this.upperThresholdNumber && this.lastScrollTop - target.scrollTop > 0 && $event.timeStamp - this.lastScrollToUpperTime > 200) { - this.$trigger("scrolltoupper", $event, { - direction: "top" - }); - this.lastScrollToUpperTime = $event.timeStamp; - } - if (target.scrollTop + target.offsetHeight + this.lowerThresholdNumber >= target.scrollHeight && this.lastScrollTop - target.scrollTop < 0 && $event.timeStamp - this.lastScrollToLowerTime > 200) { - this.$trigger("scrolltolower", $event, { - direction: "bottom" - }); - this.lastScrollToLowerTime = $event.timeStamp; - } - } - if (this.scrollX) { - if (target.scrollLeft <= this.upperThresholdNumber && this.lastScrollLeft - target.scrollLeft > 0 && $event.timeStamp - this.lastScrollToUpperTime > 200) { - this.$trigger("scrolltoupper", $event, { - direction: "left" - }); - this.lastScrollToUpperTime = $event.timeStamp; - } - if (target.scrollLeft + target.offsetWidth + this.lowerThresholdNumber >= target.scrollWidth && this.lastScrollLeft - target.scrollLeft < 0 && $event.timeStamp - this.lastScrollToLowerTime > 200) { - this.$trigger("scrolltolower", $event, { - direction: "right" - }); - this.lastScrollToLowerTime = $event.timeStamp; - } - } - this.lastScrollTop = target.scrollTop; - this.lastScrollLeft = target.scrollLeft; } + var transform = "translateX(" + x + "px) translateY(" + y + "px) translateZ(0px) scale(" + scale + ")"; + this.$el.style.transform = transform; + this.$el.style.webkitTransform = transform; + this._translateX = x; + this._translateY = y; + this._scale = scale; + } + } +}; +function _sfc_render$e(_ctx, _cache, $props, $setup, $data, $options) { + const _component_v_uni_resize_sensor = resolveComponent("v-uni-resize-sensor"); + return openBlock(), createBlock("uni-movable-view", _ctx.$attrs, [ + createVNode(_component_v_uni_resize_sensor, {onResize: $options.setParent}, null, 8, ["onResize"]), + renderSlot(_ctx.$slots, "default") + ], 16); +} +_sfc_main$e.render = _sfc_render$e; +const OPEN_TYPES = [ + "navigate", + "redirect", + "switchTab", + "reLaunch", + "navigateBack" +]; +const _sfc_main$d = { + name: "Navigator", + mixins: [hover], + props: { + hoverClass: { + type: String, + default: "navigator-hover" }, - _scrollTopChanged: function(val) { - if (this.scrollY) { - if (this._innerSetScrollTop) { - this._innerSetScrollTop = false; - } else { - if (this.scrollWithAnimation) { - this.scrollTo(val, "y"); - } else { - this.$refs.main.scrollTop = val; - } - } - } + url: { + type: String, + default: "" }, - _scrollLeftChanged: function(val) { - if (this.scrollX) { - if (this._innerSetScrollLeft) { - this._innerSetScrollLeft = false; - } else { - if (this.scrollWithAnimation) { - this.scrollTo(val, "x"); - } else { - this.$refs.main.scrollLeft = val; - } - } + openType: { + type: String, + default: "navigate", + validator(value) { + return ~OPEN_TYPES.indexOf(value); } }, - _scrollIntoViewChanged: function(val) { - if (val) { - if (!/^[_a-zA-Z][-_a-zA-Z0-9:]*$/.test(val)) { - console.group('scroll-into-view="' + val + '" \u6709\u8BEF'); - console.error("id \u5C5E\u6027\u503C\u683C\u5F0F\u9519\u8BEF\u3002\u5982\u4E0D\u80FD\u4EE5\u6570\u5B57\u5F00\u5934\u3002"); - console.groupEnd(); - return; - } - var element = this.$el.querySelector("#" + val); - if (element) { - var mainRect = this.$refs.main.getBoundingClientRect(); - var elRect = element.getBoundingClientRect(); - if (this.scrollX) { - var left = elRect.left - mainRect.left; - var scrollLeft = this.$refs.main.scrollLeft; - var x = scrollLeft + left; - if (this.scrollWithAnimation) { - this.scrollTo(x, "x"); - } else { - this.$refs.main.scrollLeft = x; - } - } - if (this.scrollY) { - var top = elRect.top - mainRect.top; - var scrollTop = this.$refs.main.scrollTop; - var y = scrollTop + top; - if (this.scrollWithAnimation) { - this.scrollTo(y, "y"); - } else { - this.$refs.main.scrollTop = y; - } - } - } - } + delta: { + type: Number, + default: 1 }, - _transitionEnd: function(val, type) { - this.$refs.content.style.transition = ""; - this.$refs.content.style.webkitTransition = ""; - this.$refs.content.style.transform = ""; - this.$refs.content.style.webkitTransform = ""; - var main = this.$refs.main; - if (type === "x") { - main.style.overflowX = this.scrollX ? "auto" : "hidden"; - main.scrollLeft = val; - } else if (type === "y") { - main.style.overflowY = this.scrollY ? "auto" : "hidden"; - main.scrollTop = val; - } - this.$refs.content.removeEventListener("transitionend", this.__transitionEnd); - this.$refs.content.removeEventListener("webkitTransitionEnd", this.__transitionEnd); + hoverStartTime: { + type: [Number, String], + default: 20 }, - _setRefreshState(state) { - switch (state) { - case "refreshing": - this.refresherHeight = this.refresherThreshold; - this.$trigger("refresherrefresh", event, {}); + hoverStayTime: { + type: [Number, String], + default: 600 + }, + exists: { + type: String, + default: "" + } + }, + methods: { + _onClick($event) { + if (this.openType !== "navigateBack" && !this.url) { + console.error(" should have url attribute when using navigateTo, redirectTo, reLaunch or switchTab"); + return; + } + switch (this.openType) { + case "navigate": + uni.navigateTo({ + url: this.url + }); break; - case "restore": - this.refresherHeight = 0; - this.$trigger("refresherrestore", {}, {}); + case "redirect": + uni.redirectTo({ + url: this.url, + exists: this.exists + }); + break; + case "switchTab": + uni.switchTab({ + url: this.url + }); + break; + case "reLaunch": + uni.reLaunch({ + url: this.url + }); + break; + case "navigateBack": + uni.navigateBack({ + delta: this.delta + }); break; } - this.refreshState = state; - }, - getScrollPosition() { - const main = this.$refs.main; - return { - scrollLeft: main.scrollLeft, - scrollTop: main.scrollTop - }; } } }; -const _hoisted_1$6 = { - ref: "wrap", - class: "uni-scroll-view" -}; -const _hoisted_2$4 = { - ref: "content", - class: "uni-scroll-view-content" -}; -const _hoisted_3$1 = { - key: 0, - class: "uni-scroll-view-refresh" -}; -const _hoisted_4$1 = {class: "uni-scroll-view-refresh-inner"}; -const _hoisted_5 = /* @__PURE__ */ createVNode("path", {d: "M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"}, null, -1); -const _hoisted_6 = /* @__PURE__ */ createVNode("path", { - d: "M0 0h24v24H0z", - fill: "none" -}, null, -1); -const _hoisted_7 = { - key: 1, - class: "uni-scroll-view-refresh__spinner", - width: "24", - height: "24", - viewBox: "25 25 50 50" -}; -const _hoisted_8 = /* @__PURE__ */ createVNode("circle", { - cx: "50", - cy: "50", - r: "20", - fill: "none", - style: {color: "#2bd009"}, - "stroke-width": "3" -}, null, -1); -function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) { - return openBlock(), createBlock("uni-scroll-view", _ctx.$attrs, [ - createVNode("div", _hoisted_1$6, [ - createVNode("div", { - ref: "main", - style: { - "overflow-x": $props.scrollX ? "auto" : "hidden", - "overflow-y": $props.scrollY ? "auto" : "hidden" - }, - class: "uni-scroll-view" - }, [ - createVNode("div", _hoisted_2$4, [ - $props.refresherEnabled ? (openBlock(), createBlock("div", { - key: 0, - ref: "refresherinner", - style: { - "background-color": $props.refresherBackground, - height: $data.refresherHeight + "px" - }, - class: "uni-scroll-view-refresher" - }, [ - $props.refresherDefaultStyle !== "none" ? (openBlock(), createBlock("div", _hoisted_3$1, [ - createVNode("div", _hoisted_4$1, [ - $data.refreshState == "pulling" ? (openBlock(), createBlock("svg", { - key: 0, - style: {transform: "rotate(" + $data.refreshRotate + "deg)"}, - fill: "#2BD009", - class: "uni-scroll-view-refresh__icon", - width: "24", - height: "24", - viewBox: "0 0 24 24" - }, [ - _hoisted_5, - _hoisted_6 - ], 4)) : createCommentVNode("", true), - $data.refreshState == "refreshing" ? (openBlock(), createBlock("svg", _hoisted_7, [ - _hoisted_8 - ])) : createCommentVNode("", true) - ]) - ])) : createCommentVNode("", true), - $props.refresherDefaultStyle == "none" ? renderSlot(_ctx.$slots, "refresher", {key: 1}) : createCommentVNode("", true) - ], 4)) : createCommentVNode("", true), - renderSlot(_ctx.$slots, "default") - ], 512) - ], 4) - ], 512) - ], 16); +function _sfc_render$d(_ctx, _cache, $props, $setup, $data, $options) { + return $props.hoverClass && $props.hoverClass !== "none" ? (openBlock(), createBlock("uni-navigator", { + key: 0, + class: [_ctx.hovering ? $props.hoverClass : ""], + onTouchstart: _cache[1] || (_cache[1] = (...args) => _ctx._hoverTouchStart && _ctx._hoverTouchStart(...args)), + onTouchend: _cache[2] || (_cache[2] = (...args) => _ctx._hoverTouchEnd && _ctx._hoverTouchEnd(...args)), + onTouchcancel: _cache[3] || (_cache[3] = (...args) => _ctx._hoverTouchCancel && _ctx._hoverTouchCancel(...args)), + onClick: _cache[4] || (_cache[4] = (...args) => $options._onClick && $options._onClick(...args)) + }, [ + renderSlot(_ctx.$slots, "default") + ], 34)) : (openBlock(), createBlock("uni-navigator", { + key: 1, + onClick: _cache[5] || (_cache[5] = (...args) => $options._onClick && $options._onClick(...args)) + }, [ + renderSlot(_ctx.$slots, "default") + ])); } -_sfc_main$8.render = _sfc_render$8; -const _sfc_main$7 = { - name: "Slider", - mixins: [emitter, listeners, touchtrack], +_sfc_main$d.render = _sfc_render$d; +const VALUES = { + activeColor: "#007AFF", + backgroundColor: "#EBEBEB", + activeMode: "backwards" +}; +const _sfc_main$c = { + name: "Progress", props: { - name: { - type: String, - default: "" - }, - min: { - type: [Number, String], - default: 0 - }, - max: { - type: [Number, String], - default: 100 - }, - value: { - type: [Number, String], - default: 0 - }, - step: { + percent: { type: [Number, String], - default: 1 + default: 0, + validator(value) { + return !isNaN(parseFloat(value, 10)); + } }, - disabled: { + showInfo: { type: [Boolean, String], default: false }, - color: { - type: String, - default: "#e9e9e9" + strokeWidth: { + type: [Number, String], + default: 6, + validator(value) { + return !isNaN(parseFloat(value, 10)); + } }, - backgroundColor: { + color: { type: String, - default: "#e9e9e9" + default: VALUES.activeColor }, activeColor: { type: String, - default: "#007aff" - }, - selectedColor: { - type: String, - default: "#007aff" + default: VALUES.activeColor }, - blockColor: { + backgroundColor: { type: String, - default: "#ffffff" - }, - blockSize: { - type: [Number, String], - default: 28 + default: VALUES.backgroundColor }, - showValue: { + active: { type: [Boolean, String], default: false + }, + activeMode: { + type: String, + default: VALUES.activeMode } }, data() { return { - sliderValue: Number(this.value) + currentPercent: 0, + strokeTimer: 0, + lastPercent: 0 }; }, computed: { - setBlockStyle() { - return { - width: this.blockSize + "px", - height: this.blockSize + "px", - marginLeft: -this.blockSize / 2 + "px", - marginTop: -this.blockSize / 2 + "px", - left: this._getValueWidth(), - backgroundColor: this.blockColor - }; - }, - setBgColor() { - return { - backgroundColor: this._getBgColor() - }; + outerBarStyle() { + return `background-color: ${this.backgroundColor}; height: ${this.strokeWidth}px;`; }, - setBlockBg() { - return { - left: this._getValueWidth() - }; + innerBarStyle() { + let backgroundColor = ""; + if (this.color !== VALUES.activeColor && this.activeColor === VALUES.activeColor) { + backgroundColor = this.color; + } else { + backgroundColor = this.activeColor; + } + return `width: ${this.currentPercent}%;background-color: ${backgroundColor}`; }, - setActiveColor() { - return { - backgroundColor: this._getActiveColor(), - width: this._getValueWidth() - }; + realPercent() { + let realValue = parseFloat(this.percent, 10); + realValue < 0 && (realValue = 0); + realValue > 100 && (realValue = 100); + return realValue; } }, watch: { - value(val) { - this.sliderValue = Number(val); + realPercent(newValue, oldValue) { + this.strokeTimer && clearInterval(this.strokeTimer); + this.lastPercent = oldValue || 0; + this._activeAnimation(); } }, - mounted() { - this.touchtrack(this.$refs["uni-slider-handle"], "_onTrack"); - }, created() { - this.$dispatch("Form", "uni-form-group-update", { - type: "add", - vm: this - }); - }, - beforeDestroy() { - this.$dispatch("Form", "uni-form-group-update", { - type: "remove", - vm: this - }); + this._activeAnimation(); }, methods: { - _onUserChangedValue(e2) { - const slider = this.$refs["uni-slider"]; - const offsetWidth = slider.offsetWidth; - const boxLeft = slider.getBoundingClientRect().left; - const value = (e2.x - boxLeft) * (this.max - this.min) / offsetWidth + Number(this.min); - this.sliderValue = this._filterValue(value); - }, - _filterValue(e2) { - return e2 < this.min ? this.min : e2 > this.max ? this.max : Math.round((e2 - this.min) / this.step) * this.step + Number(this.min); - }, - _getValueWidth() { - return 100 * (this.sliderValue - this.min) / (this.max - this.min) + "%"; - }, - _getBgColor() { - return this.backgroundColor !== "#e9e9e9" ? this.backgroundColor : this.color !== "#007aff" ? this.color : "#007aff"; - }, - _getActiveColor() { - return this.activeColor !== "#007aff" ? this.activeColor : this.selectedColor !== "#e9e9e9" ? this.selectedColor : "#e9e9e9"; - }, - _onTrack: function(e2) { - if (!this.disabled) { - return e2.detail.state === "move" ? (this._onUserChangedValue({ - x: e2.detail.x0 - }), this.$trigger("changing", e2, { - value: this.sliderValue - }), false) : e2.detail.state === "end" && this.$trigger("change", e2, { - value: this.sliderValue - }); - } - }, - _onClick($event) { - if (this.disabled) { - return; - } - this._onUserChangedValue($event); - this.$trigger("change", $event, { - value: this.sliderValue - }); - }, - _resetFormData() { - this.sliderValue = this.min; - }, - _getFormData() { - const data = {}; - if (this.name !== "") { - data.value = this.sliderValue; - data.key = this.name; + _activeAnimation() { + if (this.active) { + this.currentPercent = this.activeMode === VALUES.activeMode ? 0 : this.lastPercent; + this.strokeTimer = setInterval(() => { + if (this.currentPercent + 1 > this.realPercent) { + this.currentPercent = this.realPercent; + this.strokeTimer && clearInterval(this.strokeTimer); + } else { + this.currentPercent += 1; + } + }, 30); + } else { + this.currentPercent = this.realPercent; } - return data; } } }; -const _hoisted_1$5 = {class: "uni-slider-wrapper"}; -const _hoisted_2$3 = {class: "uni-slider-tap-area"}; -function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) { - return openBlock(), createBlock("uni-slider", mergeProps({ref: "uni-slider"}, _ctx.$attrs, { - onClick: _cache[1] || (_cache[1] = (...args) => $options._onClick && $options._onClick(...args)) - }), [ - createVNode("div", _hoisted_1$5, [ - createVNode("div", _hoisted_2$3, [ - createVNode("div", { - style: $options.setBgColor, - class: "uni-slider-handle-wrapper" - }, [ - createVNode("div", { - ref: "uni-slider-handle", - style: $options.setBlockBg, - class: "uni-slider-handle" - }, null, 4), - createVNode("div", { - style: $options.setBlockStyle, - class: "uni-slider-thumb" - }, null, 4), - createVNode("div", { - style: $options.setActiveColor, - class: "uni-slider-track" - }, null, 4) - ], 4) - ]), - withDirectives(createVNode("span", {class: "uni-slider-value"}, toDisplayString($data.sliderValue), 513), [ - [vShow, $props.showValue] - ]) - ]), - renderSlot(_ctx.$slots, "default") - ], 16); -} -_sfc_main$7.render = _sfc_render$7; -var index_vue_vue_type_style_index_0_lang$4 = "\nuni-swiper-item {\n display: block;\n overflow: hidden;\n will-change: transform;\n position: absolute;\n width: 100%;\n height: 100%;\n cursor: grab;\n}\nuni-swiper-item[hidden] {\n display: none;\n}\n"; -const _sfc_main$6 = { - name: "SwiperItem", - props: { - itemId: { - type: String, - default: "" - } - }, - mounted: function() { - var $el = this.$el; - $el.style.position = "absolute"; - $el.style.width = "100%"; - $el.style.height = "100%"; - var callbacks2 = this.$vnode._callbacks; - if (callbacks2) { - callbacks2.forEach((callback) => { - callback(); - }); - } - } +const _hoisted_1$9 = { + key: 0, + class: "uni-progress-info" }; -function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) { - return openBlock(), createBlock("uni-swiper-item", _ctx.$attrs, [ - renderSlot(_ctx.$slots, "default") +function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) { + return openBlock(), createBlock("uni-progress", mergeProps({class: "uni-progress"}, _ctx.$attrs), [ + createVNode("div", { + style: $options.outerBarStyle, + class: "uni-progress-bar" + }, [ + createVNode("div", { + style: $options.innerBarStyle, + class: "uni-progress-inner-bar" + }, null, 4) + ], 4), + $props.showInfo ? (openBlock(), createBlock("p", _hoisted_1$9, toDisplayString($data.currentPercent) + "% ", 1)) : createCommentVNode("", true) ], 16); } -_sfc_main$6.render = _sfc_render$6; -var index_vue_vue_type_style_index_0_lang$3 = '\nuni-switch {\r\n -webkit-tap-highlight-color: transparent;\r\n display: inline-block;\r\n cursor: pointer;\n}\nuni-switch[hidden] {\r\n display: none;\n}\nuni-switch[disabled] {\r\n cursor: not-allowed;\n}\nuni-switch .uni-switch-wrapper {\r\n display: -webkit-inline-flex;\r\n display: inline-flex;\r\n -webkit-align-items: center;\r\n align-items: center;\r\n vertical-align: middle;\n}\nuni-switch .uni-switch-input {\r\n -webkit-appearance: none;\r\n appearance: none;\r\n position: relative;\r\n width: 52px;\r\n height: 32px;\r\n margin-right: 5px;\r\n border: 1px solid #DFDFDF;\r\n outline: 0;\r\n border-radius: 16px;\r\n box-sizing: border-box;\r\n background-color: #DFDFDF;\r\n transition: background-color 0.1s, border 0.1s;\n}\nuni-switch[disabled] .uni-switch-input {\r\n opacity: .7;\n}\nuni-switch .uni-switch-input:before {\r\n content: " ";\r\n position: absolute;\r\n top: 0;\r\n left: 0;\r\n width: 50px;\r\n height: 30px;\r\n border-radius: 15px;\r\n background-color: #FDFDFD;\r\n transition: -webkit-transform 0.3s;\r\n transition: transform 0.3s;\r\n transition: transform 0.3s, -webkit-transform 0.3s;\n}\nuni-switch .uni-switch-input:after {\r\n content: " ";\r\n position: absolute;\r\n top: 0;\r\n left: 0;\r\n width: 30px;\r\n height: 30px;\r\n border-radius: 15px;\r\n background-color: #FFFFFF;\r\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);\r\n transition: -webkit-transform 0.3s;\r\n transition: transform 0.3s;\r\n transition: transform 0.3s, -webkit-transform 0.3s;\n}\nuni-switch .uni-switch-input.uni-switch-input-checked {\r\n border-color: #007aff;\r\n background-color: #007aff;\n}\nuni-switch .uni-switch-input.uni-switch-input-checked:before {\r\n -webkit-transform: scale(0);\r\n transform: scale(0);\n}\nuni-switch .uni-switch-input.uni-switch-input-checked:after {\r\n -webkit-transform: translateX(20px);\r\n transform: translateX(20px);\n}\nuni-switch .uni-checkbox-input {\r\n margin-right: 5px;\r\n -webkit-appearance: none;\r\n appearance: none;\r\n outline: 0;\r\n border: 1px solid #D1D1D1;\r\n background-color: #FFFFFF;\r\n border-radius: 3px;\r\n width: 22px;\r\n height: 22px;\r\n position: relative;\r\n color: #007aff;\n}\nuni-switch:not([disabled]) .uni-checkbox-input:hover {\r\n border-color: #007aff;\n}\nuni-switch .uni-checkbox-input.uni-checkbox-input-checked:before {\r\n font: normal normal normal 14px/1 "uni";\r\n content: "\\EA08";\r\n color: inherit;\r\n font-size: 22px;\r\n position: absolute;\r\n top: 50%;\r\n left: 50%;\r\n transform: translate(-50%, -48%) scale(0.73);\r\n -webkit-transform: translate(-50%, -48%) scale(0.73);\n}\nuni-switch .uni-checkbox-input.uni-checkbox-input-disabled {\r\n background-color: #E1E1E1;\n}\nuni-switch .uni-checkbox-input.uni-checkbox-input-disabled:before {\r\n color: #ADADAD;\n}\r\n'; -const _sfc_main$5 = { - name: "Switch", +_sfc_main$c.render = _sfc_render$c; +var index_vue_vue_type_style_index_0_lang$6 = '\nuni-radio {\r\n -webkit-tap-highlight-color: transparent;\r\n display: inline-block;\r\n cursor: pointer;\n}\nuni-radio[hidden] {\r\n display: none;\n}\nuni-radio[disabled] {\r\n cursor: not-allowed;\n}\nuni-radio .uni-radio-wrapper {\r\n display: -webkit-inline-flex;\r\n display: inline-flex;\r\n -webkit-align-items: center;\r\n align-items: center;\r\n vertical-align: middle;\n}\nuni-radio .uni-radio-input {\r\n -webkit-appearance: none;\r\n appearance: none;\r\n margin-right: 5px;\r\n outline: 0;\r\n border: 1px solid #D1D1D1;\r\n background-color: #ffffff;\r\n border-radius: 50%;\r\n width: 22px;\r\n height: 22px;\r\n position: relative;\n}\nuni-radio:not([disabled]) .uni-radio-input:hover {\r\n border-color: #007aff;\n}\nuni-radio .uni-radio-input.uni-radio-input-checked:before {\r\n font: normal normal normal 14px/1 "uni";\r\n content: "\\EA08";\r\n color: #ffffff;\r\n font-size: 18px;\r\n position: absolute;\r\n top: 50%;\r\n left: 50%;\r\n transform: translate(-50%, -48%) scale(0.73);\r\n -webkit-transform: translate(-50%, -48%) scale(0.73);\n}\nuni-radio .uni-radio-input.uni-radio-input-disabled {\r\n background-color: #E1E1E1;\r\n border-color: #D1D1D1;\n}\nuni-radio .uni-radio-input.uni-radio-input-disabled:before {\r\n color: #ADADAD;\n}\nuni-radio-group {\r\n display: block;\n}\r\n'; +const _sfc_main$b = { + name: "Radio", mixins: [emitter, listeners], props: { - name: { - type: String, - default: "" - }, checked: { type: [Boolean, String], default: false }, - type: { - type: String, - default: "switch" - }, id: { type: String, default: "" @@ -7033,274 +6680,105 @@ const _sfc_main$5 = { }, color: { type: String, - default: "#007aff" + default: "#007AFF" + }, + value: { + type: String, + default: "" } }, data() { return { - switchChecked: this.checked + radioChecked: this.checked, + radioValue: this.value }; }, + computed: { + checkedStyle() { + return `background-color: ${this.color};border-color: ${this.color};`; + } + }, watch: { checked(val) { - this.switchChecked = val; + this.radioChecked = val; + }, + value(val) { + this.radioValue = val; } }, + listeners: { + "label-click": "_onClick", + "@label-click": "_onClick" + }, created() { + this.$dispatch("RadioGroup", "uni-radio-group-update", { + type: "add", + vm: this + }); this.$dispatch("Form", "uni-form-group-update", { type: "add", vm: this }); }, beforeDestroy() { + this.$dispatch("RadioGroup", "uni-radio-group-update", { + type: "remove", + vm: this + }); this.$dispatch("Form", "uni-form-group-update", { type: "remove", vm: this }); }, - listeners: { - "label-click": "_onClick", - "@label-click": "_onClick" - }, methods: { _onClick($event) { - if (this.disabled) { + if (this.disabled || this.radioChecked) { return; } - this.switchChecked = !this.switchChecked; - this.$trigger("change", $event, { - value: this.switchChecked - }); + this.radioChecked = true; + this.$dispatch("RadioGroup", "uni-radio-change", $event, this); }, _resetFormData() { - this.switchChecked = false; - }, - _getFormData() { - const data = {}; - if (this.name !== "") { - data.value = this.switchChecked; - data.key = this.name; - } - return data; + this.radioChecked = this.min; } } }; -const _hoisted_1$4 = {class: "uni-switch-wrapper"}; -function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) { - return openBlock(), createBlock("uni-switch", mergeProps({disabled: $props.disabled}, _ctx.$attrs, { +const _hoisted_1$8 = {class: "uni-radio-wrapper"}; +function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) { + return openBlock(), createBlock("uni-radio", mergeProps({disabled: $props.disabled}, _ctx.$attrs, { onClick: _cache[1] || (_cache[1] = (...args) => $options._onClick && $options._onClick(...args)) }), [ - createVNode("div", _hoisted_1$4, [ - withDirectives(createVNode("div", { - class: [[$data.switchChecked ? "uni-switch-input-checked" : ""], "uni-switch-input"], - style: {backgroundColor: $data.switchChecked ? $props.color : "#DFDFDF", borderColor: $data.switchChecked ? $props.color : "#DFDFDF"} - }, null, 6), [ - [vShow, $props.type === "switch"] - ]), - withDirectives(createVNode("div", { - class: [[$data.switchChecked ? "uni-checkbox-input-checked" : ""], "uni-checkbox-input"], - style: {color: $props.color} - }, null, 6), [ - [vShow, $props.type === "checkbox"] - ]) + createVNode("div", _hoisted_1$8, [ + createVNode("div", { + class: [$data.radioChecked ? "uni-radio-input-checked" : "", "uni-radio-input"], + style: $data.radioChecked ? $options.checkedStyle : "" + }, null, 6), + renderSlot(_ctx.$slots, "default") ]) ], 16, ["disabled"]); } -_sfc_main$5.render = _sfc_render$5; -const SPACE_UNICODE = { - ensp: "\u2002", - emsp: "\u2003", - nbsp: "\xA0" -}; -function normalizeText(text2, { - space, - decode: decode2 -}) { - if (space && SPACE_UNICODE[space]) { - text2 = text2.replace(/ /g, SPACE_UNICODE[space]); - } - if (!decode2) { - return 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$1 = defineComponent({ - name: "Text", +_sfc_main$b.render = _sfc_render$b; +var index_vue_vue_type_style_index_0_lang$5 = "\nuni-radio-group[hidden] {\r\n display: none;\n}\r\n"; +const _sfc_main$a = { + name: "RadioGroup", + mixins: [emitter, listeners], props: { - selectable: { - type: [Boolean, String], - default: false - }, - space: { + name: { type: String, default: "" - }, - decode: { - type: [Boolean, String], - default: false } }, - setup(props, { - slots - }) { - return () => { - const children = []; - if (slots.default) { - slots.default().forEach((vnode) => { - if (vnode.shapeFlag & 8) { - const lines = vnode.children.replace(/\\n/g, "\n").split("\n"); - const len = lines.length - 1; - lines.forEach((text2, index2) => { - children.push(createTextVNode(normalizeText(text2, { - space: props.space, - decode: props.decode - }))); - if (index2 !== len) { - children.push(createVNode("br")); - } - }); - } else { - if (process.env.NODE_ENV !== "production" && vnode.shapeFlag & 6 && vnode.type.name !== "Text") { - console.warn("Do not nest other components in the text component, as there may be display differences on different platforms."); - } - children.push(vnode); - } - }); - } - return createVNode("uni-text", { - selectable: props.selectable - }, [createVNode("span", null, [children])], 8, ["selectable"]); - }; - } -}); -var index_vue_vue_type_style_index_0_lang$2 = "\nuni-textarea {\n width: 300px;\n height: 150px;\n display: block;\n position: relative;\n font-size: 16px;\n line-height: normal;\n white-space: pre-wrap;\n word-break: break-all;\n}\nuni-textarea[hidden] {\n display: none;\n}\n.uni-textarea-wrapper,\n.uni-textarea-placeholder,\n.uni-textarea-line,\n.uni-textarea-compute,\n.uni-textarea-textarea {\n outline: none;\n border: none;\n padding: 0;\n margin: 0;\n text-decoration: inherit;\n}\n.uni-textarea-wrapper {\n display: block;\n position: relative;\n width: 100%;\n height: 100%;\n}\n.uni-textarea-placeholder,\n.uni-textarea-line,\n.uni-textarea-compute,\n.uni-textarea-textarea {\n position: absolute;\n width: 100%;\n height: 100%;\n left: 0;\n top: 0;\n white-space: inherit;\n word-break: inherit;\n}\n.uni-textarea-placeholder {\n color: grey;\n overflow: hidden;\n}\n.uni-textarea-line,\n.uni-textarea-compute {\n visibility: hidden;\n height: auto;\n}\n.uni-textarea-line {\n width: 1em;\n}\n.uni-textarea-textarea {\n resize: none;\n background: none;\n color: inherit;\n opacity: 1;\n -webkit-text-fill-color: currentcolor;\n font: inherit;\n line-height: inherit;\n letter-spacing: inherit;\n text-align: inherit;\n text-indent: inherit;\n text-transform: inherit;\n text-shadow: inherit;\n}\n/* \u7528\u4E8E\u89E3\u51B3 iOS textarea \u5185\u90E8\u9ED8\u8BA4\u8FB9\u8DDD */\n.uni-textarea-textarea-fix-margin {\n width: auto;\n right: 0;\n margin: 0 -3px;\n}\n"; -const DARK_TEST_STRING = "(prefers-color-scheme: dark)"; -const _sfc_main$4 = { - name: "Textarea", - mixins: [baseInput], - props: { - name: { - type: String, - default: "" - }, - maxlength: { - type: [Number, String], - default: 140 - }, - placeholder: { - type: String, - default: "" - }, - disabled: { - type: [Boolean, String], - default: false - }, - focus: { - type: [Boolean, String], - default: false - }, - autoFocus: { - type: [Boolean, String], - default: false - }, - placeholderClass: { - type: String, - default: "textarea-placeholder" - }, - placeholderStyle: { - type: String, - default: "" - }, - autoHeight: { - type: [Boolean, String], - default: false - }, - cursor: { - type: [Number, String], - default: -1 - }, - selectionStart: { - type: [Number, String], - default: -1 - }, - selectionEnd: { - type: [Number, String], - default: -1 - } - }, - data() { - return { - valueComposition: "", - composition: false, - focusSync: this.focus, - height: 0, - focusChangeSource: "", - fixMargin: String(navigator.platform).indexOf("iP") === 0 && String(navigator.vendor).indexOf("Apple") === 0 && window.matchMedia(DARK_TEST_STRING).media !== DARK_TEST_STRING + data() { + return { + radioList: [] }; }, - computed: { - maxlengthNumber() { - var maxlength = Number(this.maxlength); - return isNaN(maxlength) ? 140 : maxlength; - }, - cursorNumber() { - var cursor = Number(this.cursor); - return isNaN(cursor) ? -1 : cursor; - }, - selectionStartNumber() { - var selectionStart = Number(this.selectionStart); - return isNaN(selectionStart) ? -1 : selectionStart; - }, - selectionEndNumber() { - var selectionEnd = Number(this.selectionEnd); - return isNaN(selectionEnd) ? -1 : selectionEnd; - }, - valueCompute() { - return (this.composition ? this.valueComposition : this.valueSync).split("\n"); - } + listeners: { + "@radio-change": "_changeHandler", + "@radio-group-update": "_radioGroupUpdateHandler" }, - watch: { - focus(val) { - if (val) { - this.focusChangeSource = "focus"; - if (this.$refs.textarea) { - this.$refs.textarea.focus(); - } - } else { - if (this.$refs.textarea) { - this.$refs.textarea.blur(); - } - } - }, - focusSync(val) { - this.$emit("update:focus", val); - this._checkSelection(); - this._checkCursor(); - }, - cursorNumber() { - this._checkCursor(); - }, - selectionStartNumber() { - this._checkSelection(); - }, - selectionEndNumber() { - this._checkSelection(); - }, - height(height) { - let lineHeight = parseFloat(getComputedStyle(this.$el).lineHeight); - if (isNaN(lineHeight)) { - lineHeight = this.$refs.line.offsetHeight; - } - var lineCount = Math.round(height / lineHeight); - this.$trigger("linechange", {}, { - height, - heightRpx: 750 / window.innerWidth * height, - lineCount - }); - if (this.autoHeight) { - this.$el.style.height = this.height + "px"; - } - } + mounted() { + this._resetRadioGroupValue(this.radioList.length - 1); }, created() { this.$dispatch("Form", "uni-form-group-update", { @@ -7308,20 +6786,6 @@ const _sfc_main$4 = { vm: this }); }, - mounted() { - this._resize({ - height: this.$refs.sensor.$el.offsetHeight - }); - let $vm = this; - while ($vm) { - const scopeId = $vm.$options._scopeId; - if (scopeId) { - this.$refs.placeholder.setAttribute(scopeId, ""); - } - $vm = $vm.$parent; - } - this.initKeyboard(this.$refs.textarea); - }, beforeDestroy() { this.$dispatch("Form", "uni-form-group-update", { type: "remove", @@ -7329,1060 +6793,2165 @@ const _sfc_main$4 = { }); }, methods: { - _focus: function($event) { - this.focusSync = true; - this.$trigger("focus", $event, { - value: this.valueSync + _changeHandler($event, vm) { + const index2 = this.radioList.indexOf(vm); + this._resetRadioGroupValue(index2, true); + this.$trigger("change", $event, { + value: vm.radioValue }); }, - _checkSelection() { - if (this.focusSync && !this.focusChangeSource && this.selectionStartNumber > -1 && this.selectionEndNumber > -1) { - this.$refs.textarea.selectionStart = this.selectionStartNumber; - this.$refs.textarea.selectionEnd = this.selectionEndNumber; - } - }, - _checkCursor() { - if (this.focusSync && (this.focusChangeSource === "focus" || !this.focusChangeSource && this.selectionStartNumber < 0 && this.selectionEndNumber < 0) && this.cursorNumber > -1) { - this.$refs.textarea.selectionEnd = this.$refs.textarea.selectionStart = this.cursorNumber; + _radioGroupUpdateHandler($event) { + if ($event.type === "add") { + this.radioList.push($event.vm); + } else { + const index2 = this.radioList.indexOf($event.vm); + this.radioList.splice(index2, 1); } }, - _blur: function($event) { - this.focusSync = false; - this.$trigger("blur", $event, { - value: this.valueSync, - cursor: this.$refs.textarea.selectionEnd - }); - }, - _compositionstart($event) { - this.composition = true; - }, - _compositionend($event) { - this.composition = false; - }, - _confirm($event) { - this.$trigger("confirm", $event, { - value: this.valueSync - }); - }, - _linechange($event) { - this.$trigger("linechange", $event, { - value: this.valueSync - }); - }, - _touchstart() { - this.focusChangeSource = "touch"; - }, - _resize({height}) { - this.height = height; - }, - _input($event) { - if (this.composition) { - this.valueComposition = $event.target.value; - return; - } - this.$triggerInput($event, { - value: this.valueSync, - cursor: this.$refs.textarea.selectionEnd + _resetRadioGroupValue(key, change) { + this.radioList.forEach((value, index2) => { + if (index2 === key) { + return; + } + if (change) { + this.radioList[index2].radioChecked = false; + } else { + this.radioList.forEach((v2, i2) => { + if (index2 >= i2) { + return; + } + if (this.radioList[i2].radioChecked) { + this.radioList[index2].radioChecked = false; + } + }); + } }); }, _getFormData() { - return { - value: this.valueSync, - key: this.name - }; - }, - _resetFormData() { - this.valueSync = ""; + const data = {}; + if (this.name !== "") { + let value = ""; + this.radioList.forEach((vm) => { + if (vm.radioChecked) { + value = vm.value; + } + }); + data.value = value; + data.key = this.name; + } + return data; } } }; -const _hoisted_1$3 = {class: "uni-textarea-wrapper"}; -const _hoisted_2$2 = {class: "uni-textarea-compute"}; -function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) { - const _component_v_uni_resize_sensor = resolveComponent("v-uni-resize-sensor"); - return openBlock(), createBlock("uni-textarea", mergeProps({ - onChange: _cache[8] || (_cache[8] = withModifiers(() => { - }, ["stop"])) - }, _ctx.$attrs), [ - createVNode("div", _hoisted_1$3, [ - withDirectives(createVNode("div", { - ref: "placeholder", - style: $props.placeholderStyle, - class: [$props.placeholderClass, "uni-textarea-placeholder"], - textContent: toDisplayString($props.placeholder) - }, null, 14, ["textContent"]), [ - [vShow, !($data.composition || _ctx.valueSync.length)] - ]), - createVNode("div", { - ref: "line", - class: "uni-textarea-line", - textContent: toDisplayString(" ") - }, null, 8, ["textContent"]), - createVNode("div", _hoisted_2$2, [ - (openBlock(true), createBlock(Fragment, null, renderList($options.valueCompute, (item, index2) => { - return openBlock(), createBlock("div", { - key: index2, - textContent: toDisplayString(item.trim() ? item : ".") - }, null, 8, ["textContent"]); - }), 128)), - createVNode(_component_v_uni_resize_sensor, { - ref: "sensor", - onResize: $options._resize - }, null, 8, ["onResize"]) - ]), - withDirectives(createVNode("textarea", { - ref: "textarea", - "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => _ctx.valueSync = $event), - disabled: $props.disabled, - maxlength: $options.maxlengthNumber, - autofocus: $props.autoFocus || $props.focus, - class: [{"uni-textarea-textarea-fix-margin": $data.fixMargin}, "uni-textarea-textarea"], - style: {"overflow-y": $props.autoHeight ? "hidden" : "auto"}, - onCompositionstart: _cache[2] || (_cache[2] = (...args) => $options._compositionstart && $options._compositionstart(...args)), - onCompositionend: _cache[3] || (_cache[3] = (...args) => $options._compositionend && $options._compositionend(...args)), - onInput: _cache[4] || (_cache[4] = withModifiers((...args) => $options._input && $options._input(...args), ["stop"])), - onFocus: _cache[5] || (_cache[5] = (...args) => $options._focus && $options._focus(...args)), - onBlur: _cache[6] || (_cache[6] = (...args) => $options._blur && $options._blur(...args)), - onTouchstartPassive: _cache[7] || (_cache[7] = (...args) => $options._touchstart && $options._touchstart(...args)) - }, null, 46, ["disabled", "maxlength", "autofocus"]), [ - [vModelText, _ctx.valueSync] - ]) - ]) - ], 16); -} -_sfc_main$4.render = _sfc_render$4; -const _sfc_main$3 = { - name: "View", - mixins: [hover], - listeners: { - "label-click": "clickHandler" - } -}; -const _hoisted_1$2 = {key: 1}; -function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) { - return _ctx.hoverClass && _ctx.hoverClass !== "none" ? (openBlock(), createBlock("uni-view", { - key: 0, - class: [_ctx.hovering ? _ctx.hoverClass : ""], - onTouchstart: _cache[1] || (_cache[1] = (...args) => _ctx._hoverTouchStart && _ctx._hoverTouchStart(...args)), - onTouchend: _cache[2] || (_cache[2] = (...args) => _ctx._hoverTouchEnd && _ctx._hoverTouchEnd(...args)), - onTouchcancel: _cache[3] || (_cache[3] = (...args) => _ctx._hoverTouchCancel && _ctx._hoverTouchCancel(...args)) - }, [ - renderSlot(_ctx.$slots, "default") - ], 34)) : (openBlock(), createBlock("uni-view", _hoisted_1$2, [ +function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) { + return openBlock(), createBlock("uni-radio-group", _ctx.$attrs, [ renderSlot(_ctx.$slots, "default") - ])); -} -_sfc_main$3.render = _sfc_render$3; -const UniViewJSBridge$1 = extend(ViewJSBridge, { - publishHandler(event2, args, pageId) { - window.UniServiceJSBridge.subscribeHandler(event2, args, pageId); - } -}); -var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -var lookup = new Uint8Array(256); -for (var i = 0; i < chars.length; i++) { - lookup[chars.charCodeAt(i)] = i; + ], 16); } -function encode$1(arraybuffer) { - var bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = ""; - for (i = 0; i < len; i += 3) { - base64 += chars[bytes[i] >> 2]; - base64 += chars[(bytes[i] & 3) << 4 | bytes[i + 1] >> 4]; - base64 += chars[(bytes[i + 1] & 15) << 2 | bytes[i + 2] >> 6]; - base64 += chars[bytes[i + 2] & 63]; - } - if (len % 3 === 2) { - base64 = base64.substring(0, base64.length - 1) + "="; - } else if (len % 3 === 1) { - base64 = base64.substring(0, base64.length - 2) + "=="; - } - return base64; +_sfc_main$a.render = _sfc_render$a; +function removeDOCTYPE(html) { + return html.replace(/<\?xml.*\?>\n/, "").replace(/\n/, "").replace(/\n/, ""); } -function decode(base64) { - var bufferLength = base64.length * 0.75, len = base64.length, i, p2 = 0, encoded1, encoded2, encoded3, encoded4; - if (base64[base64.length - 1] === "=") { - bufferLength--; - if (base64[base64.length - 2] === "=") { - bufferLength--; +function parseAttrs(attrs2) { + return attrs2.reduce(function(pre, attr2) { + let value = attr2.value; + const name = attr2.name; + if (value.match(/ /) && name !== "style") { + value = value.split(" "); } - } - var arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer); - for (i = 0; i < len; i += 4) { - encoded1 = lookup[base64.charCodeAt(i)]; - encoded2 = lookup[base64.charCodeAt(i + 1)]; - encoded3 = lookup[base64.charCodeAt(i + 2)]; - encoded4 = lookup[base64.charCodeAt(i + 3)]; - bytes[p2++] = encoded1 << 2 | encoded2 >> 4; - bytes[p2++] = (encoded2 & 15) << 4 | encoded3 >> 2; - bytes[p2++] = (encoded3 & 3) << 6 | encoded4 & 63; - } - return arraybuffer; -} -const API_TYPE_ON_PROTOCOLS = [ - { - name: "callback", - type: Function, - required: true - } -]; -function validateProtocolFail(name, msg) { - const errMsg = `${name}:fail ${msg}`; - { - console.error(errMsg); - } - return { - errMsg - }; -} -function validateProtocol(name, data, protocol) { - for (const key in protocol) { - const errMsg = validateProp(key, data[key], protocol[key], !hasOwn$1(data, key)); - if (errMsg) { - return validateProtocolFail(name, errMsg); + if (pre[name]) { + if (Array.isArray(pre[name])) { + pre[name].push(value); + } else { + pre[name] = [pre[name], value]; + } + } else { + pre[name] = value; } - } + return pre; + }, {}); } -function validateProtocols(name, args, protocol) { - if (!protocol) { - return; - } - if (isArray(protocol)) { - const len = protocol.length; - const argsLen = args.length; - for (let i = 0; i < len; i++) { - const opts = protocol[i]; - const data = Object.create(null); - if (argsLen > i) { - data[opts.name] = args[i]; +function parseHtml(html) { + html = removeDOCTYPE(html); + const stacks = []; + const results = { + node: "root", + children: [] + }; + HTMLParser(html, { + start: function(tag, attrs2, unary) { + const node = { + name: tag + }; + if (attrs2.length !== 0) { + node.attrs = parseAttrs(attrs2); } - const errMsg = validateProtocol(name, data, {[opts.name]: opts}); - if (errMsg) { - return errMsg; + if (unary) { + const parent = stacks[0] || results; + if (!parent.children) { + parent.children = []; + } + parent.children.push(node); + } else { + stacks.unshift(node); } + }, + end: function(tag) { + const node = stacks.shift(); + if (node.name !== tag) + console.error("invalid state: mismatch end tag"); + if (stacks.length === 0) { + results.children.push(node); + } else { + const parent = stacks[0]; + if (!parent.children) { + parent.children = []; + } + parent.children.push(node); + } + }, + chars: function(text2) { + const node = { + type: "text", + text: text2 + }; + if (stacks.length === 0) { + results.children.push(node); + } else { + const parent = stacks[0]; + if (!parent.children) { + parent.children = []; + } + parent.children.push(node); + } + }, + comment: function(text2) { + const node = { + node: "comment", + text: text2 + }; + const parent = stacks[0]; + if (!parent.children) { + parent.children = []; + } + parent.children.push(node); } - return; - } - return validateProtocol(name, args[0] || Object.create(null), protocol); -} -function validateProp(name, value, prop, isAbsent) { - const {type, required, validator} = prop; - if (required && isAbsent) { - return 'Missing required args: "' + name + '"'; - } - if (value == null && !prop.required) { - return; - } - if (type != null && type !== true) { - let isValid = false; - const types = isArray(type) ? type : [type]; - const expectedTypes = []; - for (let i = 0; i < types.length && !isValid; i++) { - const {valid, expectedType} = assertType(value, types[i]); - expectedTypes.push(expectedType || ""); - isValid = valid; - } - if (!isValid) { - return getInvalidTypeMessage(name, value, expectedTypes); - } - } - if (validator && !validator(value)) { - return 'Invalid args: custom validator check failed for args "' + name + '".'; - } + }); + return results.children; } -const isSimpleType = /* @__PURE__ */ makeMap$1("String,Number,Boolean,Function,Symbol"); -function assertType(value, type) { - let valid; - const expectedType = getType(type); - if (isSimpleType(expectedType)) { - const t2 = typeof value; - valid = t2 === expectedType.toLowerCase(); - if (!valid && t2 === "object") { - valid = value instanceof type; - } - } else if (expectedType === "Object") { - valid = isObject$1(value); - } else if (expectedType === "Array") { - valid = isArray(value); - } else { - { - valid = value instanceof type; - } - } - return { - valid, - expectedType - }; -} -function getInvalidTypeMessage(name, value, expectedTypes) { - let message = `Invalid args: type check failed for args "${name}". Expected ${expectedTypes.map(capitalize).join(", ")}`; - const expectedType = expectedTypes[0]; - const receivedType = toRawType(value); - const expectedValue = styleValue(value, expectedType); - const receivedValue = styleValue(value, receivedType); - if (expectedTypes.length === 1 && isExplicable(expectedType) && !isBoolean(expectedType, receivedType)) { - message += ` with value ${expectedValue}`; - } - message += `, got ${receivedType} `; - if (isExplicable(receivedType)) { - message += `with value ${receivedValue}.`; - } - return message; -} -function getType(ctor) { - const match = ctor && ctor.toString().match(/^\s*function (\w+)/); - return match ? match[1] : ""; -} -function styleValue(value, type) { - if (type === "String") { - return `"${value}"`; - } else if (type === "Number") { - return `${Number(value)}`; - } else { - return `${value}`; - } -} -function isExplicable(type) { - const explicitTypes = ["string", "number", "boolean"]; - return explicitTypes.some((elem) => type.toLowerCase() === elem); -} -function isBoolean(...args) { - return args.some((elem) => elem.toLowerCase() === "boolean"); -} -function tryCatch(fn) { - return function() { - try { - return fn.apply(fn, arguments); - } catch (e2) { - console.error(e2); +const TAGS = { + a: "", + abbr: "", + b: "", + blockquote: "", + br: "", + code: "", + col: ["span", "width"], + colgroup: ["span", "width"], + dd: "", + del: "", + div: "", + dl: "", + dt: "", + em: "", + fieldset: "", + h1: "", + h2: "", + h3: "", + h4: "", + h5: "", + h6: "", + hr: "", + i: "", + img: ["alt", "src", "height", "width"], + ins: "", + label: "", + legend: "", + li: "", + ol: ["start", "type"], + p: "", + q: "", + span: "", + strong: "", + sub: "", + sup: "", + table: ["width"], + tbody: "", + td: ["colspan", "rowspan", "height", "width"], + tfoot: "", + th: ["colspan", "rowspan", "height", "width"], + thead: "", + tr: "", + ul: "" +}; +const CHARS = { + amp: "&", + gt: ">", + lt: "<", + nbsp: " ", + quot: '"', + apos: "'" +}; +function decodeEntities(htmlString) { + return htmlString.replace(/&(([a-zA-Z]+)|(#x{0,1}[\da-zA-Z]+));/gi, function(match, stage) { + if (hasOwn$1(CHARS, stage) && CHARS[stage]) { + return CHARS[stage]; } - }; -} -let invokeCallbackId = 1; -const invokeCallbacks = {}; -function addInvokeCallback(id2, name, callback, keepAlive = false) { - invokeCallbacks[id2] = { - name, - keepAlive, - callback - }; - return id2; -} -function invokeCallback(id2, res, extras) { - if (typeof id2 === "number") { - const opts = invokeCallbacks[id2]; - if (opts) { - if (!opts.keepAlive) { - delete invokeCallbacks[id2]; - } - return opts.callback(res, extras); + if (/^#[0-9]{1,4}$/.test(stage)) { + return String.fromCharCode(stage.slice(1)); } - } - return res; -} -function findInvokeCallbackByName(name) { - for (const key in invokeCallbacks) { - if (invokeCallbacks[key].name === name) { - return true; + if (/^#x[0-9a-f]{1,4}$/i.test(stage)) { + return String.fromCharCode("0" + stage.slice(1)); } - } - return false; + const wrap = document.createElement("div"); + wrap.innerHTML = match; + return wrap.innerText || wrap.textContent; + }); } -function removeKeepAliveApiCallback(name, callback) { - for (const key in invokeCallbacks) { - const item = invokeCallbacks[key]; - if (item.callback === callback && item.name === name) { - delete invokeCallbacks[key]; +function parseNodes(nodes, parentNode) { + nodes.forEach(function(node) { + if (!isPlainObject(node)) { + return; } - } -} -function offKeepAliveApiCallback(name) { - UniServiceJSBridge.off("api." + name); -} -function onKeepAliveApiCallback(name) { - UniServiceJSBridge.on("api." + name, (res) => { - for (const key in invokeCallbacks) { - const opts = invokeCallbacks[key]; - if (opts.name === name) { - opts.callback(res); + if (!hasOwn$1(node, "type") || node.type === "node") { + if (!(typeof node.name === "string" && node.name)) { + return; + } + const tagName = node.name.toLowerCase(); + if (!hasOwn$1(TAGS, tagName)) { + return; + } + const elem = document.createElement(tagName); + if (!elem) { + return; + } + const attrs2 = node.attrs; + if (isPlainObject(attrs2)) { + const tagAttrs = TAGS[tagName] || []; + Object.keys(attrs2).forEach(function(name) { + let value = attrs2[name]; + switch (name) { + case "class": + Array.isArray(value) && (value = value.join(" ")); + case "style": + elem.setAttribute(name, value); + break; + default: + if (tagAttrs.indexOf(name) !== -1) { + elem.setAttribute(name, value); + } + } + }); + } + const children = node.children; + if (Array.isArray(children) && children.length) { + parseNodes(node.children, elem); + } + parentNode.appendChild(elem); + } else { + if (node.type === "text" && typeof node.text === "string" && node.text !== "") { + parentNode.appendChild(document.createTextNode(decodeEntities(node.text))); } } }); + return parentNode; } -function createKeepAliveApiCallback(name, callback) { - return addInvokeCallback(invokeCallbackId++, name, callback, true); -} -const API_SUCCESS = "success"; -const API_FAIL = "fail"; -const API_COMPLETE = "complete"; -function getApiCallbacks(args) { - const apiCallbacks = {}; - for (const name in args) { - const fn = args[name]; - if (isFunction(fn)) { - apiCallbacks[name] = tryCatch(fn); - delete args[name]; +const _sfc_main$9 = { + name: "RichText", + props: { + nodes: { + type: [Array, String], + default: function() { + return []; + } + } + }, + watch: { + nodes(value) { + this._renderNodes(value); + } + }, + mounted() { + this._renderNodes(this.nodes); + }, + methods: { + _renderNodes(nodes) { + if (typeof nodes === "string") { + nodes = parseHtml(nodes); + } + const nodeList = parseNodes(nodes, document.createDocumentFragment()); + this.$el.firstChild.innerHTML = ""; + this.$el.firstChild.appendChild(nodeList); } } - return apiCallbacks; +}; +const _hoisted_1$7 = /* @__PURE__ */ createVNode("div", null, null, -1); +function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) { + return openBlock(), createBlock("uni-rich-text", _ctx.$attrs, [ + _hoisted_1$7 + ], 16); } -function normalizeErrMsg(errMsg, name) { - if (!errMsg || errMsg.indexOf(":fail") === -1) { - return name + ":ok"; - } - return name + errMsg.substring(errMsg.indexOf(":fail")); +_sfc_main$9.render = _sfc_render$9; +function Friction(e2) { + this._drag = e2; + this._dragLog = Math.log(e2); + this._x = 0; + this._v = 0; + this._startTime = 0; } -function createAsyncApiCallback(name, args = {}, {beforeAll, beforeSuccess} = {}) { - if (!isPlainObject(args)) { - args = {}; +Friction.prototype.set = function(e2, t2) { + this._x = e2; + this._v = t2; + this._startTime = new Date().getTime(); +}; +Friction.prototype.setVelocityByEnd = function(e2) { + this._v = (e2 - this._x) * this._dragLog / (Math.pow(this._drag, 100) - 1); +}; +Friction.prototype.x = function(e2) { + if (e2 === void 0) { + e2 = (new Date().getTime() - this._startTime) / 1e3; } - const {success, fail, complete} = getApiCallbacks(args); - const hasSuccess = isFunction(success); - const hasFail = isFunction(fail); - const hasComplete = isFunction(complete); - const callbackId = invokeCallbackId++; - addInvokeCallback(callbackId, name, (res) => { - res = res || {}; - res.errMsg = normalizeErrMsg(res.errMsg, name); - isFunction(beforeAll) && beforeAll(res); - if (res.errMsg === name + ":ok") { - isFunction(beforeSuccess) && beforeSuccess(res); - hasSuccess && success(res); - } else { - hasFail && fail(res); + var t2; + t2 = e2 === this._dt && this._powDragDt ? this._powDragDt : this._powDragDt = Math.pow(this._drag, e2); + this._dt = e2; + return this._x + this._v * t2 / this._dragLog - this._v / this._dragLog; +}; +Friction.prototype.dx = function(e2) { + if (e2 === void 0) { + e2 = (new Date().getTime() - this._startTime) / 1e3; + } + var t2; + t2 = e2 === this._dt && this._powDragDt ? this._powDragDt : this._powDragDt = Math.pow(this._drag, e2); + this._dt = e2; + return this._v * t2; +}; +Friction.prototype.done = function() { + return Math.abs(this.dx()) < 3; +}; +Friction.prototype.reconfigure = function(e2) { + var t2 = this.x(); + var n = this.dx(); + this._drag = e2; + this._dragLog = Math.log(e2); + this.set(t2, n); +}; +Friction.prototype.configuration = function() { + var e2 = this; + return [ + { + label: "Friction", + read: function() { + return e2._drag; + }, + write: function(t2) { + e2.reconfigure(t2); + }, + min: 1e-3, + max: 0.1, + step: 1e-3 } - hasComplete && complete(res); - }); - return callbackId; + ]; +}; +function o(e2, t2, n) { + return e2 > t2 - n && e2 < t2 + n; } -const callbacks = [API_SUCCESS, API_FAIL, API_COMPLETE]; -function hasCallback(args) { - if (isPlainObject(args) && callbacks.find((cb) => isFunction(args[cb]))) { - return true; - } - return false; +function a(e2, t2) { + return o(e2, 0, t2); } -function handlePromise(promise) { - if (__UNI_FEATURE_PROMISE__) { - return promise.then((data) => { - return [null, data]; - }).catch((err) => [err]); - } - return promise; +function Spring(e2, t2, n) { + this._m = e2; + this._k = t2; + this._c = n; + this._solution = null; + this._endPosition = 0; + this._startTime = 0; } -function promisify(fn) { - return (args = {}) => { - if (hasCallback(args)) { - return fn(args); +Spring.prototype._solve = function(e2, t2) { + var n = this._c; + var i2 = this._m; + var r = this._k; + var o2 = n * n - 4 * i2 * r; + if (o2 === 0) { + const a3 = -n / (2 * i2); + const s2 = e2; + const l2 = t2 / (a3 * e2); + return { + x: function(e3) { + return (s2 + l2 * e3) * Math.pow(Math.E, a3 * e3); + }, + dx: function(e3) { + var t3 = Math.pow(Math.E, a3 * e3); + return a3 * (s2 + l2 * e3) * t3 + l2 * t3; + } + }; + } + if (o2 > 0) { + const c = (-n - Math.sqrt(o2)) / (2 * i2); + const u = (-n + Math.sqrt(o2)) / (2 * i2); + const l2 = (t2 - c * e2) / (u - c); + const s2 = e2 - l2; + return { + x: function(e3) { + let t3; + let n2; + if (e3 === this._t) { + t3 = this._powER1T; + n2 = this._powER2T; + } + this._t = e3; + if (!t3) { + t3 = this._powER1T = Math.pow(Math.E, c * e3); + } + if (!n2) { + n2 = this._powER2T = Math.pow(Math.E, u * e3); + } + return s2 * t3 + l2 * n2; + }, + dx: function(e3) { + let t3; + let n2; + if (e3 === this._t) { + t3 = this._powER1T; + n2 = this._powER2T; + } + this._t = e3; + if (!t3) { + t3 = this._powER1T = Math.pow(Math.E, c * e3); + } + if (!n2) { + n2 = this._powER2T = Math.pow(Math.E, u * e3); + } + return s2 * c * t3 + l2 * u * n2; + } + }; + } + var d = Math.sqrt(4 * i2 * r - n * n) / (2 * i2); + var a2 = -n / 2 * i2; + var s = e2; + var l = (t2 - a2 * e2) / d; + return { + x: function(e3) { + return Math.pow(Math.E, a2 * e3) * (s * Math.cos(d * e3) + l * Math.sin(d * e3)); + }, + dx: function(e3) { + var t3 = Math.pow(Math.E, a2 * e3); + var n2 = Math.cos(d * e3); + var i3 = Math.sin(d * e3); + return t3 * (l * d * n2 - s * d * i3) + a2 * t3 * (l * i3 + s * n2); } - return handlePromise(new Promise((resolve, reject) => { - fn(Object.assign(args, {success: resolve, fail: reject})); - })); }; -} -function formatApiArgs(args, options) { - const params = args[0]; - if (!options || !isPlainObject(options.formatArgs) && isPlainObject(params)) { - return args; +}; +Spring.prototype.x = function(e2) { + if (e2 === void 0) { + e2 = (new Date().getTime() - this._startTime) / 1e3; } - const formatArgs = options.formatArgs; - Object.keys(formatArgs).forEach((name) => { - formatArgs[name](args[0][name], params); - }); - return args; -} -function wrapperOnApi(name, fn) { - return (callback) => { - const isFirstInvokeOnApi = !findInvokeCallbackByName(name); - createKeepAliveApiCallback(name, callback); - if (isFirstInvokeOnApi) { - onKeepAliveApiCallback(name); - fn(); + return this._solution ? this._endPosition + this._solution.x(e2) : 0; +}; +Spring.prototype.dx = function(e2) { + if (e2 === void 0) { + e2 = (new Date().getTime() - this._startTime) / 1e3; + } + return this._solution ? this._solution.dx(e2) : 0; +}; +Spring.prototype.setEnd = function(e2, t2, n) { + if (!n) { + n = new Date().getTime(); + } + if (e2 !== this._endPosition || !a(t2, 0.4)) { + t2 = t2 || 0; + var i2 = this._endPosition; + if (this._solution) { + if (a(t2, 0.4)) { + t2 = this._solution.dx((n - this._startTime) / 1e3); + } + i2 = this._solution.x((n - this._startTime) / 1e3); + if (a(t2, 0.4)) { + t2 = 0; + } + if (a(i2, 0.4)) { + i2 = 0; + } + i2 += this._endPosition; } - }; -} -function wrapperOffApi(name, fn) { - return (callback) => { - name = name.replace("off", "on"); - removeKeepAliveApiCallback(name, callback); - const hasInvokeOnApi = findInvokeCallbackByName(name); - if (!hasInvokeOnApi) { - offKeepAliveApiCallback(name); - fn(); + if (!(this._solution && a(i2 - e2, 0.4) && a(t2, 0.4))) { + this._endPosition = e2; + this._solution = this._solve(i2 - this._endPosition, t2); + this._startTime = n; + } + } +}; +Spring.prototype.snap = function(e2) { + this._startTime = new Date().getTime(); + this._endPosition = e2; + this._solution = { + x: function() { + return 0; + }, + dx: function() { + return 0; } }; -} -function invokeSuccess(id2, name, res) { - return invokeCallback(id2, extend(res || {}, {errMsg: name + ":ok"})); -} -function invokeFail(id2, name, err) { - return invokeCallback(id2, {errMsg: name + ":fail" + (err ? " " + err : "")}); -} -function wrapperTaskApi(name, fn, options) { - return (args) => { - const id2 = createAsyncApiCallback(name, args, options); - return fn(args, { - resolve: (res) => invokeSuccess(id2, name, res), - reject: (err) => invokeFail(id2, name, err) - }); - }; -} -function wrapperSyncApi(fn) { - return (...args) => fn.apply(null, args); -} -function wrapperAsyncApi(name, fn, options) { - return wrapperTaskApi(name, fn, options); -} -function wrapperApi(fn, name, protocol, options) { - return function(...args) { - if (process.env.NODE_ENV !== "production") { - const errMsg = validateProtocols(name, args, protocol); - if (errMsg) { - return errMsg; - } - } - return fn.apply(null, formatApiArgs(args, options)); - }; -} -function defineOnApi(name, fn, options) { - return wrapperApi(wrapperOnApi(name, fn), name, process.env.NODE_ENV !== "production" ? API_TYPE_ON_PROTOCOLS : void 0, options); -} -function defineOffApi(name, fn, options) { - return wrapperApi(wrapperOffApi(name, fn), name, process.env.NODE_ENV !== "production" ? API_TYPE_ON_PROTOCOLS : void 0, options); -} -function defineTaskApi(name, fn, protocol, options) { - return promisify(wrapperApi(wrapperTaskApi(name, fn), name, process.env.NODE_ENV !== "production" ? protocol : void 0, options)); -} -function defineSyncApi(name, fn, protocol, options) { - return wrapperApi(wrapperSyncApi(fn), name, process.env.NODE_ENV !== "production" ? protocol : void 0, options); -} -function defineAsyncApi(name, fn, protocol, options) { - return promisify(wrapperApi(wrapperAsyncApi(name, fn, options), name, process.env.NODE_ENV !== "production" ? protocol : void 0, options)); -} -const API_BASE64_TO_ARRAY_BUFFER = "base64ToArrayBuffer"; -const API_ARRAY_BUFFER_TO_BASE64 = "arrayBufferToBase64"; -const Base64ToArrayBufferProtocol = [ - { - name: "base64", - type: String, - required: true +}; +Spring.prototype.done = function(e2) { + if (!e2) { + e2 = new Date().getTime(); } -]; -const ArrayBufferToBase64Protocol = [ - { - name: "arrayBuffer", - type: [ArrayBuffer, Uint8Array], - required: true + return o(this.x(), this._endPosition, 0.4) && a(this.dx(), 0.4); +}; +Spring.prototype.reconfigure = function(e2, t2, n) { + this._m = e2; + this._k = t2; + this._c = n; + if (!this.done()) { + this._solution = this._solve(this.x() - this._endPosition, this.dx()); + this._startTime = new Date().getTime(); } -]; -const base64ToArrayBuffer = defineSyncApi(API_BASE64_TO_ARRAY_BUFFER, (base64) => { - return decode(base64); -}, Base64ToArrayBufferProtocol); -const arrayBufferToBase64 = defineSyncApi(API_ARRAY_BUFFER_TO_BASE64, (arrayBuffer) => { - return encode$1(arrayBuffer); -}, ArrayBufferToBase64Protocol); -const API_UPX2PX = "upx2px"; -const Upx2pxProtocol = [ - { - name: "upx", - type: [Number, String], - required: true +}; +Spring.prototype.springConstant = function() { + return this._k; +}; +Spring.prototype.damping = function() { + return this._c; +}; +Spring.prototype.configuration = function() { + function e2(e3, t3) { + e3.reconfigure(1, t3, e3.damping()); } -]; -const EPS = 1e-4; -const BASE_DEVICE_WIDTH = 750; -let isIOS = false; -let deviceWidth = 0; -let deviceDPR = 0; -function checkDeviceWidth() { - const {platform, pixelRatio: pixelRatio2, windowWidth} = getBaseSystemInfo(); - deviceWidth = windowWidth; - deviceDPR = pixelRatio2; - isIOS = platform === "ios"; + function t2(e3, t3) { + e3.reconfigure(1, e3.springConstant(), t3); + } + return [ + { + label: "Spring Constant", + read: this.springConstant.bind(this), + write: e2.bind(this, this), + min: 100, + max: 1e3 + }, + { + label: "Damping", + read: this.damping.bind(this), + write: t2.bind(this, this), + min: 1, + max: 500 + } + ]; +}; +function Scroll(extent, friction, spring) { + this._extent = extent; + this._friction = friction || new Friction(0.01); + this._spring = spring || new Spring(1, 90, 20); + this._startTime = 0; + this._springing = false; + this._springOffset = 0; } -const upx2px = defineSyncApi(API_UPX2PX, (number, newDeviceWidth) => { - if (deviceWidth === 0) { - checkDeviceWidth(); +Scroll.prototype.snap = function(e2, t2) { + this._springOffset = 0; + this._springing = true; + this._spring.snap(e2); + this._spring.setEnd(t2); +}; +Scroll.prototype.set = function(e2, t2) { + this._friction.set(e2, t2); + if (e2 > 0 && t2 >= 0) { + this._springOffset = 0; + this._springing = true; + this._spring.snap(e2); + this._spring.setEnd(0); + } else { + if (e2 < -this._extent && t2 <= 0) { + this._springOffset = 0; + this._springing = true; + this._spring.snap(e2); + this._spring.setEnd(-this._extent); + } else { + this._springing = false; + } } - number = Number(number); - if (number === 0) { + this._startTime = new Date().getTime(); +}; +Scroll.prototype.x = function(e2) { + if (!this._startTime) { return 0; } - let result = number / BASE_DEVICE_WIDTH * (newDeviceWidth || deviceWidth); - if (result < 0) { - result = -result; + if (!e2) { + e2 = (new Date().getTime() - this._startTime) / 1e3; } - result = Math.floor(result + EPS); - if (result === 0) { - if (deviceDPR === 1 || !isIOS) { - result = 1; + if (this._springing) { + return this._spring.x() + this._springOffset; + } + var t2 = this._friction.x(e2); + var n = this.dx(e2); + if (t2 > 0 && n >= 0 || t2 < -this._extent && n <= 0) { + this._springing = true; + this._spring.setEnd(0, n); + if (t2 < -this._extent) { + this._springOffset = -this._extent; } else { - result = 0.5; + this._springOffset = 0; } + t2 = this._spring.x() + this._springOffset; } - return number < 0 ? -result : result; -}, Upx2pxProtocol); -var HOOKS; -(function(HOOKS2) { - HOOKS2["INVOKE"] = "invoke"; - HOOKS2["SUCCESS"] = "success"; - HOOKS2["FAIL"] = "fail"; - HOOKS2["COMPLETE"] = "complete"; - HOOKS2["RETURN_VALUE"] = "returnValue"; -})(HOOKS || (HOOKS = {})); -const globalInterceptors = {}; -const scopedInterceptors = {}; -const API_ADD_INTERCEPTOR = "addInterceptor"; -const API_REMOVE_INTERCEPTOR = "removeInterceptor"; -const AddInterceptorProtocol = [ - { - name: "method", - type: [String, Object], - required: true - } -]; -const RemoveInterceptorProtocol = AddInterceptorProtocol; -function mergeInterceptorHook(interceptors, interceptor) { - Object.keys(interceptor).forEach((hook) => { - if (isFunction(interceptor[hook])) { - interceptors[hook] = mergeHook(interceptors[hook], interceptor[hook]); + return t2; +}; +Scroll.prototype.dx = function(e2) { + var t2 = 0; + t2 = this._lastTime === e2 ? this._lastDx : this._springing ? this._spring.dx(e2) : this._friction.dx(e2); + this._lastTime = e2; + this._lastDx = t2; + return t2; +}; +Scroll.prototype.done = function() { + return this._springing ? this._spring.done() : this._friction.done(); +}; +Scroll.prototype.setVelocityByEnd = function(e2) { + this._friction.setVelocityByEnd(e2); +}; +Scroll.prototype.configuration = function() { + var e2 = this._friction.configuration(); + e2.push.apply(e2, this._spring.configuration()); + return e2; +}; +function i(scroll, t2, n) { + function i2(t3, scroll2, r2, o3) { + if (!t3 || !t3.cancelled) { + r2(scroll2); + var a2 = scroll2.done(); + if (!a2) { + if (!t3.cancelled) { + t3.id = requestAnimationFrame(i2.bind(null, t3, scroll2, r2, o3)); + } + } + if (a2 && o3) { + o3(scroll2); + } } - }); -} -function removeInterceptorHook(interceptors, interceptor) { - if (!interceptors || !interceptor) { - return; } - Object.keys(interceptor).forEach((hook) => { - if (isFunction(interceptor[hook])) { - removeHook(interceptors[hook], interceptor[hook]); + function r(scroll2) { + if (scroll2 && scroll2.id) { + cancelAnimationFrame(scroll2.id); } - }); + if (scroll2) { + scroll2.cancelled = true; + } + } + var o2 = { + id: 0, + cancelled: false + }; + i2(o2, scroll, t2, n); + return { + cancel: r.bind(null, o2), + model: scroll + }; } -function mergeHook(parentVal, childVal) { - const res = childVal ? parentVal ? parentVal.concat(childVal) : isArray(childVal) ? childVal : [childVal] : parentVal; - return res ? dedupeHooks(res) : res; +function Scroller(element, options) { + options = options || {}; + this._element = element; + this._options = options; + this._enableSnap = options.enableSnap || false; + this._itemSize = options.itemSize || 0; + this._enableX = options.enableX || false; + this._enableY = options.enableY || false; + this._shouldDispatchScrollEvent = !!options.onScroll; + if (this._enableX) { + this._extent = (options.scrollWidth || this._element.offsetWidth) - this._element.parentElement.offsetWidth; + this._scrollWidth = options.scrollWidth; + } else { + this._extent = (options.scrollHeight || this._element.offsetHeight) - this._element.parentElement.offsetHeight; + this._scrollHeight = options.scrollHeight; + } + this._position = 0; + this._scroll = new Scroll(this._extent, options.friction, options.spring); + this._onTransitionEnd = this.onTransitionEnd.bind(this); + this.updatePosition(); +} +Scroller.prototype.onTouchStart = function() { + this._startPosition = this._position; + this._lastChangePos = this._startPosition; + if (this._startPosition > 0) { + this._startPosition /= 0.5; + } else { + if (this._startPosition < -this._extent) { + this._startPosition = (this._startPosition + this._extent) / 0.5 - this._extent; + } + } + if (this._animation) { + this._animation.cancel(); + this._scrolling = false; + } + this.updatePosition(); +}; +Scroller.prototype.onTouchMove = function(x, y) { + var startPosition = this._startPosition; + if (this._enableX) { + startPosition += x; + } else if (this._enableY) { + startPosition += y; + } + if (startPosition > 0) { + startPosition *= 0.5; + } else if (startPosition < -this._extent) { + startPosition = 0.5 * (startPosition + this._extent) - this._extent; + } + this._position = startPosition; + this.updatePosition(); + this.dispatchScroll(); +}; +Scroller.prototype.onTouchEnd = function(e2, r, o2) { + if (this._enableSnap && this._position > -this._extent && this._position < 0) { + if (this._enableY && (Math.abs(r) < this._itemSize && Math.abs(o2.y) < 300 || Math.abs(o2.y) < 150)) { + this.snap(); + return; + } + if (this._enableX && (Math.abs(e2) < this._itemSize && Math.abs(o2.x) < 300 || Math.abs(o2.x) < 150)) { + this.snap(); + return; + } + } + if (this._enableX) { + this._scroll.set(this._position, o2.x); + } else if (this._enableY) { + this._scroll.set(this._position, o2.y); + } + if (this._enableSnap) { + var s = this._scroll._friction.x(100); + var l = s % this._itemSize; + var c = Math.abs(l) > this._itemSize / 2 ? s - (this._itemSize - Math.abs(l)) : s - l; + if (c <= 0 && c >= -this._extent) { + this._scroll.setVelocityByEnd(c); + } + } + this._lastTime = Date.now(); + this._lastDelay = 0; + this._scrolling = true; + this._lastChangePos = this._position; + this._lastIdx = Math.floor(Math.abs(this._position / this._itemSize)); + this._animation = i(this._scroll, () => { + var e3 = Date.now(); + var i2 = (e3 - this._scroll._startTime) / 1e3; + var r2 = this._scroll.x(i2); + this._position = r2; + this.updatePosition(); + var o3 = this._scroll.dx(i2); + if (this._shouldDispatchScrollEvent && e3 - this._lastTime > this._lastDelay) { + this.dispatchScroll(); + this._lastDelay = Math.abs(2e3 / o3); + this._lastTime = e3; + } + }, () => { + if (this._enableSnap) { + if (c <= 0 && c >= -this._extent) { + this._position = c; + this.updatePosition(); + } + if (typeof this._options.onSnap === "function") { + this._options.onSnap(Math.floor(Math.abs(this._position) / this._itemSize)); + } + } + if (this._shouldDispatchScrollEvent) { + this.dispatchScroll(); + } + this._scrolling = false; + }); +}; +Scroller.prototype.onTransitionEnd = function() { + this._element.style.transition = ""; + this._element.style.webkitTransition = ""; + this._element.removeEventListener("transitionend", this._onTransitionEnd); + this._element.removeEventListener("webkitTransitionEnd", this._onTransitionEnd); + if (this._snapping) { + this._snapping = false; + } + this.dispatchScroll(); +}; +Scroller.prototype.snap = function() { + var e2 = this._itemSize; + var t2 = this._position % e2; + var i2 = Math.abs(t2) > this._itemSize / 2 ? this._position - (e2 - Math.abs(t2)) : this._position - t2; + if (this._position !== i2) { + this._snapping = true; + this.scrollTo(-i2); + if (typeof this._options.onSnap === "function") { + this._options.onSnap(Math.floor(Math.abs(this._position) / this._itemSize)); + } + } +}; +Scroller.prototype.scrollTo = function(e2, t2) { + if (this._animation) { + this._animation.cancel(); + this._scrolling = false; + } + if (typeof e2 === "number") { + this._position = -e2; + } + if (this._position < -this._extent) { + this._position = -this._extent; + } else { + if (this._position > 0) { + this._position = 0; + } + } + this._element.style.transition = "transform " + (t2 || 0.2) + "s ease-out"; + this._element.style.webkitTransition = "-webkit-transform " + (t2 || 0.2) + "s ease-out"; + this.updatePosition(); + this._element.addEventListener("transitionend", this._onTransitionEnd); + this._element.addEventListener("webkitTransitionEnd", this._onTransitionEnd); +}; +Scroller.prototype.dispatchScroll = function() { + if (typeof this._options.onScroll === "function" && Math.round(this._lastPos) !== Math.round(this._position)) { + this._lastPos = this._position; + var e2 = { + target: { + scrollLeft: this._enableX ? -this._position : 0, + scrollTop: this._enableY ? -this._position : 0, + scrollHeight: this._scrollHeight || this._element.offsetHeight, + scrollWidth: this._scrollWidth || this._element.offsetWidth, + offsetHeight: this._element.parentElement.offsetHeight, + offsetWidth: this._element.parentElement.offsetWidth + } + }; + this._options.onScroll(e2); + } +}; +Scroller.prototype.update = function(e2, t2, n) { + var i2 = 0; + var r = this._position; + if (this._enableX) { + i2 = this._element.childNodes.length ? (t2 || this._element.offsetWidth) - this._element.parentElement.offsetWidth : 0; + this._scrollWidth = t2; + } else { + i2 = this._element.childNodes.length ? (t2 || this._element.offsetHeight) - this._element.parentElement.offsetHeight : 0; + this._scrollHeight = t2; + } + if (typeof e2 === "number") { + this._position = -e2; + } + if (this._position < -i2) { + this._position = -i2; + } else { + if (this._position > 0) { + this._position = 0; + } + } + this._itemSize = n || this._itemSize; + this.updatePosition(); + if (r !== this._position) { + this.dispatchScroll(); + if (typeof this._options.onSnap === "function") { + this._options.onSnap(Math.floor(Math.abs(this._position) / this._itemSize)); + } + } + this._extent = i2; + this._scroll._extent = i2; +}; +Scroller.prototype.updatePosition = function() { + var transform = ""; + if (this._enableX) { + transform = "translateX(" + this._position + "px) translateZ(0)"; + } else { + if (this._enableY) { + transform = "translateY(" + this._position + "px) translateZ(0)"; + } + } + this._element.style.webkitTransform = transform; + this._element.style.transform = transform; +}; +Scroller.prototype.isScrolling = function() { + return this._scrolling || this._snapping; +}; +var scroller = { + methods: { + initScroller: function(element, options) { + this._touchInfo = { + trackingID: -1, + maxDy: 0, + maxDx: 0 + }; + this._scroller = new Scroller(element, options); + this.__handleTouchStart = this._handleTouchStart.bind(this); + this.__handleTouchMove = this._handleTouchMove.bind(this); + this.__handleTouchEnd = this._handleTouchEnd.bind(this); + this._initedScroller = true; + }, + _findDelta: function(event2) { + var touchInfo = this._touchInfo; + return event2.detail.state === "move" || event2.detail.state === "end" ? { + x: event2.detail.dx, + y: event2.detail.dy + } : { + x: event2.screenX - touchInfo.x, + y: event2.screenY - touchInfo.y + }; + }, + _handleTouchStart: function(e2) { + var t2 = this._touchInfo; + var n = this._scroller; + if (n) { + if (e2.detail.state === "start") { + t2.trackingID = "touch"; + t2.x = e2.detail.x; + t2.y = e2.detail.y; + } else { + t2.trackingID = "mouse"; + t2.x = e2.screenX; + t2.y = e2.screenY; + } + t2.maxDx = 0; + t2.maxDy = 0; + t2.historyX = [0]; + t2.historyY = [0]; + t2.historyTime = [e2.detail.timeStamp]; + t2.listener = n; + if (n.onTouchStart) { + n.onTouchStart(); + } + event.preventDefault(); + } + }, + _handleTouchMove: function(event2) { + var touchInfo = this._touchInfo; + if (touchInfo.trackingID !== -1) { + event2.preventDefault(); + var delta = this._findDelta(event2); + if (delta) { + for (touchInfo.maxDy = Math.max(touchInfo.maxDy, Math.abs(delta.y)), touchInfo.maxDx = Math.max(touchInfo.maxDx, Math.abs(delta.x)), touchInfo.historyX.push(delta.x), touchInfo.historyY.push(delta.y), touchInfo.historyTime.push(event2.detail.timeStamp); touchInfo.historyTime.length > 10; ) { + touchInfo.historyTime.shift(); + touchInfo.historyX.shift(); + touchInfo.historyY.shift(); + } + if (touchInfo.listener && touchInfo.listener.onTouchMove) { + touchInfo.listener.onTouchMove(delta.x, delta.y, event2.detail.timeStamp); + } + } + } + }, + _handleTouchEnd: function(event2) { + var touchInfo = this._touchInfo; + if (touchInfo.trackingID !== -1) { + event2.preventDefault(); + var delta = this._findDelta(event2); + if (delta) { + var listener = touchInfo.listener; + touchInfo.trackingID = -1; + touchInfo.listener = null; + var r = touchInfo.historyTime.length; + var o2 = { + x: 0, + y: 0 + }; + if (r > 2) { + for (var a2 = touchInfo.historyTime.length - 1, s = touchInfo.historyTime[a2], l = touchInfo.historyX[a2], c = touchInfo.historyY[a2]; a2 > 0; ) { + a2--; + var u = touchInfo.historyTime[a2]; + var d = s - u; + if (d > 30 && d < 50) { + o2.x = (l - touchInfo.historyX[a2]) / (d / 1e3); + o2.y = (c - touchInfo.historyY[a2]) / (d / 1e3); + break; + } + } + } + touchInfo.historyTime = []; + touchInfo.historyX = []; + touchInfo.historyY = []; + if (listener && listener.onTouchEnd) { + listener.onTouchEnd(delta.x, delta.y, o2); + } + } + } + } + } +}; +const passiveOptions = passive(true); +const _sfc_main$8 = { + name: "ScrollView", + mixins: [scroller], + props: { + scrollX: { + type: [Boolean, String], + default: false + }, + scrollY: { + type: [Boolean, String], + default: false + }, + upperThreshold: { + type: [Number, String], + default: 50 + }, + lowerThreshold: { + type: [Number, String], + default: 50 + }, + scrollTop: { + type: [Number, String], + default: 0 + }, + scrollLeft: { + type: [Number, String], + default: 0 + }, + scrollIntoView: { + type: String, + default: "" + }, + scrollWithAnimation: { + type: [Boolean, String], + default: false + }, + enableBackToTop: { + type: [Boolean, String], + default: false + }, + refresherEnabled: { + type: [Boolean, String], + default: false + }, + refresherThreshold: { + type: Number, + default: 45 + }, + refresherDefaultStyle: { + type: String, + default: "back" + }, + refresherBackground: { + type: String, + default: "#fff" + }, + refresherTriggered: { + type: [Boolean, String], + default: false + } + }, + data() { + return { + lastScrollTop: this.scrollTopNumber, + lastScrollLeft: this.scrollLeftNumber, + lastScrollToUpperTime: 0, + lastScrollToLowerTime: 0, + refresherHeight: 0, + refreshRotate: 0, + refreshState: "" + }; + }, + computed: { + upperThresholdNumber() { + var val = Number(this.upperThreshold); + return isNaN(val) ? 50 : val; + }, + lowerThresholdNumber() { + var val = Number(this.lowerThreshold); + return isNaN(val) ? 50 : val; + }, + scrollTopNumber() { + return Number(this.scrollTop) || 0; + }, + scrollLeftNumber() { + return Number(this.scrollLeft) || 0; + } + }, + watch: { + scrollTopNumber(val) { + this._scrollTopChanged(val); + }, + scrollLeftNumber(val) { + this._scrollLeftChanged(val); + }, + scrollIntoView(val) { + this._scrollIntoViewChanged(val); + }, + refresherTriggered(val) { + if (val === true) { + this._setRefreshState("refreshing"); + } else if (val === false) { + this._setRefreshState("restore"); + } + } + }, + mounted() { + var self = this; + this._attached = true; + this._scrollTopChanged(this.scrollTopNumber); + this._scrollLeftChanged(this.scrollLeftNumber); + this._scrollIntoViewChanged(this.scrollIntoView); + this.__handleScroll = function(e2) { + event.preventDefault(); + event.stopPropagation(); + self._handleScroll.bind(self, event)(); + }; + var touchStart = null; + var needStop = null; + this.__handleTouchMove = function(event2) { + var x = event2.touches[0].pageX; + var y = event2.touches[0].pageY; + var main = self.$refs.main; + if (needStop === null) { + if (Math.abs(x - touchStart.x) > Math.abs(y - touchStart.y)) { + if (self.scrollX) { + if (main.scrollLeft === 0 && x > touchStart.x) { + needStop = false; + return; + } else if (main.scrollWidth === main.offsetWidth + main.scrollLeft && x < touchStart.x) { + needStop = false; + return; + } + needStop = true; + } else { + needStop = false; + } + } else { + if (self.scrollY) { + if (main.scrollTop === 0 && y > touchStart.y) { + needStop = false; + return; + } else if (main.scrollHeight === main.offsetHeight + main.scrollTop && y < touchStart.y) { + needStop = false; + return; + } + needStop = true; + } else { + needStop = false; + } + } + } + if (needStop) { + event2.stopPropagation(); + } + if (self.refresherEnabled && self.refreshState === "pulling") { + const dy = y - touchStart.y; + self.refresherHeight = dy; + let rotate = dy / self.refresherThreshold; + if (rotate > 1) { + rotate = 1; + } else { + rotate = rotate * 360; + } + self.refreshRotate = rotate; + self.$trigger("refresherpulling", event2, { + deltaY: dy + }); + } + }; + this.__handleTouchStart = function(event2) { + if (event2.touches.length === 1) { + needStop = null; + touchStart = { + x: event2.touches[0].pageX, + y: event2.touches[0].pageY + }; + if (self.refresherEnabled && self.refreshState !== "refreshing" && self.$refs.main.scrollTop === 0) { + self.refreshState = "pulling"; + } + } + }; + this.__handleTouchEnd = function(event2) { + touchStart = null; + if (self.refresherHeight >= self.refresherThreshold) { + self._setRefreshState("refreshing"); + } else { + self.refresherHeight = 0; + self.$trigger("refresherabort", event2, {}); + } + }; + this.$refs.main.addEventListener("touchstart", this.__handleTouchStart, passiveOptions); + this.$refs.main.addEventListener("touchmove", this.__handleTouchMove, passiveOptions); + this.$refs.main.addEventListener("scroll", this.__handleScroll, passive(false)); + this.$refs.main.addEventListener("touchend", this.__handleTouchEnd, passiveOptions); + }, + activated() { + this.scrollY && (this.$refs.main.scrollTop = this.lastScrollTop); + this.scrollX && (this.$refs.main.scrollLeft = this.lastScrollLeft); + }, + beforeDestroy() { + this.$refs.main.removeEventListener("touchstart", this.__handleTouchStart, passiveOptions); + this.$refs.main.removeEventListener("touchmove", this.__handleTouchMove, passiveOptions); + this.$refs.main.removeEventListener("scroll", this.__handleScroll, passive(false)); + this.$refs.main.removeEventListener("touchend", this.__handleTouchEnd, passiveOptions); + }, + methods: { + scrollTo: function(t2, n) { + var i2 = this.$refs.main; + t2 < 0 ? t2 = 0 : n === "x" && t2 > i2.scrollWidth - i2.offsetWidth ? t2 = i2.scrollWidth - i2.offsetWidth : n === "y" && t2 > i2.scrollHeight - i2.offsetHeight && (t2 = i2.scrollHeight - i2.offsetHeight); + var r = 0; + var o2 = ""; + n === "x" ? r = i2.scrollLeft - t2 : n === "y" && (r = i2.scrollTop - t2); + if (r !== 0) { + this.$refs.content.style.transition = "transform .3s ease-out"; + this.$refs.content.style.webkitTransition = "-webkit-transform .3s ease-out"; + if (n === "x") { + o2 = "translateX(" + r + "px) translateZ(0)"; + } else { + n === "y" && (o2 = "translateY(" + r + "px) translateZ(0)"); + } + this.$refs.content.removeEventListener("transitionend", this.__transitionEnd); + this.$refs.content.removeEventListener("webkitTransitionEnd", this.__transitionEnd); + this.__transitionEnd = this._transitionEnd.bind(this, t2, n); + this.$refs.content.addEventListener("transitionend", this.__transitionEnd); + this.$refs.content.addEventListener("webkitTransitionEnd", this.__transitionEnd); + if (n === "x") { + i2.style.overflowX = "hidden"; + } else if (n === "y") { + i2.style.overflowY = "hidden"; + } + this.$refs.content.style.transform = o2; + this.$refs.content.style.webkitTransform = o2; + } + }, + _handleTrack: function($event) { + if ($event.detail.state === "start") { + this._x = $event.detail.x; + this._y = $event.detail.y; + this._noBubble = null; + return; + } + if ($event.detail.state === "end") { + this._noBubble = false; + } + if (this._noBubble === null && this.scrollY) { + if (Math.abs(this._y - $event.detail.y) / Math.abs(this._x - $event.detail.x) > 1) { + this._noBubble = true; + } else { + this._noBubble = false; + } + } + if (this._noBubble === null && this.scrollX) { + if (Math.abs(this._x - $event.detail.x) / Math.abs(this._y - $event.detail.y) > 1) { + this._noBubble = true; + } else { + this._noBubble = false; + } + } + this._x = $event.detail.x; + this._y = $event.detail.y; + if (this._noBubble) { + $event.stopPropagation(); + } + }, + _handleScroll: function($event) { + if (!($event.timeStamp - this._lastScrollTime < 20)) { + this._lastScrollTime = $event.timeStamp; + const target = $event.target; + this.$trigger("scroll", $event, { + scrollLeft: target.scrollLeft, + scrollTop: target.scrollTop, + scrollHeight: target.scrollHeight, + scrollWidth: target.scrollWidth, + deltaX: this.lastScrollLeft - target.scrollLeft, + deltaY: this.lastScrollTop - target.scrollTop + }); + if (this.scrollY) { + if (target.scrollTop <= this.upperThresholdNumber && this.lastScrollTop - target.scrollTop > 0 && $event.timeStamp - this.lastScrollToUpperTime > 200) { + this.$trigger("scrolltoupper", $event, { + direction: "top" + }); + this.lastScrollToUpperTime = $event.timeStamp; + } + if (target.scrollTop + target.offsetHeight + this.lowerThresholdNumber >= target.scrollHeight && this.lastScrollTop - target.scrollTop < 0 && $event.timeStamp - this.lastScrollToLowerTime > 200) { + this.$trigger("scrolltolower", $event, { + direction: "bottom" + }); + this.lastScrollToLowerTime = $event.timeStamp; + } + } + if (this.scrollX) { + if (target.scrollLeft <= this.upperThresholdNumber && this.lastScrollLeft - target.scrollLeft > 0 && $event.timeStamp - this.lastScrollToUpperTime > 200) { + this.$trigger("scrolltoupper", $event, { + direction: "left" + }); + this.lastScrollToUpperTime = $event.timeStamp; + } + if (target.scrollLeft + target.offsetWidth + this.lowerThresholdNumber >= target.scrollWidth && this.lastScrollLeft - target.scrollLeft < 0 && $event.timeStamp - this.lastScrollToLowerTime > 200) { + this.$trigger("scrolltolower", $event, { + direction: "right" + }); + this.lastScrollToLowerTime = $event.timeStamp; + } + } + this.lastScrollTop = target.scrollTop; + this.lastScrollLeft = target.scrollLeft; + } + }, + _scrollTopChanged: function(val) { + if (this.scrollY) { + if (this._innerSetScrollTop) { + this._innerSetScrollTop = false; + } else { + if (this.scrollWithAnimation) { + this.scrollTo(val, "y"); + } else { + this.$refs.main.scrollTop = val; + } + } + } + }, + _scrollLeftChanged: function(val) { + if (this.scrollX) { + if (this._innerSetScrollLeft) { + this._innerSetScrollLeft = false; + } else { + if (this.scrollWithAnimation) { + this.scrollTo(val, "x"); + } else { + this.$refs.main.scrollLeft = val; + } + } + } + }, + _scrollIntoViewChanged: function(val) { + if (val) { + if (!/^[_a-zA-Z][-_a-zA-Z0-9:]*$/.test(val)) { + console.group('scroll-into-view="' + val + '" \u6709\u8BEF'); + console.error("id \u5C5E\u6027\u503C\u683C\u5F0F\u9519\u8BEF\u3002\u5982\u4E0D\u80FD\u4EE5\u6570\u5B57\u5F00\u5934\u3002"); + console.groupEnd(); + return; + } + var element = this.$el.querySelector("#" + val); + if (element) { + var mainRect = this.$refs.main.getBoundingClientRect(); + var elRect = element.getBoundingClientRect(); + if (this.scrollX) { + var left = elRect.left - mainRect.left; + var scrollLeft = this.$refs.main.scrollLeft; + var x = scrollLeft + left; + if (this.scrollWithAnimation) { + this.scrollTo(x, "x"); + } else { + this.$refs.main.scrollLeft = x; + } + } + if (this.scrollY) { + var top = elRect.top - mainRect.top; + var scrollTop = this.$refs.main.scrollTop; + var y = scrollTop + top; + if (this.scrollWithAnimation) { + this.scrollTo(y, "y"); + } else { + this.$refs.main.scrollTop = y; + } + } + } + } + }, + _transitionEnd: function(val, type) { + this.$refs.content.style.transition = ""; + this.$refs.content.style.webkitTransition = ""; + this.$refs.content.style.transform = ""; + this.$refs.content.style.webkitTransform = ""; + var main = this.$refs.main; + if (type === "x") { + main.style.overflowX = this.scrollX ? "auto" : "hidden"; + main.scrollLeft = val; + } else if (type === "y") { + main.style.overflowY = this.scrollY ? "auto" : "hidden"; + main.scrollTop = val; + } + this.$refs.content.removeEventListener("transitionend", this.__transitionEnd); + this.$refs.content.removeEventListener("webkitTransitionEnd", this.__transitionEnd); + }, + _setRefreshState(state) { + switch (state) { + case "refreshing": + this.refresherHeight = this.refresherThreshold; + this.$trigger("refresherrefresh", event, {}); + break; + case "restore": + this.refresherHeight = 0; + this.$trigger("refresherrestore", {}, {}); + break; + } + this.refreshState = state; + }, + getScrollPosition() { + const main = this.$refs.main; + return { + scrollLeft: main.scrollLeft, + scrollTop: main.scrollTop + }; + } + } +}; +const _hoisted_1$6 = { + ref: "wrap", + class: "uni-scroll-view" +}; +const _hoisted_2$4 = { + ref: "content", + class: "uni-scroll-view-content" +}; +const _hoisted_3$1 = { + key: 0, + class: "uni-scroll-view-refresh" +}; +const _hoisted_4$1 = {class: "uni-scroll-view-refresh-inner"}; +const _hoisted_5 = /* @__PURE__ */ createVNode("path", {d: "M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"}, null, -1); +const _hoisted_6 = /* @__PURE__ */ createVNode("path", { + d: "M0 0h24v24H0z", + fill: "none" +}, null, -1); +const _hoisted_7 = { + key: 1, + class: "uni-scroll-view-refresh__spinner", + width: "24", + height: "24", + viewBox: "25 25 50 50" +}; +const _hoisted_8 = /* @__PURE__ */ createVNode("circle", { + cx: "50", + cy: "50", + r: "20", + fill: "none", + style: {color: "#2bd009"}, + "stroke-width": "3" +}, null, -1); +function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) { + return openBlock(), createBlock("uni-scroll-view", _ctx.$attrs, [ + createVNode("div", _hoisted_1$6, [ + createVNode("div", { + ref: "main", + style: { + "overflow-x": $props.scrollX ? "auto" : "hidden", + "overflow-y": $props.scrollY ? "auto" : "hidden" + }, + class: "uni-scroll-view" + }, [ + createVNode("div", _hoisted_2$4, [ + $props.refresherEnabled ? (openBlock(), createBlock("div", { + key: 0, + ref: "refresherinner", + style: { + "background-color": $props.refresherBackground, + height: $data.refresherHeight + "px" + }, + class: "uni-scroll-view-refresher" + }, [ + $props.refresherDefaultStyle !== "none" ? (openBlock(), createBlock("div", _hoisted_3$1, [ + createVNode("div", _hoisted_4$1, [ + $data.refreshState == "pulling" ? (openBlock(), createBlock("svg", { + key: 0, + style: {transform: "rotate(" + $data.refreshRotate + "deg)"}, + fill: "#2BD009", + class: "uni-scroll-view-refresh__icon", + width: "24", + height: "24", + viewBox: "0 0 24 24" + }, [ + _hoisted_5, + _hoisted_6 + ], 4)) : createCommentVNode("", true), + $data.refreshState == "refreshing" ? (openBlock(), createBlock("svg", _hoisted_7, [ + _hoisted_8 + ])) : createCommentVNode("", true) + ]) + ])) : createCommentVNode("", true), + $props.refresherDefaultStyle == "none" ? renderSlot(_ctx.$slots, "refresher", {key: 1}) : createCommentVNode("", true) + ], 4)) : createCommentVNode("", true), + renderSlot(_ctx.$slots, "default") + ], 512) + ], 4) + ], 512) + ], 16); } -function dedupeHooks(hooks) { - const res = []; - for (let i = 0; i < hooks.length; i++) { - if (res.indexOf(hooks[i]) === -1) { - res.push(hooks[i]); +_sfc_main$8.render = _sfc_render$8; +const _sfc_main$7 = { + name: "Slider", + mixins: [emitter, listeners, touchtrack], + props: { + name: { + type: String, + default: "" + }, + min: { + type: [Number, String], + default: 0 + }, + max: { + type: [Number, String], + default: 100 + }, + value: { + type: [Number, String], + default: 0 + }, + step: { + type: [Number, String], + default: 1 + }, + disabled: { + type: [Boolean, String], + default: false + }, + color: { + type: String, + default: "#e9e9e9" + }, + backgroundColor: { + type: String, + default: "#e9e9e9" + }, + activeColor: { + type: String, + default: "#007aff" + }, + selectedColor: { + type: String, + default: "#007aff" + }, + blockColor: { + type: String, + default: "#ffffff" + }, + blockSize: { + type: [Number, String], + default: 28 + }, + showValue: { + type: [Boolean, String], + default: false } - } - return res; -} -function removeHook(hooks, hook) { - if (!hooks) { - return; - } - const index2 = hooks.indexOf(hook); - if (index2 !== -1) { - hooks.splice(index2, 1); - } -} -const addInterceptor = defineSyncApi(API_ADD_INTERCEPTOR, (method, interceptor) => { - if (typeof method === "string" && isPlainObject(interceptor)) { - mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor); - } else if (isPlainObject(method)) { - mergeInterceptorHook(globalInterceptors, method); - } -}, AddInterceptorProtocol); -const removeInterceptor = defineSyncApi(API_REMOVE_INTERCEPTOR, (method, interceptor) => { - if (typeof method === "string") { - if (isPlainObject(interceptor)) { - removeInterceptorHook(scopedInterceptors[method], interceptor); - } else { - delete scopedInterceptors[method]; + }, + data() { + return { + sliderValue: Number(this.value) + }; + }, + computed: { + setBlockStyle() { + return { + width: this.blockSize + "px", + height: this.blockSize + "px", + marginLeft: -this.blockSize / 2 + "px", + marginTop: -this.blockSize / 2 + "px", + left: this._getValueWidth(), + backgroundColor: this.blockColor + }; + }, + setBgColor() { + return { + backgroundColor: this._getBgColor() + }; + }, + setBlockBg() { + return { + left: this._getValueWidth() + }; + }, + setActiveColor() { + return { + backgroundColor: this._getActiveColor(), + width: this._getValueWidth() + }; } - } else if (isPlainObject(method)) { - removeInterceptorHook(globalInterceptors, method); - } -}, RemoveInterceptorProtocol); -const promiseInterceptor = { - returnValue(res) { - if (!isPromise(res)) { - return res; + }, + watch: { + value(val) { + this.sliderValue = Number(val); } - return res.then((res2) => { - return res2[1]; - }).catch((res2) => { - return res2[0]; + }, + mounted() { + this.touchtrack(this.$refs["uni-slider-handle"], "_onTrack"); + }, + created() { + this.$dispatch("Form", "uni-form-group-update", { + type: "add", + vm: this }); - } -}; -function getCurrentPageVm() { - const pages = getCurrentPages(); - const len = pages.length; - const page = pages[len - 1]; - return page && page.$vm; -} -const defaultOptions = { - thresholds: [0], - initialRatio: 0, - observeAll: false -}; -let reqComponentObserverId = 1; -const reqComponentObserverCallbacks = {}; -const API_CREATE_INTERSECTION_OBSERVER = "createIntersectionObserver"; -UniServiceJSBridge.subscribe("requestComponentObserver", ({reqId, reqEnd, res}) => { - const callback = reqComponentObserverCallbacks[reqId]; - if (callback) { - if (reqEnd) { - return delete reqComponentObserverCallbacks[reqId]; - } - callback(res); - } -}); -class ServiceIntersectionObserver { - constructor(component, options) { - this._pageId = component.$page.id; - this._component = component._$id || component; - this._options = extend({}, defaultOptions, options || {}); - this._relativeInfo = []; - } - relativeTo(selector, margins) { - if (this._reqId) { - throw new Error('Relative nodes cannot be added after "observe" call in IntersectionObserver'); - } - this._relativeInfo.push({ - selector, - margins + }, + beforeDestroy() { + this.$dispatch("Form", "uni-form-group-update", { + type: "remove", + vm: this }); - return this; - } - relativeToViewport(margins) { - return this.relativeTo(null, margins); - } - observe(selector, callback) { - if (typeof callback !== "function") { - return; - } - if (this._reqId) { - throw new Error('"observe" call can be only called once in IntersectionObserver'); - } - this._reqId = reqComponentObserverId++; - reqComponentObserverCallbacks[this._reqId] = callback; - UniServiceJSBridge.publishHandler("addIntersectionObserver", { - selector, - reqId: this._reqId, - component: this._component, - options: this._options, - relativeInfo: this._relativeInfo - }, this._pageId); - } - disconnect() { - UniServiceJSBridge.publishHandler("removeIntersectionObserver", { - reqId: this._reqId - }, this._pageId); - } -} -const createIntersectionObserver = defineSyncApi(API_CREATE_INTERSECTION_OBSERVER, (context, options) => { - if (!context) { - context = getCurrentPageVm(); - } - return new ServiceIntersectionObserver(context, options); -}); -const createSelectorQuery = () => { -}; -const API_CAN_I_USE = "canIUse"; -const CanIUseProtocol = [ - { - name: "schema", - type: String, - required: true - } -]; -const API_MAKE_PHONE_CALL = "makePhoneCall"; -const MakePhoneCallProtocol = { - phoneNumber: { - type: String, - required: true, - validator(phoneNumber) { - if (!phoneNumber) { - return "parameter error: parameter.phoneNumber should not be empty String;"; + }, + methods: { + _onUserChangedValue(e2) { + const slider = this.$refs["uni-slider"]; + const offsetWidth = slider.offsetWidth; + const boxLeft = slider.getBoundingClientRect().left; + const value = (e2.x - boxLeft) * (this.max - this.min) / offsetWidth + Number(this.min); + this.sliderValue = this._filterValue(value); + }, + _filterValue(e2) { + return e2 < this.min ? this.min : e2 > this.max ? this.max : Math.round((e2 - this.min) / this.step) * this.step + Number(this.min); + }, + _getValueWidth() { + return 100 * (this.sliderValue - this.min) / (this.max - this.min) + "%"; + }, + _getBgColor() { + return this.backgroundColor !== "#e9e9e9" ? this.backgroundColor : this.color !== "#007aff" ? this.color : "#007aff"; + }, + _getActiveColor() { + return this.activeColor !== "#007aff" ? this.activeColor : this.selectedColor !== "#e9e9e9" ? this.selectedColor : "#e9e9e9"; + }, + _onTrack: function(e2) { + if (!this.disabled) { + return e2.detail.state === "move" ? (this._onUserChangedValue({ + x: e2.detail.x0 + }), this.$trigger("changing", e2, { + value: this.sliderValue + }), false) : e2.detail.state === "end" && this.$trigger("change", e2, { + value: this.sliderValue + }); + } + }, + _onClick($event) { + if (this.disabled) { + return; + } + this._onUserChangedValue($event); + this.$trigger("change", $event, { + value: this.sliderValue + }); + }, + _resetFormData() { + this.sliderValue = this.min; + }, + _getFormData() { + const data = {}; + if (this.name !== "") { + data.value = this.sliderValue; + data.key = this.name; } + return data; } } }; -const API_OPEN_DOCUMENT = "openDocument"; -const OpenDocumentProtocol = { - filePath: { - type: String, - required: true +const _hoisted_1$5 = {class: "uni-slider-wrapper"}; +const _hoisted_2$3 = {class: "uni-slider-tap-area"}; +function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) { + return openBlock(), createBlock("uni-slider", mergeProps({ref: "uni-slider"}, _ctx.$attrs, { + onClick: _cache[1] || (_cache[1] = (...args) => $options._onClick && $options._onClick(...args)) + }), [ + createVNode("div", _hoisted_1$5, [ + createVNode("div", _hoisted_2$3, [ + createVNode("div", { + style: $options.setBgColor, + class: "uni-slider-handle-wrapper" + }, [ + createVNode("div", { + ref: "uni-slider-handle", + style: $options.setBlockBg, + class: "uni-slider-handle" + }, null, 4), + createVNode("div", { + style: $options.setBlockStyle, + class: "uni-slider-thumb" + }, null, 4), + createVNode("div", { + style: $options.setActiveColor, + class: "uni-slider-track" + }, null, 4) + ], 4) + ]), + withDirectives(createVNode("span", {class: "uni-slider-value"}, toDisplayString($data.sliderValue), 513), [ + [vShow, $props.showValue] + ]) + ]), + renderSlot(_ctx.$slots, "default") + ], 16); +} +_sfc_main$7.render = _sfc_render$7; +var index_vue_vue_type_style_index_0_lang$4 = "\nuni-swiper-item {\n display: block;\n overflow: hidden;\n will-change: transform;\n position: absolute;\n width: 100%;\n height: 100%;\n cursor: grab;\n}\nuni-swiper-item[hidden] {\n display: none;\n}\n"; +const _sfc_main$6 = { + name: "SwiperItem", + props: { + itemId: { + type: String, + default: "" + } }, - fileType: { - type: String - } -}; -const API_GET_IMAGE_INFO = "getImageInfo"; -const GetImageInfoOptions = { - formatArgs: { - src(src, params) { - params.src = getRealPath(src); + mounted: function() { + var $el = this.$el; + $el.style.position = "absolute"; + $el.style.width = "100%"; + $el.style.height = "100%"; + var callbacks2 = this.$vnode._callbacks; + if (callbacks2) { + callbacks2.forEach((callback) => { + callback(); + }); } } }; -const GetImageInfoProtocol = { - src: { - type: String, - required: true - } -}; -const API_REQUEST = "request"; -const METHOD = [ - "GET", - "OPTIONS", - "HEAD", - "POST", - "PUT", - "DELETE", - "TRACE", - "CONNECT" -]; -const DEFAULT_METHOD = "GET"; -const dataType = { - JSON: "json" -}; -const RESPONSE_TYPE = ["text", "arraybuffer"]; -const DEFAULT_RESPONSE_TYPE = "text"; -const encode = encodeURIComponent; -function stringifyQuery(url, data) { - let str = url.split("#"); - const hash = str[1] || ""; - str = str[0].split("?"); - let query = str[1] || ""; - url = str[0]; - const search = query.split("&").filter((item) => item); - const params = {}; - search.forEach((item) => { - const part = item.split("="); - params[part[0]] = part[1]; - }); - for (const key in data) { - if (hasOwn$1(data, key)) { - let v2 = data[key]; - if (typeof v2 === "undefined" || v2 === null) { - v2 = ""; - } else if (isPlainObject(v2)) { - v2 = JSON.stringify(v2); - } - params[encode(key)] = encode(v2); - } - } - query = Object.keys(params).map((item) => `${item}=${params[item]}`).join("&"); - return url + (query ? "?" + query : "") + (hash ? "#" + hash : ""); +function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) { + return openBlock(), createBlock("uni-swiper-item", _ctx.$attrs, [ + renderSlot(_ctx.$slots, "default") + ], 16); } -const RequestProtocol = { - method: { - type: String +_sfc_main$6.render = _sfc_render$6; +var index_vue_vue_type_style_index_0_lang$3 = '\nuni-switch {\r\n -webkit-tap-highlight-color: transparent;\r\n display: inline-block;\r\n cursor: pointer;\n}\nuni-switch[hidden] {\r\n display: none;\n}\nuni-switch[disabled] {\r\n cursor: not-allowed;\n}\nuni-switch .uni-switch-wrapper {\r\n display: -webkit-inline-flex;\r\n display: inline-flex;\r\n -webkit-align-items: center;\r\n align-items: center;\r\n vertical-align: middle;\n}\nuni-switch .uni-switch-input {\r\n -webkit-appearance: none;\r\n appearance: none;\r\n position: relative;\r\n width: 52px;\r\n height: 32px;\r\n margin-right: 5px;\r\n border: 1px solid #DFDFDF;\r\n outline: 0;\r\n border-radius: 16px;\r\n box-sizing: border-box;\r\n background-color: #DFDFDF;\r\n transition: background-color 0.1s, border 0.1s;\n}\nuni-switch[disabled] .uni-switch-input {\r\n opacity: .7;\n}\nuni-switch .uni-switch-input:before {\r\n content: " ";\r\n position: absolute;\r\n top: 0;\r\n left: 0;\r\n width: 50px;\r\n height: 30px;\r\n border-radius: 15px;\r\n background-color: #FDFDFD;\r\n transition: -webkit-transform 0.3s;\r\n transition: transform 0.3s;\r\n transition: transform 0.3s, -webkit-transform 0.3s;\n}\nuni-switch .uni-switch-input:after {\r\n content: " ";\r\n position: absolute;\r\n top: 0;\r\n left: 0;\r\n width: 30px;\r\n height: 30px;\r\n border-radius: 15px;\r\n background-color: #FFFFFF;\r\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);\r\n transition: -webkit-transform 0.3s;\r\n transition: transform 0.3s;\r\n transition: transform 0.3s, -webkit-transform 0.3s;\n}\nuni-switch .uni-switch-input.uni-switch-input-checked {\r\n border-color: #007aff;\r\n background-color: #007aff;\n}\nuni-switch .uni-switch-input.uni-switch-input-checked:before {\r\n -webkit-transform: scale(0);\r\n transform: scale(0);\n}\nuni-switch .uni-switch-input.uni-switch-input-checked:after {\r\n -webkit-transform: translateX(20px);\r\n transform: translateX(20px);\n}\nuni-switch .uni-checkbox-input {\r\n margin-right: 5px;\r\n -webkit-appearance: none;\r\n appearance: none;\r\n outline: 0;\r\n border: 1px solid #D1D1D1;\r\n background-color: #FFFFFF;\r\n border-radius: 3px;\r\n width: 22px;\r\n height: 22px;\r\n position: relative;\r\n color: #007aff;\n}\nuni-switch:not([disabled]) .uni-checkbox-input:hover {\r\n border-color: #007aff;\n}\nuni-switch .uni-checkbox-input.uni-checkbox-input-checked:before {\r\n font: normal normal normal 14px/1 "uni";\r\n content: "\\EA08";\r\n color: inherit;\r\n font-size: 22px;\r\n position: absolute;\r\n top: 50%;\r\n left: 50%;\r\n transform: translate(-50%, -48%) scale(0.73);\r\n -webkit-transform: translate(-50%, -48%) scale(0.73);\n}\nuni-switch .uni-checkbox-input.uni-checkbox-input-disabled {\r\n background-color: #E1E1E1;\n}\nuni-switch .uni-checkbox-input.uni-checkbox-input-disabled:before {\r\n color: #ADADAD;\n}\r\n'; +const _sfc_main$5 = { + name: "Switch", + mixins: [emitter, listeners], + props: { + name: { + type: String, + default: "" + }, + checked: { + type: [Boolean, String], + default: false + }, + type: { + type: String, + default: "switch" + }, + id: { + type: String, + default: "" + }, + disabled: { + type: [Boolean, String], + default: false + }, + color: { + type: String, + default: "#007aff" + } }, - data: { - type: [Object, String, Array, ArrayBuffer] + data() { + return { + switchChecked: this.checked + }; }, - url: { - type: String, - required: true + watch: { + checked(val) { + this.switchChecked = val; + } }, - header: { - type: Object + created() { + this.$dispatch("Form", "uni-form-group-update", { + type: "add", + vm: this + }); }, - dataType: { - type: String + beforeDestroy() { + this.$dispatch("Form", "uni-form-group-update", { + type: "remove", + vm: this + }); }, - responseType: { - type: String + listeners: { + "label-click": "_onClick", + "@label-click": "_onClick" }, - withCredentials: { - type: Boolean - } -}; -const RequestOptions = { - formatArgs: { - method(value, params) { - params.method = (value || "").toUpperCase(); - if (METHOD.indexOf(params.method) === -1) { - params.method = DEFAULT_METHOD; - } - }, - data(value, params) { - params.data = value || ""; - }, - url(value, params) { - if (params.method === DEFAULT_METHOD && isPlainObject(params.data) && Object.keys(params.data).length) { - params.url = stringifyQuery(value, params.data); - } - }, - header(value, params) { - const header = params.header = value || {}; - if (params.method !== DEFAULT_METHOD) { - if (!Object.keys(header).find((key) => key.toLowerCase() === "content-type")) { - header["Content-Type"] = "application/json"; - } + methods: { + _onClick($event) { + if (this.disabled) { + return; } + this.switchChecked = !this.switchChecked; + this.$trigger("change", $event, { + value: this.switchChecked + }); }, - dataType(value, params) { - params.dataType = (value || dataType.JSON).toLowerCase(); + _resetFormData() { + this.switchChecked = false; }, - responseType(value, params) { - params.responseType = (value || "").toLowerCase(); - if (RESPONSE_TYPE.indexOf(params.responseType) === -1) { - params.responseType = DEFAULT_RESPONSE_TYPE; + _getFormData() { + const data = {}; + if (this.name !== "") { + data.value = this.switchChecked; + data.key = this.name; } + return data; } } }; -function encodeQueryString(url) { - if (typeof url !== "string") { - return url; - } - const index2 = url.indexOf("?"); - if (index2 === -1) { - return url; - } - const query = url.substr(index2 + 1).trim().replace(/^(\?|#|&)/, ""); - if (!query) { - return url; - } - url = url.substr(0, index2); - const params = []; - query.split("&").forEach((param) => { - const parts = param.replace(/\+/g, " ").split("="); - const key = parts.shift(); - const val = parts.length > 0 ? parts.join("=") : ""; - params.push(key + "=" + encodeURIComponent(val)); - }); - return params.length ? url + "?" + params.join("&") : url; +const _hoisted_1$4 = {class: "uni-switch-wrapper"}; +function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) { + return openBlock(), createBlock("uni-switch", mergeProps({disabled: $props.disabled}, _ctx.$attrs, { + onClick: _cache[1] || (_cache[1] = (...args) => $options._onClick && $options._onClick(...args)) + }), [ + createVNode("div", _hoisted_1$4, [ + withDirectives(createVNode("div", { + class: [[$data.switchChecked ? "uni-switch-input-checked" : ""], "uni-switch-input"], + style: {backgroundColor: $data.switchChecked ? $props.color : "#DFDFDF", borderColor: $data.switchChecked ? $props.color : "#DFDFDF"} + }, null, 6), [ + [vShow, $props.type === "switch"] + ]), + withDirectives(createVNode("div", { + class: [[$data.switchChecked ? "uni-checkbox-input-checked" : ""], "uni-checkbox-input"], + style: {color: $props.color} + }, null, 6), [ + [vShow, $props.type === "checkbox"] + ]) + ]) + ], 16, ["disabled"]); } -const ANIMATION_IN = [ - "slide-in-right", - "slide-in-left", - "slide-in-top", - "slide-in-bottom", - "fade-in", - "zoom-out", - "zoom-fade-out", - "pop-in", - "none" -]; -const ANIMATION_OUT = [ - "slide-out-right", - "slide-out-left", - "slide-out-top", - "slide-out-bottom", - "fade-out", - "zoom-in", - "zoom-fade-in", - "pop-out", - "none" -]; -const BaseRouteProtocol = { - url: { - type: String, - required: true - } +_sfc_main$5.render = _sfc_render$5; +const SPACE_UNICODE = { + ensp: "\u2002", + emsp: "\u2003", + nbsp: "\xA0" }; -const API_NAVIGATE_TO = "navigateTo"; -const API_REDIRECT_TO = "redirectTo"; -const API_RE_LAUNCH = "reLaunch"; -const API_SWITCH_TAB = "switchTab"; -const API_NAVIGATE_BACK = "navigateBack"; -const API_PRELOAD_PAGE = "preloadPage"; -const API_UN_PRELOAD_PAGE = "unPreloadPage"; -const NavigateToProtocol = extend({}, BaseRouteProtocol, createAnimationProtocol(ANIMATION_IN)); -const NavigateBackProtocol = extend({ - delta: { - type: Number +function normalizeText(text2, { + space, + decode: decode2 +}) { + if (space && SPACE_UNICODE[space]) { + text2 = text2.replace(/ /g, SPACE_UNICODE[space]); } -}, createAnimationProtocol(ANIMATION_OUT)); -const RedirectToProtocol = BaseRouteProtocol; -const ReLaunchProtocol = BaseRouteProtocol; -const SwitchTabProtocol = BaseRouteProtocol; -const NavigateToOptions = /* @__PURE__ */ createRouteOptions(API_NAVIGATE_TO); -const RedirectToOptions = /* @__PURE__ */ createRouteOptions(API_REDIRECT_TO); -const ReLaunchOptions = /* @__PURE__ */ createRouteOptions(API_RE_LAUNCH); -const SwitchTabOptions = /* @__PURE__ */ createRouteOptions(API_SWITCH_TAB); -const NavigateBackOptions = { - formatArgs: { - delta(delta, params) { - delta = parseInt(delta) || 1; - params.delta = Math.min(getCurrentPages().length - 1, delta); + if (!decode2) { + return 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$1 = defineComponent({ + name: "Text", + props: { + selectable: { + type: [Boolean, String], + default: false + }, + space: { + type: String, + default: "" + }, + decode: { + type: [Boolean, String], + default: false } + }, + setup(props, { + slots + }) { + return () => { + const children = []; + if (slots.default) { + slots.default().forEach((vnode) => { + if (vnode.shapeFlag & 8) { + const lines = vnode.children.replace(/\\n/g, "\n").split("\n"); + const len = lines.length - 1; + lines.forEach((text2, index2) => { + children.push(createTextVNode(normalizeText(text2, { + space: props.space, + decode: props.decode + }))); + if (index2 !== len) { + children.push(createVNode("br")); + } + }); + } else { + if (process.env.NODE_ENV !== "production" && vnode.shapeFlag & 6 && vnode.type.name !== "Text") { + console.warn("Do not nest other components in the text component, as there may be display differences on different platforms."); + } + children.push(vnode); + } + }); + } + return createVNode("uni-text", { + selectable: props.selectable + }, [createVNode("span", null, [children])], 8, ["selectable"]); + }; } -}; -function createAnimationProtocol(animationTypes) { - return { - animationType: { +}); +var index_vue_vue_type_style_index_0_lang$2 = "\nuni-textarea {\n width: 300px;\n height: 150px;\n display: block;\n position: relative;\n font-size: 16px;\n line-height: normal;\n white-space: pre-wrap;\n word-break: break-all;\n}\nuni-textarea[hidden] {\n display: none;\n}\n.uni-textarea-wrapper,\n.uni-textarea-placeholder,\n.uni-textarea-line,\n.uni-textarea-compute,\n.uni-textarea-textarea {\n outline: none;\n border: none;\n padding: 0;\n margin: 0;\n text-decoration: inherit;\n}\n.uni-textarea-wrapper {\n display: block;\n position: relative;\n width: 100%;\n height: 100%;\n}\n.uni-textarea-placeholder,\n.uni-textarea-line,\n.uni-textarea-compute,\n.uni-textarea-textarea {\n position: absolute;\n width: 100%;\n height: 100%;\n left: 0;\n top: 0;\n white-space: inherit;\n word-break: inherit;\n}\n.uni-textarea-placeholder {\n color: grey;\n overflow: hidden;\n}\n.uni-textarea-line,\n.uni-textarea-compute {\n visibility: hidden;\n height: auto;\n}\n.uni-textarea-line {\n width: 1em;\n}\n.uni-textarea-textarea {\n resize: none;\n background: none;\n color: inherit;\n opacity: 1;\n -webkit-text-fill-color: currentcolor;\n font: inherit;\n line-height: inherit;\n letter-spacing: inherit;\n text-align: inherit;\n text-indent: inherit;\n text-transform: inherit;\n text-shadow: inherit;\n}\n/* \u7528\u4E8E\u89E3\u51B3 iOS textarea \u5185\u90E8\u9ED8\u8BA4\u8FB9\u8DDD */\n.uni-textarea-textarea-fix-margin {\n width: auto;\n right: 0;\n margin: 0 -3px;\n}\n"; +const DARK_TEST_STRING = "(prefers-color-scheme: dark)"; +const _sfc_main$4 = { + name: "Textarea", + mixins: [baseInput], + props: { + name: { type: String, - validator(type) { - if (type && animationTypes.indexOf(type) === -1) { - return "`" + type + "` is not supported for `animationType` (supported values are: `" + animationTypes.join("`|`") + "`)"; + default: "" + }, + maxlength: { + type: [Number, String], + default: 140 + }, + placeholder: { + type: String, + default: "" + }, + disabled: { + type: [Boolean, String], + default: false + }, + focus: { + type: [Boolean, String], + default: false + }, + autoFocus: { + type: [Boolean, String], + default: false + }, + placeholderClass: { + type: String, + default: "textarea-placeholder" + }, + placeholderStyle: { + type: String, + default: "" + }, + autoHeight: { + type: [Boolean, String], + default: false + }, + cursor: { + type: [Number, String], + default: -1 + }, + selectionStart: { + type: [Number, String], + default: -1 + }, + selectionEnd: { + type: [Number, String], + default: -1 + } + }, + data() { + return { + valueComposition: "", + composition: false, + focusSync: this.focus, + height: 0, + focusChangeSource: "", + fixMargin: String(navigator.platform).indexOf("iP") === 0 && String(navigator.vendor).indexOf("Apple") === 0 && window.matchMedia(DARK_TEST_STRING).media !== DARK_TEST_STRING + }; + }, + computed: { + maxlengthNumber() { + var maxlength = Number(this.maxlength); + return isNaN(maxlength) ? 140 : maxlength; + }, + cursorNumber() { + var cursor = Number(this.cursor); + return isNaN(cursor) ? -1 : cursor; + }, + selectionStartNumber() { + var selectionStart = Number(this.selectionStart); + return isNaN(selectionStart) ? -1 : selectionStart; + }, + selectionEndNumber() { + var selectionEnd = Number(this.selectionEnd); + return isNaN(selectionEnd) ? -1 : selectionEnd; + }, + valueCompute() { + return (this.composition ? this.valueComposition : this.valueSync).split("\n"); + } + }, + watch: { + focus(val) { + if (val) { + this.focusChangeSource = "focus"; + if (this.$refs.textarea) { + this.$refs.textarea.focus(); + } + } else { + if (this.$refs.textarea) { + this.$refs.textarea.blur(); } } }, - animationDuration: { - type: Number - } - }; -} -let navigatorLock; -function beforeRoute() { - navigatorLock = ""; -} -function createRouteOptions(type) { - return { - formatArgs: { - url: createNormalizeUrl(type) + focusSync(val) { + this.$emit("update:focus", val); + this._checkSelection(); + this._checkCursor(); }, - beforeAll: beforeRoute - }; -} -function createNormalizeUrl(type) { - return function normalizeUrl(url, params) { - url = getRealRoute(url); - const pagePath = url.split("?")[0]; - if (url === "/") { - url = __uniRoutes[0].path; - } - const routeOptions = __uniRoutes.find(({path}) => path === pagePath); - if (!routeOptions) { - return "page `" + url + "` is not found"; - } - if (type === API_NAVIGATE_TO || type === API_REDIRECT_TO) { - if (routeOptions.meta.isTabBar) { - return `can not ${type} a tabbar page`; + cursorNumber() { + this._checkCursor(); + }, + selectionStartNumber() { + this._checkSelection(); + }, + selectionEndNumber() { + this._checkSelection(); + }, + height(height) { + let lineHeight = parseFloat(getComputedStyle(this.$el).lineHeight); + if (isNaN(lineHeight)) { + lineHeight = this.$refs.line.offsetHeight; } - } else if (type === API_SWITCH_TAB) { - if (!routeOptions.meta.isTabBar) { - return "can not switch to no-tabBar page"; + var lineCount = Math.round(height / lineHeight); + this.$trigger("linechange", {}, { + height, + heightRpx: 750 / window.innerWidth * height, + lineCount + }); + if (this.autoHeight) { + this.$el.style.height = this.height + "px"; } } - if ((type === API_SWITCH_TAB || type === API_PRELOAD_PAGE) && routeOptions.meta.isTabBar && params.openType !== "appLaunch") { - url = pagePath; - } - if (routeOptions.meta.isEntry) { - url = url.replace(routeOptions.path, "/"); - } - params.url = encodeQueryString(url); - if (type === API_UN_PRELOAD_PAGE) { - return; - } else if (type === API_PRELOAD_PAGE) { - if (routeOptions.meta.isTabBar) { - const pages = getCurrentPages(true); - const tabBarPagePath = routeOptions.path.substr(1); - if (pages.find((page) => page.route === tabBarPagePath)) { - return "tabBar page `" + tabBarPagePath + "` already exists"; - } + }, + created() { + this.$dispatch("Form", "uni-form-group-update", { + type: "add", + vm: this + }); + }, + mounted() { + this._resize({ + height: this.$refs.sensor.$el.offsetHeight + }); + let $vm = this; + while ($vm) { + const scopeId = $vm.$options._scopeId; + if (scopeId) { + this.$refs.placeholder.setAttribute(scopeId, ""); } - return; - } - if (navigatorLock === url && params.openType !== "appLaunch") { - return `${navigatorLock} locked`; + $vm = $vm.$parent; } - if (__uniConfig.ready) { - navigatorLock = url; + this.initKeyboard(this.$refs.textarea); + }, + beforeDestroy() { + this.$dispatch("Form", "uni-form-group-update", { + type: "remove", + vm: this + }); + }, + methods: { + _focus: function($event) { + this.focusSync = true; + this.$trigger("focus", $event, { + value: this.valueSync + }); + }, + _checkSelection() { + if (this.focusSync && !this.focusChangeSource && this.selectionStartNumber > -1 && this.selectionEndNumber > -1) { + this.$refs.textarea.selectionStart = this.selectionStartNumber; + this.$refs.textarea.selectionEnd = this.selectionEndNumber; + } + }, + _checkCursor() { + if (this.focusSync && (this.focusChangeSource === "focus" || !this.focusChangeSource && this.selectionStartNumber < 0 && this.selectionEndNumber < 0) && this.cursorNumber > -1) { + this.$refs.textarea.selectionEnd = this.$refs.textarea.selectionStart = this.cursorNumber; + } + }, + _blur: function($event) { + this.focusSync = false; + this.$trigger("blur", $event, { + value: this.valueSync, + cursor: this.$refs.textarea.selectionEnd + }); + }, + _compositionstart($event) { + this.composition = true; + }, + _compositionend($event) { + this.composition = false; + }, + _confirm($event) { + this.$trigger("confirm", $event, { + value: this.valueSync + }); + }, + _linechange($event) { + this.$trigger("linechange", $event, { + value: this.valueSync + }); + }, + _touchstart() { + this.focusChangeSource = "touch"; + }, + _resize({height}) { + this.height = height; + }, + _input($event) { + if (this.composition) { + this.valueComposition = $event.target.value; + return; + } + this.$triggerInput($event, { + value: this.valueSync, + cursor: this.$refs.textarea.selectionEnd + }); + }, + _getFormData() { + return { + value: this.valueSync, + key: this.name + }; + }, + _resetFormData() { + this.valueSync = ""; } - }; + } +}; +const _hoisted_1$3 = {class: "uni-textarea-wrapper"}; +const _hoisted_2$2 = {class: "uni-textarea-compute"}; +function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) { + const _component_v_uni_resize_sensor = resolveComponent("v-uni-resize-sensor"); + return openBlock(), createBlock("uni-textarea", mergeProps({ + onChange: _cache[8] || (_cache[8] = withModifiers(() => { + }, ["stop"])) + }, _ctx.$attrs), [ + createVNode("div", _hoisted_1$3, [ + withDirectives(createVNode("div", { + ref: "placeholder", + style: $props.placeholderStyle, + class: [$props.placeholderClass, "uni-textarea-placeholder"], + textContent: toDisplayString($props.placeholder) + }, null, 14, ["textContent"]), [ + [vShow, !($data.composition || _ctx.valueSync.length)] + ]), + createVNode("div", { + ref: "line", + class: "uni-textarea-line", + textContent: toDisplayString(" ") + }, null, 8, ["textContent"]), + createVNode("div", _hoisted_2$2, [ + (openBlock(true), createBlock(Fragment, null, renderList($options.valueCompute, (item, index2) => { + return openBlock(), createBlock("div", { + key: index2, + textContent: toDisplayString(item.trim() ? item : ".") + }, null, 8, ["textContent"]); + }), 128)), + createVNode(_component_v_uni_resize_sensor, { + ref: "sensor", + onResize: $options._resize + }, null, 8, ["onResize"]) + ]), + withDirectives(createVNode("textarea", { + ref: "textarea", + "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => _ctx.valueSync = $event), + disabled: $props.disabled, + maxlength: $options.maxlengthNumber, + autofocus: $props.autoFocus || $props.focus, + class: [{"uni-textarea-textarea-fix-margin": $data.fixMargin}, "uni-textarea-textarea"], + style: {"overflow-y": $props.autoHeight ? "hidden" : "auto"}, + onCompositionstart: _cache[2] || (_cache[2] = (...args) => $options._compositionstart && $options._compositionstart(...args)), + onCompositionend: _cache[3] || (_cache[3] = (...args) => $options._compositionend && $options._compositionend(...args)), + onInput: _cache[4] || (_cache[4] = withModifiers((...args) => $options._input && $options._input(...args), ["stop"])), + onFocus: _cache[5] || (_cache[5] = (...args) => $options._focus && $options._focus(...args)), + onBlur: _cache[6] || (_cache[6] = (...args) => $options._blur && $options._blur(...args)), + onTouchstartPassive: _cache[7] || (_cache[7] = (...args) => $options._touchstart && $options._touchstart(...args)) + }, null, 46, ["disabled", "maxlength", "autofocus"]), [ + [vModelText, _ctx.valueSync] + ]) + ]) + ], 16); +} +_sfc_main$4.render = _sfc_render$4; +const _sfc_main$3 = { + name: "View", + mixins: [hover], + listeners: { + "label-click": "clickHandler" + } +}; +const _hoisted_1$2 = {key: 1}; +function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) { + return _ctx.hoverClass && _ctx.hoverClass !== "none" ? (openBlock(), createBlock("uni-view", { + key: 0, + class: [_ctx.hovering ? _ctx.hoverClass : ""], + onTouchstart: _cache[1] || (_cache[1] = (...args) => _ctx._hoverTouchStart && _ctx._hoverTouchStart(...args)), + onTouchend: _cache[2] || (_cache[2] = (...args) => _ctx._hoverTouchEnd && _ctx._hoverTouchEnd(...args)), + onTouchcancel: _cache[3] || (_cache[3] = (...args) => _ctx._hoverTouchCancel && _ctx._hoverTouchCancel(...args)) + }, [ + renderSlot(_ctx.$slots, "default") + ], 34)) : (openBlock(), createBlock("uni-view", _hoisted_1$2, [ + renderSlot(_ctx.$slots, "default") + ])); } +_sfc_main$3.render = _sfc_render$3; +const UniViewJSBridge$1 = extend(ViewJSBridge, { + publishHandler(event2, args, pageId) { + window.UniServiceJSBridge.subscribeHandler(event2, args, pageId); + } +}); function cssSupports(css) { return window.CSS && window.CSS.supports && window.CSS.supports(css); } @@ -8444,8 +9013,8 @@ const getSystemInfoSync = defineSyncApi("getSystemInfoSync", () => { /\bBrowser\b/i, /\bMobile\b/i ]; - for (let i = 0; i < infos.length; i++) { - const info = infos[i]; + for (let i2 = 0; i2 < infos.length; i2++) { + const info = infos[i2]; if (info.indexOf("Build") > 0) { model = info.split("Build")[0].trim(); break; @@ -8802,13 +9371,13 @@ function usePageHeadTransparent(headRef, {titleColor, coverage, backgroundColor} const borderRadiusElems = $el.querySelectorAll(".uni-page-head-btn"); const iconElems = $el.querySelectorAll(".uni-btn-icon"); const iconElemsStyles = []; - for (let i = 0; i < iconElems.length; i++) { - iconElemsStyles.push(iconElems[i].style); + for (let i2 = 0; i2 < iconElems.length; i2++) { + iconElemsStyles.push(iconElems[i2].style); } const oldColors = []; const borderRadiusElemsStyles = []; - for (let i = 0; i < borderRadiusElems.length; i++) { - const borderRadiusElem = borderRadiusElems[i]; + for (let i2 = 0; i2 < borderRadiusElems.length; i2++) { + const borderRadiusElem = borderRadiusElems[i2]; oldColors.push(getComputedStyle(borderRadiusElem).backgroundColor); borderRadiusElemsStyles.push(borderRadiusElem.style); } diff --git a/packages/uni-h5/package.json b/packages/uni-h5/package.json index 2574345119dbd8061541dab8960688b40dd432a1..6ed74f011c1f8b500a619557f390a5b83085da63 100644 --- a/packages/uni-h5/package.json +++ b/packages/uni-h5/package.json @@ -25,6 +25,6 @@ }, "dependencies": { "safe-area-insets": "^1.4.1", - "vue-router": "^4.0.5" + "vue-router": "^4.0.6" } } diff --git a/packages/uni-h5/src/helpers/utils.ts b/packages/uni-h5/src/helpers/utils.ts new file mode 100644 index 0000000000000000000000000000000000000000..50f038767595e657c1a7bb6278be8b9831441e65 --- /dev/null +++ b/packages/uni-h5/src/helpers/utils.ts @@ -0,0 +1,14 @@ +import { ComponentPublicInstance } from 'vue' + +const WINDOW_NAMES = ['VUniLeftWindow', 'VUniTopWindow', 'VUniRightWindow'] + +export function isInWindows(vm: ComponentPublicInstance) { + while (vm) { + const name = vm.$options.name + if (name && WINDOW_NAMES.indexOf(name) !== -1) { + return true + } + vm = vm.$parent! + } + return false +} diff --git a/packages/uni-h5/src/platform/getRealPath.ts b/packages/uni-h5/src/platform/dom.ts similarity index 90% rename from packages/uni-h5/src/platform/getRealPath.ts rename to packages/uni-h5/src/platform/dom.ts index 06fd56af527eff6a7109e5c5452ff2cadc5c4ca3..2c3a75f7695bf50c665590835e9dc88204685382 100644 --- a/packages/uni-h5/src/platform/getRealPath.ts +++ b/packages/uni-h5/src/platform/dom.ts @@ -1,5 +1,10 @@ +import { ComponentPublicInstance } from 'vue' import { getRealRoute } from '@dcloudio/uni-core' +export function findElem(vm: ComponentPublicInstance) { + return vm.$el +} + const SCHEME_RE = /^([a-z-]+:)?\/\//i const DATA_RE = /^data:.*,.*/ diff --git a/packages/uni-h5/src/platform/index.ts b/packages/uni-h5/src/platform/index.ts index b55df6b0e002615d28b95d32ef6a29d2ded0b920..b88f7e7b5e17255e5d8e21af4c7041899fd5d844 100644 --- a/packages/uni-h5/src/platform/index.ts +++ b/packages/uni-h5/src/platform/index.ts @@ -1,3 +1,7 @@ -export * from './getRealPath' +export * from './dom' export { getBaseSystemInfo } from '../service/api/base/getBaseSystemInfo' export { operateVideoPlayer } from '../service/api/context/operateVideoPlayer' +export { + addIntersectionObserver, + removeIntersectionObserver, +} from '../service/api/ui/intersectionObserver' diff --git a/packages/uni-h5/src/service/api/ui/intersectionObserver.ts b/packages/uni-h5/src/service/api/ui/intersectionObserver.ts new file mode 100644 index 0000000000000000000000000000000000000000..2f3044f242df2b5fb8ccba478f612d832d952d49 --- /dev/null +++ b/packages/uni-h5/src/service/api/ui/intersectionObserver.ts @@ -0,0 +1,30 @@ +import { + requestComponentObserver, + AddIntersectionObserverArgs, + RemoveIntersectionObserverArgs, +} from '@dcloudio/uni-api' +import { findElem } from '../../../platform/dom' + +export function addIntersectionObserver( + { reqId, component, options, callback }: AddIntersectionObserverArgs, + _pageId: number +) { + const $el = findElem(component) + ;($el.__io || ($el.__io = {}))[reqId] = requestComponentObserver( + $el, + options, + callback + ) +} + +export function removeIntersectionObserver( + { reqId, component }: RemoveIntersectionObserverArgs, + _pageId: number +) { + const $el = findElem(component) + const intersectionObserver = $el.__io && $el.__io[reqId] + if (intersectionObserver) { + intersectionObserver.disconnect() + delete $el.__io[reqId] + } +} diff --git a/packages/uni-h5/src/view/components/video/index.vue b/packages/uni-h5/src/view/components/video/index.vue index 8fdf78433ed09756aba41c4ad22e2a3e613c3640..b1694bd781131523be9fbf13a734b1862ac1e1ef 100644 --- a/packages/uni-h5/src/view/components/video/index.vue +++ b/packages/uni-h5/src/view/components/video/index.vue @@ -1,8 +1,5 @@