ninemoon-ui 0.0.12 → 0.0.14

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,4 +1,5 @@
1
- export declare const throttle: (fn: Function, delay: number) => () => void;
1
+ export declare function debounce(func: Function, wait: number): () => void;
2
+ export declare function throttle(func: Function, wait: number): () => void;
2
3
  export declare const usePotion: (baseDom: HTMLElement, aimDom: HTMLElement, set?: {
3
4
  position: 'topleft' | 'topmiddle' | 'topright' | 'bottomleft' | 'bottommiddle' | 'bottomright' | 'centerleft' | 'centerright';
4
5
  divide?: number;
@@ -7,6 +8,7 @@ export declare const usePotion: (baseDom: HTMLElement, aimDom: HTMLElement, set?
7
8
  Left: number;
8
9
  arrowLeft: number;
9
10
  arrowTop: number;
11
+ exChange: boolean;
10
12
  };
11
13
  export declare function getNewArray(array: Array<any>, subGroupLength: number): any[][];
12
14
  export declare function getScrollWidth(): number;
@@ -40,5 +42,6 @@ export declare const on: (element: {
40
42
  export declare const off: (element: {
41
43
  removeEventListener: (arg0: any, arg1: any, arg2: boolean) => void;
42
44
  }, event: any, handler: any) => void;
45
+ export declare function createAndAppendElementWithId(id: string): void;
43
46
  declare const _default: {};
44
47
  export default _default;
package/dist/index.css CHANGED
@@ -807,9 +807,9 @@
807
807
  content: var(--tw-content);
808
808
  position: absolute;
809
809
  }
810
- .before\:tdd-box-border::before {
810
+ .before\:tdd-z-\[-1\]::before {
811
811
  content: var(--tw-content);
812
- box-sizing: border-box;
812
+ z-index: -1;
813
813
  }
814
814
  .before\:tdd-h-2::before {
815
815
  content: var(--tw-content);
@@ -831,6 +831,31 @@
831
831
  content: var(--tw-content);
832
832
  --tw-rotate: 45deg;
833
833
  transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
834
+ }
835
+ .before\:tdd-rounded-bl::before {
836
+ content: var(--tw-content);
837
+ border-bottom-left-radius: 0.25rem;
838
+ }
839
+ .before\:tdd-rounded-br::before {
840
+ content: var(--tw-content);
841
+ border-bottom-right-radius: 0.25rem;
842
+ }
843
+ .before\:tdd-rounded-tl::before {
844
+ content: var(--tw-content);
845
+ border-top-left-radius: 0.25rem;
846
+ }
847
+ .before\:tdd-rounded-tr::before {
848
+ content: var(--tw-content);
849
+ border-top-right-radius: 0.25rem;
850
+ }
851
+ .before\:tdd-border::before {
852
+ content: var(--tw-content);
853
+ border-width: 1px;
854
+ }
855
+ .before\:tdd-border-gray-300::before {
856
+ content: var(--tw-content);
857
+ --tw-border-opacity: 1;
858
+ border-color: rgb(209 213 219 / var(--tw-border-opacity));
834
859
  }
835
860
  .before\:tdd-border-b-transparent::before {
836
861
  content: var(--tw-content);
@@ -852,10 +877,6 @@
852
877
  content: var(--tw-content);
853
878
  --tw-bg-opacity: 1;
854
879
  background-color: rgb(255 255 255 / var(--tw-bg-opacity));
855
- }
856
- .before\:tdd-content-\[\'\'\]::before {
857
- --tw-content: '';
858
- content: var(--tw-content);
859
880
  }
860
881
  .checked\:tdd-border-transparent:checked {
861
882
  border-color: transparent;
package/dist/index.es.js CHANGED
@@ -1,37 +1,37 @@
1
1
  import "vue";
2
- import { G, v, J, K, B, A, n, p, L, d, e, m, f, H, q, M, x, s, w, y, z, F, I, h, j, N, k, l, D, E, O, C, i } from "./js/index/index.js";
2
+ import { I, x, N, O, D, C, q, s, L, f, h, p, j, J, v, M, z, w, y, A, B, H, K, k, l, P, m, n, F, G, Q, E, i } from "./js/index/index.js";
3
3
  export {
4
- G as LibAlert,
5
- v as LibBadge,
6
- J as LibCarousel,
7
- K as LibCarouselItem,
8
- B as LibCheckBox,
9
- A as LibCheckGroup,
10
- n as LibDatePicker,
11
- p as LibDatePickerRange,
4
+ I as LibAlert,
5
+ x as LibBadge,
6
+ N as LibCarousel,
7
+ O as LibCarouselItem,
8
+ D as LibCheckBox,
9
+ C as LibCheckGroup,
10
+ q as LibDatePicker,
11
+ s as LibDatePickerRange,
12
12
  L as LibDialog,
13
- d as LibForm,
14
- e as LibFormLabel,
15
- m as LibImage,
16
- f as LibInput,
17
- H as LibLoad,
18
- q as LibMenu,
13
+ f as LibForm,
14
+ h as LibFormLabel,
15
+ p as LibImage,
16
+ j as LibInput,
17
+ J as LibLoad,
18
+ v as LibMenu,
19
19
  M as LibMessage,
20
- x as LibNumberInput,
21
- s as LibPagination,
22
- w as LibPopover,
23
- y as LibRadioBox,
24
- z as LibRadioGroup,
25
- F as LibScrollBar,
26
- I as LibScrollLoad,
27
- h as LibSelect,
28
- j as LibSelectOption,
29
- N as LibSwitch,
30
- k as LibTable,
31
- l as LibTableItem,
32
- D as LibTabs,
33
- E as LibTabsPane,
34
- O as LibTree,
35
- C as LibUpload,
20
+ z as LibNumberInput,
21
+ w as LibPagination,
22
+ y as LibPopover,
23
+ A as LibRadioBox,
24
+ B as LibRadioGroup,
25
+ H as LibScrollBar,
26
+ K as LibScrollLoad,
27
+ k as LibSelect,
28
+ l as LibSelectOption,
29
+ P as LibSwitch,
30
+ m as LibTable,
31
+ n as LibTableItem,
32
+ F as LibTabs,
33
+ G as LibTabsPane,
34
+ Q as LibTree,
35
+ E as LibUpload,
36
36
  i as default
37
37
  };
package/dist/index.umd.js CHANGED
@@ -812,9 +812,9 @@
812
812
  content: var(--tw-content);
813
813
  position: absolute;
814
814
  }
815
- .before\\:tdd-box-border::before {
815
+ .before\\:tdd-z-\\[-1\\]::before {
816
816
  content: var(--tw-content);
817
- box-sizing: border-box;
817
+ z-index: -1;
818
818
  }
819
819
  .before\\:tdd-h-2::before {
820
820
  content: var(--tw-content);
@@ -836,6 +836,31 @@
836
836
  content: var(--tw-content);
837
837
  --tw-rotate: 45deg;
838
838
  transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
839
+ }
840
+ .before\\:tdd-rounded-bl::before {
841
+ content: var(--tw-content);
842
+ border-bottom-left-radius: 0.25rem;
843
+ }
844
+ .before\\:tdd-rounded-br::before {
845
+ content: var(--tw-content);
846
+ border-bottom-right-radius: 0.25rem;
847
+ }
848
+ .before\\:tdd-rounded-tl::before {
849
+ content: var(--tw-content);
850
+ border-top-left-radius: 0.25rem;
851
+ }
852
+ .before\\:tdd-rounded-tr::before {
853
+ content: var(--tw-content);
854
+ border-top-right-radius: 0.25rem;
855
+ }
856
+ .before\\:tdd-border::before {
857
+ content: var(--tw-content);
858
+ border-width: 1px;
859
+ }
860
+ .before\\:tdd-border-gray-300::before {
861
+ content: var(--tw-content);
862
+ --tw-border-opacity: 1;
863
+ border-color: rgb(209 213 219 / var(--tw-border-opacity));
839
864
  }
840
865
  .before\\:tdd-border-b-transparent::before {
841
866
  content: var(--tw-content);
@@ -857,10 +882,6 @@
857
882
  content: var(--tw-content);
858
883
  --tw-bg-opacity: 1;
859
884
  background-color: rgb(255 255 255 / var(--tw-bg-opacity));
860
- }
861
- .before\\:tdd-content-\\[\\'\\'\\]::before {
862
- --tw-content: '';
863
- content: var(--tw-content);
864
885
  }
865
886
  .checked\\:tdd-border-transparent:checked {
866
887
  border-color: transparent;
@@ -1784,33 +1805,47 @@
1784
1805
  el.removeChild(el.instance.$el);
1785
1806
  }
1786
1807
  };
1787
- const throttle = (fn, delay) => {
1788
- let flag = true;
1808
+ function debounce(func, wait) {
1809
+ let timeout;
1789
1810
  return function() {
1790
- if (flag) {
1791
- setTimeout(() => {
1792
- fn.apply(this, arguments);
1793
- flag = true;
1794
- }, delay);
1811
+ const context = this;
1812
+ const args = arguments;
1813
+ clearTimeout(timeout);
1814
+ timeout = setTimeout(function() {
1815
+ func.apply(context, args);
1816
+ }, wait);
1817
+ };
1818
+ }
1819
+ function throttle(func, wait) {
1820
+ let timeout;
1821
+ return function() {
1822
+ const context = this;
1823
+ const args = arguments;
1824
+ if (!timeout) {
1825
+ timeout = setTimeout(function() {
1826
+ timeout = null;
1827
+ func.apply(context, args);
1828
+ }, wait);
1795
1829
  }
1796
- flag = false;
1797
1830
  };
1798
- };
1831
+ }
1799
1832
  const usePotion = (baseDom, aimDom, set) => {
1800
1833
  let left = 0;
1801
1834
  let top = 0;
1802
1835
  let arrowleft = 0;
1803
1836
  let arrowtop = 0;
1837
+ let exchange = false;
1804
1838
  if (!baseDom || !aimDom) {
1805
1839
  return {
1806
1840
  Top: top,
1807
1841
  Left: left,
1808
1842
  arrowLeft: arrowleft,
1809
- arrowTop: arrowtop
1843
+ arrowTop: arrowtop,
1844
+ exChange: exchange
1810
1845
  };
1811
1846
  }
1812
- const { left: baseLeft, right, bottom, top: baseTop, width: baseWidth } = baseDom.getBoundingClientRect();
1813
- const { height: aimHeight, width: aimWidth } = aimDom.getBoundingClientRect();
1847
+ const { left: baseLeft, right, bottom, top: baseTop, width: baseWidth, height: baseHeight } = baseDom.getBoundingClientRect();
1848
+ const { height: aimHeight, width: aimWidth, top: aimTop } = aimDom.getBoundingClientRect();
1814
1849
  const scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
1815
1850
  const scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
1816
1851
  switch (set == null ? void 0 : set.position) {
@@ -1818,17 +1853,15 @@
1818
1853
  case "bottommiddle":
1819
1854
  case "bottomright":
1820
1855
  top = scrollTop + bottom;
1821
- arrowtop = -5;
1822
1856
  break;
1823
1857
  case "topleft":
1824
1858
  case "topmiddle":
1825
1859
  case "topright":
1826
1860
  top = scrollTop + baseTop - aimHeight;
1827
- arrowtop = aimHeight - 5;
1828
1861
  break;
1829
1862
  case "centerleft":
1830
1863
  case "centerright":
1831
- top = scrollTop + baseTop + (bottom - baseTop - aimHeight) / 2;
1864
+ top = scrollTop + baseTop + (baseHeight - aimHeight) / 2;
1832
1865
  arrowtop = aimHeight / 2 - 5;
1833
1866
  break;
1834
1867
  }
@@ -1857,20 +1890,42 @@
1857
1890
  arrowleft = -5;
1858
1891
  break;
1859
1892
  }
1860
- if (top + aimHeight > window.innerHeight) {
1861
- top = scrollTop + window.innerHeight - aimHeight - 10;
1862
- }
1863
- if (top < 0) {
1864
- top = 10;
1893
+ if (top + aimHeight + 10 > scrollTop + window.innerHeight) {
1894
+ switch (set == null ? void 0 : set.position) {
1895
+ case "bottommiddle":
1896
+ case "bottomleft":
1897
+ case "bottomright":
1898
+ exchange = true;
1899
+ top = scrollTop + baseTop - aimHeight - 24;
1900
+ break;
1901
+ case "centerleft":
1902
+ case "centerright":
1903
+ top = scrollTop + window.innerHeight - aimHeight - 10;
1904
+ arrowtop = baseTop - aimTop + baseHeight / 2 - 10;
1905
+ break;
1906
+ }
1865
1907
  }
1866
- if (left + aimWidth > window.innerWidth) {
1867
- left = scrollLeft + right - aimWidth;
1908
+ if (top - scrollTop < 0) {
1909
+ switch (set == null ? void 0 : set.position) {
1910
+ case "topmiddle":
1911
+ case "topleft":
1912
+ case "topright":
1913
+ exchange = true;
1914
+ top = scrollTop + bottom + 24;
1915
+ break;
1916
+ case "centerleft":
1917
+ case "centerright":
1918
+ top = 10 + scrollTop;
1919
+ arrowtop = baseTop + baseHeight / 2 - 10;
1920
+ break;
1921
+ }
1868
1922
  }
1869
1923
  return {
1870
1924
  Top: top,
1871
1925
  Left: left,
1872
1926
  arrowLeft: arrowleft,
1873
- arrowTop: arrowtop
1927
+ arrowTop: arrowtop,
1928
+ exChange: exchange
1874
1929
  };
1875
1930
  };
1876
1931
  function getNewArray(array, subGroupLength) {
@@ -1940,6 +1995,13 @@
1940
1995
  }
1941
1996
  };
1942
1997
  }();
1998
+ function createAndAppendElementWithId(id) {
1999
+ if (!document.getElementById(id)) {
2000
+ const element = document.createElement("div");
2001
+ element.id = id;
2002
+ document.body.appendChild(element);
2003
+ }
2004
+ }
1943
2005
  const scrolllead = {
1944
2006
  beforeMount(el, binding) {
1945
2007
  function scrollhandle(e) {
@@ -4522,9 +4584,12 @@
4522
4584
  emits: ["update:modelValue"],
4523
4585
  setup(__props, { expose: __expose, emit: emitAct }) {
4524
4586
  const props = __props;
4587
+ const bindName = vue.ref("body");
4525
4588
  const base = vue.ref();
4526
4589
  const pop = vue.ref();
4527
4590
  const showPop = vue.ref(false);
4591
+ createAndAppendElementWithId("tdd-pop");
4592
+ bindName.value = "#tdd-pop";
4528
4593
  const trueFlag = vue.computed(() => {
4529
4594
  if (showPop.value || props.trigger === "native" && props.modelValue) {
4530
4595
  vue.nextTick(() => {
@@ -4562,22 +4627,41 @@
4562
4627
  }
4563
4628
  return margin;
4564
4629
  });
4630
+ const styleConditions = {
4631
+ left: (placement) => ["topleft", "topmiddle", "topright", "bottomleft", "bottommiddle", "bottomright"].includes(placement) ? `${arrowLeft.value}px` : "centerright" == placement ? "-5px" : null,
4632
+ right: (placement) => "centerleft" == placement ? "-5px" : null,
4633
+ top: (placement, exChange2) => ["bottomleft", "bottommiddle", "bottomright"].includes(placement) && !exChange2 ? "-5px" : ["topleft", "topmiddle", "topright"].includes(placement) && exChange2 ? "-5px" : ["centerright", "centerleft"].includes(placement) ? `${arrowTop.value}px` : null,
4634
+ bottom: (placement, exChange2) => ["topleft", "topmiddle", "topright"].includes(placement) && !exChange2 ? "-5px" : ["bottomleft", "bottommiddle", "bottomright"].includes(placement) && exChange2 ? "-5px" : null
4635
+ };
4565
4636
  const arrowHandle = () => {
4637
+ const resultStyles = {};
4638
+ for (const styleName in styleConditions) {
4639
+ const condition = styleConditions[styleName];
4640
+ if (typeof condition === "function") {
4641
+ resultStyles[styleName] = condition(props.placement, exChange.value);
4642
+ } else if (condition) {
4643
+ resultStyles[styleName] = condition;
4644
+ }
4645
+ }
4646
+ const publicClass = "tdd-absolute tdd-z-1000 tdd-w-2.5 tdd-h-2.5 before:tdd-z-[-1] before:tdd-border before:tdd-border-gray-300 before:tdd-bg-white before:tdd-content-border before:tdd-rotate-45 before:tdd-content-[' '] before:tdd-w-2.5 before:tdd-h-2.5 before:tdd-absolute";
4566
4647
  return vue.h(
4567
4648
  "span",
4568
4649
  {
4569
- class: vue.normalizeClass([
4570
- "tdd-absolute tdd-z-1000 tdd-w-2.5 tdd-h-2.5 before:tdd-bg-white before:tdd-box-border before:tdd-rotate-45 before:tdd-content-[''] before:tdd-w-2.5 before:tdd-h-2.5 before:tdd-absolute",
4571
- ["topleft", "topmiddle", "topright"].includes(props.placement) ? "before:tdd-border-t-transparent before:tdd-border-l-transparent" : "",
4572
- ["bottomleft", "bottommiddle", "bottomright"].includes(props.placement) ? "before:tdd-border-b-transparent before:tdd-border-r-transparent" : "",
4573
- "centerright" == props.placement ? "before:tdd-border-r-transparent before:tdd-border-t-transparent" : "",
4574
- "centerleft" == props.placement ? "before:tdd-border-l-transparent before:tdd-border-b-transparent" : "",
4575
- props.beforebgcolor
4576
- ]),
4577
- style: {
4578
- left: `${arrowLeft.value}px`,
4579
- top: `${arrowTop.value}px`
4580
- }
4650
+ class: vue.normalizeClass(
4651
+ [
4652
+ publicClass,
4653
+ ["topleft", "topmiddle", "topright"].includes(props.placement) && !exChange.value ? "before:tdd-border-t-transparent before:tdd-border-l-transparent before:tdd-rounded-br" : "",
4654
+ ["topleft", "topmiddle", "topright"].includes(props.placement) && exChange.value ? "before:tdd-border-b-transparent before:tdd-border-r-transparent before:tdd-rounded-tl" : "",
4655
+ ["bottomleft", "bottommiddle", "bottomright"].includes(props.placement) && !exChange.value ? "before:tdd-border-b-transparent before:tdd-border-r-transparent before:tdd-rounded-tl" : "",
4656
+ ["bottomleft", "bottommiddle", "bottomright"].includes(props.placement) && exChange.value ? "before:tdd-border-t-transparent before:tdd-border-l-transparent before:tdd-rounded-br" : "",
4657
+ "centerright" == props.placement ? "before:tdd-border-r-transparent before:tdd-border-t-transparent before:tdd-rounded-bl" : "",
4658
+ "centerleft" == props.placement ? "before:tdd-border-l-transparent before:tdd-border-b-transparent before:tdd-rounded-tr" : "",
4659
+ props.beforebgcolor
4660
+ ]
4661
+ ),
4662
+ style: vue.normalizeStyle(
4663
+ resultStyles
4664
+ )
4581
4665
  }
4582
4666
  );
4583
4667
  };
@@ -4593,12 +4677,8 @@
4593
4677
  const Top = vue.ref(0);
4594
4678
  const arrowLeft = vue.ref(0);
4595
4679
  const arrowTop = vue.ref(0);
4680
+ const exChange = vue.ref(false);
4596
4681
  const setPosition = () => {
4597
- if (!pop.value) {
4598
- window.removeEventListener("resize", setPosition);
4599
- window.removeEventListener("scroll", setPosition, true);
4600
- return;
4601
- }
4602
4682
  const { top, bottom } = base.value.getBoundingClientRect();
4603
4683
  if (top < 0 || bottom > window.innerHeight) {
4604
4684
  if (props.trigger === "native") {
@@ -4608,8 +4688,6 @@
4608
4688
  }
4609
4689
  return;
4610
4690
  }
4611
- window.addEventListener("resize", setPosition);
4612
- window.addEventListener("scroll", setPosition, true);
4613
4691
  const position = usePotion(base.value, pop.value, {
4614
4692
  position: props.placement
4615
4693
  });
@@ -4617,23 +4695,25 @@
4617
4695
  Left.value = position.Left;
4618
4696
  arrowTop.value = position.arrowTop;
4619
4697
  arrowLeft.value = position.arrowLeft;
4698
+ exChange.value = position.exChange;
4699
+ window.addEventListener("resize", setPosition);
4700
+ window.addEventListener("scroll", setPosition, true);
4620
4701
  };
4621
4702
  const vClickoutside = {
4622
4703
  mounted(el, binding) {
4623
- if (!(el instanceof HTMLElement)) {
4624
- console.error("el must be an instance of HTMLElement");
4625
- return;
4626
- }
4627
4704
  function documentHandler(e) {
4628
- if ((el == null ? void 0 : el.contains) && (el == null ? void 0 : el.contains(e.target))) {
4705
+ var _a;
4706
+ if (trueFlag.value == false)
4707
+ return;
4708
+ if (el.contains(e.target)) {
4629
4709
  return false;
4630
- } else if (base.value.contains(e.target)) {
4710
+ } else if ((_a = base.value) == null ? void 0 : _a.contains(e.target)) {
4631
4711
  return false;
4632
4712
  } else {
4633
4713
  binding.value && binding.value(e);
4634
4714
  }
4635
4715
  }
4636
- el._vueClickOutside_ = throttle(documentHandler, 100);
4716
+ el._vueClickOutside_ = debounce(documentHandler, 80);
4637
4717
  document.addEventListener("click", el._vueClickOutside_);
4638
4718
  switch (props.trigger) {
4639
4719
  case "hover":
@@ -4642,10 +4722,6 @@
4642
4722
  }
4643
4723
  },
4644
4724
  beforeUnmount(el) {
4645
- if (!(el instanceof HTMLElement)) {
4646
- console.error("el must be an instance of HTMLElement");
4647
- return;
4648
- }
4649
4725
  document.removeEventListener("click", el._vueClickOutside_);
4650
4726
  switch (props.trigger) {
4651
4727
  case "hover":
@@ -4706,37 +4782,15 @@
4706
4782
  }, [
4707
4783
  vue.renderSlot(_ctx.$slots, "reference"),
4708
4784
  (vue.openBlock(), vue.createBlock(vue.Teleport, {
4709
- to: "body",
4785
+ to: bindName.value,
4710
4786
  disabled: !trueFlag.value
4711
4787
  }, [
4712
- _ctx.vIF ? (vue.openBlock(), vue.createBlock(vue.Transition, {
4713
- key: 0,
4714
- name: "opecity"
4715
- }, {
4716
- default: vue.withCtx(() => [
4717
- trueFlag.value ? vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", {
4718
- key: 0,
4719
- ref_key: "pop",
4720
- ref: pop,
4721
- class: vue.normalizeClass(["tdd-absolute tdd-z-1000 tdd-rounded tdd-bg-white tdd-p-4 tdd-drop-shadow", [marginClass.value, _ctx.insertClass]]),
4722
- style: vue.normalizeStyle({ width: widthNum.value, top: `${Top.value}px`, left: `${Left.value}px` })
4723
- }, [
4724
- vue.renderSlot(_ctx.$slots, "default"),
4725
- vue.createVNode(arrowHandle)
4726
- ], 6)), [
4727
- [vClickoutside, closeCenter]
4728
- ]) : vue.createCommentVNode("", true)
4729
- ]),
4730
- _: 3
4731
- })) : (vue.openBlock(), vue.createBlock(vue.Transition, {
4732
- key: 1,
4733
- name: "opecity"
4734
- }, {
4788
+ vue.createVNode(vue.Transition, { name: "opecity" }, {
4735
4789
  default: vue.withCtx(() => [
4736
4790
  vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", {
4737
4791
  ref_key: "pop",
4738
4792
  ref: pop,
4739
- class: vue.normalizeClass(["tdd-absolute tdd-z-1000 tdd-rounded tdd-bg-white tdd-p-4 tdd-drop-shadow", [marginClass.value, _ctx.insertClass]]),
4793
+ class: vue.normalizeClass(["tdd-absolute tdd-z-1000 tdd-rounded tdd-bg-white tdd-p-4 tdd-drop-shadow tdd-border tdd-border-gray-300 tdd-box-border", [marginClass.value, _ctx.insertClass]]),
4740
4794
  style: vue.normalizeStyle({ width: widthNum.value, top: `${Top.value}px`, left: `${Left.value}px` })
4741
4795
  }, [
4742
4796
  vue.renderSlot(_ctx.$slots, "default"),
@@ -4747,8 +4801,8 @@
4747
4801
  ])
4748
4802
  ]),
4749
4803
  _: 3
4750
- }))
4751
- ], 8, ["disabled"]))
4804
+ })
4805
+ ], 8, ["to", "disabled"]))
4752
4806
  ], 40, _hoisted_1$7);
4753
4807
  };
4754
4808
  }
@@ -535,33 +535,47 @@ const removeHandle = (el, root) => {
535
535
  el.removeChild(el.instance.$el);
536
536
  }
537
537
  };
538
- const throttle = (fn, delay) => {
539
- let flag = true;
538
+ function debounce(func, wait) {
539
+ let timeout;
540
540
  return function() {
541
- if (flag) {
542
- setTimeout(() => {
543
- fn.apply(this, arguments);
544
- flag = true;
545
- }, delay);
541
+ const context = this;
542
+ const args = arguments;
543
+ clearTimeout(timeout);
544
+ timeout = setTimeout(function() {
545
+ func.apply(context, args);
546
+ }, wait);
547
+ };
548
+ }
549
+ function throttle(func, wait) {
550
+ let timeout;
551
+ return function() {
552
+ const context = this;
553
+ const args = arguments;
554
+ if (!timeout) {
555
+ timeout = setTimeout(function() {
556
+ timeout = null;
557
+ func.apply(context, args);
558
+ }, wait);
546
559
  }
547
- flag = false;
548
560
  };
549
- };
561
+ }
550
562
  const usePotion = (baseDom, aimDom, set) => {
551
563
  let left = 0;
552
564
  let top = 0;
553
565
  let arrowleft = 0;
554
566
  let arrowtop = 0;
567
+ let exchange = false;
555
568
  if (!baseDom || !aimDom) {
556
569
  return {
557
570
  Top: top,
558
571
  Left: left,
559
572
  arrowLeft: arrowleft,
560
- arrowTop: arrowtop
573
+ arrowTop: arrowtop,
574
+ exChange: exchange
561
575
  };
562
576
  }
563
- const { left: baseLeft, right, bottom, top: baseTop, width: baseWidth } = baseDom.getBoundingClientRect();
564
- const { height: aimHeight, width: aimWidth } = aimDom.getBoundingClientRect();
577
+ const { left: baseLeft, right, bottom, top: baseTop, width: baseWidth, height: baseHeight } = baseDom.getBoundingClientRect();
578
+ const { height: aimHeight, width: aimWidth, top: aimTop } = aimDom.getBoundingClientRect();
565
579
  const scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
566
580
  const scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
567
581
  switch (set == null ? void 0 : set.position) {
@@ -569,17 +583,15 @@ const usePotion = (baseDom, aimDom, set) => {
569
583
  case "bottommiddle":
570
584
  case "bottomright":
571
585
  top = scrollTop + bottom;
572
- arrowtop = -5;
573
586
  break;
574
587
  case "topleft":
575
588
  case "topmiddle":
576
589
  case "topright":
577
590
  top = scrollTop + baseTop - aimHeight;
578
- arrowtop = aimHeight - 5;
579
591
  break;
580
592
  case "centerleft":
581
593
  case "centerright":
582
- top = scrollTop + baseTop + (bottom - baseTop - aimHeight) / 2;
594
+ top = scrollTop + baseTop + (baseHeight - aimHeight) / 2;
583
595
  arrowtop = aimHeight / 2 - 5;
584
596
  break;
585
597
  }
@@ -608,20 +620,42 @@ const usePotion = (baseDom, aimDom, set) => {
608
620
  arrowleft = -5;
609
621
  break;
610
622
  }
611
- if (top + aimHeight > window.innerHeight) {
612
- top = scrollTop + window.innerHeight - aimHeight - 10;
613
- }
614
- if (top < 0) {
615
- top = 10;
623
+ if (top + aimHeight + 10 > scrollTop + window.innerHeight) {
624
+ switch (set == null ? void 0 : set.position) {
625
+ case "bottommiddle":
626
+ case "bottomleft":
627
+ case "bottomright":
628
+ exchange = true;
629
+ top = scrollTop + baseTop - aimHeight - 24;
630
+ break;
631
+ case "centerleft":
632
+ case "centerright":
633
+ top = scrollTop + window.innerHeight - aimHeight - 10;
634
+ arrowtop = baseTop - aimTop + baseHeight / 2 - 10;
635
+ break;
636
+ }
616
637
  }
617
- if (left + aimWidth > window.innerWidth) {
618
- left = scrollLeft + right - aimWidth;
638
+ if (top - scrollTop < 0) {
639
+ switch (set == null ? void 0 : set.position) {
640
+ case "topmiddle":
641
+ case "topleft":
642
+ case "topright":
643
+ exchange = true;
644
+ top = scrollTop + bottom + 24;
645
+ break;
646
+ case "centerleft":
647
+ case "centerright":
648
+ top = 10 + scrollTop;
649
+ arrowtop = baseTop + baseHeight / 2 - 10;
650
+ break;
651
+ }
619
652
  }
620
653
  return {
621
654
  Top: top,
622
655
  Left: left,
623
656
  arrowLeft: arrowleft,
624
- arrowTop: arrowtop
657
+ arrowTop: arrowtop,
658
+ exChange: exchange
625
659
  };
626
660
  };
627
661
  function getNewArray(array, subGroupLength) {
@@ -691,6 +725,13 @@ const off = function() {
691
725
  }
692
726
  };
693
727
  }();
728
+ function createAndAppendElementWithId(id) {
729
+ if (!document.getElementById(id)) {
730
+ const element = document.createElement("div");
731
+ element.id = id;
732
+ document.body.appendChild(element);
733
+ }
734
+ }
694
735
  const scrolllead = {
695
736
  beforeMount(el, binding) {
696
737
  function scrollhandle(e) {
@@ -784,45 +825,47 @@ const index = {
784
825
  }
785
826
  };
786
827
  export {
787
- LibCheckGroup as A,
788
- LibCheckBox as B,
789
- LibUpload as C,
790
- LibTabs as D,
791
- LibTabsPane as E,
792
- LibScrollBar as F,
793
- AlertCom as G,
794
- LibLoad as H,
795
- scrolllead as I,
796
- LibCarousel as J,
797
- LibCarouselItem as K,
828
+ LibRadioBox as A,
829
+ LibRadioGroup as B,
830
+ LibCheckGroup as C,
831
+ LibCheckBox as D,
832
+ LibUpload as E,
833
+ LibTabs as F,
834
+ LibTabsPane as G,
835
+ LibScrollBar as H,
836
+ AlertCom as I,
837
+ LibLoad as J,
838
+ scrolllead as K,
798
839
  LibDialog as L,
799
840
  MessageCom as M,
800
- LibSwitch as N,
801
- LibTree as O,
841
+ LibCarousel as N,
842
+ LibCarouselItem as O,
843
+ LibSwitch as P,
844
+ LibTree as Q,
802
845
  off as a,
803
846
  getScrollWidth as b,
804
- addResizeListener as c,
805
- LibForm as d,
806
- LibFormLabel as e,
807
- LibInput as f,
847
+ createAndAppendElementWithId as c,
848
+ debounce as d,
849
+ addResizeListener as e,
850
+ LibForm as f,
808
851
  getNewArray as g,
809
- LibSelect as h,
852
+ LibFormLabel as h,
810
853
  index as i,
811
- LibSelectOption as j,
812
- LibTable as k,
813
- LibTableItem as l,
814
- LibImage as m,
815
- LibDatePicker as n,
854
+ LibInput as j,
855
+ LibSelect as k,
856
+ LibSelectOption as l,
857
+ LibTable as m,
858
+ LibTableItem as n,
816
859
  on as o,
817
- LibDatePickerRange as p,
818
- LibMenu as q,
860
+ LibImage as p,
861
+ LibDatePicker as q,
819
862
  removeResizeListener as r,
820
- LibPagination as s,
863
+ LibDatePickerRange as s,
821
864
  throttle as t,
822
865
  usePotion as u,
823
- LibBadge as v,
824
- LibPopover as w,
825
- LibNumberInput as x,
826
- LibRadioBox as y,
827
- LibRadioGroup as z
866
+ LibMenu as v,
867
+ LibPagination as w,
868
+ LibBadge as x,
869
+ LibPopover as y,
870
+ LibNumberInput as z
828
871
  };
@@ -1,5 +1,5 @@
1
- import { defineComponent, ref, computed, nextTick, onUnmounted, openBlock, createElementBlock, withModifiers, renderSlot, createBlock, Teleport, Transition, withCtx, withDirectives, normalizeClass, normalizeStyle, createVNode, createCommentVNode, vShow, h } from "vue";
2
- import { u as usePotion, t as throttle } from "../index/index.js";
1
+ import { defineComponent, ref, computed, nextTick, onUnmounted, openBlock, createElementBlock, withModifiers, renderSlot, createBlock, Teleport, createVNode, Transition, withCtx, withDirectives, normalizeClass, normalizeStyle, vShow, h } from "vue";
2
+ import { c as createAndAppendElementWithId, u as usePotion, d as debounce } from "../index/index.js";
3
3
  const _hoisted_1 = ["onMouseenter"];
4
4
  const _sfc_main = /* @__PURE__ */ defineComponent({
5
5
  __name: "popover",
@@ -16,9 +16,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
16
16
  emits: ["update:modelValue"],
17
17
  setup(__props, { expose: __expose, emit: emitAct }) {
18
18
  const props = __props;
19
+ const bindName = ref("body");
19
20
  const base = ref();
20
21
  const pop = ref();
21
22
  const showPop = ref(false);
23
+ createAndAppendElementWithId("tdd-pop");
24
+ bindName.value = "#tdd-pop";
22
25
  const trueFlag = computed(() => {
23
26
  if (showPop.value || props.trigger === "native" && props.modelValue) {
24
27
  nextTick(() => {
@@ -56,22 +59,41 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
56
59
  }
57
60
  return margin;
58
61
  });
62
+ const styleConditions = {
63
+ left: (placement) => ["topleft", "topmiddle", "topright", "bottomleft", "bottommiddle", "bottomright"].includes(placement) ? `${arrowLeft.value}px` : "centerright" == placement ? "-5px" : null,
64
+ right: (placement) => "centerleft" == placement ? "-5px" : null,
65
+ top: (placement, exChange2) => ["bottomleft", "bottommiddle", "bottomright"].includes(placement) && !exChange2 ? "-5px" : ["topleft", "topmiddle", "topright"].includes(placement) && exChange2 ? "-5px" : ["centerright", "centerleft"].includes(placement) ? `${arrowTop.value}px` : null,
66
+ bottom: (placement, exChange2) => ["topleft", "topmiddle", "topright"].includes(placement) && !exChange2 ? "-5px" : ["bottomleft", "bottommiddle", "bottomright"].includes(placement) && exChange2 ? "-5px" : null
67
+ };
59
68
  const arrowHandle = () => {
69
+ const resultStyles = {};
70
+ for (const styleName in styleConditions) {
71
+ const condition = styleConditions[styleName];
72
+ if (typeof condition === "function") {
73
+ resultStyles[styleName] = condition(props.placement, exChange.value);
74
+ } else if (condition) {
75
+ resultStyles[styleName] = condition;
76
+ }
77
+ }
78
+ const publicClass = "tdd-absolute tdd-z-1000 tdd-w-2.5 tdd-h-2.5 before:tdd-z-[-1] before:tdd-border before:tdd-border-gray-300 before:tdd-bg-white before:tdd-content-border before:tdd-rotate-45 before:tdd-content-[' '] before:tdd-w-2.5 before:tdd-h-2.5 before:tdd-absolute";
60
79
  return h(
61
80
  "span",
62
81
  {
63
- class: normalizeClass([
64
- "tdd-absolute tdd-z-1000 tdd-w-2.5 tdd-h-2.5 before:tdd-bg-white before:tdd-box-border before:tdd-rotate-45 before:tdd-content-[''] before:tdd-w-2.5 before:tdd-h-2.5 before:tdd-absolute",
65
- ["topleft", "topmiddle", "topright"].includes(props.placement) ? "before:tdd-border-t-transparent before:tdd-border-l-transparent" : "",
66
- ["bottomleft", "bottommiddle", "bottomright"].includes(props.placement) ? "before:tdd-border-b-transparent before:tdd-border-r-transparent" : "",
67
- "centerright" == props.placement ? "before:tdd-border-r-transparent before:tdd-border-t-transparent" : "",
68
- "centerleft" == props.placement ? "before:tdd-border-l-transparent before:tdd-border-b-transparent" : "",
69
- props.beforebgcolor
70
- ]),
71
- style: {
72
- left: `${arrowLeft.value}px`,
73
- top: `${arrowTop.value}px`
74
- }
82
+ class: normalizeClass(
83
+ [
84
+ publicClass,
85
+ ["topleft", "topmiddle", "topright"].includes(props.placement) && !exChange.value ? "before:tdd-border-t-transparent before:tdd-border-l-transparent before:tdd-rounded-br" : "",
86
+ ["topleft", "topmiddle", "topright"].includes(props.placement) && exChange.value ? "before:tdd-border-b-transparent before:tdd-border-r-transparent before:tdd-rounded-tl" : "",
87
+ ["bottomleft", "bottommiddle", "bottomright"].includes(props.placement) && !exChange.value ? "before:tdd-border-b-transparent before:tdd-border-r-transparent before:tdd-rounded-tl" : "",
88
+ ["bottomleft", "bottommiddle", "bottomright"].includes(props.placement) && exChange.value ? "before:tdd-border-t-transparent before:tdd-border-l-transparent before:tdd-rounded-br" : "",
89
+ "centerright" == props.placement ? "before:tdd-border-r-transparent before:tdd-border-t-transparent before:tdd-rounded-bl" : "",
90
+ "centerleft" == props.placement ? "before:tdd-border-l-transparent before:tdd-border-b-transparent before:tdd-rounded-tr" : "",
91
+ props.beforebgcolor
92
+ ]
93
+ ),
94
+ style: normalizeStyle(
95
+ resultStyles
96
+ )
75
97
  }
76
98
  );
77
99
  };
@@ -87,12 +109,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
87
109
  const Top = ref(0);
88
110
  const arrowLeft = ref(0);
89
111
  const arrowTop = ref(0);
112
+ const exChange = ref(false);
90
113
  const setPosition = () => {
91
- if (!pop.value) {
92
- window.removeEventListener("resize", setPosition);
93
- window.removeEventListener("scroll", setPosition, true);
94
- return;
95
- }
96
114
  const { top, bottom } = base.value.getBoundingClientRect();
97
115
  if (top < 0 || bottom > window.innerHeight) {
98
116
  if (props.trigger === "native") {
@@ -102,8 +120,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
102
120
  }
103
121
  return;
104
122
  }
105
- window.addEventListener("resize", setPosition);
106
- window.addEventListener("scroll", setPosition, true);
107
123
  const position = usePotion(base.value, pop.value, {
108
124
  position: props.placement
109
125
  });
@@ -111,23 +127,25 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
111
127
  Left.value = position.Left;
112
128
  arrowTop.value = position.arrowTop;
113
129
  arrowLeft.value = position.arrowLeft;
130
+ exChange.value = position.exChange;
131
+ window.addEventListener("resize", setPosition);
132
+ window.addEventListener("scroll", setPosition, true);
114
133
  };
115
134
  const vClickoutside = {
116
135
  mounted(el, binding) {
117
- if (!(el instanceof HTMLElement)) {
118
- console.error("el must be an instance of HTMLElement");
119
- return;
120
- }
121
136
  function documentHandler(e) {
122
- if ((el == null ? void 0 : el.contains) && (el == null ? void 0 : el.contains(e.target))) {
137
+ var _a;
138
+ if (trueFlag.value == false)
139
+ return;
140
+ if (el.contains(e.target)) {
123
141
  return false;
124
- } else if (base.value.contains(e.target)) {
142
+ } else if ((_a = base.value) == null ? void 0 : _a.contains(e.target)) {
125
143
  return false;
126
144
  } else {
127
145
  binding.value && binding.value(e);
128
146
  }
129
147
  }
130
- el._vueClickOutside_ = throttle(documentHandler, 100);
148
+ el._vueClickOutside_ = debounce(documentHandler, 80);
131
149
  document.addEventListener("click", el._vueClickOutside_);
132
150
  switch (props.trigger) {
133
151
  case "hover":
@@ -136,10 +154,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
136
154
  }
137
155
  },
138
156
  beforeUnmount(el) {
139
- if (!(el instanceof HTMLElement)) {
140
- console.error("el must be an instance of HTMLElement");
141
- return;
142
- }
143
157
  document.removeEventListener("click", el._vueClickOutside_);
144
158
  switch (props.trigger) {
145
159
  case "hover":
@@ -200,37 +214,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
200
214
  }, [
201
215
  renderSlot(_ctx.$slots, "reference"),
202
216
  (openBlock(), createBlock(Teleport, {
203
- to: "body",
217
+ to: bindName.value,
204
218
  disabled: !trueFlag.value
205
219
  }, [
206
- _ctx.vIF ? (openBlock(), createBlock(Transition, {
207
- key: 0,
208
- name: "opecity"
209
- }, {
210
- default: withCtx(() => [
211
- trueFlag.value ? withDirectives((openBlock(), createElementBlock("div", {
212
- key: 0,
213
- ref_key: "pop",
214
- ref: pop,
215
- class: normalizeClass(["tdd-absolute tdd-z-1000 tdd-rounded tdd-bg-white tdd-p-4 tdd-drop-shadow", [marginClass.value, _ctx.insertClass]]),
216
- style: normalizeStyle({ width: widthNum.value, top: `${Top.value}px`, left: `${Left.value}px` })
217
- }, [
218
- renderSlot(_ctx.$slots, "default"),
219
- createVNode(arrowHandle)
220
- ], 6)), [
221
- [vClickoutside, closeCenter]
222
- ]) : createCommentVNode("", true)
223
- ]),
224
- _: 3
225
- })) : (openBlock(), createBlock(Transition, {
226
- key: 1,
227
- name: "opecity"
228
- }, {
220
+ createVNode(Transition, { name: "opecity" }, {
229
221
  default: withCtx(() => [
230
222
  withDirectives((openBlock(), createElementBlock("div", {
231
223
  ref_key: "pop",
232
224
  ref: pop,
233
- class: normalizeClass(["tdd-absolute tdd-z-1000 tdd-rounded tdd-bg-white tdd-p-4 tdd-drop-shadow", [marginClass.value, _ctx.insertClass]]),
225
+ class: normalizeClass(["tdd-absolute tdd-z-1000 tdd-rounded tdd-bg-white tdd-p-4 tdd-drop-shadow tdd-border tdd-border-gray-300 tdd-box-border", [marginClass.value, _ctx.insertClass]]),
234
226
  style: normalizeStyle({ width: widthNum.value, top: `${Top.value}px`, left: `${Left.value}px` })
235
227
  }, [
236
228
  renderSlot(_ctx.$slots, "default"),
@@ -241,8 +233,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
241
233
  ])
242
234
  ]),
243
235
  _: 3
244
- }))
245
- ], 8, ["disabled"]))
236
+ })
237
+ ], 8, ["to", "disabled"]))
246
238
  ], 40, _hoisted_1);
247
239
  };
248
240
  }
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, ref, computed, openBlock, createElementBlock, normalizeClass, createElementVNode, normalizeStyle, onMounted, nextTick, onUnmounted, renderSlot, createVNode } from "vue";
2
- import { o as on, a as off, b as getScrollWidth, c as addResizeListener, r as removeResizeListener } from "../index/index.js";
2
+ import { o as on, a as off, b as getScrollWidth, e as addResizeListener, r as removeResizeListener } from "../index/index.js";
3
3
  const _sfc_main$1 = /* @__PURE__ */ defineComponent({
4
4
  __name: "movebar",
5
5
  props: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ninemoon-ui",
3
3
  "private": false,
4
- "version": "0.0.12",
4
+ "version": "0.0.14",
5
5
  "author": "zhuboy",
6
6
  "keywords": [
7
7
  "vue3",