@idds/js 1.6.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.iife.js +51 -3
- package/dist/index.js +51 -3
- package/package.json +1 -1
package/dist/index.iife.js
CHANGED
|
@@ -1300,7 +1300,6 @@ var InaUI = (() => {
|
|
|
1300
1300
|
input.placeholder = this.container.getAttribute("placeholder") || "Select time";
|
|
1301
1301
|
if (this.options.disabled) input.disabled = true;
|
|
1302
1302
|
if (this.options.readonly) input.readOnly = true;
|
|
1303
|
-
else input.readOnly = true;
|
|
1304
1303
|
wrapper.appendChild(input);
|
|
1305
1304
|
if (this.options.allowClear) {
|
|
1306
1305
|
clearBtn = document.createElement("button");
|
|
@@ -1615,13 +1614,50 @@ var InaUI = (() => {
|
|
|
1615
1614
|
bindEvents() {
|
|
1616
1615
|
this.elements.wrapper.addEventListener("click", (e) => {
|
|
1617
1616
|
e.stopPropagation();
|
|
1618
|
-
|
|
1617
|
+
const target = e.target;
|
|
1618
|
+
if (target === this.elements.wrapper || target.classList.contains(`${PREFIX}-time-picker__suffix-icon`) || target.classList.contains(`${PREFIX}-time-picker__prefix-icon`)) {
|
|
1619
|
+
this.toggle();
|
|
1620
|
+
}
|
|
1621
|
+
});
|
|
1622
|
+
this.elements.input.addEventListener("input", (e) => {
|
|
1623
|
+
const val = e.target.value;
|
|
1624
|
+
this.state.internalValue = val;
|
|
1625
|
+
const timeRegex = this.options.use12Hours ? /^(\d{1,2}):(\d{2})(?::(\d{2}))?\s?(AM|PM|am|pm)?$/ : /^(\d{1,2}):(\d{2})(?::(\d{2}))?$/;
|
|
1626
|
+
if (timeRegex.test(val)) {
|
|
1627
|
+
this.state.currentTime = this.parseTime(val);
|
|
1628
|
+
if (this.state.isOpen) this.buildPanel();
|
|
1629
|
+
}
|
|
1630
|
+
if (this.elements.clearBtn && this.options.allowClear) {
|
|
1631
|
+
this.elements.clearBtn.style.display = val && !this.options.disabled ? "flex" : "none";
|
|
1632
|
+
}
|
|
1633
|
+
if (typeof this.options.onChange === "function") {
|
|
1634
|
+
this.options.onChange(val);
|
|
1635
|
+
}
|
|
1636
|
+
});
|
|
1637
|
+
this.elements.input.addEventListener("click", (e) => {
|
|
1638
|
+
e.stopPropagation();
|
|
1639
|
+
this.open();
|
|
1640
|
+
});
|
|
1641
|
+
this.elements.input.addEventListener("focus", () => {
|
|
1642
|
+
this.open();
|
|
1643
|
+
});
|
|
1644
|
+
this.elements.input.addEventListener("keydown", (e) => {
|
|
1645
|
+
if (e.key === "Enter") {
|
|
1646
|
+
e.preventDefault();
|
|
1647
|
+
if (this.state.internalValue) {
|
|
1648
|
+
this.close();
|
|
1649
|
+
} else {
|
|
1650
|
+
this.toggle();
|
|
1651
|
+
}
|
|
1652
|
+
} else if (e.key === "Escape") {
|
|
1653
|
+
if (this.state.isOpen) this.close();
|
|
1654
|
+
}
|
|
1619
1655
|
});
|
|
1620
1656
|
if (this.elements.clearBtn) {
|
|
1621
1657
|
this.elements.clearBtn.addEventListener("click", (e) => {
|
|
1622
1658
|
e.stopPropagation();
|
|
1623
|
-
this.container.dataset.value = "";
|
|
1624
1659
|
this.state.internalValue = "";
|
|
1660
|
+
this.elements.input.value = "";
|
|
1625
1661
|
this.elements.clearBtn.style.display = "none";
|
|
1626
1662
|
this.elements.input.dispatchEvent(
|
|
1627
1663
|
new Event("change", { bubbles: true })
|
|
@@ -1630,6 +1666,12 @@ var InaUI = (() => {
|
|
|
1630
1666
|
this.options.onChange("");
|
|
1631
1667
|
}
|
|
1632
1668
|
});
|
|
1669
|
+
this.elements.clearBtn.addEventListener("keydown", (e) => {
|
|
1670
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
1671
|
+
e.preventDefault();
|
|
1672
|
+
this.elements.clearBtn.click();
|
|
1673
|
+
}
|
|
1674
|
+
});
|
|
1633
1675
|
}
|
|
1634
1676
|
document.addEventListener("click", (e) => {
|
|
1635
1677
|
if (!this.container.contains(e.target)) this.close();
|
|
@@ -3726,6 +3768,12 @@ var InaUI = (() => {
|
|
|
3726
3768
|
this.elements.clearBtn.addEventListener("click", () => {
|
|
3727
3769
|
this.clear();
|
|
3728
3770
|
});
|
|
3771
|
+
this.elements.clearBtn.addEventListener("keydown", (e) => {
|
|
3772
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
3773
|
+
e.preventDefault();
|
|
3774
|
+
this.clear();
|
|
3775
|
+
}
|
|
3776
|
+
});
|
|
3729
3777
|
}
|
|
3730
3778
|
document.addEventListener("click", (e) => {
|
|
3731
3779
|
if (!this.elements.wrapper.contains(e.target)) {
|
package/dist/index.js
CHANGED
|
@@ -1319,7 +1319,6 @@ var TimePicker = class {
|
|
|
1319
1319
|
input.placeholder = this.container.getAttribute("placeholder") || "Select time";
|
|
1320
1320
|
if (this.options.disabled) input.disabled = true;
|
|
1321
1321
|
if (this.options.readonly) input.readOnly = true;
|
|
1322
|
-
else input.readOnly = true;
|
|
1323
1322
|
wrapper.appendChild(input);
|
|
1324
1323
|
if (this.options.allowClear) {
|
|
1325
1324
|
clearBtn = document.createElement("button");
|
|
@@ -1634,13 +1633,50 @@ var TimePicker = class {
|
|
|
1634
1633
|
bindEvents() {
|
|
1635
1634
|
this.elements.wrapper.addEventListener("click", (e) => {
|
|
1636
1635
|
e.stopPropagation();
|
|
1637
|
-
|
|
1636
|
+
const target = e.target;
|
|
1637
|
+
if (target === this.elements.wrapper || target.classList.contains(`${PREFIX}-time-picker__suffix-icon`) || target.classList.contains(`${PREFIX}-time-picker__prefix-icon`)) {
|
|
1638
|
+
this.toggle();
|
|
1639
|
+
}
|
|
1640
|
+
});
|
|
1641
|
+
this.elements.input.addEventListener("input", (e) => {
|
|
1642
|
+
const val = e.target.value;
|
|
1643
|
+
this.state.internalValue = val;
|
|
1644
|
+
const timeRegex = this.options.use12Hours ? /^(\d{1,2}):(\d{2})(?::(\d{2}))?\s?(AM|PM|am|pm)?$/ : /^(\d{1,2}):(\d{2})(?::(\d{2}))?$/;
|
|
1645
|
+
if (timeRegex.test(val)) {
|
|
1646
|
+
this.state.currentTime = this.parseTime(val);
|
|
1647
|
+
if (this.state.isOpen) this.buildPanel();
|
|
1648
|
+
}
|
|
1649
|
+
if (this.elements.clearBtn && this.options.allowClear) {
|
|
1650
|
+
this.elements.clearBtn.style.display = val && !this.options.disabled ? "flex" : "none";
|
|
1651
|
+
}
|
|
1652
|
+
if (typeof this.options.onChange === "function") {
|
|
1653
|
+
this.options.onChange(val);
|
|
1654
|
+
}
|
|
1655
|
+
});
|
|
1656
|
+
this.elements.input.addEventListener("click", (e) => {
|
|
1657
|
+
e.stopPropagation();
|
|
1658
|
+
this.open();
|
|
1659
|
+
});
|
|
1660
|
+
this.elements.input.addEventListener("focus", () => {
|
|
1661
|
+
this.open();
|
|
1662
|
+
});
|
|
1663
|
+
this.elements.input.addEventListener("keydown", (e) => {
|
|
1664
|
+
if (e.key === "Enter") {
|
|
1665
|
+
e.preventDefault();
|
|
1666
|
+
if (this.state.internalValue) {
|
|
1667
|
+
this.close();
|
|
1668
|
+
} else {
|
|
1669
|
+
this.toggle();
|
|
1670
|
+
}
|
|
1671
|
+
} else if (e.key === "Escape") {
|
|
1672
|
+
if (this.state.isOpen) this.close();
|
|
1673
|
+
}
|
|
1638
1674
|
});
|
|
1639
1675
|
if (this.elements.clearBtn) {
|
|
1640
1676
|
this.elements.clearBtn.addEventListener("click", (e) => {
|
|
1641
1677
|
e.stopPropagation();
|
|
1642
|
-
this.container.dataset.value = "";
|
|
1643
1678
|
this.state.internalValue = "";
|
|
1679
|
+
this.elements.input.value = "";
|
|
1644
1680
|
this.elements.clearBtn.style.display = "none";
|
|
1645
1681
|
this.elements.input.dispatchEvent(
|
|
1646
1682
|
new Event("change", { bubbles: true })
|
|
@@ -1649,6 +1685,12 @@ var TimePicker = class {
|
|
|
1649
1685
|
this.options.onChange("");
|
|
1650
1686
|
}
|
|
1651
1687
|
});
|
|
1688
|
+
this.elements.clearBtn.addEventListener("keydown", (e) => {
|
|
1689
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
1690
|
+
e.preventDefault();
|
|
1691
|
+
this.elements.clearBtn.click();
|
|
1692
|
+
}
|
|
1693
|
+
});
|
|
1652
1694
|
}
|
|
1653
1695
|
document.addEventListener("click", (e) => {
|
|
1654
1696
|
if (!this.container.contains(e.target)) this.close();
|
|
@@ -3837,6 +3879,12 @@ var PhoneInput = class {
|
|
|
3837
3879
|
this.elements.clearBtn.addEventListener("click", () => {
|
|
3838
3880
|
this.clear();
|
|
3839
3881
|
});
|
|
3882
|
+
this.elements.clearBtn.addEventListener("keydown", (e) => {
|
|
3883
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
3884
|
+
e.preventDefault();
|
|
3885
|
+
this.clear();
|
|
3886
|
+
}
|
|
3887
|
+
});
|
|
3840
3888
|
}
|
|
3841
3889
|
document.addEventListener("click", (e) => {
|
|
3842
3890
|
if (!this.elements.wrapper.contains(e.target)) {
|