ct-component-plus 2.0.2 → 2.0.3

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,8 @@
1
1
  {
2
2
  "name": "ct-component-plus",
3
3
  "private": false,
4
- "version": "2.0.2",
4
+ "version": "2.0.3",
5
+ "description": "兼容下拉多选时的选中置顶逻辑",
5
6
  "type": "module",
6
7
  "main": "packages/components/index.js",
7
8
  "files": [
@@ -16,8 +17,7 @@
16
17
  },
17
18
  "dependencies": {
18
19
  "cingta-icon": "^2.1.6",
19
- "element-plus": "~2.12.0",
20
- "publish": "^0.6.0",
20
+ "element-plus": "2.5.0",
21
21
  "vue": "^3.2.47"
22
22
  },
23
23
  "devDependencies": {
@@ -1,6 +1,6 @@
1
- import { buriedParamsKey, searchComponentProps } from '../../../hooks';
2
- import arrowDown from './arrow-down.vue';
3
- import clearIcon from './clear-icon.vue';
1
+ import { buriedParamsKey, searchComponentProps } from "../../../hooks";
2
+ import arrowDown from "./arrow-down.vue";
3
+ import clearIcon from "./clear-icon.vue";
4
4
 
5
5
  export const selectEmits = ["update:modelValue", buriedParamsKey];
6
6
  export const selectProps = {
@@ -10,8 +10,8 @@ export const selectProps = {
10
10
  options: {
11
11
  type: Array,
12
12
  default() {
13
- return []
14
- }
13
+ return [];
14
+ },
15
15
  },
16
16
  filterable: Boolean,
17
17
  api: String,
@@ -20,16 +20,16 @@ export const selectProps = {
20
20
  mapObj: {
21
21
  type: Object,
22
22
  default() {
23
- return {}
24
- }
23
+ return {};
24
+ },
25
25
  },
26
26
  selectAllText: {
27
27
  type: String,
28
- default: '全部'
28
+ default: "全部",
29
29
  },
30
30
  connectors: {
31
31
  type: String,
32
- default: ''
32
+ default: "",
33
33
  },
34
34
  fitInputWidth: {
35
35
  type: Boolean,
@@ -38,15 +38,20 @@ export const selectProps = {
38
38
  clearIcon: {
39
39
  type: [String, Object],
40
40
  default() {
41
- return clearIcon
42
- }
41
+ return clearIcon;
42
+ },
43
43
  },
44
44
  suffixIcon: {
45
45
  type: [String, Object],
46
46
  default() {
47
- return arrowDown
48
- }
47
+ return arrowDown;
48
+ },
49
49
  },
50
50
  noMatchText: String,
51
51
  noDataText: String,
52
- }
52
+ // 是否保持原始 options 顺序(用于一些情况下不想让多选时“已选项置顶”逻辑)
53
+ keepOrder: {
54
+ type: Boolean,
55
+ default: false,
56
+ },
57
+ };
@@ -155,9 +155,9 @@ const selectText = computed(() => {
155
155
  result = selectObj.value.map((item) => item.label).join(cnt);
156
156
  }
157
157
  }
158
- nextTick(() => {
159
- selectRef.value.$refs.reference.input.value = result;
160
- });
158
+ // nextTick(() => {
159
+ // selectRef.value.$refs.reference.input.value = result;
160
+ // });
161
161
  return result;
162
162
  });
163
163
  const emptyText = computed(() => {
@@ -178,7 +178,7 @@ watch(
178
178
  // selectRef.value.$refs.reference.input.value = newVal;
179
179
  // })
180
180
  // }
181
- }
181
+ },
182
182
  );
183
183
  watchEffect(async () => {
184
184
  // 输入框过滤,触发的事件
@@ -191,7 +191,7 @@ watchEffect(async () => {
191
191
  const filterCallbackHandle = await cbs.filterCallback(
192
192
  keyword.value,
193
193
  showOptions.value,
194
- valueModel
194
+ valueModel,
195
195
  );
196
196
  if (filterCallbackHandle === false) return;
197
197
  arr = filterCallbackHandle || arr;
@@ -208,8 +208,9 @@ watchEffect(async () => {
208
208
 
209
209
  const optionsRef = ref(null);
210
210
  //针对多选时,已选的项要排在整个列表的最前面
211
+ // 当 keepOrder 为 true 时,不做置顶,保持原有顺序(用于层级选择等场景)
211
212
  const handleListSort = (val) => {
212
- if (props.multiple) {
213
+ if (props.multiple && !props.keepOrder) {
213
214
  if (val) {
214
215
  const selectedSet = new Set(valueModel.value);
215
216
  filterOptions.value = [
@@ -271,7 +272,7 @@ const watchServiceHandle = async () => {
271
272
  try {
272
273
  const defineSearchHandle = await cbs.defineSearch(
273
274
  optionsByApi,
274
- valueModel
275
+ valueModel,
275
276
  );
276
277
  if (defineSearchHandle === false) return;
277
278
  if (defineSearchHandle) {
@@ -292,7 +293,7 @@ watch(
292
293
  },
293
294
  {
294
295
  immediate: true,
295
- }
296
+ },
296
297
  );
297
298
  const checkedAll = useCheckedAll(filterOptions, valueModel, {
298
299
  onCheckedAll: (falg) => {
@@ -358,7 +359,9 @@ defineExpose({
358
359
  </script>
359
360
  <style lang="less">
360
361
  .ct-select {
361
- width: 214px;
362
+ &.el-select {
363
+ width: 214px;
364
+ }
362
365
  &__top {
363
366
  padding: 0 16px;
364
367
  font-size: var(--ct-font-size);
@@ -407,7 +410,7 @@ defineExpose({
407
410
  z-index: 3;
408
411
  right: var(--ct-component-inner-padding);
409
412
  top: 50%;
410
- height: calc(var(--ct-component-size) - 2px);
413
+ height: calc(var(--ct-component-size) - 8px);
411
414
  transform: translateY(-50%);
412
415
  background-color: #fff;
413
416
  }
@@ -419,18 +422,24 @@ defineExpose({
419
422
  color: var(--ct-color-grey-sub);
420
423
  }
421
424
  &.is-multiple {
422
- // &::after {
423
- // content: attr(select-text);
424
- // position: absolute;
425
- // left: var(--ct-component-inner-padding);
426
- // right: calc(var(--ct-component-inner-padding) * 2);
427
- // top: 50%;
428
- // transform: translateY(-50%);
429
- // text-overflow: ellipsis;
430
- // overflow: hidden;
431
- // white-space: nowrap;
432
- // cursor: pointer;
433
- // }
425
+ &::after {
426
+ content: attr(select-text);
427
+ position: absolute;
428
+ left: var(--ct-component-inner-padding);
429
+ right: calc(var(--ct-component-inner-padding) * 2);
430
+ top: 50%;
431
+ transform: translateY(-50%);
432
+ text-overflow: ellipsis;
433
+ overflow: hidden;
434
+ white-space: nowrap;
435
+ cursor: pointer;
436
+ }
437
+ .el-select__placeholder.is-transparent {
438
+ display: block;
439
+ }
440
+ .el-select__selected-item {
441
+ display: none;
442
+ }
434
443
  }
435
444
  }
436
445
  </style>
@@ -135,9 +135,12 @@ const getYearList = () => {
135
135
  }
136
136
  yearList.value = yearArr;
137
137
  };
138
- watch(() => props.range, () => {
139
- getYearList();
140
- })
138
+ watch(
139
+ () => props.range,
140
+ () => {
141
+ getYearList();
142
+ }
143
+ );
141
144
  const filterHandleE = (str) => {
142
145
  //处理结束年
143
146
  if (judgeYear(str) && judgeRange(str)) {
@@ -207,7 +210,7 @@ onMounted(() => {
207
210
  getYearList();
208
211
  });
209
212
  </script>
210
- <style lang='less'>
213
+ <style lang="less">
211
214
  .ct-year-select {
212
215
  --el-select-input-focus-border-color: transparent;
213
216
  --ct-year-select-select-inner-box-shadow: none;
@@ -273,5 +276,15 @@ onMounted(() => {
273
276
  }
274
277
  }
275
278
  }
279
+ .el-select__wrapper {
280
+ padding: 1px 12px;
281
+ min-height: 30px;
282
+ box-shadow: var(--ct-year-select-select-inner-box-shadow);
283
+ &.is-focused,
284
+ &.is-hovering:not(.is-focused),
285
+ &.is-disabled {
286
+ box-shadow: var(--ct-year-select-select-inner-box-shadow);
287
+ }
288
+ }
276
289
  }
277
- </style>
290
+ </style>