datex-ui 1.2.3 → 1.2.6
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.esm.js +75 -23
- package/dist/types/datex-types.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -433,7 +433,11 @@ class H {
|
|
|
433
433
|
line-height: 1em !important;
|
|
434
434
|
width: 278px !important;
|
|
435
435
|
z-index: 999999; /* Removed !important to allow JavaScript override */
|
|
436
|
-
margin-top:7px;
|
|
436
|
+
margin-top: 7px;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
.datex-picker.drop-up {
|
|
440
|
+
margin-top: 0 !important;
|
|
437
441
|
}
|
|
438
442
|
|
|
439
443
|
/* Base arrow styles - creates the dropdown arrow */
|
|
@@ -1531,6 +1535,10 @@ class E {
|
|
|
1531
1535
|
*/
|
|
1532
1536
|
updateZIndex() {
|
|
1533
1537
|
if (!this.container) return;
|
|
1538
|
+
if (this.options.zIndex !== "auto") {
|
|
1539
|
+
this.container.style.zIndex = this.options.zIndex.toString(), this.updateInternalElementsZIndex(this.options.zIndex);
|
|
1540
|
+
return;
|
|
1541
|
+
}
|
|
1534
1542
|
const t = this.getHighestZIndex(), e = parseInt(this.container.style.zIndex || "0");
|
|
1535
1543
|
if (t >= e) {
|
|
1536
1544
|
const a = t + 1;
|
|
@@ -1549,15 +1557,20 @@ class E {
|
|
|
1549
1557
|
}
|
|
1550
1558
|
positionForMobile() {
|
|
1551
1559
|
this.container.style.position = "fixed", this.container.style.bottom = "0", this.container.style.left = "0", this.container.style.right = "0", this.container.style.top = "auto", this.container.style.width = "100%", this.container.style.maxWidth = "100vw", this.container.style.minWidth = "100vw", this.container.style.borderRadius = "12px 12px 0 0", this.container.style.zIndex = "999999", this.container.style.margin = "0", this.container.style.padding = "0", this.container.style.boxSizing = "border-box", this.container.style.transform = "none", this.container.style.maxHeight = "85vh", this.container.style.isolation = "isolate", this.container.style.contain = "layout style", this.container.style.pointerEvents = "auto", this.container.style.touchAction = "manipulation", this.container.classList.add("drop-up", "mobile-view"), this.container.classList.remove("opensleft", "opensright", "openscenter"), this.showMobileHeader();
|
|
1552
|
-
|
|
1553
|
-
this.
|
|
1560
|
+
let t;
|
|
1561
|
+
if (this.options.zIndex !== "auto")
|
|
1562
|
+
t = this.options.zIndex;
|
|
1563
|
+
else {
|
|
1564
|
+
const e = this.getHighestZIndex(), a = 999999;
|
|
1565
|
+
t = e >= a ? e + 1 : a;
|
|
1566
|
+
}
|
|
1567
|
+
this.container.style.zIndex = t.toString(), this.updateInternalElementsZIndex(t);
|
|
1554
1568
|
}
|
|
1555
1569
|
getHighestZIndex() {
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
!isNaN(i) && i > e && (e = i);
|
|
1570
|
+
let t = this.element, e = 0;
|
|
1571
|
+
for (; t && t instanceof HTMLElement && t !== document.body; ) {
|
|
1572
|
+
const a = window.getComputedStyle(t), i = parseInt(a.zIndex);
|
|
1573
|
+
!isNaN(i) && i > e && (e = i), t = t.parentElement;
|
|
1561
1574
|
}
|
|
1562
1575
|
return e;
|
|
1563
1576
|
}
|
|
@@ -1574,25 +1587,55 @@ class E {
|
|
|
1574
1587
|
this.applyDropUpClass(o), this.applyFinalPosition(i, n);
|
|
1575
1588
|
}
|
|
1576
1589
|
resetContainerPosition() {
|
|
1577
|
-
this.container.style.top = "0", this.container.style.left = "0", this.container.style.right = "auto", this.container.style.position = "fixed";
|
|
1590
|
+
this.options.appendToBody ? (this.container.style.top = "0", this.container.style.left = "0", this.container.style.right = "auto", this.container.style.position = "fixed") : (this.container.style.position = "absolute", this.container.style.top = "auto", this.container.style.left = "auto", this.container.style.right = "auto");
|
|
1578
1591
|
}
|
|
1579
1592
|
calculateVerticalPosition(t, e) {
|
|
1580
1593
|
let a, i = this.options.drops;
|
|
1594
|
+
if (!this.options.appendToBody) {
|
|
1595
|
+
const o = this.element.offsetHeight;
|
|
1596
|
+
switch (i) {
|
|
1597
|
+
case "auto":
|
|
1598
|
+
const n = this.element.getBoundingClientRect();
|
|
1599
|
+
window.innerHeight - n.bottom < e && n.top > e ? (a = -e - 7, i = "up") : a = o;
|
|
1600
|
+
break;
|
|
1601
|
+
case "up":
|
|
1602
|
+
a = -e - 7;
|
|
1603
|
+
break;
|
|
1604
|
+
default:
|
|
1605
|
+
a = o;
|
|
1606
|
+
break;
|
|
1607
|
+
}
|
|
1608
|
+
return { top: a, drops: i };
|
|
1609
|
+
}
|
|
1581
1610
|
switch (i) {
|
|
1582
1611
|
case "auto":
|
|
1583
|
-
a = t.bottom
|
|
1612
|
+
a = t.bottom, a + e >= window.innerHeight && (a = t.top - e - 7, i = "up");
|
|
1584
1613
|
break;
|
|
1585
1614
|
case "up":
|
|
1586
|
-
a = t.top - e -
|
|
1615
|
+
a = t.top - e - 7;
|
|
1587
1616
|
break;
|
|
1588
1617
|
default:
|
|
1589
|
-
a = t.bottom
|
|
1618
|
+
a = t.bottom;
|
|
1590
1619
|
break;
|
|
1591
1620
|
}
|
|
1592
1621
|
return { top: Math.max(9, a), drops: i };
|
|
1593
1622
|
}
|
|
1594
1623
|
calculateHorizontalPosition(t, e) {
|
|
1595
1624
|
let a;
|
|
1625
|
+
if (!this.options.appendToBody) {
|
|
1626
|
+
switch (this.options.opens) {
|
|
1627
|
+
case "left":
|
|
1628
|
+
a = this.element.offsetWidth - e;
|
|
1629
|
+
break;
|
|
1630
|
+
case "center":
|
|
1631
|
+
a = (this.element.offsetWidth - e) / 2;
|
|
1632
|
+
break;
|
|
1633
|
+
default:
|
|
1634
|
+
a = 0;
|
|
1635
|
+
break;
|
|
1636
|
+
}
|
|
1637
|
+
return a;
|
|
1638
|
+
}
|
|
1596
1639
|
switch (this.options.opens) {
|
|
1597
1640
|
case "left":
|
|
1598
1641
|
a = t.right - e;
|
|
@@ -1611,8 +1654,14 @@ class E {
|
|
|
1611
1654
|
}
|
|
1612
1655
|
applyFinalPosition(t, e) {
|
|
1613
1656
|
this.container.style.top = `${t}px`, this.container.style.left = `${e}px`, this.container.style.right = "auto";
|
|
1614
|
-
|
|
1615
|
-
this.
|
|
1657
|
+
let a;
|
|
1658
|
+
if (this.options.zIndex !== "auto")
|
|
1659
|
+
a = this.options.zIndex;
|
|
1660
|
+
else {
|
|
1661
|
+
const i = this.getHighestZIndex(), o = 99999;
|
|
1662
|
+
a = i >= o ? i + 1 : o;
|
|
1663
|
+
}
|
|
1664
|
+
this.container.style.zIndex = a.toString(), this.updateInternalElementsZIndex(a);
|
|
1616
1665
|
}
|
|
1617
1666
|
updateInternalElementsZIndex(t) {
|
|
1618
1667
|
this.container.querySelectorAll("select").forEach((i) => {
|
|
@@ -1800,7 +1849,7 @@ class L {
|
|
|
1800
1849
|
return !this.options.maxDate || x(B(t), this.options.maxDate);
|
|
1801
1850
|
}
|
|
1802
1851
|
}
|
|
1803
|
-
class
|
|
1852
|
+
class F {
|
|
1804
1853
|
constructor(t = {}) {
|
|
1805
1854
|
this.validation = t;
|
|
1806
1855
|
}
|
|
@@ -1893,7 +1942,7 @@ class A {
|
|
|
1893
1942
|
return ((e = this.validation.holidays) == null ? void 0 : e.some((a) => this.isSameDate(a, t))) || !1;
|
|
1894
1943
|
}
|
|
1895
1944
|
}
|
|
1896
|
-
class
|
|
1945
|
+
class A {
|
|
1897
1946
|
constructor(t, e = {}) {
|
|
1898
1947
|
this.currentFocusedDate = null, this.isActive = !1, this.container = t, this.options = {
|
|
1899
1948
|
enabled: !1,
|
|
@@ -2113,7 +2162,7 @@ const P = {
|
|
|
2113
2162
|
"Diciembre"
|
|
2114
2163
|
],
|
|
2115
2164
|
firstDay: 1
|
|
2116
|
-
},
|
|
2165
|
+
}, R = {
|
|
2117
2166
|
format: "DD/MM/YYYY HH:mm",
|
|
2118
2167
|
separator: " - ",
|
|
2119
2168
|
applyLabel: "Aplicar",
|
|
@@ -2136,7 +2185,7 @@ const P = {
|
|
|
2136
2185
|
],
|
|
2137
2186
|
firstDay: 1
|
|
2138
2187
|
};
|
|
2139
|
-
class
|
|
2188
|
+
class O {
|
|
2140
2189
|
constructor(t, e = {}, a) {
|
|
2141
2190
|
this.element = this.resolveElement(t), this.options = this.mergeWithDefaults(e), this.locale = this.options.locale, this.callback = a || (() => {
|
|
2142
2191
|
}), this.eventService = new T(), this.initializeState(), this.initializeServices(), this.addDropdownArrow(), this.createContainer(), this.setupEventListeners(), this.updateElement(), this.calculateChosenLabel();
|
|
@@ -2179,7 +2228,9 @@ class R {
|
|
|
2179
2228
|
cancelButtonClasses: t.cancelButtonClasses || "datex-btn-danger",
|
|
2180
2229
|
theme: t.theme || M,
|
|
2181
2230
|
validation: t.validation || {},
|
|
2182
|
-
events: t.events || {}
|
|
2231
|
+
events: t.events || {},
|
|
2232
|
+
zIndex: t.zIndex ?? "auto",
|
|
2233
|
+
appendToBody: t.appendToBody ?? !0
|
|
2183
2234
|
};
|
|
2184
2235
|
return a.timePicker && a.autoApply && (a.autoApply = !1), a;
|
|
2185
2236
|
}
|
|
@@ -2204,8 +2255,9 @@ class R {
|
|
|
2204
2255
|
this.element.tagName === "INPUT" && this.element.classList.add("datex-input");
|
|
2205
2256
|
}
|
|
2206
2257
|
createContainer() {
|
|
2258
|
+
var a;
|
|
2207
2259
|
const t = this.buildContainerTemplate(), e = document.createElement("div");
|
|
2208
|
-
e.innerHTML = t.trim(), this.container = e.firstElementChild, document.body.appendChild(this.container), this.initializeContainerServices(), this.setupContainerClasses(), this.setupInitialVisibility();
|
|
2260
|
+
e.innerHTML = t.trim(), this.container = e.firstElementChild, this.options.appendToBody ? document.body.appendChild(this.container) : (a = this.element.parentElement) == null || a.appendChild(this.container), this.initializeContainerServices(), this.setupContainerClasses(), this.setupInitialVisibility();
|
|
2209
2261
|
}
|
|
2210
2262
|
buildContainerTemplate() {
|
|
2211
2263
|
return `
|
|
@@ -2250,7 +2302,7 @@ class R {
|
|
|
2250
2302
|
this.element,
|
|
2251
2303
|
this.container,
|
|
2252
2304
|
this.options
|
|
2253
|
-
), this.validationService = new
|
|
2305
|
+
), this.validationService = new F(this.options.validation), this.keyboardService = new A(this.container, {
|
|
2254
2306
|
enabled: !1
|
|
2255
2307
|
// Deshabilitado por defecto para evitar conflictos
|
|
2256
2308
|
}), this.keyboardService.setHandlers({
|
|
@@ -2885,10 +2937,10 @@ class R {
|
|
|
2885
2937
|
export {
|
|
2886
2938
|
z as BOOTSTRAP_THEME,
|
|
2887
2939
|
M as DEFAULT_THEME,
|
|
2888
|
-
|
|
2940
|
+
O as Datex,
|
|
2889
2941
|
Y as MATERIAL_THEME,
|
|
2890
2942
|
P as SPANISH_LOCALE,
|
|
2891
|
-
|
|
2943
|
+
R as SPANISH_LOCALE_WITH_TIME,
|
|
2892
2944
|
g as addMonths,
|
|
2893
2945
|
S as endOfDay,
|
|
2894
2946
|
D as formatDate,
|
|
@@ -71,6 +71,8 @@ export interface DatexOptions {
|
|
|
71
71
|
theme?: DatexTheme;
|
|
72
72
|
validation?: DatexValidation;
|
|
73
73
|
events?: DatexEvents;
|
|
74
|
+
zIndex?: number | "auto";
|
|
75
|
+
appendToBody?: boolean;
|
|
74
76
|
}
|
|
75
77
|
export type DatexCallback = (startDate: Date, endDate: Date, label?: string) => void;
|
|
76
78
|
export interface CalendarState {
|
package/package.json
CHANGED