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
@@ -1,11 +1,14 @@
1
- import { defineComponent, computed, ref, reactive, useSlots, onMounted, onUnmounted, openBlock, createElementBlock, createVNode, createElementVNode, normalizeStyle, createCommentVNode, h, normalizeClass, withDirectives, vShow } from "vue";
1
+ import { defineComponent, computed, ref, reactive, useSlots, onMounted, nextTick, onUnmounted, openBlock, createElementBlock, createElementVNode, createVNode, normalizeClass, withCtx, Fragment, renderList, toDisplayString, createCommentVNode, normalizeStyle, Comment, Text, h, withDirectives, vShow } from "vue";
2
+ import { _ as _sfc_main$1 } from "../popover.vue_vue_type_script_setup_true_lang/popover.vue_vue_type_script_setup_true_lang.js";
2
3
  import { S as ShapeFlags } from "../shapeFlag/shapeFlag.js";
4
+ import "../index/index.js";
3
5
  const _hoisted_1 = { class: "relative w-full overflow-hidden" };
4
- const _hoisted_2 = {
6
+ const _hoisted_2 = ["onClick"];
7
+ const _hoisted_3 = {
5
8
  key: 0,
6
9
  class: "relative my-2 border-t-2 border-solid border-gray-200"
7
10
  };
8
- const _hoisted_3 = { class: "relative w-full" };
11
+ const _hoisted_4 = { class: "relative w-full" };
9
12
  const _sfc_main = /* @__PURE__ */ defineComponent({
10
13
  __name: "tabs",
11
14
  props: {
@@ -40,27 +43,98 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
40
43
  left: 0,
41
44
  width: 0
42
45
  });
46
+ const showPopver = ref(false);
47
+ const dropdownSelected = ref("");
48
+ const containerWidth = ref(0);
49
+ const tabsWidth = ref([]);
50
+ const hasOverflow = ref(false);
43
51
  const slots = useSlots();
52
+ const flattenSlots = (nodes) => {
53
+ const result = [];
54
+ for (const node of nodes) {
55
+ if (!node)
56
+ continue;
57
+ if (node.type === Comment || node.type === Text)
58
+ continue;
59
+ if (node.type === Fragment) {
60
+ if (node.children) {
61
+ result.push(...flattenSlots(
62
+ Array.isArray(node.children) ? node.children : [node.children]
63
+ ));
64
+ }
65
+ continue;
66
+ }
67
+ if (node.shapeFlag & ShapeFlags.ARRAY_CHILDREN) {
68
+ if (node.children) {
69
+ result.push(...flattenSlots(node.children));
70
+ }
71
+ continue;
72
+ }
73
+ if (node.shapeFlag & (ShapeFlags.STATEFUL_COMPONENT | ShapeFlags.FUNCTIONAL_COMPONENT | ShapeFlags.SLOTS_CHILDREN)) {
74
+ result.push(node);
75
+ }
76
+ }
77
+ return result;
78
+ };
44
79
  const validSlots = computed(() => {
45
- return slots.default().reduce((pre, cur) => {
46
- if (cur.shapeFlag & ShapeFlags.ARRAY_CHILDREN) {
47
- pre = pre.concat(cur.children);
48
- } else if (cur.shapeFlag & ShapeFlags.STATEFUL_COMPONENT) {
49
- pre.push(cur);
80
+ var _a;
81
+ const defaultSlots = ((_a = slots.default) == null ? void 0 : _a.call(slots)) || [];
82
+ return flattenSlots(defaultSlots);
83
+ });
84
+ const visibleTabs = computed(() => {
85
+ if (!hasOverflow.value) {
86
+ return validSlots.value;
87
+ }
88
+ let totalWidth = 0;
89
+ const dropdownWidth = 64;
90
+ const maxWidth = containerWidth.value - dropdownWidth;
91
+ const visible = [];
92
+ for (let i = 0; i < validSlots.value.length; i++) {
93
+ const tabWidth = tabsWidth.value[i] || 100;
94
+ if (totalWidth + tabWidth <= maxWidth || i === 0 && validSlots.value.length > 1) {
95
+ totalWidth += tabWidth;
96
+ visible.push(validSlots.value[i]);
97
+ } else {
98
+ break;
50
99
  }
51
- return pre;
52
- }, []);
100
+ }
101
+ if (visible.length === validSlots.value.length) {
102
+ return validSlots.value;
103
+ }
104
+ return visible;
53
105
  });
106
+ const overflowTabs = computed(() => {
107
+ if (!hasOverflow.value) {
108
+ return [];
109
+ }
110
+ return validSlots.value.slice(visibleTabs.value.length);
111
+ });
112
+ const handleDropdownChange = () => {
113
+ const selectedIndex = validSlots.value.findIndex((tab) => tab.props.name === dropdownSelected.value);
114
+ if (selectedIndex !== -1) {
115
+ activeIndex.value = selectedIndex;
116
+ currentActive.value = dropdownSelected.value;
117
+ nextTick(() => {
118
+ var _a;
119
+ const activeElement = (_a = observerRef.value) == null ? void 0 : _a.children[selectedIndex];
120
+ if (activeElement) {
121
+ indicatorPos.width = activeElement.offsetWidth;
122
+ indicatorPos.left = activeElement.offsetLeft;
123
+ }
124
+ });
125
+ }
126
+ };
54
127
  const renderBar = () => {
55
128
  return h(
56
129
  "div",
57
130
  {
58
131
  class: normalizeClass([
59
- "ETab",
132
+ "ETab flex-grow",
60
133
  [showBaseline.value ? "px-2 pt-2" : " ETab_Card"]
61
- ])
134
+ ]),
135
+ ref: observerRef
62
136
  },
63
- validSlots.value.map((it, index) => {
137
+ visibleTabs.value.map((it, index) => {
64
138
  return renderBtn(it, index);
65
139
  })
66
140
  );
@@ -109,7 +183,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
109
183
  {
110
184
  class: normalizeClass(divc)
111
185
  },
112
- node.props.name
186
+ node.props.label || node.props.name
113
187
  )
114
188
  );
115
189
  };
@@ -127,8 +201,49 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
127
201
  [[vShow, activeIndex.value === i]]
128
202
  );
129
203
  };
204
+ const containRef = ref();
130
205
  const observerRef = ref();
131
206
  let observer;
207
+ const resizeObserver = new ResizeObserver((entries) => {
208
+ if (entries.length > 0) {
209
+ const entry = entries[0];
210
+ const newWidth = entry.contentRect.width;
211
+ if (Math.abs(newWidth - containerWidth.value) > 1) {
212
+ containerWidth.value = newWidth;
213
+ checkOverflow();
214
+ }
215
+ }
216
+ });
217
+ const checkOverflow = () => {
218
+ if (!observerRef.value)
219
+ return;
220
+ const tabElements = observerRef.value.children;
221
+ const newTabsWidth = Array.from(tabElements).map((el) => el.clientWidth);
222
+ const totalWidth = newTabsWidth.reduce((sum, width) => sum + width, 0);
223
+ const dropdownWidth = 64;
224
+ const wouldOverflow = totalWidth > containerWidth.value;
225
+ const wouldOverflowWithDropdown = totalWidth + dropdownWidth > containerWidth.value;
226
+ const newHasOverflow = hasOverflow.value ? wouldOverflowWithDropdown : wouldOverflow;
227
+ if (newHasOverflow !== hasOverflow.value) {
228
+ hasOverflow.value = newHasOverflow;
229
+ }
230
+ const widthChanged = newTabsWidth.length !== tabsWidth.value.length || newTabsWidth.some((width, index) => width !== tabsWidth.value[index]);
231
+ if (widthChanged) {
232
+ tabsWidth.value = newTabsWidth;
233
+ }
234
+ if (newHasOverflow && overflowTabs.value.length > 0) {
235
+ const isActiveInOverflow = overflowTabs.value.some((tab) => tab.props.name === currentActive.value);
236
+ if (isActiveInOverflow && dropdownSelected.value !== currentActive.value) {
237
+ dropdownSelected.value = currentActive.value || "";
238
+ }
239
+ }
240
+ };
241
+ const handleOverflowTabClick = (tab) => {
242
+ const name = tab.props.name;
243
+ dropdownSelected.value = name;
244
+ handleDropdownChange();
245
+ showPopver.value = false;
246
+ };
132
247
  onMounted(() => {
133
248
  observer = new IntersectionObserver((entries) => {
134
249
  entries.forEach((entry) => {
@@ -142,28 +257,94 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
142
257
  if (observerRef.value) {
143
258
  observer.observe(observerRef.value);
144
259
  }
260
+ if (containRef.value) {
261
+ containerWidth.value = containRef.value.clientWidth;
262
+ resizeObserver.observe(containRef.value);
263
+ }
264
+ nextTick(() => {
265
+ checkOverflow();
266
+ });
145
267
  });
146
268
  onUnmounted(() => {
147
269
  if (observerRef.value) {
148
270
  observer.unobserve(observerRef.value);
149
271
  }
272
+ if (containRef.value) {
273
+ resizeObserver.unobserve(containRef.value);
274
+ }
150
275
  });
151
276
  return (_ctx, _cache) => {
152
277
  return openBlock(), createElementBlock("div", _hoisted_1, [
153
- createVNode(renderBar, {
154
- ref_key: "observerRef",
155
- ref: observerRef
156
- }, null, 512),
157
- showBaseline.value ? (openBlock(), createElementBlock("div", _hoisted_2, [
278
+ createElementVNode("div", {
279
+ class: "flex items-end",
280
+ ref_key: "containRef",
281
+ ref: containRef
282
+ }, [
283
+ createVNode(renderBar, {
284
+ ref_key: "observerRef",
285
+ ref: observerRef
286
+ }, null, 512),
287
+ hasOverflow.value ? (openBlock(), createElementBlock("div", {
288
+ key: 0,
289
+ class: normalizeClass({ "ETab_Card": !showBaseline.value, "h-11": !showBaseline.value })
290
+ }, [
291
+ createVNode(_sfc_main$1, {
292
+ trigger: "native",
293
+ "insert-class": "!p-0",
294
+ placement: "bottomright",
295
+ arrowshow: false,
296
+ modelValue: showPopver.value,
297
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => showPopver.value = $event),
298
+ ref: "morePopoverRef"
299
+ }, {
300
+ reference: withCtx(() => [
301
+ createElementVNode("div", {
302
+ onClick: _cache[0] || (_cache[0] = ($event) => showPopver.value = true),
303
+ class: normalizeClass([
304
+ "text-blue-500 cursor-pointer inline-flex items-center justify-center px-2 text-sm",
305
+ showBaseline.value ? " " : "h-11 rounded-tl-lg rounded-tr-lg font-medium focus:text-blue-brand"
306
+ ])
307
+ }, [..._cache[2] || (_cache[2] = [
308
+ createElementVNode("div", { class: "whitespace-nowrap" }, "更多", -1),
309
+ createElementVNode("svg", {
310
+ class: "w-4 h-4 ml-1",
311
+ fill: "none",
312
+ stroke: "currentColor",
313
+ viewBox: "0 0 24 24",
314
+ xmlns: "http://www.w3.org/2000/svg"
315
+ }, [
316
+ createElementVNode("path", {
317
+ "stroke-linecap": "round",
318
+ "stroke-linejoin": "round",
319
+ "stroke-width": "2",
320
+ d: "M19 9l-7 7-7-7"
321
+ })
322
+ ], -1)
323
+ ])], 2)
324
+ ]),
325
+ default: withCtx(() => [
326
+ (openBlock(true), createElementBlock(Fragment, null, renderList(overflowTabs.value, (tab) => {
327
+ return openBlock(), createElementBlock("div", {
328
+ key: tab.props.name,
329
+ class: "px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 cursor-pointer whitespace-nowrap",
330
+ onClick: ($event) => handleOverflowTabClick(tab)
331
+ }, toDisplayString(tab.props.label || tab.props.name), 9, _hoisted_2);
332
+ }), 128))
333
+ ]),
334
+ _: 1
335
+ }, 8, ["modelValue"])
336
+ ], 2)) : createCommentVNode("", true)
337
+ ], 512),
338
+ showBaseline.value ? (openBlock(), createElementBlock("div", _hoisted_3, [
158
339
  createElementVNode("div", {
159
340
  class: "absolute bottom-0 border-t-2 border-solid border-blue-brand transition",
160
341
  style: normalizeStyle({
161
- transform: `translateX(${indicatorPos.left}px`,
342
+ transform: `translateX(${indicatorPos.left}px)`,
162
343
  width: `${indicatorPos.width}px`
163
344
  })
164
345
  }, null, 4)
165
346
  ])) : createCommentVNode("", true),
166
- createElementVNode("div", _hoisted_3, [
347
+ createElementVNode("div", _hoisted_4, [
167
348
  createVNode(renderContent)
168
349
  ])
169
350
  ]);
@@ -1,4 +1,4 @@
1
- import { defineComponent, ref, openBlock, createElementBlock, Fragment, createElementVNode, renderSlot, renderList, toDisplayString, createVNode, createCommentVNode } from "vue";
1
+ import { defineComponent, ref, openBlock, createElementBlock, Fragment, createElementVNode, withModifiers, renderSlot, normalizeClass, createStaticVNode, renderList, toDisplayString, createVNode, createCommentVNode } from "vue";
2
2
  import { C as CloseIcon } from "../index/index.js";
3
3
  const _hoisted_1 = ["accept", "multiple"];
4
4
  const _hoisted_2 = {
@@ -14,7 +14,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
14
14
  accept: { default: "" },
15
15
  fileList: {},
16
16
  showFileList: { type: Boolean, default: true },
17
- multiple: { type: Boolean, default: false }
17
+ multiple: { type: Boolean, default: false },
18
+ draggable: { type: Boolean, default: false }
18
19
  },
19
20
  emits: ["getNewFile", "delOldFile"],
20
21
  setup(__props, { expose: __expose, emit: __emit }) {
@@ -22,6 +23,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
22
23
  const emit = __emit;
23
24
  const FILEINPUT = ref();
24
25
  const fileList = ref(props.fileList || []);
26
+ const isDragOver = ref(false);
25
27
  const fileGet = () => {
26
28
  FILEINPUT.value.click();
27
29
  };
@@ -44,30 +46,73 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
44
46
  DeleteFileHandle(i);
45
47
  });
46
48
  };
49
+ const handleDragOver = (event) => {
50
+ isDragOver.value = true;
51
+ };
52
+ const handleDragEnter = (event) => {
53
+ isDragOver.value = true;
54
+ };
55
+ const handleDragLeave = (event) => {
56
+ isDragOver.value = false;
57
+ };
58
+ const handleDrop = (event) => {
59
+ isDragOver.value = false;
60
+ if (event.dataTransfer && event.dataTransfer.files.length > 0) {
61
+ const files = event.dataTransfer.files;
62
+ if (props.multiple) {
63
+ for (const file of files) {
64
+ fileList.value.push(file);
65
+ }
66
+ } else {
67
+ fileList.value = [files[0]];
68
+ }
69
+ emit("getNewFile", files, fileList.value);
70
+ event.dataTransfer.clearData();
71
+ }
72
+ };
47
73
  __expose({
48
74
  clearFiles
49
75
  });
50
76
  return (_ctx, _cache) => {
51
77
  return openBlock(), createElementBlock(Fragment, null, [
52
- createElementVNode("span", null, [
78
+ createElementVNode("div", null, [
53
79
  createElementVNode("input", {
54
80
  ref_key: "FILEINPUT",
55
81
  ref: FILEINPUT,
56
82
  onChange: _cache[0] || (_cache[0] = ($event) => FileHandle()),
57
- accept: _ctx.accept,
58
- multiple: _ctx.multiple,
83
+ accept: __props.accept,
84
+ multiple: __props.multiple,
59
85
  type: "file",
60
86
  class: "hidden"
61
87
  }, null, 40, _hoisted_1),
62
- createElementVNode("button", {
63
- onClick: fileGet,
64
- type: "button",
65
- class: "appearance-none"
88
+ __props.draggable ? (openBlock(), createElementBlock("div", {
89
+ key: 0,
90
+ onDragover: withModifiers(handleDragOver, ["prevent"]),
91
+ onDragenter: withModifiers(handleDragEnter, ["prevent"]),
92
+ onDragleave: withModifiers(handleDragLeave, ["prevent"]),
93
+ onDrop: withModifiers(handleDrop, ["prevent"]),
94
+ onClick: fileGet
66
95
  }, [
67
- renderSlot(_ctx.$slots, "default")
68
- ])
96
+ renderSlot(_ctx.$slots, "default", {}, () => [
97
+ createElementVNode("div", {
98
+ class: normalizeClass(["border-2 border-dashed border-gray-300 rounded-lg p-8 text-center transition-all duration-300 bg-gray-50 cursor-pointer hover:border-gray-500", { "border-blue-500 bg-blue-50": isDragOver.value }])
99
+ }, [..._cache[1] || (_cache[1] = [
100
+ createStaticVNode('<div class="flex flex-col items-center justify-center"><svg class="w-12 h-12 text-gray-400 mb-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"></path></svg><p class="text-lg font-medium text-gray-700 mb-2">拖拽文件到此处或点击选择文件</p><p class="text-sm text-gray-500">支持多种文件格式</p></div>', 1)
101
+ ])], 2)
102
+ ])
103
+ ], 32)) : (openBlock(), createElementBlock("div", {
104
+ key: 1,
105
+ onClick: fileGet
106
+ }, [
107
+ renderSlot(_ctx.$slots, "default", {}, () => [
108
+ _cache[2] || (_cache[2] = createElementVNode("button", {
109
+ type: "button",
110
+ class: "appearance-none border border-gray-300 rounded-md px-4 py-2 text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors duration-200 cursor-pointer"
111
+ }, " 点击上传 ", -1))
112
+ ])
113
+ ]))
69
114
  ]),
70
- _ctx.showFileList ? (openBlock(), createElementBlock("ul", _hoisted_2, [
115
+ __props.showFileList ? (openBlock(), createElementBlock("ul", _hoisted_2, [
71
116
  (openBlock(true), createElementBlock(Fragment, null, renderList(fileList.value, (i, d) => {
72
117
  return openBlock(), createElementBlock("li", {
73
118
  key: d,
@@ -50,5 +50,10 @@ export declare const useResizeObserver: (callback: () => void) => {
50
50
  observe: (el: HTMLElement) => void;
51
51
  unobserve: (el: HTMLElement) => void;
52
52
  };
53
+ export declare const zIndexManager: {
54
+ getNextZIndex(): number;
55
+ getCurrentZIndex(): number;
56
+ setZIndex(zIndex: number): void;
57
+ };
53
58
  declare const _default: {};
54
59
  export default _default;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ninemoon-ui",
3
3
  "private": false,
4
- "version": "0.1.20",
4
+ "version": "0.2.1",
5
5
  "author": "zhuboy",
6
6
  "keywords": [
7
7
  "vue3",
@@ -33,5 +33,8 @@
33
33
  "dist"
34
34
  ],
35
35
  "type": "module",
36
- "types": "dist/index.d.ts"
36
+ "types": "dist/index.d.ts",
37
+ "volta": {
38
+ "node": "18.12.1"
39
+ }
37
40
  }