ct-component-plus 2.1.9 → 2.1.11

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ct-component-plus",
3
3
  "private": false,
4
- "version": "2.1.9",
4
+ "version": "2.1.11",
5
5
  "type": "module",
6
6
  "main": "packages/components/index.js",
7
7
  "files": [
@@ -5,6 +5,7 @@
5
5
  ns.b(),
6
6
  ns.is('disabled', disabled),
7
7
  ns.is('filterable', filterable),
8
+ componentId,
8
9
  ]"
9
10
  v-model="showValue"
10
11
  :props="propsShow"
@@ -41,6 +42,7 @@ const serviceConfig = inject("$ctServiceConfig");
41
42
 
42
43
  const ns = useNamespace("cascader");
43
44
  const cascaderRef = ref(null);
45
+ const componentId = `ct-cascader-${Math.random().toString(36).slice(2)}`;
44
46
  const checkedText = ref("");
45
47
  const propsShow = computed(() => {
46
48
  return {
@@ -73,6 +75,19 @@ watch(showValue, async (newValue) => {
73
75
  });
74
76
  props.cbs.change(dataList, cascaderRef.value);
75
77
  }
78
+ if (propsShow.value.multiple && props.filterable) {
79
+ await nextTick();
80
+
81
+ // 如果组件内部没找到,尝试在文档中通过类名查找(作为最后的兜底,注意可能会影响页面上其他同类组件,所以最好通过el限制范围,如果el也拿不到才用document)
82
+ const targetInput = document.querySelector(
83
+ `.${componentId} .el-cascader__search-input`
84
+ );
85
+
86
+ if (targetInput) {
87
+ targetInput.value = "";
88
+ targetInput.dispatchEvent(new Event("input", { bubbles: true }));
89
+ }
90
+ }
76
91
  });
77
92
  const popperClassShow = computed(() => {
78
93
  let popperClass = ns.e("dropdown");
@@ -12,7 +12,7 @@
12
12
  :suffix-icon="suffixIcon"
13
13
  :fit-input-width="fitInputWidth"
14
14
  :select-text="selectText"
15
- :popper-class="ns.e('popper')"
15
+ :popper-class="popperClass"
16
16
  @focus="showSearchPrefix"
17
17
  @blur="hideSearchPrefix"
18
18
  @click="focusSearchInput"
@@ -89,7 +89,15 @@
89
89
  </template>
90
90
 
91
91
  <script setup>
92
- import { onMounted, computed, ref, watch, inject, nextTick } from "vue";
92
+ import {
93
+ onMounted,
94
+ computed,
95
+ ref,
96
+ watch,
97
+ inject,
98
+ nextTick,
99
+ useAttrs,
100
+ } from "vue";
93
101
  import { selectEmits, selectProps } from "./index";
94
102
  import { useNamespace, useBuriedParams } from "../../../hooks";
95
103
  import { isFunction, isArray } from "../../../utils";
@@ -100,6 +108,7 @@ const selectTooltip = inject("$selectTooltip");
100
108
 
101
109
  const props = defineProps(selectProps);
102
110
  const emit = defineEmits(selectEmits);
111
+ const attrs = useAttrs();
103
112
 
104
113
  const ns = useNamespace("select");
105
114
  const optionsByApi = ref([]);
@@ -170,6 +179,18 @@ const emptyText = computed(() => {
170
179
  ? props.noMatchText || "暂无匹配数据"
171
180
  : props.noDataText || "暂无数据";
172
181
  });
182
+
183
+ const popperClass = computed(() => {
184
+ const defaultClass = ns.e("popper");
185
+ const userClass =
186
+ attrs["popper-class"] ||
187
+ attrs["popperClass"] ||
188
+ (props.rawAttr &&
189
+ (props.rawAttr["popper-class"] || props.rawAttr["popperClass"])) ||
190
+ "";
191
+ return `${defaultClass} ${userClass}`.trim();
192
+ });
193
+
173
194
  const getUseLabel = (label) => {
174
195
  return typeof label === "string" ? label : String(label);
175
196
  };
@@ -12,7 +12,7 @@
12
12
  :suffix-icon="suffixIcon"
13
13
  :fit-input-width="fitInputWidth"
14
14
  :select-text="selectText"
15
- :popper-class="ns.e('popper')"
15
+ :popper-class="popperClass"
16
16
  @focus="showSearchPrefix"
17
17
  @blur="hideSearchPrefix"
18
18
  @click="focusSearchInput"
@@ -117,6 +117,10 @@ const attrs = useAttrs();
117
117
 
118
118
  const bindAttrs = computed(() => {
119
119
  const merged = { ...attrs, ...props.rawAttr };
120
+ // 剔除已在组件内部显式处理的属性,避免 v-bind 覆盖或冲突
121
+ delete merged["popper-class"];
122
+ delete merged["popperClass"];
123
+
120
124
  if (merged.onChange) {
121
125
  const original = merged.onChange;
122
126
  merged.onChange = (val) => {
@@ -223,6 +227,14 @@ const emptyText = computed(() => {
223
227
  ? props.noMatchText || "暂无匹配数据"
224
228
  : props.noDataText || "暂无数据";
225
229
  });
230
+
231
+ const popperClass = computed(() => {
232
+ const defaultClass = ns.e("popper");
233
+ const merged = { ...attrs, ...props.rawAttr };
234
+ const userClass = merged["popper-class"] || merged["popperClass"] || "";
235
+ return `${defaultClass} ${userClass}`.trim();
236
+ });
237
+
226
238
  const getUseLabel = (label) => {
227
239
  return typeof label === "string" ? label : String(label);
228
240
  };