Socket
Socket
Sign inDemoInstall

mobile-select

Package Overview
Dependencies
0
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.3.1 to 1.3.2

29

dist/mobile-select.d.ts
/*
* mobile-select v1.3.0
* mobile-select v1.3.1
* Homepage: https://github.com/onlyhom/mobile-select

@@ -9,7 +9,11 @@ * Released under the MIT License.

export type CascadeData = {
[k: string]: any;
};
export type ResultVal = number | string | CascadeData;
export interface CallbackFn {
(curValue?: number[] | string[], indexArr?: number[], context?: any): void;
(curValue: ResultVal[], indexArr: number[], context: MobileSelect): void;
}
export interface OldCallbackFn {
(indexArr?: number[], curValue?: number[] | string[], context?: any): void;
(indexArr: number[], curValue: ResultVal[], context: MobileSelect): void;
}

@@ -21,5 +25,2 @@ export type KeyMap = {

};
export type CascadeData = {
[k: string]: any;
};
export type OptionData = CascadeData | string | number;

@@ -77,9 +78,9 @@ export type CustomConfig = {

scrollSpeed?: number;
/** 旧版本 选择完毕的回调函数 */
/** (即将废弃) 选择完毕的回调函数 */
callback?: OldCallbackFn;
/** 旧版本 取消面板的回调函数 */
/** (即将废弃) 取消面板的回调函数 */
cancel?: OldCallbackFn;
/** 旧版本 滚动滚动完毕的回调函数 */
/** (即将废弃) 滚动滚动完毕的回调函数 */
transitionEnd?: OldCallbackFn;
/** 旧版本 onChange后 是否修改trigger的innerText */
/** (即将废弃) onChange后 是否修改trigger的innerText */
triggerDisplayData?: boolean;

@@ -89,7 +90,7 @@ };

declare class MobileSelect {
mobileSelect: any;
mobileSelect: HTMLDivElement;
trigger: HTMLElement;
wheel: HTMLCollectionOf<HTMLElement>;
slider: HTMLCollectionOf<HTMLElement>;
wheels: HTMLDivElement;
wheelList: HTMLCollectionOf<HTMLElement>;
sliderList: HTMLCollectionOf<HTMLElement>;
wheelsContain: HTMLDivElement;
panel: HTMLDivElement;

@@ -96,0 +97,0 @@ ensureBtn: HTMLDivElement;

/*
* mobile-select v1.3.0
* mobile-select v1.3.1
* Homepage: https://github.com/onlyhom/mobile-select

@@ -15,5 +15,5 @@ * Released under the MIT License.

h(this, "trigger");
h(this, "wheel");
h(this, "slider");
h(this, "wheels");
h(this, "wheelList");
h(this, "sliderList");
h(this, "wheelsContain");
h(this, "panel");

@@ -52,4 +52,4 @@ h(this, "ensureBtn");

if (this.isJsonType = r.checkDataType(this.wheelsData), this.renderComponent(this.wheelsData), !!this.checkTriggerAvailable()) {
if (this.wheel = this.mobileSelect.getElementsByClassName("ms-wheel"), this.slider = this.mobileSelect.getElementsByClassName("ms-select-container"), this.panel = this.mobileSelect.querySelector(".ms-panel"), this.wheels = this.mobileSelect.querySelector(".ms-wheels"), this.ensureBtn = this.mobileSelect.querySelector(".ms-ensure"), this.cancelBtn = this.mobileSelect.querySelector(".ms-cancel"), this.grayLayer = this.mobileSelect.querySelector(".ms-gray-layer"), this.popUp = this.mobileSelect.querySelector(".ms-content"), this.optionHeight = this.mobileSelect.querySelector("li").offsetHeight, t.initValue && t.triggerDisplayValue && (this.trigger.innerText = t.initValue), this.setStyle(t), this.isPC = r.checkIsPC(), this.isCascade = this.checkCascade(), this.isCascade && this.initCascade(), t.initValue && (this.initPosition = this.getPositionByValue()), this.initPosition.length < this.slider.length) {
const e = this.slider.length - this.initPosition.length;
if (this.wheelList = this.mobileSelect.getElementsByClassName("ms-wheel"), this.sliderList = this.mobileSelect.getElementsByClassName("ms-select-container"), this.panel = this.mobileSelect.querySelector(".ms-panel"), this.wheelsContain = this.mobileSelect.querySelector(".ms-wheels"), this.ensureBtn = this.mobileSelect.querySelector(".ms-ensure"), this.cancelBtn = this.mobileSelect.querySelector(".ms-cancel"), this.grayLayer = this.mobileSelect.querySelector(".ms-gray-layer"), this.popUp = this.mobileSelect.querySelector(".ms-content"), this.optionHeight = this.mobileSelect.querySelector("li").offsetHeight, t.initValue && t.triggerDisplayValue && (this.trigger.innerText = t.initValue), this.setStyle(t), this.isPC = r.checkIsPC(), this.isCascade = this.checkCascade(), this.isCascade && this.initCascade(), t.initValue && (this.initPosition = this.getPositionByValue()), this.initPosition.length < this.sliderList.length) {
const e = this.sliderList.length - this.initPosition.length;
for (let i = 0; i < e; i++)

@@ -74,4 +74,4 @@ this.initPosition.push(0);

let e = "";
for (let o = 0; o < this.wheel.length; o++)
o == this.wheel.length - 1 ? e += this.getInnerText(o) : e += this.getInnerText(o) + this.config.connector;
for (let o = 0; o < this.wheelList.length; o++)
o == this.wheelList.length - 1 ? e += this.getInnerText(o) : e += this.getInnerText(o) + this.config.connector;
t.triggerDisplayValue && (this.trigger.innerText = e), this.curIndexArr = this.getIndexArr(), this.curValue = this.getCurValue(), (s = (i = this.config).callback) == null || s.call(i, this.curIndexArr, this.curValue, this), (l = (n = this.config).onChange) == null || l.call(n, this.curValue, this.curIndexArr, this);

@@ -170,7 +170,7 @@ }

var t, e, i;
this.mobileSelect.classList.add("ms-show"), (t = document.querySelector("body")) == null || t.classList.add("ms-show"), typeof this.config.onShow == "function" && ((i = (e = this.config).onShow) == null || i.call(e));
this.mobileSelect.classList.add("ms-show"), (t = document.querySelector("body")) == null || t.classList.add("ms-show"), typeof this.config.onShow == "function" && ((i = (e = this.config).onShow) == null || i.call(e, this.curValue, this.curIndexArr, this));
}
hide() {
var t, e, i;
this.mobileSelect.classList.remove("ms-show"), (t = document.querySelector("body")) == null || t.classList.remove("ms-show"), typeof this.config.onHide == "function" && ((i = (e = this.config).onHide) == null || i.call(e));
this.mobileSelect.classList.remove("ms-show"), (t = document.querySelector("body")) == null || t.classList.remove("ms-show"), typeof this.config.onHide == "function" && ((i = (e = this.config).onHide) == null || i.call(e, this.curValue, this.curIndexArr, this));
}

@@ -223,12 +223,12 @@ registerEvents(t) {

reRenderWheels() {
const t = this.wheel.length - this.displayJson.length;
const t = this.wheelList.length - this.displayJson.length;
if (t > 0)
for (let e = 0; e < t; e++)
this.wheels.removeChild(this.wheel[this.wheel.length - 1]);
this.wheelsContain.removeChild(this.wheelList[this.wheelList.length - 1]);
for (let e = 0; e < this.displayJson.length; e++)
if (this.wheel[e])
this.slider[e].innerHTML = this.getOptionsHtmlStr(this.displayJson[e]);
if (this.wheelList[e])
this.sliderList[e].innerHTML = this.getOptionsHtmlStr(this.displayJson[e]);
else {
const i = document.createElement("div");
i.className = "ms-wheel", i.innerHTML = `<ul class="ms-select-container">${this.getOptionsHtmlStr(this.displayJson[e])}</ul>`, i.setAttribute("data-index", e.toString()), this.wheels.appendChild(i);
i.className = "ms-wheel", i.innerHTML = `<ul class="ms-select-container">${this.getOptionsHtmlStr(this.displayJson[e])}</ul>`, i.setAttribute("data-index", e.toString()), this.wheelsContain.appendChild(i);
}

@@ -279,8 +279,8 @@ }

let s;
if (this.slider.length > e.length) {
s = this.slider.length - e.length;
if (this.sliderList.length > e.length) {
s = this.sliderList.length - e.length;
for (let n = 0; n < s; n++)
i.push(0);
} else if (this.slider.length < e.length) {
s = e.length - this.slider.length;
} else if (this.sliderList.length < e.length) {
s = e.length - this.sliderList.length;
for (let n = 0; n < s; n++)

@@ -295,4 +295,4 @@ i.pop();

if (this.isCascade) {
if (this.cascadeJsonData = t, this.displayJson = [], this.initCascade(), this.initPosition.length < this.slider.length) {
const e = this.slider.length - this.initPosition.length;
if (this.cascadeJsonData = t, this.displayJson = [], this.initCascade(), this.initPosition.length < this.sliderList.length) {
const e = this.sliderList.length - this.initPosition.length;
for (let i = 0; i < e; i++)

@@ -310,15 +310,15 @@ this.initPosition.push(0);

let i = "";
i += this.getOptionsHtmlStr(e), this.wheelsData[t] = this.isJsonType ? { data: e } : e, this.slider[t].innerHTML = i;
i += this.getOptionsHtmlStr(e), this.wheelsData[t] = this.isJsonType ? { data: e } : e, this.sliderList[t].innerHTML = i;
}
fixRowStyle() {
if (this.initColWidth.length && this.initColWidth.length === this.wheel.length) {
if (this.initColWidth.length && this.initColWidth.length === this.wheelList.length) {
const e = this.initColWidth.reduce((i, s) => i + s, 0);
this.initColWidth.forEach((i, s) => {
this.wheel[s].style.width = (i / e * 100).toFixed(2) + "%";
this.wheelList[s].style.width = (i / e * 100).toFixed(2) + "%";
});
return;
}
const t = (100 / this.wheel.length).toFixed(2);
for (let e = 0; e < this.wheel.length; e++)
this.wheel[e].style.width = t + "%";
const t = (100 / this.wheelList.length).toFixed(2);
for (let e = 0; e < this.wheelList.length; e++)
this.wheelList[e].style.width = t + "%";
}

@@ -337,3 +337,3 @@ getIndex(t) {

if (this.isCascade)
for (let s = 0; s < this.wheel.length; s++) {
for (let s = 0; s < this.wheelList.length; s++) {
const n = this.displayJson[s][e[s]];

@@ -361,4 +361,4 @@ n && t.push({

const e = [];
for (let i = 0; i < this.slider.length; i++)
e.push(this.calcDistance(t[i])), this.movePosition(this.slider[i], e[i]);
for (let i = 0; i < this.sliderList.length; i++)
e.push(this.calcDistance(t[i])), this.movePosition(this.sliderList[i], e[i]);
this.curDistance = e;

@@ -373,3 +373,3 @@ }

locatePosition(t, e) {
this.curDistance[t] = this.calcDistance(e), this.movePosition(this.slider[t], this.curDistance[t]), this.isCascade && this.checkRange(t, this.getIndexArr());
this.curDistance[t] = this.calcDistance(e), this.movePosition(this.sliderList[t], this.curDistance[t]), this.isCascade && this.checkRange(t, this.getIndexArr());
}

@@ -381,8 +381,8 @@ updateCurDistance(t, e) {

var s;
const e = this.slider[t].getElementsByTagName("li").length;
const e = this.sliderList[t].getElementsByTagName("li").length;
let i = this.getIndex(this.curDistance[t]);
return i >= e ? i = e - 1 : i < 0 && (i = 0), ((s = this.slider[t].getElementsByTagName("li")[i]) == null ? void 0 : s.innerText) || "";
return i >= e ? i = e - 1 : i < 0 && (i = 0), ((s = this.sliderList[t].getElementsByTagName("li")[i]) == null ? void 0 : s.innerText) || "";
}
touch(t) {
var l, o, d, a, c, u, f, C;
var l, o, d, a, c, u, f, v;
const i = (t.composedPath && t.composedPath()).find((m) => {

@@ -411,7 +411,7 @@ var p;

if (m != 2) {
const p = m - 2, v = this.curDistance[n] + p * this.optionHeight;
v <= 2 * this.optionHeight && v >= this.oversizeBorder && (this.curDistance[n] = v, this.movePosition(s, this.curDistance[n]), (o = (l = this.config).transitionEnd) == null || o.call(l, this.getIndexArr(), this.getCurValue(), this), (a = (d = this.config).onTransitionEnd) == null || a.call(d, this.getCurValue(), this.getIndexArr(), this));
const p = m - 2, C = this.curDistance[n] + p * this.optionHeight;
C <= 2 * this.optionHeight && C >= this.oversizeBorder && (this.curDistance[n] = C, this.movePosition(s, this.curDistance[n]), (o = (l = this.config).transitionEnd) == null || o.call(l, this.getIndexArr(), this.getCurValue(), this), (a = (d = this.config).onTransitionEnd) == null || a.call(d, this.getCurValue(), this.getIndexArr(), this));
}
} else
this.updateCurDistance(s, n), this.curDistance[n] = this.fixPosition(this.curDistance[n]), this.curDistance[n] > 2 * this.optionHeight ? this.curDistance[n] = 2 * this.optionHeight : this.curDistance[n] < this.oversizeBorder && (this.curDistance[n] = this.oversizeBorder), this.movePosition(s, this.curDistance[n]), (u = (c = this.config).transitionEnd) == null || u.call(c, this.getIndexArr(), this.getCurValue(), this), (C = (f = this.config).onTransitionEnd) == null || C.call(f, this.getCurValue(), this.getIndexArr(), this);
this.updateCurDistance(s, n), this.curDistance[n] = this.fixPosition(this.curDistance[n]), this.curDistance[n] > 2 * this.optionHeight ? this.curDistance[n] = 2 * this.optionHeight : this.curDistance[n] < this.oversizeBorder && (this.curDistance[n] = this.oversizeBorder), this.movePosition(s, this.curDistance[n]), (u = (c = this.config).transitionEnd) == null || u.call(c, this.getIndexArr(), this.getCurValue(), this), (v = (f = this.config).onTransitionEnd) == null || v.call(f, this.getCurValue(), this.getIndexArr(), this);
t.type === "mouseup" && (this.enableClickStatus = !1), this.isCascade && this.checkRange(n, this.getIndexArr());

@@ -418,0 +418,0 @@ break;

/*
* mobile-select v1.3.0
* mobile-select v1.3.1
* Homepage: https://github.com/onlyhom/mobile-select

@@ -63,5 +63,5 @@ * Released under the MIT License.

h(this, "trigger");
h(this, "wheel");
h(this, "slider");
h(this, "wheels");
h(this, "wheelList");
h(this, "sliderList");
h(this, "wheelsContain");
h(this, "panel");

@@ -106,4 +106,4 @@ h(this, "ensureBtn");

if (this.isJsonType = l.checkDataType(this.wheelsData), this.renderComponent(this.wheelsData), !!this.checkTriggerAvailable()) {
if (this.wheel = this.mobileSelect.getElementsByClassName("ms-wheel"), this.slider = this.mobileSelect.getElementsByClassName("ms-select-container"), this.panel = this.mobileSelect.querySelector(".ms-panel"), this.wheels = this.mobileSelect.querySelector(".ms-wheels"), this.ensureBtn = this.mobileSelect.querySelector(".ms-ensure"), this.cancelBtn = this.mobileSelect.querySelector(".ms-cancel"), this.grayLayer = this.mobileSelect.querySelector(".ms-gray-layer"), this.popUp = this.mobileSelect.querySelector(".ms-content"), this.optionHeight = this.mobileSelect.querySelector("li").offsetHeight, t.initValue && t.triggerDisplayValue && (this.trigger.innerText = t.initValue), this.setStyle(t), this.isPC = l.checkIsPC(), this.isCascade = this.checkCascade(), this.isCascade && this.initCascade(), t.initValue && (this.initPosition = this.getPositionByValue()), this.initPosition.length < this.slider.length) {
var e = this.slider.length - this.initPosition.length;
if (this.wheelList = this.mobileSelect.getElementsByClassName("ms-wheel"), this.sliderList = this.mobileSelect.getElementsByClassName("ms-select-container"), this.panel = this.mobileSelect.querySelector(".ms-panel"), this.wheelsContain = this.mobileSelect.querySelector(".ms-wheels"), this.ensureBtn = this.mobileSelect.querySelector(".ms-ensure"), this.cancelBtn = this.mobileSelect.querySelector(".ms-cancel"), this.grayLayer = this.mobileSelect.querySelector(".ms-gray-layer"), this.popUp = this.mobileSelect.querySelector(".ms-content"), this.optionHeight = this.mobileSelect.querySelector("li").offsetHeight, t.initValue && t.triggerDisplayValue && (this.trigger.innerText = t.initValue), this.setStyle(t), this.isPC = l.checkIsPC(), this.isCascade = this.checkCascade(), this.isCascade && this.initCascade(), t.initValue && (this.initPosition = this.getPositionByValue()), this.initPosition.length < this.sliderList.length) {
var e = this.sliderList.length - this.initPosition.length;

@@ -132,4 +132,4 @@ for (var i = 0; i < e; i++) {

for (var o = 0; o < _this.wheel.length; o++) {
o == _this.wheel.length - 1 ? e += _this.getInnerText(o) : e += _this.getInnerText(o) + _this.config.connector;
for (var o = 0; o < _this.wheelList.length; o++) {
o == _this.wheelList.length - 1 ? e += _this.getInnerText(o) : e += _this.getInnerText(o) + _this.config.connector;
}

@@ -241,3 +241,3 @@

var t, e, i;
this.mobileSelect.classList.add("ms-show"), (t = document.querySelector("body")) == null || t.classList.add("ms-show"), typeof this.config.onShow == "function" && ((i = (e = this.config).onShow) == null || i.call(e));
this.mobileSelect.classList.add("ms-show"), (t = document.querySelector("body")) == null || t.classList.add("ms-show"), typeof this.config.onShow == "function" && ((i = (e = this.config).onShow) == null || i.call(e, this.curValue, this.curIndexArr, this));
}

@@ -248,3 +248,3 @@ }, {

var t, e, i;
this.mobileSelect.classList.remove("ms-show"), (t = document.querySelector("body")) == null || t.classList.remove("ms-show"), typeof this.config.onHide == "function" && ((i = (e = this.config).onHide) == null || i.call(e));
this.mobileSelect.classList.remove("ms-show"), (t = document.querySelector("body")) == null || t.classList.remove("ms-show"), typeof this.config.onHide == "function" && ((i = (e = this.config).onHide) == null || i.call(e, this.curValue, this.curIndexArr, this));
}

@@ -309,11 +309,11 @@ }, {

value: function reRenderWheels() {
var t = this.wheel.length - this.displayJson.length;
var t = this.wheelList.length - this.displayJson.length;
if (t > 0) for (var e = 0; e < t; e++) {
this.wheels.removeChild(this.wheel[this.wheel.length - 1]);
this.wheelsContain.removeChild(this.wheelList[this.wheelList.length - 1]);
}
for (var _e4 = 0; _e4 < this.displayJson.length; _e4++) {
if (this.wheel[_e4]) this.slider[_e4].innerHTML = this.getOptionsHtmlStr(this.displayJson[_e4]);else {
if (this.wheelList[_e4]) this.sliderList[_e4].innerHTML = this.getOptionsHtmlStr(this.displayJson[_e4]);else {
var i = document.createElement("div");
i.className = "ms-wheel", i.innerHTML = "<ul class=\"ms-select-container\">".concat(this.getOptionsHtmlStr(this.displayJson[_e4]), "</ul>"), i.setAttribute("data-index", _e4.toString()), this.wheels.appendChild(i);
i.className = "ms-wheel", i.innerHTML = "<ul class=\"ms-select-container\">".concat(this.getOptionsHtmlStr(this.displayJson[_e4]), "</ul>"), i.setAttribute("data-index", _e4.toString()), this.wheelsContain.appendChild(i);
}

@@ -389,4 +389,4 @@ }

if (this.slider.length > e.length) {
s = this.slider.length - e.length;
if (this.sliderList.length > e.length) {
s = this.sliderList.length - e.length;

@@ -396,4 +396,4 @@ for (var n = 0; n < s; n++) {

}
} else if (this.slider.length < e.length) {
s = e.length - this.slider.length;
} else if (this.sliderList.length < e.length) {
s = e.length - this.sliderList.length;

@@ -415,4 +415,4 @@ for (var _n2 = 0; _n2 < s; _n2++) {

if (this.isCascade) {
if (this.cascadeJsonData = t, this.displayJson = [], this.initCascade(), this.initPosition.length < this.slider.length) {
var e = this.slider.length - this.initPosition.length;
if (this.cascadeJsonData = t, this.displayJson = [], this.initCascade(), this.initPosition.length < this.sliderList.length) {
var e = this.sliderList.length - this.initPosition.length;

@@ -438,3 +438,3 @@ for (var i = 0; i < e; i++) {

data: e
} : e, this.slider[t].innerHTML = i;
} : e, this.sliderList[t].innerHTML = i;
}

@@ -446,3 +446,3 @@ }, {

if (this.initColWidth.length && this.initColWidth.length === this.wheel.length) {
if (this.initColWidth.length && this.initColWidth.length === this.wheelList.length) {
var e = this.initColWidth.reduce(function (i, s) {

@@ -452,3 +452,3 @@ return i + s;

this.initColWidth.forEach(function (i, s) {
_this4.wheel[s].style.width = (i / e * 100).toFixed(2) + "%";
_this4.wheelList[s].style.width = (i / e * 100).toFixed(2) + "%";
});

@@ -458,6 +458,6 @@ return;

var t = (100 / this.wheel.length).toFixed(2);
var t = (100 / this.wheelList.length).toFixed(2);
for (var _e5 = 0; _e5 < this.wheel.length; _e5++) {
this.wheel[_e5].style.width = t + "%";
for (var _e5 = 0; _e5 < this.wheelList.length; _e5++) {
this.wheelList[_e5].style.width = t + "%";
}

@@ -487,3 +487,3 @@ }

i = this.config.keyMap;
if (this.isCascade) for (var s = 0; s < this.wheel.length; s++) {
if (this.isCascade) for (var s = 0; s < this.wheelList.length; s++) {
var _t$push;

@@ -515,4 +515,4 @@

for (var i = 0; i < this.slider.length; i++) {
e.push(this.calcDistance(t[i])), this.movePosition(this.slider[i], e[i]);
for (var i = 0; i < this.sliderList.length; i++) {
e.push(this.calcDistance(t[i])), this.movePosition(this.sliderList[i], e[i]);
}

@@ -535,3 +535,3 @@

value: function locatePosition(t, e) {
this.curDistance[t] = this.calcDistance(e), this.movePosition(this.slider[t], this.curDistance[t]), this.isCascade && this.checkRange(t, this.getIndexArr());
this.curDistance[t] = this.calcDistance(e), this.movePosition(this.sliderList[t], this.curDistance[t]), this.isCascade && this.checkRange(t, this.getIndexArr());
}

@@ -547,5 +547,5 @@ }, {

var s;
var e = this.slider[t].getElementsByTagName("li").length;
var e = this.sliderList[t].getElementsByTagName("li").length;
var i = this.getIndex(this.curDistance[t]);
return i >= e ? i = e - 1 : i < 0 && (i = 0), ((s = this.slider[t].getElementsByTagName("li")[i]) == null ? void 0 : s.innerText) || "";
return i >= e ? i = e - 1 : i < 0 && (i = 0), ((s = this.sliderList[t].getElementsByTagName("li")[i]) == null ? void 0 : s.innerText) || "";
}

@@ -555,3 +555,3 @@ }, {

value: function touch(t) {
var r, o, g, a, u, d, m, C;
var r, o, g, a, u, d, m, v;
var i = (t.composedPath && t.composedPath()).find(function (p) {

@@ -584,6 +584,6 @@ var y;

var y = p - 2,
v = this.curDistance[n] + y * this.optionHeight;
v <= 2 * this.optionHeight && v >= this.oversizeBorder && (this.curDistance[n] = v, this.movePosition(s, this.curDistance[n]), (o = (r = this.config).transitionEnd) == null || o.call(r, this.getIndexArr(), this.getCurValue(), this), (a = (g = this.config).onTransitionEnd) == null || a.call(g, this.getCurValue(), this.getIndexArr(), this));
C = this.curDistance[n] + y * this.optionHeight;
C <= 2 * this.optionHeight && C >= this.oversizeBorder && (this.curDistance[n] = C, this.movePosition(s, this.curDistance[n]), (o = (r = this.config).transitionEnd) == null || o.call(r, this.getIndexArr(), this.getCurValue(), this), (a = (g = this.config).onTransitionEnd) == null || a.call(g, this.getCurValue(), this.getIndexArr(), this));
}
} else this.updateCurDistance(s, n), this.curDistance[n] = this.fixPosition(this.curDistance[n]), this.curDistance[n] > 2 * this.optionHeight ? this.curDistance[n] = 2 * this.optionHeight : this.curDistance[n] < this.oversizeBorder && (this.curDistance[n] = this.oversizeBorder), this.movePosition(s, this.curDistance[n]), (d = (u = this.config).transitionEnd) == null || d.call(u, this.getIndexArr(), this.getCurValue(), this), (C = (m = this.config).onTransitionEnd) == null || C.call(m, this.getCurValue(), this.getIndexArr(), this);
} else this.updateCurDistance(s, n), this.curDistance[n] = this.fixPosition(this.curDistance[n]), this.curDistance[n] > 2 * this.optionHeight ? this.curDistance[n] = 2 * this.optionHeight : this.curDistance[n] < this.oversizeBorder && (this.curDistance[n] = this.oversizeBorder), this.movePosition(s, this.curDistance[n]), (d = (u = this.config).transitionEnd) == null || d.call(u, this.getIndexArr(), this.getCurValue(), this), (v = (m = this.config).onTransitionEnd) == null || v.call(m, this.getCurValue(), this.getIndexArr(), this);

@@ -590,0 +590,0 @@ t.type === "mouseup" && (this.enableClickStatus = !1), this.isCascade && this.checkRange(n, this.getIndexArr());

/*
* mobile-select v1.3.0
* mobile-select v1.3.1
* Homepage: https://github.com/onlyhom/mobile-select

@@ -7,2 +7,2 @@ * Released under the MIT License.

*/
"use strict";function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}function _toConsumableArray(arr){return _arrayWithoutHoles(arr)||_iterableToArray(arr)||_unsupportedIterableToArray(arr)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(iter){if("undefined"!=typeof Symbol&&null!=iter[Symbol.iterator]||null!=iter["@@iterator"])return Array.from(iter)}function _arrayWithoutHoles(arr){if(Array.isArray(arr))return _arrayLikeToArray(arr)}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(o,minLen){if(o){if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);return"Map"===(n="Object"===n&&o.constructor?o.constructor.name:n)||"Set"===n?Array.from(o):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(o,minLen):void 0}}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _iterableToArrayLimit(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null!=_i){var _s,_e,_arr=[],_n=!0,_d=!1;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{_n||null==_i.return||_i.return()}finally{if(_d)throw _e}}return _arr}}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}function _createClass(Constructor,protoProps,staticProps){return protoProps&&_defineProperties(Constructor.prototype,protoProps),staticProps&&_defineProperties(Constructor,staticProps),Object.defineProperty(Constructor,"prototype",{writable:!1}),Constructor}function _typeof(obj){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj})(obj)}var MobileSelect=function(){function h(c,l,f){S(c,"symbol"!=_typeof(l)?l+"":l,f)}var D=Object.defineProperty,S=function(c,l,f){return l in c?D(c,l,{enumerable:!0,configurable:!0,writable:!0,value:f}):c[l]=f},c=function(){function l(t){_classCallCheck(this,l),h(this,"mobileSelect"),h(this,"trigger"),h(this,"wheel"),h(this,"slider"),h(this,"wheels"),h(this,"panel"),h(this,"ensureBtn"),h(this,"cancelBtn"),h(this,"grayLayer"),h(this,"popUp"),h(this,"initPosition"),h(this,"initColWidth"),h(this,"wheelsData"),h(this,"displayJson"),h(this,"curValue"),h(this,"curIndexArr"),h(this,"isCascade"),h(this,"isJsonType"),h(this,"startY"),h(this,"moveEndY"),h(this,"moveY"),h(this,"preMoveY"),h(this,"offsetY"),h(this,"offsetSum"),h(this,"oversizeBorder"),h(this,"enableClickStatus"),h(this,"isPC"),h(this,"optionHeight"),h(this,"curDistance"),h(this,"cascadeJsonData"),h(this,"eventHandleMap"),h(this,"initDeepCount"),h(this,"config"),l.checkRequiredConfig(t)&&(this.config=Object.assign({},l.defaultConfig,t),this.wheelsData=t.wheels,this.isJsonType=!1,this.cascadeJsonData=[],this.displayJson=[],this.curValue=[],this.curIndexArr=[],this.isCascade=!1,this.startY,this.moveEndY,this.moveY,this.preMoveY,this.offsetY=0,this.offsetSum=0,this.oversizeBorder,this.curDistance=[],this.enableClickStatus=!1,this.isPC=!0,this.optionHeight=0,this.initPosition=t.position||[],this.initColWidth=t.colWidth||[],this.init())}return _createClass(l,[{key:"init",value:function(){var _this=this,t=this.config;if(this.isJsonType=l.checkDataType(this.wheelsData),this.renderComponent(this.wheelsData),this.checkTriggerAvailable()){if(this.wheel=this.mobileSelect.getElementsByClassName("ms-wheel"),this.slider=this.mobileSelect.getElementsByClassName("ms-select-container"),this.panel=this.mobileSelect.querySelector(".ms-panel"),this.wheels=this.mobileSelect.querySelector(".ms-wheels"),this.ensureBtn=this.mobileSelect.querySelector(".ms-ensure"),this.cancelBtn=this.mobileSelect.querySelector(".ms-cancel"),this.grayLayer=this.mobileSelect.querySelector(".ms-gray-layer"),this.popUp=this.mobileSelect.querySelector(".ms-content"),this.optionHeight=this.mobileSelect.querySelector("li").offsetHeight,t.initValue&&t.triggerDisplayValue&&(this.trigger.innerText=t.initValue),this.setStyle(t),this.isPC=l.checkIsPC(),this.isCascade=this.checkCascade(),this.isCascade&&this.initCascade(),t.initValue&&(this.initPosition=this.getPositionByValue()),this.initPosition.length<this.slider.length)for(var e=this.slider.length-this.initPosition.length,i=0;i<e;i++)this.initPosition.push(0);this.isCascade?this.initPosition.forEach(function(e,i){_this.checkRange(i,_this.initPosition)}):this.setCurDistance(this.initPosition),this.eventHandleMap={cancelBtn:{event:"click",fn:function(){var i,e;_this.hide(),null!=(i=(e=_this.config).cancel)&&i.call(e,_this.curIndexArr,_this.curValue,_this),null!=(e=(i=_this.config).onCancel)&&e.call(i,_this.curValue,_this.curIndexArr,_this)}},ensureBtn:{event:"click",fn:function(){_this.hide(),_this.optionHeight||(_this.optionHeight=_this.mobileSelect.querySelector("li").offsetHeight);for(var s,i,e="",o=0;o<_this.wheel.length;o++)o==_this.wheel.length-1?e+=_this.getInnerText(o):e+=_this.getInnerText(o)+_this.config.connector;t.triggerDisplayValue&&(_this.trigger.innerText=e),_this.curIndexArr=_this.getIndexArr(),_this.curValue=_this.getCurValue(),null!=(s=(i=_this.config).callback)&&s.call(i,_this.curIndexArr,_this.curValue,_this),null!=(i=(s=_this.config).onChange)&&i.call(s,_this.curValue,_this.curIndexArr,_this)}},trigger:{event:"click",fn:function(){_this.show()}},grayLayer:{event:"click",fn:function(){return _this.hide()}},popUp:{event:"click",fn:function(e){return e.stopPropagation()}},panel:{event:["touchstart","touchend","touchmove"],fn:function(e){return _this.touch(e)}}},this.isPC&&(this.eventHandleMap.panel.event=["mousedown","mousemove","mouseup"]),this.registerEvents("add"),this.fixRowStyle(),t.autoFocus&&this.show()}}},{key:"checkTriggerAvailable",value:function(){var t=this.config;return this.trigger=t.trigger instanceof HTMLElement?t.trigger:document.querySelector(t.trigger),!!this.trigger||(l.log("error","trigger HTMLElement does not found on your document."),!1)}},{key:"getPositionByValue",value:function(){var r,_this2=this,_this$config=this.config,t=_this$config.keyMap,e=_this$config.connector,_this$config=_this$config.initValue,_this$config=(null==_this$config?void 0:_this$config.split(e))||[];return this.isJsonType?(r=null==(e=this.wheelsData[0])?void 0:e.data,_this$config.reduce(function(o,g){var a=null==r?void 0:r.findIndex(function(d){return d[t.value]==g});return o.push(a<0?0:a),r=null==(a=r[a])?void 0:a[t.childs],o},[])):_this$config.reduce(function(r,o,g){g=null==(g=null==(g=_this2.wheelsData[g])?void 0:g.data)?void 0:g.findIndex(function(m){return m==o});return r.push(g<0?0:g),r},[])}},{key:"setTitle",value:function(t){this.mobileSelect.querySelector(".ms-title").innerHTML=t}},{key:"setStyle",value:function(t){var _e2;t.ensureBtnColor&&(this.ensureBtn.style.color=t.ensureBtnColor),t.cancelBtnColor&&(this.cancelBtn.style.color=t.cancelBtnColor),t.titleColor&&(this.mobileSelect.querySelector(".ms-title").style.color=t.titleColor),t.textColor&&(this.panel=this.mobileSelect.querySelector(".ms-panel"),this.panel.style.color=t.textColor),t.titleBgColor&&(this.mobileSelect.querySelector(".ms-btn-bar").style.backgroundColor=t.titleBgColor),t.bgColor&&(this.panel=this.mobileSelect.querySelector(".ms-panel"),_e2=this.mobileSelect.querySelector(".ms-shadow-mask"),this.panel.style.backgroundColor=t.bgColor,_e2.style.background="linear-gradient(to bottom, "+t.bgColor+", rgba(255, 255, 255, 0), "+t.bgColor+")"),"number"==typeof t.maskOpacity&&(this.mobileSelect.querySelector(".ms-gray-layer").style.background="rgba(0, 0, 0, "+t.maskOpacity+")")}},{key:"show",value:function(){var t,i;this.mobileSelect.classList.add("ms-show"),null!=(t=document.querySelector("body"))&&t.classList.add("ms-show"),"function"==typeof this.config.onShow&&null!=(i=(t=this.config).onShow)&&i.call(t)}},{key:"hide",value:function(){var t,i;this.mobileSelect.classList.remove("ms-show"),null!=(t=document.querySelector("body"))&&t.classList.remove("ms-show"),"function"==typeof this.config.onHide&&null!=(i=(t=this.config).onHide)&&i.call(t)}},{key:"registerEvents",value:function(t){for(var _this3=this,_i=0,_Object$entries=Object.entries(this.eventHandleMap);_i<_Object$entries.length;_i++)!function(){var _Object$entries$_i=_slicedToArray(_Object$entries[_i],2),e=_Object$entries$_i[0],i=_Object$entries$_i[1];"string"==typeof i.event?_this3[e]["".concat(t,"EventListener")](i.event,i.fn,{passive:!1}):i.event.forEach(function(s){_this3[e]["".concat(t,"EventListener")](s,i.fn,{passive:!1})})}()}},{key:"destroy",value:function(){var t;this.registerEvents("remove"),null!=(t=null==(t=this.mobileSelect)?void 0:t.parentNode)&&t.removeChild(this.mobileSelect)}},{key:"getOptionsHtmlStr",value:function(t){var e=this.config.keyMap,i="";if(this.isJsonType)for(var s=0;s<t.length;s++){var n=t[s][e.id],r=t[s][e.value];i+='<li data-id="'.concat(n,'">').concat(r,"</li>")}else for(var _s2=0;_s2<t.length;_s2++)i+="<li>"+t[_s2]+"</li>";return i}},{key:"renderComponent",value:function(t){this.mobileSelect=document.createElement("div"),this.mobileSelect.className="ms-mobile-select",this.mobileSelect.innerHTML='<div class="ms-gray-layer"></div>\n <div class="ms-content">\n <div class="ms-btn-bar">\n <div class="ms-fix-width">\n <div class="ms-cancel">'.concat(this.config.cancelBtnText,'</div> \n <div class="ms-title">').concat(this.config.title||"",'</div>\n <div class="ms-ensure">').concat(this.config.ensureBtnText,'</div>\n </div>\n </div>\n <div class="ms-panel">\n <div class="ms-fix-width">\n <div class="ms-wheels"></div>\n <div class="ms-select-line"></div>\n <div class="ms-shadow-mask"></div>\n </div>\n </div>'),document.body.appendChild(this.mobileSelect);for(var e="",i=0;i<t.length;i++)e=(e+='<div class="ms-wheel" data-index="'.concat(i,'"><ul class="ms-select-container">'))+this.getOptionsHtmlStr(t[i].data)+"</ul></div>";this.mobileSelect.querySelector(".ms-wheels").innerHTML=e}},{key:"reRenderWheels",value:function(){var t=this.wheel.length-this.displayJson.length;if(0<t)for(var e=0;e<t;e++)this.wheels.removeChild(this.wheel[this.wheel.length-1]);for(var i,_e4=0;_e4<this.displayJson.length;_e4++)this.wheel[_e4]?this.slider[_e4].innerHTML=this.getOptionsHtmlStr(this.displayJson[_e4]):((i=document.createElement("div")).className="ms-wheel",i.innerHTML='<ul class="ms-select-container">'.concat(this.getOptionsHtmlStr(this.displayJson[_e4]),"</ul>"),i.setAttribute("data-index",_e4.toString()),this.wheels.appendChild(i))}},{key:"checkCascade",value:function(){var e,t=this.config.keyMap;if(this.isJsonType)for(var i=this.wheelsData[0].data,s=0;s<i.length;s++)if(t.childs in i[s]&&0<(null==(e=i[s][t.childs])?void 0:e.length))return this.cascadeJsonData=this.wheelsData[0].data,!0;return!1}},{key:"initCascade",value:function(){this.displayJson.push(this.cascadeJsonData),0<this.initPosition.length?(this.initDeepCount=0,this.initCheckArrDeep(this.cascadeJsonData[this.initPosition[0]])):this.checkArrDeep(this.cascadeJsonData[0]),this.reRenderWheels()}},{key:"initCheckArrDeep",value:function(t){var e,i;t&&(e=this.config.keyMap).childs in t&&0<t[e.childs].length&&(this.displayJson.push(t[e.childs]),this.initDeepCount++,(i=t[e.childs][this.initPosition[this.initDeepCount]])?this.initCheckArrDeep(i):this.checkArrDeep(t[e.childs][0]))}},{key:"checkArrDeep",value:function(t){var e;!t||(e=this.config.keyMap).childs in t&&0<t[e.childs].length&&(this.displayJson.push(t[e.childs]),this.checkArrDeep(t[e.childs][0]))}},{key:"checkRange",value:function(t,e){for(var r,n,i=this.displayJson.length-1-t,s=this.config.keyMap,o=0;o<i;o++)this.displayJson.pop();for(var _o=0;_o<=t;_o++)n=0==_o?this.cascadeJsonData[e[0]]:null==(r=null==n?void 0:n[s.childs])?void 0:r[e[_o]];this.checkArrDeep(n),this.reRenderWheels(),this.fixRowStyle(),this.setCurDistance(this.resetPosition(t,e))}},{key:"resetPosition",value:function(t,e){var i=_toConsumableArray(e);if(this.slider.length>e.length)for(var s=this.slider.length-e.length,n=0;n<s;n++)i.push(0);else if(this.slider.length<e.length){s=e.length-this.slider.length;for(var _n2=0;_n2<s;_n2++)i.pop()}for(var _n3=t+1;_n3<i.length;_n3++)i[_n3]=0;return i}},{key:"updateWheels",value:function(t){if(this.isCascade){if(this.cascadeJsonData=t,this.displayJson=[],this.initCascade(),this.initPosition.length<this.slider.length)for(var e=this.slider.length-this.initPosition.length,i=0;i<e;i++)this.initPosition.push(0);this.setCurDistance(this.initPosition),this.fixRowStyle()}}},{key:"updateWheel",value:function(t,e){var i;this.isCascade?l.log("error","'updateWheel()' not support cascade json data, please use 'updateWheels()' instead to update the whole data source"):(i="",i+=this.getOptionsHtmlStr(e),this.wheelsData[t]=this.isJsonType?{data:e}:e,this.slider[t].innerHTML=i)}},{key:"fixRowStyle",value:function(){var e,_this4=this;if(this.initColWidth.length&&this.initColWidth.length===this.wheel.length)e=this.initColWidth.reduce(function(i,s){return i+s},0),this.initColWidth.forEach(function(i,s){_this4.wheel[s].style.width=(i/e*100).toFixed(2)+"%"});else for(var t=(100/this.wheel.length).toFixed(2),_e5=0;_e5<this.wheel.length;_e5++)this.wheel[_e5].style.width=t+"%"}},{key:"getIndex",value:function(t){return Math.round((2*this.optionHeight-t)/this.optionHeight)}},{key:"getIndexArr",value:function(){for(var t=[],e=0;e<this.curDistance.length;e++)t.push(this.getIndex(this.curDistance[e]));return t}},{key:"getCurValue",value:function(){var t=[],e=this.getIndexArr(),i=this.config.keyMap;if(this.isCascade)for(var s=0;s<this.wheel.length;s++){var _t$push,n=this.displayJson[s][e[s]];n&&t.push((_defineProperty(_t$push={},i.id,n[i.id]),_defineProperty(_t$push,i.value,n[i.value]),_t$push))}else if(this.isJsonType)for(var _s3=0;_s3<this.curDistance.length;_s3++)t.push(this.wheelsData[_s3].data[this.getIndex(this.curDistance[_s3])]);else for(var _s4=0;_s4<this.curDistance.length;_s4++)t.push(this.getInnerText(_s4));return t}},{key:"getValue",value:function(){return this.curValue}},{key:"calcDistance",value:function(t){return 2*this.optionHeight-t*this.optionHeight}},{key:"setCurDistance",value:function(t){for(var e=[],i=0;i<this.slider.length;i++)e.push(this.calcDistance(t[i])),this.movePosition(this.slider[i],e[i]);this.curDistance=e}},{key:"fixPosition",value:function(t){return-(this.getIndex(t)-2)*this.optionHeight}},{key:"movePosition",value:function(t,e){t.style.transform="translate3d(0,"+e+"px, 0)"}},{key:"locatePosition",value:function(t,e){this.curDistance[t]=this.calcDistance(e),this.movePosition(this.slider[t],this.curDistance[t]),this.isCascade&&this.checkRange(t,this.getIndexArr())}},{key:"updateCurDistance",value:function(t,e){this.curDistance[e]=parseInt(t.style.transform.split(",")[1])}},{key:"getInnerText",value:function(t){var e=this.slider[t].getElementsByTagName("li").length,i=this.getIndex(this.curDistance[t]);return e<=i?i=e-1:i<0&&(i=0),(null==(e=this.slider[t].getElementsByTagName("li")[i])?void 0:e.innerText)||""}},{key:"touch",value:function(t){var o,i=(t.composedPath&&t.composedPath()).find(function(p){return null==(p=p.classList)?void 0:p.contains("ms-wheel")});if(i){var p,s=i.firstChild,n=parseInt(i.getAttribute("data-index")||"0");switch(t.type){case"touchstart":case"mousedown":s.style.transition="none 0s ease-out",this.startY=Math.floor((t instanceof TouchEvent?t.touches[0]:t).clientY),this.preMoveY=this.startY,"mousedown"===t.type&&(this.enableClickStatus=!0);break;case"touchmove":case"mousemove":if(t.preventDefault(),"mousemove"===t.type&&!this.enableClickStatus)break;this.moveY=Math.floor((t instanceof TouchEvent?t.touches[0]:t).clientY),this.offsetY=(this.moveY-this.preMoveY)*this.config.scrollSpeed,this.updateCurDistance(s,n),this.curDistance[n]=this.curDistance[n]+this.offsetY,this.movePosition(s,this.curDistance[n]),this.preMoveY=this.moveY;break;case"touchend":case"mouseup":s.style.transition="transform 0.18s ease-out",this.moveEndY=Math.floor((t instanceof TouchEvent?t.changedTouches[0]:t).clientY),this.offsetSum=this.moveEndY-this.startY,this.oversizeBorder=-(s.getElementsByTagName("li").length-3)*this.optionHeight,0==this.offsetSum?2!=(p=Math.floor((window.innerHeight-this.moveEndY)/40))&&(p=this.curDistance[n]+(p-2)*this.optionHeight)<=2*this.optionHeight&&p>=this.oversizeBorder&&(this.curDistance[n]=p,this.movePosition(s,this.curDistance[n]),null!=(o=(p=this.config).transitionEnd)&&o.call(p,this.getIndexArr(),this.getCurValue(),this),null!=(p=(o=this.config).onTransitionEnd)&&p.call(o,this.getCurValue(),this.getIndexArr(),this)):(this.updateCurDistance(s,n),this.curDistance[n]=this.fixPosition(this.curDistance[n]),this.curDistance[n]>2*this.optionHeight?this.curDistance[n]=2*this.optionHeight:this.curDistance[n]<this.oversizeBorder&&(this.curDistance[n]=this.oversizeBorder),this.movePosition(s,this.curDistance[n]),null!=(o=(p=this.config).transitionEnd)&&o.call(p,this.getIndexArr(),this.getCurValue(),this),null!=(p=(o=this.config).onTransitionEnd)&&p.call(o,this.getCurValue(),this.getIndexArr(),this)),"mouseup"===t.type&&(this.enableClickStatus=!1),this.isCascade&&this.checkRange(n,this.getIndexArr())}}}}],[{key:"checkIsPC",value:function(){return!navigator.userAgent.toLowerCase().match(/ipad|iphone os|midp|rv:1.2.3.4|ucweb|android|windows ce|windows mobile/)}},{key:"checkDataType",value:function(t){return"object"==_typeof(null==(t=null==(t=t[0])?void 0:t.data)?void 0:t[0])}},{key:"checkRequiredConfig",value:function(t){var i,e=l.REQUIRED_PARAMS;if(!t)return i=e.map(function(s){return"'".concat(s,"'")}),l.log("error","missing required param ".concat(i.join(" and "),".")),!1;for(var _i2=0;_i2<e.length;_i2++){var s=e[_i2];if(!t[s])return l.log("error","missing required param '".concat(s,"'.")),!1}return!0}},{key:"log",value:function(t,e){null!=(t=console[t])&&t.call(console,"[mobile-select]: ".concat(e))}}]),l}();return h(c,"defaultConfig",{keyMap:{id:"id",value:"value",childs:"childs"},position:[],colWidth:[],title:"",connector:" ",ensureBtnText:"确认",cancelBtnText:"取消",triggerDisplayValue:!0,scrollSpeed:1}),h(c,"REQUIRED_PARAMS",["trigger","wheels"]),c}();
"use strict";function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}function _toConsumableArray(arr){return _arrayWithoutHoles(arr)||_iterableToArray(arr)||_unsupportedIterableToArray(arr)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(iter){if("undefined"!=typeof Symbol&&null!=iter[Symbol.iterator]||null!=iter["@@iterator"])return Array.from(iter)}function _arrayWithoutHoles(arr){if(Array.isArray(arr))return _arrayLikeToArray(arr)}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(o,minLen){if(o){if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);return"Map"===(n="Object"===n&&o.constructor?o.constructor.name:n)||"Set"===n?Array.from(o):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(o,minLen):void 0}}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _iterableToArrayLimit(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null!=_i){var _s,_e,_arr=[],_n=!0,_d=!1;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{_n||null==_i.return||_i.return()}finally{if(_d)throw _e}}return _arr}}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}function _createClass(Constructor,protoProps,staticProps){return protoProps&&_defineProperties(Constructor.prototype,protoProps),staticProps&&_defineProperties(Constructor,staticProps),Object.defineProperty(Constructor,"prototype",{writable:!1}),Constructor}function _typeof(obj){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj})(obj)}var MobileSelect=function(){function h(c,l,f){S(c,"symbol"!=_typeof(l)?l+"":l,f)}var D=Object.defineProperty,S=function(c,l,f){return l in c?D(c,l,{enumerable:!0,configurable:!0,writable:!0,value:f}):c[l]=f},c=function(){function l(t){_classCallCheck(this,l),h(this,"mobileSelect"),h(this,"trigger"),h(this,"wheelList"),h(this,"sliderList"),h(this,"wheelsContain"),h(this,"panel"),h(this,"ensureBtn"),h(this,"cancelBtn"),h(this,"grayLayer"),h(this,"popUp"),h(this,"initPosition"),h(this,"initColWidth"),h(this,"wheelsData"),h(this,"displayJson"),h(this,"curValue"),h(this,"curIndexArr"),h(this,"isCascade"),h(this,"isJsonType"),h(this,"startY"),h(this,"moveEndY"),h(this,"moveY"),h(this,"preMoveY"),h(this,"offsetY"),h(this,"offsetSum"),h(this,"oversizeBorder"),h(this,"enableClickStatus"),h(this,"isPC"),h(this,"optionHeight"),h(this,"curDistance"),h(this,"cascadeJsonData"),h(this,"eventHandleMap"),h(this,"initDeepCount"),h(this,"config"),l.checkRequiredConfig(t)&&(this.config=Object.assign({},l.defaultConfig,t),this.wheelsData=t.wheels,this.isJsonType=!1,this.cascadeJsonData=[],this.displayJson=[],this.curValue=[],this.curIndexArr=[],this.isCascade=!1,this.startY,this.moveEndY,this.moveY,this.preMoveY,this.offsetY=0,this.offsetSum=0,this.oversizeBorder,this.curDistance=[],this.enableClickStatus=!1,this.isPC=!0,this.optionHeight=0,this.initPosition=t.position||[],this.initColWidth=t.colWidth||[],this.init())}return _createClass(l,[{key:"init",value:function(){var _this=this,t=this.config;if(this.isJsonType=l.checkDataType(this.wheelsData),this.renderComponent(this.wheelsData),this.checkTriggerAvailable()){if(this.wheelList=this.mobileSelect.getElementsByClassName("ms-wheel"),this.sliderList=this.mobileSelect.getElementsByClassName("ms-select-container"),this.panel=this.mobileSelect.querySelector(".ms-panel"),this.wheelsContain=this.mobileSelect.querySelector(".ms-wheels"),this.ensureBtn=this.mobileSelect.querySelector(".ms-ensure"),this.cancelBtn=this.mobileSelect.querySelector(".ms-cancel"),this.grayLayer=this.mobileSelect.querySelector(".ms-gray-layer"),this.popUp=this.mobileSelect.querySelector(".ms-content"),this.optionHeight=this.mobileSelect.querySelector("li").offsetHeight,t.initValue&&t.triggerDisplayValue&&(this.trigger.innerText=t.initValue),this.setStyle(t),this.isPC=l.checkIsPC(),this.isCascade=this.checkCascade(),this.isCascade&&this.initCascade(),t.initValue&&(this.initPosition=this.getPositionByValue()),this.initPosition.length<this.sliderList.length)for(var e=this.sliderList.length-this.initPosition.length,i=0;i<e;i++)this.initPosition.push(0);this.isCascade?this.initPosition.forEach(function(e,i){_this.checkRange(i,_this.initPosition)}):this.setCurDistance(this.initPosition),this.eventHandleMap={cancelBtn:{event:"click",fn:function(){var i,e;_this.hide(),null!=(i=(e=_this.config).cancel)&&i.call(e,_this.curIndexArr,_this.curValue,_this),null!=(e=(i=_this.config).onCancel)&&e.call(i,_this.curValue,_this.curIndexArr,_this)}},ensureBtn:{event:"click",fn:function(){_this.hide(),_this.optionHeight||(_this.optionHeight=_this.mobileSelect.querySelector("li").offsetHeight);for(var s,i,e="",o=0;o<_this.wheelList.length;o++)o==_this.wheelList.length-1?e+=_this.getInnerText(o):e+=_this.getInnerText(o)+_this.config.connector;t.triggerDisplayValue&&(_this.trigger.innerText=e),_this.curIndexArr=_this.getIndexArr(),_this.curValue=_this.getCurValue(),null!=(s=(i=_this.config).callback)&&s.call(i,_this.curIndexArr,_this.curValue,_this),null!=(i=(s=_this.config).onChange)&&i.call(s,_this.curValue,_this.curIndexArr,_this)}},trigger:{event:"click",fn:function(){_this.show()}},grayLayer:{event:"click",fn:function(){return _this.hide()}},popUp:{event:"click",fn:function(e){return e.stopPropagation()}},panel:{event:["touchstart","touchend","touchmove"],fn:function(e){return _this.touch(e)}}},this.isPC&&(this.eventHandleMap.panel.event=["mousedown","mousemove","mouseup"]),this.registerEvents("add"),this.fixRowStyle(),t.autoFocus&&this.show()}}},{key:"checkTriggerAvailable",value:function(){var t=this.config;return this.trigger=t.trigger instanceof HTMLElement?t.trigger:document.querySelector(t.trigger),!!this.trigger||(l.log("error","trigger HTMLElement does not found on your document."),!1)}},{key:"getPositionByValue",value:function(){var r,_this2=this,_this$config=this.config,t=_this$config.keyMap,e=_this$config.connector,_this$config=_this$config.initValue,_this$config=(null==_this$config?void 0:_this$config.split(e))||[];return this.isJsonType?(r=null==(e=this.wheelsData[0])?void 0:e.data,_this$config.reduce(function(o,g){var a=null==r?void 0:r.findIndex(function(d){return d[t.value]==g});return o.push(a<0?0:a),r=null==(a=r[a])?void 0:a[t.childs],o},[])):_this$config.reduce(function(r,o,g){g=null==(g=null==(g=_this2.wheelsData[g])?void 0:g.data)?void 0:g.findIndex(function(m){return m==o});return r.push(g<0?0:g),r},[])}},{key:"setTitle",value:function(t){this.mobileSelect.querySelector(".ms-title").innerHTML=t}},{key:"setStyle",value:function(t){var _e2;t.ensureBtnColor&&(this.ensureBtn.style.color=t.ensureBtnColor),t.cancelBtnColor&&(this.cancelBtn.style.color=t.cancelBtnColor),t.titleColor&&(this.mobileSelect.querySelector(".ms-title").style.color=t.titleColor),t.textColor&&(this.panel=this.mobileSelect.querySelector(".ms-panel"),this.panel.style.color=t.textColor),t.titleBgColor&&(this.mobileSelect.querySelector(".ms-btn-bar").style.backgroundColor=t.titleBgColor),t.bgColor&&(this.panel=this.mobileSelect.querySelector(".ms-panel"),_e2=this.mobileSelect.querySelector(".ms-shadow-mask"),this.panel.style.backgroundColor=t.bgColor,_e2.style.background="linear-gradient(to bottom, "+t.bgColor+", rgba(255, 255, 255, 0), "+t.bgColor+")"),"number"==typeof t.maskOpacity&&(this.mobileSelect.querySelector(".ms-gray-layer").style.background="rgba(0, 0, 0, "+t.maskOpacity+")")}},{key:"show",value:function(){var t,i;this.mobileSelect.classList.add("ms-show"),null!=(t=document.querySelector("body"))&&t.classList.add("ms-show"),"function"==typeof this.config.onShow&&null!=(i=(t=this.config).onShow)&&i.call(t,this.curValue,this.curIndexArr,this)}},{key:"hide",value:function(){var t,i;this.mobileSelect.classList.remove("ms-show"),null!=(t=document.querySelector("body"))&&t.classList.remove("ms-show"),"function"==typeof this.config.onHide&&null!=(i=(t=this.config).onHide)&&i.call(t,this.curValue,this.curIndexArr,this)}},{key:"registerEvents",value:function(t){for(var _this3=this,_i=0,_Object$entries=Object.entries(this.eventHandleMap);_i<_Object$entries.length;_i++)!function(){var _Object$entries$_i=_slicedToArray(_Object$entries[_i],2),e=_Object$entries$_i[0],i=_Object$entries$_i[1];"string"==typeof i.event?_this3[e]["".concat(t,"EventListener")](i.event,i.fn,{passive:!1}):i.event.forEach(function(s){_this3[e]["".concat(t,"EventListener")](s,i.fn,{passive:!1})})}()}},{key:"destroy",value:function(){var t;this.registerEvents("remove"),null!=(t=null==(t=this.mobileSelect)?void 0:t.parentNode)&&t.removeChild(this.mobileSelect)}},{key:"getOptionsHtmlStr",value:function(t){var e=this.config.keyMap,i="";if(this.isJsonType)for(var s=0;s<t.length;s++){var n=t[s][e.id],r=t[s][e.value];i+='<li data-id="'.concat(n,'">').concat(r,"</li>")}else for(var _s2=0;_s2<t.length;_s2++)i+="<li>"+t[_s2]+"</li>";return i}},{key:"renderComponent",value:function(t){this.mobileSelect=document.createElement("div"),this.mobileSelect.className="ms-mobile-select",this.mobileSelect.innerHTML='<div class="ms-gray-layer"></div>\n <div class="ms-content">\n <div class="ms-btn-bar">\n <div class="ms-fix-width">\n <div class="ms-cancel">'.concat(this.config.cancelBtnText,'</div> \n <div class="ms-title">').concat(this.config.title||"",'</div>\n <div class="ms-ensure">').concat(this.config.ensureBtnText,'</div>\n </div>\n </div>\n <div class="ms-panel">\n <div class="ms-fix-width">\n <div class="ms-wheels"></div>\n <div class="ms-select-line"></div>\n <div class="ms-shadow-mask"></div>\n </div>\n </div>'),document.body.appendChild(this.mobileSelect);for(var e="",i=0;i<t.length;i++)e=(e+='<div class="ms-wheel" data-index="'.concat(i,'"><ul class="ms-select-container">'))+this.getOptionsHtmlStr(t[i].data)+"</ul></div>";this.mobileSelect.querySelector(".ms-wheels").innerHTML=e}},{key:"reRenderWheels",value:function(){var t=this.wheelList.length-this.displayJson.length;if(0<t)for(var e=0;e<t;e++)this.wheelsContain.removeChild(this.wheelList[this.wheelList.length-1]);for(var i,_e4=0;_e4<this.displayJson.length;_e4++)this.wheelList[_e4]?this.sliderList[_e4].innerHTML=this.getOptionsHtmlStr(this.displayJson[_e4]):((i=document.createElement("div")).className="ms-wheel",i.innerHTML='<ul class="ms-select-container">'.concat(this.getOptionsHtmlStr(this.displayJson[_e4]),"</ul>"),i.setAttribute("data-index",_e4.toString()),this.wheelsContain.appendChild(i))}},{key:"checkCascade",value:function(){var e,t=this.config.keyMap;if(this.isJsonType)for(var i=this.wheelsData[0].data,s=0;s<i.length;s++)if(t.childs in i[s]&&0<(null==(e=i[s][t.childs])?void 0:e.length))return this.cascadeJsonData=this.wheelsData[0].data,!0;return!1}},{key:"initCascade",value:function(){this.displayJson.push(this.cascadeJsonData),0<this.initPosition.length?(this.initDeepCount=0,this.initCheckArrDeep(this.cascadeJsonData[this.initPosition[0]])):this.checkArrDeep(this.cascadeJsonData[0]),this.reRenderWheels()}},{key:"initCheckArrDeep",value:function(t){var e,i;t&&(e=this.config.keyMap).childs in t&&0<t[e.childs].length&&(this.displayJson.push(t[e.childs]),this.initDeepCount++,(i=t[e.childs][this.initPosition[this.initDeepCount]])?this.initCheckArrDeep(i):this.checkArrDeep(t[e.childs][0]))}},{key:"checkArrDeep",value:function(t){var e;!t||(e=this.config.keyMap).childs in t&&0<t[e.childs].length&&(this.displayJson.push(t[e.childs]),this.checkArrDeep(t[e.childs][0]))}},{key:"checkRange",value:function(t,e){for(var r,n,i=this.displayJson.length-1-t,s=this.config.keyMap,o=0;o<i;o++)this.displayJson.pop();for(var _o=0;_o<=t;_o++)n=0==_o?this.cascadeJsonData[e[0]]:null==(r=null==n?void 0:n[s.childs])?void 0:r[e[_o]];this.checkArrDeep(n),this.reRenderWheels(),this.fixRowStyle(),this.setCurDistance(this.resetPosition(t,e))}},{key:"resetPosition",value:function(t,e){var i=_toConsumableArray(e);if(this.sliderList.length>e.length)for(var s=this.sliderList.length-e.length,n=0;n<s;n++)i.push(0);else if(this.sliderList.length<e.length){s=e.length-this.sliderList.length;for(var _n2=0;_n2<s;_n2++)i.pop()}for(var _n3=t+1;_n3<i.length;_n3++)i[_n3]=0;return i}},{key:"updateWheels",value:function(t){if(this.isCascade){if(this.cascadeJsonData=t,this.displayJson=[],this.initCascade(),this.initPosition.length<this.sliderList.length)for(var e=this.sliderList.length-this.initPosition.length,i=0;i<e;i++)this.initPosition.push(0);this.setCurDistance(this.initPosition),this.fixRowStyle()}}},{key:"updateWheel",value:function(t,e){var i;this.isCascade?l.log("error","'updateWheel()' not support cascade json data, please use 'updateWheels()' instead to update the whole data source"):(i="",i+=this.getOptionsHtmlStr(e),this.wheelsData[t]=this.isJsonType?{data:e}:e,this.sliderList[t].innerHTML=i)}},{key:"fixRowStyle",value:function(){var e,_this4=this;if(this.initColWidth.length&&this.initColWidth.length===this.wheelList.length)e=this.initColWidth.reduce(function(i,s){return i+s},0),this.initColWidth.forEach(function(i,s){_this4.wheelList[s].style.width=(i/e*100).toFixed(2)+"%"});else for(var t=(100/this.wheelList.length).toFixed(2),_e5=0;_e5<this.wheelList.length;_e5++)this.wheelList[_e5].style.width=t+"%"}},{key:"getIndex",value:function(t){return Math.round((2*this.optionHeight-t)/this.optionHeight)}},{key:"getIndexArr",value:function(){for(var t=[],e=0;e<this.curDistance.length;e++)t.push(this.getIndex(this.curDistance[e]));return t}},{key:"getCurValue",value:function(){var t=[],e=this.getIndexArr(),i=this.config.keyMap;if(this.isCascade)for(var s=0;s<this.wheelList.length;s++){var _t$push,n=this.displayJson[s][e[s]];n&&t.push((_defineProperty(_t$push={},i.id,n[i.id]),_defineProperty(_t$push,i.value,n[i.value]),_t$push))}else if(this.isJsonType)for(var _s3=0;_s3<this.curDistance.length;_s3++)t.push(this.wheelsData[_s3].data[this.getIndex(this.curDistance[_s3])]);else for(var _s4=0;_s4<this.curDistance.length;_s4++)t.push(this.getInnerText(_s4));return t}},{key:"getValue",value:function(){return this.curValue}},{key:"calcDistance",value:function(t){return 2*this.optionHeight-t*this.optionHeight}},{key:"setCurDistance",value:function(t){for(var e=[],i=0;i<this.sliderList.length;i++)e.push(this.calcDistance(t[i])),this.movePosition(this.sliderList[i],e[i]);this.curDistance=e}},{key:"fixPosition",value:function(t){return-(this.getIndex(t)-2)*this.optionHeight}},{key:"movePosition",value:function(t,e){t.style.transform="translate3d(0,"+e+"px, 0)"}},{key:"locatePosition",value:function(t,e){this.curDistance[t]=this.calcDistance(e),this.movePosition(this.sliderList[t],this.curDistance[t]),this.isCascade&&this.checkRange(t,this.getIndexArr())}},{key:"updateCurDistance",value:function(t,e){this.curDistance[e]=parseInt(t.style.transform.split(",")[1])}},{key:"getInnerText",value:function(t){var e=this.sliderList[t].getElementsByTagName("li").length,i=this.getIndex(this.curDistance[t]);return e<=i?i=e-1:i<0&&(i=0),(null==(e=this.sliderList[t].getElementsByTagName("li")[i])?void 0:e.innerText)||""}},{key:"touch",value:function(t){var o,i=(t.composedPath&&t.composedPath()).find(function(p){return null==(p=p.classList)?void 0:p.contains("ms-wheel")});if(i){var p,s=i.firstChild,n=parseInt(i.getAttribute("data-index")||"0");switch(t.type){case"touchstart":case"mousedown":s.style.transition="none 0s ease-out",this.startY=Math.floor((t instanceof TouchEvent?t.touches[0]:t).clientY),this.preMoveY=this.startY,"mousedown"===t.type&&(this.enableClickStatus=!0);break;case"touchmove":case"mousemove":if(t.preventDefault(),"mousemove"===t.type&&!this.enableClickStatus)break;this.moveY=Math.floor((t instanceof TouchEvent?t.touches[0]:t).clientY),this.offsetY=(this.moveY-this.preMoveY)*this.config.scrollSpeed,this.updateCurDistance(s,n),this.curDistance[n]=this.curDistance[n]+this.offsetY,this.movePosition(s,this.curDistance[n]),this.preMoveY=this.moveY;break;case"touchend":case"mouseup":s.style.transition="transform 0.18s ease-out",this.moveEndY=Math.floor((t instanceof TouchEvent?t.changedTouches[0]:t).clientY),this.offsetSum=this.moveEndY-this.startY,this.oversizeBorder=-(s.getElementsByTagName("li").length-3)*this.optionHeight,0==this.offsetSum?2!=(p=Math.floor((window.innerHeight-this.moveEndY)/40))&&(p=this.curDistance[n]+(p-2)*this.optionHeight)<=2*this.optionHeight&&p>=this.oversizeBorder&&(this.curDistance[n]=p,this.movePosition(s,this.curDistance[n]),null!=(o=(p=this.config).transitionEnd)&&o.call(p,this.getIndexArr(),this.getCurValue(),this),null!=(p=(o=this.config).onTransitionEnd)&&p.call(o,this.getCurValue(),this.getIndexArr(),this)):(this.updateCurDistance(s,n),this.curDistance[n]=this.fixPosition(this.curDistance[n]),this.curDistance[n]>2*this.optionHeight?this.curDistance[n]=2*this.optionHeight:this.curDistance[n]<this.oversizeBorder&&(this.curDistance[n]=this.oversizeBorder),this.movePosition(s,this.curDistance[n]),null!=(o=(p=this.config).transitionEnd)&&o.call(p,this.getIndexArr(),this.getCurValue(),this),null!=(p=(o=this.config).onTransitionEnd)&&p.call(o,this.getCurValue(),this.getIndexArr(),this)),"mouseup"===t.type&&(this.enableClickStatus=!1),this.isCascade&&this.checkRange(n,this.getIndexArr())}}}}],[{key:"checkIsPC",value:function(){return!navigator.userAgent.toLowerCase().match(/ipad|iphone os|midp|rv:1.2.3.4|ucweb|android|windows ce|windows mobile/)}},{key:"checkDataType",value:function(t){return"object"==_typeof(null==(t=null==(t=t[0])?void 0:t.data)?void 0:t[0])}},{key:"checkRequiredConfig",value:function(t){var i,e=l.REQUIRED_PARAMS;if(!t)return i=e.map(function(s){return"'".concat(s,"'")}),l.log("error","missing required param ".concat(i.join(" and "),".")),!1;for(var _i2=0;_i2<e.length;_i2++){var s=e[_i2];if(!t[s])return l.log("error","missing required param '".concat(s,"'.")),!1}return!0}},{key:"log",value:function(t,e){null!=(t=console[t])&&t.call(console,"[mobile-select]: ".concat(e))}}]),l}();return h(c,"defaultConfig",{keyMap:{id:"id",value:"value",childs:"childs"},position:[],colWidth:[],title:"",connector:" ",ensureBtnText:"确认",cancelBtnText:"取消",triggerDisplayValue:!0,scrollSpeed:1}),h(c,"REQUIRED_PARAMS",["trigger","wheels"]),c}();
/*
* mobile-select v1.3.0
* mobile-select v1.3.1
* Homepage: https://github.com/onlyhom/mobile-select

@@ -7,3 +7,3 @@ * Released under the MIT License.

*/
(function(c,o){typeof exports=="object"&&typeof module<"u"?module.exports=o(require("./style/mobile-select.css")):typeof define=="function"&&define.amd?define(["./style/mobile-select.css"],o):(c=typeof globalThis<"u"?globalThis:c||self,c.MobileSelect=o())})(this,function(){"use strict";var D=Object.defineProperty;var S=(c,o,f)=>o in c?D(c,o,{enumerable:!0,configurable:!0,writable:!0,value:f}):c[o]=f;var h=(c,o,f)=>(S(c,typeof o!="symbol"?o+"":o,f),f);const o=class{constructor(t){h(this,"mobileSelect");h(this,"trigger");h(this,"wheel");h(this,"slider");h(this,"wheels");h(this,"panel");h(this,"ensureBtn");h(this,"cancelBtn");h(this,"grayLayer");h(this,"popUp");h(this,"initPosition");h(this,"initColWidth");h(this,"wheelsData");h(this,"displayJson");h(this,"curValue");h(this,"curIndexArr");h(this,"isCascade");h(this,"isJsonType");h(this,"startY");h(this,"moveEndY");h(this,"moveY");h(this,"preMoveY");h(this,"offsetY");h(this,"offsetSum");h(this,"oversizeBorder");h(this,"enableClickStatus");h(this,"isPC");h(this,"optionHeight");h(this,"curDistance");h(this,"cascadeJsonData");h(this,"eventHandleMap");h(this,"initDeepCount");h(this,"config");!o.checkRequiredConfig(t)||(this.config=Object.assign({},o.defaultConfig,t),this.wheelsData=t.wheels,this.isJsonType=!1,this.cascadeJsonData=[],this.displayJson=[],this.curValue=[],this.curIndexArr=[],this.isCascade=!1,this.startY,this.moveEndY,this.moveY,this.preMoveY,this.offsetY=0,this.offsetSum=0,this.oversizeBorder,this.curDistance=[],this.enableClickStatus=!1,this.isPC=!0,this.optionHeight=0,this.initPosition=t.position||[],this.initColWidth=t.colWidth||[],this.init())}init(){const{config:t}=this;if(this.isJsonType=o.checkDataType(this.wheelsData),this.renderComponent(this.wheelsData),!!this.checkTriggerAvailable()){if(this.wheel=this.mobileSelect.getElementsByClassName("ms-wheel"),this.slider=this.mobileSelect.getElementsByClassName("ms-select-container"),this.panel=this.mobileSelect.querySelector(".ms-panel"),this.wheels=this.mobileSelect.querySelector(".ms-wheels"),this.ensureBtn=this.mobileSelect.querySelector(".ms-ensure"),this.cancelBtn=this.mobileSelect.querySelector(".ms-cancel"),this.grayLayer=this.mobileSelect.querySelector(".ms-gray-layer"),this.popUp=this.mobileSelect.querySelector(".ms-content"),this.optionHeight=this.mobileSelect.querySelector("li").offsetHeight,t.initValue&&t.triggerDisplayValue&&(this.trigger.innerText=t.initValue),this.setStyle(t),this.isPC=o.checkIsPC(),this.isCascade=this.checkCascade(),this.isCascade&&this.initCascade(),t.initValue&&(this.initPosition=this.getPositionByValue()),this.initPosition.length<this.slider.length){const e=this.slider.length-this.initPosition.length;for(let i=0;i<e;i++)this.initPosition.push(0)}this.isCascade?this.initPosition.forEach((e,i)=>{this.checkRange(i,this.initPosition)}):this.setCurDistance(this.initPosition),this.eventHandleMap={cancelBtn:{event:"click",fn:()=>{var e,i,s,n;this.hide(),(i=(e=this.config).cancel)==null||i.call(e,this.curIndexArr,this.curValue,this),(n=(s=this.config).onCancel)==null||n.call(s,this.curValue,this.curIndexArr,this)}},ensureBtn:{event:"click",fn:()=>{var i,s,n,r;this.hide(),this.optionHeight||(this.optionHeight=this.mobileSelect.querySelector("li").offsetHeight);let e="";for(let l=0;l<this.wheel.length;l++)l==this.wheel.length-1?e+=this.getInnerText(l):e+=this.getInnerText(l)+this.config.connector;t.triggerDisplayValue&&(this.trigger.innerText=e),this.curIndexArr=this.getIndexArr(),this.curValue=this.getCurValue(),(s=(i=this.config).callback)==null||s.call(i,this.curIndexArr,this.curValue,this),(r=(n=this.config).onChange)==null||r.call(n,this.curValue,this.curIndexArr,this)}},trigger:{event:"click",fn:()=>{this.show()}},grayLayer:{event:"click",fn:()=>this.hide()},popUp:{event:"click",fn:e=>e.stopPropagation()},panel:{event:["touchstart","touchend","touchmove"],fn:e=>this.touch(e)}},this.isPC&&(this.eventHandleMap.panel.event=["mousedown","mousemove","mouseup"]),this.registerEvents("add"),this.fixRowStyle(),t.autoFocus&&this.show()}}static checkIsPC(){return!navigator.userAgent.toLowerCase().match(/ipad|iphone os|midp|rv:1.2.3.4|ucweb|android|windows ce|windows mobile/)}static checkDataType(t){var e,i;return typeof((i=(e=t[0])==null?void 0:e.data)==null?void 0:i[0])=="object"}static checkRequiredConfig(t){const e=o.REQUIRED_PARAMS;if(!t){const i=e.map(s=>`'${s}'`);return o.log("error",`missing required param ${i.join(" and ")}.`),!1}for(let i=0;i<e.length;i++){const s=e[i];if(!t[s])return o.log("error",`missing required param '${s}'.`),!1}return!0}static log(t,e){var i;(i=console[t])==null||i.call(console,`[mobile-select]: ${e}`)}checkTriggerAvailable(){const{config:t}=this;return this.trigger=t.trigger instanceof HTMLElement?t.trigger:document.querySelector(t.trigger),this.trigger?!0:(o.log("error","trigger HTMLElement does not found on your document."),!1)}getPositionByValue(){var n;const{keyMap:t,connector:e,initValue:i}=this.config,s=(i==null?void 0:i.split(e))||[];if(this.isJsonType){let r=(n=this.wheelsData[0])==null?void 0:n.data;return s.reduce((l,g)=>{var u;const a=r==null?void 0:r.findIndex(d=>d[t.value]==g);return l.push(a<0?0:a),r=(u=r[a])==null?void 0:u[t.childs],l},[])}return s.reduce((r,l,g)=>{var u,d;const a=(d=(u=this.wheelsData[g])==null?void 0:u.data)==null?void 0:d.findIndex(m=>m==l);return r.push(a<0?0:a),r},[])}setTitle(t){this.mobileSelect.querySelector(".ms-title").innerHTML=t}setStyle(t){if(t.ensureBtnColor&&(this.ensureBtn.style.color=t.ensureBtnColor),t.cancelBtnColor&&(this.cancelBtn.style.color=t.cancelBtnColor),t.titleColor){const e=this.mobileSelect.querySelector(".ms-title");e.style.color=t.titleColor}if(t.textColor&&(this.panel=this.mobileSelect.querySelector(".ms-panel"),this.panel.style.color=t.textColor),t.titleBgColor){const e=this.mobileSelect.querySelector(".ms-btn-bar");e.style.backgroundColor=t.titleBgColor}if(t.bgColor){this.panel=this.mobileSelect.querySelector(".ms-panel");const e=this.mobileSelect.querySelector(".ms-shadow-mask");this.panel.style.backgroundColor=t.bgColor,e.style.background="linear-gradient(to bottom, "+t.bgColor+", rgba(255, 255, 255, 0), "+t.bgColor+")"}if(typeof t.maskOpacity=="number"){const e=this.mobileSelect.querySelector(".ms-gray-layer");e.style.background="rgba(0, 0, 0, "+t.maskOpacity+")"}}show(){var t,e,i;this.mobileSelect.classList.add("ms-show"),(t=document.querySelector("body"))==null||t.classList.add("ms-show"),typeof this.config.onShow=="function"&&((i=(e=this.config).onShow)==null||i.call(e))}hide(){var t,e,i;this.mobileSelect.classList.remove("ms-show"),(t=document.querySelector("body"))==null||t.classList.remove("ms-show"),typeof this.config.onHide=="function"&&((i=(e=this.config).onHide)==null||i.call(e))}registerEvents(t){for(const[e,i]of Object.entries(this.eventHandleMap))typeof i.event=="string"?this[e][`${t}EventListener`](i.event,i.fn,{passive:!1}):i.event.forEach(s=>{this[e][`${t}EventListener`](s,i.fn,{passive:!1})})}destroy(){var t,e;this.registerEvents("remove"),(e=(t=this.mobileSelect)==null?void 0:t.parentNode)==null||e.removeChild(this.mobileSelect)}getOptionsHtmlStr(t){const{keyMap:e}=this.config;let i="";if(this.isJsonType)for(let s=0;s<t.length;s++){const n=t[s][e.id],r=t[s][e.value];i+=`<li data-id="${n}">${r}</li>`}else for(let s=0;s<t.length;s++)i+="<li>"+t[s]+"</li>";return i}renderComponent(t){this.mobileSelect=document.createElement("div"),this.mobileSelect.className="ms-mobile-select",this.mobileSelect.innerHTML=`<div class="ms-gray-layer"></div>
(function(c,o){typeof exports=="object"&&typeof module<"u"?module.exports=o(require("./style/mobile-select.css")):typeof define=="function"&&define.amd?define(["./style/mobile-select.css"],o):(c=typeof globalThis<"u"?globalThis:c||self,c.MobileSelect=o())})(this,function(){"use strict";var D=Object.defineProperty;var S=(c,o,f)=>o in c?D(c,o,{enumerable:!0,configurable:!0,writable:!0,value:f}):c[o]=f;var h=(c,o,f)=>(S(c,typeof o!="symbol"?o+"":o,f),f);const o=class{constructor(t){h(this,"mobileSelect");h(this,"trigger");h(this,"wheelList");h(this,"sliderList");h(this,"wheelsContain");h(this,"panel");h(this,"ensureBtn");h(this,"cancelBtn");h(this,"grayLayer");h(this,"popUp");h(this,"initPosition");h(this,"initColWidth");h(this,"wheelsData");h(this,"displayJson");h(this,"curValue");h(this,"curIndexArr");h(this,"isCascade");h(this,"isJsonType");h(this,"startY");h(this,"moveEndY");h(this,"moveY");h(this,"preMoveY");h(this,"offsetY");h(this,"offsetSum");h(this,"oversizeBorder");h(this,"enableClickStatus");h(this,"isPC");h(this,"optionHeight");h(this,"curDistance");h(this,"cascadeJsonData");h(this,"eventHandleMap");h(this,"initDeepCount");h(this,"config");!o.checkRequiredConfig(t)||(this.config=Object.assign({},o.defaultConfig,t),this.wheelsData=t.wheels,this.isJsonType=!1,this.cascadeJsonData=[],this.displayJson=[],this.curValue=[],this.curIndexArr=[],this.isCascade=!1,this.startY,this.moveEndY,this.moveY,this.preMoveY,this.offsetY=0,this.offsetSum=0,this.oversizeBorder,this.curDistance=[],this.enableClickStatus=!1,this.isPC=!0,this.optionHeight=0,this.initPosition=t.position||[],this.initColWidth=t.colWidth||[],this.init())}init(){const{config:t}=this;if(this.isJsonType=o.checkDataType(this.wheelsData),this.renderComponent(this.wheelsData),!!this.checkTriggerAvailable()){if(this.wheelList=this.mobileSelect.getElementsByClassName("ms-wheel"),this.sliderList=this.mobileSelect.getElementsByClassName("ms-select-container"),this.panel=this.mobileSelect.querySelector(".ms-panel"),this.wheelsContain=this.mobileSelect.querySelector(".ms-wheels"),this.ensureBtn=this.mobileSelect.querySelector(".ms-ensure"),this.cancelBtn=this.mobileSelect.querySelector(".ms-cancel"),this.grayLayer=this.mobileSelect.querySelector(".ms-gray-layer"),this.popUp=this.mobileSelect.querySelector(".ms-content"),this.optionHeight=this.mobileSelect.querySelector("li").offsetHeight,t.initValue&&t.triggerDisplayValue&&(this.trigger.innerText=t.initValue),this.setStyle(t),this.isPC=o.checkIsPC(),this.isCascade=this.checkCascade(),this.isCascade&&this.initCascade(),t.initValue&&(this.initPosition=this.getPositionByValue()),this.initPosition.length<this.sliderList.length){const e=this.sliderList.length-this.initPosition.length;for(let i=0;i<e;i++)this.initPosition.push(0)}this.isCascade?this.initPosition.forEach((e,i)=>{this.checkRange(i,this.initPosition)}):this.setCurDistance(this.initPosition),this.eventHandleMap={cancelBtn:{event:"click",fn:()=>{var e,i,s,n;this.hide(),(i=(e=this.config).cancel)==null||i.call(e,this.curIndexArr,this.curValue,this),(n=(s=this.config).onCancel)==null||n.call(s,this.curValue,this.curIndexArr,this)}},ensureBtn:{event:"click",fn:()=>{var i,s,n,r;this.hide(),this.optionHeight||(this.optionHeight=this.mobileSelect.querySelector("li").offsetHeight);let e="";for(let l=0;l<this.wheelList.length;l++)l==this.wheelList.length-1?e+=this.getInnerText(l):e+=this.getInnerText(l)+this.config.connector;t.triggerDisplayValue&&(this.trigger.innerText=e),this.curIndexArr=this.getIndexArr(),this.curValue=this.getCurValue(),(s=(i=this.config).callback)==null||s.call(i,this.curIndexArr,this.curValue,this),(r=(n=this.config).onChange)==null||r.call(n,this.curValue,this.curIndexArr,this)}},trigger:{event:"click",fn:()=>{this.show()}},grayLayer:{event:"click",fn:()=>this.hide()},popUp:{event:"click",fn:e=>e.stopPropagation()},panel:{event:["touchstart","touchend","touchmove"],fn:e=>this.touch(e)}},this.isPC&&(this.eventHandleMap.panel.event=["mousedown","mousemove","mouseup"]),this.registerEvents("add"),this.fixRowStyle(),t.autoFocus&&this.show()}}static checkIsPC(){return!navigator.userAgent.toLowerCase().match(/ipad|iphone os|midp|rv:1.2.3.4|ucweb|android|windows ce|windows mobile/)}static checkDataType(t){var e,i;return typeof((i=(e=t[0])==null?void 0:e.data)==null?void 0:i[0])=="object"}static checkRequiredConfig(t){const e=o.REQUIRED_PARAMS;if(!t){const i=e.map(s=>`'${s}'`);return o.log("error",`missing required param ${i.join(" and ")}.`),!1}for(let i=0;i<e.length;i++){const s=e[i];if(!t[s])return o.log("error",`missing required param '${s}'.`),!1}return!0}static log(t,e){var i;(i=console[t])==null||i.call(console,`[mobile-select]: ${e}`)}checkTriggerAvailable(){const{config:t}=this;return this.trigger=t.trigger instanceof HTMLElement?t.trigger:document.querySelector(t.trigger),this.trigger?!0:(o.log("error","trigger HTMLElement does not found on your document."),!1)}getPositionByValue(){var n;const{keyMap:t,connector:e,initValue:i}=this.config,s=(i==null?void 0:i.split(e))||[];if(this.isJsonType){let r=(n=this.wheelsData[0])==null?void 0:n.data;return s.reduce((l,g)=>{var u;const a=r==null?void 0:r.findIndex(d=>d[t.value]==g);return l.push(a<0?0:a),r=(u=r[a])==null?void 0:u[t.childs],l},[])}return s.reduce((r,l,g)=>{var u,d;const a=(d=(u=this.wheelsData[g])==null?void 0:u.data)==null?void 0:d.findIndex(m=>m==l);return r.push(a<0?0:a),r},[])}setTitle(t){this.mobileSelect.querySelector(".ms-title").innerHTML=t}setStyle(t){if(t.ensureBtnColor&&(this.ensureBtn.style.color=t.ensureBtnColor),t.cancelBtnColor&&(this.cancelBtn.style.color=t.cancelBtnColor),t.titleColor){const e=this.mobileSelect.querySelector(".ms-title");e.style.color=t.titleColor}if(t.textColor&&(this.panel=this.mobileSelect.querySelector(".ms-panel"),this.panel.style.color=t.textColor),t.titleBgColor){const e=this.mobileSelect.querySelector(".ms-btn-bar");e.style.backgroundColor=t.titleBgColor}if(t.bgColor){this.panel=this.mobileSelect.querySelector(".ms-panel");const e=this.mobileSelect.querySelector(".ms-shadow-mask");this.panel.style.backgroundColor=t.bgColor,e.style.background="linear-gradient(to bottom, "+t.bgColor+", rgba(255, 255, 255, 0), "+t.bgColor+")"}if(typeof t.maskOpacity=="number"){const e=this.mobileSelect.querySelector(".ms-gray-layer");e.style.background="rgba(0, 0, 0, "+t.maskOpacity+")"}}show(){var t,e,i;this.mobileSelect.classList.add("ms-show"),(t=document.querySelector("body"))==null||t.classList.add("ms-show"),typeof this.config.onShow=="function"&&((i=(e=this.config).onShow)==null||i.call(e,this.curValue,this.curIndexArr,this))}hide(){var t,e,i;this.mobileSelect.classList.remove("ms-show"),(t=document.querySelector("body"))==null||t.classList.remove("ms-show"),typeof this.config.onHide=="function"&&((i=(e=this.config).onHide)==null||i.call(e,this.curValue,this.curIndexArr,this))}registerEvents(t){for(const[e,i]of Object.entries(this.eventHandleMap))typeof i.event=="string"?this[e][`${t}EventListener`](i.event,i.fn,{passive:!1}):i.event.forEach(s=>{this[e][`${t}EventListener`](s,i.fn,{passive:!1})})}destroy(){var t,e;this.registerEvents("remove"),(e=(t=this.mobileSelect)==null?void 0:t.parentNode)==null||e.removeChild(this.mobileSelect)}getOptionsHtmlStr(t){const{keyMap:e}=this.config;let i="";if(this.isJsonType)for(let s=0;s<t.length;s++){const n=t[s][e.id],r=t[s][e.value];i+=`<li data-id="${n}">${r}</li>`}else for(let s=0;s<t.length;s++)i+="<li>"+t[s]+"</li>";return i}renderComponent(t){this.mobileSelect=document.createElement("div"),this.mobileSelect.className="ms-mobile-select",this.mobileSelect.innerHTML=`<div class="ms-gray-layer"></div>
<div class="ms-content">

@@ -23,2 +23,2 @@ <div class="ms-btn-bar">

</div>
</div>`,document.body.appendChild(this.mobileSelect);let e="";for(let i=0;i<t.length;i++)e+=`<div class="ms-wheel" data-index="${i}"><ul class="ms-select-container">`,e+=this.getOptionsHtmlStr(t[i].data),e+="</ul></div>";this.mobileSelect.querySelector(".ms-wheels").innerHTML=e}reRenderWheels(){const t=this.wheel.length-this.displayJson.length;if(t>0)for(let e=0;e<t;e++)this.wheels.removeChild(this.wheel[this.wheel.length-1]);for(let e=0;e<this.displayJson.length;e++)if(this.wheel[e])this.slider[e].innerHTML=this.getOptionsHtmlStr(this.displayJson[e]);else{const i=document.createElement("div");i.className="ms-wheel",i.innerHTML=`<ul class="ms-select-container">${this.getOptionsHtmlStr(this.displayJson[e])}</ul>`,i.setAttribute("data-index",e.toString()),this.wheels.appendChild(i)}}checkCascade(){var e;const{keyMap:t}=this.config;if(this.isJsonType){const i=this.wheelsData[0].data;for(let s=0;s<i.length;s++)if(t.childs in i[s]&&((e=i[s][t.childs])==null?void 0:e.length)>0)return this.cascadeJsonData=this.wheelsData[0].data,!0}return!1}initCascade(){this.displayJson.push(this.cascadeJsonData),this.initPosition.length>0?(this.initDeepCount=0,this.initCheckArrDeep(this.cascadeJsonData[this.initPosition[0]])):this.checkArrDeep(this.cascadeJsonData[0]),this.reRenderWheels()}initCheckArrDeep(t){if(t){const{keyMap:e}=this.config;if(e.childs in t&&t[e.childs].length>0){this.displayJson.push(t[e.childs]),this.initDeepCount++;const i=t[e.childs][this.initPosition[this.initDeepCount]];i?this.initCheckArrDeep(i):this.checkArrDeep(t[e.childs][0])}}}checkArrDeep(t){if(!t)return;const{keyMap:e}=this.config;e.childs in t&&t[e.childs].length>0&&(this.displayJson.push(t[e.childs]),this.checkArrDeep(t[e.childs][0]))}checkRange(t,e){var r;const i=this.displayJson.length-1-t,{keyMap:s}=this.config;for(let l=0;l<i;l++)this.displayJson.pop();let n;for(let l=0;l<=t;l++)n=l==0?this.cascadeJsonData[e[0]]:(r=n==null?void 0:n[s.childs])==null?void 0:r[e[l]];this.checkArrDeep(n),this.reRenderWheels(),this.fixRowStyle(),this.setCurDistance(this.resetPosition(t,e))}resetPosition(t,e){const i=[...e];let s;if(this.slider.length>e.length){s=this.slider.length-e.length;for(let n=0;n<s;n++)i.push(0)}else if(this.slider.length<e.length){s=e.length-this.slider.length;for(let n=0;n<s;n++)i.pop()}for(let n=t+1;n<i.length;n++)i[n]=0;return i}updateWheels(t){if(this.isCascade){if(this.cascadeJsonData=t,this.displayJson=[],this.initCascade(),this.initPosition.length<this.slider.length){const e=this.slider.length-this.initPosition.length;for(let i=0;i<e;i++)this.initPosition.push(0)}this.setCurDistance(this.initPosition),this.fixRowStyle()}}updateWheel(t,e){if(this.isCascade){o.log("error","'updateWheel()' not support cascade json data, please use 'updateWheels()' instead to update the whole data source");return}let i="";i+=this.getOptionsHtmlStr(e),this.wheelsData[t]=this.isJsonType?{data:e}:e,this.slider[t].innerHTML=i}fixRowStyle(){if(this.initColWidth.length&&this.initColWidth.length===this.wheel.length){const e=this.initColWidth.reduce((i,s)=>i+s,0);this.initColWidth.forEach((i,s)=>{this.wheel[s].style.width=(i/e*100).toFixed(2)+"%"});return}const t=(100/this.wheel.length).toFixed(2);for(let e=0;e<this.wheel.length;e++)this.wheel[e].style.width=t+"%"}getIndex(t){return Math.round((2*this.optionHeight-t)/this.optionHeight)}getIndexArr(){const t=[];for(let e=0;e<this.curDistance.length;e++)t.push(this.getIndex(this.curDistance[e]));return t}getCurValue(){const t=[],e=this.getIndexArr(),{keyMap:i}=this.config;if(this.isCascade)for(let s=0;s<this.wheel.length;s++){const n=this.displayJson[s][e[s]];n&&t.push({[i.id]:n[i.id],[i.value]:n[i.value]})}else if(this.isJsonType)for(let s=0;s<this.curDistance.length;s++)t.push(this.wheelsData[s].data[this.getIndex(this.curDistance[s])]);else for(let s=0;s<this.curDistance.length;s++)t.push(this.getInnerText(s));return t}getValue(){return this.curValue}calcDistance(t){return 2*this.optionHeight-t*this.optionHeight}setCurDistance(t){const e=[];for(let i=0;i<this.slider.length;i++)e.push(this.calcDistance(t[i])),this.movePosition(this.slider[i],e[i]);this.curDistance=e}fixPosition(t){return-(this.getIndex(t)-2)*this.optionHeight}movePosition(t,e){t.style.transform="translate3d(0,"+e+"px, 0)"}locatePosition(t,e){this.curDistance[t]=this.calcDistance(e),this.movePosition(this.slider[t],this.curDistance[t]),this.isCascade&&this.checkRange(t,this.getIndexArr())}updateCurDistance(t,e){this.curDistance[e]=parseInt(t.style.transform.split(",")[1])}getInnerText(t){var s;const e=this.slider[t].getElementsByTagName("li").length;let i=this.getIndex(this.curDistance[t]);return i>=e?i=e-1:i<0&&(i=0),((s=this.slider[t].getElementsByTagName("li")[i])==null?void 0:s.innerText)||""}touch(t){var r,l,g,a,u,d,m,C;const i=(t.composedPath&&t.composedPath()).find(p=>{var y;return(y=p.classList)==null?void 0:y.contains("ms-wheel")});if(!i)return;const s=i.firstChild,n=parseInt(i.getAttribute("data-index")||"0");switch(t.type){case"touchstart":case"mousedown":s.style.transition="none 0s ease-out",this.startY=Math.floor(t instanceof TouchEvent?t.touches[0].clientY:t.clientY),this.preMoveY=this.startY,t.type==="mousedown"&&(this.enableClickStatus=!0);break;case"touchmove":case"mousemove":if(t.preventDefault(),t.type==="mousemove"&&!this.enableClickStatus)break;this.moveY=Math.floor(t instanceof TouchEvent?t.touches[0].clientY:t.clientY),this.offsetY=(this.moveY-this.preMoveY)*this.config.scrollSpeed,this.updateCurDistance(s,n),this.curDistance[n]=this.curDistance[n]+this.offsetY,this.movePosition(s,this.curDistance[n]),this.preMoveY=this.moveY;break;case"touchend":case"mouseup":if(s.style.transition="transform 0.18s ease-out",this.moveEndY=Math.floor(t instanceof TouchEvent?t.changedTouches[0].clientY:t.clientY),this.offsetSum=this.moveEndY-this.startY,this.oversizeBorder=-(s.getElementsByTagName("li").length-3)*this.optionHeight,this.offsetSum==0){const p=Math.floor((window.innerHeight-this.moveEndY)/40);if(p!=2){const y=p-2,v=this.curDistance[n]+y*this.optionHeight;v<=2*this.optionHeight&&v>=this.oversizeBorder&&(this.curDistance[n]=v,this.movePosition(s,this.curDistance[n]),(l=(r=this.config).transitionEnd)==null||l.call(r,this.getIndexArr(),this.getCurValue(),this),(a=(g=this.config).onTransitionEnd)==null||a.call(g,this.getCurValue(),this.getIndexArr(),this))}}else this.updateCurDistance(s,n),this.curDistance[n]=this.fixPosition(this.curDistance[n]),this.curDistance[n]>2*this.optionHeight?this.curDistance[n]=2*this.optionHeight:this.curDistance[n]<this.oversizeBorder&&(this.curDistance[n]=this.oversizeBorder),this.movePosition(s,this.curDistance[n]),(d=(u=this.config).transitionEnd)==null||d.call(u,this.getIndexArr(),this.getCurValue(),this),(C=(m=this.config).onTransitionEnd)==null||C.call(m,this.getCurValue(),this.getIndexArr(),this);t.type==="mouseup"&&(this.enableClickStatus=!1),this.isCascade&&this.checkRange(n,this.getIndexArr());break}}};let c=o;return h(c,"defaultConfig",{keyMap:{id:"id",value:"value",childs:"childs"},position:[],colWidth:[],title:"",connector:" ",ensureBtnText:"\u786E\u8BA4",cancelBtnText:"\u53D6\u6D88",triggerDisplayValue:!0,scrollSpeed:1}),h(c,"REQUIRED_PARAMS",["trigger","wheels"]),c});
</div>`,document.body.appendChild(this.mobileSelect);let e="";for(let i=0;i<t.length;i++)e+=`<div class="ms-wheel" data-index="${i}"><ul class="ms-select-container">`,e+=this.getOptionsHtmlStr(t[i].data),e+="</ul></div>";this.mobileSelect.querySelector(".ms-wheels").innerHTML=e}reRenderWheels(){const t=this.wheelList.length-this.displayJson.length;if(t>0)for(let e=0;e<t;e++)this.wheelsContain.removeChild(this.wheelList[this.wheelList.length-1]);for(let e=0;e<this.displayJson.length;e++)if(this.wheelList[e])this.sliderList[e].innerHTML=this.getOptionsHtmlStr(this.displayJson[e]);else{const i=document.createElement("div");i.className="ms-wheel",i.innerHTML=`<ul class="ms-select-container">${this.getOptionsHtmlStr(this.displayJson[e])}</ul>`,i.setAttribute("data-index",e.toString()),this.wheelsContain.appendChild(i)}}checkCascade(){var e;const{keyMap:t}=this.config;if(this.isJsonType){const i=this.wheelsData[0].data;for(let s=0;s<i.length;s++)if(t.childs in i[s]&&((e=i[s][t.childs])==null?void 0:e.length)>0)return this.cascadeJsonData=this.wheelsData[0].data,!0}return!1}initCascade(){this.displayJson.push(this.cascadeJsonData),this.initPosition.length>0?(this.initDeepCount=0,this.initCheckArrDeep(this.cascadeJsonData[this.initPosition[0]])):this.checkArrDeep(this.cascadeJsonData[0]),this.reRenderWheels()}initCheckArrDeep(t){if(t){const{keyMap:e}=this.config;if(e.childs in t&&t[e.childs].length>0){this.displayJson.push(t[e.childs]),this.initDeepCount++;const i=t[e.childs][this.initPosition[this.initDeepCount]];i?this.initCheckArrDeep(i):this.checkArrDeep(t[e.childs][0])}}}checkArrDeep(t){if(!t)return;const{keyMap:e}=this.config;e.childs in t&&t[e.childs].length>0&&(this.displayJson.push(t[e.childs]),this.checkArrDeep(t[e.childs][0]))}checkRange(t,e){var r;const i=this.displayJson.length-1-t,{keyMap:s}=this.config;for(let l=0;l<i;l++)this.displayJson.pop();let n;for(let l=0;l<=t;l++)n=l==0?this.cascadeJsonData[e[0]]:(r=n==null?void 0:n[s.childs])==null?void 0:r[e[l]];this.checkArrDeep(n),this.reRenderWheels(),this.fixRowStyle(),this.setCurDistance(this.resetPosition(t,e))}resetPosition(t,e){const i=[...e];let s;if(this.sliderList.length>e.length){s=this.sliderList.length-e.length;for(let n=0;n<s;n++)i.push(0)}else if(this.sliderList.length<e.length){s=e.length-this.sliderList.length;for(let n=0;n<s;n++)i.pop()}for(let n=t+1;n<i.length;n++)i[n]=0;return i}updateWheels(t){if(this.isCascade){if(this.cascadeJsonData=t,this.displayJson=[],this.initCascade(),this.initPosition.length<this.sliderList.length){const e=this.sliderList.length-this.initPosition.length;for(let i=0;i<e;i++)this.initPosition.push(0)}this.setCurDistance(this.initPosition),this.fixRowStyle()}}updateWheel(t,e){if(this.isCascade){o.log("error","'updateWheel()' not support cascade json data, please use 'updateWheels()' instead to update the whole data source");return}let i="";i+=this.getOptionsHtmlStr(e),this.wheelsData[t]=this.isJsonType?{data:e}:e,this.sliderList[t].innerHTML=i}fixRowStyle(){if(this.initColWidth.length&&this.initColWidth.length===this.wheelList.length){const e=this.initColWidth.reduce((i,s)=>i+s,0);this.initColWidth.forEach((i,s)=>{this.wheelList[s].style.width=(i/e*100).toFixed(2)+"%"});return}const t=(100/this.wheelList.length).toFixed(2);for(let e=0;e<this.wheelList.length;e++)this.wheelList[e].style.width=t+"%"}getIndex(t){return Math.round((2*this.optionHeight-t)/this.optionHeight)}getIndexArr(){const t=[];for(let e=0;e<this.curDistance.length;e++)t.push(this.getIndex(this.curDistance[e]));return t}getCurValue(){const t=[],e=this.getIndexArr(),{keyMap:i}=this.config;if(this.isCascade)for(let s=0;s<this.wheelList.length;s++){const n=this.displayJson[s][e[s]];n&&t.push({[i.id]:n[i.id],[i.value]:n[i.value]})}else if(this.isJsonType)for(let s=0;s<this.curDistance.length;s++)t.push(this.wheelsData[s].data[this.getIndex(this.curDistance[s])]);else for(let s=0;s<this.curDistance.length;s++)t.push(this.getInnerText(s));return t}getValue(){return this.curValue}calcDistance(t){return 2*this.optionHeight-t*this.optionHeight}setCurDistance(t){const e=[];for(let i=0;i<this.sliderList.length;i++)e.push(this.calcDistance(t[i])),this.movePosition(this.sliderList[i],e[i]);this.curDistance=e}fixPosition(t){return-(this.getIndex(t)-2)*this.optionHeight}movePosition(t,e){t.style.transform="translate3d(0,"+e+"px, 0)"}locatePosition(t,e){this.curDistance[t]=this.calcDistance(e),this.movePosition(this.sliderList[t],this.curDistance[t]),this.isCascade&&this.checkRange(t,this.getIndexArr())}updateCurDistance(t,e){this.curDistance[e]=parseInt(t.style.transform.split(",")[1])}getInnerText(t){var s;const e=this.sliderList[t].getElementsByTagName("li").length;let i=this.getIndex(this.curDistance[t]);return i>=e?i=e-1:i<0&&(i=0),((s=this.sliderList[t].getElementsByTagName("li")[i])==null?void 0:s.innerText)||""}touch(t){var r,l,g,a,u,d,m,v;const i=(t.composedPath&&t.composedPath()).find(p=>{var y;return(y=p.classList)==null?void 0:y.contains("ms-wheel")});if(!i)return;const s=i.firstChild,n=parseInt(i.getAttribute("data-index")||"0");switch(t.type){case"touchstart":case"mousedown":s.style.transition="none 0s ease-out",this.startY=Math.floor(t instanceof TouchEvent?t.touches[0].clientY:t.clientY),this.preMoveY=this.startY,t.type==="mousedown"&&(this.enableClickStatus=!0);break;case"touchmove":case"mousemove":if(t.preventDefault(),t.type==="mousemove"&&!this.enableClickStatus)break;this.moveY=Math.floor(t instanceof TouchEvent?t.touches[0].clientY:t.clientY),this.offsetY=(this.moveY-this.preMoveY)*this.config.scrollSpeed,this.updateCurDistance(s,n),this.curDistance[n]=this.curDistance[n]+this.offsetY,this.movePosition(s,this.curDistance[n]),this.preMoveY=this.moveY;break;case"touchend":case"mouseup":if(s.style.transition="transform 0.18s ease-out",this.moveEndY=Math.floor(t instanceof TouchEvent?t.changedTouches[0].clientY:t.clientY),this.offsetSum=this.moveEndY-this.startY,this.oversizeBorder=-(s.getElementsByTagName("li").length-3)*this.optionHeight,this.offsetSum==0){const p=Math.floor((window.innerHeight-this.moveEndY)/40);if(p!=2){const y=p-2,C=this.curDistance[n]+y*this.optionHeight;C<=2*this.optionHeight&&C>=this.oversizeBorder&&(this.curDistance[n]=C,this.movePosition(s,this.curDistance[n]),(l=(r=this.config).transitionEnd)==null||l.call(r,this.getIndexArr(),this.getCurValue(),this),(a=(g=this.config).onTransitionEnd)==null||a.call(g,this.getCurValue(),this.getIndexArr(),this))}}else this.updateCurDistance(s,n),this.curDistance[n]=this.fixPosition(this.curDistance[n]),this.curDistance[n]>2*this.optionHeight?this.curDistance[n]=2*this.optionHeight:this.curDistance[n]<this.oversizeBorder&&(this.curDistance[n]=this.oversizeBorder),this.movePosition(s,this.curDistance[n]),(d=(u=this.config).transitionEnd)==null||d.call(u,this.getIndexArr(),this.getCurValue(),this),(v=(m=this.config).onTransitionEnd)==null||v.call(m,this.getCurValue(),this.getIndexArr(),this);t.type==="mouseup"&&(this.enableClickStatus=!1),this.isCascade&&this.checkRange(n,this.getIndexArr());break}}};let c=o;return h(c,"defaultConfig",{keyMap:{id:"id",value:"value",childs:"childs"},position:[],colWidth:[],title:"",connector:" ",ensureBtnText:"\u786E\u8BA4",cancelBtnText:"\u53D6\u6D88",triggerDisplayValue:!0,scrollSpeed:1}),h(c,"REQUIRED_PARAMS",["trigger","wheels"]),c});

@@ -111,3 +111,3 @@ <p align="center"><img width="130" src="https://github.com/onlyhom/img-folder/blob/master/png/m_logo_orange.png?raw=true"></p>

<img src="https://raw.githubusercontent.com/gilbarbara/logos/master/logos/react.svg" width="50" title="React"> <br/>
<strong>React</strong> <br/>
<strong>React-ts</strong> <br/>
<sub>

@@ -114,0 +114,0 @@ <a href="https://codesandbox.io/s/mobile-select-react-ts-woc5f8" target="_blank">📦Sandbox</a>

@@ -6,3 +6,3 @@ {

"private": false,
"version": "1.3.1",
"version": "1.3.2",
"main": "dist/mobile-select.umd.js",

@@ -9,0 +9,0 @@ "module": "dist/mobile-select.es.js",

@@ -114,3 +114,3 @@ <p align="center"><img width="130" src="https://github.com/onlyhom/img-folder/blob/master/png/m_logo_orange.png?raw=true"></p>

<img src="https://raw.githubusercontent.com/gilbarbara/logos/master/logos/react.svg" width="50" title="React"> <br/>
<strong>React</strong> <br/>
<strong>React-ts</strong> <br/>
<sub>

@@ -380,3 +380,3 @@ <a href="https://codesandbox.io/s/mobile-select-react-ts-woc5f8" target="_blank">📦Sandbox</a>

| onTransitionEnd | function(data, indexArr, instance){} | function |≥1.2.0 | A callback function that after each gesture sliding|
| cancel | function(data, indexArr, instance){} | function | | A callback function after cancel selected, return last successful selected data|
| onCancel | function(data, indexArr, instance){} | function | | A callback function after cancel selected, return last successful selected data|
| onShow | function(instance){} | function | | A callback when the panel is show|

@@ -383,0 +383,0 @@ | onHide | function(instance){} | function | | A callback when the panel is hidden|

@@ -10,7 +10,7 @@ import {

export default class MobileSelect {
mobileSelect: any;
mobileSelect!: HTMLDivElement;
trigger!: HTMLElement;
wheel!: HTMLCollectionOf<HTMLElement>;
slider!: HTMLCollectionOf<HTMLElement>;
wheels!: HTMLDivElement;
wheelList!: HTMLCollectionOf<HTMLElement>;
sliderList!: HTMLCollectionOf<HTMLElement>;
wheelsContain!: HTMLDivElement;
panel!: HTMLDivElement;

@@ -117,13 +117,18 @@ ensureBtn!: HTMLDivElement;

if (!this.checkTriggerAvailable()) return;
this.wheel = this.mobileSelect.getElementsByClassName("ms-wheel");
this.slider = this.mobileSelect.getElementsByClassName(
// 这里使用getElementsByClassName(不使用querySelectorAll)的原因:返回一个实时的 HTMLCollection, DOM的更改将在更改发生时反映在数组中
this.wheelList = this.mobileSelect.getElementsByClassName(
"ms-wheel"
) as HTMLCollectionOf<HTMLElement>;
this.sliderList = this.mobileSelect.getElementsByClassName(
"ms-select-container"
);
this.panel = this.mobileSelect.querySelector(".ms-panel");
this.wheels = this.mobileSelect.querySelector(".ms-wheels");
this.ensureBtn = this.mobileSelect.querySelector(".ms-ensure");
this.cancelBtn = this.mobileSelect.querySelector(".ms-cancel");
this.grayLayer = this.mobileSelect.querySelector(".ms-gray-layer");
this.popUp = this.mobileSelect.querySelector(".ms-content");
this.optionHeight = this.mobileSelect.querySelector("li").offsetHeight;
) as HTMLCollectionOf<HTMLElement>;
this.panel = this.mobileSelect.querySelector(".ms-panel")!;
this.wheelsContain = this.mobileSelect.querySelector(".ms-wheels")!;
this.ensureBtn = this.mobileSelect.querySelector(".ms-ensure")!;
this.cancelBtn = this.mobileSelect.querySelector(".ms-cancel")!;
this.grayLayer = this.mobileSelect.querySelector(".ms-gray-layer")!;
this.popUp = this.mobileSelect.querySelector(".ms-content")!;
this.optionHeight = this.mobileSelect.querySelector("li")!.offsetHeight;
// 复显初始值

@@ -145,4 +150,4 @@ if (config.initValue && config.triggerDisplayValue) {

// 补全initPosition
if (this.initPosition.length < this.slider.length) {
const diff = this.slider.length - this.initPosition.length;
if (this.initPosition.length < this.sliderList.length) {
const diff = this.sliderList.length - this.initPosition.length;
for (let i = 0; i < diff; i++) {

@@ -176,7 +181,7 @@ this.initPosition.push(0);

this.optionHeight =
this.mobileSelect.querySelector("li").offsetHeight;
this.mobileSelect.querySelector("li")!.offsetHeight;
}
let tempValue = "";
for (let i = 0; i < this.wheel.length; i++) {
i == this.wheel.length - 1
for (let i = 0; i < this.wheelList.length; i++) {
i == this.wheelList.length - 1
? (tempValue += this.getInnerText(i))

@@ -303,3 +308,3 @@ : (tempValue += this.getInnerText(i) + this.config.connector);

setTitle(title: string): void {
this.mobileSelect.querySelector(".ms-title").innerHTML = title;
this.mobileSelect.querySelector(".ms-title")!.innerHTML = title;
}

@@ -315,16 +320,19 @@

if (config.titleColor) {
const titleDom = this.mobileSelect.querySelector(".ms-title");
const titleDom =
this.mobileSelect.querySelector<HTMLDivElement>(".ms-title")!;
titleDom.style.color = config.titleColor;
}
if (config.textColor) {
this.panel = this.mobileSelect.querySelector(".ms-panel");
this.panel = this.mobileSelect.querySelector(".ms-panel")!;
this.panel.style.color = config.textColor;
}
if (config.titleBgColor) {
const btnBar = this.mobileSelect.querySelector(".ms-btn-bar");
const btnBar =
this.mobileSelect.querySelector<HTMLDivElement>(".ms-btn-bar")!;
btnBar.style.backgroundColor = config.titleBgColor;
}
if (config.bgColor) {
this.panel = this.mobileSelect.querySelector(".ms-panel");
const shadowMask = this.mobileSelect.querySelector(".ms-shadow-mask");
this.panel = this.mobileSelect.querySelector(".ms-panel")!;
const shadowMask =
this.mobileSelect.querySelector<HTMLDivElement>(".ms-shadow-mask")!;
this.panel.style.backgroundColor = config.bgColor;

@@ -339,3 +347,4 @@ shadowMask.style.background =

if (typeof config.maskOpacity === "number") {
const grayMask = this.mobileSelect.querySelector(".ms-gray-layer");
const grayMask =
this.mobileSelect.querySelector<HTMLDivElement>(".ms-gray-layer")!;
grayMask.style.background = "rgba(0, 0, 0, " + config.maskOpacity + ")";

@@ -349,3 +358,3 @@ }

if (typeof this.config.onShow === "function") {
this.config.onShow?.();
this.config.onShow?.(this.curValue, this.curIndexArr, this);
}

@@ -358,3 +367,3 @@ }

if (typeof this.config.onHide === "function") {
this.config.onHide?.();
this.config.onHide?.(this.curValue, this.curIndexArr, this);
}

@@ -366,15 +375,11 @@ }

if (typeof item.event === "string") {
this[domName as keyof MobileSelect][`${type}EventListener`](
item.event,
item.fn,
{ passive: false }
);
(this[domName as keyof MobileSelect] as HTMLElement)[
`${type}EventListener`
](item.event, item.fn as EventListener, { passive: false });
} else {
// 数组
item.event.forEach((eventName) => {
this[domName as keyof MobileSelect][`${type}EventListener`](
eventName,
item.fn,
{ passive: false }
);
(this[domName as keyof MobileSelect] as HTMLElement)[
`${type}EventListener`
](eventName, item.fn as EventListener, { passive: false });
});

@@ -438,3 +443,3 @@ }

}
this.mobileSelect.querySelector(".ms-wheels").innerHTML = tempHTML;
this.mobileSelect.querySelector(".ms-wheels")!.innerHTML = tempHTML;
}

@@ -444,11 +449,15 @@

reRenderWheels(): void {
const diff = this.wheel.length - this.displayJson.length;
const diff = this.wheelList.length - this.displayJson.length;
if (diff > 0) {
for (let i = 0; i < diff; i++) {
this.wheels.removeChild(this.wheel[this.wheel.length - 1]);
this.wheelsContain.removeChild(
this.wheelList[this.wheelList.length - 1]
);
}
}
for (let i = 0; i < this.displayJson.length; i++) {
if (this.wheel[i]) {
this.slider[i].innerHTML = this.getOptionsHtmlStr(this.displayJson[i]);
if (this.wheelList[i]) {
this.sliderList[i].innerHTML = this.getOptionsHtmlStr(
this.displayJson[i]
);
} else {

@@ -461,3 +470,3 @@ const tempWheel = document.createElement("div");

tempWheel.setAttribute("data-index", i.toString());
this.wheels.appendChild(tempWheel);
this.wheelsContain.appendChild(tempWheel);
}

@@ -543,9 +552,9 @@ }

let tempCount;
if (this.slider.length > posIndexArr.length) {
tempCount = this.slider.length - posIndexArr.length;
if (this.sliderList.length > posIndexArr.length) {
tempCount = this.sliderList.length - posIndexArr.length;
for (let i = 0; i < tempCount; i++) {
tempPosArr.push(0);
}
} else if (this.slider.length < posIndexArr.length) {
tempCount = posIndexArr.length - this.slider.length;
} else if (this.sliderList.length < posIndexArr.length) {
tempCount = posIndexArr.length - this.sliderList.length;
for (let i = 0; i < tempCount; i++) {

@@ -566,4 +575,4 @@ tempPosArr.pop();

this.initCascade();
if (this.initPosition.length < this.slider.length) {
const diff = this.slider.length - this.initPosition.length;
if (this.initPosition.length < this.sliderList.length) {
const diff = this.sliderList.length - this.initPosition.length;
for (let i = 0; i < diff; i++) {

@@ -592,3 +601,3 @@ this.initPosition.push(0);

this.wheelsData[sliderIndex] = this.isJsonType ? { data } : data;
this.slider[sliderIndex].innerHTML = tempHTML;
this.sliderList[sliderIndex].innerHTML = tempHTML;
}

@@ -600,7 +609,7 @@

this.initColWidth.length &&
this.initColWidth.length === this.wheel.length
this.initColWidth.length === this.wheelList.length
) {
const widthSum = this.initColWidth.reduce((cur, pre) => cur + pre, 0);
this.initColWidth.forEach((item, index) => {
this.wheel[index].style.width =
this.wheelList[index].style.width =
((item / widthSum) * 100).toFixed(2) + "%";

@@ -610,5 +619,5 @@ });

}
const width = (100 / this.wheel.length).toFixed(2);
for (let i = 0; i < this.wheel.length; i++) {
this.wheel[i].style.width = width + "%";
const width = (100 / this.wheelList.length).toFixed(2);
for (let i = 0; i < this.wheelList.length; i++) {
this.wheelList[i].style.width = width + "%";
}

@@ -634,3 +643,3 @@ }

if (this.isCascade) {
for (let i = 0; i < this.wheel.length; i++) {
for (let i = 0; i < this.wheelList.length; i++) {
const tempObj = this.displayJson[i][positionArr[i]];

@@ -666,5 +675,5 @@ if (tempObj) {

const temp = [];
for (let i = 0; i < this.slider.length; i++) {
for (let i = 0; i < this.sliderList.length; i++) {
temp.push(this.calcDistance(indexArr[i]));
this.movePosition(this.slider[i], temp[i]);
this.movePosition(this.sliderList[i], temp[i]);
}

@@ -684,3 +693,3 @@ this.curDistance = temp;

this.curDistance[index] = this.calcDistance(posIndex);
this.movePosition(this.slider[index], this.curDistance[index]);
this.movePosition(this.sliderList[index], this.curDistance[index]);
if (this.isCascade) {

@@ -697,3 +706,3 @@ this.checkRange(index, this.getIndexArr());

const lengthOfList =
this.slider[sliderIndex].getElementsByTagName("li").length;
this.sliderList[sliderIndex].getElementsByTagName("li").length;
let index = this.getIndex(this.curDistance[sliderIndex]);

@@ -707,4 +716,4 @@

return (
this.slider[sliderIndex].getElementsByTagName("li")[index]?.innerText ||
""
this.sliderList[sliderIndex].getElementsByTagName("li")[index]
?.innerText || ""
);

@@ -711,0 +720,0 @@ }

@@ -0,6 +1,14 @@

import MobileSelect from "../ms-core";
export type CascadeData = {
[k: string]: any;
};
export type ResultVal = number | string | CascadeData;
export interface CallbackFn {
(curValue?: number[] | string[], indexArr?: number[], context?: any): void;
(curValue: ResultVal[], indexArr: number[], context: MobileSelect): void;
}
export interface OldCallbackFn {
(indexArr?: number[], curValue?: number[] | string[], context?: any): void;
(indexArr: number[], curValue: ResultVal[], context: MobileSelect): void;
}

@@ -10,6 +18,2 @@

export type CascadeData = {
[k: string]: any;
};
export type OptionData = CascadeData | string | number;

@@ -93,12 +97,12 @@

/** 旧版本 选择完毕的回调函数 */
/** (即将废弃) 选择完毕的回调函数 */
callback?: OldCallbackFn;
/** 旧版本 取消面板的回调函数 */
/** (即将废弃) 取消面板的回调函数 */
cancel?: OldCallbackFn;
/** 旧版本 滚动滚动完毕的回调函数 */
/** (即将废弃) 滚动滚动完毕的回调函数 */
transitionEnd?: OldCallbackFn;
/** 旧版本 onChange后 是否修改trigger的innerText */
/** (即将废弃) onChange后 是否修改trigger的innerText */
triggerDisplayData?: boolean;

@@ -105,0 +109,0 @@ };

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc