datex-ui 1.2.1 → 1.2.3

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/datex.d.ts CHANGED
@@ -14,6 +14,7 @@ export declare class Datex {
14
14
  private locale;
15
15
  private callback;
16
16
  private state;
17
+ private domObserver?;
17
18
  private themeService;
18
19
  private eventService;
19
20
  private positionService;
@@ -66,6 +67,9 @@ export declare class Datex {
66
67
  private roundToIncrement;
67
68
  private dispatchShowEvent;
68
69
  private dispatchHideEvent;
70
+ private setupDOMObserver;
71
+ private removeDOMObserver;
72
+ private hasHighZIndex;
69
73
  private cleanup;
70
74
  private handleKeyboardDateSelect;
71
75
  private handleKeyboardMonthChange;
package/dist/index.esm.js CHANGED
@@ -67,7 +67,7 @@ function w(l) {
67
67
  function B(l) {
68
68
  return new Date(l.getFullYear(), l.getMonth() + 1, 0);
69
69
  }
70
- function H(l, t = 1) {
70
+ function I(l, t = 1) {
71
71
  const a = (l.getDay() - t + 7) % 7, i = new Date(l);
72
72
  return i.setDate(l.getDate() - a), i;
73
73
  }
@@ -87,7 +87,7 @@ const M = {
87
87
  borderRadius: "4px",
88
88
  fontSize: "15px",
89
89
  fontFamily: "arial"
90
- }, Y = {
90
+ }, z = {
91
91
  primaryColor: "#0d6efd",
92
92
  secondaryColor: "#6c757d",
93
93
  backgroundColor: "#ffffff",
@@ -103,7 +103,7 @@ const M = {
103
103
  borderRadius: "6px",
104
104
  fontSize: "14px",
105
105
  fontFamily: 'system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'
106
- }, z = {
106
+ }, Y = {
107
107
  primaryColor: "#1976d2",
108
108
  secondaryColor: "#757575",
109
109
  backgroundColor: "#ffffff",
@@ -121,7 +121,7 @@ const M = {
121
121
  fontSize: "14px",
122
122
  fontFamily: 'Roboto, "Helvetica Neue", Arial, sans-serif'
123
123
  };
124
- class T {
124
+ class H {
125
125
  constructor(t, e = M) {
126
126
  this.mode = "light", this.handleMediaChange = () => {
127
127
  this.mode === "auto" && this.applyTheme();
@@ -432,7 +432,8 @@ class T {
432
432
  color: ${t.textColor} !important;
433
433
  line-height: 1em !important;
434
434
  width: 278px !important;
435
- z-index: 999999 !important;
435
+ z-index: 999999; /* Removed !important to allow JavaScript override */
436
+ margin-top:7px;
436
437
  }
437
438
 
438
439
  /* Base arrow styles - creates the dropdown arrow */
@@ -854,7 +855,7 @@ class T {
854
855
  min-height: 20px !important;
855
856
  min-width: 50px !important;
856
857
  position: relative !important;
857
- z-index: 1000000 !important;
858
+ z-index: 1000000; /* Removed !important to allow JavaScript override */
858
859
  transform: none !important;
859
860
  isolation: auto !important;
860
861
  }
@@ -946,7 +947,7 @@ class T {
946
947
  box-sizing: border-box !important;
947
948
  transform: none !important;
948
949
  overflow-x: hidden !important;
949
- z-index: 999999 !important;
950
+ z-index: 999999; /* Removed !important to allow JavaScript override */
950
951
  /* Fix for overlay issues */
951
952
  isolation: isolate !important;
952
953
  contain: layout style !important;
@@ -1191,7 +1192,7 @@ class T {
1191
1192
  .datex-picker select,
1192
1193
  .datex-picker.mobile-view select {
1193
1194
  position: relative !important;
1194
- z-index: 1000 !important;
1195
+ z-index: 1000; /* Removed !important to allow JavaScript override */
1195
1196
  background: ${t.backgroundColor} !important;
1196
1197
  border: 1px solid ${t.borderColor} !important;
1197
1198
  border-radius: 4px !important;
@@ -1473,7 +1474,7 @@ class T {
1473
1474
  `;
1474
1475
  }
1475
1476
  }
1476
- class F {
1477
+ class T {
1477
1478
  constructor() {
1478
1479
  this.boundHandlers = /* @__PURE__ */ new Map();
1479
1480
  }
@@ -1525,6 +1526,17 @@ class E {
1525
1526
  this.orientationChangeHandler
1526
1527
  ), window.removeEventListener("resize", this.orientationChangeHandler));
1527
1528
  }
1529
+ /**
1530
+ * Recalculates and updates z-index when DOM changes (e.g., new modals opened)
1531
+ */
1532
+ updateZIndex() {
1533
+ if (!this.container) return;
1534
+ const t = this.getHighestZIndex(), e = parseInt(this.container.style.zIndex || "0");
1535
+ if (t >= e) {
1536
+ const a = t + 1;
1537
+ this.container.style.zIndex = a.toString(), this.updateInternalElementsZIndex(a);
1538
+ }
1539
+ }
1528
1540
  calculatePosition() {
1529
1541
  if (!this.container) return;
1530
1542
  this.isMobileDevice() ? this.positionForMobile() : this.positionForDesktop();
@@ -1537,8 +1549,8 @@ class E {
1537
1549
  }
1538
1550
  positionForMobile() {
1539
1551
  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();
1540
- const t = this.getHighestZIndex();
1541
- t >= 999999 && (this.container.style.zIndex = (t + 1).toString());
1552
+ const t = this.getHighestZIndex(), e = 999999, a = t >= e ? t + 1 : e;
1553
+ this.container.style.zIndex = a.toString(), this.updateInternalElementsZIndex(a);
1542
1554
  }
1543
1555
  getHighestZIndex() {
1544
1556
  const t = document.querySelectorAll("*");
@@ -1598,7 +1610,16 @@ class E {
1598
1610
  t === "up" ? this.container.classList.add("drop-up") : this.container.classList.remove("drop-up");
1599
1611
  }
1600
1612
  applyFinalPosition(t, e) {
1601
- this.container.style.top = `${t}px`, this.container.style.left = `${e}px`, this.container.style.right = "auto", this.container.style.zIndex = "99999";
1613
+ this.container.style.top = `${t}px`, this.container.style.left = `${e}px`, this.container.style.right = "auto";
1614
+ const a = this.getHighestZIndex(), i = 99999, o = a >= i ? a + 1 : i;
1615
+ this.container.style.zIndex = o.toString(), this.updateInternalElementsZIndex(o);
1616
+ }
1617
+ updateInternalElementsZIndex(t) {
1618
+ this.container.querySelectorAll("select").forEach((i) => {
1619
+ i.style.zIndex = (t + 1).toString();
1620
+ }), this.container.querySelectorAll(".keyboard-focused").forEach((i) => {
1621
+ i.style.zIndex = (t + 2).toString();
1622
+ });
1602
1623
  }
1603
1624
  showMobileHeader() {
1604
1625
  const t = this.container.querySelector(
@@ -1618,7 +1639,7 @@ class L {
1618
1639
  this.options = t, this.locale = e;
1619
1640
  }
1620
1641
  buildCalendarMatrix(t) {
1621
- const e = w(t), a = H(e, this.locale.firstDay), i = [];
1642
+ const e = w(t), a = I(e, this.locale.firstDay), i = [];
1622
1643
  let o = [];
1623
1644
  const n = new Date(a);
1624
1645
  for (let r = 0; r < 42; r++) {
@@ -1872,7 +1893,7 @@ class A {
1872
1893
  return ((e = this.validation.holidays) == null ? void 0 : e.some((a) => this.isSameDate(a, t))) || !1;
1873
1894
  }
1874
1895
  }
1875
- class P {
1896
+ class F {
1876
1897
  constructor(t, e = {}) {
1877
1898
  this.currentFocusedDate = null, this.isActive = !1, this.container = t, this.options = {
1878
1899
  enabled: !1,
@@ -2070,7 +2091,7 @@ class P {
2070
2091
  t && t.remove();
2071
2092
  }
2072
2093
  }
2073
- const I = {
2094
+ const P = {
2074
2095
  format: "DD/MM/YYYY",
2075
2096
  separator: " - ",
2076
2097
  applyLabel: "Aplicar",
@@ -2092,7 +2113,7 @@ const I = {
2092
2113
  "Diciembre"
2093
2114
  ],
2094
2115
  firstDay: 1
2095
- }, R = {
2116
+ }, O = {
2096
2117
  format: "DD/MM/YYYY HH:mm",
2097
2118
  separator: " - ",
2098
2119
  applyLabel: "Aplicar",
@@ -2115,10 +2136,10 @@ const I = {
2115
2136
  ],
2116
2137
  firstDay: 1
2117
2138
  };
2118
- class N {
2139
+ class R {
2119
2140
  constructor(t, e = {}, a) {
2120
2141
  this.element = this.resolveElement(t), this.options = this.mergeWithDefaults(e), this.locale = this.options.locale, this.callback = a || (() => {
2121
- }), this.eventService = new F(), this.initializeState(), this.initializeServices(), this.addDropdownArrow(), this.createContainer(), this.setupEventListeners(), this.updateElement(), this.calculateChosenLabel();
2142
+ }), this.eventService = new T(), this.initializeState(), this.initializeServices(), this.addDropdownArrow(), this.createContainer(), this.setupEventListeners(), this.updateElement(), this.calculateChosenLabel();
2122
2143
  }
2123
2144
  resolveElement(t) {
2124
2145
  if (typeof t == "string") {
@@ -2152,7 +2173,7 @@ class N {
2152
2173
  ranges: t.ranges || {},
2153
2174
  opens: t.opens || "center",
2154
2175
  drops: t.drops || "auto",
2155
- locale: t.locale || I,
2176
+ locale: t.locale || P,
2156
2177
  buttonClasses: t.buttonClasses || "datex-btn datex-btn-sm",
2157
2178
  applyButtonClasses: t.applyButtonClasses || "datex-btn-success",
2158
2179
  cancelButtonClasses: t.cancelButtonClasses || "datex-btn-danger",
@@ -2225,11 +2246,11 @@ class N {
2225
2246
  `;
2226
2247
  }
2227
2248
  initializeContainerServices() {
2228
- this.themeService = new T(this.container, this.options.theme), this.positionService = new E(
2249
+ this.themeService = new H(this.container, this.options.theme), this.positionService = new E(
2229
2250
  this.element,
2230
2251
  this.container,
2231
2252
  this.options
2232
- ), this.validationService = new A(this.options.validation), this.keyboardService = new P(this.container, {
2253
+ ), this.validationService = new A(this.options.validation), this.keyboardService = new F(this.container, {
2233
2254
  enabled: !1
2234
2255
  // Deshabilitado por defecto para evitar conflictos
2235
2256
  }), this.keyboardService.setHandlers({
@@ -2261,10 +2282,10 @@ class N {
2261
2282
  }
2262
2283
  // Public API methods
2263
2284
  show() {
2264
- this.state.isShowing || (this.storeOldValues(), this.themeService.applyTheme(), this.setupDocumentListeners(), this.updateView(), this.displayContainer(), this.positionContainer(), this.element.tagName === "INPUT" && this.element.classList.add("datex-active"), this.dispatchShowEvent());
2285
+ this.state.isShowing || (this.storeOldValues(), this.themeService.applyTheme(), this.setupDocumentListeners(), this.setupDOMObserver(), this.updateView(), this.displayContainer(), this.positionContainer(), this.element.tagName === "INPUT" && this.element.classList.add("datex-active"), this.dispatchShowEvent());
2265
2286
  }
2266
2287
  hide() {
2267
- this.state.isShowing && (this.revertIfIncomplete(), this.triggerCallbackIfChanged(), this.updateElement(), this.removeDocumentListeners(), this.keyboardService.deactivate(), this.hideContainer(), this.element.tagName === "INPUT" && this.element.classList.remove("datex-active"), this.dispatchHideEvent());
2288
+ this.state.isShowing && (this.revertIfIncomplete(), this.triggerCallbackIfChanged(), this.updateElement(), this.removeDocumentListeners(), this.removeDOMObserver(), this.keyboardService.deactivate(), this.hideContainer(), this.element.tagName === "INPUT" && this.element.classList.remove("datex-active"), this.dispatchHideEvent());
2268
2289
  }
2269
2290
  toggle() {
2270
2291
  this.state.isShowing ? this.hide() : this.show();
@@ -2411,9 +2432,36 @@ class N {
2411
2432
  dispatchHideEvent() {
2412
2433
  this.eventService.dispatchEvent(this.element, "hide.daterangepicker", this);
2413
2434
  }
2435
+ setupDOMObserver() {
2436
+ this.domObserver = new MutationObserver((t) => {
2437
+ let e = !1;
2438
+ t.forEach((a) => {
2439
+ a.type === "childList" && a.addedNodes.forEach((i) => {
2440
+ if (i.nodeType === Node.ELEMENT_NODE) {
2441
+ const o = i;
2442
+ this.hasHighZIndex(o) && (e = !0);
2443
+ }
2444
+ });
2445
+ }), e && setTimeout(() => {
2446
+ this.state.isShowing && this.positionService && this.positionService.updateZIndex();
2447
+ }, 10);
2448
+ }), this.domObserver.observe(document.body, {
2449
+ childList: !0,
2450
+ subtree: !0
2451
+ });
2452
+ }
2453
+ removeDOMObserver() {
2454
+ this.domObserver && (this.domObserver.disconnect(), this.domObserver = void 0);
2455
+ }
2456
+ hasHighZIndex(t) {
2457
+ const e = window.getComputedStyle(t), a = parseInt(e.zIndex);
2458
+ return !isNaN(a) && a > 1e3 ? !0 : ["modal", "dialog", "popup", "overlay", "dropdown"].some(
2459
+ (o) => t.classList.contains(o) || t.className.toLowerCase().includes(o)
2460
+ );
2461
+ }
2414
2462
  cleanup() {
2415
2463
  var t;
2416
- this.removeDocumentListeners(), this.themeService.cleanup(), this.eventService.cleanup(), this.keyboardService.cleanup(), this.positionService.cleanup(), (t = this.container) != null && t.parentNode && this.container.parentNode.removeChild(this.container), this.element.tagName === "INPUT" && this.element.classList.remove("datex-input", "datex-active");
2464
+ this.removeDocumentListeners(), this.removeDOMObserver(), this.themeService.cleanup(), this.eventService.cleanup(), this.keyboardService.cleanup(), this.positionService.cleanup(), (t = this.container) != null && t.parentNode && this.container.parentNode.removeChild(this.container), this.element.tagName === "INPUT" && this.element.classList.remove("datex-input", "datex-active");
2417
2465
  }
2418
2466
  handleKeyboardDateSelect(t) {
2419
2467
  const e = this.validationService.validateDate(t);
@@ -2835,12 +2883,12 @@ class N {
2835
2883
  }
2836
2884
  }
2837
2885
  export {
2838
- Y as BOOTSTRAP_THEME,
2886
+ z as BOOTSTRAP_THEME,
2839
2887
  M as DEFAULT_THEME,
2840
- N as Datex,
2841
- z as MATERIAL_THEME,
2842
- I as SPANISH_LOCALE,
2843
- R as SPANISH_LOCALE_WITH_TIME,
2888
+ R as Datex,
2889
+ Y as MATERIAL_THEME,
2890
+ P as SPANISH_LOCALE,
2891
+ O as SPANISH_LOCALE_WITH_TIME,
2844
2892
  g as addMonths,
2845
2893
  S as endOfDay,
2846
2894
  D as formatDate,
@@ -10,6 +10,10 @@ export declare class PositionService {
10
10
  constructor(element: HTMLElement, container: HTMLElement, options: Required<DatexOptions>);
11
11
  private setupOrientationHandler;
12
12
  cleanup(): void;
13
+ /**
14
+ * Recalculates and updates z-index when DOM changes (e.g., new modals opened)
15
+ */
16
+ updateZIndex(): void;
13
17
  calculatePosition(): void;
14
18
  private isMobileDevice;
15
19
  private positionForMobile;
@@ -20,6 +24,7 @@ export declare class PositionService {
20
24
  private calculateHorizontalPosition;
21
25
  private applyDropUpClass;
22
26
  private applyFinalPosition;
27
+ private updateInternalElementsZIndex;
23
28
  private showMobileHeader;
24
29
  private hideMobileHeader;
25
30
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "datex-ui",
3
3
  "access": "public",
4
- "version": "1.2.1",
4
+ "version": "1.2.3",
5
5
  "type": "module",
6
6
  "description": "A modern, lightweight, and customizable date range picker for TypeScript/JavaScript applications",
7
7
  "main": "dist/index.esm.js",