@nutui/nutui 4.1.0-beta.1 → 4.1.0-beta.2
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/dist/nutui.es.js +1 -1
- package/dist/nutui.umd.js +2 -2
- package/dist/packages/_es/Collapse.js +28 -38
- package/dist/packages/_es/CollapseItem.js +52 -115
- package/dist/smartips/web-types.json +1 -1
- package/dist/style.css +1 -1
- package/dist/styles/themes/default.scss +55 -55
- package/dist/styles/themes/jdb.scss +55 -55
- package/dist/styles/themes/jddkh.scss +55 -55
- package/dist/styles/themes/jdt.scss +55 -55
- package/dist/types/__VUE/collapse/index.vue.d.ts +29 -3
- package/dist/types/__VUE/collapseitem/index.vue.d.ts +7 -8
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ref, computed,
|
|
1
|
+
import { ref, computed, provide, openBlock, createElementBlock, normalizeClass, renderSlot } from "vue";
|
|
2
2
|
import { c as createComponent } from "./component-81a4c1d0.js";
|
|
3
3
|
import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js";
|
|
4
4
|
import "../locale/lang";
|
|
@@ -17,57 +17,47 @@ const _sfc_main = create({
|
|
|
17
17
|
emits: ["update:modelValue", "change"],
|
|
18
18
|
setup(props, { emit }) {
|
|
19
19
|
const collapseDom = ref(null);
|
|
20
|
-
const collapseChldren = ref([]);
|
|
21
20
|
const classes = computed(() => {
|
|
22
21
|
const prefixCls = componentName;
|
|
23
22
|
return {
|
|
24
23
|
[prefixCls]: true
|
|
25
24
|
};
|
|
26
25
|
});
|
|
27
|
-
|
|
28
|
-
() => props.modelValue,
|
|
29
|
-
(newval) => {
|
|
30
|
-
let doms = collapseChldren.value;
|
|
31
|
-
Array.from(doms).forEach((item) => {
|
|
32
|
-
if (typeof newval == "number" || typeof newval == "string") {
|
|
33
|
-
item.changeOpen(newval == item.name ? true : false);
|
|
34
|
-
} else if (Object.values(newval) instanceof Array) {
|
|
35
|
-
const isOpen = newval.indexOf(Number(item.name)) > -1 || newval.indexOf(String(item.name)) > -1;
|
|
36
|
-
item.changeOpen(isOpen);
|
|
37
|
-
}
|
|
38
|
-
item.animation();
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
);
|
|
42
|
-
onMounted(() => {
|
|
43
|
-
collapseChldren.value = getCurrentInstance().provides.collapseParent.children || [];
|
|
44
|
-
});
|
|
45
|
-
const changeVal = (val) => {
|
|
26
|
+
const changeVal = (val, name, status = true) => {
|
|
46
27
|
emit("update:modelValue", val);
|
|
47
|
-
emit("change", val);
|
|
28
|
+
emit("change", val, name, status);
|
|
48
29
|
};
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
30
|
+
const updateVal = (name) => {
|
|
31
|
+
if (props.accordion) {
|
|
32
|
+
if (props.modelValue === name) {
|
|
33
|
+
changeVal("", name, false);
|
|
34
|
+
} else {
|
|
35
|
+
changeVal(name, name, true);
|
|
55
36
|
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
37
|
+
} else {
|
|
38
|
+
if (Array.isArray(props.modelValue)) {
|
|
39
|
+
if (props.modelValue.includes(name)) {
|
|
40
|
+
const newValue = props.modelValue.filter((v) => v !== name);
|
|
41
|
+
changeVal(newValue, name, false);
|
|
42
|
+
} else {
|
|
43
|
+
const newValue = props.modelValue.concat([name]);
|
|
44
|
+
changeVal(newValue, name, true);
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
console.warn("[NutUI] <Collapse> 未开启手风琴模式时 v-model 应为数组");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
59
50
|
};
|
|
60
51
|
const isExpanded = (name) => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
52
|
+
if (props.accordion) {
|
|
53
|
+
return props.modelValue === name;
|
|
54
|
+
} else if (Array.isArray(props.modelValue)) {
|
|
55
|
+
return props.modelValue.includes(name);
|
|
64
56
|
}
|
|
57
|
+
return false;
|
|
65
58
|
};
|
|
66
59
|
provide("collapseParent", {
|
|
67
|
-
|
|
68
|
-
props,
|
|
69
|
-
changeValAry,
|
|
70
|
-
changeVal,
|
|
60
|
+
updateVal,
|
|
71
61
|
isExpanded
|
|
72
62
|
});
|
|
73
63
|
return { collapseDom, classes };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { inject, reactive, computed,
|
|
1
|
+
import { ref, inject, reactive, computed, watch, openBlock, createElementBlock, normalizeClass, createElementVNode, renderSlot, toDisplayString, createCommentVNode, normalizeStyle, createBlock, resolveDynamicComponent } from "vue";
|
|
2
2
|
import { DownArrow } from "@nutui/icons-vue";
|
|
3
3
|
import { c as createComponent } from "./component-81a4c1d0.js";
|
|
4
4
|
import { r as renderIcon } from "./renderIcon-3d0fd47c.js";
|
|
@@ -44,8 +44,9 @@ const _sfc_main = create({
|
|
|
44
44
|
default: 180
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
setup(props) {
|
|
48
|
+
const wrapperRef = ref(null);
|
|
49
|
+
const contentRef = ref(null);
|
|
49
50
|
const collapse = inject("collapseParent");
|
|
50
51
|
const parent = reactive(collapse);
|
|
51
52
|
const classes = computed(() => {
|
|
@@ -55,123 +56,54 @@ const _sfc_main = create({
|
|
|
55
56
|
[prefixCls + "__border"]: props.border
|
|
56
57
|
};
|
|
57
58
|
});
|
|
58
|
-
const
|
|
59
|
-
if (
|
|
60
|
-
parent.
|
|
59
|
+
const expanded = computed(() => {
|
|
60
|
+
if (parent) {
|
|
61
|
+
return parent.isExpanded(props.name);
|
|
61
62
|
}
|
|
62
|
-
|
|
63
|
-
relation(getCurrentInstance());
|
|
64
|
-
const proxyData = reactive({
|
|
65
|
-
openExpanded: false
|
|
63
|
+
return false;
|
|
66
64
|
});
|
|
67
|
-
const
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
const wrapperRefEle = document.getElementsByClassName("nut-collapse__item-wrapper")[0];
|
|
71
|
-
if (wrapperRefEle) {
|
|
72
|
-
wrapperRefEle.style.willChange = "auto";
|
|
73
|
-
}
|
|
65
|
+
const wrapperHeight = ref(expanded.value ? "auto" : "0px");
|
|
66
|
+
const toggle = () => {
|
|
67
|
+
parent.updateVal(props.name);
|
|
74
68
|
};
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (!wrapperRefEle || !contentRefEle) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
const offsetHeight = contentRefEle.offsetHeight || "auto";
|
|
82
|
-
if (offsetHeight) {
|
|
83
|
-
const contentHeight = `${offsetHeight}px`;
|
|
84
|
-
wrapperRefEle.style.willChange = "height";
|
|
85
|
-
wrapperRefEle.style.height = !proxyData.openExpanded ? 0 : contentHeight;
|
|
86
|
-
}
|
|
87
|
-
if (!proxyData.openExpanded) {
|
|
88
|
-
onTransitionEnd();
|
|
69
|
+
const onTransitionEnd = () => {
|
|
70
|
+
if (expanded.value) {
|
|
71
|
+
wrapperHeight.value = "auto";
|
|
89
72
|
}
|
|
90
73
|
};
|
|
91
74
|
const open = () => {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const currentName = computed(() => props.name);
|
|
99
|
-
const toggleOpen = () => {
|
|
100
|
-
if (parent.props.accordion) {
|
|
101
|
-
nextTick(() => {
|
|
102
|
-
if (currentName.value == parent.props.modelValue) {
|
|
103
|
-
open();
|
|
104
|
-
} else {
|
|
105
|
-
parent.changeVal(currentName.value);
|
|
106
|
-
}
|
|
75
|
+
wrapperHeight.value = "0px";
|
|
76
|
+
requestAnimationFrame(() => {
|
|
77
|
+
requestAnimationFrame(() => {
|
|
78
|
+
var _a;
|
|
79
|
+
const height = (_a = contentRef.value) == null ? void 0 : _a.offsetHeight;
|
|
80
|
+
wrapperHeight.value = height ? `${height}px` : "auto";
|
|
107
81
|
});
|
|
108
|
-
} else {
|
|
109
|
-
parent.changeValAry(String(props.name));
|
|
110
|
-
open();
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
const changeOpen = (bol) => {
|
|
114
|
-
proxyData.openExpanded = bol;
|
|
115
|
-
};
|
|
116
|
-
const expanded = computed(() => {
|
|
117
|
-
if (parent) {
|
|
118
|
-
return parent.isExpanded(props.name);
|
|
119
|
-
}
|
|
120
|
-
return null;
|
|
121
|
-
});
|
|
122
|
-
watch(expanded, (value, oldValue) => {
|
|
123
|
-
if (value) {
|
|
124
|
-
proxyData.openExpanded = true;
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
const init = () => {
|
|
128
|
-
const { name } = props;
|
|
129
|
-
const active = parent && parent.props.modelValue;
|
|
130
|
-
nextTick(() => {
|
|
131
|
-
if (typeof active == "number" || typeof active == "string") {
|
|
132
|
-
if (name == active) {
|
|
133
|
-
defaultOpen();
|
|
134
|
-
}
|
|
135
|
-
} else if (Object.values(active) instanceof Array) {
|
|
136
|
-
const f = Object.values(active).filter((item) => item == name);
|
|
137
|
-
if (f.length > 0) {
|
|
138
|
-
defaultOpen();
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
82
|
});
|
|
142
83
|
};
|
|
143
|
-
|
|
144
|
-
var
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
childList: true,
|
|
151
|
-
subtree: true
|
|
84
|
+
const close = () => {
|
|
85
|
+
var _a;
|
|
86
|
+
const height = (_a = contentRef.value) == null ? void 0 : _a.offsetHeight;
|
|
87
|
+
wrapperHeight.value = height ? `${height}px` : "auto";
|
|
88
|
+
requestAnimationFrame(() => {
|
|
89
|
+
requestAnimationFrame(() => {
|
|
90
|
+
wrapperHeight.value = "0px";
|
|
152
91
|
});
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
let ele = contentRef.value;
|
|
158
|
-
let _class = "";
|
|
159
|
-
if (!(ele == null ? void 0 : ele.innerText)) {
|
|
160
|
-
_class = "nut-collapse__item-wrapper__content--empty";
|
|
161
|
-
}
|
|
162
|
-
return _class;
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
watch(expanded, (value) => {
|
|
95
|
+
value ? open() : close();
|
|
163
96
|
});
|
|
164
97
|
return {
|
|
165
98
|
classes,
|
|
166
|
-
emptyContent,
|
|
167
|
-
...toRefs(proxyData),
|
|
168
99
|
renderIcon,
|
|
169
100
|
wrapperRef,
|
|
170
101
|
contentRef,
|
|
171
102
|
open,
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
103
|
+
toggle,
|
|
104
|
+
wrapperHeight,
|
|
105
|
+
expanded,
|
|
106
|
+
onTransitionEnd
|
|
175
107
|
};
|
|
176
108
|
}
|
|
177
109
|
});
|
|
@@ -193,8 +125,8 @@ const _hoisted_7 = {
|
|
|
193
125
|
};
|
|
194
126
|
const _hoisted_8 = { class: "nut-collapse__item-extraWrapper__extraRender" };
|
|
195
127
|
const _hoisted_9 = {
|
|
196
|
-
class: "nut-collapse__item-
|
|
197
|
-
ref: "
|
|
128
|
+
class: "nut-collapse__item-wrapper__content",
|
|
129
|
+
ref: "contentRef"
|
|
198
130
|
};
|
|
199
131
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
200
132
|
return openBlock(), createElementBlock("view", {
|
|
@@ -202,7 +134,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
202
134
|
}, [
|
|
203
135
|
createElementVNode("view", {
|
|
204
136
|
class: normalizeClass(["nut-collapse-item__title", { "nut-collapse-item__title--disabled": _ctx.disabled }]),
|
|
205
|
-
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.
|
|
137
|
+
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.toggle && _ctx.toggle(...args))
|
|
206
138
|
}, [
|
|
207
139
|
createElementVNode("view", _hoisted_1, [
|
|
208
140
|
createElementVNode("view", _hoisted_2, [
|
|
@@ -222,8 +154,8 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
222
154
|
class: "nut-collapse-item__title-sub"
|
|
223
155
|
}, null, 8, _hoisted_6)),
|
|
224
156
|
createElementVNode("view", {
|
|
225
|
-
class: normalizeClass(["nut-collapse-item__title-icon", { "nut-collapse-item__title-icon--expanded": _ctx.
|
|
226
|
-
style: normalizeStyle({ transform: "rotate(" + (_ctx.
|
|
157
|
+
class: normalizeClass(["nut-collapse-item__title-icon", { "nut-collapse-item__title-icon--expanded": _ctx.expanded }]),
|
|
158
|
+
style: normalizeStyle({ transform: "rotate(" + (_ctx.expanded ? _ctx.rotate : 0) + "deg)" })
|
|
227
159
|
}, [
|
|
228
160
|
(openBlock(), createBlock(resolveDynamicComponent(_ctx.renderIcon(_ctx.icon))))
|
|
229
161
|
], 6)
|
|
@@ -233,14 +165,19 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
233
165
|
renderSlot(_ctx.$slots, "extra")
|
|
234
166
|
])
|
|
235
167
|
])) : createCommentVNode("", true),
|
|
236
|
-
createElementVNode("view",
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
168
|
+
createElementVNode("view", {
|
|
169
|
+
class: "nut-collapse__item-wrapper",
|
|
170
|
+
ref: "wrapperRef",
|
|
171
|
+
style: normalizeStyle({
|
|
172
|
+
willChange: "height",
|
|
173
|
+
height: _ctx.wrapperHeight
|
|
174
|
+
}),
|
|
175
|
+
onTransitionend: _cache[1] || (_cache[1] = (...args) => _ctx.onTransitionEnd && _ctx.onTransitionEnd(...args))
|
|
176
|
+
}, [
|
|
177
|
+
createElementVNode("view", _hoisted_9, [
|
|
241
178
|
renderSlot(_ctx.$slots, "default")
|
|
242
|
-
],
|
|
243
|
-
],
|
|
179
|
+
], 512)
|
|
180
|
+
], 36)
|
|
244
181
|
], 2);
|
|
245
182
|
}
|
|
246
183
|
const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|