ninemoon-ui 0.1.20 → 0.2.1

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.
Files changed (40) hide show
  1. package/dist/components/carousel/carousel.vue.d.ts +2 -0
  2. package/dist/components/date/datepicker.vue.d.ts +1 -1
  3. package/dist/components/date/datepickerRange.vue.d.ts +16 -0
  4. package/dist/components/form/formlabel.vue.d.ts +1 -3
  5. package/dist/components/pagination/pagination.vue.d.ts +8 -15
  6. package/dist/components/popover/popover.vue.d.ts +5 -0
  7. package/dist/components/switch/switch.vue.d.ts +10 -0
  8. package/dist/components/upload/upload.vue.d.ts +5 -0
  9. package/dist/index.d.ts +139 -61
  10. package/dist/index.es.js +21 -21
  11. package/dist/js/arrow/arrow.js +2 -2
  12. package/dist/js/badge/badge.js +1 -1
  13. package/dist/js/calendar/calendar.js +4 -4
  14. package/dist/js/carousel/carousel.js +59 -38
  15. package/dist/js/check/checkbox.js +4 -4
  16. package/dist/js/date/datepicker.js +20 -8
  17. package/dist/js/date/datepickerRange.js +104 -69
  18. package/dist/js/dateArrowplus/dateArrowplus.js +2 -2
  19. package/dist/js/delete/delete.js +2 -2
  20. package/dist/js/dialog/dialog.js +41 -29
  21. package/dist/js/form/formlabel.js +21 -89
  22. package/dist/js/image/image.js +17 -18
  23. package/dist/js/index/index.js +273 -253
  24. package/dist/js/input/input.js +8 -8
  25. package/dist/js/menu/menu.js +1 -1
  26. package/dist/js/numberInput/numberinput.js +8 -8
  27. package/dist/js/pagination/pagination.js +17 -14
  28. package/dist/js/popover/popover.js +3 -239
  29. package/dist/js/popover.vue_vue_type_script_setup_true_lang/popover.vue_vue_type_script_setup_true_lang.js +249 -0
  30. package/dist/js/radio/radiobox.js +4 -4
  31. package/dist/js/scrollBar/scrollBar.js +4 -4
  32. package/dist/js/select/select.js +5 -5
  33. package/dist/js/select/selectoption.js +3 -3
  34. package/dist/js/switch/switch.js +33 -7
  35. package/dist/js/table/table.js +107 -77
  36. package/dist/js/table/tableItem.js +2 -2
  37. package/dist/js/tabs/tabs.js +202 -21
  38. package/dist/js/upload/upload.js +57 -12
  39. package/dist/utils/tool.d.ts +5 -0
  40. package/package.json +5 -2
@@ -54,7 +54,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
54
54
  ref_key: "menuListRef",
55
55
  ref: menuListRef
56
56
  }, [
57
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.menulist, (item, i) => {
57
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.menulist, (item, i) => {
58
58
  return openBlock(), createElementBlock("label", { key: item }, [
59
59
  withDirectives(createElementVNode("input", {
60
60
  class: "hidden",
@@ -7,9 +7,9 @@ const _hoisted_1$2 = {
7
7
  xmlns: "http://www.w3.org/2000/svg"
8
8
  };
9
9
  function _sfc_render$1(_ctx, _cache) {
10
- return openBlock(), createElementBlock("svg", _hoisted_1$2, _cache[0] || (_cache[0] = [
10
+ return openBlock(), createElementBlock("svg", _hoisted_1$2, [..._cache[0] || (_cache[0] = [
11
11
  createElementVNode("path", { d: "M853.333333 544H170.666667c-17.066667 0-32-14.933333-32-32s14.933333-32 32-32h682.666666c17.066667 0 32 14.933333 32 32s-14.933333 32-32 32z" }, null, -1)
12
- ]));
12
+ ])]);
13
13
  }
14
14
  const minusIcon = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$1]]);
15
15
  const _sfc_main$1 = {};
@@ -19,12 +19,12 @@ const _hoisted_1$1 = {
19
19
  xmlns: "http://www.w3.org/2000/svg"
20
20
  };
21
21
  function _sfc_render(_ctx, _cache) {
22
- return openBlock(), createElementBlock("svg", _hoisted_1$1, _cache[0] || (_cache[0] = [
22
+ return openBlock(), createElementBlock("svg", _hoisted_1$1, [..._cache[0] || (_cache[0] = [
23
23
  createElementVNode("path", { d: "M853.333333 480H544V170.666667c0-17.066667-14.933333-32-32-32s-32 14.933333-32 32v309.333333H170.666667c-17.066667 0-32 14.933333-32 32s14.933333 32 32 32h309.333333V853.333333c0 17.066667 14.933333 32 32 32s32-14.933333 32-32V544H853.333333c17.066667 0 32-14.933333 32-32s-14.933333-32-32-32z" }, null, -1)
24
- ]));
24
+ ])]);
25
25
  }
26
26
  const addIcon = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render]]);
27
- const _hoisted_1 = { class: "inline-flex w-full rounded-sm border border-solid" };
27
+ const _hoisted_1 = { class: "inline-flex w-full rounded border border-solid" };
28
28
  const _hoisted_2 = ["disabled"];
29
29
  const _hoisted_3 = ["disabled"];
30
30
  const _sfc_main = /* @__PURE__ */ defineComponent({
@@ -92,12 +92,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
92
92
  type: "button",
93
93
  disabled: isMinReached.value,
94
94
  onClick: reduceHandle,
95
- class: normalizeClass(["disabled:cursor-not-allowed flex-none bg-gray-200 text-xs", sizeClass.value])
95
+ class: normalizeClass(["disabled:cursor-not-allowed bg-gray-200 text-xs", sizeClass.value])
96
96
  }, [
97
97
  createVNode(minusIcon, { class: "h-4 w-4 fill-word6 inline-block" })
98
98
  ], 10, _hoisted_2),
99
99
  withDirectives(createElementVNode("input", {
100
- class: "w-full px-1 text-center outline-none text-word3",
100
+ class: "w-full flex-1 px-1 text-sm text-center outline-none text-word3",
101
101
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => inputValue.value = $event),
102
102
  type: "text"
103
103
  }, null, 512), [
@@ -107,7 +107,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
107
107
  type: "button",
108
108
  disabled: isMaxReached.value,
109
109
  onClick: addHandle,
110
- class: normalizeClass(["disabled:cursor-not-allowed flex-none bg-gray-200 text-xs", sizeClass.value])
110
+ class: normalizeClass(["disabled:cursor-not-allowed bg-gray-200 text-xs", sizeClass.value])
111
111
  }, [
112
112
  createVNode(addIcon, { class: "h-4 w-4 fill-word6 inline-block" })
113
113
  ], 10, _hoisted_3)
@@ -9,7 +9,7 @@ const _hoisted_1$1 = {
9
9
  xmlns: "http://www.w3.org/2000/svg"
10
10
  };
11
11
  function _sfc_render(_ctx, _cache) {
12
- return openBlock(), createElementBlock("svg", _hoisted_1$1, _cache[0] || (_cache[0] = [
12
+ return openBlock(), createElementBlock("svg", _hoisted_1$1, [..._cache[0] || (_cache[0] = [
13
13
  createElementVNode("path", {
14
14
  d: "M192 512m-64 0a64 64 0 1 0 128 0 64 64 0 1 0-128 0Z",
15
15
  fill: "currentColor"
@@ -22,7 +22,7 @@ function _sfc_render(_ctx, _cache) {
22
22
  d: "M832 512m-64 0a64 64 0 1 0 128 0 64 64 0 1 0-128 0Z",
23
23
  fill: "currentColor"
24
24
  }, null, -1)
25
- ]));
25
+ ])]);
26
26
  }
27
27
  const ellipsisIcon = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render]]);
28
28
  const _hoisted_1 = { class: "flex items-center w-full h-7 text-sm text-center select-none" };
@@ -49,8 +49,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
49
49
  emits: [
50
50
  "size-change",
51
51
  "current-change",
52
- "update:currentPage",
53
- "update:activeSize"
52
+ "update:current-page",
53
+ "update:active-size"
54
54
  ],
55
55
  setup(__props, { emit: __emit }) {
56
56
  const LibSelect = defineAsyncComponent(() => import("../select/select.js"));
@@ -65,7 +65,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
65
65
  const emit = __emit;
66
66
  const size = computed({
67
67
  set(num) {
68
- emit("update:activeSize", num);
68
+ emit("update:active-size", num);
69
69
  emit("size-change", num);
70
70
  },
71
71
  get() {
@@ -74,7 +74,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
74
74
  });
75
75
  const currentPage = computed({
76
76
  set(num) {
77
- emit("update:currentPage", num);
77
+ emit("update:current-page", num);
78
78
  emit("current-change", num);
79
79
  },
80
80
  get() {
@@ -109,10 +109,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
109
109
  return currentPage.value >= maxPage.value;
110
110
  });
111
111
  const showFirst = computed(() => {
112
- return currentPage.value - 5 > 0 && maxPage.value > 7;
112
+ return currentPage.value - props.visibleRange > 2 && maxPage.value > props.edgeVisibleCount;
113
113
  });
114
114
  const showLast = computed(() => {
115
- return maxPage.value - currentPage.value > 4 && maxPage.value > 7;
115
+ return maxPage.value - currentPage.value > props.visibleRange && maxPage.value > props.edgeVisibleCount;
116
116
  });
117
117
  const activeChange = (num) => {
118
118
  currentPage.value += num;
@@ -121,6 +121,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
121
121
  currentPage.value = k;
122
122
  };
123
123
  const range = (start, end) => {
124
+ if (start > end) {
125
+ return [];
126
+ }
124
127
  const length = end - start + 1;
125
128
  return Array.from({ length }, (_, i) => start + i);
126
129
  };
@@ -133,7 +136,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
133
136
  size: "mini"
134
137
  }, {
135
138
  default: withCtx(() => [
136
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.sizeArr, (i) => {
139
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.sizeArr, (i) => {
137
140
  return openBlock(), createBlock(unref(LibSelectOption), {
138
141
  value: i,
139
142
  label: `${i}条/页`
@@ -154,7 +157,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
154
157
  createElementVNode("button", {
155
158
  onClick: _cache[1] || (_cache[1] = ($event) => activeChange(-1)),
156
159
  type: "button",
157
- class: normalizeClass(["w-5 h-5", { "cursor-not-allowed": firstBtnDisable.value }]),
160
+ class: normalizeClass(["w-5 h-5 flex items-center justify-center", { "cursor-not-allowed": firstBtnDisable.value }]),
158
161
  disabled: firstBtnDisable.value
159
162
  }, [
160
163
  createVNode(ArrowPlug, { class: "h-4 w-4" })
@@ -162,7 +165,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
162
165
  createElementVNode("ul", _hoisted_5, [
163
166
  createElementVNode("li", {
164
167
  onClick: _cache[2] || (_cache[2] = ($event) => indexHandle(1)),
165
- class: normalizeClass(["px-2 h-5 leading-5 cursor-pointer font-bold", { "text-blue-500": 1 === currentPage.value }])
168
+ class: normalizeClass(["px-2 h-5 leading-5 cursor-pointer font-bold rounded", { "text-blue-500 bg-blue-100": 1 === currentPage.value }])
166
169
  }, " 1 ", 2),
167
170
  showFirst.value ? (openBlock(), createBlock(ellipsisIcon, {
168
171
  key: 0,
@@ -171,7 +174,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
171
174
  (openBlock(true), createElementBlock(Fragment, null, renderList(numberArr.value, (i) => {
172
175
  return openBlock(), createElementBlock("li", {
173
176
  onClick: ($event) => indexHandle(i),
174
- class: normalizeClass([{ "text-blue-500": i === currentPage.value }, "px-2 h-5 leading-5 cursor-pointer font-bold"]),
177
+ class: normalizeClass([{ "text-blue-500 bg-blue-100": i === currentPage.value }, "px-2 h-5 leading-5 cursor-pointer font-bold rounded"]),
175
178
  key: i
176
179
  }, toDisplayString(i), 11, _hoisted_6);
177
180
  }), 128)),
@@ -182,13 +185,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
182
185
  maxPage.value > 1 ? (openBlock(), createElementBlock("li", {
183
186
  key: 2,
184
187
  onClick: _cache[3] || (_cache[3] = ($event) => indexHandle(maxPage.value)),
185
- class: normalizeClass(["px-2 h-5 leading-5 cursor-pointer font-bold", { "text-blue-500": maxPage.value === currentPage.value }])
188
+ class: normalizeClass(["px-2 h-5 leading-5 cursor-pointer font-bold rounded", { "text-blue-500 bg-blue-100": maxPage.value === currentPage.value }])
186
189
  }, toDisplayString(maxPage.value), 3)) : createCommentVNode("", true)
187
190
  ]),
188
191
  createElementVNode("button", {
189
192
  onClick: _cache[4] || (_cache[4] = ($event) => activeChange(1)),
190
193
  type: "button",
191
- class: normalizeClass(["w-5 h-5", { "cursor-not-allowed": lastBtnDisable.value }]),
194
+ class: normalizeClass(["w-5 h-5 flex items-center justify-center", { "cursor-not-allowed": lastBtnDisable.value }]),
192
195
  disabled: lastBtnDisable.value
193
196
  }, [
194
197
  createVNode(ArrowPlug, { class: "h-4 w-4 rotate-180 transform" })
@@ -1,242 +1,6 @@
1
- import { defineComponent, h, normalizeClass, normalizeStyle, ref, computed, nextTick, getCurrentInstance, openBlock, createElementBlock, withModifiers, renderSlot, createBlock, Teleport, unref, createVNode, Transition, withCtx, withDirectives, createCommentVNode, vShow } from "vue";
2
- import { u as usePotion, h as createScrollDirective, i as createBgClickDirective, c as createEscapeDirective, s as selector } from "../index/index.js";
3
- const PLACEMENT_GROUPS = {
4
- top: ["topleft", "topmiddle", "topright"],
5
- bottom: ["bottomleft", "bottommiddle", "bottomright"],
6
- center: ["centerleft", "centerright"]
7
- };
8
- const ARROW_CLASSES = {
9
- base: 'absolute w-2.5 h-2.5 before:z-[-1] before:border before:border-gray-300 before:bg-white before:content-border before:rotate-45 before:content-[" "] before:w-2.5 before:h-2.5 before:absolute',
10
- top: {
11
- normal: "before:border-t-transparent before:border-l-transparent before:rounded-br",
12
- exchange: "before:border-b-transparent before:border-r-transparent before:rounded-tl"
13
- },
14
- bottom: {
15
- normal: "before:border-b-transparent before:border-r-transparent before:rounded-tl",
16
- exchange: "before:border-t-transparent before:border-l-transparent before:rounded-br"
17
- },
18
- center: {
19
- right: "before:border-r-transparent before:border-t-transparent before:rounded-bl",
20
- left: "before:border-l-transparent before:border-b-transparent before:rounded-tr"
21
- }
22
- };
23
- const arrowComponent = defineComponent({
24
- name: "PopArrow",
25
- props: {
26
- arrowLeft: { type: Number, required: true },
27
- arrowTop: { type: Number, required: true },
28
- placement: { type: String, required: true },
29
- exChange: { type: Boolean, required: true },
30
- beforebgcolor: { type: String }
31
- },
32
- setup(props) {
33
- const getArrowStyles = () => {
34
- const { placement, exChange, arrowLeft, arrowTop } = props;
35
- const isTopGroup = PLACEMENT_GROUPS.top.includes(placement);
36
- const isBottomGroup = PLACEMENT_GROUPS.bottom.includes(placement);
37
- const isCenterGroup = PLACEMENT_GROUPS.center.includes(placement);
38
- return {
39
- left: isTopGroup || isBottomGroup ? `${arrowLeft}px` : placement === "centerright" ? "-5px" : null,
40
- right: placement === "centerleft" ? "-5px" : null,
41
- top: isCenterGroup ? `${arrowTop}px` : isBottomGroup && !exChange || isTopGroup && exChange ? "-5px" : null,
42
- bottom: isTopGroup && !exChange || isBottomGroup && exChange ? "-5px" : null
43
- };
44
- };
45
- const getArrowClasses = () => {
46
- const { placement, exChange, beforebgcolor } = props;
47
- const classes = [ARROW_CLASSES.base, beforebgcolor];
48
- if (PLACEMENT_GROUPS.top.includes(placement)) {
49
- classes.push(exChange ? ARROW_CLASSES.top.exchange : ARROW_CLASSES.top.normal);
50
- }
51
- if (PLACEMENT_GROUPS.bottom.includes(placement)) {
52
- classes.push(exChange ? ARROW_CLASSES.bottom.exchange : ARROW_CLASSES.bottom.normal);
53
- }
54
- if (placement === "centerright") {
55
- classes.push(ARROW_CLASSES.center.right);
56
- }
57
- if (placement === "centerleft") {
58
- classes.push(ARROW_CLASSES.center.left);
59
- }
60
- return classes;
61
- };
62
- return () => h("span", {
63
- class: normalizeClass(getArrowClasses()),
64
- style: normalizeStyle(getArrowStyles())
65
- });
66
- }
67
- });
68
- const defaultWidth = "200px";
69
- const _sfc_main = /* @__PURE__ */ defineComponent({
70
- __name: "popover",
71
- props: {
72
- trigger: { default: "click" },
73
- width: {},
74
- placement: { default: "topleft" },
75
- insertClass: {},
76
- beforeHidden: {},
77
- modelValue: { type: Boolean },
78
- beforebgcolor: {},
79
- arrowshow: { type: Boolean, default: true }
80
- },
81
- emits: ["update:modelValue"],
82
- setup(__props, { expose: __expose, emit: __emit }) {
83
- const props = __props;
84
- const base = ref();
85
- const pop = ref();
86
- const isLocalOpen = ref(false);
87
- const shouldShow = computed(() => {
88
- if (isLocalOpen.value || props.trigger === "native" && props.modelValue) {
89
- nextTick(setPosition);
90
- }
91
- if (props.trigger === "native") {
92
- return props.modelValue;
93
- } else {
94
- return isLocalOpen.value;
95
- }
96
- });
97
- const emitAct = __emit;
98
- const marginClass = computed(() => {
99
- const marginMap = {
100
- topleft: "-mt-3",
101
- topmiddle: "-mt-3",
102
- topright: "-mt-3",
103
- bottomleft: "mt-3",
104
- bottommiddle: "mt-3",
105
- bottomright: "mt-3",
106
- centerleft: "-ml-3",
107
- centerright: "ml-3"
108
- };
109
- return marginMap[props.placement];
110
- });
111
- const showHandle = () => {
112
- isLocalOpen.value = true;
113
- };
114
- const hovershowHandle = () => {
115
- if (props.trigger === "hover") {
116
- isLocalOpen.value = true;
117
- }
118
- };
119
- const Left = ref(0);
120
- const Top = ref(0);
121
- const arrowLeft = ref(0);
122
- const arrowTop = ref(0);
123
- const exChange = ref(false);
124
- const setPosition = () => {
125
- const { top, bottom } = base.value.getBoundingClientRect();
126
- if (top < 0 || bottom > window.innerHeight) {
127
- hideHandle();
128
- return;
129
- }
130
- const position = usePotion(base.value, pop.value, {
131
- position: props.placement
132
- });
133
- Top.value = position.Top;
134
- Left.value = position.Left;
135
- arrowTop.value = position.arrowTop;
136
- arrowLeft.value = position.arrowLeft;
137
- exChange.value = position.exChange;
138
- };
139
- const { proxy } = getCurrentInstance();
140
- const vScroll = createScrollDirective({
141
- onMove: () => {
142
- setPosition();
143
- },
144
- scrollContainerId: (proxy == null ? void 0 : proxy.gloablScrollBar) ? proxy == null ? void 0 : proxy.gloablScrollBar : void 0
145
- });
146
- const vClickoutside = createBgClickDirective({
147
- onCheckOut: (event, el) => {
148
- if (el.contains(event.target)) {
149
- return;
150
- } else if (base.value.contains(event.target)) {
151
- return;
152
- } else {
153
- closeCenter();
154
- }
155
- },
156
- moveModel: props.trigger === "hover"
157
- });
158
- const vEsc = createEscapeDirective({
159
- onEscape: () => {
160
- hideHandle();
161
- }
162
- });
163
- const closeCenter = () => {
164
- if (props.beforeHidden) {
165
- props.beforeHidden(hideHandle);
166
- } else {
167
- hideHandle();
168
- }
169
- };
170
- const hideHandle = (disablecancelflag) => {
171
- if (disablecancelflag === true) {
172
- return;
173
- } else {
174
- if (props.trigger === "native") {
175
- emitAct("update:modelValue", false);
176
- } else {
177
- isLocalOpen.value = false;
178
- }
179
- }
180
- };
181
- const widthNum = computed(() => {
182
- if (!props.width)
183
- return defaultWidth;
184
- if (typeof props.width === "number") {
185
- return `${props.width}px`;
186
- } else if (typeof props.width === "string") {
187
- const validUnit = /^(?:\d+(?:\.\d+)?)(?:px|%|em|rem|vw|vh)$/.test(
188
- props.width
189
- );
190
- return validUnit ? props.width : `${props.width}px`;
191
- }
192
- return defaultWidth;
193
- });
194
- __expose({
195
- hideHandle
196
- });
197
- return (_ctx, _cache) => {
198
- return openBlock(), createElementBlock("div", {
199
- class: "inline-block",
200
- ref_key: "base",
201
- ref: base,
202
- onClick: showHandle,
203
- onMouseenter: withModifiers(hovershowHandle, ["prevent"])
204
- }, [
205
- renderSlot(_ctx.$slots, "reference"),
206
- (openBlock(), createBlock(Teleport, {
207
- to: `#${unref(selector)}`
208
- }, [
209
- createVNode(Transition, { name: "opecity" }, {
210
- default: withCtx(() => [
211
- withDirectives((openBlock(), createElementBlock("div", {
212
- ref_key: "pop",
213
- ref: pop,
214
- class: normalizeClass(["absolute z-1000 rounded bg-white p-4 drop-shadow border border-gray-300 box-border", [marginClass.value, _ctx.insertClass]]),
215
- style: normalizeStyle({ width: widthNum.value, top: `${Top.value}px`, left: `${Left.value}px` })
216
- }, [
217
- renderSlot(_ctx.$slots, "default"),
218
- _ctx.arrowshow ? (openBlock(), createBlock(unref(arrowComponent), {
219
- key: 0,
220
- arrowLeft: arrowLeft.value,
221
- arrowTop: arrowTop.value,
222
- exChange: exChange.value,
223
- beforebgcolor: _ctx.beforebgcolor,
224
- placement: _ctx.placement
225
- }, null, 8, ["arrowLeft", "arrowTop", "exChange", "beforebgcolor", "placement"])) : createCommentVNode("", true)
226
- ], 6)), [
227
- [vShow, shouldShow.value],
228
- [unref(vClickoutside), shouldShow.value],
229
- [unref(vEsc), shouldShow.value],
230
- [unref(vScroll), shouldShow.value]
231
- ])
232
- ]),
233
- _: 3
234
- })
235
- ], 8, ["to"]))
236
- ], 544);
237
- };
238
- }
239
- });
1
+ import { _ as _sfc_main } from "../popover.vue_vue_type_script_setup_true_lang/popover.vue_vue_type_script_setup_true_lang.js";
2
+ import "vue";
3
+ import "../index/index.js";
240
4
  export {
241
5
  _sfc_main as default
242
6
  };
@@ -0,0 +1,249 @@
1
+ import { defineComponent, h, normalizeClass, normalizeStyle, ref, computed, nextTick, watch, getCurrentInstance, openBlock, createElementBlock, withModifiers, renderSlot, createBlock, Teleport, unref, createVNode, Transition, withCtx, withDirectives, resolveDynamicComponent, createCommentVNode, vShow } from "vue";
2
+ import { z as zIndexManager, u as usePotion, h as createScrollDirective, i as createBgClickDirective, c as createEscapeDirective, s as selector } from "../index/index.js";
3
+ const PLACEMENT_GROUPS = {
4
+ top: ["topleft", "topmiddle", "topright"],
5
+ bottom: ["bottomleft", "bottommiddle", "bottomright"],
6
+ center: ["centerleft", "centerright"]
7
+ };
8
+ const ARROW_CLASSES = {
9
+ base: 'absolute w-2.5 h-2.5 before:z-[-1] before:border before:border-gray-300 before:bg-white before:content-border before:rotate-45 before:content-[" "] before:w-2.5 before:h-2.5 before:absolute',
10
+ top: {
11
+ normal: "before:border-t-transparent before:border-l-transparent before:rounded-br",
12
+ exchange: "before:border-b-transparent before:border-r-transparent before:rounded-tl"
13
+ },
14
+ bottom: {
15
+ normal: "before:border-b-transparent before:border-r-transparent before:rounded-tl",
16
+ exchange: "before:border-t-transparent before:border-l-transparent before:rounded-br"
17
+ },
18
+ center: {
19
+ right: "before:border-r-transparent before:border-t-transparent before:rounded-bl",
20
+ left: "before:border-l-transparent before:border-b-transparent before:rounded-tr"
21
+ }
22
+ };
23
+ const arrowComponent = defineComponent({
24
+ name: "PopArrow",
25
+ props: {
26
+ arrowLeft: { type: Number, required: true },
27
+ arrowTop: { type: Number, required: true },
28
+ placement: { type: String, required: true },
29
+ exChange: { type: Boolean, required: true },
30
+ beforebgcolor: { type: String }
31
+ },
32
+ setup(props) {
33
+ const getArrowStyles = () => {
34
+ const { placement, exChange, arrowLeft, arrowTop } = props;
35
+ const isTopGroup = PLACEMENT_GROUPS.top.includes(placement);
36
+ const isBottomGroup = PLACEMENT_GROUPS.bottom.includes(placement);
37
+ const isCenterGroup = PLACEMENT_GROUPS.center.includes(placement);
38
+ return {
39
+ left: isTopGroup || isBottomGroup ? `${arrowLeft}px` : placement === "centerright" ? "-5px" : null,
40
+ right: placement === "centerleft" ? "-5px" : null,
41
+ top: isCenterGroup ? `${arrowTop}px` : isBottomGroup && !exChange || isTopGroup && exChange ? "-5px" : null,
42
+ bottom: isTopGroup && !exChange || isBottomGroup && exChange ? "-5px" : null
43
+ };
44
+ };
45
+ const getArrowClasses = () => {
46
+ const { placement, exChange, beforebgcolor } = props;
47
+ const classes = [ARROW_CLASSES.base, beforebgcolor];
48
+ if (PLACEMENT_GROUPS.top.includes(placement)) {
49
+ classes.push(exChange ? ARROW_CLASSES.top.exchange : ARROW_CLASSES.top.normal);
50
+ }
51
+ if (PLACEMENT_GROUPS.bottom.includes(placement)) {
52
+ classes.push(exChange ? ARROW_CLASSES.bottom.exchange : ARROW_CLASSES.bottom.normal);
53
+ }
54
+ if (placement === "centerright") {
55
+ classes.push(ARROW_CLASSES.center.right);
56
+ }
57
+ if (placement === "centerleft") {
58
+ classes.push(ARROW_CLASSES.center.left);
59
+ }
60
+ return classes;
61
+ };
62
+ return () => h("span", {
63
+ class: normalizeClass(getArrowClasses()),
64
+ style: normalizeStyle(getArrowStyles())
65
+ });
66
+ }
67
+ });
68
+ const defaultWidth = "200px";
69
+ const _sfc_main = /* @__PURE__ */ defineComponent({
70
+ __name: "popover",
71
+ props: {
72
+ trigger: { default: "click" },
73
+ width: {},
74
+ placement: { default: "topleft" },
75
+ insertClass: {},
76
+ beforeHidden: {},
77
+ modelValue: { type: Boolean },
78
+ beforebgcolor: {},
79
+ arrowshow: { type: Boolean, default: true },
80
+ renderType: { default: "show" }
81
+ },
82
+ emits: ["update:modelValue"],
83
+ setup(__props, { expose: __expose, emit: __emit }) {
84
+ const props = __props;
85
+ const base = ref();
86
+ const pop = ref();
87
+ const isLocalOpen = ref(false);
88
+ const currentZIndex = ref(zIndexManager.getCurrentZIndex());
89
+ const shouldShow = computed(() => {
90
+ if (isLocalOpen.value || props.trigger === "native" && props.modelValue) {
91
+ nextTick(setPosition);
92
+ }
93
+ if (props.trigger === "native") {
94
+ return props.modelValue;
95
+ } else {
96
+ return isLocalOpen.value;
97
+ }
98
+ });
99
+ watch(shouldShow, (newVal) => {
100
+ if (newVal) {
101
+ currentZIndex.value = zIndexManager.getNextZIndex();
102
+ }
103
+ });
104
+ const emitAct = __emit;
105
+ const marginClass = computed(() => {
106
+ const marginMap = {
107
+ topleft: "-mt-3",
108
+ topmiddle: "-mt-3",
109
+ topright: "-mt-3",
110
+ bottomleft: "mt-3",
111
+ bottommiddle: "mt-3",
112
+ bottomright: "mt-3",
113
+ centerleft: "-ml-3",
114
+ centerright: "ml-3"
115
+ };
116
+ return marginMap[props.placement];
117
+ });
118
+ const showHandle = () => {
119
+ isLocalOpen.value = true;
120
+ };
121
+ const hovershowHandle = () => {
122
+ if (props.trigger === "hover") {
123
+ isLocalOpen.value = true;
124
+ }
125
+ };
126
+ const Left = ref(0);
127
+ const Top = ref(0);
128
+ const arrowLeft = ref(0);
129
+ const arrowTop = ref(0);
130
+ const exChange = ref(false);
131
+ const setPosition = () => {
132
+ const { top, bottom } = base.value.getBoundingClientRect();
133
+ if (top < 0 || bottom > window.innerHeight) {
134
+ hideHandle();
135
+ return;
136
+ }
137
+ const position = usePotion(base.value, pop.value, {
138
+ position: props.placement
139
+ });
140
+ Top.value = position.Top;
141
+ Left.value = position.Left;
142
+ arrowTop.value = position.arrowTop;
143
+ arrowLeft.value = position.arrowLeft;
144
+ exChange.value = position.exChange;
145
+ };
146
+ const { proxy } = getCurrentInstance();
147
+ const vScroll = createScrollDirective({
148
+ onMove: () => {
149
+ setPosition();
150
+ },
151
+ scrollContainerId: (proxy == null ? void 0 : proxy.gloablScrollBar) ? proxy == null ? void 0 : proxy.gloablScrollBar : void 0
152
+ });
153
+ const vClickoutside = createBgClickDirective({
154
+ onCheckOut: (event, el) => {
155
+ if (el.contains(event.target)) {
156
+ return;
157
+ } else if (base.value.contains(event.target)) {
158
+ return;
159
+ } else {
160
+ closeCenter();
161
+ }
162
+ },
163
+ moveModel: props.trigger === "hover"
164
+ });
165
+ const vEsc = createEscapeDirective({
166
+ onEscape: () => {
167
+ hideHandle();
168
+ }
169
+ });
170
+ const closeCenter = () => {
171
+ if (props.beforeHidden) {
172
+ props.beforeHidden(hideHandle);
173
+ } else {
174
+ hideHandle();
175
+ }
176
+ };
177
+ const hideHandle = (disablecancelflag) => {
178
+ if (disablecancelflag === true) {
179
+ return;
180
+ } else {
181
+ if (props.trigger === "native") {
182
+ emitAct("update:modelValue", false);
183
+ } else {
184
+ isLocalOpen.value = false;
185
+ }
186
+ }
187
+ };
188
+ const widthNum = computed(() => {
189
+ if (!props.width)
190
+ return defaultWidth;
191
+ if (typeof props.width === "number") {
192
+ return `${props.width}px`;
193
+ } else if (typeof props.width === "string") {
194
+ const validUnit = /^(?:\d+(?:\.\d+)?)(?:px|%|em|rem|vw|vh)$/.test(
195
+ props.width
196
+ );
197
+ return validUnit ? props.width : `${props.width}px`;
198
+ }
199
+ return defaultWidth;
200
+ });
201
+ __expose({
202
+ hideHandle
203
+ });
204
+ return (_ctx, _cache) => {
205
+ return openBlock(), createElementBlock("div", {
206
+ class: "inline-block",
207
+ ref_key: "base",
208
+ ref: base,
209
+ onClick: showHandle,
210
+ onMouseenter: withModifiers(hovershowHandle, ["prevent"])
211
+ }, [
212
+ renderSlot(_ctx.$slots, "reference"),
213
+ (openBlock(), createBlock(Teleport, {
214
+ to: `#${unref(selector)}`
215
+ }, [
216
+ createVNode(Transition, { name: "opacity" }, {
217
+ default: withCtx(() => [
218
+ withDirectives((openBlock(), createElementBlock("div", {
219
+ ref_key: "pop",
220
+ ref: pop,
221
+ class: normalizeClass(["absolute rounded bg-white p-4 drop-shadow border border-gray-300 box-border", [marginClass.value, __props.insertClass]]),
222
+ style: normalizeStyle({ width: widthNum.value, top: `${Top.value}px`, left: `${Left.value}px`, "z-index": currentZIndex.value })
223
+ }, [
224
+ renderSlot(_ctx.$slots, "default"),
225
+ __props.arrowshow ? (openBlock(), createBlock(resolveDynamicComponent(unref(arrowComponent)), {
226
+ key: 0,
227
+ arrowLeft: arrowLeft.value,
228
+ arrowTop: arrowTop.value,
229
+ exChange: exChange.value,
230
+ beforebgcolor: __props.beforebgcolor,
231
+ placement: __props.placement
232
+ }, null, 8, ["arrowLeft", "arrowTop", "exChange", "beforebgcolor", "placement"])) : createCommentVNode("", true)
233
+ ], 6)), [
234
+ [vShow, shouldShow.value],
235
+ [unref(vClickoutside), shouldShow.value],
236
+ [unref(vEsc), shouldShow.value],
237
+ [unref(vScroll), shouldShow.value]
238
+ ])
239
+ ]),
240
+ _: 3
241
+ })
242
+ ], 8, ["to"]))
243
+ ], 544);
244
+ };
245
+ }
246
+ });
247
+ export {
248
+ _sfc_main as _
249
+ };