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, ref, computed, watch, nextTick, onUnmounted, openBlock, createElementBlock, withModifiers, renderSlot, createBlock, Teleport, createVNode, Transition, withCtx, withDirectives, normalizeClass, normalizeStyle, createCommentVNode } from "vue";
1
+ import { defineComponent, ref, computed, nextTick, onUnmounted, openBlock, createElementBlock, withModifiers, renderSlot, createBlock, Teleport, Transition, withCtx, withDirectives, normalizeClass, normalizeStyle, createCommentVNode, vShow } from "vue";
2
2
  import { u as usePotion, t as throttle } from "../index/index.js";
3
3
  const _hoisted_1 = ["onMouseenter"];
4
4
  const _sfc_main = /* @__PURE__ */ defineComponent({
@@ -9,7 +9,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
9
9
  placement: { default: "topleft" },
10
10
  insertClass: {},
11
11
  beforeHidden: {},
12
- modelValue: { type: Boolean }
12
+ modelValue: { type: Boolean },
13
+ vIF: { type: Boolean, default: true }
13
14
  },
14
15
  emits: ["update:modelValue"],
15
16
  setup(__props, { expose: __expose, emit: emitAct }) {
@@ -17,7 +18,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
17
18
  const base = ref();
18
19
  const pop = ref();
19
20
  const showPop = ref(false);
20
- const showPopFlag = computed(() => {
21
+ const trueFlag = computed(() => {
22
+ if (showPop.value || props.trigger === "native" && props.modelValue) {
23
+ nextTick(() => {
24
+ setPosition();
25
+ });
26
+ } else {
27
+ window.removeEventListener("resize", setPosition);
28
+ window.removeEventListener("scroll", setPosition, true);
29
+ }
21
30
  if (props.trigger === "native") {
22
31
  return props.modelValue;
23
32
  } else {
@@ -56,29 +65,23 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
56
65
  };
57
66
  const Left = ref(0);
58
67
  const Top = ref(0);
59
- watch(showPopFlag, (n) => {
60
- if (n === true) {
61
- nextTick(() => {
62
- setPosition();
63
- if (props.trigger === "hover")
64
- return;
65
- window.addEventListener("resize", setPosition);
66
- window.addEventListener("scroll", setPosition, true);
67
- });
68
- }
69
- });
70
68
  const setPosition = () => {
71
- let { top, bottom } = base.value.getBoundingClientRect();
69
+ if (!pop.value) {
70
+ window.removeEventListener("resize", setPosition);
71
+ window.removeEventListener("scroll", setPosition, true);
72
+ return;
73
+ }
74
+ const { top, bottom } = base.value.getBoundingClientRect();
72
75
  if (top < 0 || bottom > window.innerHeight) {
73
76
  if (props.trigger === "native") {
74
77
  emitAct("update:modelValue", false);
75
78
  } else {
76
79
  showPop.value = false;
77
80
  }
78
- window.removeEventListener("resize", setPosition);
79
- window.removeEventListener("scroll", setPosition, true);
80
81
  return;
81
82
  }
83
+ window.addEventListener("resize", setPosition);
84
+ window.addEventListener("scroll", setPosition, true);
82
85
  const position = usePotion(base.value, pop.value, {
83
86
  position: props.placement
84
87
  });
@@ -87,6 +90,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
87
90
  };
88
91
  const vClickoutside = {
89
92
  mounted(el, binding) {
93
+ if (!(el instanceof HTMLElement)) {
94
+ console.error("el must be an instance of HTMLElement");
95
+ return;
96
+ }
90
97
  function documentHandler(e) {
91
98
  if ((el == null ? void 0 : el.contains) && (el == null ? void 0 : el.contains(e.target))) {
92
99
  return false;
@@ -105,6 +112,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
105
112
  }
106
113
  },
107
114
  beforeUnmount(el) {
115
+ if (!(el instanceof HTMLElement)) {
116
+ console.error("el must be an instance of HTMLElement");
117
+ return;
118
+ }
108
119
  document.removeEventListener("click", el._vueClickOutside_);
109
120
  switch (props.trigger) {
110
121
  case "hover":
@@ -125,8 +136,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
125
136
  if (disablecancelflag === true) {
126
137
  return;
127
138
  } else {
128
- window.removeEventListener("resize", setPosition);
129
- window.removeEventListener("scroll", setPosition, true);
130
139
  if (props.trigger === "native") {
131
140
  emitAct("update:modelValue", false);
132
141
  } else {
@@ -168,11 +177,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
168
177
  renderSlot(_ctx.$slots, "reference"),
169
178
  (openBlock(), createBlock(Teleport, {
170
179
  to: "body",
171
- disabled: !showPopFlag.value
180
+ disabled: !trueFlag.value
172
181
  }, [
173
- createVNode(Transition, { name: "opecity" }, {
182
+ _ctx.vIF ? (openBlock(), createBlock(Transition, {
183
+ key: 0,
184
+ name: "opecity"
185
+ }, {
174
186
  default: withCtx(() => [
175
- showPopFlag.value ? withDirectives((openBlock(), createElementBlock("div", {
187
+ trueFlag.value ? withDirectives((openBlock(), createElementBlock("div", {
176
188
  key: 0,
177
189
  ref_key: "pop",
178
190
  ref: pop,
@@ -185,7 +197,25 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
185
197
  ]) : createCommentVNode("", true)
186
198
  ]),
187
199
  _: 3
188
- })
200
+ })) : (openBlock(), createBlock(Transition, {
201
+ key: 1,
202
+ name: "opecity"
203
+ }, {
204
+ default: withCtx(() => [
205
+ withDirectives((openBlock(), createElementBlock("div", {
206
+ ref_key: "pop",
207
+ ref: pop,
208
+ class: normalizeClass(["tdd-absolute tdd-z-1000 tdd-rounded tdd-bg-white tdd-p-4 tdd-drop-shadow", [marginClass.value, _ctx.insertClass]]),
209
+ style: normalizeStyle({ width: widthNum.value, top: `${Top.value}px`, left: `${Left.value}px` })
210
+ }, [
211
+ renderSlot(_ctx.$slots, "default")
212
+ ], 6)), [
213
+ [vShow, trueFlag.value],
214
+ [vClickoutside, closeCenter]
215
+ ])
216
+ ]),
217
+ _: 3
218
+ }))
189
219
  ], 8, ["disabled"]))
190
220
  ], 40, _hoisted_1);
191
221
  };
@@ -1,4 +1,4 @@
1
- import { defineComponent, inject, useSlots, openBlock, createBlock, h, withDirectives, vModelRadio } from "vue";
1
+ import { defineComponent, inject, useSlots, openBlock, createBlock, h, normalizeClass, withDirectives, vModelRadio } from "vue";
2
2
  const _sfc_main = /* @__PURE__ */ defineComponent({
3
3
  __name: "radiogroup",
4
4
  props: {
@@ -10,80 +10,49 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
10
10
  const props = __props;
11
11
  const ParentGetChangeHandle = inject("changHandle", () => null);
12
12
  const slots = useSlots();
13
+ const BoxHandle = (MySlot) => {
14
+ var _a, _b;
15
+ return h(
16
+ "label",
17
+ {
18
+ class: normalizeClass(["radioGroup", [(_a = MySlot.props) == null ? void 0 : _a.class, props.modelValue == MySlot.props.label ? " tdd-bg-wordblue" : ""]])
19
+ },
20
+ [
21
+ withDirectives(
22
+ h("input", {
23
+ type: "radio",
24
+ value: MySlot.props.label,
25
+ "onUpdate:modelValue": (value) => {
26
+ ParentGetChangeHandle(value);
27
+ emit("update:modelValue", value);
28
+ },
29
+ class: normalizeClass(["hiddeninput form-tick", [props.showinput ? "" : " tdd-hidden"]])
30
+ }),
31
+ [[vModelRadio, props.modelValue]]
32
+ ),
33
+ h(
34
+ "span",
35
+ {
36
+ class: normalizeClass(["tdd-text-sm", [props.modelValue == MySlot.props.label ? " tdd-text-white" : " tdd-text-word6"]])
37
+ },
38
+ ((_b = MySlot.children) == null ? void 0 : _b.default()) || MySlot.props.label
39
+ )
40
+ ]
41
+ );
42
+ };
13
43
  const renderBoxs = () => {
14
44
  return h(
15
45
  "div",
16
46
  {},
17
47
  slots.default().map((MySlot) => {
18
- var _a, _b;
19
- if (MySlot.type.toString().includes("Symbol")) {
20
- if (MySlot.children && MySlot.children instanceof Array) {
21
- return MySlot.children.map((trueSlot) => {
22
- var _a2;
23
- return h(
24
- "label",
25
- {
26
- class: "radioGroup " + // @ts-ignore
27
- (trueSlot.props.class || "") + // @ts-ignore
28
- (props.modelValue == trueSlot.props.label ? " tdd-bg-wordblue" : "")
29
- },
30
- [
31
- withDirectives(
32
- h("input", {
33
- type: "radio",
34
- // @ts-ignore
35
- value: trueSlot.props.label,
36
- "onUpdate:modelValue": (value) => {
37
- ParentGetChangeHandle(value);
38
- emit("update:modelValue", value);
39
- },
40
- class: "hiddeninput form-tick" + // @ts-ignore
41
- (props.showinput ? "" : " tdd-hidden")
42
- }),
43
- [[vModelRadio, props.modelValue]]
44
- ),
45
- h(
46
- "span",
47
- {
48
- class: "tdd-text-sm " + // @ts-ignore
49
- (props.modelValue == trueSlot.props.label ? " tdd-text-white" : " tdd-text-word6")
50
- },
51
- // @ts-ignore
52
- ((_a2 = trueSlot.children) == null ? void 0 : _a2.default()) || trueSlot.props.label
53
- )
54
- ]
55
- );
56
- });
57
- }
48
+ if (typeof MySlot.children === "string")
49
+ return null;
50
+ if (Array.isArray(MySlot.children)) {
51
+ return MySlot.children.map((slot) => {
52
+ return BoxHandle(slot);
53
+ });
58
54
  } else {
59
- return h(
60
- "label",
61
- {
62
- class: "radioGroup " + (((_a = MySlot.props) == null ? void 0 : _a.class) || "") + (props.modelValue == MySlot.props.label ? " tdd-bg-wordblue" : "")
63
- },
64
- [
65
- withDirectives(
66
- h("input", {
67
- type: "radio",
68
- value: MySlot.props.label,
69
- "onUpdate:modelValue": (value) => {
70
- ParentGetChangeHandle(value);
71
- emit("update:modelValue", value);
72
- },
73
- class: "hiddeninput form-tick" + (props.showinput ? "" : " tdd-hidden")
74
- }),
75
- [[vModelRadio, props.modelValue]]
76
- ),
77
- h(
78
- "span",
79
- {
80
- class: "tdd-text-sm " + (props.modelValue == MySlot.props.label ? " tdd-text-white" : " tdd-text-word6")
81
- },
82
- // @ts-ignore
83
- ((_b = MySlot.children) == null ? void 0 : _b.default()) || MySlot.props.label
84
- )
85
- ]
86
- );
55
+ return BoxHandle(MySlot);
87
56
  }
88
57
  })
89
58
  );
@@ -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, normalizeClass } from "vue";
2
2
  const _hoisted_1 = ["value", "disabled", "readonly", "placeholder"];
3
3
  const _sfc_main = /* @__PURE__ */ defineComponent({
4
4
  __name: "select",
@@ -29,67 +29,58 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
29
29
  const isThis = optionList.value.filter((v) => v.value === props.modelValue);
30
30
  if (isThis.length > 0) {
31
31
  return isThis[0].label;
32
+ } else if (props.modelValue) {
33
+ return;
32
34
  } else {
35
+ emit("update:modelValue", null);
36
+ ParentGetChangeHandle && ParentGetChangeHandle(null);
37
+ emit("change", null);
33
38
  return null;
34
39
  }
35
40
  });
36
41
  const optionList = ref([]);
42
+ const optionHandle = (it) => {
43
+ optionList.value.push({
44
+ value: it.props.value,
45
+ label: it.props.label
46
+ });
47
+ return h(
48
+ "div",
49
+ {
50
+ class: normalizeClass(["label", [props.modelValue === it.props.value ? "labelselect" : ""]]),
51
+ key: it.props.key,
52
+ onClick: () => {
53
+ emit("update:modelValue", it.props.value);
54
+ ParentGetChangeHandle && ParentGetChangeHandle(it.props.value);
55
+ emit("change", it.props.value);
56
+ showOption.value = false;
57
+ }
58
+ },
59
+ it.children || it.props.label
60
+ );
61
+ };
37
62
  const renderOption = () => {
38
63
  return h(
39
64
  "div",
40
65
  {
41
66
  class: "selectOption"
42
67
  },
43
- 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
- );
68
+ slots.default().map((i, _j) => {
69
+ if (typeof i.children == "string")
70
+ return null;
71
+ if (Array.isArray(i.children)) {
72
+ return i.children.map((it) => {
73
+ return optionHandle(it);
62
74
  });
63
75
  } 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
- );
76
+ return optionHandle(i);
80
77
  }
81
78
  })
82
79
  );
83
80
  };
84
- watch(
85
- () => props.modelValue,
86
- (n) => {
87
- ParentGetChangeHandle && ParentGetChangeHandle(n);
88
- emit("change", n);
89
- }
90
- );
91
81
  return (_ctx, _cache) => {
92
82
  return openBlock(), createBlock(unref(Pop), {
83
+ vIF: false,
93
84
  trigger: "native",
94
85
  modelValue: showOption.value,
95
86
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => showOption.value = $event),
@@ -22,47 +22,64 @@ 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
- { 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
- );
44
+ {
45
+ class: normalizeClass(["tdd-text-word6", [props.headclass]])
46
+ },
47
+ slots.default().map((it) => {
48
+ if (typeof it.children == "string")
49
+ return null;
50
+ if (Array.isArray(it.children)) {
51
+ return it.children.map((itt) => {
52
+ return headitemHandle(itt);
53
+ });
54
+ } else {
55
+ return headitemHandle(it);
56
+ }
63
57
  })
64
58
  );
65
59
  };
60
+ const headitemHandle = (it) => {
61
+ var _a;
62
+ return h(
63
+ "th",
64
+ {
65
+ class: "tdd-font-normal tdd-h-10 tdd-border-b "
66
+ },
67
+ it.children && it.children.head ? it.children.head() : ((_a = it.props) == null ? void 0 : _a.type) && it.props.type === "selection" ? h(
68
+ "label",
69
+ {
70
+ class: "tdd-px-1 tdd-flex"
71
+ },
72
+ withDirectives(
73
+ h("input", {
74
+ type: "checkbox",
75
+ "onUpdate:modelValue": (value) => allSelect.value = value,
76
+ 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"
77
+ }),
78
+ [[vModelCheckbox, allSelect.value]]
79
+ )
80
+ ) : it.props.label
81
+ );
82
+ };
66
83
  const allSelect = computed({
67
84
  set(flag) {
68
85
  if (flag) {
@@ -121,47 +138,54 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
121
138
  }, ["stop"])
122
139
  },
123
140
  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
- );
141
+ if (typeof it.children == "string")
142
+ return null;
143
+ if (Array.isArray(it.children)) {
144
+ return it.children.map((itt) => {
145
+ return bodyHandle(row, itt, i);
146
+ });
147
+ } else {
148
+ return bodyHandle(row, it, i);
149
+ }
160
150
  })
161
151
  );
162
152
  })
163
153
  );
164
154
  };
155
+ const bodyHandle = (row, it, i) => {
156
+ var _a;
157
+ return h(
158
+ "td",
159
+ {
160
+ class: normalizeClass(["tdd-text-center tdd-py-2", [props.cellclass]])
161
+ },
162
+ ((_a = it.props) == null ? void 0 : _a.type) && it.props.type === "selection" ? h(
163
+ "label",
164
+ {
165
+ class: "tdd-px-1 tdd-flex",
166
+ for: "checkbox"
167
+ },
168
+ withDirectives(
169
+ h("input", {
170
+ type: "checkbox",
171
+ value: i,
172
+ "onUpdate:modelValue": (value) => {
173
+ choosed.value = value;
174
+ },
175
+ 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 "
176
+ }),
177
+ [[vModelCheckbox, choosed.value]]
178
+ )
179
+ ) : h(
180
+ "div",
181
+ null,
182
+ it.children && it.children.default ? it.children.default({
183
+ row,
184
+ index: i
185
+ }) : row[it.props.prop] != null ? row[it.props.prop] : props.whiteword
186
+ )
187
+ );
188
+ };
165
189
  __expose({
166
190
  clearSelection,
167
191
  allSelection,