datex-ui 1.2.5 → 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 CHANGED
@@ -64,10 +64,10 @@ function f(l, t) {
64
64
  function w(l) {
65
65
  return new Date(l.getFullYear(), l.getMonth(), 1);
66
66
  }
67
- function I(l) {
67
+ function B(l) {
68
68
  return new Date(l.getFullYear(), l.getMonth() + 1, 0);
69
69
  }
70
- function B(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
  }
@@ -1587,10 +1587,26 @@ class E {
1587
1587
  this.applyDropUpClass(o), this.applyFinalPosition(i, n);
1588
1588
  }
1589
1589
  resetContainerPosition() {
1590
- 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");
1591
1591
  }
1592
1592
  calculateVerticalPosition(t, e) {
1593
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
+ }
1594
1610
  switch (i) {
1595
1611
  case "auto":
1596
1612
  a = t.bottom, a + e >= window.innerHeight && (a = t.top - e - 7, i = "up");
@@ -1606,6 +1622,20 @@ class E {
1606
1622
  }
1607
1623
  calculateHorizontalPosition(t, e) {
1608
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
+ }
1609
1639
  switch (this.options.opens) {
1610
1640
  case "left":
1611
1641
  a = t.right - e;
@@ -1658,7 +1688,7 @@ class L {
1658
1688
  this.options = t, this.locale = e;
1659
1689
  }
1660
1690
  buildCalendarMatrix(t) {
1661
- const e = w(t), a = B(e, this.locale.firstDay), i = [];
1691
+ const e = w(t), a = I(e, this.locale.firstDay), i = [];
1662
1692
  let o = [];
1663
1693
  const n = new Date(a);
1664
1694
  for (let r = 0; r < 42; r++) {
@@ -1816,7 +1846,7 @@ class L {
1816
1846
  return !this.options.minDate || y(w(t), this.options.minDate);
1817
1847
  }
1818
1848
  canNavigateNext(t) {
1819
- return !this.options.maxDate || x(I(t), this.options.maxDate);
1849
+ return !this.options.maxDate || x(B(t), this.options.maxDate);
1820
1850
  }
1821
1851
  }
1822
1852
  class F {
@@ -2132,7 +2162,7 @@ const P = {
2132
2162
  "Diciembre"
2133
2163
  ],
2134
2164
  firstDay: 1
2135
- }, O = {
2165
+ }, R = {
2136
2166
  format: "DD/MM/YYYY HH:mm",
2137
2167
  separator: " - ",
2138
2168
  applyLabel: "Aplicar",
@@ -2155,7 +2185,7 @@ const P = {
2155
2185
  ],
2156
2186
  firstDay: 1
2157
2187
  };
2158
- class R {
2188
+ class O {
2159
2189
  constructor(t, e = {}, a) {
2160
2190
  this.element = this.resolveElement(t), this.options = this.mergeWithDefaults(e), this.locale = this.options.locale, this.callback = a || (() => {
2161
2191
  }), this.eventService = new T(), this.initializeState(), this.initializeServices(), this.addDropdownArrow(), this.createContainer(), this.setupEventListeners(), this.updateElement(), this.calculateChosenLabel();
@@ -2199,7 +2229,8 @@ class R {
2199
2229
  theme: t.theme || M,
2200
2230
  validation: t.validation || {},
2201
2231
  events: t.events || {},
2202
- zIndex: t.zIndex ?? "auto"
2232
+ zIndex: t.zIndex ?? "auto",
2233
+ appendToBody: t.appendToBody ?? !0
2203
2234
  };
2204
2235
  return a.timePicker && a.autoApply && (a.autoApply = !1), a;
2205
2236
  }
@@ -2224,8 +2255,9 @@ class R {
2224
2255
  this.element.tagName === "INPUT" && this.element.classList.add("datex-input");
2225
2256
  }
2226
2257
  createContainer() {
2258
+ var a;
2227
2259
  const t = this.buildContainerTemplate(), e = document.createElement("div");
2228
- 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();
2229
2261
  }
2230
2262
  buildContainerTemplate() {
2231
2263
  return `
@@ -2905,10 +2937,10 @@ class R {
2905
2937
  export {
2906
2938
  z as BOOTSTRAP_THEME,
2907
2939
  M as DEFAULT_THEME,
2908
- R as Datex,
2940
+ O as Datex,
2909
2941
  Y as MATERIAL_THEME,
2910
2942
  P as SPANISH_LOCALE,
2911
- O as SPANISH_LOCALE_WITH_TIME,
2943
+ R as SPANISH_LOCALE_WITH_TIME,
2912
2944
  g as addMonths,
2913
2945
  S as endOfDay,
2914
2946
  D as formatDate,
@@ -72,6 +72,7 @@ export interface DatexOptions {
72
72
  validation?: DatexValidation;
73
73
  events?: DatexEvents;
74
74
  zIndex?: number | "auto";
75
+ appendToBody?: boolean;
75
76
  }
76
77
  export type DatexCallback = (startDate: Date, endDate: Date, label?: string) => void;
77
78
  export interface CalendarState {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "datex-ui",
3
3
  "access": "public",
4
- "version": "1.2.5",
4
+ "version": "1.2.6",
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",