ct-component-plus 0.0.18 → 0.0.19

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.19",
5
5
  "type": "module",
6
6
  "main": "packages/components/index.js",
7
7
  "files": [
@@ -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) {
@@ -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)))