ninemoon-ui 0.0.11 → 0.0.13

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 { H, w, K, N, C, B, q, s, L, f, h, p, j, I, t, M, y, v, x, z, A, G, J, k, l, O, m, n, E, F, P, D, 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
+ H as LibAlert,
5
+ w as LibBadge,
6
+ K as LibCarousel,
7
+ N as LibCarouselItem,
8
+ C as LibCheckBox,
9
+ B 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
+ I as LibLoad,
18
+ t 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
+ y as LibNumberInput,
21
+ v as LibPagination,
22
+ x as LibPopover,
23
+ z as LibRadioBox,
24
+ A as LibRadioGroup,
25
+ G as LibScrollBar,
26
+ J as LibScrollLoad,
27
+ k as LibSelect,
28
+ l as LibSelectOption,
29
+ O as LibSwitch,
30
+ m as LibTable,
31
+ n as LibTableItem,
32
+ E as LibTabs,
33
+ F as LibTabsPane,
34
+ P as LibTree,
35
+ D 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,32 +1805,46 @@
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();
1847
+ const { left: baseLeft, right, bottom, top: baseTop, width: baseWidth, height: baseHeight } = baseDom.getBoundingClientRect();
1813
1848
  const { height: aimHeight, width: aimWidth } = aimDom.getBoundingClientRect();
1814
1849
  const scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
1815
1850
  const scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
@@ -1818,13 +1853,11 @@
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":
@@ -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;
1893
+ if (top + aimHeight + 10 > 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 + baseHeight / 2 - 10;
1905
+ break;
1906
+ }
1862
1907
  }
1863
1908
  if (top < 0) {
1864
- top = 10;
1865
- }
1866
- if (left + aimWidth > window.innerWidth) {
1867
- left = scrollLeft + right - aimWidth;
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;
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) {
@@ -2548,9 +2610,6 @@
2548
2610
  } else if (props.modelValue) {
2549
2611
  return;
2550
2612
  } else {
2551
- emit("update:modelValue", null);
2552
- ParentGetChangeHandle && ParentGetChangeHandle(null);
2553
- emit("change", null);
2554
2613
  return null;
2555
2614
  }
2556
2615
  });
@@ -3001,7 +3060,7 @@
3001
3060
  mouseX = e.pageX;
3002
3061
  mouseY = e.pageY;
3003
3062
  ImgIsMoving.value = true;
3004
- el._vueMove_ = throttle(setMoveHandle, 60);
3063
+ el._vueMove_ = debounce(setMoveHandle, 60);
3005
3064
  window.addEventListener("mousemove", el._vueMove_);
3006
3065
  }
3007
3066
  function upHandle() {
@@ -4525,9 +4584,12 @@
4525
4584
  emits: ["update:modelValue"],
4526
4585
  setup(__props, { expose: __expose, emit: emitAct }) {
4527
4586
  const props = __props;
4587
+ const bindName = vue.ref("body");
4528
4588
  const base = vue.ref();
4529
4589
  const pop = vue.ref();
4530
4590
  const showPop = vue.ref(false);
4591
+ createAndAppendElementWithId("tdd-pop");
4592
+ bindName.value = "#tdd-pop";
4531
4593
  const trueFlag = vue.computed(() => {
4532
4594
  if (showPop.value || props.trigger === "native" && props.modelValue) {
4533
4595
  vue.nextTick(() => {
@@ -4565,22 +4627,41 @@
4565
4627
  }
4566
4628
  return margin;
4567
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
+ };
4568
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";
4569
4647
  return vue.h(
4570
4648
  "span",
4571
4649
  {
4572
- class: vue.normalizeClass([
4573
- "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",
4574
- ["topleft", "topmiddle", "topright"].includes(props.placement) ? "before:tdd-border-t-transparent before:tdd-border-l-transparent" : "",
4575
- ["bottomleft", "bottommiddle", "bottomright"].includes(props.placement) ? "before:tdd-border-b-transparent before:tdd-border-r-transparent" : "",
4576
- "centerright" == props.placement ? "before:tdd-border-r-transparent before:tdd-border-t-transparent" : "",
4577
- "centerleft" == props.placement ? "before:tdd-border-l-transparent before:tdd-border-b-transparent" : "",
4578
- props.beforebgcolor
4579
- ]),
4580
- style: {
4581
- left: `${arrowLeft.value}px`,
4582
- top: `${arrowTop.value}px`
4583
- }
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
+ )
4584
4665
  }
4585
4666
  );
4586
4667
  };
@@ -4596,12 +4677,8 @@
4596
4677
  const Top = vue.ref(0);
4597
4678
  const arrowLeft = vue.ref(0);
4598
4679
  const arrowTop = vue.ref(0);
4680
+ const exChange = vue.ref(false);
4599
4681
  const setPosition = () => {
4600
- if (!pop.value) {
4601
- window.removeEventListener("resize", setPosition);
4602
- window.removeEventListener("scroll", setPosition, true);
4603
- return;
4604
- }
4605
4682
  const { top, bottom } = base.value.getBoundingClientRect();
4606
4683
  if (top < 0 || bottom > window.innerHeight) {
4607
4684
  if (props.trigger === "native") {
@@ -4611,8 +4688,6 @@
4611
4688
  }
4612
4689
  return;
4613
4690
  }
4614
- window.addEventListener("resize", setPosition);
4615
- window.addEventListener("scroll", setPosition, true);
4616
4691
  const position = usePotion(base.value, pop.value, {
4617
4692
  position: props.placement
4618
4693
  });
@@ -4620,23 +4695,25 @@
4620
4695
  Left.value = position.Left;
4621
4696
  arrowTop.value = position.arrowTop;
4622
4697
  arrowLeft.value = position.arrowLeft;
4698
+ exChange.value = position.exChange;
4699
+ window.addEventListener("resize", setPosition);
4700
+ window.addEventListener("scroll", setPosition, true);
4623
4701
  };
4624
4702
  const vClickoutside = {
4625
4703
  mounted(el, binding) {
4626
- if (!(el instanceof HTMLElement)) {
4627
- console.error("el must be an instance of HTMLElement");
4628
- return;
4629
- }
4630
4704
  function documentHandler(e) {
4631
- 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)) {
4632
4709
  return false;
4633
- } else if (base.value.contains(e.target)) {
4710
+ } else if ((_a = base.value) == null ? void 0 : _a.contains(e.target)) {
4634
4711
  return false;
4635
4712
  } else {
4636
4713
  binding.value && binding.value(e);
4637
4714
  }
4638
4715
  }
4639
- el._vueClickOutside_ = throttle(documentHandler, 100);
4716
+ el._vueClickOutside_ = debounce(documentHandler, 80);
4640
4717
  document.addEventListener("click", el._vueClickOutside_);
4641
4718
  switch (props.trigger) {
4642
4719
  case "hover":
@@ -4645,10 +4722,6 @@
4645
4722
  }
4646
4723
  },
4647
4724
  beforeUnmount(el) {
4648
- if (!(el instanceof HTMLElement)) {
4649
- console.error("el must be an instance of HTMLElement");
4650
- return;
4651
- }
4652
4725
  document.removeEventListener("click", el._vueClickOutside_);
4653
4726
  switch (props.trigger) {
4654
4727
  case "hover":
@@ -4659,6 +4732,7 @@
4659
4732
  }
4660
4733
  };
4661
4734
  const closeCenter = () => {
4735
+ console.log(1111);
4662
4736
  if (props.beforeHidden) {
4663
4737
  props.beforeHidden(hideHandle);
4664
4738
  } else {
@@ -4709,37 +4783,15 @@
4709
4783
  }, [
4710
4784
  vue.renderSlot(_ctx.$slots, "reference"),
4711
4785
  (vue.openBlock(), vue.createBlock(vue.Teleport, {
4712
- to: "body",
4786
+ to: bindName.value,
4713
4787
  disabled: !trueFlag.value
4714
4788
  }, [
4715
- _ctx.vIF ? (vue.openBlock(), vue.createBlock(vue.Transition, {
4716
- key: 0,
4717
- name: "opecity"
4718
- }, {
4719
- default: vue.withCtx(() => [
4720
- trueFlag.value ? vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", {
4721
- key: 0,
4722
- ref_key: "pop",
4723
- ref: pop,
4724
- class: vue.normalizeClass(["tdd-absolute tdd-z-1000 tdd-rounded tdd-bg-white tdd-p-4 tdd-drop-shadow", [marginClass.value, _ctx.insertClass]]),
4725
- style: vue.normalizeStyle({ width: widthNum.value, top: `${Top.value}px`, left: `${Left.value}px` })
4726
- }, [
4727
- vue.renderSlot(_ctx.$slots, "default"),
4728
- vue.createVNode(arrowHandle)
4729
- ], 6)), [
4730
- [vClickoutside, closeCenter]
4731
- ]) : vue.createCommentVNode("", true)
4732
- ]),
4733
- _: 3
4734
- })) : (vue.openBlock(), vue.createBlock(vue.Transition, {
4735
- key: 1,
4736
- name: "opecity"
4737
- }, {
4789
+ vue.createVNode(vue.Transition, { name: "opecity" }, {
4738
4790
  default: vue.withCtx(() => [
4739
4791
  vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", {
4740
4792
  ref_key: "pop",
4741
4793
  ref: pop,
4742
- class: vue.normalizeClass(["tdd-absolute tdd-z-1000 tdd-rounded tdd-bg-white tdd-p-4 tdd-drop-shadow", [marginClass.value, _ctx.insertClass]]),
4794
+ 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]]),
4743
4795
  style: vue.normalizeStyle({ width: widthNum.value, top: `${Top.value}px`, left: `${Left.value}px` })
4744
4796
  }, [
4745
4797
  vue.renderSlot(_ctx.$slots, "default"),
@@ -4750,8 +4802,8 @@
4750
4802
  ])
4751
4803
  ]),
4752
4804
  _: 3
4753
- }))
4754
- ], 8, ["disabled"]))
4805
+ })
4806
+ ], 8, ["to", "disabled"]))
4755
4807
  ], 40, _hoisted_1$7);
4756
4808
  };
4757
4809
  }
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, ref, watch, openBlock, createElementBlock, Fragment, createElementVNode, createCommentVNode, renderSlot, createBlock, Teleport, createVNode, Transition, withCtx, withDirectives, withModifiers, normalizeStyle, normalizeClass, nextTick } from "vue";
2
- import { t as throttle } from "../index/index.js";
2
+ import { d as debounce } from "../index/index.js";
3
3
  const _hoisted_1 = { class: "tdd-relative tdd-inline-block tdd-h-full tdd-w-full" };
4
4
  const _hoisted_2 = ["src"];
5
5
  const _hoisted_3 = /* @__PURE__ */ createElementVNode("svg", {
@@ -109,7 +109,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
109
109
  mouseX = e.pageX;
110
110
  mouseY = e.pageY;
111
111
  ImgIsMoving.value = true;
112
- el._vueMove_ = throttle(setMoveHandle, 60);
112
+ el._vueMove_ = debounce(setMoveHandle, 60);
113
113
  window.addEventListener("mousemove", el._vueMove_);
114
114
  }
115
115
  function upHandle() {
@@ -535,32 +535,46 @@ 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();
577
+ const { left: baseLeft, right, bottom, top: baseTop, width: baseWidth, height: baseHeight } = baseDom.getBoundingClientRect();
564
578
  const { height: aimHeight, width: aimWidth } = aimDom.getBoundingClientRect();
565
579
  const scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
566
580
  const scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
@@ -569,13 +583,11 @@ 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":
@@ -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;
623
+ if (top + aimHeight + 10 > 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 + baseHeight / 2 - 10;
635
+ break;
636
+ }
613
637
  }
614
638
  if (top < 0) {
615
- top = 10;
616
- }
617
- if (left + aimWidth > window.innerWidth) {
618
- left = scrollLeft + right - aimWidth;
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;
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,46 @@ 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
+ LibRadioGroup as A,
829
+ LibCheckGroup as B,
830
+ LibCheckBox as C,
831
+ LibUpload as D,
832
+ LibTabs as E,
833
+ LibTabsPane as F,
834
+ LibScrollBar as G,
835
+ AlertCom as H,
836
+ LibLoad as I,
837
+ scrolllead as J,
838
+ LibCarousel as K,
798
839
  LibDialog as L,
799
840
  MessageCom as M,
800
- LibSwitch as N,
801
- LibTree as O,
841
+ LibCarouselItem as N,
842
+ LibSwitch as O,
843
+ LibTree as P,
802
844
  off as a,
803
845
  getScrollWidth as b,
804
- addResizeListener as c,
805
- LibForm as d,
806
- LibFormLabel as e,
807
- LibInput as f,
846
+ createAndAppendElementWithId as c,
847
+ debounce as d,
848
+ addResizeListener as e,
849
+ LibForm as f,
808
850
  getNewArray as g,
809
- LibSelect as h,
851
+ LibFormLabel as h,
810
852
  index as i,
811
- LibSelectOption as j,
812
- LibTable as k,
813
- LibTableItem as l,
814
- LibImage as m,
815
- LibDatePicker as n,
853
+ LibInput as j,
854
+ LibSelect as k,
855
+ LibSelectOption as l,
856
+ LibTable as m,
857
+ LibTableItem as n,
816
858
  on as o,
817
- LibDatePickerRange as p,
818
- LibMenu as q,
859
+ LibImage as p,
860
+ LibDatePicker as q,
819
861
  removeResizeListener as r,
820
- LibPagination as s,
821
- throttle as t,
862
+ LibDatePickerRange as s,
863
+ LibMenu as t,
822
864
  usePotion as u,
823
- LibBadge as v,
824
- LibPopover as w,
825
- LibNumberInput as x,
826
- LibRadioBox as y,
827
- LibRadioGroup as z
865
+ LibPagination as v,
866
+ LibBadge as w,
867
+ LibPopover as x,
868
+ LibNumberInput as y,
869
+ LibRadioBox as z
828
870
  };
@@ -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":
@@ -150,6 +164,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
150
164
  }
151
165
  };
152
166
  const closeCenter = () => {
167
+ console.log(1111);
153
168
  if (props.beforeHidden) {
154
169
  props.beforeHidden(hideHandle);
155
170
  } else {
@@ -200,37 +215,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
200
215
  }, [
201
216
  renderSlot(_ctx.$slots, "reference"),
202
217
  (openBlock(), createBlock(Teleport, {
203
- to: "body",
218
+ to: bindName.value,
204
219
  disabled: !trueFlag.value
205
220
  }, [
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
- }, {
221
+ createVNode(Transition, { name: "opecity" }, {
229
222
  default: withCtx(() => [
230
223
  withDirectives((openBlock(), createElementBlock("div", {
231
224
  ref_key: "pop",
232
225
  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]]),
226
+ 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
227
  style: normalizeStyle({ width: widthNum.value, top: `${Top.value}px`, left: `${Left.value}px` })
235
228
  }, [
236
229
  renderSlot(_ctx.$slots, "default"),
@@ -241,8 +234,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
241
234
  ])
242
235
  ]),
243
236
  _: 3
244
- }))
245
- ], 8, ["disabled"]))
237
+ })
238
+ ], 8, ["to", "disabled"]))
246
239
  ], 40, _hoisted_1);
247
240
  };
248
241
  }
@@ -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: {
@@ -32,9 +32,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
32
32
  } else if (props.modelValue) {
33
33
  return;
34
34
  } else {
35
- emit("update:modelValue", null);
36
- ParentGetChangeHandle && ParentGetChangeHandle(null);
37
- emit("change", null);
38
35
  return null;
39
36
  }
40
37
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ninemoon-ui",
3
3
  "private": false,
4
- "version": "0.0.11",
4
+ "version": "0.0.13",
5
5
  "author": "zhuboy",
6
6
  "keywords": [
7
7
  "vue3",