ninemoon-ui 0.0.8 → 0.0.10

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,4 @@
1
- import { defineComponent, computed, ref, useSlots, onMounted, openBlock, createElementBlock, createVNode, createElementVNode, normalizeStyle, createCommentVNode, h, withDirectives, vShow } from "vue";
1
+ import { defineComponent, computed, ref, useSlots, onMounted, openBlock, createElementBlock, createVNode, createElementVNode, normalizeStyle, createCommentVNode, h, normalizeClass, withDirectives, vShow } from "vue";
2
2
  const _hoisted_1 = { class: "tdd-relative tdd-w-full tdd-overflow-hidden" };
3
3
  const _hoisted_2 = {
4
4
  key: 0,
@@ -8,23 +8,39 @@ const _hoisted_3 = { class: "tdd-relative tdd-w-full" };
8
8
  const _sfc_main = /* @__PURE__ */ defineComponent({
9
9
  __name: "tabs",
10
10
  props: {
11
- active: {},
12
- default: {},
11
+ active: { default: "" },
13
12
  type: { default: "line" }
14
13
  },
15
14
  emits: ["update:active"],
16
15
  setup(__props, { emit }) {
17
16
  const props = __props;
18
17
  const showBaseline = computed(() => props.type === "line");
19
- const currentActive = ref(props.default || "");
20
- const activeIndex = ref(0);
21
- const arrowNum = ref(8);
22
- const arrowWidth = ref(0);
23
18
  const changeHandle = (name) => {
24
19
  emit("update:active", name);
25
20
  };
21
+ const noactive = ref(props.active === "");
22
+ const activename = ref("");
23
+ const currentActive = computed({
24
+ set(val) {
25
+ if (noactive.value) {
26
+ activename.value = val;
27
+ } else {
28
+ changeHandle(val);
29
+ }
30
+ },
31
+ get() {
32
+ if (noactive.value) {
33
+ return activename.value;
34
+ } else {
35
+ return props.active;
36
+ }
37
+ }
38
+ });
39
+ const activeIndex = ref(0);
40
+ const arrowNum = ref(8);
41
+ const arrowWidth = ref(0);
26
42
  const slots = useSlots();
27
- const renderBtn = (name, index) => {
43
+ const renderBtn = (node, index) => {
28
44
  let btc = [];
29
45
  let divc = [];
30
46
  switch (props.type) {
@@ -53,23 +69,21 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
53
69
  "button",
54
70
  {
55
71
  type: "button",
56
- class: btc.join(" "),
72
+ class: normalizeClass(btc),
57
73
  onClick: (e) => {
58
74
  activeIndex.value = index;
59
75
  let aim = e.target;
60
76
  arrowWidth.value = aim.offsetWidth;
61
77
  arrowNum.value = aim.offsetLeft;
62
- changeHandle(name);
63
- currentActive.value = name;
78
+ currentActive.value = node.props.name;
64
79
  }
65
- // key: index,
66
80
  },
67
81
  h(
68
82
  "span",
69
83
  {
70
84
  class: divc.join(" ")
71
85
  },
72
- name
86
+ node.props.name
73
87
  )
74
88
  );
75
89
  };
@@ -77,63 +91,60 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
77
91
  return h(
78
92
  "div",
79
93
  {
80
- class: `ETab${props.type === "line" ? " px-2 pt-2" : " ETab_Card"}`
94
+ class: normalizeClass(["ETab", [props.type === "line" ? " tdd-px-2 tdd-pt-2" : " ETab_Card"]])
81
95
  },
82
96
  slots.default().map((it, index) => {
83
- var _a;
84
- if (it.type.toString().includes("Symbol")) {
97
+ if (typeof it.children == "string")
98
+ return null;
99
+ if (Array.isArray(it.children)) {
85
100
  return it.children.map((simple, i) => {
86
- return renderBtn(simple.props.name, i);
101
+ return renderBtn(simple, i);
87
102
  });
88
103
  } else {
89
- return renderBtn((_a = it.props) == null ? void 0 : _a.name, index);
104
+ return renderBtn(it, index);
90
105
  }
91
106
  })
92
107
  );
93
108
  };
109
+ const contentHandle = (it, i) => {
110
+ if (currentActive.value === "") {
111
+ activeIndex.value = i;
112
+ currentActive.value = it.props.name;
113
+ } else if (currentActive.value === it.props.name) {
114
+ activeIndex.value = i;
115
+ }
116
+ return withDirectives(
117
+ h(it, {
118
+ key: it.props.name
119
+ }),
120
+ [[vShow, currentActive.value === "" || currentActive.value === it.props.name]]
121
+ );
122
+ };
94
123
  const renderContent = () => {
124
+ let defaultindex = -1;
95
125
  return h(
96
126
  "div",
97
127
  {},
98
- slots.default().map((it, index) => {
99
- var _a, _b;
100
- if (it.type.toString().includes("Symbol")) {
101
- return it.children.map((simple, i) => {
102
- if (currentActive.value === "") {
103
- activeIndex.value = i;
104
- currentActive.value = simple.props.name;
105
- } else if (currentActive.value === simple.props.name) {
106
- activeIndex.value = i;
107
- }
108
- return withDirectives(
109
- h(simple, {
110
- key: simple.props.name
111
- }),
112
- [[vShow, currentActive.value === "" || currentActive.value === simple.props.name]]
113
- );
128
+ slots.default().map((it, _) => {
129
+ if (typeof it.children == "string")
130
+ return null;
131
+ if (Array.isArray(it.children)) {
132
+ return it.children.map((itt, _i) => {
133
+ defaultindex += 1;
134
+ return contentHandle(itt, defaultindex);
114
135
  });
115
136
  } else {
116
- if (currentActive.value === "") {
117
- activeIndex.value = index;
118
- currentActive.value = (_a = it.props) == null ? void 0 : _a.name;
119
- } else if (currentActive.value === ((_b = it.props) == null ? void 0 : _b.name)) {
120
- activeIndex.value = index;
121
- }
122
- return withDirectives(
123
- h(it, {
124
- key: it.props.name
125
- }),
126
- [[vShow, currentActive.value === "" || currentActive.value === it.props.name]]
127
- );
137
+ defaultindex += 1;
138
+ return contentHandle(it, defaultindex);
128
139
  }
129
140
  })
130
141
  );
131
142
  };
132
143
  const btnBar = ref();
133
144
  onMounted(() => {
134
- if (props.type === "line") {
145
+ if (showBaseline.value) {
135
146
  const aim = btnBar.value.children[activeIndex.value];
136
- arrowWidth.value = aim.children[0].innerHTML.length * 14 + 16;
147
+ arrowWidth.value = aim.children[0].innerHTML.length * 14;
137
148
  }
138
149
  });
139
150
  return (_ctx, _cache) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ninemoon-ui",
3
3
  "private": false,
4
- "version": "0.0.8",
4
+ "version": "0.0.10",
5
5
  "author": "zhuboy",
6
6
  "keywords": [
7
7
  "vue3",