centui 3.0.0 → 3.1.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/ActionBar-Bs5fkyFH.cjs +1 -0
- package/dist/ActionBar-CF1zMUMC.js +56 -0
- package/dist/ActivityIndicator-BOZRJBDn.cjs +1 -0
- package/dist/{RollerSuccess-CVEmS9gU.js → ActivityIndicator-Cp20c1E0.js} +30 -92
- package/dist/{Agree-DT46e5q5.cjs → Agree-ZswFiFNy.cjs} +1 -1
- package/dist/{Agree-yTGTi4e6.js → Agree-lAcOo38C.js} +2 -3
- package/dist/Amount-B2StZGGW.js +56 -0
- package/dist/Amount-CU7Oc4vv.cjs +1 -0
- package/dist/Bill-DDVs3Lu3.cjs +1 -0
- package/dist/Bill-qQ4LdkmR.js +58 -0
- package/dist/{Button-Blpwwbnw.cjs → Button-Bu8liJQE.cjs} +1 -1
- package/dist/{Button-BIi6CrwM.js → Button-D7e-cuA1.js} +5 -6
- package/dist/Captcha-BEF-de8-.cjs +1 -0
- package/dist/Captcha-CgpynYTc.js +283 -0
- package/dist/Cashier-CJLfQOXm.js +363 -0
- package/dist/Cashier-CLJngM0n.cjs +1 -0
- package/dist/{CellItem-YZD-BxKt.js → CellItem-BHEh4Cp-.js} +2 -3
- package/dist/{CellItem-T78DHako.cjs → CellItem-J0LkwZNL.cjs} +1 -1
- package/dist/Chart-BINJAx7V.js +135 -0
- package/dist/Chart-DJ0Q1g1P.cjs +1 -0
- package/dist/CheckBox-D5bCJUXD.js +55 -0
- package/dist/CheckBox-DDeCshDK.cjs +1 -0
- package/dist/CheckBoxBase-BIPGJ-TD.js +43 -0
- package/dist/CheckBoxBase-CobK6-tL.cjs +1 -0
- package/dist/CheckList-BsKo_Fl3.cjs +1 -0
- package/dist/{CheckList-Bfy3B-eN.js → CheckList-ViiCo4yi.js} +47 -91
- package/dist/{Codebox-D0UtCj11.js → Codebox-BLPrFnIv.js} +4 -5
- package/dist/Codebox-yLkdTU7w.cjs +1 -0
- package/dist/{DatePicker-B1AVbKhK.cjs → DatePicker-CCU6gqG3.cjs} +1 -1
- package/dist/{DatePicker-TAHuve5t.js → DatePicker-CYvPJatt.js} +2 -4
- package/dist/DetailItem-D6-zbZmd.js +21 -0
- package/dist/DetailItem-DDJXXao0.cjs +1 -0
- package/dist/Dialog-208_XUAL.cjs +1 -0
- package/dist/Dialog-Bb7Gth3j.js +148 -0
- package/dist/DropMenu-5TA_6bas.js +95 -0
- package/dist/DropMenu-D_ZMGOOi.cjs +1 -0
- package/dist/{Field-CseJzTZz.js → Field-0hdNWFNm.js} +1 -2
- package/dist/{FieldItem-Cc7bw5vU.js → FieldItem-D79w330m.js} +2 -3
- package/dist/{FieldItem-Dkpx5Kxk.cjs → FieldItem-UFKrl_5J.cjs} +1 -1
- package/dist/{Icon-jaEPn7d7.cjs → Icon-83WWqE5z.cjs} +1 -1
- package/dist/{Icon-dWGSK6Ou.js → Icon-BgCtu0ZV.js} +3 -5
- package/dist/ImageReader-DjshA_hh.cjs +1 -0
- package/dist/ImageReader-hUb5CEbV.js +122 -0
- package/dist/ImageViewer-BCEK4DOF.cjs +1 -0
- package/dist/ImageViewer-_dTRCIsV.js +68 -0
- package/dist/InputItem-DO5Yo_IH.cjs +1 -0
- package/dist/InputItem-yHsLFvKt.js +327 -0
- package/dist/Landscape-BsHyoM4N.cjs +1 -0
- package/dist/Landscape-Dd0abEy1.js +73 -0
- package/dist/LicensePlate-CTcAIbcb.js +201 -0
- package/dist/LicensePlate-CfwpVw0G.cjs +1 -0
- package/dist/NoticeBar-CV355FeO.cjs +1 -0
- package/dist/NoticeBar-G5aKL6VO.js +92 -0
- package/dist/NumberKeyboard-BWpxsbYt.cjs +1 -0
- package/dist/{NumberKeyboard-C7TRF5iC.js → NumberKeyboard-B_TJXxki.js} +77 -62
- package/dist/Picker-BOEGTBaN.cjs +1 -0
- package/dist/{Picker-Dam0LEcc.js → Picker-CA-JQ_OC.js} +168 -151
- package/dist/Popup-Ca1jPi0t.cjs +1 -0
- package/dist/Popup-qLk-BsRS.js +116 -0
- package/dist/{PopupTitleBar-nVurLaOe.js → PopupTitleBar-9P4RUMC1.js} +2 -3
- package/dist/{PopupTitleBar-B4vwxKC7.cjs → PopupTitleBar-Bfl49eYJ.cjs} +1 -1
- package/dist/Progress-CT-LHaQ0.cjs +1 -0
- package/dist/{Progress-CwIC6scr.js → Progress-Clet0W_n.js} +20 -22
- package/dist/Radio-B_MxJ65X.cjs +1 -0
- package/dist/{Radio-fsc7_N5K.js → Radio-DY-ZX0BP.js} +16 -14
- package/dist/{RadioGroup-CMPmk8X_.js → RadioGroup-B00aqM9e.js} +8 -6
- package/dist/RadioGroup-B6ukqnm5.cjs +1 -0
- package/dist/{RadioList-upQgua8Z.cjs → RadioList-D-9PITpr.cjs} +1 -1
- package/dist/{RadioList-CkerkQEY.js → RadioList-DNGsEzgf.js} +6 -8
- package/dist/ResultPage-DUs8ok5R.js +64 -0
- package/dist/ResultPage-YQWDaFmz.cjs +1 -0
- package/dist/{Roller-DFJ7jMV0.js → Roller-BznN57fL.js} +1 -2
- package/dist/RollerSuccess-BbMzNlkv.cjs +1 -0
- package/dist/RollerSuccess-CTh43Rh0.js +65 -0
- package/dist/Ruler-Bhf5J7hU.js +136 -0
- package/dist/Ruler-CEzB0oqG.cjs +1 -0
- package/dist/ScrollView-BNY62f7B.js +228 -0
- package/dist/ScrollView-BnadVBJC.cjs +1 -0
- package/dist/ScrollViewMore-BL1vpyMj.cjs +1 -0
- package/dist/ScrollViewMore-DBhoiI1X.js +54 -0
- package/dist/Selector-DOU8Af55.js +209 -0
- package/dist/Selector-DnFvOGbv.cjs +1 -0
- package/dist/{Skeleton-BG_j23KI.js → Skeleton-DqA5IxL5.js} +1 -2
- package/dist/Slider-BB2Nhpys.js +100 -0
- package/dist/Slider-vV7_nULf.cjs +1 -0
- package/dist/Stepper-BnDhL8IO.js +137 -0
- package/dist/Stepper-n_mc16V2.cjs +1 -0
- package/dist/Steps-BPQwab3T.js +157 -0
- package/dist/Steps-Dfpmgl8B.cjs +1 -0
- package/dist/SwiperItem-BY5cUoGn.cjs +1 -0
- package/dist/SwiperItem-BydyBdYU.js +323 -0
- package/dist/Switch-B1rsBY-M.js +31 -0
- package/dist/Switch-CghubImq.cjs +1 -0
- package/dist/TabPane-BCVsdptu.cjs +1 -0
- package/dist/TabPane-Q7oUFzmP.js +237 -0
- package/dist/TabPicker-BcL9assY.cjs +1 -0
- package/dist/TabPicker-BicPrto7.js +173 -0
- package/dist/Tag-C7ygxOwU.js +78 -0
- package/dist/Tag-CIA2npnD.cjs +1 -0
- package/dist/TextareaItem-Dl-PCLl-.js +168 -0
- package/dist/TextareaItem-Du5nl7tv.cjs +1 -0
- package/dist/{Tip-BFZSiRc1.js → Tip-DHPmevlv.js} +2 -3
- package/dist/{Tip-C3brAF9N.cjs → Tip-De_3tKtb.cjs} +1 -1
- package/dist/Transition-B-baX512.js +14 -0
- package/dist/Transition-Bwbqr4Xr.cjs +1 -0
- package/dist/WaterMark-CgkuQjv3.js +103 -0
- package/dist/WaterMark-M81jg6T5.cjs +1 -0
- package/dist/action-bar.cjs +1 -0
- package/dist/action-bar.d.ts +1 -0
- package/dist/action-bar.js +1 -0
- package/dist/{action-sheet-LJilF3EQ.cjs → action-sheet-BjaReHkr.cjs} +1 -1
- package/dist/{action-sheet-DKpi2GLQ.js → action-sheet-Da8dHevy.js} +15 -12
- package/dist/action-sheet.cjs +1 -1
- package/dist/action-sheet.js +1 -2
- package/dist/activity-indicator.cjs +1 -1
- package/dist/activity-indicator.js +4 -3
- package/dist/agree.cjs +1 -1
- package/dist/agree.js +1 -2
- package/dist/amount.cjs +1 -1
- package/dist/amount.js +1 -2
- package/dist/bill.cjs +1 -0
- package/dist/bill.d.ts +1 -0
- package/dist/bill.js +1 -0
- package/dist/button.cjs +1 -1
- package/dist/button.js +1 -2
- package/dist/captcha.cjs +1 -0
- package/dist/captcha.d.ts +1 -0
- package/dist/captcha.js +1 -0
- package/dist/cashier.cjs +1 -0
- package/dist/cashier.d.ts +1 -0
- package/dist/cashier.js +1 -0
- package/dist/cell-item.cjs +1 -1
- package/dist/cell-item.js +1 -2
- package/dist/chart.cjs +1 -0
- package/dist/chart.d.ts +1 -0
- package/dist/chart.js +1 -0
- package/dist/check-base.cjs +1 -1
- package/dist/check-base.js +1 -2
- package/dist/check.cjs +1 -1
- package/dist/check.js +3 -2
- package/dist/codebox.cjs +1 -1
- package/dist/codebox.js +1 -2
- package/dist/components/action-sheet/ActionSheet.vue.d.ts +5 -0
- package/dist/components/cashier/CashierChannel.vue.d.ts +4 -0
- package/dist/components/dialog/Dialog.vue.d.ts +10 -0
- package/dist/components/index.d.ts +2 -2
- package/dist/components/number-keyboard/KeyboardKey.vue.d.ts +3 -0
- package/dist/components/popup/PopupTitleBar.vue.d.ts +4 -0
- package/dist/components/swiper/Swiper.vue.d.ts +2 -2
- package/dist/cursor-BIPoNm8V.js +11 -0
- package/dist/cursor-tQE3LcbU.cjs +1 -0
- package/dist/date-picker.cjs +1 -1
- package/dist/date-picker.js +1 -2
- package/dist/detail-item.cjs +1 -0
- package/dist/detail-item.d.ts +1 -0
- package/dist/detail-item.js +1 -0
- package/dist/dialog-C38EDWGJ.cjs +1 -0
- package/dist/dialog-DdNA6YSe.js +91 -0
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.js +2 -1
- package/dist/drop-menu.cjs +1 -0
- package/dist/drop-menu.d.ts +1 -0
- package/dist/drop-menu.js +1 -0
- package/dist/field-item.cjs +1 -1
- package/dist/field-item.js +1 -2
- package/dist/field.js +1 -2
- package/dist/icon.cjs +1 -1
- package/dist/icon.js +1 -2
- package/dist/image-reader.cjs +1 -0
- package/dist/image-reader.d.ts +1 -0
- package/dist/image-reader.js +1 -0
- package/dist/image-viewer.cjs +1 -0
- package/dist/image-viewer.d.ts +1 -0
- package/dist/image-viewer.js +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +61 -2669
- package/dist/input-item.cjs +1 -1
- package/dist/input-item.js +1 -2
- package/dist/landscape.cjs +1 -0
- package/dist/landscape.d.ts +1 -0
- package/dist/landscape.js +1 -0
- package/dist/license-plate.cjs +1 -0
- package/dist/license-plate.d.ts +1 -0
- package/dist/license-plate.js +1 -0
- package/dist/notice-bar.cjs +1 -1
- package/dist/notice-bar.js +1 -2
- package/dist/number-keyboard.cjs +1 -1
- package/dist/number-keyboard.js +1 -2
- package/dist/picker.cjs +1 -1
- package/dist/picker.js +1 -2
- package/dist/popup.cjs +1 -1
- package/dist/popup.js +2 -2
- package/dist/progress.cjs +1 -1
- package/dist/progress.js +1 -2
- package/dist/radio-list.cjs +1 -1
- package/dist/radio-list.js +1 -2
- package/dist/radio.cjs +1 -1
- package/dist/radio.js +2 -2
- package/dist/result-page.cjs +1 -0
- package/dist/result-page.d.ts +1 -0
- package/dist/result-page.js +1 -0
- package/dist/ruler.cjs +1 -0
- package/dist/ruler.d.ts +1 -0
- package/dist/ruler.js +1 -0
- package/dist/scroll-view.cjs +1 -1
- package/dist/scroll-view.js +3 -2
- package/dist/selector.cjs +1 -0
- package/dist/selector.d.ts +1 -0
- package/dist/selector.js +1 -0
- package/dist/{shared-BtSkmaWC.js → shared-C9XlLe7F.js} +1 -2
- package/dist/skeleton.js +1 -2
- package/dist/slider.cjs +1 -1
- package/dist/slider.js +1 -2
- package/dist/stepper.cjs +1 -1
- package/dist/stepper.js +1 -2
- package/dist/steps.cjs +1 -0
- package/dist/steps.d.ts +1 -0
- package/dist/steps.js +1 -0
- package/dist/swiper.cjs +1 -1
- package/dist/swiper.js +1 -2
- package/dist/switch.cjs +1 -1
- package/dist/switch.js +1 -2
- package/dist/tab-picker.cjs +1 -0
- package/dist/tab-picker.d.ts +1 -0
- package/dist/tab-picker.js +1 -0
- package/dist/tabs.cjs +1 -0
- package/dist/tabs.d.ts +1 -0
- package/dist/tabs.js +1 -0
- package/dist/tag.cjs +1 -1
- package/dist/tag.js +1 -2
- package/dist/textarea-item.cjs +1 -0
- package/dist/textarea-item.d.ts +1 -0
- package/dist/textarea-item.js +1 -0
- package/dist/tip.cjs +1 -1
- package/dist/tip.js +1 -2
- package/dist/{toast-DX-RoB7Q.js → toast-ByIFvpMs.js} +6 -6
- package/dist/toast-C1K2_cOo.cjs +1 -0
- package/dist/toast.cjs +1 -1
- package/dist/toast.js +1 -2
- package/dist/transition.cjs +1 -0
- package/dist/transition.d.ts +1 -0
- package/dist/transition.js +1 -0
- package/dist/water-mark.cjs +1 -0
- package/dist/water-mark.d.ts +1 -0
- package/dist/water-mark.js +1 -0
- package/package.json +105 -4
- package/dist/Amount-De-oObat.cjs +0 -1
- package/dist/Amount-wOtRYOdx.js +0 -62
- package/dist/CheckBoxBase-BDsytL_r.cjs +0 -1
- package/dist/CheckBoxBase-BjyVzGqj.js +0 -40
- package/dist/CheckList-DEmLmccw.cjs +0 -1
- package/dist/Codebox-Cgj7wyzd.cjs +0 -1
- package/dist/InputItem-EJ4Y3tpU.cjs +0 -1
- package/dist/InputItem-bhFtp97z.js +0 -322
- package/dist/NoticeBar-DSf_EjTL.cjs +0 -1
- package/dist/NoticeBar-PEYcjXwD.js +0 -84
- package/dist/NumberKeyboard-BX0c0l2r.cjs +0 -1
- package/dist/Picker-D-TPtSxf.cjs +0 -1
- package/dist/Popup-Cm4BuaOo.cjs +0 -1
- package/dist/Popup-DPYBBL95.js +0 -116
- package/dist/Progress-DukssNvl.cjs +0 -1
- package/dist/Radio-ZHivLdvi.cjs +0 -1
- package/dist/RadioGroup-BR_jSDR4.cjs +0 -1
- package/dist/RollerSuccess--JecJ7bz.cjs +0 -1
- package/dist/ScrollViewMore-BWph-i1-.cjs +0 -1
- package/dist/ScrollViewMore-BgYJx-TP.js +0 -278
- package/dist/Slider-D3wrE8hn.cjs +0 -1
- package/dist/Slider-DteN8p-L.js +0 -95
- package/dist/Stepper-1EOk4pCY.js +0 -127
- package/dist/Stepper-BJr4I6_8.cjs +0 -1
- package/dist/SwiperItem-B6TgjCsM.cjs +0 -1
- package/dist/SwiperItem-CKd-XKT7.js +0 -337
- package/dist/Switch-B6DvVj2p.js +0 -30
- package/dist/Switch-BVPjF8CM.cjs +0 -1
- package/dist/Tag-CPv77lC8.cjs +0 -1
- package/dist/Tag-bs5j40pF.js +0 -66
- package/dist/dialog-0-E4Vyc-.cjs +0 -1
- package/dist/dialog-DHIZ2SMK.js +0 -227
- package/dist/toast-CAeyMc5r.cjs +0 -1
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { computed as e, createElementBlock as t, createElementVNode as n, defineComponent as r, normalizeClass as i, onMounted as a, openBlock as o, ref as s, watch as c } from "vue";
|
|
2
|
+
import { warn as l } from "@centui/core";
|
|
3
|
+
// src/components/stepper/Stepper.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
+
var u = { class: "cu-stepper-number" }, d = [
|
|
5
|
+
"type",
|
|
6
|
+
"size",
|
|
7
|
+
"value",
|
|
8
|
+
"readonly"
|
|
9
|
+
], f = "减少", p = "增加", m = /* @__PURE__ */ r({
|
|
10
|
+
name: "cu-stepper",
|
|
11
|
+
__name: "Stepper",
|
|
12
|
+
props: {
|
|
13
|
+
defaultValue: { default: 0 },
|
|
14
|
+
modelValue: { default: 0 },
|
|
15
|
+
step: { default: 1 },
|
|
16
|
+
min: { default: -Number.MAX_VALUE },
|
|
17
|
+
max: { default: Number.MAX_VALUE },
|
|
18
|
+
disabled: {
|
|
19
|
+
type: Boolean,
|
|
20
|
+
default: !1
|
|
21
|
+
},
|
|
22
|
+
readOnly: {
|
|
23
|
+
type: Boolean,
|
|
24
|
+
default: !1
|
|
25
|
+
},
|
|
26
|
+
isInteger: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
default: !1
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
emits: [
|
|
32
|
+
"update:modelValue",
|
|
33
|
+
"change",
|
|
34
|
+
"increase",
|
|
35
|
+
"decrease"
|
|
36
|
+
],
|
|
37
|
+
setup(r, { emit: m }) {
|
|
38
|
+
let h = r, g = m;
|
|
39
|
+
function _(e) {
|
|
40
|
+
try {
|
|
41
|
+
return e.toString().split(".")[1].length;
|
|
42
|
+
} catch {
|
|
43
|
+
return 0;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function v(e, t) {
|
|
47
|
+
let n = Number(e), r = Number(t), i = _(e), a = _(t), o = 10 ** Math.max(i, a);
|
|
48
|
+
return +((n * o + r * o) / o);
|
|
49
|
+
}
|
|
50
|
+
function y(e, t) {
|
|
51
|
+
let n = Number(e), r = Number(t), i = _(e), a = _(t), o = 10 ** Math.max(i, a), s = i >= a ? i : a;
|
|
52
|
+
return +((n * o - r * o) / o).toFixed(s);
|
|
53
|
+
}
|
|
54
|
+
let b = s(!1), x = s(!1), S = s(!1), C = s(0);
|
|
55
|
+
C.value = O(h.modelValue || h.defaultValue);
|
|
56
|
+
let w = e(() => {
|
|
57
|
+
if (!h.modelValue) return 2;
|
|
58
|
+
let e = h.modelValue.toString().length;
|
|
59
|
+
return e > 2 ? e : 2;
|
|
60
|
+
});
|
|
61
|
+
c(() => h.defaultValue, (e) => {
|
|
62
|
+
C.value = O(e);
|
|
63
|
+
}), c(() => h.modelValue, (e) => {
|
|
64
|
+
S.value || (C.value = O(e));
|
|
65
|
+
}), c(() => h.min, (e) => {
|
|
66
|
+
let t = Number(e);
|
|
67
|
+
C.value < t && (C.value = t), k();
|
|
68
|
+
}), c(() => h.max, (e) => {
|
|
69
|
+
let t = Number(e);
|
|
70
|
+
C.value > t && (C.value = t), k();
|
|
71
|
+
}), c(C, (e, t) => {
|
|
72
|
+
let n = Math.min(Math.max(e, Number(h.min)), Number(h.max));
|
|
73
|
+
if (n !== e) {
|
|
74
|
+
C.value = n;
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
k(), e !== h.modelValue && (g("update:modelValue", e), g("change", e));
|
|
78
|
+
let r = e - t;
|
|
79
|
+
r > 0 ? g("increase", r) : r < 0 && g("decrease", Math.abs(r));
|
|
80
|
+
}), a(() => {
|
|
81
|
+
A(), k();
|
|
82
|
+
});
|
|
83
|
+
function T() {
|
|
84
|
+
h.disabled || b.value || (C.value = y(C.value, h.step), N());
|
|
85
|
+
}
|
|
86
|
+
function E() {
|
|
87
|
+
h.disabled || x.value || (C.value = v(C.value, h.step), N());
|
|
88
|
+
}
|
|
89
|
+
function D(e) {
|
|
90
|
+
let t = String(e).replace(/[^0-9.-]|^-|^\./g, "");
|
|
91
|
+
return t === "" ? 0 : h.isInteger ? Math.floor(Number(t)) : +t;
|
|
92
|
+
}
|
|
93
|
+
function O(e) {
|
|
94
|
+
return Math.max(Math.min(Number(h.max), D(e)), Number(h.min));
|
|
95
|
+
}
|
|
96
|
+
function k() {
|
|
97
|
+
b.value = C.value <= Number(h.min), x.value = C.value >= Number(h.max);
|
|
98
|
+
}
|
|
99
|
+
function A() {
|
|
100
|
+
return Number(h.min) > Number(h.max) && l("[cu-vue-stepper] minNum is larger than maxNum"), Number(h.max) > Number(h.min);
|
|
101
|
+
}
|
|
102
|
+
function j(e) {
|
|
103
|
+
let t = e.target, { value: n } = t, r = D(n);
|
|
104
|
+
+n !== r && (t.value = String(r)), C.value = r;
|
|
105
|
+
}
|
|
106
|
+
function M() {
|
|
107
|
+
S.value = !0;
|
|
108
|
+
}
|
|
109
|
+
function N() {
|
|
110
|
+
S.value = !1, C.value = O(C.value);
|
|
111
|
+
}
|
|
112
|
+
return (e, a) => (o(), t("div", { class: i(["cu-stepper", { disabled: r.disabled }]) }, [
|
|
113
|
+
n("div", {
|
|
114
|
+
class: i(["cu-stepper-button cu-stepper-button-reduce", { disabled: b.value }]),
|
|
115
|
+
role: "button",
|
|
116
|
+
"aria-label": f,
|
|
117
|
+
onClick: T
|
|
118
|
+
}, null, 2),
|
|
119
|
+
n("div", u, [n("input", {
|
|
120
|
+
type: r.isInteger ? "tel" : "number",
|
|
121
|
+
size: w.value,
|
|
122
|
+
value: C.value,
|
|
123
|
+
readonly: r.readOnly,
|
|
124
|
+
onInput: j,
|
|
125
|
+
onFocus: M,
|
|
126
|
+
onBlur: N
|
|
127
|
+
}, null, 40, d)]),
|
|
128
|
+
n("div", {
|
|
129
|
+
class: i(["cu-stepper-button cu-stepper-button-add", { disabled: x.value }]),
|
|
130
|
+
role: "button",
|
|
131
|
+
"aria-label": p,
|
|
132
|
+
onClick: E
|
|
133
|
+
}, null, 2)
|
|
134
|
+
], 2));
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
export { m as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let e=require("vue"),t=require("@centui/core");var n={class:`cu-stepper-number`},r=[`type`,`size`,`value`,`readonly`],i=`减少`,a=`增加`,o=(0,e.defineComponent)({name:`cu-stepper`,__name:`Stepper`,props:{defaultValue:{default:0},modelValue:{default:0},step:{default:1},min:{default:-Number.MAX_VALUE},max:{default:Number.MAX_VALUE},disabled:{type:Boolean,default:!1},readOnly:{type:Boolean,default:!1},isInteger:{type:Boolean,default:!1}},emits:[`update:modelValue`,`change`,`increase`,`decrease`],setup(o,{emit:s}){let c=o,l=s;function u(e){try{return e.toString().split(`.`)[1].length}catch{return 0}}function d(e,t){let n=Number(e),r=Number(t),i=u(e),a=u(t),o=10**Math.max(i,a);return+((n*o+r*o)/o)}function f(e,t){let n=Number(e),r=Number(t),i=u(e),a=u(t),o=10**Math.max(i,a),s=i>=a?i:a;return+((n*o-r*o)/o).toFixed(s)}let p=(0,e.ref)(!1),m=(0,e.ref)(!1),h=(0,e.ref)(!1),g=(0,e.ref)(0);g.value=x(c.modelValue||c.defaultValue);let _=(0,e.computed)(()=>{if(!c.modelValue)return 2;let e=c.modelValue.toString().length;return e>2?e:2});(0,e.watch)(()=>c.defaultValue,e=>{g.value=x(e)}),(0,e.watch)(()=>c.modelValue,e=>{h.value||(g.value=x(e))}),(0,e.watch)(()=>c.min,e=>{let t=Number(e);g.value<t&&(g.value=t),S()}),(0,e.watch)(()=>c.max,e=>{let t=Number(e);g.value>t&&(g.value=t),S()}),(0,e.watch)(g,(e,t)=>{let n=Math.min(Math.max(e,Number(c.min)),Number(c.max));if(n!==e){g.value=n;return}S(),e!==c.modelValue&&(l(`update:modelValue`,e),l(`change`,e));let r=e-t;r>0?l(`increase`,r):r<0&&l(`decrease`,Math.abs(r))}),(0,e.onMounted)(()=>{C(),S()});function v(){c.disabled||p.value||(g.value=f(g.value,c.step),E())}function y(){c.disabled||m.value||(g.value=d(g.value,c.step),E())}function b(e){let t=String(e).replace(/[^0-9.-]|^-|^\./g,``);return t===``?0:c.isInteger?Math.floor(Number(t)):+t}function x(e){return Math.max(Math.min(Number(c.max),b(e)),Number(c.min))}function S(){p.value=g.value<=Number(c.min),m.value=g.value>=Number(c.max)}function C(){return Number(c.min)>Number(c.max)&&(0,t.warn)(`[cu-vue-stepper] minNum is larger than maxNum`),Number(c.max)>Number(c.min)}function w(e){let t=e.target,{value:n}=t,r=b(n);+n!==r&&(t.value=String(r)),g.value=r}function T(){h.value=!0}function E(){h.value=!1,g.value=x(g.value)}return(t,s)=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{class:(0,e.normalizeClass)([`cu-stepper`,{disabled:o.disabled}])},[(0,e.createElementVNode)(`div`,{class:(0,e.normalizeClass)([`cu-stepper-button cu-stepper-button-reduce`,{disabled:p.value}]),role:`button`,"aria-label":i,onClick:v},null,2),(0,e.createElementVNode)(`div`,n,[(0,e.createElementVNode)(`input`,{type:o.isInteger?`tel`:`number`,size:_.value,value:g.value,readonly:o.readOnly,onInput:w,onFocus:T,onBlur:E},null,40,r)]),(0,e.createElementVNode)(`div`,{class:(0,e.normalizeClass)([`cu-stepper-button cu-stepper-button-add`,{disabled:m.value}]),role:`button`,"aria-label":a,onClick:y},null,2)],2))}});Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return o}});
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { t as e } from "./Icon-BgCtu0ZV.js";
|
|
2
|
+
import { Fragment as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, defineComponent as o, nextTick as s, normalizeClass as c, normalizeStyle as l, onBeforeUnmount as u, onMounted as d, onUpdated as f, openBlock as p, ref as m, renderList as h, renderSlot as g, toDisplayString as _, watch as v } from "vue";
|
|
3
|
+
// src/components/steps/Steps.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
+
var y = {
|
|
5
|
+
key: 0,
|
|
6
|
+
class: "icon-wrapper"
|
|
7
|
+
}, b = {
|
|
8
|
+
key: 1,
|
|
9
|
+
class: "icon-wrapper"
|
|
10
|
+
}, x = {
|
|
11
|
+
key: 1,
|
|
12
|
+
class: "step-node-default"
|
|
13
|
+
}, S = {
|
|
14
|
+
key: 1,
|
|
15
|
+
class: "step-node-default"
|
|
16
|
+
}, C = { class: "text-wrapper" }, w = { class: "name" }, T = {
|
|
17
|
+
key: 0,
|
|
18
|
+
class: "desc"
|
|
19
|
+
}, E = .3, D = /* @__PURE__ */ o({
|
|
20
|
+
name: "cu-steps",
|
|
21
|
+
__name: "Steps",
|
|
22
|
+
props: {
|
|
23
|
+
steps: { default: () => [] },
|
|
24
|
+
current: { default: 0 },
|
|
25
|
+
direction: { default: "horizontal" },
|
|
26
|
+
transition: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
default: !1
|
|
29
|
+
},
|
|
30
|
+
verticalAdaptive: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
default: !1
|
|
33
|
+
},
|
|
34
|
+
custom: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
default: !1
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
setup(o) {
|
|
40
|
+
let D = o, O = m(), k = m(!1), A = m([]), j = m([]), M = m(0), N = null, P = [], F = () => {
|
|
41
|
+
P.forEach(clearTimeout), P = [];
|
|
42
|
+
}, I = (e) => {
|
|
43
|
+
let t = A.value[e];
|
|
44
|
+
return t ? {
|
|
45
|
+
transform: `translate3d${D.direction === "horizontal" ? `(${(t.len - 1) * 100}%, 0, 0)` : `(0, ${(t.len - 1) * 100}%, 0)`}`,
|
|
46
|
+
transition: `all ${t.time}s linear`
|
|
47
|
+
} : {};
|
|
48
|
+
};
|
|
49
|
+
v(() => D.current, (e, t) => {
|
|
50
|
+
let n = B(e), r = V(n);
|
|
51
|
+
if (D.transition) {
|
|
52
|
+
let e = n >= t;
|
|
53
|
+
N && clearTimeout(N), F(), N = setTimeout(() => {
|
|
54
|
+
N = null, H(r, e, (t) => {
|
|
55
|
+
(e && t > M.value || !e && t < M.value) && (M.value = t);
|
|
56
|
+
});
|
|
57
|
+
}, 100);
|
|
58
|
+
} else A.value = r, M.value = n;
|
|
59
|
+
}), v(() => D.steps.length, () => {
|
|
60
|
+
A.value = V(M.value);
|
|
61
|
+
});
|
|
62
|
+
{
|
|
63
|
+
let e = B(D.current);
|
|
64
|
+
M.value = e, A.value = V(e);
|
|
65
|
+
}
|
|
66
|
+
u(() => {
|
|
67
|
+
N &&= (clearTimeout(N), null), F();
|
|
68
|
+
}), d(() => {
|
|
69
|
+
L(), k.value = !0;
|
|
70
|
+
}), f(() => {
|
|
71
|
+
s(() => {
|
|
72
|
+
L();
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
function L() {
|
|
76
|
+
if (D.direction !== "vertical" || D.verticalAdaptive) return;
|
|
77
|
+
let e = O.value;
|
|
78
|
+
if (!e) return;
|
|
79
|
+
let t = e.querySelectorAll(".icon-wrapper"), n = e.querySelectorAll(".text-wrapper"), r = Array.from(n).map((e, r) => {
|
|
80
|
+
let i = e.clientHeight, a = t[r]?.clientHeight ?? 0;
|
|
81
|
+
return r === n.length - 1 ? i -= a : i += 40, i > 0 ? i : 0;
|
|
82
|
+
});
|
|
83
|
+
r.toString() !== j.value.toString() && (j.value = r);
|
|
84
|
+
}
|
|
85
|
+
function R(e) {
|
|
86
|
+
let t = D.direction === "vertical" && !D.verticalAdaptive ? j.value[e] : 0;
|
|
87
|
+
return t ? { height: `${t}px` } : null;
|
|
88
|
+
}
|
|
89
|
+
function z(e) {
|
|
90
|
+
let t = M.value, n = [];
|
|
91
|
+
return e < t && n.push("reached"), e === Math.floor(t) && n.push("current"), n.join(" ");
|
|
92
|
+
}
|
|
93
|
+
function B(e) {
|
|
94
|
+
return e < 0 ? 0 : e > D.steps.length - 1 ? D.steps.length - 1 : e;
|
|
95
|
+
}
|
|
96
|
+
function V(e) {
|
|
97
|
+
return D.steps.slice(0, D.steps.length - 1).map((t, n) => {
|
|
98
|
+
let r = e - n, i = A.value[n], a = i === void 0, o;
|
|
99
|
+
o = r <= 0 ? 0 : r >= 1 ? 1 : r;
|
|
100
|
+
let s = (a ? o : Math.abs(i.len - o)) * E;
|
|
101
|
+
return {
|
|
102
|
+
len: o,
|
|
103
|
+
time: s
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
function H(e, t, n) {
|
|
108
|
+
let r = t ? 0 : M.value, i = (a) => {
|
|
109
|
+
a < e.length && a > -1 && e[a] && (t ? r += e[a].len : r -= A.value[a].len - e[a].len, P.push(setTimeout(() => {
|
|
110
|
+
i(t ? a + 1 : a - 1), n(r);
|
|
111
|
+
}, e[a].time * 1e3))), A.value[a] = e[a];
|
|
112
|
+
};
|
|
113
|
+
i(t ? 0 : e.length - 1);
|
|
114
|
+
}
|
|
115
|
+
return (s, u) => (p(), i("div", {
|
|
116
|
+
ref_key: "root",
|
|
117
|
+
ref: O,
|
|
118
|
+
class: c(["cu-steps", {
|
|
119
|
+
"cu-steps-vertical": o.direction === "vertical",
|
|
120
|
+
"cu-steps-horizontal": o.direction === "horizontal",
|
|
121
|
+
"vertical-adaptive": o.direction === "vertical" && o.verticalAdaptive,
|
|
122
|
+
"no-current": M.value % 1 != 0
|
|
123
|
+
}])
|
|
124
|
+
}, [o.custom ? g(s.$slots, "default", { steps: o.steps }, void 0, void 0, 0) : (p(!0), i(t, { key: 1 }, h(o.steps, (d, f) => (p(), i(t, { key: `steps-${f}` }, [a("div", { class: c(["step-wrapper", z(f)]) }, [s.$slots.icon ? (p(), i("div", y, [g(s.$slots, "icon", {
|
|
125
|
+
index: f,
|
|
126
|
+
currentIndex: M.value
|
|
127
|
+
})])) : (p(), i("div", b, [f < M.value ? (p(), i(t, { key: 0 }, [s.$slots.reached ? g(s.$slots, "reached", { index: f }, void 0, void 0, 0) : (p(), i("div", x, [...u[0] ||= [a("div", {
|
|
128
|
+
class: "step-node-default-icon",
|
|
129
|
+
style: {
|
|
130
|
+
width: "6px",
|
|
131
|
+
height: "6px",
|
|
132
|
+
"border-radius": "50%"
|
|
133
|
+
}
|
|
134
|
+
}, null, -1)]]))], 64)) : f === M.value ? (p(), i(t, { key: 1 }, [s.$slots.current ? g(s.$slots, "current", { index: f }, void 0, void 0, 0) : (p(), n(e, {
|
|
135
|
+
key: 1,
|
|
136
|
+
name: "success"
|
|
137
|
+
}))], 64)) : (p(), i(t, { key: 2 }, [s.$slots.unreached ? g(s.$slots, "unreached", { index: f }, void 0, void 0, 0) : (p(), i("div", S, [...u[1] ||= [a("div", {
|
|
138
|
+
class: "step-node-default-icon",
|
|
139
|
+
style: {
|
|
140
|
+
width: "6px",
|
|
141
|
+
height: "6px",
|
|
142
|
+
"border-radius": "50%"
|
|
143
|
+
}
|
|
144
|
+
}, null, -1)]]))], 64))])), a("div", C, [s.$slots.content ? g(s.$slots, "content", {
|
|
145
|
+
index: f,
|
|
146
|
+
step: d
|
|
147
|
+
}, void 0, void 0, 0) : (p(), i(t, { key: 1 }, [a("div", w, _(d.name), 1), d.text ? (p(), i("div", T, _(d.text), 1)) : r("", !0)], 64))])], 2), a("div", {
|
|
148
|
+
class: c(["bar", [o.direction === "horizontal" ? "horizontal-bar" : "vertical-bar"]]),
|
|
149
|
+
style: l(R(f))
|
|
150
|
+
}, [A.value[f] ? (p(), i("i", {
|
|
151
|
+
key: 0,
|
|
152
|
+
class: "bar-inner",
|
|
153
|
+
style: l(I(f))
|
|
154
|
+
}, null, 4)) : r("", !0)], 6)], 64))), 128))], 2));
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
export { D as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./Icon-83WWqE5z.cjs");let t=require("vue");var n={key:0,class:`icon-wrapper`},r={key:1,class:`icon-wrapper`},i={key:1,class:`step-node-default`},a={key:1,class:`step-node-default`},o={class:`text-wrapper`},s={class:`name`},c={key:0,class:`desc`},l=.3,u=(0,t.defineComponent)({name:`cu-steps`,__name:`Steps`,props:{steps:{default:()=>[]},current:{default:0},direction:{default:`horizontal`},transition:{type:Boolean,default:!1},verticalAdaptive:{type:Boolean,default:!1},custom:{type:Boolean,default:!1}},setup(u){let d=u,f=(0,t.ref)(),p=(0,t.ref)(!1),m=(0,t.ref)([]),h=(0,t.ref)([]),g=(0,t.ref)(0),_=null,v=[],y=()=>{v.forEach(clearTimeout),v=[]},b=e=>{let t=m.value[e];return t?{transform:`translate3d${d.direction===`horizontal`?`(${(t.len-1)*100}%, 0, 0)`:`(0, ${(t.len-1)*100}%, 0)`}`,transition:`all ${t.time}s linear`}:{}};(0,t.watch)(()=>d.current,(e,t)=>{let n=w(e),r=T(n);if(d.transition){let e=n>=t;_&&clearTimeout(_),y(),_=setTimeout(()=>{_=null,E(r,e,t=>{(e&&t>g.value||!e&&t<g.value)&&(g.value=t)})},100)}else m.value=r,g.value=n}),(0,t.watch)(()=>d.steps.length,()=>{m.value=T(g.value)});{let e=w(d.current);g.value=e,m.value=T(e)}(0,t.onBeforeUnmount)(()=>{_&&=(clearTimeout(_),null),y()}),(0,t.onMounted)(()=>{x(),p.value=!0}),(0,t.onUpdated)(()=>{(0,t.nextTick)(()=>{x()})});function x(){if(d.direction!==`vertical`||d.verticalAdaptive)return;let e=f.value;if(!e)return;let t=e.querySelectorAll(`.icon-wrapper`),n=e.querySelectorAll(`.text-wrapper`),r=Array.from(n).map((e,r)=>{let i=e.clientHeight,a=t[r]?.clientHeight??0;return r===n.length-1?i-=a:i+=40,i>0?i:0});r.toString()!==h.value.toString()&&(h.value=r)}function S(e){let t=d.direction===`vertical`&&!d.verticalAdaptive?h.value[e]:0;return t?{height:`${t}px`}:null}function C(e){let t=g.value,n=[];return e<t&&n.push(`reached`),e===Math.floor(t)&&n.push(`current`),n.join(` `)}function w(e){return e<0?0:e>d.steps.length-1?d.steps.length-1:e}function T(e){return d.steps.slice(0,d.steps.length-1).map((t,n)=>{let r=e-n,i=m.value[n],a=i===void 0,o;o=r<=0?0:r>=1?1:r;let s=(a?o:Math.abs(i.len-o))*l;return{len:o,time:s}})}function E(e,t,n){let r=t?0:g.value,i=a=>{a<e.length&&a>-1&&e[a]&&(t?r+=e[a].len:r-=m.value[a].len-e[a].len,v.push(setTimeout(()=>{i(t?a+1:a-1),n(r)},e[a].time*1e3))),m.value[a]=e[a]};i(t?0:e.length-1)}return(l,d)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{ref_key:`root`,ref:f,class:(0,t.normalizeClass)([`cu-steps`,{"cu-steps-vertical":u.direction===`vertical`,"cu-steps-horizontal":u.direction===`horizontal`,"vertical-adaptive":u.direction===`vertical`&&u.verticalAdaptive,"no-current":g.value%1!=0}])},[u.custom?(0,t.renderSlot)(l.$slots,`default`,{steps:u.steps},void 0,void 0,0):((0,t.openBlock)(!0),(0,t.createElementBlock)(t.Fragment,{key:1},(0,t.renderList)(u.steps,(f,p)=>((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:`steps-${p}`},[(0,t.createElementVNode)(`div`,{class:(0,t.normalizeClass)([`step-wrapper`,C(p)])},[l.$slots.icon?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,n,[(0,t.renderSlot)(l.$slots,`icon`,{index:p,currentIndex:g.value})])):((0,t.openBlock)(),(0,t.createElementBlock)(`div`,r,[p<g.value?((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:0},[l.$slots.reached?(0,t.renderSlot)(l.$slots,`reached`,{index:p},void 0,void 0,0):((0,t.openBlock)(),(0,t.createElementBlock)(`div`,i,[...d[0]||=[(0,t.createElementVNode)(`div`,{class:`step-node-default-icon`,style:{width:`6px`,height:`6px`,"border-radius":`50%`}},null,-1)]]))],64)):p===g.value?((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:1},[l.$slots.current?(0,t.renderSlot)(l.$slots,`current`,{index:p},void 0,void 0,0):((0,t.openBlock)(),(0,t.createBlock)(e.t,{key:1,name:`success`}))],64)):((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:2},[l.$slots.unreached?(0,t.renderSlot)(l.$slots,`unreached`,{index:p},void 0,void 0,0):((0,t.openBlock)(),(0,t.createElementBlock)(`div`,a,[...d[1]||=[(0,t.createElementVNode)(`div`,{class:`step-node-default-icon`,style:{width:`6px`,height:`6px`,"border-radius":`50%`}},null,-1)]]))],64))])),(0,t.createElementVNode)(`div`,o,[l.$slots.content?(0,t.renderSlot)(l.$slots,`content`,{index:p,step:f},void 0,void 0,0):((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:1},[(0,t.createElementVNode)(`div`,s,(0,t.toDisplayString)(f.name),1),f.text?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,c,(0,t.toDisplayString)(f.text),1)):(0,t.createCommentVNode)(``,!0)],64))])],2),(0,t.createElementVNode)(`div`,{class:(0,t.normalizeClass)([`bar`,[u.direction===`horizontal`?`horizontal-bar`:`vertical-bar`]]),style:(0,t.normalizeStyle)(S(p))},[m.value[p]?((0,t.openBlock)(),(0,t.createElementBlock)(`i`,{key:0,class:`bar-inner`,style:(0,t.normalizeStyle)(b(p))},null,4)):(0,t.createCommentVNode)(``,!0)],6)],64))),128))],2))}});Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return u}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let e=require("vue"),t=require("@centui/core"),n=require("@centui/core/web");var r=.5,i=300,a=(0,e.defineComponent)({name:`cu-swiper`,__name:`Swiper`,props:{autoplay:{default:3e3},transition:{default:`slide`},transitionDuration:{default:250},defaultIndex:{default:0},hasDots:{type:Boolean,default:!0},isPrevent:{type:Boolean,default:!0},isLoop:{type:Boolean,default:!0},dragable:{type:Boolean,default:!0},useNativeDriver:{type:Boolean,default:!0}},emits:[`beforeChange`,`afterChange`],setup(a,{expose:o,emit:s}){let c=typeof process<`u`&&process.env.MAND_ENV===`test`,l=a,u=s,d=(0,e.useSlots)(),f=(0,e.ref)(),ee=(0,e.ref)(),p=(0,e.ref)(),m=(0,e.ref)(!1),h=(0,e.ref)(!1),g=(0,e.ref)(!1),_=(0,e.ref)(0),v=(0,e.ref)(0),y=(0,e.ref)(0),b=(0,e.ref)(0),x=(0,e.ref)(0),S=(0,e.ref)(0),C=(0,e.ref)(0),w=(0,e.ref)(0),T=(0,e.ref)(0),E=(0,e.ref)(!1),D=(0,e.ref)(!0),O=(0,e.ref)(null),te=(0,e.ref)(!1),k={},A=null,j=null,M=null,N=null,P=!1,F=null,I=null,L=[];function ne(e){L.push(e),m.value&&ie()}function re(e){let t=L.indexOf(e);t>=0&&L.splice(t,1),m.value&&ie()}let ie=(0,t.debounce)(()=>{P||(0,e.nextTick)(()=>{P||(Y(),J(),D.value||$(_.value))})},50);(0,e.provide)(`mdSwiper`,{dimension:()=>T.value,isVertical:()=>z.value,register:ne,unregister:re}),(0,e.watch)(()=>l.autoplay,e=>{_.value=e},{immediate:!0});let ae=(0,e.computed)(()=>v.value===w.value-1),oe=(0,e.computed)(()=>v.value===0),se=(0,e.computed)(()=>Te()),R=(0,e.computed)(()=>l.transition.toLowerCase().includes(`slide`)),z=(0,e.computed)(()=>l.transition===`slideY`),ce=(0,e.computed)(()=>{let t=(d.default?.()??[]).filter(e=>e.type!==Symbol.for(`v-cmt`));return!B.value||t.length<2?null:(0,e.cloneVNode)(t[0],{class:`cu-swiper-item-first-copy`,style:H.value,isCopy:!0})}),le=(0,e.computed)(()=>{let t=(d.default?.()??[]).filter(e=>e.type!==Symbol.for(`v-cmt`));return!B.value||t.length<2?null:(0,e.cloneVNode)(t[t.length-1],{class:`cu-swiper-item-last-copy`,style:H.value,isCopy:!0})}),B=(0,e.computed)(()=>R.value&&g.value),V=e=>e.vnode;V.props=[`vnode`];let H=(0,e.computed)(()=>z.value?{height:`${T.value}px`}:{width:`${T.value}px`});(0,e.onMounted)(()=>{W()}),(0,e.onActivated)(()=>{W()}),(0,e.onDeactivated)(()=>{G()}),(0,e.onBeforeUnmount)(()=>{P=!0,M=null,F&&=(clearTimeout(F),null),I&&=(clearTimeout(I),null),G()});function U(){N&&clearTimeout(N);let e=v.value;N=setTimeout(()=>{J(e)},300)}function W(){m.value=!0,(0,e.nextTick)(()=>{J(),$(_.value),window.addEventListener(`resize`,U)})}function G(){m.value=!1,Y(),window.removeEventListener(`resize`,U),N&&clearTimeout(N)}function ue(){T.value=z.value?f.value?.clientHeight??0:f.value?.clientWidth??0}function de(){let e=new n.Scroller((e,t)=>{(0,n.render)(p.value,e,t,1,l.useNativeDriver)},{scrollingY:z.value,scrollingX:!z.value,snapping:!1,bouncing:!1,animationDuration:l.transitionDuration,scrollingComplete:()=>{M&&M()}}),t=ee.value;if(!t)return;let r=z.value?t.clientWidth:t.clientWidth*w.value,i=z.value?t.clientHeight*w.value:t.clientHeight;e.setPosition(t.clientLeft,t.clientTop),e.setDimensions(t.clientWidth,t.clientHeight,r,i),O.value=e}function fe(){L.length>1&&l.isLoop&&(x.value++,S.value++,v.value++,te.value=!0)}function K(e,n,r=!0){if(!e){(0,t.warn)(`[cu-swiper] no element for translate`);return}let i=z.value?0:-n,a=z.value?-n:0;O.value?.scrollTo(i,a,r)}function q(e=!0,t){let n=L;if(!n||!n.length)return;if(t!==void 0){let r=0,i=b.value,a=w.value;t>0?i>0?r=i-1:i===0&&(r=a-1):i<a-1?r=i+1:i===a-1&&(r=0);let o=n[i]?.$el,s=n[r]?.$el;if(!o||!s)return;o.style.opacity=String(1-Math.abs(t)),o.style.transition=e?`opacity 300ms ease`:``,s.style.opacity=String(Math.abs(t));return}let r=n[y.value]?.$el,i=n[b.value]?.$el;r&&i&&(r.style.opacity=`0`,r.style.transition=e?`opacity 500ms ease`:``,i.style.opacity=`1`,e&&(I&&clearTimeout(I),I=setTimeout(()=>{I=null,P||u(`afterChange`,y.value,b.value)},500)))}function pe(e,t){C.value=e,w.value=e+(l.isLoop&&R.value&&e>1?2:0),te.value=!1,E.value=e===1||!l.dragable,v.value=t===void 0?l.defaultIndex>=0&&l.defaultIndex<e?parseInt(String(l.defaultIndex)):0:X(t),x.value=0,S.value=e-1,y.value=v.value===x.value?S.value:v.value===S.value?x.value:v.value+1,b.value=v.value}function J(e){let t=L.length;t&&(ue(),pe(t,e),R.value?(fe(),de(),K(p.value,-T.value*v.value,!1)):q(!1),g.value=!0)}function me(){_.value>0&&C.value>1&&(Y(),j=setInterval(()=>{if(!l.isLoop&&v.value>=w.value-1)return Y();h.value||Se()},_.value))}function Y(){j&&=(clearInterval(j),null)}function he(e,t){let n=z.value,{currentLeft:r,currentTop:i,startLeft:a,startTop:o}=k;if(A===null){if(!n&&i===o||n&&r===a)return!1;if(e*e+t*t>=25){let r=Math.atan2(Math.abs(t),Math.abs(e))*180/Math.PI;return n?90-r>45:r>45}return!1}return A}function X(e){return l.isLoop&&R.value&&C.value>0?e-1<0?C.value-1:e-1>C.value-1?0:e-1:e}function ge(e){return e<0?e=0:C.value>0&&e>C.value-1&&(e=C.value-1),l.isLoop&&R.value?e+1:e}function Z(e,t){if(C.value===0||!t&&C.value<2)return;let n=v.value,r=w.value,i=v.value;e&&(t&&t.index!==void 0?v.value=t.index:e===`prev`?n>0?v.value=n-1:(!R.value&&n===0||l.isLoop&&n===0)&&(v.value=r-1):e===`next`&&(n<r-1?v.value=n+1:!R.value&&n===r-1?v.value=0:l.isLoop&&n===r-1&&(v.value=1)),l.isLoop&&R.value?(y.value=X(i),b.value=X(v.value)):(y.value=b.value,b.value=v.value),u(`beforeChange`,y.value,b.value),R.value?(F&&clearTimeout(F),F=setTimeout(()=>{if(F=null,P)return;let e=oe.value&&l.isLoop,t=ae.value&&l.isLoop;M=()=>{if(t){let e=z.value?0:x.value*T.value,t=z.value?x.value*T.value:0;O.value?.scrollTo(e,t,!1)}if(e){let e=z.value?0:S.value*T.value,t=z.value?S.value*T.value:0;O.value?.scrollTo(e,t,!1)}u(`afterChange`,y.value,b.value),M=null},K(p.value,-T.value*v.value),e?v.value=S.value:t&&(v.value=x.value)},10)):q())}function _e(e){if(E.value)return;Ee();let t=e,n=t.changedTouches?.[0]??t.touches?.[0]??t.targetTouches?.[0]??t;k={},k.startTime=new Date,k.startLeft=n.pageX,k.startTop=n.pageY,k.itemWidth=c?100:f.value?.offsetWidth??0,k.itemHeight=c?100:f.value?.offsetHeight??0}function ve(e){if(E.value)return;let t=e,n=t.changedTouches?.[0]??t.touches?.[0]??t.targetTouches?.[0]??t;k.currentLeft=n.pageX,k.currentTop=n.pageY;let r=Number(k.currentLeft)-Number(k.startLeft),i=Number(k.currentTop)-Number(k.startTop);if(A=he(Math.abs(r),Math.abs(i)),A)return;e.preventDefault();let a=Number(k.itemWidth),o=Number(k.itemHeight),s=Math.min(Math.max(-a+1,r),a-1),c=Math.min(Math.max(-o+1,i),o-1),l=z.value?c-o*v.value:s-a*v.value;R.value?K(p.value,l,!1):q(!1,r/a)}function ye(){if(E.value)return;let e=Number(new Date)-Number(k.startTime),t=Number(k.currentLeft)-Number(k.startLeft),n=Number(k.currentTop)-Number(k.startTop),a=Number(k.itemWidth),o=Number(k.itemHeight),s=v.value,c=w.value,u=e<i,d=null;u&&k.currentLeft===void 0||(z.value?Math.abs(n)>o*r||u?d=n<0?`next`:`prev`:K(p.value,-T.value*s,!0):Math.abs(t)>a*r||u?d=t<0?`next`:`prev`:R.value?K(p.value,-T.value*s,!0):q(!0,0),l.isLoop||(s===0&&d===`prev`||s===c-1&&d===`next`)&&(d=null),Z(d),k={}),$(_.value)}function be(e){M&&M(),l.isPrevent&&e.preventDefault(),h.value=!0,A=null,_e(e)}function xe(e){l.isPrevent&&e.preventDefault(),h.value&&ve(e)}function Q(e){l.isPrevent&&e.preventDefault(),A?($(_.value),h.value=!1,k={}):h.value&&=(ye(),!1)}function Se(){Z(`next`)}function Ce(){Z(`prev`)}function we(e){if(isNaN(e))return;e=parseInt(String(e));let t=ge(e);Z(t>v.value?`next`:`prev`,{index:t}),$(_.value)}function Te(){return X(v.value)}function $(e=3e3){Y(),e<500||(_.value=e||l.autoplay,me(),D.value=!1)}function Ee(){Y(),D.value=!0}return o({next:Se,prev:Ce,goto:we,getIndex:Te,play:$,stop:Ee,index:v,rItemCount:w,oItemCount:C}),(t,n)=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{ref_key:`root`,ref:f,class:(0,e.normalizeClass)([`cu-swiper`,{"cu-swiper-vertical":z.value,"cu-swiper-fade":!R.value,disabled:!g.value}]),onMousedown:be,onMousemove:xe,onMouseup:Q,onMouseleave:Q,onTouchstart:be,onTouchmove:xe,onTouchend:Q,onTouchcancel:Q},[(0,e.createElementVNode)(`div`,{ref_key:`swiperBox`,ref:ee,class:`cu-swiper-box`},[(0,e.createElementVNode)(`div`,{ref_key:`swiper`,ref:p,class:`cu-swiper-container`},[B.value&&t.$slots.default?((0,e.openBlock)(),(0,e.createElementBlock)(e.Fragment,{key:0},[le.value?((0,e.openBlock)(),(0,e.createBlock)(V,{key:0,vnode:le.value},null,8,[`vnode`])):(0,e.createCommentVNode)(``,!0)],64)):(0,e.createCommentVNode)(``,!0),(0,e.renderSlot)(t.$slots,`default`),B.value&&t.$slots.default?((0,e.openBlock)(),(0,e.createElementBlock)(e.Fragment,{key:1},[ce.value?((0,e.openBlock)(),(0,e.createBlock)(V,{key:0,vnode:ce.value},null,8,[`vnode`])):(0,e.createCommentVNode)(``,!0)],64)):(0,e.createCommentVNode)(``,!0)],512)],512),C.value>1&&a.hasDots?((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:0,class:(0,e.normalizeClass)([`cu-swiper-indicators`,{disabled:!a.hasDots}])},[((0,e.openBlock)(!0),(0,e.createElementBlock)(e.Fragment,null,(0,e.renderList)(C.value,t=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{key:t,class:(0,e.normalizeClass)([`cu-swiper-indicator`,{"cu-swiper-indicator-active":t-1===se.value}])},null,2))),128))],2)):(0,e.createCommentVNode)(``,!0)],34))}}),o=(0,e.defineComponent)({name:`cu-swiper-item`,__name:`SwiperItem`,props:{isCopy:{type:Boolean,default:!1}},setup(t){let n=t,r=(0,e.inject)(`mdSwiper`,null),i=(0,e.computed)(()=>!r||r.isVertical()?`auto`:`${r.dimension()}px`),a=(0,e.computed)(()=>!r||!r.isVertical()?`auto`:`${r.dimension()}px`),o=(0,e.getCurrentInstance)()?.proxy;return(0,e.onMounted)(()=>{n.isCopy||r&&o&&r.register(o)}),(0,e.onBeforeUnmount)(()=>{n.isCopy||r&&o&&r.unregister(o)}),(t,n)=>((0,e.openBlock)(),(0,e.createElementBlock)(`div`,{class:`cu-swiper-item`,style:(0,e.normalizeStyle)({width:i.value,height:a.value})},[(0,e.renderSlot)(t.$slots,`default`)],4))}});Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return o}});
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { Fragment as e, cloneVNode as t, computed as n, createBlock as r, createCommentVNode as i, createElementBlock as a, createElementVNode as o, defineComponent as s, getCurrentInstance as c, inject as l, nextTick as ee, normalizeClass as u, normalizeStyle as d, onActivated as te, onBeforeUnmount as ne, onDeactivated as re, onMounted as ie, openBlock as f, provide as ae, ref as p, renderList as oe, renderSlot as se, useSlots as ce, watch as le } from "vue";
|
|
2
|
+
import { debounce as ue, warn as de } from "@centui/core";
|
|
3
|
+
import { Scroller as fe, render as pe } from "@centui/core/web";
|
|
4
|
+
// src/components/swiper/Swiper.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
+
var me = .5, he = 300, m = /* @__PURE__ */ s({
|
|
6
|
+
name: "cu-swiper",
|
|
7
|
+
__name: "Swiper",
|
|
8
|
+
props: {
|
|
9
|
+
autoplay: { default: 3e3 },
|
|
10
|
+
transition: { default: "slide" },
|
|
11
|
+
transitionDuration: { default: 250 },
|
|
12
|
+
defaultIndex: { default: 0 },
|
|
13
|
+
hasDots: {
|
|
14
|
+
type: Boolean,
|
|
15
|
+
default: !0
|
|
16
|
+
},
|
|
17
|
+
isPrevent: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: !0
|
|
20
|
+
},
|
|
21
|
+
isLoop: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
default: !0
|
|
24
|
+
},
|
|
25
|
+
dragable: {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
default: !0
|
|
28
|
+
},
|
|
29
|
+
useNativeDriver: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: !0
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
emits: ["beforeChange", "afterChange"],
|
|
35
|
+
setup(s, { expose: c, emit: l }) {
|
|
36
|
+
let d = typeof process < "u" && process.env.MAND_ENV === "test", m = s, h = l, ge = ce(), g = p(), _e = p(), _ = p(), v = p(!1), y = p(!1), b = p(!1), x = p(0), S = p(0), C = p(0), w = p(0), T = p(0), E = p(0), D = p(0), O = p(0), k = p(0), A = p(!1), j = p(!0), M = p(null), ve = p(!1), N = {}, P = null, F = null, I = null, L = null, R = !1, z = null, B = null, V = [];
|
|
37
|
+
function ye(e) {
|
|
38
|
+
V.push(e), v.value && xe();
|
|
39
|
+
}
|
|
40
|
+
function be(e) {
|
|
41
|
+
let t = V.indexOf(e);
|
|
42
|
+
t >= 0 && V.splice(t, 1), v.value && xe();
|
|
43
|
+
}
|
|
44
|
+
let xe = ue(() => {
|
|
45
|
+
R || ee(() => {
|
|
46
|
+
R || (Y(), J(), j.value || $(x.value));
|
|
47
|
+
});
|
|
48
|
+
}, 50);
|
|
49
|
+
ae("mdSwiper", {
|
|
50
|
+
dimension: () => k.value,
|
|
51
|
+
isVertical: () => U.value,
|
|
52
|
+
register: ye,
|
|
53
|
+
unregister: be
|
|
54
|
+
}), le(() => m.autoplay, (e) => {
|
|
55
|
+
x.value = e;
|
|
56
|
+
}, { immediate: !0 });
|
|
57
|
+
let Se = n(() => S.value === O.value - 1), Ce = n(() => S.value === 0), we = n(() => Ke()), H = n(() => m.transition.toLowerCase().includes("slide")), U = n(() => m.transition === "slideY"), Te = n(() => {
|
|
58
|
+
let e = (ge.default?.() ?? []).filter((e) => e.type !== Symbol.for("v-cmt"));
|
|
59
|
+
return !W.value || e.length < 2 ? null : t(e[0], {
|
|
60
|
+
class: "cu-swiper-item-first-copy",
|
|
61
|
+
style: De.value,
|
|
62
|
+
isCopy: !0
|
|
63
|
+
});
|
|
64
|
+
}), Ee = n(() => {
|
|
65
|
+
let e = (ge.default?.() ?? []).filter((e) => e.type !== Symbol.for("v-cmt"));
|
|
66
|
+
return !W.value || e.length < 2 ? null : t(e[e.length - 1], {
|
|
67
|
+
class: "cu-swiper-item-last-copy",
|
|
68
|
+
style: De.value,
|
|
69
|
+
isCopy: !0
|
|
70
|
+
});
|
|
71
|
+
}), W = n(() => H.value && b.value), G = (e) => e.vnode;
|
|
72
|
+
G.props = ["vnode"];
|
|
73
|
+
let De = n(() => U.value ? { height: `${k.value}px` } : { width: `${k.value}px` });
|
|
74
|
+
ie(() => {
|
|
75
|
+
ke();
|
|
76
|
+
}), te(() => {
|
|
77
|
+
ke();
|
|
78
|
+
}), re(() => {
|
|
79
|
+
Ae();
|
|
80
|
+
}), ne(() => {
|
|
81
|
+
R = !0, I = null, z &&= (clearTimeout(z), null), B &&= (clearTimeout(B), null), Ae();
|
|
82
|
+
});
|
|
83
|
+
function Oe() {
|
|
84
|
+
L && clearTimeout(L);
|
|
85
|
+
let e = S.value;
|
|
86
|
+
L = setTimeout(() => {
|
|
87
|
+
J(e);
|
|
88
|
+
}, 300);
|
|
89
|
+
}
|
|
90
|
+
function ke() {
|
|
91
|
+
v.value = !0, ee(() => {
|
|
92
|
+
J(), $(x.value), window.addEventListener("resize", Oe);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function Ae() {
|
|
96
|
+
v.value = !1, Y(), window.removeEventListener("resize", Oe), L && clearTimeout(L);
|
|
97
|
+
}
|
|
98
|
+
function je() {
|
|
99
|
+
k.value = U.value ? g.value?.clientHeight ?? 0 : g.value?.clientWidth ?? 0;
|
|
100
|
+
}
|
|
101
|
+
function Me() {
|
|
102
|
+
let e = new fe((e, t) => {
|
|
103
|
+
pe(_.value, e, t, 1, m.useNativeDriver);
|
|
104
|
+
}, {
|
|
105
|
+
scrollingY: U.value,
|
|
106
|
+
scrollingX: !U.value,
|
|
107
|
+
snapping: !1,
|
|
108
|
+
bouncing: !1,
|
|
109
|
+
animationDuration: m.transitionDuration,
|
|
110
|
+
scrollingComplete: () => {
|
|
111
|
+
I && I();
|
|
112
|
+
}
|
|
113
|
+
}), t = _e.value;
|
|
114
|
+
if (!t) return;
|
|
115
|
+
let n = U.value ? t.clientWidth : t.clientWidth * O.value, r = U.value ? t.clientHeight * O.value : t.clientHeight;
|
|
116
|
+
e.setPosition(t.clientLeft, t.clientTop), e.setDimensions(t.clientWidth, t.clientHeight, n, r), M.value = e;
|
|
117
|
+
}
|
|
118
|
+
function Ne() {
|
|
119
|
+
V.length > 1 && m.isLoop && (T.value++, E.value++, S.value++, ve.value = !0);
|
|
120
|
+
}
|
|
121
|
+
function K(e, t, n = !0) {
|
|
122
|
+
if (!e) {
|
|
123
|
+
de("[cu-swiper] no element for translate");
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
let r = U.value ? 0 : -t, i = U.value ? -t : 0;
|
|
127
|
+
M.value?.scrollTo(r, i, n);
|
|
128
|
+
}
|
|
129
|
+
function q(e = !0, t) {
|
|
130
|
+
let n = V;
|
|
131
|
+
if (!n || !n.length) return;
|
|
132
|
+
if (t !== void 0) {
|
|
133
|
+
let r = 0, i = w.value, a = O.value;
|
|
134
|
+
t > 0 ? i > 0 ? r = i - 1 : i === 0 && (r = a - 1) : i < a - 1 ? r = i + 1 : i === a - 1 && (r = 0);
|
|
135
|
+
let o = n[i]?.$el, s = n[r]?.$el;
|
|
136
|
+
if (!o || !s) return;
|
|
137
|
+
o.style.opacity = String(1 - Math.abs(t)), o.style.transition = e ? "opacity 300ms ease" : "", s.style.opacity = String(Math.abs(t));
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
let r = n[C.value]?.$el, i = n[w.value]?.$el;
|
|
141
|
+
r && i && (r.style.opacity = "0", r.style.transition = e ? "opacity 500ms ease" : "", i.style.opacity = "1", e && (B && clearTimeout(B), B = setTimeout(() => {
|
|
142
|
+
B = null, R || h("afterChange", C.value, w.value);
|
|
143
|
+
}, 500)));
|
|
144
|
+
}
|
|
145
|
+
function Pe(e, t) {
|
|
146
|
+
D.value = e, O.value = e + (m.isLoop && H.value && e > 1 ? 2 : 0), ve.value = !1, A.value = e === 1 || !m.dragable, S.value = t === void 0 ? m.defaultIndex >= 0 && m.defaultIndex < e ? parseInt(String(m.defaultIndex)) : 0 : X(t), T.value = 0, E.value = e - 1, C.value = S.value === T.value ? E.value : S.value === E.value ? T.value : S.value + 1, w.value = S.value;
|
|
147
|
+
}
|
|
148
|
+
function J(e) {
|
|
149
|
+
let t = V.length;
|
|
150
|
+
t && (je(), Pe(t, e), H.value ? (Ne(), Me(), K(_.value, -k.value * S.value, !1)) : q(!1), b.value = !0);
|
|
151
|
+
}
|
|
152
|
+
function Fe() {
|
|
153
|
+
x.value > 0 && D.value > 1 && (Y(), F = setInterval(() => {
|
|
154
|
+
if (!m.isLoop && S.value >= O.value - 1) return Y();
|
|
155
|
+
y.value || Ue();
|
|
156
|
+
}, x.value));
|
|
157
|
+
}
|
|
158
|
+
function Y() {
|
|
159
|
+
F &&= (clearInterval(F), null);
|
|
160
|
+
}
|
|
161
|
+
function Ie(e, t) {
|
|
162
|
+
let n = U.value, { currentLeft: r, currentTop: i, startLeft: a, startTop: o } = N;
|
|
163
|
+
if (P === null) {
|
|
164
|
+
if (!n && i === o || n && r === a) return !1;
|
|
165
|
+
if (e * e + t * t >= 25) {
|
|
166
|
+
let r = Math.atan2(Math.abs(t), Math.abs(e)) * 180 / Math.PI;
|
|
167
|
+
return n ? 90 - r > 45 : r > 45;
|
|
168
|
+
}
|
|
169
|
+
return !1;
|
|
170
|
+
}
|
|
171
|
+
return P;
|
|
172
|
+
}
|
|
173
|
+
function X(e) {
|
|
174
|
+
return m.isLoop && H.value && D.value > 0 ? e - 1 < 0 ? D.value - 1 : e - 1 > D.value - 1 ? 0 : e - 1 : e;
|
|
175
|
+
}
|
|
176
|
+
function Le(e) {
|
|
177
|
+
return e < 0 ? e = 0 : D.value > 0 && e > D.value - 1 && (e = D.value - 1), m.isLoop && H.value ? e + 1 : e;
|
|
178
|
+
}
|
|
179
|
+
function Z(e, t) {
|
|
180
|
+
if (D.value === 0 || !t && D.value < 2) return;
|
|
181
|
+
let n = S.value, r = O.value, i = S.value;
|
|
182
|
+
e && (t && t.index !== void 0 ? S.value = t.index : e === "prev" ? n > 0 ? S.value = n - 1 : (!H.value && n === 0 || m.isLoop && n === 0) && (S.value = r - 1) : e === "next" && (n < r - 1 ? S.value = n + 1 : !H.value && n === r - 1 ? S.value = 0 : m.isLoop && n === r - 1 && (S.value = 1)), m.isLoop && H.value ? (C.value = X(i), w.value = X(S.value)) : (C.value = w.value, w.value = S.value), h("beforeChange", C.value, w.value), H.value ? (z && clearTimeout(z), z = setTimeout(() => {
|
|
183
|
+
if (z = null, R) return;
|
|
184
|
+
let e = Ce.value && m.isLoop, t = Se.value && m.isLoop;
|
|
185
|
+
I = () => {
|
|
186
|
+
if (t) {
|
|
187
|
+
let e = U.value ? 0 : T.value * k.value, t = U.value ? T.value * k.value : 0;
|
|
188
|
+
M.value?.scrollTo(e, t, !1);
|
|
189
|
+
}
|
|
190
|
+
if (e) {
|
|
191
|
+
let e = U.value ? 0 : E.value * k.value, t = U.value ? E.value * k.value : 0;
|
|
192
|
+
M.value?.scrollTo(e, t, !1);
|
|
193
|
+
}
|
|
194
|
+
h("afterChange", C.value, w.value), I = null;
|
|
195
|
+
}, K(_.value, -k.value * S.value), e ? S.value = E.value : t && (S.value = T.value);
|
|
196
|
+
}, 10)) : q());
|
|
197
|
+
}
|
|
198
|
+
function Re(e) {
|
|
199
|
+
if (A.value) return;
|
|
200
|
+
qe();
|
|
201
|
+
let t = e, n = t.changedTouches?.[0] ?? t.touches?.[0] ?? t.targetTouches?.[0] ?? t;
|
|
202
|
+
N = {}, N.startTime = /* @__PURE__ */ new Date(), N.startLeft = n.pageX, N.startTop = n.pageY, N.itemWidth = d ? 100 : g.value?.offsetWidth ?? 0, N.itemHeight = d ? 100 : g.value?.offsetHeight ?? 0;
|
|
203
|
+
}
|
|
204
|
+
function ze(e) {
|
|
205
|
+
if (A.value) return;
|
|
206
|
+
let t = e, n = t.changedTouches?.[0] ?? t.touches?.[0] ?? t.targetTouches?.[0] ?? t;
|
|
207
|
+
N.currentLeft = n.pageX, N.currentTop = n.pageY;
|
|
208
|
+
let r = Number(N.currentLeft) - Number(N.startLeft), i = Number(N.currentTop) - Number(N.startTop);
|
|
209
|
+
if (P = Ie(Math.abs(r), Math.abs(i)), P) return;
|
|
210
|
+
e.preventDefault();
|
|
211
|
+
let a = Number(N.itemWidth), o = Number(N.itemHeight), s = Math.min(Math.max(-a + 1, r), a - 1), c = Math.min(Math.max(-o + 1, i), o - 1), l = U.value ? c - o * S.value : s - a * S.value;
|
|
212
|
+
H.value ? K(_.value, l, !1) : q(!1, r / a);
|
|
213
|
+
}
|
|
214
|
+
function Be() {
|
|
215
|
+
if (A.value) return;
|
|
216
|
+
let e = Number(/* @__PURE__ */ new Date()) - Number(N.startTime), t = Number(N.currentLeft) - Number(N.startLeft), n = Number(N.currentTop) - Number(N.startTop), r = Number(N.itemWidth), i = Number(N.itemHeight), a = S.value, o = O.value, s = e < he, c = null;
|
|
217
|
+
s && N.currentLeft === void 0 || (U.value ? Math.abs(n) > i * me || s ? c = n < 0 ? "next" : "prev" : K(_.value, -k.value * a, !0) : Math.abs(t) > r * me || s ? c = t < 0 ? "next" : "prev" : H.value ? K(_.value, -k.value * a, !0) : q(!0, 0), m.isLoop || (a === 0 && c === "prev" || a === o - 1 && c === "next") && (c = null), Z(c), N = {}), $(x.value);
|
|
218
|
+
}
|
|
219
|
+
function Ve(e) {
|
|
220
|
+
I && I(), m.isPrevent && e.preventDefault(), y.value = !0, P = null, Re(e);
|
|
221
|
+
}
|
|
222
|
+
function He(e) {
|
|
223
|
+
m.isPrevent && e.preventDefault(), y.value && ze(e);
|
|
224
|
+
}
|
|
225
|
+
function Q(e) {
|
|
226
|
+
m.isPrevent && e.preventDefault(), P ? ($(x.value), y.value = !1, N = {}) : y.value &&= (Be(), !1);
|
|
227
|
+
}
|
|
228
|
+
function Ue() {
|
|
229
|
+
Z("next");
|
|
230
|
+
}
|
|
231
|
+
function We() {
|
|
232
|
+
Z("prev");
|
|
233
|
+
}
|
|
234
|
+
function Ge(e) {
|
|
235
|
+
if (isNaN(e)) return;
|
|
236
|
+
e = parseInt(String(e));
|
|
237
|
+
let t = Le(e);
|
|
238
|
+
Z(t > S.value ? "next" : "prev", { index: t }), $(x.value);
|
|
239
|
+
}
|
|
240
|
+
function Ke() {
|
|
241
|
+
return X(S.value);
|
|
242
|
+
}
|
|
243
|
+
function $(e = 3e3) {
|
|
244
|
+
Y(), e < 500 || (x.value = e || m.autoplay, Fe(), j.value = !1);
|
|
245
|
+
}
|
|
246
|
+
function qe() {
|
|
247
|
+
Y(), j.value = !0;
|
|
248
|
+
}
|
|
249
|
+
return c({
|
|
250
|
+
next: Ue,
|
|
251
|
+
prev: We,
|
|
252
|
+
goto: Ge,
|
|
253
|
+
getIndex: Ke,
|
|
254
|
+
play: $,
|
|
255
|
+
stop: qe,
|
|
256
|
+
index: S,
|
|
257
|
+
rItemCount: O,
|
|
258
|
+
oItemCount: D
|
|
259
|
+
}), (t, n) => (f(), a("div", {
|
|
260
|
+
ref_key: "root",
|
|
261
|
+
ref: g,
|
|
262
|
+
class: u(["cu-swiper", {
|
|
263
|
+
"cu-swiper-vertical": U.value,
|
|
264
|
+
"cu-swiper-fade": !H.value,
|
|
265
|
+
disabled: !b.value
|
|
266
|
+
}]),
|
|
267
|
+
onMousedown: Ve,
|
|
268
|
+
onMousemove: He,
|
|
269
|
+
onMouseup: Q,
|
|
270
|
+
onMouseleave: Q,
|
|
271
|
+
onTouchstart: Ve,
|
|
272
|
+
onTouchmove: He,
|
|
273
|
+
onTouchend: Q,
|
|
274
|
+
onTouchcancel: Q
|
|
275
|
+
}, [o("div", {
|
|
276
|
+
ref_key: "swiperBox",
|
|
277
|
+
ref: _e,
|
|
278
|
+
class: "cu-swiper-box"
|
|
279
|
+
}, [o("div", {
|
|
280
|
+
ref_key: "swiper",
|
|
281
|
+
ref: _,
|
|
282
|
+
class: "cu-swiper-container"
|
|
283
|
+
}, [
|
|
284
|
+
W.value && t.$slots.default ? (f(), a(e, { key: 0 }, [Ee.value ? (f(), r(G, {
|
|
285
|
+
key: 0,
|
|
286
|
+
vnode: Ee.value
|
|
287
|
+
}, null, 8, ["vnode"])) : i("", !0)], 64)) : i("", !0),
|
|
288
|
+
se(t.$slots, "default"),
|
|
289
|
+
W.value && t.$slots.default ? (f(), a(e, { key: 1 }, [Te.value ? (f(), r(G, {
|
|
290
|
+
key: 0,
|
|
291
|
+
vnode: Te.value
|
|
292
|
+
}, null, 8, ["vnode"])) : i("", !0)], 64)) : i("", !0)
|
|
293
|
+
], 512)], 512), D.value > 1 && s.hasDots ? (f(), a("div", {
|
|
294
|
+
key: 0,
|
|
295
|
+
class: u(["cu-swiper-indicators", { disabled: !s.hasDots }])
|
|
296
|
+
}, [(f(!0), a(e, null, oe(D.value, (e) => (f(), a("div", {
|
|
297
|
+
key: e,
|
|
298
|
+
class: u(["cu-swiper-indicator", { "cu-swiper-indicator-active": e - 1 === we.value }])
|
|
299
|
+
}, null, 2))), 128))], 2)) : i("", !0)], 34));
|
|
300
|
+
}
|
|
301
|
+
}), h = /* @__PURE__ */ s({
|
|
302
|
+
name: "cu-swiper-item",
|
|
303
|
+
__name: "SwiperItem",
|
|
304
|
+
props: { isCopy: {
|
|
305
|
+
type: Boolean,
|
|
306
|
+
default: !1
|
|
307
|
+
} },
|
|
308
|
+
setup(e) {
|
|
309
|
+
let t = e, r = l("mdSwiper", null), i = n(() => !r || r.isVertical() ? "auto" : `${r.dimension()}px`), o = n(() => !r || !r.isVertical() ? "auto" : `${r.dimension()}px`), s = c()?.proxy;
|
|
310
|
+
return ie(() => {
|
|
311
|
+
t.isCopy || r && s && r.register(s);
|
|
312
|
+
}), ne(() => {
|
|
313
|
+
t.isCopy || r && s && r.unregister(s);
|
|
314
|
+
}), (e, t) => (f(), a("div", {
|
|
315
|
+
class: "cu-swiper-item",
|
|
316
|
+
style: d({
|
|
317
|
+
width: i.value,
|
|
318
|
+
height: o.value
|
|
319
|
+
})
|
|
320
|
+
}, [se(e.$slots, "default")], 4));
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
export { m as n, h as t };
|