datex-ui 1.2.1 → 1.2.2

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();
@@ -1473,7 +1473,7 @@ class T {
1473
1473
  `;
1474
1474
  }
1475
1475
  }
1476
- class F {
1476
+ class T {
1477
1477
  constructor() {
1478
1478
  this.boundHandlers = /* @__PURE__ */ new Map();
1479
1479
  }
@@ -1525,6 +1525,17 @@ class E {
1525
1525
  this.orientationChangeHandler
1526
1526
  ), window.removeEventListener("resize", this.orientationChangeHandler));
1527
1527
  }
1528
+ /**
1529
+ * Recalculates and updates z-index when DOM changes (e.g., new modals opened)
1530
+ */
1531
+ updateZIndex() {
1532
+ if (!this.container) return;
1533
+ const t = this.getHighestZIndex(), e = parseInt(this.container.style.zIndex || "0");
1534
+ if (t >= e) {
1535
+ const a = t + 1;
1536
+ this.container.style.zIndex = a.toString(), this.updateInternalElementsZIndex(a);
1537
+ }
1538
+ }
1528
1539
  calculatePosition() {
1529
1540
  if (!this.container) return;
1530
1541
  this.isMobileDevice() ? this.positionForMobile() : this.positionForDesktop();
@@ -1537,8 +1548,8 @@ class E {
1537
1548
  }
1538
1549
  positionForMobile() {
1539
1550
  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());
1551
+ const t = this.getHighestZIndex(), e = 999999, a = t >= e ? t + 1 : e;
1552
+ this.container.style.zIndex = a.toString(), this.updateInternalElementsZIndex(a);
1542
1553
  }
1543
1554
  getHighestZIndex() {
1544
1555
  const t = document.querySelectorAll("*");
@@ -1598,7 +1609,16 @@ class E {
1598
1609
  t === "up" ? this.container.classList.add("drop-up") : this.container.classList.remove("drop-up");
1599
1610
  }
1600
1611
  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";
1612
+ this.container.style.top = `${t}px`, this.container.style.left = `${e}px`, this.container.style.right = "auto";
1613
+ const a = this.getHighestZIndex(), i = 99999, o = a >= i ? a + 1 : i;
1614
+ this.container.style.zIndex = o.toString(), this.updateInternalElementsZIndex(o);
1615
+ }
1616
+ updateInternalElementsZIndex(t) {
1617
+ this.container.querySelectorAll("select").forEach((i) => {
1618
+ i.style.zIndex = (t + 1).toString();
1619
+ }), this.container.querySelectorAll(".keyboard-focused").forEach((i) => {
1620
+ i.style.zIndex = (t + 2).toString();
1621
+ });
1602
1622
  }
1603
1623
  showMobileHeader() {
1604
1624
  const t = this.container.querySelector(
@@ -1618,7 +1638,7 @@ class L {
1618
1638
  this.options = t, this.locale = e;
1619
1639
  }
1620
1640
  buildCalendarMatrix(t) {
1621
- const e = w(t), a = H(e, this.locale.firstDay), i = [];
1641
+ const e = w(t), a = I(e, this.locale.firstDay), i = [];
1622
1642
  let o = [];
1623
1643
  const n = new Date(a);
1624
1644
  for (let r = 0; r < 42; r++) {
@@ -1872,7 +1892,7 @@ class A {
1872
1892
  return ((e = this.validation.holidays) == null ? void 0 : e.some((a) => this.isSameDate(a, t))) || !1;
1873
1893
  }
1874
1894
  }
1875
- class P {
1895
+ class F {
1876
1896
  constructor(t, e = {}) {
1877
1897
  this.currentFocusedDate = null, this.isActive = !1, this.container = t, this.options = {
1878
1898
  enabled: !1,
@@ -2070,7 +2090,7 @@ class P {
2070
2090
  t && t.remove();
2071
2091
  }
2072
2092
  }
2073
- const I = {
2093
+ const P = {
2074
2094
  format: "DD/MM/YYYY",
2075
2095
  separator: " - ",
2076
2096
  applyLabel: "Aplicar",
@@ -2092,7 +2112,7 @@ const I = {
2092
2112
  "Diciembre"
2093
2113
  ],
2094
2114
  firstDay: 1
2095
- }, R = {
2115
+ }, O = {
2096
2116
  format: "DD/MM/YYYY HH:mm",
2097
2117
  separator: " - ",
2098
2118
  applyLabel: "Aplicar",
@@ -2118,7 +2138,7 @@ const I = {
2118
2138
  class N {
2119
2139
  constructor(t, e = {}, a) {
2120
2140
  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();
2141
+ }), this.eventService = new T(), this.initializeState(), this.initializeServices(), this.addDropdownArrow(), this.createContainer(), this.setupEventListeners(), this.updateElement(), this.calculateChosenLabel();
2122
2142
  }
2123
2143
  resolveElement(t) {
2124
2144
  if (typeof t == "string") {
@@ -2152,7 +2172,7 @@ class N {
2152
2172
  ranges: t.ranges || {},
2153
2173
  opens: t.opens || "center",
2154
2174
  drops: t.drops || "auto",
2155
- locale: t.locale || I,
2175
+ locale: t.locale || P,
2156
2176
  buttonClasses: t.buttonClasses || "datex-btn datex-btn-sm",
2157
2177
  applyButtonClasses: t.applyButtonClasses || "datex-btn-success",
2158
2178
  cancelButtonClasses: t.cancelButtonClasses || "datex-btn-danger",
@@ -2225,11 +2245,11 @@ class N {
2225
2245
  `;
2226
2246
  }
2227
2247
  initializeContainerServices() {
2228
- this.themeService = new T(this.container, this.options.theme), this.positionService = new E(
2248
+ this.themeService = new H(this.container, this.options.theme), this.positionService = new E(
2229
2249
  this.element,
2230
2250
  this.container,
2231
2251
  this.options
2232
- ), this.validationService = new A(this.options.validation), this.keyboardService = new P(this.container, {
2252
+ ), this.validationService = new A(this.options.validation), this.keyboardService = new F(this.container, {
2233
2253
  enabled: !1
2234
2254
  // Deshabilitado por defecto para evitar conflictos
2235
2255
  }), this.keyboardService.setHandlers({
@@ -2261,10 +2281,10 @@ class N {
2261
2281
  }
2262
2282
  // Public API methods
2263
2283
  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());
2284
+ 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
2285
  }
2266
2286
  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());
2287
+ 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
2288
  }
2269
2289
  toggle() {
2270
2290
  this.state.isShowing ? this.hide() : this.show();
@@ -2411,9 +2431,36 @@ class N {
2411
2431
  dispatchHideEvent() {
2412
2432
  this.eventService.dispatchEvent(this.element, "hide.daterangepicker", this);
2413
2433
  }
2434
+ setupDOMObserver() {
2435
+ this.domObserver = new MutationObserver((t) => {
2436
+ let e = !1;
2437
+ t.forEach((a) => {
2438
+ a.type === "childList" && a.addedNodes.forEach((i) => {
2439
+ if (i.nodeType === Node.ELEMENT_NODE) {
2440
+ const o = i;
2441
+ this.hasHighZIndex(o) && (e = !0);
2442
+ }
2443
+ });
2444
+ }), e && setTimeout(() => {
2445
+ this.state.isShowing && this.positionService && this.positionService.updateZIndex();
2446
+ }, 10);
2447
+ }), this.domObserver.observe(document.body, {
2448
+ childList: !0,
2449
+ subtree: !0
2450
+ });
2451
+ }
2452
+ removeDOMObserver() {
2453
+ this.domObserver && (this.domObserver.disconnect(), this.domObserver = void 0);
2454
+ }
2455
+ hasHighZIndex(t) {
2456
+ const e = window.getComputedStyle(t), a = parseInt(e.zIndex);
2457
+ return !isNaN(a) && a > 1e3 ? !0 : ["modal", "dialog", "popup", "overlay", "dropdown"].some(
2458
+ (o) => t.classList.contains(o) || t.className.toLowerCase().includes(o)
2459
+ );
2460
+ }
2414
2461
  cleanup() {
2415
2462
  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");
2463
+ 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
2464
  }
2418
2465
  handleKeyboardDateSelect(t) {
2419
2466
  const e = this.validationService.validateDate(t);
@@ -2835,12 +2882,12 @@ class N {
2835
2882
  }
2836
2883
  }
2837
2884
  export {
2838
- Y as BOOTSTRAP_THEME,
2885
+ z as BOOTSTRAP_THEME,
2839
2886
  M as DEFAULT_THEME,
2840
2887
  N as Datex,
2841
- z as MATERIAL_THEME,
2842
- I as SPANISH_LOCALE,
2843
- R as SPANISH_LOCALE_WITH_TIME,
2888
+ Y as MATERIAL_THEME,
2889
+ P as SPANISH_LOCALE,
2890
+ O as SPANISH_LOCALE_WITH_TIME,
2844
2891
  g as addMonths,
2845
2892
  S as endOfDay,
2846
2893
  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.2",
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",