@daracl/form 0.0.2 → 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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @daracl/form v0.0.2
2
+ * @daracl/form v0.0.4
3
3
  * Copyright 2023-2024 darainfo and other contributors;
4
4
  * Licensed MIT
5
5
  */
@@ -9,9 +9,9 @@
9
9
  else if(typeof define === 'function' && define.amd)
10
10
  define([], factory);
11
11
  else if(typeof exports === 'object')
12
- exports["DaraForm"] = factory();
12
+ exports["Daracl"] = factory();
13
13
  else
14
- root["DaraForm"] = factory();
14
+ root["Daracl"] = root["Daracl"] || {}, root["Daracl"]["form"] = factory();
15
15
  })(self, () => {
16
16
  return /******/ (() => { // webpackBootstrap
17
17
  /******/ "use strict";
@@ -718,6 +718,7 @@ var init_DateTimePicker = __esm({
718
718
  mode: "date" /* date */,
719
719
  enableTodayBtn: true,
720
720
  showMonthAfterYear: false,
721
+ isPositionFixed: false,
721
722
  format: "",
722
723
  zIndex: 1e3,
723
724
  minDate: "",
@@ -820,7 +821,7 @@ var init_DateTimePicker = __esm({
820
821
  this.initTimeEvent();
821
822
  }
822
823
  static {
823
- this.VERSION = `${"0.0.2"}`;
824
+ this.VERSION = `${"0.0.4"}`;
824
825
  }
825
826
  static {
826
827
  this.format = format_default;
@@ -1072,14 +1073,21 @@ var init_DateTimePicker = __esm({
1072
1073
  const rect = this.targetElement.getBoundingClientRect();
1073
1074
  const scrollTop = window.scrollY || document.documentElement.scrollTop;
1074
1075
  const scrollLeft = window.scrollX || document.documentElement.scrollLeft;
1075
- const offsetTop = rect.top + scrollTop;
1076
- let top = offsetTop + this.targetElement.offsetHeight + 2;
1077
- const left = rect.left + scrollLeft;
1078
- if (top + this.datetimeElement.offsetHeight > docSize.clientHeight) {
1079
- const newTop = offsetTop - (this.datetimeElement.offsetHeight + 2);
1080
- top = newTop > 0 ? newTop : top;
1076
+ const elementHeight = this.datetimeElement.offsetHeight;
1077
+ const targetElementHeight = this.targetElement.offsetHeight + 2;
1078
+ let left = rect.left + scrollLeft;
1079
+ let top = 0;
1080
+ if (this.options.isPositionFixed) {
1081
+ top = rect.top + targetElementHeight;
1082
+ left = rect.left;
1083
+ } else {
1084
+ if (rect.top + targetElementHeight + elementHeight > docSize.clientHeight && rect.top >= elementHeight) {
1085
+ top = scrollTop + rect.top - elementHeight - 2;
1086
+ } else {
1087
+ top = scrollTop + rect.top + targetElementHeight;
1088
+ }
1081
1089
  }
1082
- this.datetimeElement.setAttribute("style", `top:${top}px;left:${left}px;z-index:${this.options.zIndex}`);
1090
+ this.datetimeElement.setAttribute("style", `${this.options.isPositionFixed ? "position:fixed;" : ""}top:${top}px;left:${left}px;z-index:${this.options.zIndex}`);
1083
1091
  document.addEventListener("click", this._documentClickEvent);
1084
1092
  }
1085
1093
  /**
@@ -1816,7 +1824,7 @@ class DaraForm {
1816
1824
  return this.fieldInfoMap;
1817
1825
  }
1818
1826
  }
1819
- DaraForm.VERSION = `${"0.0.2"}`;
1827
+ DaraForm.VERSION = `${"0.0.4"}`;
1820
1828
  DaraForm.validator = {
1821
1829
  string: (value, field) => {
1822
1830
  return (0, stringValidator_1.stringValidator)(value, field);