@component-hook/picker 0.1.1 → 0.1.2-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +1 -1
- package/dist/picker.es.js +61 -61
- package/dist/picker.umd.js +2 -2
- package/package.json +2 -2
package/dist/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.fade-enter-active[data-v-
|
|
1
|
+
.fade-enter-active[data-v-3207fa1f],.fade-leave-active[data-v-3207fa1f],.slide-enter-active[data-v-3207fa1f],.slide-leave-active[data-v-3207fa1f]{transition:all .3s ease}.fade-enter-from[data-v-3207fa1f],.fade-leave-to[data-v-3207fa1f]{opacity:0}.slide-enter-from[data-v-3207fa1f],.slide-leave-to[data-v-3207fa1f]{opacity:.5;transform:translate3d(0,270px,0)}.mask[data-v-3207fa1f]{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9999;background:#0003}.picker[data-v-3207fa1f]{position:fixed;left:0;right:0;bottom:0;height:270px;z-index:10000;background:#fff;-webkit-user-select:none;user-select:none}.picker_title[data-v-3207fa1f]{position:relative;height:44px;color:#333}.picker_title[data-v-3207fa1f]:after{content:"";display:block;border-bottom:1px solid #ebebeb;left:0;right:0;transform:scaleY(.5)}.picker_title button[data-v-3207fa1f]{position:absolute;height:44px;line-height:44px;padding:0 12px;font-size:14px;border:none;background-color:transparent}.picker_title h4[data-v-3207fa1f]{margin:0;font-size:16px;font-weight:400;height:44px;line-height:44px;text-align:center}.picker_cancel[data-v-3207fa1f]{left:0;cursor:pointer;transition:all .3s}.picker_cancel[data-v-3207fa1f]:hover{filter:brightness(110%)}.picker_confirm[data-v-3207fa1f]{right:0;cursor:pointer;transition:all .3s}.picker_confirm[data-v-3207fa1f]:hover{filter:brightness(110%)}.picker_panel[data-v-3207fa1f]{position:relative;height:226px;padding:24px 12px;box-sizing:border-box}.picker_mask_top[data-v-3207fa1f],.picker_mask_bottom[data-v-3207fa1f]{position:absolute;left:0;right:0;height:72px;background:#fff;transform:translateZ(0);z-index:1;pointer-events:none}.picker_mask_top[data-v-3207fa1f]{top:24px;background:linear-gradient(to bottom,#ffffffe6,#ffffff80)}.picker_mask_top[data-v-3207fa1f]:after{content:"";display:block;position:absolute;left:0;right:0;bottom:0;border-bottom:1px solid #ebebeb;transform:scaleY(.5)}.picker_mask_bottom[data-v-3207fa1f]{bottom:24px;background:linear-gradient(to top,#ffffffe6,#ffffff80)}.picker_mask_bottom[data-v-3207fa1f]:before{content:"";display:block;position:absolute;left:0;right:0;top:0;border-bottom:1px solid #ebebeb;transform:scaleY(.5)}.picker_wheel[data-v-3207fa1f]{flex:1;overflow:hidden}.picker_wheel_wrapper[data-v-3207fa1f]{display:flex;align-items:stretch;height:100%}.picker_wheel_scroll[data-v-3207fa1f]{margin-top:72px;padding:0}.picker_wheel_item[data-v-3207fa1f]{height:34px;line-height:34px;font-size:17px;text-align:center;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#333}
|
package/dist/picker.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./index.css";
|
|
2
|
-
import { ref as L, computed as P, watch as lt, nextTick as ne, defineComponent as se, openBlock as z, createElementBlock as K,
|
|
2
|
+
import { ref as L, computed as P, watch as lt, nextTick as ne, defineComponent as se, openBlock as z, createElementBlock as K, createVNode as bt, Transition as wt, withCtx as Pt, withDirectives as Et, createElementVNode as w, unref as x, vShow as Ct, normalizeClass as ct, normalizeStyle as ht, toDisplayString as j, Fragment as Dt, renderList as Bt, pushScopeId as ae, popScopeId as le } from "vue";
|
|
3
3
|
/*!
|
|
4
4
|
* better-scroll / core
|
|
5
5
|
* (c) 2016-2023 ustbhuangyi
|
|
@@ -19,15 +19,15 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
19
19
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
20
20
|
PERFORMANCE OF THIS SOFTWARE.
|
|
21
21
|
***************************************************************************** */
|
|
22
|
-
var
|
|
23
|
-
return
|
|
22
|
+
var dt = function(o, t) {
|
|
23
|
+
return dt = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, r) {
|
|
24
24
|
e.__proto__ = r;
|
|
25
25
|
} || function(e, r) {
|
|
26
26
|
for (var i in r) Object.prototype.hasOwnProperty.call(r, i) && (e[i] = r[i]);
|
|
27
|
-
},
|
|
27
|
+
}, dt(o, t);
|
|
28
28
|
};
|
|
29
29
|
function rt(o, t) {
|
|
30
|
-
|
|
30
|
+
dt(o, t);
|
|
31
31
|
function e() {
|
|
32
32
|
this.constructor = o;
|
|
33
33
|
}
|
|
@@ -166,18 +166,18 @@ if (E) {
|
|
|
166
166
|
function O() {
|
|
167
167
|
return window.performance && window.performance.now && window.performance.timing ? window.performance.now() + window.performance.timing.navigationStart : +/* @__PURE__ */ new Date();
|
|
168
168
|
}
|
|
169
|
-
var
|
|
169
|
+
var mt = function(o, t) {
|
|
170
170
|
for (var e in t)
|
|
171
171
|
o[e] = t[e];
|
|
172
172
|
return o;
|
|
173
173
|
};
|
|
174
|
-
function
|
|
174
|
+
function yt(o) {
|
|
175
175
|
return o == null;
|
|
176
176
|
}
|
|
177
177
|
function At(o, t, e) {
|
|
178
178
|
return o < t ? t : o > e ? e : o;
|
|
179
179
|
}
|
|
180
|
-
var
|
|
180
|
+
var kt = E && document.createElement("div").style, H = function() {
|
|
181
181
|
if (!E)
|
|
182
182
|
return !1;
|
|
183
183
|
for (var o = [
|
|
@@ -203,7 +203,7 @@ var Tt = E && document.createElement("div").style, H = function() {
|
|
|
203
203
|
}
|
|
204
204
|
], t = 0, e = o; t < e.length; t++) {
|
|
205
205
|
var r = e[t];
|
|
206
|
-
if (
|
|
206
|
+
if (kt[r.value] !== void 0)
|
|
207
207
|
return r.key;
|
|
208
208
|
}
|
|
209
209
|
return !1;
|
|
@@ -238,7 +238,7 @@ function Yt(o) {
|
|
|
238
238
|
};
|
|
239
239
|
}
|
|
240
240
|
H && H !== "standard" && "" + H.toLowerCase();
|
|
241
|
-
var me = D("transform"), $t = D("transition"), ye = E && D("perspective") in
|
|
241
|
+
var me = D("transform"), $t = D("transition"), ye = E && D("perspective") in kt, Mt = E && ("ontouchstart" in window || he), ge = E && $t in kt, _ = {
|
|
242
242
|
transform: me,
|
|
243
243
|
transition: $t,
|
|
244
244
|
transitionTimingFunction: D("transitionTimingFunction"),
|
|
@@ -247,7 +247,7 @@ var me = D("transform"), $t = D("transition"), ye = E && D("perspective") in Tt,
|
|
|
247
247
|
transformOrigin: D("transformOrigin"),
|
|
248
248
|
transitionEnd: D("transitionEnd"),
|
|
249
249
|
transitionProperty: D("transitionProperty")
|
|
250
|
-
},
|
|
250
|
+
}, ut = {
|
|
251
251
|
touchstart: 1,
|
|
252
252
|
touchmove: 1,
|
|
253
253
|
touchend: 1,
|
|
@@ -298,7 +298,7 @@ function jt(o, t) {
|
|
|
298
298
|
};
|
|
299
299
|
if (typeof MouseEvent < "u")
|
|
300
300
|
try {
|
|
301
|
-
i = new MouseEvent(t,
|
|
301
|
+
i = new MouseEvent(t, mt(N({
|
|
302
302
|
bubbles: n,
|
|
303
303
|
cancelable: s
|
|
304
304
|
}, u), r));
|
|
@@ -308,7 +308,7 @@ function jt(o, t) {
|
|
|
308
308
|
else
|
|
309
309
|
v();
|
|
310
310
|
function v() {
|
|
311
|
-
i = document.createEvent("Event"), i.initEvent(t, n, s),
|
|
311
|
+
i = document.createEvent("Event"), i.initEvent(t, n, s), mt(i, r);
|
|
312
312
|
}
|
|
313
313
|
i.forwardedTouchEvent = !0, i._constructed = !0, o.target.dispatchEvent(i);
|
|
314
314
|
}
|
|
@@ -350,7 +350,7 @@ var qt = function() {
|
|
|
350
350
|
window.clearTimeout(o);
|
|
351
351
|
} : Ut;
|
|
352
352
|
}(), _t = function(o) {
|
|
353
|
-
},
|
|
353
|
+
}, pt = {
|
|
354
354
|
enumerable: !0,
|
|
355
355
|
configurable: !0,
|
|
356
356
|
get: _t,
|
|
@@ -369,11 +369,11 @@ var qt = function() {
|
|
|
369
369
|
o[r.pop()] = e;
|
|
370
370
|
};
|
|
371
371
|
function Ee(o, t, e) {
|
|
372
|
-
|
|
372
|
+
pt.get = function() {
|
|
373
373
|
return we(this, t);
|
|
374
|
-
},
|
|
374
|
+
}, pt.set = function(i) {
|
|
375
375
|
Pe(this, t, i);
|
|
376
|
-
}, Object.defineProperty(o, e,
|
|
376
|
+
}, Object.defineProperty(o, e, pt);
|
|
377
377
|
}
|
|
378
378
|
var Y = (
|
|
379
379
|
/** @class */
|
|
@@ -506,7 +506,7 @@ var Y = (
|
|
|
506
506
|
bottom: !1,
|
|
507
507
|
left: !1
|
|
508
508
|
}, n;
|
|
509
|
-
return typeof e == "object" ? n =
|
|
509
|
+
return typeof e == "object" ? n = mt(r, e) : n = e ? r : i, n;
|
|
510
510
|
}, t;
|
|
511
511
|
}(Ce)
|
|
512
512
|
), Be = (
|
|
@@ -565,7 +565,7 @@ var Y = (
|
|
|
565
565
|
}, o.prototype.setInitiated = function(t) {
|
|
566
566
|
t === void 0 && (t = 0), this.initiated = t;
|
|
567
567
|
}, o.prototype.start = function(t) {
|
|
568
|
-
var e =
|
|
568
|
+
var e = ut[t.type];
|
|
569
569
|
if (!(this.initiated && this.initiated !== e)) {
|
|
570
570
|
if (this.setInitiated(e), ke(t.target, this.options.tagException)) {
|
|
571
571
|
this.setInitiated();
|
|
@@ -578,7 +578,7 @@ var Y = (
|
|
|
578
578
|
}
|
|
579
579
|
}
|
|
580
580
|
}, o.prototype.move = function(t) {
|
|
581
|
-
if (
|
|
581
|
+
if (ut[t.type] === this.initiated) {
|
|
582
582
|
this.beforeHandler(t, "move");
|
|
583
583
|
var e = t.touches ? t.touches[0] : t, r = e.pageX - this.pointX, i = e.pageY - this.pointY;
|
|
584
584
|
if (this.pointX = e.pageX, this.pointY = e.pageY, !this.hooks.trigger(this.hooks.eventTypes.move, {
|
|
@@ -591,7 +591,7 @@ var Y = (
|
|
|
591
591
|
}
|
|
592
592
|
}
|
|
593
593
|
}, o.prototype.end = function(t) {
|
|
594
|
-
|
|
594
|
+
ut[t.type] === this.initiated && (this.setInitiated(), this.beforeHandler(t, "end"), this.hooks.trigger(this.hooks.eventTypes.end, t));
|
|
595
595
|
}, o.prototype.click = function(t) {
|
|
596
596
|
this.hooks.trigger(this.hooks.eventTypes.click, t);
|
|
597
597
|
}, o.prototype.setContent = function(t) {
|
|
@@ -602,7 +602,7 @@ var Y = (
|
|
|
602
602
|
this.wrapperEventRegister.destroy(), this.targetEventRegister.destroy(), this.hooks.destroy();
|
|
603
603
|
}, o;
|
|
604
604
|
}()
|
|
605
|
-
),
|
|
605
|
+
), ft = {
|
|
606
606
|
x: ["translateX", "px"],
|
|
607
607
|
y: ["translateY", "px"]
|
|
608
608
|
}, xe = (
|
|
@@ -620,10 +620,10 @@ var Y = (
|
|
|
620
620
|
}, o.prototype.translate = function(t) {
|
|
621
621
|
var e = [];
|
|
622
622
|
Object.keys(t).forEach(function(r) {
|
|
623
|
-
if (
|
|
624
|
-
var i =
|
|
623
|
+
if (ft[r]) {
|
|
624
|
+
var i = ft[r][0];
|
|
625
625
|
if (i) {
|
|
626
|
-
var n =
|
|
626
|
+
var n = ft[r][1], s = t[r];
|
|
627
627
|
e.push(i + "(" + s + n + ")");
|
|
628
628
|
}
|
|
629
629
|
}
|
|
@@ -1008,7 +1008,7 @@ function Lt(o, t, e, r) {
|
|
|
1008
1008
|
}, {});
|
|
1009
1009
|
return i.scrollable = !!o[t], i.bounces = e, i.rect = r, i;
|
|
1010
1010
|
}
|
|
1011
|
-
function
|
|
1011
|
+
function gt(o, t, e) {
|
|
1012
1012
|
e.forEach(function(r) {
|
|
1013
1013
|
var i, n;
|
|
1014
1014
|
typeof r == "string" ? i = n = r : (i = r.source, n = r.target), o.on(i, function() {
|
|
@@ -1097,7 +1097,7 @@ var Ht = 1, We = (
|
|
|
1097
1097
|
var t = this;
|
|
1098
1098
|
this.animater.hooks.on(this.animater.hooks.eventTypes.end, function(e) {
|
|
1099
1099
|
t.resetPosition(t.options.bounceTime) || (t.animater.setPending(!1), t.hooks.trigger(t.hooks.eventTypes.scrollEnd, e));
|
|
1100
|
-
}),
|
|
1100
|
+
}), gt(this.animater.hooks, this.hooks, [
|
|
1101
1101
|
{
|
|
1102
1102
|
source: this.animater.hooks.eventTypes.move,
|
|
1103
1103
|
target: this.hooks.eventTypes.scroll
|
|
@@ -1109,7 +1109,7 @@ var Ht = 1, We = (
|
|
|
1109
1109
|
]);
|
|
1110
1110
|
}, o.prototype.bindActions = function() {
|
|
1111
1111
|
var t = this, e = this.actions;
|
|
1112
|
-
|
|
1112
|
+
gt(e.hooks, this.hooks, [
|
|
1113
1113
|
{
|
|
1114
1114
|
source: e.hooks.eventTypes.start,
|
|
1115
1115
|
target: this.hooks.eventTypes.beforeStart
|
|
@@ -1162,7 +1162,7 @@ var Ht = 1, We = (
|
|
|
1162
1162
|
newX: t.x,
|
|
1163
1163
|
newY: t.y
|
|
1164
1164
|
}, i = this.scrollBehaviorX.end(e), n = this.scrollBehaviorY.end(e);
|
|
1165
|
-
if (r.newX =
|
|
1165
|
+
if (r.newX = yt(i.destination) ? r.newX : i.destination, r.newY = yt(n.destination) ? r.newY : n.destination, r.time = Math.max(i.duration, n.duration), this.hooks.trigger(this.hooks.eventTypes.momentum, r, this), r.newX !== t.x || r.newY !== t.y)
|
|
1166
1166
|
return (r.newX > this.scrollBehaviorX.minScrollPos || r.newX < this.scrollBehaviorX.maxScrollPos || r.newY > this.scrollBehaviorY.minScrollPos || r.newY < this.scrollBehaviorY.maxScrollPos) && (r.easing = X.swipeBounce), this.scrollTo(r.newX, r.newY, r.time, r.easing), !0;
|
|
1167
1167
|
}, o.prototype.checkClick = function(t) {
|
|
1168
1168
|
var e = {
|
|
@@ -1290,7 +1290,7 @@ var Ht = 1, We = (
|
|
|
1290
1290
|
var r = e.pluginName, i = t.plugins.some(function(n) {
|
|
1291
1291
|
return e === n.ctor;
|
|
1292
1292
|
});
|
|
1293
|
-
return i ? t :
|
|
1293
|
+
return i ? t : yt(r) ? (Q("Plugin Class must specify plugin's name in static property by 'pluginName' field."), t) : (t.pluginsMap[r] = !0, t.plugins.push({
|
|
1294
1294
|
name: r,
|
|
1295
1295
|
applyOrder: e.applyOrder,
|
|
1296
1296
|
ctor: e
|
|
@@ -1326,7 +1326,7 @@ var Ht = 1, We = (
|
|
|
1326
1326
|
e && (e.tagName === "INPUT" || e.tagName === "TEXTAREA") && e.blur();
|
|
1327
1327
|
});
|
|
1328
1328
|
}, t.prototype.eventBubbling = function() {
|
|
1329
|
-
|
|
1329
|
+
gt(this.scroller.hooks, this, [
|
|
1330
1330
|
this.eventTypes.beforeScrollStart,
|
|
1331
1331
|
this.eventTypes.scrollStart,
|
|
1332
1332
|
this.eventTypes.scroll,
|
|
@@ -1442,7 +1442,7 @@ function B(o) {
|
|
|
1442
1442
|
F && F !== "standard" && "" + F.toLowerCase();
|
|
1443
1443
|
var Ve = B("transform"), $e = B("transition");
|
|
1444
1444
|
$ && B("perspective") in Zt;
|
|
1445
|
-
var
|
|
1445
|
+
var vt = {
|
|
1446
1446
|
transform: Ve,
|
|
1447
1447
|
transition: $e,
|
|
1448
1448
|
transitionTimingFunction: B("transitionTimingFunction"),
|
|
@@ -1587,14 +1587,14 @@ var Ue = {
|
|
|
1587
1587
|
}
|
|
1588
1588
|
}, o.prototype.transitionDuration = function(t) {
|
|
1589
1589
|
for (var e = 0; e < this.items.length; e++)
|
|
1590
|
-
this.items[e].style[
|
|
1590
|
+
this.items[e].style[vt.transitionDuration] = t + "ms";
|
|
1591
1591
|
}, o.prototype.timeFunction = function(t) {
|
|
1592
1592
|
for (var e = 0; e < this.items.length; e++)
|
|
1593
|
-
this.items[e].style[
|
|
1593
|
+
this.items[e].style[vt.transitionTimingFunction] = t;
|
|
1594
1594
|
}, o.prototype.rotateX = function(t) {
|
|
1595
1595
|
for (var e = this.options.rotate, r = e === void 0 ? 25 : e, i = 0; i < this.items.length; i++) {
|
|
1596
1596
|
var n = r * (t / this.itemHeight + i), s = n.toFixed(3);
|
|
1597
|
-
this.items[i].style[
|
|
1597
|
+
this.items[i].style[vt.transform] = "rotateX(" + s + "deg)";
|
|
1598
1598
|
}
|
|
1599
1599
|
}, o.prototype.findNearestValidWheel = function(t) {
|
|
1600
1600
|
t = t > 0 ? 0 : t < this.scroll.maxScrollY ? this.scroll.maxScrollY : t;
|
|
@@ -1619,7 +1619,7 @@ var Ue = {
|
|
|
1619
1619
|
}()
|
|
1620
1620
|
);
|
|
1621
1621
|
const ot = Array.isArray, to = (o) => typeof o == "object" && o !== null;
|
|
1622
|
-
function
|
|
1622
|
+
function Tt(o) {
|
|
1623
1623
|
return ot(o) && o.length === 3;
|
|
1624
1624
|
}
|
|
1625
1625
|
function eo() {
|
|
@@ -1637,7 +1637,7 @@ function eo() {
|
|
|
1637
1637
|
return g;
|
|
1638
1638
|
}
|
|
1639
1639
|
function d(f) {
|
|
1640
|
-
return (
|
|
1640
|
+
return (Tt(f) ? f : [r, i, n]).map((g, C) => {
|
|
1641
1641
|
const M = u.value[C].indexOf(g);
|
|
1642
1642
|
return M > -1 ? M : 0;
|
|
1643
1643
|
});
|
|
@@ -1668,7 +1668,7 @@ function oo() {
|
|
|
1668
1668
|
r.value = [c, a, h];
|
|
1669
1669
|
}
|
|
1670
1670
|
function s(l) {
|
|
1671
|
-
return (
|
|
1671
|
+
return (Tt(l) ? l : r.value).map((a) => +a);
|
|
1672
1672
|
}
|
|
1673
1673
|
return {
|
|
1674
1674
|
timeList: [o, t, e],
|
|
@@ -1690,7 +1690,7 @@ function ro(o, t) {
|
|
|
1690
1690
|
e.value = p[k] ?? b;
|
|
1691
1691
|
}
|
|
1692
1692
|
function g() {
|
|
1693
|
-
!n.value && !s.value || (n.value && h(T.value), s.value && !
|
|
1693
|
+
!n.value && !s.value || (n.value && h(T.value), s.value && !Tt(o.anchor) && y());
|
|
1694
1694
|
}
|
|
1695
1695
|
function C(p) {
|
|
1696
1696
|
var b;
|
|
@@ -1745,8 +1745,8 @@ function ro(o, t) {
|
|
|
1745
1745
|
function ie() {
|
|
1746
1746
|
const { item: p, anchor: k } = i.value.reduce(
|
|
1747
1747
|
(m, b, st) => {
|
|
1748
|
-
const
|
|
1749
|
-
return m.item.push(s.value ? +at : at), m.anchor.push(n.value ? at :
|
|
1748
|
+
const St = b.getSelectedIndex(), at = e.value[st][St];
|
|
1749
|
+
return m.item.push(s.value ? +at : at), m.anchor.push(n.value ? at : St), m;
|
|
1750
1750
|
},
|
|
1751
1751
|
{ item: [], anchor: [] }
|
|
1752
1752
|
);
|
|
@@ -1772,7 +1772,7 @@ function ro(o, t) {
|
|
|
1772
1772
|
closePicker: nt
|
|
1773
1773
|
};
|
|
1774
1774
|
}
|
|
1775
|
-
const Jt = (o) => (ae("data-v-
|
|
1775
|
+
const Jt = (o) => (ae("data-v-3207fa1f"), o = o(), le(), o), io = { class: "picker" }, no = { class: "picker_title" }, so = { class: "picker_panel" }, ao = /* @__PURE__ */ Jt(() => /* @__PURE__ */ w("div", { class: "picker_mask_top" }, null, -1)), lo = /* @__PURE__ */ Jt(() => /* @__PURE__ */ w("div", { class: "picker_mask_bottom" }, null, -1)), co = { class: "picker_wheel_scroll" }, ho = /* @__PURE__ */ se({
|
|
1776
1776
|
__name: "Picker",
|
|
1777
1777
|
props: {
|
|
1778
1778
|
data: { default: () => [] },
|
|
@@ -1797,38 +1797,38 @@ const Jt = (o) => (ae("data-v-78632b89"), o = o(), le(), o), io = { class: "pick
|
|
|
1797
1797
|
titleText: "",
|
|
1798
1798
|
...e.options
|
|
1799
1799
|
})), n = P(() => i.value.cancelColor), s = P(() => i.value.confirmColor), l = P(() => i.value.titleColor), c = P(() => ot(e.showKey) ? e.showKey : [e.showKey]), { pickerData: a, wheelWrapper: h, cancel: u, confirm: v, closePicker: y } = ro(e, r);
|
|
1800
|
-
return (d, T) => (z(), K(
|
|
1801
|
-
wt
|
|
1802
|
-
default:
|
|
1803
|
-
|
|
1800
|
+
return (d, T) => (z(), K("div", null, [
|
|
1801
|
+
bt(wt, { name: "fade" }, {
|
|
1802
|
+
default: Pt(() => [
|
|
1803
|
+
Et(w("div", {
|
|
1804
1804
|
class: "mask",
|
|
1805
1805
|
onClick: T[0] || (T[0] = //@ts-ignore
|
|
1806
1806
|
(...f) => x(y) && x(y)(...f))
|
|
1807
1807
|
}, null, 512), [
|
|
1808
|
-
[
|
|
1808
|
+
[Ct, d.isShowPicker]
|
|
1809
1809
|
])
|
|
1810
1810
|
]),
|
|
1811
1811
|
_: 1
|
|
1812
1812
|
}),
|
|
1813
|
-
wt
|
|
1814
|
-
default:
|
|
1815
|
-
|
|
1813
|
+
bt(wt, { name: "slide" }, {
|
|
1814
|
+
default: Pt(() => [
|
|
1815
|
+
Et(w("div", io, [
|
|
1816
1816
|
w("div", no, [
|
|
1817
1817
|
w("button", {
|
|
1818
|
-
class:
|
|
1819
|
-
style:
|
|
1818
|
+
class: ct(["picker_cancel", i.value.cancelClass]),
|
|
1819
|
+
style: ht({ color: n.value }),
|
|
1820
1820
|
onClick: T[1] || (T[1] = //@ts-ignore
|
|
1821
1821
|
(...f) => x(u) && x(u)(...f))
|
|
1822
1822
|
}, j(i.value.cancelText), 7),
|
|
1823
1823
|
w("button", {
|
|
1824
|
-
class:
|
|
1825
|
-
style:
|
|
1824
|
+
class: ct(["picker_confirm", i.value.confirmClass]),
|
|
1825
|
+
style: ht({ color: s.value }),
|
|
1826
1826
|
onClick: T[2] || (T[2] = //@ts-ignore
|
|
1827
1827
|
(...f) => x(v) && x(v)(...f))
|
|
1828
1828
|
}, j(i.value.confirmText), 7),
|
|
1829
1829
|
w("h4", {
|
|
1830
|
-
class:
|
|
1831
|
-
style:
|
|
1830
|
+
class: ct([i.value.titleClass]),
|
|
1831
|
+
style: ht({ color: l.value })
|
|
1832
1832
|
}, j(i.value.titleText), 7)
|
|
1833
1833
|
]),
|
|
1834
1834
|
w("div", so, [
|
|
@@ -1839,12 +1839,12 @@ const Jt = (o) => (ae("data-v-78632b89"), o = o(), le(), o), io = { class: "pick
|
|
|
1839
1839
|
ref: h,
|
|
1840
1840
|
class: "picker_wheel_wrapper"
|
|
1841
1841
|
}, [
|
|
1842
|
-
(z(!0), K(
|
|
1842
|
+
(z(!0), K(Dt, null, Bt(x(a), (f, S) => (z(), K("div", {
|
|
1843
1843
|
key: S,
|
|
1844
1844
|
class: "picker_wheel"
|
|
1845
1845
|
}, [
|
|
1846
1846
|
w("ul", co, [
|
|
1847
|
-
(z(!0), K(
|
|
1847
|
+
(z(!0), K(Dt, null, Bt(f, (g, C) => {
|
|
1848
1848
|
var M;
|
|
1849
1849
|
return z(), K("li", {
|
|
1850
1850
|
key: C,
|
|
@@ -1856,19 +1856,19 @@ const Jt = (o) => (ae("data-v-78632b89"), o = o(), le(), o), io = { class: "pick
|
|
|
1856
1856
|
], 512)
|
|
1857
1857
|
])
|
|
1858
1858
|
], 512), [
|
|
1859
|
-
[
|
|
1859
|
+
[Ct, d.isShowPicker]
|
|
1860
1860
|
])
|
|
1861
1861
|
]),
|
|
1862
1862
|
_: 1
|
|
1863
1863
|
})
|
|
1864
|
-
]
|
|
1864
|
+
]));
|
|
1865
1865
|
}
|
|
1866
1866
|
}), uo = (o, t) => {
|
|
1867
1867
|
const e = o.__vccOpts || o;
|
|
1868
1868
|
for (const [r, i] of t)
|
|
1869
1869
|
e[r] = i;
|
|
1870
1870
|
return e;
|
|
1871
|
-
}, zt = /* @__PURE__ */ uo(ho, [["__scopeId", "data-v-
|
|
1871
|
+
}, zt = /* @__PURE__ */ uo(ho, [["__scopeId", "data-v-3207fa1f"]]);
|
|
1872
1872
|
zt.install = function(o) {
|
|
1873
1873
|
o.component("Picker", zt);
|
|
1874
1874
|
};
|
package/dist/picker.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(c,O){typeof exports=="object"&&typeof module<"u"?module.exports=O(require("vue")):typeof define=="function"&&define.amd?define(["vue"],O):(c=typeof globalThis<"u"?globalThis:c||self,c.picker=O(c.Vue))})(this,function(c){"use strict";var O=document.createElement("style");O.textContent=`.fade-enter-active[data-v-
|
|
1
|
+
(function(c,O){typeof exports=="object"&&typeof module<"u"?module.exports=O(require("vue")):typeof define=="function"&&define.amd?define(["vue"],O):(c=typeof globalThis<"u"?globalThis:c||self,c.picker=O(c.Vue))})(this,function(c){"use strict";var O=document.createElement("style");O.textContent=`.fade-enter-active[data-v-3207fa1f],.fade-leave-active[data-v-3207fa1f],.slide-enter-active[data-v-3207fa1f],.slide-leave-active[data-v-3207fa1f]{transition:all .3s ease}.fade-enter-from[data-v-3207fa1f],.fade-leave-to[data-v-3207fa1f]{opacity:0}.slide-enter-from[data-v-3207fa1f],.slide-leave-to[data-v-3207fa1f]{opacity:.5;transform:translate3d(0,270px,0)}.mask[data-v-3207fa1f]{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9999;background:#0003}.picker[data-v-3207fa1f]{position:fixed;left:0;right:0;bottom:0;height:270px;z-index:10000;background:#fff;-webkit-user-select:none;user-select:none}.picker_title[data-v-3207fa1f]{position:relative;height:44px;color:#333}.picker_title[data-v-3207fa1f]:after{content:"";display:block;border-bottom:1px solid #ebebeb;left:0;right:0;transform:scaleY(.5)}.picker_title button[data-v-3207fa1f]{position:absolute;height:44px;line-height:44px;padding:0 12px;font-size:14px;border:none;background-color:transparent}.picker_title h4[data-v-3207fa1f]{margin:0;font-size:16px;font-weight:400;height:44px;line-height:44px;text-align:center}.picker_cancel[data-v-3207fa1f]{left:0;cursor:pointer;transition:all .3s}.picker_cancel[data-v-3207fa1f]:hover{filter:brightness(110%)}.picker_confirm[data-v-3207fa1f]{right:0;cursor:pointer;transition:all .3s}.picker_confirm[data-v-3207fa1f]:hover{filter:brightness(110%)}.picker_panel[data-v-3207fa1f]{position:relative;height:226px;padding:24px 12px;box-sizing:border-box}.picker_mask_top[data-v-3207fa1f],.picker_mask_bottom[data-v-3207fa1f]{position:absolute;left:0;right:0;height:72px;background:#fff;transform:translateZ(0);z-index:1;pointer-events:none}.picker_mask_top[data-v-3207fa1f]{top:24px;background:linear-gradient(to bottom,#ffffffe6,#ffffff80)}.picker_mask_top[data-v-3207fa1f]:after{content:"";display:block;position:absolute;left:0;right:0;bottom:0;border-bottom:1px solid #ebebeb;transform:scaleY(.5)}.picker_mask_bottom[data-v-3207fa1f]{bottom:24px;background:linear-gradient(to top,#ffffffe6,#ffffff80)}.picker_mask_bottom[data-v-3207fa1f]:before{content:"";display:block;position:absolute;left:0;right:0;top:0;border-bottom:1px solid #ebebeb;transform:scaleY(.5)}.picker_wheel[data-v-3207fa1f]{flex:1;overflow:hidden}.picker_wheel_wrapper[data-v-3207fa1f]{display:flex;align-items:stretch;height:100%}.picker_wheel_scroll[data-v-3207fa1f]{margin-top:72px;padding:0}.picker_wheel_item[data-v-3207fa1f]{height:34px;line-height:34px;font-size:17px;text-align:center;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#333}
|
|
2
2
|
`,document.head.appendChild(O);/*!
|
|
3
3
|
* better-scroll / core
|
|
4
4
|
* (c) 2016-2023 ustbhuangyi
|
|
@@ -20,4 +20,4 @@
|
|
|
20
20
|
* better-scroll / wheel
|
|
21
21
|
* (c) 2016-2023 ustbhuangyi
|
|
22
22
|
* Released under the MIT License.
|
|
23
|
-
*/var W=typeof window<"u",Z=W&&navigator.userAgent.toLowerCase();Z&&Z.indexOf("android")>0,function(){if(typeof Z=="string"){var o=/os (\d\d?_\d(_\d)?)/,t=o.exec(Z);if(!t)return!1;var e=t[1].split("_").map(function(r){return parseInt(r,10)});return e[0]===13&&e[1]>=4}return!1}();var ye=!1;if(W){var ge="test-passive";try{var Mt={};Object.defineProperty(Mt,"passive",{get:function(){ye=!0}}),window.addEventListener(ge,function(){},Mt)}catch{}}var ke=function(o,t){for(var e in t)o[e]=t[e];return o},Xt=W&&document.createElement("div").style,z=function(){if(!W)return!1;for(var o=[{key:"standard",value:"transform"},{key:"webkit",value:"webkitTransform"},{key:"Moz",value:"MozTransform"},{key:"O",value:"OTransform"},{key:"ms",value:"msTransform"}],t=0,e=o;t<e.length;t++){var r=e[t];if(Xt[r.value]!==void 0)return r.key}return!1}();function x(o){return z===!1?o:z==="standard"?o==="transitionEnd"?"transitionend":o:z+o.charAt(0).toUpperCase()+o.substr(1)}z&&z!=="standard"&&""+z.toLowerCase();var Te=x("transform"),be=x("transition");W&&x("perspective")in Xt;var lt={transform:Te,transition:be,transitionTimingFunction:x("transitionTimingFunction"),transitionDuration:x("transitionDuration"),transitionDelay:x("transitionDelay"),transformOrigin:x("transformOrigin"),transitionEnd:x("transitionEnd"),transitionProperty:x("transitionProperty")};function J(o,t){var e=new RegExp("(^|\\s)"+t+"(\\s|$)");return e.test(o.className)}function Se(o){return Array.prototype.slice.call(o,0)}var we={swipe:{style:"cubic-bezier(0.23, 1, 0.32, 1)",fn:function(o){return 1+--o*o*o*o*o}},swipeBounce:{style:"cubic-bezier(0.25, 0.46, 0.45, 0.94)",fn:function(o){return o*(2-o)}},bounce:{style:"cubic-bezier(0.165, 0.84, 0.44, 1)",fn:function(o){return 1- --o*o*o*o}}},Pe="plugins.wheel",Ee=[{key:"wheelTo",name:"wheelTo"},{key:"getSelectedIndex",name:"getSelectedIndex"},{key:"restorePosition",name:"restorePosition"}],xe=Ee.map(function(o){return{key:o.key,sourceKey:Pe+"."+o.name}}),Ot="wheelIndexChanged",Ce={rate:4},De=function(){function o(t){this.scroll=t,this.init()}return o.prototype.init=function(){this.handleBScroll(),this.handleOptions(),this.handleHooks(),this.refreshBoundary(),this.setSelectedIndex(this.options.selectedIndex)},o.prototype.handleBScroll=function(){this.scroll.proxy(xe),this.scroll.registerType([Ot])},o.prototype.handleOptions=function(){var t=this.scroll.options.wheel===!0?{}:this.scroll.options.wheel,e={wheelWrapperClass:"wheel-scroll",wheelItemClass:"wheel-item",rotate:25,adjustTime:400,selectedIndex:0,wheelDisabledItemClass:"wheel-disabled-item"};this.options=ke(e,t)},o.prototype.handleHooks=function(){var t=this,e=this.scroll,r=this.scroll.scroller,i=r.actionsHandler,n=r.scrollBehaviorX,s=r.scrollBehaviorY,l=r.animater,h=r.content;e.on(e.eventTypes.scrollEnd,function(a){var u=t.findNearestValidWheel(a.y).index;if(r.animater.forceStopped&&!t.isAdjustingPosition)return t.target=t.items[u],!0;t.setSelectedIndex(u),t.isAdjustingPosition&&(t.isAdjustingPosition=!1)}),this.scroll.hooks.on(this.scroll.hooks.eventTypes.refresh,function(a){a!==h&&(h=a,t.setSelectedIndex(t.options.selectedIndex,!0)),t.rotateX(t.scroll.y),t.wheelTo(t.selectedIndex,0)}),this.scroll.hooks.on(this.scroll.hooks.eventTypes.beforeInitialScrollTo,function(a){a.x=0,a.y=-(t.selectedIndex*t.itemHeight)}),r.hooks.on(r.hooks.eventTypes.checkClick,function(){var a=Se(t.items).indexOf(t.target);return a===-1||t.wheelTo(a,t.options.adjustTime,we.swipe),!0}),r.hooks.on(r.hooks.eventTypes.scrollTo,function(a){a.y=t.findNearestValidWheel(a.y).y}),r.hooks.on(r.hooks.eventTypes.minDistanceScroll,function(){var a=r.animater;a.forceStopped===!0&&(a.forceStopped=!1)}),r.hooks.on(r.hooks.eventTypes.scrollToElement,function(a,u){if(J(a,t.options.wheelItemClass))u.top=t.findNearestValidWheel(u.top).y;else return!0}),i.hooks.on(i.hooks.eventTypes.beforeStart,function(a){t.target=a.target}),n.hooks.on(n.hooks.eventTypes.computeBoundary,function(a){a.maxScrollPos=0,a.minScrollPos=0}),s.hooks.on(s.hooks.eventTypes.computeBoundary,function(a){t.items=t.scroll.scroller.content.children,t.checkWheelAllDisabled(),t.itemHeight=t.items.length>0?s.contentSize/t.items.length:0,a.maxScrollPos=-t.itemHeight*(t.items.length-1),a.minScrollPos=0}),s.hooks.on(s.hooks.eventTypes.momentum,function(a){a.rate=Ce.rate,a.destination=t.findNearestValidWheel(a.destination).y}),s.hooks.on(s.hooks.eventTypes.end,function(a){var u=t.findNearestValidWheel(s.currentPos);a.destination=u.y,a.duration=t.options.adjustTime}),l.hooks.on(l.hooks.eventTypes.time,function(a){t.transitionDuration(a)}),l.hooks.on(l.hooks.eventTypes.timeFunction,function(a){t.timeFunction(a)}),l.hooks.on(l.hooks.eventTypes.callStop,function(){var a=t.findNearestValidWheel(t.scroll.y).index;t.isAdjustingPosition=!0,t.wheelTo(a,0)}),l.translater.hooks.on(l.translater.hooks.eventTypes.translate,function(a){t.rotateX(a.y)})},o.prototype.refreshBoundary=function(){var t=this.scroll.scroller,e=t.scrollBehaviorX,r=t.scrollBehaviorY,i=t.content;e.refresh(i),r.refresh(i)},o.prototype.setSelectedIndex=function(t,e){e===void 0&&(e=!1);var r=this.selectedIndex;this.selectedIndex=t,r!==t&&!e&&this.scroll.trigger(Ot,t)},o.prototype.getSelectedIndex=function(){return this.selectedIndex},o.prototype.wheelTo=function(t,e,r){t===void 0&&(t=0),e===void 0&&(e=0);var i=-t*this.itemHeight;this.scroll.scrollTo(0,i,e,r)},o.prototype.restorePosition=function(){var t=this.scroll.pending;if(t){var e=this.getSelectedIndex();this.scroll.scroller.animater.clearTimer(),this.wheelTo(e,0)}},o.prototype.transitionDuration=function(t){for(var e=0;e<this.items.length;e++)this.items[e].style[lt.transitionDuration]=t+"ms"},o.prototype.timeFunction=function(t){for(var e=0;e<this.items.length;e++)this.items[e].style[lt.transitionTimingFunction]=t},o.prototype.rotateX=function(t){for(var e=this.options.rotate,r=e===void 0?25:e,i=0;i<this.items.length;i++){var n=r*(t/this.itemHeight+i),s=n.toFixed(3);this.items[i].style[lt.transform]="rotateX("+s+"deg)"}},o.prototype.findNearestValidWheel=function(t){t=t>0?0:t<this.scroll.maxScrollY?this.scroll.maxScrollY:t;for(var e=Math.abs(Math.round(-t/this.itemHeight)),r=e,i=this.items,n=this.options.wheelDisabledItemClass;e>=0&&J(i[e],n);)e--;if(e<0)for(e=r;e<=i.length-1&&J(i[e],n);)e++;return e===i.length&&(e=r),{index:this.wheelItemsAllDisabled?-1:e,y:-e*this.itemHeight}},o.prototype.checkWheelAllDisabled=function(){var t=this.options.wheelDisabledItemClass,e=this.items;this.wheelItemsAllDisabled=!0;for(var r=0;r<e.length;r++)if(!J(e[r],t)){this.wheelItemsAllDisabled=!1;break}},o.pluginName="wheel",o}();const Q=Array.isArray,Be=o=>typeof o=="object"&&o!==null;function ct(o){return Q(o)&&o.length===3}function _e(){const e=new Date,r=e.getFullYear(),i=e.getMonth()+1,n=e.getDate(),s=c.ref(r),l=c.ref(i),h=g(1900,2100),a=g(1,12),u=c.computed(()=>{const d=[4,6,9,11],S=[1,3,5,7,8,10,12],k=d.includes(l.value)?30:S.includes(l.value)?31:v(s.value)?29:28;return g(1,k)}),p=c.computed(()=>[h,a,u.value]);function v(d){return d%4===0&&(d%100!==0||d%400===0)}function g(d,S){const k=[];for(let C=d;C<=S;C++)k.push(C);return k}function m(d){return(ct(d)?d:[r,i,n]).map((k,C)=>{const X=p.value[C].indexOf(k);return X>-1?X:0})}function b(d){const[S,k]=d;s.value=p.value[0][S],l.value=p.value[1][k]}return{selectYear:s,selectMonth:l,dateList:p,updateDateSelect:b,getDateAnchors:m}}function Ae(){const o=i(0,23),t=i(0,59),e=i(0,59),r=c.ref([]);n();function i(l,h){const a=[];for(let u=l;u<=h;u++)a.push(`${u}`.padStart(2,"0"));return a}function n(){const l=new Date,h=l.getHours(),a=l.getMinutes(),u=l.getSeconds();r.value=[h,a,u]}function s(l){return(ct(l)?l:r.value).map(a=>+a)}return{timeList:[o,t,e],updateDefaultTime:n,getTimeAnchors:s}}me.use(De);function Ye(o,t){const e=c.ref([]),r=c.ref(),i=c.ref([]),n=c.computed(()=>o.type==="date"),s=c.computed(()=>o.type==="time"),{selectYear:l,selectMonth:h,dateList:a,updateDateSelect:u,getDateAnchors:p}=_e(),{timeList:v,updateDefaultTime:g,getTimeAnchors:m}=Ae(),b=c.computed(()=>n.value?p(o.anchor):s.value?m(o.anchor):Q(o.anchor)?o.anchor:[o.anchor]);async function d(f=!1){f?S():k(),await c.nextTick(),e.value.forEach((T,y)=>C(y)),!f&&He(),Ne()}function S(){const f={date:a==null?void 0:a.value,time:v},T=o.type,w=Q(o.data[0])?[...o.data]:[o.data];e.value=f[T]??w}function k(){!n.value&&!s.value||(n.value&&u(b.value),s.value&&!ct(o.anchor)&&g())}function C(f){var w;const T=(w=r.value)==null?void 0:w.children[f];if(!T)return;let y=i.value[f];if(y)y.refresh();else{const pt=F(T,{wheel:{selectedIndex:0,rotate:25},swipeTime:o.swipeTime??500});y=i.value[f]=pt,y.on("scrollEnd",()=>X(f))}return y}function X(f){if(!n.value||f===2)return;const T=i.value[f].getSelectedIndex(),y=a.value[f][T];f===0&&(l.value=y),f===1&&(h.value=y),d(!0)}function He(){i.value.forEach((f,T)=>{var w;const y=(w=b.value)==null?void 0:w[T];f.wheelTo(y??0)})}function Ne(){const f=e.value.length;if(i.value.length<=f)return;i.value.splice(f).forEach(y=>y.destroy())}function Fe(){t("cancel"),ut()}function We(){i.value.some(w=>w.isInTransition)&&Ke();const{item:T,anchor:y}=Re();t("confirm",T),t("update:anchor",y),ut()}function ut(){t("update:isShowPicker",!1)}function Ke(){i.value.forEach(f=>f.stop())}function Re(){const{item:f,anchor:T}=i.value.reduce((y,w,pt)=>{const Lt=w.getSelectedIndex(),ft=e.value[pt][Lt];return y.item.push(s.value?+ft:ft),y.anchor.push(n.value?ft:Lt),y},{item:[],anchor:[]});return f.length>1?{item:f,anchor:T}:{item:f[0],anchor:T[0]}}return c.watch(()=>o.data,()=>d(!0),{immediate:!0}),c.watch(()=>o.isShowPicker,f=>f&&d()),c.watch(()=>o.type,()=>{k(),d(!0)}),{pickerData:e,wheelWrapper:r,cancel:Fe,confirm:We,closePicker:ut}}const It=o=>(c.pushScopeId("data-v-78632b89"),o=o(),c.popScopeId(),o),Me={class:"picker"},Xe={class:"picker_title"},Oe={class:"picker_panel"},Ie=It(()=>c.createElementVNode("div",{class:"picker_mask_top"},null,-1)),Le=It(()=>c.createElementVNode("div",{class:"picker_mask_bottom"},null,-1)),ze={class:"picker_wheel_scroll"},ht=((o,t)=>{const e=o.__vccOpts||o;for(const[r,i]of t)e[r]=i;return e})(c.defineComponent({__name:"Picker",props:{data:{default:()=>[]},isShowPicker:{type:Boolean,default:!1},options:{default:()=>({})},anchor:{},showKey:{},swipeTime:{default:500},type:{default:""}},emits:["update:isShowPicker","update:anchor","cancel","confirm"],setup(o,{emit:t}){const e=o,r=t,i=c.computed(()=>({cancelClass:"",confirmClass:"",titleClass:"",cancelColor:"#999",confirmColor:"#42b983",titleColor:"",cancelText:"Cancel",confirmText:"Confirm",titleText:"",...e.options})),n=c.computed(()=>i.value.cancelColor),s=c.computed(()=>i.value.confirmColor),l=c.computed(()=>i.value.titleColor),h=c.computed(()=>Q(e.showKey)?e.showKey:[e.showKey]),{pickerData:a,wheelWrapper:u,cancel:p,confirm:v,closePicker:g}=Ye(e,r);return(m,b)=>(c.openBlock(),c.createElementBlock(c.Fragment,null,[c.createVNode(c.Transition,{name:"fade"},{default:c.withCtx(()=>[c.withDirectives(c.createElementVNode("div",{class:"mask",onClick:b[0]||(b[0]=(...d)=>c.unref(g)&&c.unref(g)(...d))},null,512),[[c.vShow,m.isShowPicker]])]),_:1}),c.createVNode(c.Transition,{name:"slide"},{default:c.withCtx(()=>[c.withDirectives(c.createElementVNode("div",Me,[c.createElementVNode("div",Xe,[c.createElementVNode("button",{class:c.normalizeClass(["picker_cancel",i.value.cancelClass]),style:c.normalizeStyle({color:n.value}),onClick:b[1]||(b[1]=(...d)=>c.unref(p)&&c.unref(p)(...d))},c.toDisplayString(i.value.cancelText),7),c.createElementVNode("button",{class:c.normalizeClass(["picker_confirm",i.value.confirmClass]),style:c.normalizeStyle({color:s.value}),onClick:b[2]||(b[2]=(...d)=>c.unref(v)&&c.unref(v)(...d))},c.toDisplayString(i.value.confirmText),7),c.createElementVNode("h4",{class:c.normalizeClass([i.value.titleClass]),style:c.normalizeStyle({color:l.value})},c.toDisplayString(i.value.titleText),7)]),c.createElementVNode("div",Oe,[Ie,Le,c.createElementVNode("div",{ref_key:"wheelWrapper",ref:u,class:"picker_wheel_wrapper"},[(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(c.unref(a),(d,S)=>(c.openBlock(),c.createElementBlock("div",{key:S,class:"picker_wheel"},[c.createElementVNode("ul",ze,[(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(d,(k,C)=>{var X;return c.openBlock(),c.createElementBlock("li",{key:C,class:"picker_wheel_item"},c.toDisplayString((X=h.value)!=null&&X[S]&&c.unref(Be)(k)?k[h.value[S]]:k),1)}),128))])]))),128))],512)])],512),[[c.vShow,m.isShowPicker]])]),_:1})],64))}}),[["__scopeId","data-v-78632b89"]]);return ht.install=function(o){o.component("Picker",ht)},ht});
|
|
23
|
+
*/var W=typeof window<"u",Z=W&&navigator.userAgent.toLowerCase();Z&&Z.indexOf("android")>0,function(){if(typeof Z=="string"){var o=/os (\d\d?_\d(_\d)?)/,t=o.exec(Z);if(!t)return!1;var e=t[1].split("_").map(function(r){return parseInt(r,10)});return e[0]===13&&e[1]>=4}return!1}();var ye=!1;if(W){var ge="test-passive";try{var Mt={};Object.defineProperty(Mt,"passive",{get:function(){ye=!0}}),window.addEventListener(ge,function(){},Mt)}catch{}}var ke=function(o,t){for(var e in t)o[e]=t[e];return o},Xt=W&&document.createElement("div").style,z=function(){if(!W)return!1;for(var o=[{key:"standard",value:"transform"},{key:"webkit",value:"webkitTransform"},{key:"Moz",value:"MozTransform"},{key:"O",value:"OTransform"},{key:"ms",value:"msTransform"}],t=0,e=o;t<e.length;t++){var r=e[t];if(Xt[r.value]!==void 0)return r.key}return!1}();function x(o){return z===!1?o:z==="standard"?o==="transitionEnd"?"transitionend":o:z+o.charAt(0).toUpperCase()+o.substr(1)}z&&z!=="standard"&&""+z.toLowerCase();var Te=x("transform"),be=x("transition");W&&x("perspective")in Xt;var lt={transform:Te,transition:be,transitionTimingFunction:x("transitionTimingFunction"),transitionDuration:x("transitionDuration"),transitionDelay:x("transitionDelay"),transformOrigin:x("transformOrigin"),transitionEnd:x("transitionEnd"),transitionProperty:x("transitionProperty")};function J(o,t){var e=new RegExp("(^|\\s)"+t+"(\\s|$)");return e.test(o.className)}function Se(o){return Array.prototype.slice.call(o,0)}var we={swipe:{style:"cubic-bezier(0.23, 1, 0.32, 1)",fn:function(o){return 1+--o*o*o*o*o}},swipeBounce:{style:"cubic-bezier(0.25, 0.46, 0.45, 0.94)",fn:function(o){return o*(2-o)}},bounce:{style:"cubic-bezier(0.165, 0.84, 0.44, 1)",fn:function(o){return 1- --o*o*o*o}}},Pe="plugins.wheel",Ee=[{key:"wheelTo",name:"wheelTo"},{key:"getSelectedIndex",name:"getSelectedIndex"},{key:"restorePosition",name:"restorePosition"}],xe=Ee.map(function(o){return{key:o.key,sourceKey:Pe+"."+o.name}}),Ot="wheelIndexChanged",Ce={rate:4},De=function(){function o(t){this.scroll=t,this.init()}return o.prototype.init=function(){this.handleBScroll(),this.handleOptions(),this.handleHooks(),this.refreshBoundary(),this.setSelectedIndex(this.options.selectedIndex)},o.prototype.handleBScroll=function(){this.scroll.proxy(xe),this.scroll.registerType([Ot])},o.prototype.handleOptions=function(){var t=this.scroll.options.wheel===!0?{}:this.scroll.options.wheel,e={wheelWrapperClass:"wheel-scroll",wheelItemClass:"wheel-item",rotate:25,adjustTime:400,selectedIndex:0,wheelDisabledItemClass:"wheel-disabled-item"};this.options=ke(e,t)},o.prototype.handleHooks=function(){var t=this,e=this.scroll,r=this.scroll.scroller,i=r.actionsHandler,n=r.scrollBehaviorX,s=r.scrollBehaviorY,l=r.animater,h=r.content;e.on(e.eventTypes.scrollEnd,function(a){var u=t.findNearestValidWheel(a.y).index;if(r.animater.forceStopped&&!t.isAdjustingPosition)return t.target=t.items[u],!0;t.setSelectedIndex(u),t.isAdjustingPosition&&(t.isAdjustingPosition=!1)}),this.scroll.hooks.on(this.scroll.hooks.eventTypes.refresh,function(a){a!==h&&(h=a,t.setSelectedIndex(t.options.selectedIndex,!0)),t.rotateX(t.scroll.y),t.wheelTo(t.selectedIndex,0)}),this.scroll.hooks.on(this.scroll.hooks.eventTypes.beforeInitialScrollTo,function(a){a.x=0,a.y=-(t.selectedIndex*t.itemHeight)}),r.hooks.on(r.hooks.eventTypes.checkClick,function(){var a=Se(t.items).indexOf(t.target);return a===-1||t.wheelTo(a,t.options.adjustTime,we.swipe),!0}),r.hooks.on(r.hooks.eventTypes.scrollTo,function(a){a.y=t.findNearestValidWheel(a.y).y}),r.hooks.on(r.hooks.eventTypes.minDistanceScroll,function(){var a=r.animater;a.forceStopped===!0&&(a.forceStopped=!1)}),r.hooks.on(r.hooks.eventTypes.scrollToElement,function(a,u){if(J(a,t.options.wheelItemClass))u.top=t.findNearestValidWheel(u.top).y;else return!0}),i.hooks.on(i.hooks.eventTypes.beforeStart,function(a){t.target=a.target}),n.hooks.on(n.hooks.eventTypes.computeBoundary,function(a){a.maxScrollPos=0,a.minScrollPos=0}),s.hooks.on(s.hooks.eventTypes.computeBoundary,function(a){t.items=t.scroll.scroller.content.children,t.checkWheelAllDisabled(),t.itemHeight=t.items.length>0?s.contentSize/t.items.length:0,a.maxScrollPos=-t.itemHeight*(t.items.length-1),a.minScrollPos=0}),s.hooks.on(s.hooks.eventTypes.momentum,function(a){a.rate=Ce.rate,a.destination=t.findNearestValidWheel(a.destination).y}),s.hooks.on(s.hooks.eventTypes.end,function(a){var u=t.findNearestValidWheel(s.currentPos);a.destination=u.y,a.duration=t.options.adjustTime}),l.hooks.on(l.hooks.eventTypes.time,function(a){t.transitionDuration(a)}),l.hooks.on(l.hooks.eventTypes.timeFunction,function(a){t.timeFunction(a)}),l.hooks.on(l.hooks.eventTypes.callStop,function(){var a=t.findNearestValidWheel(t.scroll.y).index;t.isAdjustingPosition=!0,t.wheelTo(a,0)}),l.translater.hooks.on(l.translater.hooks.eventTypes.translate,function(a){t.rotateX(a.y)})},o.prototype.refreshBoundary=function(){var t=this.scroll.scroller,e=t.scrollBehaviorX,r=t.scrollBehaviorY,i=t.content;e.refresh(i),r.refresh(i)},o.prototype.setSelectedIndex=function(t,e){e===void 0&&(e=!1);var r=this.selectedIndex;this.selectedIndex=t,r!==t&&!e&&this.scroll.trigger(Ot,t)},o.prototype.getSelectedIndex=function(){return this.selectedIndex},o.prototype.wheelTo=function(t,e,r){t===void 0&&(t=0),e===void 0&&(e=0);var i=-t*this.itemHeight;this.scroll.scrollTo(0,i,e,r)},o.prototype.restorePosition=function(){var t=this.scroll.pending;if(t){var e=this.getSelectedIndex();this.scroll.scroller.animater.clearTimer(),this.wheelTo(e,0)}},o.prototype.transitionDuration=function(t){for(var e=0;e<this.items.length;e++)this.items[e].style[lt.transitionDuration]=t+"ms"},o.prototype.timeFunction=function(t){for(var e=0;e<this.items.length;e++)this.items[e].style[lt.transitionTimingFunction]=t},o.prototype.rotateX=function(t){for(var e=this.options.rotate,r=e===void 0?25:e,i=0;i<this.items.length;i++){var n=r*(t/this.itemHeight+i),s=n.toFixed(3);this.items[i].style[lt.transform]="rotateX("+s+"deg)"}},o.prototype.findNearestValidWheel=function(t){t=t>0?0:t<this.scroll.maxScrollY?this.scroll.maxScrollY:t;for(var e=Math.abs(Math.round(-t/this.itemHeight)),r=e,i=this.items,n=this.options.wheelDisabledItemClass;e>=0&&J(i[e],n);)e--;if(e<0)for(e=r;e<=i.length-1&&J(i[e],n);)e++;return e===i.length&&(e=r),{index:this.wheelItemsAllDisabled?-1:e,y:-e*this.itemHeight}},o.prototype.checkWheelAllDisabled=function(){var t=this.options.wheelDisabledItemClass,e=this.items;this.wheelItemsAllDisabled=!0;for(var r=0;r<e.length;r++)if(!J(e[r],t)){this.wheelItemsAllDisabled=!1;break}},o.pluginName="wheel",o}();const Q=Array.isArray,Be=o=>typeof o=="object"&&o!==null;function ct(o){return Q(o)&&o.length===3}function _e(){const e=new Date,r=e.getFullYear(),i=e.getMonth()+1,n=e.getDate(),s=c.ref(r),l=c.ref(i),h=g(1900,2100),a=g(1,12),u=c.computed(()=>{const d=[4,6,9,11],S=[1,3,5,7,8,10,12],k=d.includes(l.value)?30:S.includes(l.value)?31:v(s.value)?29:28;return g(1,k)}),p=c.computed(()=>[h,a,u.value]);function v(d){return d%4===0&&(d%100!==0||d%400===0)}function g(d,S){const k=[];for(let C=d;C<=S;C++)k.push(C);return k}function m(d){return(ct(d)?d:[r,i,n]).map((k,C)=>{const X=p.value[C].indexOf(k);return X>-1?X:0})}function b(d){const[S,k]=d;s.value=p.value[0][S],l.value=p.value[1][k]}return{selectYear:s,selectMonth:l,dateList:p,updateDateSelect:b,getDateAnchors:m}}function Ae(){const o=i(0,23),t=i(0,59),e=i(0,59),r=c.ref([]);n();function i(l,h){const a=[];for(let u=l;u<=h;u++)a.push(`${u}`.padStart(2,"0"));return a}function n(){const l=new Date,h=l.getHours(),a=l.getMinutes(),u=l.getSeconds();r.value=[h,a,u]}function s(l){return(ct(l)?l:r.value).map(a=>+a)}return{timeList:[o,t,e],updateDefaultTime:n,getTimeAnchors:s}}me.use(De);function Ye(o,t){const e=c.ref([]),r=c.ref(),i=c.ref([]),n=c.computed(()=>o.type==="date"),s=c.computed(()=>o.type==="time"),{selectYear:l,selectMonth:h,dateList:a,updateDateSelect:u,getDateAnchors:p}=_e(),{timeList:v,updateDefaultTime:g,getTimeAnchors:m}=Ae(),b=c.computed(()=>n.value?p(o.anchor):s.value?m(o.anchor):Q(o.anchor)?o.anchor:[o.anchor]);async function d(f=!1){f?S():k(),await c.nextTick(),e.value.forEach((T,y)=>C(y)),!f&&He(),Ne()}function S(){const f={date:a==null?void 0:a.value,time:v},T=o.type,w=Q(o.data[0])?[...o.data]:[o.data];e.value=f[T]??w}function k(){!n.value&&!s.value||(n.value&&u(b.value),s.value&&!ct(o.anchor)&&g())}function C(f){var w;const T=(w=r.value)==null?void 0:w.children[f];if(!T)return;let y=i.value[f];if(y)y.refresh();else{const pt=F(T,{wheel:{selectedIndex:0,rotate:25},swipeTime:o.swipeTime??500});y=i.value[f]=pt,y.on("scrollEnd",()=>X(f))}return y}function X(f){if(!n.value||f===2)return;const T=i.value[f].getSelectedIndex(),y=a.value[f][T];f===0&&(l.value=y),f===1&&(h.value=y),d(!0)}function He(){i.value.forEach((f,T)=>{var w;const y=(w=b.value)==null?void 0:w[T];f.wheelTo(y??0)})}function Ne(){const f=e.value.length;if(i.value.length<=f)return;i.value.splice(f).forEach(y=>y.destroy())}function Fe(){t("cancel"),ut()}function We(){i.value.some(w=>w.isInTransition)&&Ke();const{item:T,anchor:y}=Re();t("confirm",T),t("update:anchor",y),ut()}function ut(){t("update:isShowPicker",!1)}function Ke(){i.value.forEach(f=>f.stop())}function Re(){const{item:f,anchor:T}=i.value.reduce((y,w,pt)=>{const Lt=w.getSelectedIndex(),ft=e.value[pt][Lt];return y.item.push(s.value?+ft:ft),y.anchor.push(n.value?ft:Lt),y},{item:[],anchor:[]});return f.length>1?{item:f,anchor:T}:{item:f[0],anchor:T[0]}}return c.watch(()=>o.data,()=>d(!0),{immediate:!0}),c.watch(()=>o.isShowPicker,f=>f&&d()),c.watch(()=>o.type,()=>{k(),d(!0)}),{pickerData:e,wheelWrapper:r,cancel:Fe,confirm:We,closePicker:ut}}const It=o=>(c.pushScopeId("data-v-3207fa1f"),o=o(),c.popScopeId(),o),Me={class:"picker"},Xe={class:"picker_title"},Oe={class:"picker_panel"},Ie=It(()=>c.createElementVNode("div",{class:"picker_mask_top"},null,-1)),Le=It(()=>c.createElementVNode("div",{class:"picker_mask_bottom"},null,-1)),ze={class:"picker_wheel_scroll"},ht=((o,t)=>{const e=o.__vccOpts||o;for(const[r,i]of t)e[r]=i;return e})(c.defineComponent({__name:"Picker",props:{data:{default:()=>[]},isShowPicker:{type:Boolean,default:!1},options:{default:()=>({})},anchor:{},showKey:{},swipeTime:{default:500},type:{default:""}},emits:["update:isShowPicker","update:anchor","cancel","confirm"],setup(o,{emit:t}){const e=o,r=t,i=c.computed(()=>({cancelClass:"",confirmClass:"",titleClass:"",cancelColor:"#999",confirmColor:"#42b983",titleColor:"",cancelText:"Cancel",confirmText:"Confirm",titleText:"",...e.options})),n=c.computed(()=>i.value.cancelColor),s=c.computed(()=>i.value.confirmColor),l=c.computed(()=>i.value.titleColor),h=c.computed(()=>Q(e.showKey)?e.showKey:[e.showKey]),{pickerData:a,wheelWrapper:u,cancel:p,confirm:v,closePicker:g}=Ye(e,r);return(m,b)=>(c.openBlock(),c.createElementBlock("div",null,[c.createVNode(c.Transition,{name:"fade"},{default:c.withCtx(()=>[c.withDirectives(c.createElementVNode("div",{class:"mask",onClick:b[0]||(b[0]=(...d)=>c.unref(g)&&c.unref(g)(...d))},null,512),[[c.vShow,m.isShowPicker]])]),_:1}),c.createVNode(c.Transition,{name:"slide"},{default:c.withCtx(()=>[c.withDirectives(c.createElementVNode("div",Me,[c.createElementVNode("div",Xe,[c.createElementVNode("button",{class:c.normalizeClass(["picker_cancel",i.value.cancelClass]),style:c.normalizeStyle({color:n.value}),onClick:b[1]||(b[1]=(...d)=>c.unref(p)&&c.unref(p)(...d))},c.toDisplayString(i.value.cancelText),7),c.createElementVNode("button",{class:c.normalizeClass(["picker_confirm",i.value.confirmClass]),style:c.normalizeStyle({color:s.value}),onClick:b[2]||(b[2]=(...d)=>c.unref(v)&&c.unref(v)(...d))},c.toDisplayString(i.value.confirmText),7),c.createElementVNode("h4",{class:c.normalizeClass([i.value.titleClass]),style:c.normalizeStyle({color:l.value})},c.toDisplayString(i.value.titleText),7)]),c.createElementVNode("div",Oe,[Ie,Le,c.createElementVNode("div",{ref_key:"wheelWrapper",ref:u,class:"picker_wheel_wrapper"},[(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(c.unref(a),(d,S)=>(c.openBlock(),c.createElementBlock("div",{key:S,class:"picker_wheel"},[c.createElementVNode("ul",ze,[(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(d,(k,C)=>{var X;return c.openBlock(),c.createElementBlock("li",{key:C,class:"picker_wheel_item"},c.toDisplayString((X=h.value)!=null&&X[S]&&c.unref(Be)(k)?k[h.value[S]]:k),1)}),128))])]))),128))],512)])],512),[[c.vShow,m.isShowPicker]])]),_:1})]))}}),[["__scopeId","data-v-3207fa1f"]]);return ht.install=function(o){o.component("Picker",ht)},ht});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@component-hook/picker",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2-alpha.0",
|
|
4
4
|
"description": "Picker component with vue3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"url": "https://github.com/tzuyi0817/component-hook.git",
|
|
24
24
|
"directory": "packages/picker"
|
|
25
25
|
},
|
|
26
|
-
"homepage": "https://github.com/tzuyi0817/component-hook#readme",
|
|
26
|
+
"homepage": "https://github.com/tzuyi0817/component-hook/tree/master/packages/picker#readme",
|
|
27
27
|
"bugs": {
|
|
28
28
|
"url": "https://github.com/tzuyi0817/component-hook/issues"
|
|
29
29
|
},
|