@nutui/nutui 4.0.8-beta.1 → 4.0.8

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.
@@ -56,7 +56,7 @@ const component = (componentName2, components) => {
56
56
  });
57
57
  const checked = computed(() => !!props.modelValue);
58
58
  const color = computed(() => {
59
- return !pDisabled.value ? !pValue.value ? "nut-checkbox__icon--unchecked" : state.partialSelect ? "nut-checkbox__icon--indeterminate" : "nut-checkbox__icon" : "nut-checkbox__icon--disable";
59
+ return !pDisabled.value ? state.partialSelect ? "nut-checkbox__icon--indeterminate" : !pValue.value ? "nut-checkbox__icon--unchecked" : "nut-checkbox__icon" : "nut-checkbox__icon--disable";
60
60
  });
61
61
  let updateType = "";
62
62
  const emitChange = (value, label) => {
@@ -81,7 +81,7 @@ const component = (componentName2, components) => {
81
81
  Checked: slots.checkedIcon ? slots.checkedIcon : components.Checked,
82
82
  CheckDisabled: slots.indeterminate ? slots.indeterminate : components.CheckDisabled
83
83
  };
84
- const iconNode = !pValue.value ? iconNodeMap.CheckNormal : state.partialSelect ? iconNodeMap.CheckDisabled : iconNodeMap.Checked;
84
+ const iconNode = state.partialSelect ? iconNodeMap.CheckDisabled : !pValue.value ? iconNodeMap.CheckNormal : iconNodeMap.Checked;
85
85
  const size = pxCheck(iconSize);
86
86
  return h(iconNode, {
87
87
  width: size,
@@ -134,10 +134,10 @@ const component = (componentName2, components) => {
134
134
  }
135
135
  };
136
136
  onMounted(() => {
137
- hasParent.value && parent["relation"](getCurrentInstance());
137
+ hasParent.value && parent.link(getCurrentInstance());
138
138
  });
139
139
  onBeforeUnmount(() => {
140
- hasParent.value && parent["relation"](getCurrentInstance(), true);
140
+ hasParent.value && parent.unlink(getCurrentInstance());
141
141
  });
142
142
  watch(
143
143
  () => props.indeterminate,
@@ -23,31 +23,19 @@ const _sfc_main = create({
23
23
  const state = reactive({
24
24
  children: []
25
25
  });
26
- const relation = (child, cancel = false) => {
27
- var _a;
28
- if (child.proxy) {
29
- if (!cancel) {
30
- state.children.push(child.proxy);
31
- } else {
32
- let key_1 = state.children.indexOf(child.proxy);
33
- if (key_1 > -1) {
34
- state.children.splice(key_1, 1);
35
- }
36
- let key_2 = props.modelValue.indexOf((_a = child.proxy) == null ? void 0 : _a.label);
37
- if (key_2 > -1) {
38
- const value = props.modelValue.filter((_, index) => index !== key_2);
39
- emit("update:modelValue", value);
40
- }
41
- }
42
- }
26
+ const link = (child) => {
27
+ child.proxy && state.children.push(child.proxy);
28
+ };
29
+ const unlink = (child) => {
30
+ child.proxy && (state.children = state.children.filter((p) => p !== child.proxy));
43
31
  };
44
32
  const updateValue = (value) => {
45
33
  emit("update:modelValue", value);
46
34
  emit("change", value);
47
35
  };
48
36
  const toggleAll = (checked) => {
49
- let values = [];
50
- if (!!checked) {
37
+ const values = [];
38
+ if (checked) {
51
39
  state.children.forEach((item) => {
52
40
  if (!(item == null ? void 0 : item.disabled)) {
53
41
  values.push(item == null ? void 0 : item.label);
@@ -57,25 +45,22 @@ const _sfc_main = create({
57
45
  emit("update:modelValue", values);
58
46
  };
59
47
  const toggleReverse = () => {
60
- let values = props.modelValue.slice();
61
- state.children.forEach((item) => {
62
- let findIndex = values.findIndex((value) => value === item.label);
63
- if (findIndex > -1) {
64
- values.splice(findIndex, 1);
48
+ const value = state.children.filter((item) => {
49
+ if (item == null ? void 0 : item.disabled) {
50
+ return false;
65
51
  } else {
66
- if (!(item == null ? void 0 : item.disabled)) {
67
- values.push(item == null ? void 0 : item.label);
68
- }
52
+ return !props.modelValue.includes(item.label);
69
53
  }
70
- });
71
- emit("update:modelValue", values);
54
+ }).map((item) => item.label);
55
+ emit("update:modelValue", value);
72
56
  };
73
57
  provide("parent", {
74
58
  value: computed(() => props.modelValue),
75
59
  disabled: computed(() => props.disabled),
76
60
  max: computed(() => props.max),
77
61
  updateValue,
78
- relation
62
+ link,
63
+ unlink
79
64
  });
80
65
  watch(
81
66
  () => props.modelValue,
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
3
3
  "framework": "vue",
4
4
  "name": "NutUI",
5
- "version": "4.0.8-beta.1",
5
+ "version": "4.0.8",
6
6
  "contributions": {
7
7
  "html": {
8
8
  "tags": [