ct-component-plus 0.0.18 → 0.0.20

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": "0.0.18",
4
+ "version": "0.0.20",
5
5
  "type": "module",
6
6
  "main": "packages/components/index.js",
7
7
  "files": [
@@ -22,7 +22,15 @@
22
22
  </template>
23
23
 
24
24
  <script setup>
25
- import { onMounted, computed, ref, watch, inject, watchEffect } from "vue";
25
+ import {
26
+ onMounted,
27
+ computed,
28
+ ref,
29
+ watch,
30
+ inject,
31
+ watchEffect,
32
+ nextTick,
33
+ } from "vue";
26
34
  import { cascaderEmits, cascaderProps } from "./index";
27
35
  import { useNamespace, useBuriedParams } from "../../../hooks";
28
36
  import { isArray, isFunction } from "../../../utils";
@@ -54,15 +62,18 @@ const showValue = computed({
54
62
  },
55
63
  set(newValue) {
56
64
  emit("update:modelValue", newValue);
57
- if (isFunction(props.cbs.change)) {
58
- const checkedNodes = cascaderRef.value?.getCheckedNodes() || [];
59
- const dataList = checkedNodes.map((item) => {
60
- return item.data;
61
- });
62
- props.cbs.change(dataList, cascaderRef.value);
63
- }
64
65
  },
65
66
  });
67
+ watch(showValue, async (newValue) => {
68
+ if (isFunction(props.cbs.change)) {
69
+ await nextTick(); //这里得等一个nextTick,否则会拿不到最新选中的值
70
+ const checkedNodes = cascaderRef.value?.getCheckedNodes() || [];
71
+ const dataList = checkedNodes.map((item) => {
72
+ return item.data;
73
+ });
74
+ props.cbs.change(dataList, cascaderRef.value);
75
+ }
76
+ });
66
77
  const popperClassShow = computed(() => {
67
78
  let popperClass = ns.e("dropdown");
68
79
  popperClass += props.popperClass || "";
@@ -222,7 +222,14 @@ watchEffect(async () => {
222
222
  } catch (error) {}
223
223
  }
224
224
  });
225
- const checkedAll = useCheckedAll(filterOptions, valueModel).checkedAll;
225
+ const checkedAll = useCheckedAll(filterOptions, valueModel, {
226
+ onCheckedAll: (falg) => {
227
+ if (!keyword.value && !falg) {
228
+ // 没有搜索,去掉全选就置空
229
+ valueModel.value = [];
230
+ }
231
+ },
232
+ }).checkedAll;
226
233
 
227
234
  const focusFilter = () => {
228
235
  if (filterInput.value && filterInput.value.focus) {
@@ -124,9 +124,8 @@ const handleProp = (item) => {
124
124
  }
125
125
  &__content {
126
126
  @{R}__item{
127
- height: 30px;
128
- line-height: 30px;
129
- padding: 0 16px;
127
+ line-height: 20px;
128
+ padding: 5px 16px;
130
129
  border-radius: 4px;
131
130
  cursor: pointer;
132
131
  display: flex;
@@ -161,6 +160,8 @@ const handleProp = (item) => {
161
160
  }
162
161
  @{R}__list{
163
162
  margin-top: 8px;
163
+ max-height: 300px;
164
+ overflow-y: auto;
164
165
  }
165
166
  @{R}__list--item{
166
167
 
@@ -170,7 +171,7 @@ const handleProp = (item) => {
170
171
  </style>
171
172
 
172
173
  <style lang="less">
173
- .el-popover.ct-table-sort__popover {
174
+ .el-popover.el-popper.ct-table-sort__popover {
174
175
  padding: 11px 6px;
175
176
  min-width: 134px;
176
177
  box-shadow: 0px 4px 14px 0px rgba(102, 114, 144, 0.1);
@@ -10,7 +10,7 @@
10
10
  ]"
11
11
  @click="handleClick(item, index)"
12
12
  >
13
- <slot>
13
+ <slot :index="index" :item="item">
14
14
  <span :class="ns.e('item-text')">{{ item.label }}</span>
15
15
  </slot>
16
16
  </div>
@@ -2,7 +2,7 @@ import { computed } from "vue"
2
2
  import { isArray, isObject } from '../../utils';
3
3
 
4
4
  export const useCheckedAll = (list, selects, options = {}) => {
5
- const { key = 'value' } = (isObject(options) ? options : {})
5
+ const { key = 'value', onCheckedAll } = (isObject(options) ? options : {})
6
6
  const listKeys = computed(() => {
7
7
  if (isArray(list.value)) return list.value.map(item => item[key])
8
8
  return []
@@ -25,6 +25,7 @@ export const useCheckedAll = (list, selects, options = {}) => {
25
25
  if (!newValue) {
26
26
  // 去掉全选
27
27
  selects.value = selects.value.filter(item => !listKeys.value.includes(item))
28
+ if (typeof onCheckedAll === 'function') onCheckedAll(false)
28
29
  } else {
29
30
  // 全选
30
31
  selects.value = selects.value.concat(listKeys.value.filter(item => !selects.value.includes(item)))
@@ -14,6 +14,7 @@
14
14
  --el-fill-color-light: var(--ct-component-hover-color);
15
15
 
16
16
  --ct-cascader-node-height: 30px;
17
+ --el-disabled-text-color: var(--ct-font-color);
17
18
  }
18
19
 
19
20
  .el {
@@ -105,6 +106,11 @@
105
106
  line-height: calc(var(--el-input-height) - 2px);
106
107
  }
107
108
  }
109
+ &.is-disabled {
110
+ .el-input__inner {
111
+ -webkit-text-fill-color: unset;
112
+ }
113
+ }
108
114
  }
109
115
 
110
116
  &-select {
@@ -86,21 +86,19 @@ body {
86
86
  -webkit-font-smoothing: antialiased;
87
87
 
88
88
  }
89
- input::placeholder,
90
- input::-webkit-input-placeholder { /* WebKit, Blink, Edge */
91
- color: var(--ct-color-placeholder);
92
- }
93
89
  :-moz-placeholder { /* Mozilla Firefox 4 to 18 */
94
90
  color: var(--ct-color-placeholder);
95
91
  }
96
92
  ::-moz-placeholder { /* Mozilla Firefox 19+ */
97
93
  color: var(--ct-color-placeholder);
98
94
  }
99
- input:-ms-input-placeholder { /* Internet Explorer 10-11 */
100
- color:var(--ct-color-placeholder);
101
- }
102
- input::-ms-input-placeholder { /* Microsoft Edge */
103
- color: var(--ct-color-placeholder);
95
+ input {
96
+ &::placeholder,
97
+ &::-webkit-input-placeholder,
98
+ &:-ms-input-placeholder,
99
+ &::-ms-input-placeholder {
100
+ color: var(--ct-color-placeholder);
101
+ }
104
102
  }
105
103
  ::-webkit-scrollbar {
106
104
  width: 7px;