@cmstops/pro-compo 3.9.2-alpha.0 → 3.9.2-alpha.1
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/index.css +34 -3
- package/dist/index.min.css +1 -1
- package/es/hooks/usePopper.d.ts +1 -1
- package/es/hooks/usePopper.js +3 -3
- package/es/index.css +34 -3
- package/es/selectResourceModal/__demo__/module/DivWrapper.d.ts +268 -0
- package/es/selectResourceModal/__demo__/module/basic.d.ts +299 -0
- package/es/selectResourceModal/components/List/ListNormal/Filter.js +166 -87
- package/es/selectResourceModal/hooks/useResponsiveFilter.d.ts +21 -0
- package/es/selectResourceModal/hooks/useResponsiveFilter.js +142 -0
- package/es/selectResourceModal/style/index.css +34 -3
- package/es/selectResourceModal/style/list.less +38 -3
- package/lib/hooks/usePopper.js +3 -3
- package/lib/index.css +34 -3
- package/lib/selectResourceModal/components/List/ListNormal/Filter.js +163 -84
- package/lib/selectResourceModal/hooks/useResponsiveFilter.js +144 -0
- package/lib/selectResourceModal/style/index.css +34 -3
- package/lib/selectResourceModal/style/list.less +38 -3
- package/package.json +1 -1
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
var vue = require("vue");
|
|
4
|
+
var usePopper = require("../../hooks/usePopper.js");
|
|
5
|
+
const getRect = (el) => {
|
|
6
|
+
if (!el || typeof el.getClientRects !== "function")
|
|
7
|
+
return { right: 0, width: 0 };
|
|
8
|
+
const rects = el.getClientRects();
|
|
9
|
+
if (rects.length === 0)
|
|
10
|
+
return { right: 0, width: 0 };
|
|
11
|
+
const rect = rects[0];
|
|
12
|
+
return {
|
|
13
|
+
right: rect.right,
|
|
14
|
+
width: rect.width
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
function useResponsiveFilter(filterItemsRef) {
|
|
18
|
+
const moreBtnRef = vue.ref();
|
|
19
|
+
const popperPanelRef = vue.ref();
|
|
20
|
+
const { initPopper, show, visible, hide } = usePopper(
|
|
21
|
+
popperPanelRef,
|
|
22
|
+
moreBtnRef
|
|
23
|
+
);
|
|
24
|
+
const windowWidth = vue.ref(0);
|
|
25
|
+
const filterContainerRightBoundary = vue.ref(0);
|
|
26
|
+
const hiddenElementList = vue.ref([]);
|
|
27
|
+
const initWidths = () => {
|
|
28
|
+
var _a, _b;
|
|
29
|
+
windowWidth.value = ((_a = document.body) == null ? void 0 : _a.clientWidth) || 0;
|
|
30
|
+
const containerElement = (_b = filterItemsRef.value) == null ? void 0 : _b.parentElement;
|
|
31
|
+
if (containerElement) {
|
|
32
|
+
filterContainerRightBoundary.value = getRect(containerElement).right;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const initResizeListener = () => {
|
|
36
|
+
window.addEventListener("resize", refreshLayout);
|
|
37
|
+
};
|
|
38
|
+
const removeResizeListener = () => {
|
|
39
|
+
window.removeEventListener("resize", refreshLayout);
|
|
40
|
+
};
|
|
41
|
+
const hideElement = (el) => {
|
|
42
|
+
var _a, _b, _c;
|
|
43
|
+
const { width } = getRect(el);
|
|
44
|
+
if (width > 0 && ((_a = filterItemsRef.value) == null ? void 0 : _a.contains(el))) {
|
|
45
|
+
hiddenElementList.value.push({ width, el });
|
|
46
|
+
(_b = filterItemsRef.value) == null ? void 0 : _b.removeChild(el);
|
|
47
|
+
(_c = popperPanelRef.value) == null ? void 0 : _c.insertBefore(el, popperPanelRef.value.firstChild);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const showElement = () => {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
if (!hiddenElementList.value.length || !filterItemsRef.value)
|
|
53
|
+
return;
|
|
54
|
+
const popEl = hiddenElementList.value.pop();
|
|
55
|
+
if (!popEl)
|
|
56
|
+
return;
|
|
57
|
+
const { el } = popEl;
|
|
58
|
+
(_a = popperPanelRef.value) == null ? void 0 : _a.removeChild(el);
|
|
59
|
+
(_b = filterItemsRef.value) == null ? void 0 : _b.appendChild(el);
|
|
60
|
+
};
|
|
61
|
+
const checkOverflow = () => {
|
|
62
|
+
if (!filterItemsRef.value)
|
|
63
|
+
return -1;
|
|
64
|
+
const containerRight = filterContainerRightBoundary.value;
|
|
65
|
+
const children = filterItemsRef.value.children;
|
|
66
|
+
let currentRightmostBoundary = getRect(filterItemsRef.value).right - getRect(filterItemsRef.value).width;
|
|
67
|
+
for (let i = children.length - 1; i >= 0; i--) {
|
|
68
|
+
const item = children[i];
|
|
69
|
+
if (!item || !item.classList || !item.classList.contains("filter-item"))
|
|
70
|
+
continue;
|
|
71
|
+
const itemRect = getRect(item);
|
|
72
|
+
if (itemRect.right > containerRight - 300) {
|
|
73
|
+
hideElement(item);
|
|
74
|
+
} else {
|
|
75
|
+
currentRightmostBoundary = Math.max(
|
|
76
|
+
currentRightmostBoundary,
|
|
77
|
+
itemRect.right
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return currentRightmostBoundary;
|
|
82
|
+
};
|
|
83
|
+
const refreshLayout = async () => {
|
|
84
|
+
await vue.nextTick();
|
|
85
|
+
initWidths();
|
|
86
|
+
if (!filterItemsRef.value || !popperPanelRef.value)
|
|
87
|
+
return;
|
|
88
|
+
const containerRight = filterContainerRightBoundary.value;
|
|
89
|
+
let lastVisibleItemRight = checkOverflow();
|
|
90
|
+
if (lastVisibleItemRight === -1 && filterItemsRef.value.children.length > 0) {
|
|
91
|
+
lastVisibleItemRight = getRect(filterItemsRef.value).left;
|
|
92
|
+
} else if (filterItemsRef.value.children.length === 0) {
|
|
93
|
+
lastVisibleItemRight = getRect(filterItemsRef.value).left;
|
|
94
|
+
}
|
|
95
|
+
await vue.nextTick();
|
|
96
|
+
let availableSpace = containerRight - lastVisibleItemRight;
|
|
97
|
+
while (hiddenElementList.value.length > 0) {
|
|
98
|
+
const nextHiddenItem = hiddenElementList.value[hiddenElementList.value.length - 1];
|
|
99
|
+
const nextHiddenItemWidth = nextHiddenItem.width;
|
|
100
|
+
if (availableSpace > nextHiddenItemWidth + 10) {
|
|
101
|
+
showElement();
|
|
102
|
+
await vue.nextTick();
|
|
103
|
+
const visibleElements = Array.from(
|
|
104
|
+
filterItemsRef.value.children
|
|
105
|
+
);
|
|
106
|
+
if (visibleElements.length > 0) {
|
|
107
|
+
lastVisibleItemRight = visibleElements.reduce((maxRight, el) => {
|
|
108
|
+
var _a;
|
|
109
|
+
if ((_a = el.classList) == null ? void 0 : _a.contains("filter-item")) {
|
|
110
|
+
return Math.max(maxRight, getRect(el).right);
|
|
111
|
+
}
|
|
112
|
+
return maxRight;
|
|
113
|
+
}, getRect(filterItemsRef.value).left);
|
|
114
|
+
} else {
|
|
115
|
+
lastVisibleItemRight = getRect(filterItemsRef.value).left;
|
|
116
|
+
}
|
|
117
|
+
availableSpace = containerRight - lastVisibleItemRight;
|
|
118
|
+
} else {
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
vue.onMounted(async () => {
|
|
124
|
+
initResizeListener();
|
|
125
|
+
initPopper("bottom-start", [0, 40]);
|
|
126
|
+
await vue.nextTick();
|
|
127
|
+
initWidths();
|
|
128
|
+
await vue.nextTick();
|
|
129
|
+
refreshLayout();
|
|
130
|
+
});
|
|
131
|
+
vue.onUnmounted(() => {
|
|
132
|
+
removeResizeListener();
|
|
133
|
+
});
|
|
134
|
+
return {
|
|
135
|
+
moreBtnRef,
|
|
136
|
+
popperPanelRef,
|
|
137
|
+
hiddenElementList,
|
|
138
|
+
visible,
|
|
139
|
+
show,
|
|
140
|
+
hide,
|
|
141
|
+
refreshLayout
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
exports.useResponsiveFilter = useResponsiveFilter;
|
|
@@ -177,6 +177,7 @@
|
|
|
177
177
|
}
|
|
178
178
|
.resource-list-footer {
|
|
179
179
|
display: flex;
|
|
180
|
+
flex-wrap: wrap;
|
|
180
181
|
justify-content: space-between;
|
|
181
182
|
padding-bottom: 20px;
|
|
182
183
|
}
|
|
@@ -186,6 +187,10 @@
|
|
|
186
187
|
gap: 10px;
|
|
187
188
|
align-items: center;
|
|
188
189
|
justify-content: flex-end;
|
|
190
|
+
margin-top: 10px;
|
|
191
|
+
}
|
|
192
|
+
.resource-list-footer .footer-right .list-selected-wrapper {
|
|
193
|
+
font-size: 12px;
|
|
189
194
|
}
|
|
190
195
|
.resource-list-content-loading {
|
|
191
196
|
display: flex;
|
|
@@ -240,7 +245,8 @@
|
|
|
240
245
|
}
|
|
241
246
|
.resource-list .list-filter-wrapper .list-filter-tags {
|
|
242
247
|
display: flex;
|
|
243
|
-
|
|
248
|
+
flex-wrap: wrap;
|
|
249
|
+
gap: 10px;
|
|
244
250
|
margin-top: 10px;
|
|
245
251
|
}
|
|
246
252
|
.resource-list .list-filter-wrapper .list-filter-tags .list-filter-tag {
|
|
@@ -261,16 +267,41 @@
|
|
|
261
267
|
justify-content: space-between;
|
|
262
268
|
}
|
|
263
269
|
.resource-list .list-filter-wrapper .list-filter .filter-list {
|
|
270
|
+
position: relative;
|
|
271
|
+
/** 给 popup 一个参考 */
|
|
264
272
|
display: flex;
|
|
265
|
-
flex-wrap: wrap;
|
|
266
|
-
gap: 10px;
|
|
267
273
|
}
|
|
268
274
|
.resource-list .list-filter-wrapper .list-filter .filter-list .filter-item {
|
|
269
275
|
width: 100px;
|
|
276
|
+
margin-right: 10px;
|
|
277
|
+
}
|
|
278
|
+
.resource-list .list-filter-wrapper .list-filter .filter-list .arco-trigger-popup {
|
|
279
|
+
z-index: 100000 !important;
|
|
270
280
|
}
|
|
271
281
|
.resource-list .list-filter-wrapper .list-filter .arco-input-prepend {
|
|
272
282
|
padding: 0;
|
|
273
283
|
}
|
|
284
|
+
.resource-list .list-filter-wrapper .list-filter .more-btn {
|
|
285
|
+
position: relative;
|
|
286
|
+
/** 给 poperjs 一个参考 */
|
|
287
|
+
}
|
|
288
|
+
.resource-list .list-filter-wrapper .list-filter .more-btn .filter-pannel {
|
|
289
|
+
inset: 40px auto auto auto !important;
|
|
290
|
+
}
|
|
291
|
+
.resource-list .list-filter-wrapper .filter-extra {
|
|
292
|
+
display: flex;
|
|
293
|
+
gap: 10px;
|
|
294
|
+
}
|
|
295
|
+
.resource-list .list-filter-wrapper .filter-pannel {
|
|
296
|
+
z-index: 100000;
|
|
297
|
+
display: flex;
|
|
298
|
+
flex-direction: column;
|
|
299
|
+
gap: 10px;
|
|
300
|
+
padding: 10px;
|
|
301
|
+
background-color: #fff;
|
|
302
|
+
border-radius: 4px;
|
|
303
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
|
304
|
+
}
|
|
274
305
|
.resource-list .title {
|
|
275
306
|
display: flex;
|
|
276
307
|
gap: 8px;
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
&-footer {
|
|
22
22
|
display: flex;
|
|
23
|
+
flex-wrap: wrap;
|
|
23
24
|
justify-content: space-between;
|
|
24
25
|
padding-bottom: 20px;
|
|
25
26
|
|
|
@@ -29,6 +30,11 @@
|
|
|
29
30
|
gap: 10px;
|
|
30
31
|
align-items: center;
|
|
31
32
|
justify-content: flex-end;
|
|
33
|
+
margin-top: 10px;
|
|
34
|
+
|
|
35
|
+
.list-selected-wrapper {
|
|
36
|
+
font-size: 12px;
|
|
37
|
+
}
|
|
32
38
|
}
|
|
33
39
|
}
|
|
34
40
|
|
|
@@ -108,7 +114,8 @@
|
|
|
108
114
|
.resource-list .list-filter-wrapper {
|
|
109
115
|
.list-filter-tags {
|
|
110
116
|
display: flex;
|
|
111
|
-
|
|
117
|
+
flex-wrap: wrap;
|
|
118
|
+
gap: 10px;
|
|
112
119
|
margin-top: 10px;
|
|
113
120
|
|
|
114
121
|
.list-filter-tag {
|
|
@@ -133,18 +140,46 @@
|
|
|
133
140
|
justify-content: space-between;
|
|
134
141
|
|
|
135
142
|
.filter-list {
|
|
143
|
+
position: relative; /** 给 popup 一个参考 */
|
|
136
144
|
display: flex;
|
|
137
|
-
flex-wrap: wrap;
|
|
138
|
-
gap: 10px;
|
|
139
145
|
|
|
140
146
|
.filter-item {
|
|
141
147
|
width: 100px;
|
|
148
|
+
margin-right: 10px;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.arco-trigger-popup {
|
|
152
|
+
z-index: 100000 !important;
|
|
142
153
|
}
|
|
143
154
|
}
|
|
144
155
|
|
|
145
156
|
.arco-input-prepend {
|
|
146
157
|
padding: 0;
|
|
147
158
|
}
|
|
159
|
+
|
|
160
|
+
.more-btn {
|
|
161
|
+
position: relative; /** 给 poperjs 一个参考 */
|
|
162
|
+
|
|
163
|
+
.filter-pannel {
|
|
164
|
+
inset: 40px auto auto auto !important;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.filter-extra {
|
|
170
|
+
display: flex;
|
|
171
|
+
gap: 10px;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.filter-pannel {
|
|
175
|
+
z-index: 100000;
|
|
176
|
+
display: flex;
|
|
177
|
+
flex-direction: column;
|
|
178
|
+
gap: 10px;
|
|
179
|
+
padding: 10px;
|
|
180
|
+
background-color: #fff;
|
|
181
|
+
border-radius: 4px;
|
|
182
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
|
148
183
|
}
|
|
149
184
|
}
|
|
150
185
|
|