ninemoon-ui 0.0.7 → 0.0.9

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, defineAsyncComponent, inject, useSlots, ref, computed, watch, openBlock, createBlock, unref, withCtx, createElementVNode, createVNode, h } from "vue";
1
+ import { defineComponent, defineAsyncComponent, inject, useSlots, ref, computed, openBlock, createBlock, unref, withCtx, createElementVNode, createVNode, h } from "vue";
2
2
  const _hoisted_1 = ["value", "disabled", "readonly", "placeholder"];
3
3
  const _sfc_main = /* @__PURE__ */ defineComponent({
4
4
  __name: "select",
@@ -30,10 +30,33 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
30
30
  if (isThis.length > 0) {
31
31
  return isThis[0].label;
32
32
  } else {
33
+ emit("update:modelValue", null);
34
+ ParentGetChangeHandle && ParentGetChangeHandle(null);
35
+ emit("change", null);
33
36
  return null;
34
37
  }
35
38
  });
36
39
  const optionList = ref([]);
40
+ const optionHandle = (it) => {
41
+ optionList.value.push({
42
+ value: it.props.value,
43
+ label: it.props.label
44
+ });
45
+ return h(
46
+ "div",
47
+ {
48
+ class: `label ${props.modelValue === it.props.value ? "labelselect" : ""}`,
49
+ key: it.props.key,
50
+ onClick: () => {
51
+ emit("update:modelValue", it.props.value);
52
+ ParentGetChangeHandle && ParentGetChangeHandle(it.props.value);
53
+ emit("change", it.props.value);
54
+ showOption.value = false;
55
+ }
56
+ },
57
+ it.children || it.props.label
58
+ );
59
+ };
37
60
  const renderOption = () => {
38
61
  return h(
39
62
  "div",
@@ -41,53 +64,18 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
41
64
  class: "selectOption"
42
65
  },
43
66
  slots.default().map((i, j) => {
44
- if (i.type.toString().includes("Symbol")) {
45
- return i.children.map((it, k) => {
46
- optionList.value.push({
47
- value: it.props.value,
48
- label: it.props.label
49
- });
50
- return h(
51
- "div",
52
- {
53
- class: `label ${props.modelValue === it.props.value ? "labelselect" : ""}`,
54
- key: `${j}-${k}`,
55
- onClick: () => {
56
- emit("update:modelValue", it.props.value);
57
- showOption.value = false;
58
- }
59
- },
60
- it.children || it.props.label
61
- );
67
+ if (typeof i.children == "string")
68
+ return null;
69
+ if (Array.isArray(i.children)) {
70
+ return i.children.map((it) => {
71
+ return optionHandle(it);
62
72
  });
63
73
  } else {
64
- optionList.value.push({
65
- value: i.props.value,
66
- label: i.props.label
67
- });
68
- return h(
69
- "div",
70
- {
71
- class: `label ${props.modelValue === i.props.value ? "labelselect" : ""}`,
72
- key: j,
73
- onClick: () => {
74
- emit("update:modelValue", i.props.value);
75
- showOption.value = false;
76
- }
77
- },
78
- i.children || i.props.label
79
- );
74
+ return optionHandle(i);
80
75
  }
81
76
  })
82
77
  );
83
78
  };
84
- watch(
85
- () => props.modelValue,
86
- (n) => {
87
- ParentGetChangeHandle && ParentGetChangeHandle(n);
88
- emit("change", n);
89
- }
90
- );
91
79
  return (_ctx, _cache) => {
92
80
  return openBlock(), createBlock(unref(Pop), {
93
81
  trigger: "native",
@@ -22,47 +22,62 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
22
22
  "colgroup",
23
23
  null,
24
24
  slots.default().map((it, _index) => {
25
- var _a;
26
- return h("col", {
27
- width: ((_a = it.props) == null ? void 0 : _a.width) || null
28
- });
25
+ if (typeof it.children == "string")
26
+ return null;
27
+ if (Array.isArray(it.children)) {
28
+ return it.children.map((itt, _i) => colitemHandle(itt));
29
+ } else {
30
+ return colitemHandle(it);
31
+ }
29
32
  })
30
33
  );
31
34
  };
35
+ const colitemHandle = (it) => {
36
+ var _a;
37
+ return h("col", {
38
+ width: ((_a = it.props) == null ? void 0 : _a.width) || null
39
+ });
40
+ };
32
41
  const renderHead = () => {
33
42
  return h(
34
43
  "thead",
35
44
  { class: props.headclass ? `tdd-text-word6 ${props.headclass}` : "tdd-text-word6" },
36
- slots.default().map((it, index) => {
37
- var _a;
38
- return h(
39
- "th",
40
- {
41
- class: "tdd-font-normal tdd-h-10 tdd-border-b ",
42
- key: index
43
- },
44
- // @ts-ignore
45
- it.children && it.children.head ? (
46
- // @ts-ignore
47
- it.children.head()
48
- ) : ((_a = it.props) == null ? void 0 : _a.type) && it.props.type === "selection" ? h(
49
- "label",
50
- {
51
- class: "tdd-px-1 tdd-flex"
52
- },
53
- withDirectives(
54
- h("input", {
55
- type: "checkbox",
56
- "onUpdate:modelValue": (value) => allSelect.value = value,
57
- class: "tdd-appearance-none form-tick tdd-h-4 tdd-w-4 tdd-border tdd-border-gray-300 tdd-rounded checked:tdd-border-transparent checked:tdd-bg-red-600 tdd-text-red-600 focus:tdd-outline-none"
58
- }),
59
- [[vModelCheckbox, allSelect.value]]
60
- )
61
- ) : it.props.label
62
- );
45
+ slots.default().map((it) => {
46
+ if (typeof it.children == "string")
47
+ return null;
48
+ if (Array.isArray(it.children)) {
49
+ return it.children.map((itt) => {
50
+ return headitemHandle(itt);
51
+ });
52
+ } else {
53
+ return headitemHandle(it);
54
+ }
63
55
  })
64
56
  );
65
57
  };
58
+ const headitemHandle = (it) => {
59
+ var _a;
60
+ return h(
61
+ "th",
62
+ {
63
+ class: "tdd-font-normal tdd-h-10 tdd-border-b "
64
+ },
65
+ it.children && it.children.head ? it.children.head() : ((_a = it.props) == null ? void 0 : _a.type) && it.props.type === "selection" ? h(
66
+ "label",
67
+ {
68
+ class: "tdd-px-1 tdd-flex"
69
+ },
70
+ withDirectives(
71
+ h("input", {
72
+ type: "checkbox",
73
+ "onUpdate:modelValue": (value) => allSelect.value = value,
74
+ class: "tdd-appearance-none form-tick tdd-h-4 tdd-w-4 tdd-border tdd-border-gray-300 tdd-rounded checked:tdd-border-transparent checked:tdd-bg-red-600 tdd-text-red-600 focus:tdd-outline-none"
75
+ }),
76
+ [[vModelCheckbox, allSelect.value]]
77
+ )
78
+ ) : it.props.label
79
+ );
80
+ };
66
81
  const allSelect = computed({
67
82
  set(flag) {
68
83
  if (flag) {
@@ -121,47 +136,54 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
121
136
  }, ["stop"])
122
137
  },
123
138
  slots.default().map((it, _j) => {
124
- var _a;
125
- return h(
126
- "td",
127
- {
128
- class: props.cellclass ? `tdd-text-center tdd-py-2 ${props.cellclass}` : "tdd-text-center tdd-py-2"
129
- },
130
- ((_a = it.props) == null ? void 0 : _a.type) && it.props.type === "selection" ? h(
131
- "label",
132
- {
133
- class: "tdd-px-1 tdd-flex",
134
- for: "checkbox"
135
- },
136
- withDirectives(
137
- h("input", {
138
- type: "checkbox",
139
- value: i,
140
- "onUpdate:modelValue": (value) => {
141
- choosed.value = value;
142
- },
143
- class: "tdd-appearance-none form-tick tdd-h-4 tdd-w-4 tdd-border tdd-border-gray-300 tdd-rounded checked:tdd-border-transparent checked:tdd-bg-red-600 tdd-text-red-600 focus:tdd-outline-none "
144
- }),
145
- [[vModelCheckbox, choosed.value]]
146
- )
147
- ) : h(
148
- "div",
149
- null,
150
- // @ts-ignore
151
- it.children && it.children.default ? (
152
- // @ts-ignore
153
- it.children.default({
154
- row,
155
- index: i
156
- })
157
- ) : row[it.props.prop] != null ? row[it.props.prop] : props.whiteword
158
- )
159
- );
139
+ if (typeof it.children == "string")
140
+ return null;
141
+ if (Array.isArray(it.children)) {
142
+ return it.children.map((itt) => {
143
+ return bodyHandle(row, itt, i);
144
+ });
145
+ } else {
146
+ return bodyHandle(row, it, i);
147
+ }
160
148
  })
161
149
  );
162
150
  })
163
151
  );
164
152
  };
153
+ const bodyHandle = (row, it, i) => {
154
+ var _a;
155
+ return h(
156
+ "td",
157
+ {
158
+ class: props.cellclass ? `tdd-text-center tdd-py-2 ${props.cellclass}` : "tdd-text-center tdd-py-2"
159
+ },
160
+ ((_a = it.props) == null ? void 0 : _a.type) && it.props.type === "selection" ? h(
161
+ "label",
162
+ {
163
+ class: "tdd-px-1 tdd-flex",
164
+ for: "checkbox"
165
+ },
166
+ withDirectives(
167
+ h("input", {
168
+ type: "checkbox",
169
+ value: i,
170
+ "onUpdate:modelValue": (value) => {
171
+ choosed.value = value;
172
+ },
173
+ class: "tdd-appearance-none form-tick tdd-h-4 tdd-w-4 tdd-border tdd-border-gray-300 tdd-rounded checked:tdd-border-transparent checked:tdd-bg-red-600 tdd-text-red-600 focus:tdd-outline-none "
174
+ }),
175
+ [[vModelCheckbox, choosed.value]]
176
+ )
177
+ ) : h(
178
+ "div",
179
+ null,
180
+ it.children && it.children.default ? it.children.default({
181
+ row,
182
+ index: i
183
+ }) : row[it.props.prop] != null ? row[it.props.prop] : props.whiteword
184
+ )
185
+ );
186
+ };
165
187
  __expose({
166
188
  clearSelection,
167
189
  allSelection,
@@ -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, Fragment, createTextVNode, toDisplayString, createElementVNode, createVNode, normalizeStyle, createCommentVNode, h, 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) {
@@ -59,17 +75,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
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,84 +91,84 @@ 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: `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) => {
140
- return openBlock(), createElementBlock("div", _hoisted_1, [
141
- createVNode(renderBar, {
142
- ref_key: "btnBar",
143
- ref: btnBar
144
- }, null, 512),
145
- showBaseline.value ? (openBlock(), createElementBlock("div", _hoisted_2, [
146
- createElementVNode("div", {
147
- class: "tdd-absolute tdd-bottom-0 tdd-border-t-2 tdd-border-solid tdd-border-blue-brand tdd-transition",
148
- style: normalizeStyle({
149
- transform: `translateX(${arrowNum.value}px`,
150
- width: `${arrowWidth.value}px`
151
- })
152
- }, null, 4)
153
- ])) : createCommentVNode("", true),
154
- createElementVNode("div", _hoisted_3, [
155
- createVNode(renderContent)
151
+ return openBlock(), createElementBlock(Fragment, null, [
152
+ createTextVNode(toDisplayString(noactive.value) + " ", 1),
153
+ createElementVNode("div", _hoisted_1, [
154
+ createVNode(renderBar, {
155
+ ref_key: "btnBar",
156
+ ref: btnBar
157
+ }, null, 512),
158
+ showBaseline.value ? (openBlock(), createElementBlock("div", _hoisted_2, [
159
+ createElementVNode("div", {
160
+ class: "tdd-absolute tdd-bottom-0 tdd-border-t-2 tdd-border-solid tdd-border-blue-brand tdd-transition",
161
+ style: normalizeStyle({
162
+ transform: `translateX(${arrowNum.value}px`,
163
+ width: `${arrowWidth.value}px`
164
+ })
165
+ }, null, 4)
166
+ ])) : createCommentVNode("", true),
167
+ createElementVNode("div", _hoisted_3, [
168
+ createVNode(renderContent)
169
+ ])
156
170
  ])
157
- ]);
171
+ ], 64);
158
172
  };
159
173
  }
160
174
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ninemoon-ui",
3
3
  "private": false,
4
- "version": "0.0.7",
4
+ "version": "0.0.9",
5
5
  "author": "zhuboy",
6
6
  "keywords": [
7
7
  "vue3",