datex-ui 1.1.11 → 1.2.0

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
@@ -48,6 +48,11 @@ export declare class Datex {
48
48
  enableKeyboardNavigation(): void;
49
49
  disableKeyboardNavigation(): void;
50
50
  setKeyboardFocusedDate(date: Date): void;
51
+ updateOptions(newOptions: Partial<DatexOptions>): void;
52
+ private reinitializeServices;
53
+ private updateContainerConfiguration;
54
+ private updateButtonLabels;
55
+ getOptions(): Required<DatexOptions>;
51
56
  remove(): void;
52
57
  private storeOldValues;
53
58
  private setupDocumentListeners;
package/dist/index.esm.js CHANGED
@@ -64,10 +64,10 @@ function x(l, t) {
64
64
  function w(l) {
65
65
  return new Date(l.getFullYear(), l.getMonth(), 1);
66
66
  }
67
- function L(l) {
67
+ function H(l) {
68
68
  return new Date(l.getFullYear(), l.getMonth() + 1, 0);
69
69
  }
70
- function $(l, t = 1) {
70
+ function B(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
  }
@@ -120,7 +120,7 @@ const E = {
120
120
  fontSize: "14px",
121
121
  fontFamily: 'Roboto, "Helvetica Neue", Arial, sans-serif'
122
122
  };
123
- class H {
123
+ class A {
124
124
  constructor(t, e = E) {
125
125
  this.mode = "light", this.handleMediaChange = () => {
126
126
  this.mode === "auto" && this.applyTheme();
@@ -216,7 +216,7 @@ class H {
216
216
  color: ${t.textColor} !important;
217
217
  line-height: 1em !important;
218
218
  width: 278px !important;
219
- z-index: 3001 !important;
219
+ z-index: 999999 !important;
220
220
  }
221
221
 
222
222
  /* Base arrow styles - creates the dropdown arrow */
@@ -1289,7 +1289,7 @@ class T {
1289
1289
  t.dispatchEvent(i);
1290
1290
  }
1291
1291
  }
1292
- class A {
1292
+ class L {
1293
1293
  constructor(t, e, a) {
1294
1294
  this.element = t, this.container = e, this.options = a, this.setupOrientationHandler();
1295
1295
  }
@@ -1394,12 +1394,12 @@ class A {
1394
1394
  t && (t.style.display = "none");
1395
1395
  }
1396
1396
  }
1397
- class B {
1397
+ class M {
1398
1398
  constructor(t, e) {
1399
1399
  this.options = t, this.locale = e;
1400
1400
  }
1401
1401
  buildCalendarMatrix(t) {
1402
- const e = w(t), a = $(e, this.locale.firstDay), i = [];
1402
+ const e = w(t), a = B(e, this.locale.firstDay), i = [];
1403
1403
  let o = [];
1404
1404
  const s = new Date(a);
1405
1405
  for (let n = 0; n < 42; n++) {
@@ -1429,8 +1429,8 @@ class B {
1429
1429
  const r = a ? n : n === 0 ? 12 : n, d = String(r).padStart(2, "0"), c = a ? t.getHours() : t.getHours() % 12 || 12;
1430
1430
  let b = !1;
1431
1431
  if (this.options.minDate || this.options.maxDate) {
1432
- const f = new Date(t), M = a ? r : t.getHours() >= 12 ? r === 12 ? 12 : r + 12 : r === 12 ? 0 : r;
1433
- if (f.setHours(M), this.options.minDate) {
1432
+ const f = new Date(t), $ = a ? r : t.getHours() >= 12 ? r === 12 ? 12 : r + 12 : r === 12 ? 0 : r;
1433
+ if (f.setHours($), this.options.minDate) {
1434
1434
  const v = new Date(f);
1435
1435
  v.setMinutes(59), v < this.options.minDate && (b = !0);
1436
1436
  }
@@ -1557,7 +1557,7 @@ class B {
1557
1557
  return !this.options.minDate || y(w(t), this.options.minDate);
1558
1558
  }
1559
1559
  canNavigateNext(t) {
1560
- return !this.options.maxDate || u(L(t), this.options.maxDate);
1560
+ return !this.options.maxDate || u(H(t), this.options.maxDate);
1561
1561
  }
1562
1562
  }
1563
1563
  class F {
@@ -1903,7 +1903,7 @@ const P = {
1903
1903
  ],
1904
1904
  firstDay: 1
1905
1905
  };
1906
- class N {
1906
+ class V {
1907
1907
  constructor(t, e = {}, a) {
1908
1908
  this.element = this.resolveElement(t), this.options = this.mergeWithDefaults(e), this.locale = this.options.locale, this.callback = a || (() => {
1909
1909
  }), this.eventService = new T(), this.initializeState(), this.initializeServices(), this.addDropdownArrow(), this.createContainer(), this.setupEventListeners(), this.updateElement(), this.calculateChosenLabel();
@@ -1965,7 +1965,7 @@ class N {
1965
1965
  };
1966
1966
  }
1967
1967
  initializeServices() {
1968
- this.calendarService = new B(this.options, this.locale);
1968
+ this.calendarService = new M(this.options, this.locale);
1969
1969
  }
1970
1970
  addDropdownArrow() {
1971
1971
  this.element.tagName === "INPUT" && this.element.classList.add("datex-input");
@@ -2013,7 +2013,7 @@ class N {
2013
2013
  `;
2014
2014
  }
2015
2015
  initializeContainerServices() {
2016
- this.themeService = new H(this.container, this.options.theme), this.positionService = new A(
2016
+ this.themeService = new A(this.container, this.options.theme), this.positionService = new L(
2017
2017
  this.element,
2018
2018
  this.container,
2019
2019
  this.options
@@ -2099,6 +2099,36 @@ class N {
2099
2099
  setKeyboardFocusedDate(t) {
2100
2100
  this.keyboardService.setFocusedDate(t);
2101
2101
  }
2102
+ updateOptions(t) {
2103
+ const e = { ...this.options, ...t };
2104
+ this.options = this.mergeWithDefaults(e), t.locale && (this.locale = t.locale), this.reinitializeServices(), this.updateContainerConfiguration(), this.updateView(), this.state.isShowing && this.positionContainer();
2105
+ }
2106
+ reinitializeServices() {
2107
+ this.calendarService = new M(this.options, this.locale), this.validationService.updateValidation(this.options.validation), this.themeService.setTheme(this.options.theme), this.positionService = new L(
2108
+ this.element,
2109
+ this.container,
2110
+ this.options
2111
+ );
2112
+ }
2113
+ updateContainerConfiguration() {
2114
+ this.options.singleDatePicker ? this.container.classList.add("single") : this.container.classList.remove("single"), this.options.autoApply ? this.container.classList.add("auto-apply") : this.container.classList.remove("auto-apply"), this.container.classList.remove("opensleft", "opensright", "openscenter"), this.container.classList.add(`opens${this.options.opens}`), Object.keys(this.options.ranges).length > 0 ? (this.container.classList.add("show-ranges"), this.renderRanges()) : this.container.classList.remove("show-ranges"), (this.options.alwaysShowCalendars || Object.keys(this.options.ranges).length === 0) && this.container.classList.add("show-calendar"), this.options.autoApply || this.container.classList.add("show-calendar"), this.container.querySelectorAll(".calendar-time").forEach((e) => {
2115
+ e.style.display = this.options.timePicker ? "block" : "none";
2116
+ }), this.updateButtonLabels();
2117
+ }
2118
+ updateButtonLabels() {
2119
+ this.container.querySelectorAll(
2120
+ ".applyBtn, .mobile-applyBtn"
2121
+ ).forEach((a) => {
2122
+ a.textContent = this.locale.applyLabel;
2123
+ }), this.container.querySelectorAll(
2124
+ ".cancelBtn, .mobile-cancelBtn"
2125
+ ).forEach((a) => {
2126
+ a.textContent = this.locale.cancelLabel;
2127
+ });
2128
+ }
2129
+ getOptions() {
2130
+ return { ...this.options };
2131
+ }
2102
2132
  remove() {
2103
2133
  this.cleanup();
2104
2134
  }
@@ -2590,7 +2620,7 @@ class N {
2590
2620
  export {
2591
2621
  Y as BOOTSTRAP_THEME,
2592
2622
  E as DEFAULT_THEME,
2593
- N as Datex,
2623
+ V as Datex,
2594
2624
  z as MATERIAL_THEME,
2595
2625
  P as SPANISH_LOCALE,
2596
2626
  R as SPANISH_LOCALE_WITH_TIME,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "datex-ui",
3
3
  "access": "public",
4
- "version": "1.1.11",
4
+ "version": "1.2.0",
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",