ninemoon-ui 0.1.14 → 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 +274 -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,4 +1,4 @@
1
- import { defineComponent, computed, useSlots, h, nextTick, ref, openBlock, createElementBlock, Fragment, createElementVNode, normalizeClass, renderList, withDirectives, vModelCheckbox, createCommentVNode, createTextVNode, toDisplayString, createBlock, markRaw } from "vue";
1
+ import { defineComponent, computed, useSlots, h, nextTick, normalizeClass, ref, openBlock, createElementBlock, Fragment, createElementVNode, renderList, withDirectives, vModelCheckbox, createCommentVNode, createTextVNode, toDisplayString, createBlock, resolveDynamicComponent, Comment, Text } from "vue";
2
2
  import { S as ShapeFlags } from "../shapeFlag/shapeFlag.js";
3
3
  const _hoisted_1 = ["width"];
4
4
  const _hoisted_2 = { key: 0 };
@@ -8,11 +8,8 @@ const _hoisted_5 = {
8
8
  key: 0,
9
9
  class: "text-center"
10
10
  };
11
- const _hoisted_6 = {
12
- class: "px-1",
13
- for: "checkbox"
14
- };
15
- const _hoisted_7 = ["checked", "onChange"];
11
+ const _hoisted_6 = ["for"];
12
+ const _hoisted_7 = ["id", "checked", "onChange"];
16
13
  const _hoisted_8 = {
17
14
  key: 1,
18
15
  class: "text-center"
@@ -49,7 +46,40 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
49
46
  emit("selectionChange", resultArray.value);
50
47
  };
51
48
  const slots = useSlots();
49
+ const flattenSlots = (nodes) => {
50
+ const result = [];
51
+ for (const node of nodes) {
52
+ if (!node)
53
+ continue;
54
+ if (node.type === Comment || node.type === Text)
55
+ continue;
56
+ if (node.type === Fragment) {
57
+ if (node.children) {
58
+ result.push(...flattenSlots(
59
+ Array.isArray(node.children) ? node.children : [node.children]
60
+ ));
61
+ }
62
+ continue;
63
+ }
64
+ if (node.shapeFlag & ShapeFlags.ARRAY_CHILDREN) {
65
+ if (node.children) {
66
+ result.push(...flattenSlots(node.children));
67
+ }
68
+ continue;
69
+ }
70
+ if (node.shapeFlag & (ShapeFlags.STATEFUL_COMPONENT | ShapeFlags.FUNCTIONAL_COMPONENT | ShapeFlags.SLOTS_CHILDREN)) {
71
+ result.push(node);
72
+ }
73
+ }
74
+ return result;
75
+ };
76
+ const validSlots = computed(() => {
77
+ var _a;
78
+ const defaultSlots = ((_a = slots.default) == null ? void 0 : _a.call(slots)) || [];
79
+ return flattenSlots(defaultSlots);
80
+ });
52
81
  const groupedSlots = computed(() => {
82
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
53
83
  const groups = {
54
84
  append: null,
55
85
  prepend: null,
@@ -59,8 +89,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
59
89
  hasindex: false,
60
90
  hascheck: false
61
91
  };
62
- const _categorizeSlot = (slot) => {
63
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
92
+ for (const slot of validSlots.value) {
64
93
  const type = (_a = slot.props) == null ? void 0 : _a.type;
65
94
  switch (type) {
66
95
  case "append":
@@ -71,59 +100,52 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
71
100
  break;
72
101
  case "index":
73
102
  groups.rest.push({
74
- type: (_b = slot.props) == null ? void 0 : _b.type,
75
- prop: (_c = slot.props) == null ? void 0 : _c.prop,
76
- label: ((_d = slot.props) == null ? void 0 : _d.label) || "",
77
- width: (_e = slot.props) == null ? void 0 : _e.width
103
+ type,
104
+ prop: (_b = slot.props) == null ? void 0 : _b.prop,
105
+ label: ((_c = slot.props) == null ? void 0 : _c.label) || "",
106
+ width: (_d = slot.props) == null ? void 0 : _d.width
78
107
  });
79
108
  groups.restLen += 1;
80
109
  groups.hasindex = true;
81
110
  break;
82
111
  case "selection":
83
112
  groups.rest.push({
84
- type: (_f = slot.props) == null ? void 0 : _f.type,
85
- prop: (_g = slot.props) == null ? void 0 : _g.prop,
86
- label: ((_h = slot.props) == null ? void 0 : _h.label) || "",
87
- width: (_i = slot.props) == null ? void 0 : _i.width
113
+ type,
114
+ prop: (_e = slot.props) == null ? void 0 : _e.prop,
115
+ label: ((_f = slot.props) == null ? void 0 : _f.label) || "",
116
+ width: (_g = slot.props) == null ? void 0 : _g.width
88
117
  });
89
118
  groups.restLen += 1;
90
119
  groups.hascheck = true;
91
120
  break;
92
121
  default:
93
122
  groups.rest.push({
94
- type: (_j = slot.props) == null ? void 0 : _j.type,
95
- prop: (_k = slot.props) == null ? void 0 : _k.prop,
96
- label: ((_l = slot.props) == null ? void 0 : _l.label) || "",
97
- width: (_m = slot.props) == null ? void 0 : _m.width
123
+ type,
124
+ prop: (_h = slot.props) == null ? void 0 : _h.prop,
125
+ label: ((_i = slot.props) == null ? void 0 : _i.label) || "",
126
+ width: (_j = slot.props) == null ? void 0 : _j.width
98
127
  });
99
128
  groups.restLen += 1;
100
129
  groups.normal.push({
101
- isSlot: Boolean((_n = slot.children) == null ? void 0 : _n.default),
102
- prop: (_o = slot.props) == null ? void 0 : _o.prop,
130
+ isSlot: Boolean((_k = slot.children) == null ? void 0 : _k.default),
131
+ prop: (_l = slot.props) == null ? void 0 : _l.prop,
103
132
  slot
104
133
  });
105
134
  break;
106
135
  }
107
- };
108
- slots.default().forEach((node) => {
109
- if (node.shapeFlag & ShapeFlags.ARRAY_CHILDREN) {
110
- node.children.forEach(_categorizeSlot);
111
- } else if (node.shapeFlag & ShapeFlags.STATEFUL_COMPONENT) {
112
- _categorizeSlot(node);
113
- }
114
- });
136
+ }
115
137
  return groups;
116
138
  });
117
139
  const prependSlot = computed(() => groupedSlots.value.prepend);
118
140
  const appendSlot = computed(() => groupedSlots.value.append);
119
- const dynamicPre = (props2) => {
141
+ const dynamicPre = computed(() => (props2) => {
120
142
  var _a, _b, _c;
121
143
  return (_c = (_a = prependSlot.value) == null ? void 0 : (_b = _a.children).default) == null ? void 0 : _c.call(_b, props2);
122
- };
123
- const dynamicAppend = (props2) => {
144
+ });
145
+ const dynamicAppend = computed(() => (props2) => {
124
146
  var _a, _b, _c;
125
147
  return (_c = (_a = appendSlot.value) == null ? void 0 : (_b = _a.children).default) == null ? void 0 : _c.call(_b, props2);
126
- };
148
+ });
127
149
  const hasindexSlot = computed(() => groupedSlots.value.hasindex);
128
150
  const hascheckSlot = computed(() => groupedSlots.value.hascheck);
129
151
  const normalSlots = computed(() => groupedSlots.value.normal);
@@ -146,17 +168,19 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
146
168
  nextTick(() => {
147
169
  emit("finishRender");
148
170
  });
149
- const dynormalRenderHandle = (rowprops) => {
150
- return dynamicnormal.value.map((rh, _) => {
151
- return h(
152
- "td",
153
- {
154
- class: normalizeClass(["text-center py-2", props.cellclass])
155
- },
156
- rh({ row: rowprops.row, index: rowprops.rowindex })
157
- );
158
- });
159
- };
171
+ const dynormalRenderHandle = computed(() => {
172
+ return (rowprops) => {
173
+ return dynamicnormal.value.map((rh, _) => {
174
+ return h(
175
+ "td",
176
+ {
177
+ class: normalizeClass(["text-center py-2", props.cellclass])
178
+ },
179
+ rh({ row: rowprops.row, index: rowprops.rowindex })
180
+ );
181
+ });
182
+ };
183
+ });
160
184
  const getRowKey = (rowdata, index) => props.idKey ? `row_${rowdata[props.idKey]}` : `row_${index}`;
161
185
  const getPreRowkey = (rowdata, index) => props.idKey ? `prepend_${rowdata[props.idKey]}` : `prepend_${index}`;
162
186
  const getAppendRowkey = (rowdata, index) => props.idKey ? `append_${rowdata[props.idKey]}` : `append_${index}`;
@@ -240,7 +264,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
240
264
  return (_ctx, _cache) => {
241
265
  return openBlock(), createElementBlock(Fragment, null, [
242
266
  createElementVNode("table", {
243
- class: normalizeClass(["w-full text-sm", _ctx.tableclass])
267
+ class: normalizeClass(["w-full text-sm", __props.tableclass])
244
268
  }, [
245
269
  createElementVNode("colgroup", null, [
246
270
  (openBlock(true), createElementBlock(Fragment, null, renderList(cachedSlots.value, (i, j) => {
@@ -250,39 +274,41 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
250
274
  }, null, 8, _hoisted_1);
251
275
  }), 128))
252
276
  ]),
253
- _ctx.showHead ? (openBlock(), createElementBlock("thead", {
277
+ __props.showHead ? (openBlock(), createElementBlock("thead", {
254
278
  key: 0,
255
- class: normalizeClass(["text-word6", _ctx.headclass])
279
+ class: normalizeClass(["text-word6", __props.headclass])
256
280
  }, [
257
- (openBlock(true), createElementBlock(Fragment, null, renderList(cachedSlots.value, (i, j) => {
258
- return openBlock(), createElementBlock("th", {
259
- class: "font-normal h-10 border-b",
260
- key: j
261
- }, [
262
- i.type === "selection" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
263
- !_ctx.outSideCheck ? withDirectives((openBlock(), createElementBlock("input", {
264
- key: 0,
265
- type: "checkbox",
266
- class: "appearance-none form-tick h-4 w-4 border border-gray-300 rounded checked:border-transparent checked:bg-blue-600 focus:outline-none",
267
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => allSelect.value = $event)
268
- }, null, 512)), [
269
- [vModelCheckbox, allSelect.value]
270
- ]) : createCommentVNode("", true)
271
- ], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
272
- createTextVNode(toDisplayString(i.label), 1)
273
- ], 64))
274
- ]);
275
- }), 128))
281
+ createElementVNode("tr", null, [
282
+ (openBlock(true), createElementBlock(Fragment, null, renderList(cachedSlots.value, (i, j) => {
283
+ return openBlock(), createElementBlock("th", {
284
+ class: "font-normal h-10 border-b",
285
+ key: j
286
+ }, [
287
+ i.type === "selection" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
288
+ !__props.outSideCheck ? withDirectives((openBlock(), createElementBlock("input", {
289
+ key: 0,
290
+ type: "checkbox",
291
+ class: "appearance-none form-tick h-4 w-4 border border-gray-300 rounded checked:border-transparent checked:bg-blue-600 focus:outline-none",
292
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => allSelect.value = $event)
293
+ }, null, 512)), [
294
+ [vModelCheckbox, allSelect.value]
295
+ ]) : createCommentVNode("", true)
296
+ ], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
297
+ createTextVNode(toDisplayString(i.label), 1)
298
+ ], 64))
299
+ ]);
300
+ }), 128))
301
+ ])
276
302
  ], 2)) : createCommentVNode("", true),
277
303
  createElementVNode("tbody", null, [
278
- (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.data, (rowdata, rowindex) => {
304
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.data, (rowdata, rowindex) => {
279
305
  return openBlock(), createElementBlock(Fragment, {
280
306
  key: getRowKey(rowdata, rowindex)
281
307
  }, [
282
308
  prependSlot.value ? (openBlock(), createElementBlock("tr", _hoisted_2, [
283
309
  createElementVNode("td", { colspan: colSpan.value }, [
284
- (openBlock(), createBlock(dynamicPre, {
285
- row: markRaw(rowdata),
310
+ (openBlock(), createBlock(resolveDynamicComponent(dynamicPre.value), {
311
+ row: rowdata,
286
312
  index: rowindex,
287
313
  key: getPreRowkey(rowdata, rowindex)
288
314
  }, null, 8, ["row", "index"]))
@@ -290,28 +316,32 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
290
316
  ])) : createCommentVNode("", true),
291
317
  createElementVNode("tr", _hoisted_4, [
292
318
  hascheckSlot.value ? (openBlock(), createElementBlock("td", _hoisted_5, [
293
- createElementVNode("label", _hoisted_6, [
319
+ createElementVNode("label", {
320
+ class: "px-1",
321
+ for: `checkbox_${getRowKey(rowdata, rowindex)}`
322
+ }, [
294
323
  createElementVNode("input", {
295
324
  type: "checkbox",
296
- checked: choosedSet.value.has(_ctx.idKey ? rowdata[_ctx.idKey] : rowindex),
325
+ id: `checkbox_${getRowKey(rowdata, rowindex)}`,
326
+ checked: choosedSet.value.has(__props.idKey ? rowdata[__props.idKey] : rowindex),
297
327
  onChange: ($event) => checkChange($event, rowdata, rowindex),
298
328
  class: "appearance-none form-tick h-4 w-4 border border-gray-300 rounded checked:border-transparent checked:bg-blue-600 text-red-600 focus:outline-none"
299
329
  }, null, 40, _hoisted_7)
300
- ])
330
+ ], 8, _hoisted_6)
301
331
  ])) : createCommentVNode("", true),
302
332
  hasindexSlot.value ? (openBlock(), createElementBlock("td", _hoisted_8, [
303
333
  createElementVNode("div", null, toDisplayString(rowindex + 1), 1)
304
334
  ])) : createCommentVNode("", true),
305
- (openBlock(), createBlock(dynormalRenderHandle, {
306
- row: markRaw(rowdata),
335
+ (openBlock(), createBlock(resolveDynamicComponent(dynormalRenderHandle.value), {
336
+ row: rowdata,
307
337
  rowindex,
308
338
  key: getRowKey(rowdata, rowindex)
309
339
  }, null, 8, ["row", "rowindex"]))
310
340
  ]),
311
341
  appendSlot.value ? (openBlock(), createElementBlock("tr", _hoisted_9, [
312
342
  createElementVNode("td", { colspan: colSpan.value }, [
313
- (openBlock(), createBlock(dynamicAppend, {
314
- row: markRaw(rowdata),
343
+ (openBlock(), createBlock(resolveDynamicComponent(dynamicAppend.value), {
344
+ row: rowdata,
315
345
  index: rowindex,
316
346
  key: getAppendRowkey(rowdata, rowindex)
317
347
  }, null, 8, ["row", "index"]))
@@ -15,8 +15,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
15
15
  setup(__props) {
16
16
  return (_ctx, _cache) => {
17
17
  return renderSlot(_ctx.$slots, "default", {
18
- row: _ctx.row,
19
- index: _ctx.index
18
+ row: __props.row,
19
+ index: __props.index
20
20
  });
21
21
  };
22
22
  }
@@ -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
  ]);