@daracl/form 0.0.3 → 0.0.4

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.cjs CHANGED
@@ -2324,6 +2324,7 @@ var init_DateTimePicker = __esm({
2324
2324
  mode: "date",
2325
2325
  enableTodayBtn: true,
2326
2326
  showMonthAfterYear: false,
2327
+ isPositionFixed: false,
2327
2328
  format: "",
2328
2329
  zIndex: 1e3,
2329
2330
  minDate: "",
@@ -2672,14 +2673,21 @@ var init_DateTimePicker = __esm({
2672
2673
  const rect = this.targetElement.getBoundingClientRect();
2673
2674
  const scrollTop = window.scrollY || document.documentElement.scrollTop;
2674
2675
  const scrollLeft = window.scrollX || document.documentElement.scrollLeft;
2675
- const offsetTop = rect.top + scrollTop;
2676
- let top = offsetTop + this.targetElement.offsetHeight + 2;
2677
- const left = rect.left + scrollLeft;
2678
- if (top + this.datetimeElement.offsetHeight > docSize.clientHeight) {
2679
- const newTop = offsetTop - (this.datetimeElement.offsetHeight + 2);
2680
- top = newTop > 0 ? newTop : top;
2676
+ const elementHeight = this.datetimeElement.offsetHeight;
2677
+ const targetElementHeight = this.targetElement.offsetHeight + 2;
2678
+ let left = rect.left + scrollLeft;
2679
+ let top = 0;
2680
+ if (this.options.isPositionFixed) {
2681
+ top = rect.top + targetElementHeight;
2682
+ left = rect.left;
2683
+ } else {
2684
+ if (rect.top + targetElementHeight + elementHeight > docSize.clientHeight && rect.top >= elementHeight) {
2685
+ top = scrollTop + rect.top - elementHeight - 2;
2686
+ } else {
2687
+ top = scrollTop + rect.top + targetElementHeight;
2688
+ }
2681
2689
  }
2682
- this.datetimeElement.setAttribute("style", `top:${top}px;left:${left}px;z-index:${this.options.zIndex}`);
2690
+ this.datetimeElement.setAttribute("style", `${this.options.isPositionFixed ? "position:fixed;" : ""}top:${top}px;left:${left}px;z-index:${this.options.zIndex}`);
2683
2691
  document.addEventListener("click", this._documentClickEvent);
2684
2692
  }
2685
2693
  /**