@component-hook/picker 0.1.1 → 0.1.2-alpha.1
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 -62
- 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,4 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import { ref as L, computed as P, watch as lt, nextTick as ne, defineComponent as se, openBlock as z, createElementBlock as K, Fragment as ct, createVNode as wt, Transition as Pt, withCtx as Et, withDirectives as Ct, createElementVNode as w, unref as x, vShow as Dt, normalizeClass as ht, normalizeStyle as ut, toDisplayString as j, renderList as Bt, pushScopeId as ae, popScopeId as le } from "vue";
|
|
1
|
+
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
2
|
/*!
|
|
4
3
|
* better-scroll / core
|
|
5
4
|
* (c) 2016-2023 ustbhuangyi
|
|
@@ -19,15 +18,15 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
19
18
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
20
19
|
PERFORMANCE OF THIS SOFTWARE.
|
|
21
20
|
***************************************************************************** */
|
|
22
|
-
var
|
|
23
|
-
return
|
|
21
|
+
var dt = function(o, t) {
|
|
22
|
+
return dt = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, r) {
|
|
24
23
|
e.__proto__ = r;
|
|
25
24
|
} || function(e, r) {
|
|
26
25
|
for (var i in r) Object.prototype.hasOwnProperty.call(r, i) && (e[i] = r[i]);
|
|
27
|
-
},
|
|
26
|
+
}, dt(o, t);
|
|
28
27
|
};
|
|
29
28
|
function rt(o, t) {
|
|
30
|
-
|
|
29
|
+
dt(o, t);
|
|
31
30
|
function e() {
|
|
32
31
|
this.constructor = o;
|
|
33
32
|
}
|
|
@@ -166,18 +165,18 @@ if (E) {
|
|
|
166
165
|
function O() {
|
|
167
166
|
return window.performance && window.performance.now && window.performance.timing ? window.performance.now() + window.performance.timing.navigationStart : +/* @__PURE__ */ new Date();
|
|
168
167
|
}
|
|
169
|
-
var
|
|
168
|
+
var mt = function(o, t) {
|
|
170
169
|
for (var e in t)
|
|
171
170
|
o[e] = t[e];
|
|
172
171
|
return o;
|
|
173
172
|
};
|
|
174
|
-
function
|
|
173
|
+
function yt(o) {
|
|
175
174
|
return o == null;
|
|
176
175
|
}
|
|
177
176
|
function At(o, t, e) {
|
|
178
177
|
return o < t ? t : o > e ? e : o;
|
|
179
178
|
}
|
|
180
|
-
var
|
|
179
|
+
var kt = E && document.createElement("div").style, H = function() {
|
|
181
180
|
if (!E)
|
|
182
181
|
return !1;
|
|
183
182
|
for (var o = [
|
|
@@ -203,7 +202,7 @@ var Tt = E && document.createElement("div").style, H = function() {
|
|
|
203
202
|
}
|
|
204
203
|
], t = 0, e = o; t < e.length; t++) {
|
|
205
204
|
var r = e[t];
|
|
206
|
-
if (
|
|
205
|
+
if (kt[r.value] !== void 0)
|
|
207
206
|
return r.key;
|
|
208
207
|
}
|
|
209
208
|
return !1;
|
|
@@ -238,7 +237,7 @@ function Yt(o) {
|
|
|
238
237
|
};
|
|
239
238
|
}
|
|
240
239
|
H && H !== "standard" && "" + H.toLowerCase();
|
|
241
|
-
var me = D("transform"), $t = D("transition"), ye = E && D("perspective") in
|
|
240
|
+
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
241
|
transform: me,
|
|
243
242
|
transition: $t,
|
|
244
243
|
transitionTimingFunction: D("transitionTimingFunction"),
|
|
@@ -247,7 +246,7 @@ var me = D("transform"), $t = D("transition"), ye = E && D("perspective") in Tt,
|
|
|
247
246
|
transformOrigin: D("transformOrigin"),
|
|
248
247
|
transitionEnd: D("transitionEnd"),
|
|
249
248
|
transitionProperty: D("transitionProperty")
|
|
250
|
-
},
|
|
249
|
+
}, ut = {
|
|
251
250
|
touchstart: 1,
|
|
252
251
|
touchmove: 1,
|
|
253
252
|
touchend: 1,
|
|
@@ -298,7 +297,7 @@ function jt(o, t) {
|
|
|
298
297
|
};
|
|
299
298
|
if (typeof MouseEvent < "u")
|
|
300
299
|
try {
|
|
301
|
-
i = new MouseEvent(t,
|
|
300
|
+
i = new MouseEvent(t, mt(N({
|
|
302
301
|
bubbles: n,
|
|
303
302
|
cancelable: s
|
|
304
303
|
}, u), r));
|
|
@@ -308,7 +307,7 @@ function jt(o, t) {
|
|
|
308
307
|
else
|
|
309
308
|
v();
|
|
310
309
|
function v() {
|
|
311
|
-
i = document.createEvent("Event"), i.initEvent(t, n, s),
|
|
310
|
+
i = document.createEvent("Event"), i.initEvent(t, n, s), mt(i, r);
|
|
312
311
|
}
|
|
313
312
|
i.forwardedTouchEvent = !0, i._constructed = !0, o.target.dispatchEvent(i);
|
|
314
313
|
}
|
|
@@ -350,7 +349,7 @@ var qt = function() {
|
|
|
350
349
|
window.clearTimeout(o);
|
|
351
350
|
} : Ut;
|
|
352
351
|
}(), _t = function(o) {
|
|
353
|
-
},
|
|
352
|
+
}, pt = {
|
|
354
353
|
enumerable: !0,
|
|
355
354
|
configurable: !0,
|
|
356
355
|
get: _t,
|
|
@@ -369,11 +368,11 @@ var qt = function() {
|
|
|
369
368
|
o[r.pop()] = e;
|
|
370
369
|
};
|
|
371
370
|
function Ee(o, t, e) {
|
|
372
|
-
|
|
371
|
+
pt.get = function() {
|
|
373
372
|
return we(this, t);
|
|
374
|
-
},
|
|
373
|
+
}, pt.set = function(i) {
|
|
375
374
|
Pe(this, t, i);
|
|
376
|
-
}, Object.defineProperty(o, e,
|
|
375
|
+
}, Object.defineProperty(o, e, pt);
|
|
377
376
|
}
|
|
378
377
|
var Y = (
|
|
379
378
|
/** @class */
|
|
@@ -506,7 +505,7 @@ var Y = (
|
|
|
506
505
|
bottom: !1,
|
|
507
506
|
left: !1
|
|
508
507
|
}, n;
|
|
509
|
-
return typeof e == "object" ? n =
|
|
508
|
+
return typeof e == "object" ? n = mt(r, e) : n = e ? r : i, n;
|
|
510
509
|
}, t;
|
|
511
510
|
}(Ce)
|
|
512
511
|
), Be = (
|
|
@@ -565,7 +564,7 @@ var Y = (
|
|
|
565
564
|
}, o.prototype.setInitiated = function(t) {
|
|
566
565
|
t === void 0 && (t = 0), this.initiated = t;
|
|
567
566
|
}, o.prototype.start = function(t) {
|
|
568
|
-
var e =
|
|
567
|
+
var e = ut[t.type];
|
|
569
568
|
if (!(this.initiated && this.initiated !== e)) {
|
|
570
569
|
if (this.setInitiated(e), ke(t.target, this.options.tagException)) {
|
|
571
570
|
this.setInitiated();
|
|
@@ -578,7 +577,7 @@ var Y = (
|
|
|
578
577
|
}
|
|
579
578
|
}
|
|
580
579
|
}, o.prototype.move = function(t) {
|
|
581
|
-
if (
|
|
580
|
+
if (ut[t.type] === this.initiated) {
|
|
582
581
|
this.beforeHandler(t, "move");
|
|
583
582
|
var e = t.touches ? t.touches[0] : t, r = e.pageX - this.pointX, i = e.pageY - this.pointY;
|
|
584
583
|
if (this.pointX = e.pageX, this.pointY = e.pageY, !this.hooks.trigger(this.hooks.eventTypes.move, {
|
|
@@ -591,7 +590,7 @@ var Y = (
|
|
|
591
590
|
}
|
|
592
591
|
}
|
|
593
592
|
}, o.prototype.end = function(t) {
|
|
594
|
-
|
|
593
|
+
ut[t.type] === this.initiated && (this.setInitiated(), this.beforeHandler(t, "end"), this.hooks.trigger(this.hooks.eventTypes.end, t));
|
|
595
594
|
}, o.prototype.click = function(t) {
|
|
596
595
|
this.hooks.trigger(this.hooks.eventTypes.click, t);
|
|
597
596
|
}, o.prototype.setContent = function(t) {
|
|
@@ -602,7 +601,7 @@ var Y = (
|
|
|
602
601
|
this.wrapperEventRegister.destroy(), this.targetEventRegister.destroy(), this.hooks.destroy();
|
|
603
602
|
}, o;
|
|
604
603
|
}()
|
|
605
|
-
),
|
|
604
|
+
), ft = {
|
|
606
605
|
x: ["translateX", "px"],
|
|
607
606
|
y: ["translateY", "px"]
|
|
608
607
|
}, xe = (
|
|
@@ -620,10 +619,10 @@ var Y = (
|
|
|
620
619
|
}, o.prototype.translate = function(t) {
|
|
621
620
|
var e = [];
|
|
622
621
|
Object.keys(t).forEach(function(r) {
|
|
623
|
-
if (
|
|
624
|
-
var i =
|
|
622
|
+
if (ft[r]) {
|
|
623
|
+
var i = ft[r][0];
|
|
625
624
|
if (i) {
|
|
626
|
-
var n =
|
|
625
|
+
var n = ft[r][1], s = t[r];
|
|
627
626
|
e.push(i + "(" + s + n + ")");
|
|
628
627
|
}
|
|
629
628
|
}
|
|
@@ -1008,7 +1007,7 @@ function Lt(o, t, e, r) {
|
|
|
1008
1007
|
}, {});
|
|
1009
1008
|
return i.scrollable = !!o[t], i.bounces = e, i.rect = r, i;
|
|
1010
1009
|
}
|
|
1011
|
-
function
|
|
1010
|
+
function gt(o, t, e) {
|
|
1012
1011
|
e.forEach(function(r) {
|
|
1013
1012
|
var i, n;
|
|
1014
1013
|
typeof r == "string" ? i = n = r : (i = r.source, n = r.target), o.on(i, function() {
|
|
@@ -1097,7 +1096,7 @@ var Ht = 1, We = (
|
|
|
1097
1096
|
var t = this;
|
|
1098
1097
|
this.animater.hooks.on(this.animater.hooks.eventTypes.end, function(e) {
|
|
1099
1098
|
t.resetPosition(t.options.bounceTime) || (t.animater.setPending(!1), t.hooks.trigger(t.hooks.eventTypes.scrollEnd, e));
|
|
1100
|
-
}),
|
|
1099
|
+
}), gt(this.animater.hooks, this.hooks, [
|
|
1101
1100
|
{
|
|
1102
1101
|
source: this.animater.hooks.eventTypes.move,
|
|
1103
1102
|
target: this.hooks.eventTypes.scroll
|
|
@@ -1109,7 +1108,7 @@ var Ht = 1, We = (
|
|
|
1109
1108
|
]);
|
|
1110
1109
|
}, o.prototype.bindActions = function() {
|
|
1111
1110
|
var t = this, e = this.actions;
|
|
1112
|
-
|
|
1111
|
+
gt(e.hooks, this.hooks, [
|
|
1113
1112
|
{
|
|
1114
1113
|
source: e.hooks.eventTypes.start,
|
|
1115
1114
|
target: this.hooks.eventTypes.beforeStart
|
|
@@ -1162,7 +1161,7 @@ var Ht = 1, We = (
|
|
|
1162
1161
|
newX: t.x,
|
|
1163
1162
|
newY: t.y
|
|
1164
1163
|
}, i = this.scrollBehaviorX.end(e), n = this.scrollBehaviorY.end(e);
|
|
1165
|
-
if (r.newX =
|
|
1164
|
+
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
1165
|
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
1166
|
}, o.prototype.checkClick = function(t) {
|
|
1168
1167
|
var e = {
|
|
@@ -1290,7 +1289,7 @@ var Ht = 1, We = (
|
|
|
1290
1289
|
var r = e.pluginName, i = t.plugins.some(function(n) {
|
|
1291
1290
|
return e === n.ctor;
|
|
1292
1291
|
});
|
|
1293
|
-
return i ? t :
|
|
1292
|
+
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
1293
|
name: r,
|
|
1295
1294
|
applyOrder: e.applyOrder,
|
|
1296
1295
|
ctor: e
|
|
@@ -1326,7 +1325,7 @@ var Ht = 1, We = (
|
|
|
1326
1325
|
e && (e.tagName === "INPUT" || e.tagName === "TEXTAREA") && e.blur();
|
|
1327
1326
|
});
|
|
1328
1327
|
}, t.prototype.eventBubbling = function() {
|
|
1329
|
-
|
|
1328
|
+
gt(this.scroller.hooks, this, [
|
|
1330
1329
|
this.eventTypes.beforeScrollStart,
|
|
1331
1330
|
this.eventTypes.scrollStart,
|
|
1332
1331
|
this.eventTypes.scroll,
|
|
@@ -1442,7 +1441,7 @@ function B(o) {
|
|
|
1442
1441
|
F && F !== "standard" && "" + F.toLowerCase();
|
|
1443
1442
|
var Ve = B("transform"), $e = B("transition");
|
|
1444
1443
|
$ && B("perspective") in Zt;
|
|
1445
|
-
var
|
|
1444
|
+
var vt = {
|
|
1446
1445
|
transform: Ve,
|
|
1447
1446
|
transition: $e,
|
|
1448
1447
|
transitionTimingFunction: B("transitionTimingFunction"),
|
|
@@ -1587,14 +1586,14 @@ var Ue = {
|
|
|
1587
1586
|
}
|
|
1588
1587
|
}, o.prototype.transitionDuration = function(t) {
|
|
1589
1588
|
for (var e = 0; e < this.items.length; e++)
|
|
1590
|
-
this.items[e].style[
|
|
1589
|
+
this.items[e].style[vt.transitionDuration] = t + "ms";
|
|
1591
1590
|
}, o.prototype.timeFunction = function(t) {
|
|
1592
1591
|
for (var e = 0; e < this.items.length; e++)
|
|
1593
|
-
this.items[e].style[
|
|
1592
|
+
this.items[e].style[vt.transitionTimingFunction] = t;
|
|
1594
1593
|
}, o.prototype.rotateX = function(t) {
|
|
1595
1594
|
for (var e = this.options.rotate, r = e === void 0 ? 25 : e, i = 0; i < this.items.length; i++) {
|
|
1596
1595
|
var n = r * (t / this.itemHeight + i), s = n.toFixed(3);
|
|
1597
|
-
this.items[i].style[
|
|
1596
|
+
this.items[i].style[vt.transform] = "rotateX(" + s + "deg)";
|
|
1598
1597
|
}
|
|
1599
1598
|
}, o.prototype.findNearestValidWheel = function(t) {
|
|
1600
1599
|
t = t > 0 ? 0 : t < this.scroll.maxScrollY ? this.scroll.maxScrollY : t;
|
|
@@ -1619,7 +1618,7 @@ var Ue = {
|
|
|
1619
1618
|
}()
|
|
1620
1619
|
);
|
|
1621
1620
|
const ot = Array.isArray, to = (o) => typeof o == "object" && o !== null;
|
|
1622
|
-
function
|
|
1621
|
+
function Tt(o) {
|
|
1623
1622
|
return ot(o) && o.length === 3;
|
|
1624
1623
|
}
|
|
1625
1624
|
function eo() {
|
|
@@ -1637,7 +1636,7 @@ function eo() {
|
|
|
1637
1636
|
return g;
|
|
1638
1637
|
}
|
|
1639
1638
|
function d(f) {
|
|
1640
|
-
return (
|
|
1639
|
+
return (Tt(f) ? f : [r, i, n]).map((g, C) => {
|
|
1641
1640
|
const M = u.value[C].indexOf(g);
|
|
1642
1641
|
return M > -1 ? M : 0;
|
|
1643
1642
|
});
|
|
@@ -1668,7 +1667,7 @@ function oo() {
|
|
|
1668
1667
|
r.value = [c, a, h];
|
|
1669
1668
|
}
|
|
1670
1669
|
function s(l) {
|
|
1671
|
-
return (
|
|
1670
|
+
return (Tt(l) ? l : r.value).map((a) => +a);
|
|
1672
1671
|
}
|
|
1673
1672
|
return {
|
|
1674
1673
|
timeList: [o, t, e],
|
|
@@ -1690,7 +1689,7 @@ function ro(o, t) {
|
|
|
1690
1689
|
e.value = p[k] ?? b;
|
|
1691
1690
|
}
|
|
1692
1691
|
function g() {
|
|
1693
|
-
!n.value && !s.value || (n.value && h(T.value), s.value && !
|
|
1692
|
+
!n.value && !s.value || (n.value && h(T.value), s.value && !Tt(o.anchor) && y());
|
|
1694
1693
|
}
|
|
1695
1694
|
function C(p) {
|
|
1696
1695
|
var b;
|
|
@@ -1745,8 +1744,8 @@ function ro(o, t) {
|
|
|
1745
1744
|
function ie() {
|
|
1746
1745
|
const { item: p, anchor: k } = i.value.reduce(
|
|
1747
1746
|
(m, b, st) => {
|
|
1748
|
-
const
|
|
1749
|
-
return m.item.push(s.value ? +at : at), m.anchor.push(n.value ? at :
|
|
1747
|
+
const St = b.getSelectedIndex(), at = e.value[st][St];
|
|
1748
|
+
return m.item.push(s.value ? +at : at), m.anchor.push(n.value ? at : St), m;
|
|
1750
1749
|
},
|
|
1751
1750
|
{ item: [], anchor: [] }
|
|
1752
1751
|
);
|
|
@@ -1772,7 +1771,7 @@ function ro(o, t) {
|
|
|
1772
1771
|
closePicker: nt
|
|
1773
1772
|
};
|
|
1774
1773
|
}
|
|
1775
|
-
const Jt = (o) => (ae("data-v-
|
|
1774
|
+
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
1775
|
__name: "Picker",
|
|
1777
1776
|
props: {
|
|
1778
1777
|
data: { default: () => [] },
|
|
@@ -1797,38 +1796,38 @@ const Jt = (o) => (ae("data-v-78632b89"), o = o(), le(), o), io = { class: "pick
|
|
|
1797
1796
|
titleText: "",
|
|
1798
1797
|
...e.options
|
|
1799
1798
|
})), 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
|
-
|
|
1799
|
+
return (d, T) => (z(), K("div", null, [
|
|
1800
|
+
bt(wt, { name: "fade" }, {
|
|
1801
|
+
default: Pt(() => [
|
|
1802
|
+
Et(w("div", {
|
|
1804
1803
|
class: "mask",
|
|
1805
1804
|
onClick: T[0] || (T[0] = //@ts-ignore
|
|
1806
1805
|
(...f) => x(y) && x(y)(...f))
|
|
1807
1806
|
}, null, 512), [
|
|
1808
|
-
[
|
|
1807
|
+
[Ct, d.isShowPicker]
|
|
1809
1808
|
])
|
|
1810
1809
|
]),
|
|
1811
1810
|
_: 1
|
|
1812
1811
|
}),
|
|
1813
|
-
wt
|
|
1814
|
-
default:
|
|
1815
|
-
|
|
1812
|
+
bt(wt, { name: "slide" }, {
|
|
1813
|
+
default: Pt(() => [
|
|
1814
|
+
Et(w("div", io, [
|
|
1816
1815
|
w("div", no, [
|
|
1817
1816
|
w("button", {
|
|
1818
|
-
class:
|
|
1819
|
-
style:
|
|
1817
|
+
class: ct(["picker_cancel", i.value.cancelClass]),
|
|
1818
|
+
style: ht({ color: n.value }),
|
|
1820
1819
|
onClick: T[1] || (T[1] = //@ts-ignore
|
|
1821
1820
|
(...f) => x(u) && x(u)(...f))
|
|
1822
1821
|
}, j(i.value.cancelText), 7),
|
|
1823
1822
|
w("button", {
|
|
1824
|
-
class:
|
|
1825
|
-
style:
|
|
1823
|
+
class: ct(["picker_confirm", i.value.confirmClass]),
|
|
1824
|
+
style: ht({ color: s.value }),
|
|
1826
1825
|
onClick: T[2] || (T[2] = //@ts-ignore
|
|
1827
1826
|
(...f) => x(v) && x(v)(...f))
|
|
1828
1827
|
}, j(i.value.confirmText), 7),
|
|
1829
1828
|
w("h4", {
|
|
1830
|
-
class:
|
|
1831
|
-
style:
|
|
1829
|
+
class: ct([i.value.titleClass]),
|
|
1830
|
+
style: ht({ color: l.value })
|
|
1832
1831
|
}, j(i.value.titleText), 7)
|
|
1833
1832
|
]),
|
|
1834
1833
|
w("div", so, [
|
|
@@ -1839,12 +1838,12 @@ const Jt = (o) => (ae("data-v-78632b89"), o = o(), le(), o), io = { class: "pick
|
|
|
1839
1838
|
ref: h,
|
|
1840
1839
|
class: "picker_wheel_wrapper"
|
|
1841
1840
|
}, [
|
|
1842
|
-
(z(!0), K(
|
|
1841
|
+
(z(!0), K(Dt, null, Bt(x(a), (f, S) => (z(), K("div", {
|
|
1843
1842
|
key: S,
|
|
1844
1843
|
class: "picker_wheel"
|
|
1845
1844
|
}, [
|
|
1846
1845
|
w("ul", co, [
|
|
1847
|
-
(z(!0), K(
|
|
1846
|
+
(z(!0), K(Dt, null, Bt(f, (g, C) => {
|
|
1848
1847
|
var M;
|
|
1849
1848
|
return z(), K("li", {
|
|
1850
1849
|
key: C,
|
|
@@ -1856,19 +1855,19 @@ const Jt = (o) => (ae("data-v-78632b89"), o = o(), le(), o), io = { class: "pick
|
|
|
1856
1855
|
], 512)
|
|
1857
1856
|
])
|
|
1858
1857
|
], 512), [
|
|
1859
|
-
[
|
|
1858
|
+
[Ct, d.isShowPicker]
|
|
1860
1859
|
])
|
|
1861
1860
|
]),
|
|
1862
1861
|
_: 1
|
|
1863
1862
|
})
|
|
1864
|
-
]
|
|
1863
|
+
]));
|
|
1865
1864
|
}
|
|
1866
1865
|
}), uo = (o, t) => {
|
|
1867
1866
|
const e = o.__vccOpts || o;
|
|
1868
1867
|
for (const [r, i] of t)
|
|
1869
1868
|
e[r] = i;
|
|
1870
1869
|
return e;
|
|
1871
|
-
}, zt = /* @__PURE__ */ uo(ho, [["__scopeId", "data-v-
|
|
1870
|
+
}, zt = /* @__PURE__ */ uo(ho, [["__scopeId", "data-v-3207fa1f"]]);
|
|
1872
1871
|
zt.install = function(o) {
|
|
1873
1872
|
o.component("Picker", zt);
|
|
1874
1873
|
};
|
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.1",
|
|
3
|
+
"version": "0.1.2-alpha.1",
|
|
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
|
},
|