@cmstops/pro-compo 3.9.1-rc.5 → 3.9.1-stable.0
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 +4 -45
- package/dist/index.min.css +1 -1
- package/es/baseFilter/component.js +71 -14
- package/es/config.js +1 -1
- package/es/contentDetailList/component.js +0 -24
- package/es/contentDetailList/components/Content/index.js +1 -2
- package/es/contentDetailList/components/Doc/index.js +0 -6
- package/es/hooks/usePopper.d.ts +1 -1
- package/es/hooks/usePopper.js +3 -3
- package/es/index.css +4 -45
- package/es/selectResourceModal/components/List/ListNormal/Filter.js +90 -192
- package/es/selectResourceModal/components/List/ListNormal/index.js +7 -23
- package/es/selectResourceModal/style/index.css +4 -45
- package/es/selectResourceModal/style/index.less +0 -14
- package/es/selectResourceModal/style/list.less +4 -40
- package/es/selectThumb/component.js +18 -7
- package/es/utils/index.js +6 -6
- package/lib/baseFilter/component.js +69 -12
- package/lib/config.js +1 -1
- package/lib/contentDetailList/component.js +0 -24
- package/lib/contentDetailList/components/Content/index.js +1 -2
- package/lib/contentDetailList/components/Doc/index.js +0 -6
- package/lib/hooks/usePopper.js +3 -3
- package/lib/index.css +4 -45
- package/lib/selectResourceModal/components/List/ListNormal/Filter.js +87 -189
- package/lib/selectResourceModal/components/List/ListNormal/index.js +6 -22
- package/lib/selectResourceModal/style/index.css +4 -45
- package/lib/selectResourceModal/style/index.less +0 -14
- package/lib/selectResourceModal/style/list.less +4 -40
- package/lib/selectThumb/component.js +18 -7
- package/lib/utils/index.js +6 -6
- package/package.json +1 -1
- package/es/selectResourceModal/__demo__/module/DivWrapper.d.ts +0 -268
- package/es/selectResourceModal/__demo__/module/basic.d.ts +0 -299
- package/es/selectResourceModal/hooks/useResponsiveFilter.d.ts +0 -21
- package/es/selectResourceModal/hooks/useResponsiveFilter.js +0 -142
- package/lib/selectResourceModal/hooks/useResponsiveFilter.js +0 -144
|
@@ -1,299 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file
|
|
3
|
-
* @title selectResourceModal
|
|
4
|
-
* @memberOf 组件类型,例如:数据输入
|
|
5
|
-
* @description 描述你的组件。
|
|
6
|
-
*/
|
|
7
|
-
export declare const BasicDemo: {
|
|
8
|
-
(args: any): {
|
|
9
|
-
components: {
|
|
10
|
-
selectResourceModal: any;
|
|
11
|
-
AButton: {
|
|
12
|
-
new (...args: any[]): {
|
|
13
|
-
$: import("vue").ComponentInternalInstance;
|
|
14
|
-
$data: {};
|
|
15
|
-
$props: Partial<{
|
|
16
|
-
disabled: boolean;
|
|
17
|
-
loading: boolean;
|
|
18
|
-
long: boolean;
|
|
19
|
-
htmlType: string;
|
|
20
|
-
}> & Omit<Readonly<{
|
|
21
|
-
type?: unknown;
|
|
22
|
-
shape?: unknown;
|
|
23
|
-
status?: unknown;
|
|
24
|
-
size?: unknown;
|
|
25
|
-
long?: unknown;
|
|
26
|
-
loading?: unknown;
|
|
27
|
-
disabled?: unknown;
|
|
28
|
-
htmlType?: unknown;
|
|
29
|
-
href?: unknown;
|
|
30
|
-
} & {
|
|
31
|
-
disabled: boolean;
|
|
32
|
-
loading: boolean;
|
|
33
|
-
long: boolean;
|
|
34
|
-
htmlType: string;
|
|
35
|
-
} & {
|
|
36
|
-
size?: "small" | "mini" | "medium" | "large" | undefined;
|
|
37
|
-
type?: "text" | "dashed" | "outline" | "primary" | "secondary" | undefined;
|
|
38
|
-
href?: string | undefined;
|
|
39
|
-
shape?: "circle" | "round" | "square" | undefined;
|
|
40
|
-
status?: "success" | "normal" | "warning" | "danger" | undefined;
|
|
41
|
-
}> & {
|
|
42
|
-
onClick?: ((ev: MouseEvent) => any) | undefined;
|
|
43
|
-
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "long" | "loading" | "disabled" | "htmlType">;
|
|
44
|
-
$attrs: {
|
|
45
|
-
[x: string]: unknown;
|
|
46
|
-
};
|
|
47
|
-
$refs: {
|
|
48
|
-
[x: string]: unknown;
|
|
49
|
-
};
|
|
50
|
-
$slots: Readonly<{
|
|
51
|
-
[name: string]: import("vue").Slot<any> | undefined;
|
|
52
|
-
}>;
|
|
53
|
-
$root: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string, {}, {}, {}, string, import("vue").ComponentProvideOptions>, {}, {}, "", {}, any> | null;
|
|
54
|
-
$parent: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string, {}, {}, {}, string, import("vue").ComponentProvideOptions>, {}, {}, "", {}, any> | null;
|
|
55
|
-
$emit: (event: "click", ev: MouseEvent) => void;
|
|
56
|
-
$el: any;
|
|
57
|
-
$options: import("vue").ComponentOptionsBase<Readonly<{
|
|
58
|
-
type?: unknown;
|
|
59
|
-
shape?: unknown;
|
|
60
|
-
status?: unknown;
|
|
61
|
-
size?: unknown;
|
|
62
|
-
long?: unknown;
|
|
63
|
-
loading?: unknown;
|
|
64
|
-
disabled?: unknown;
|
|
65
|
-
htmlType?: unknown;
|
|
66
|
-
href?: unknown;
|
|
67
|
-
} & {
|
|
68
|
-
disabled: boolean;
|
|
69
|
-
loading: boolean;
|
|
70
|
-
long: boolean;
|
|
71
|
-
htmlType: string;
|
|
72
|
-
} & {
|
|
73
|
-
size?: "small" | "mini" | "medium" | "large" | undefined;
|
|
74
|
-
type?: "text" | "dashed" | "outline" | "primary" | "secondary" | undefined;
|
|
75
|
-
href?: string | undefined;
|
|
76
|
-
shape?: "circle" | "round" | "square" | undefined;
|
|
77
|
-
status?: "success" | "normal" | "warning" | "danger" | undefined;
|
|
78
|
-
}> & {
|
|
79
|
-
onClick?: ((ev: MouseEvent) => any) | undefined;
|
|
80
|
-
}, {
|
|
81
|
-
prefixCls: string;
|
|
82
|
-
cls: import("vue").ComputedRef<(string | {
|
|
83
|
-
[x: string]: boolean;
|
|
84
|
-
})[]>;
|
|
85
|
-
mergedDisabled: import("vue").ComputedRef<boolean>;
|
|
86
|
-
handleClick: (ev: MouseEvent) => void;
|
|
87
|
-
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
88
|
-
click: (ev: MouseEvent) => true;
|
|
89
|
-
}, string, {
|
|
90
|
-
disabled: boolean;
|
|
91
|
-
loading: boolean;
|
|
92
|
-
long: boolean;
|
|
93
|
-
htmlType: string;
|
|
94
|
-
}, {}, string, {}, {}, {}, string, import("vue").ComponentProvideOptions> & {
|
|
95
|
-
beforeCreate?: (() => void) | (() => void)[] | undefined;
|
|
96
|
-
created?: (() => void) | (() => void)[] | undefined;
|
|
97
|
-
beforeMount?: (() => void) | (() => void)[] | undefined;
|
|
98
|
-
mounted?: (() => void) | (() => void)[] | undefined;
|
|
99
|
-
beforeUpdate?: (() => void) | (() => void)[] | undefined;
|
|
100
|
-
updated?: (() => void) | (() => void)[] | undefined;
|
|
101
|
-
activated?: (() => void) | (() => void)[] | undefined;
|
|
102
|
-
deactivated?: (() => void) | (() => void)[] | undefined;
|
|
103
|
-
beforeDestroy?: (() => void) | (() => void)[] | undefined;
|
|
104
|
-
beforeUnmount?: (() => void) | (() => void)[] | undefined;
|
|
105
|
-
destroyed?: (() => void) | (() => void)[] | undefined;
|
|
106
|
-
unmounted?: (() => void) | (() => void)[] | undefined;
|
|
107
|
-
renderTracked?: ((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[] | undefined;
|
|
108
|
-
renderTriggered?: ((e: import("vue").DebuggerEvent) => void) | ((e: import("vue").DebuggerEvent) => void)[] | undefined;
|
|
109
|
-
errorCaptured?: ((err: unknown, instance: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string, {}, {}, {}, string, import("vue").ComponentProvideOptions>, {}, {}, "", {}, any> | null, info: string) => boolean | void) | ((err: unknown, instance: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string, {}, {}, {}, string, import("vue").ComponentProvideOptions>, {}, {}, "", {}, any> | null, info: string) => boolean | void)[] | undefined;
|
|
110
|
-
};
|
|
111
|
-
$forceUpdate: () => void;
|
|
112
|
-
$nextTick: typeof import("vue").nextTick;
|
|
113
|
-
$watch(source: string | Function, cb: Function, options?: import("vue").WatchOptions<boolean> | undefined): import("vue").WatchStopHandle;
|
|
114
|
-
} & Readonly<{
|
|
115
|
-
type?: unknown;
|
|
116
|
-
shape?: unknown;
|
|
117
|
-
status?: unknown;
|
|
118
|
-
size?: unknown;
|
|
119
|
-
long?: unknown;
|
|
120
|
-
loading?: unknown;
|
|
121
|
-
disabled?: unknown;
|
|
122
|
-
htmlType?: unknown;
|
|
123
|
-
href?: unknown;
|
|
124
|
-
} & {
|
|
125
|
-
disabled: boolean;
|
|
126
|
-
loading: boolean;
|
|
127
|
-
long: boolean;
|
|
128
|
-
htmlType: string;
|
|
129
|
-
} & {
|
|
130
|
-
size?: "small" | "mini" | "medium" | "large" | undefined;
|
|
131
|
-
type?: "text" | "dashed" | "outline" | "primary" | "secondary" | undefined;
|
|
132
|
-
href?: string | undefined;
|
|
133
|
-
shape?: "circle" | "round" | "square" | undefined;
|
|
134
|
-
status?: "success" | "normal" | "warning" | "danger" | undefined;
|
|
135
|
-
}> & {
|
|
136
|
-
onClick?: ((ev: MouseEvent) => any) | undefined;
|
|
137
|
-
} & import("vue").ShallowUnwrapRef<{
|
|
138
|
-
prefixCls: string;
|
|
139
|
-
cls: import("vue").ComputedRef<(string | {
|
|
140
|
-
[x: string]: boolean;
|
|
141
|
-
})[]>;
|
|
142
|
-
mergedDisabled: import("vue").ComputedRef<boolean>;
|
|
143
|
-
handleClick: (ev: MouseEvent) => void;
|
|
144
|
-
}> & import("vue").ComponentCustomProperties;
|
|
145
|
-
__isFragment?: undefined;
|
|
146
|
-
__isTeleport?: undefined;
|
|
147
|
-
__isSuspense?: undefined;
|
|
148
|
-
} & import("vue").ComponentOptionsBase<Readonly<{
|
|
149
|
-
type?: unknown;
|
|
150
|
-
shape?: unknown;
|
|
151
|
-
status?: unknown;
|
|
152
|
-
size?: unknown;
|
|
153
|
-
long?: unknown;
|
|
154
|
-
loading?: unknown;
|
|
155
|
-
disabled?: unknown;
|
|
156
|
-
htmlType?: unknown;
|
|
157
|
-
href?: unknown;
|
|
158
|
-
} & {
|
|
159
|
-
disabled: boolean;
|
|
160
|
-
loading: boolean;
|
|
161
|
-
long: boolean;
|
|
162
|
-
htmlType: string;
|
|
163
|
-
} & {
|
|
164
|
-
size?: "small" | "mini" | "medium" | "large" | undefined;
|
|
165
|
-
type?: "text" | "dashed" | "outline" | "primary" | "secondary" | undefined;
|
|
166
|
-
href?: string | undefined;
|
|
167
|
-
shape?: "circle" | "round" | "square" | undefined;
|
|
168
|
-
status?: "success" | "normal" | "warning" | "danger" | undefined;
|
|
169
|
-
}> & {
|
|
170
|
-
onClick?: ((ev: MouseEvent) => any) | undefined;
|
|
171
|
-
}, {
|
|
172
|
-
prefixCls: string;
|
|
173
|
-
cls: import("vue").ComputedRef<(string | {
|
|
174
|
-
[x: string]: boolean;
|
|
175
|
-
})[]>;
|
|
176
|
-
mergedDisabled: import("vue").ComputedRef<boolean>;
|
|
177
|
-
handleClick: (ev: MouseEvent) => void;
|
|
178
|
-
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
179
|
-
click: (ev: MouseEvent) => true;
|
|
180
|
-
}, string, {
|
|
181
|
-
disabled: boolean;
|
|
182
|
-
loading: boolean;
|
|
183
|
-
long: boolean;
|
|
184
|
-
htmlType: string;
|
|
185
|
-
}, {}, string, {}, {}, {}, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & {
|
|
186
|
-
Group: import("vue").DefineComponent<{
|
|
187
|
-
type: {
|
|
188
|
-
type: import("vue").PropType<"text" | "dashed" | "outline" | "primary" | "secondary">;
|
|
189
|
-
};
|
|
190
|
-
status: {
|
|
191
|
-
type: import("vue").PropType<"success" | "normal" | "warning" | "danger">;
|
|
192
|
-
};
|
|
193
|
-
shape: {
|
|
194
|
-
type: import("vue").PropType<"circle" | "round" | "square">;
|
|
195
|
-
};
|
|
196
|
-
size: {
|
|
197
|
-
type: import("vue").PropType<"small" | "mini" | "medium" | "large">;
|
|
198
|
-
};
|
|
199
|
-
disabled: {
|
|
200
|
-
type: BooleanConstructor;
|
|
201
|
-
};
|
|
202
|
-
}, {
|
|
203
|
-
prefixCls: string;
|
|
204
|
-
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
|
|
205
|
-
type?: unknown;
|
|
206
|
-
status?: unknown;
|
|
207
|
-
shape?: unknown;
|
|
208
|
-
size?: unknown;
|
|
209
|
-
disabled?: unknown;
|
|
210
|
-
} & {
|
|
211
|
-
disabled: boolean;
|
|
212
|
-
} & {
|
|
213
|
-
size?: "small" | "mini" | "medium" | "large" | undefined;
|
|
214
|
-
type?: "text" | "dashed" | "outline" | "primary" | "secondary" | undefined;
|
|
215
|
-
shape?: "circle" | "round" | "square" | undefined;
|
|
216
|
-
status?: "success" | "normal" | "warning" | "danger" | undefined;
|
|
217
|
-
}>, {
|
|
218
|
-
disabled: boolean;
|
|
219
|
-
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
220
|
-
install: (app: import("vue").App<any>, options?: import("@arco-design/web-vue/es/_utils/types").ArcoOptions | undefined) => void;
|
|
221
|
-
};
|
|
222
|
-
};
|
|
223
|
-
setup(): {
|
|
224
|
-
visible: import("vue").Ref<boolean, boolean>;
|
|
225
|
-
submit: (data: any, ...args: any) => void;
|
|
226
|
-
args: any;
|
|
227
|
-
};
|
|
228
|
-
template: string;
|
|
229
|
-
};
|
|
230
|
-
args: {
|
|
231
|
-
wrap: string;
|
|
232
|
-
userInfo: {
|
|
233
|
-
domain_id: number;
|
|
234
|
-
repository_id: number;
|
|
235
|
-
};
|
|
236
|
-
maxcount: number;
|
|
237
|
-
filterOptions: {
|
|
238
|
-
mediaType: string;
|
|
239
|
-
mediaTypeStrict: boolean;
|
|
240
|
-
};
|
|
241
|
-
mediaUseType: number;
|
|
242
|
-
aiThumbList: string[];
|
|
243
|
-
videoThumbOptions: {
|
|
244
|
-
src: string;
|
|
245
|
-
duration: number;
|
|
246
|
-
};
|
|
247
|
-
};
|
|
248
|
-
argTypes: {
|
|
249
|
-
wrap: {
|
|
250
|
-
description: string;
|
|
251
|
-
control: {
|
|
252
|
-
type: string;
|
|
253
|
-
options: string[];
|
|
254
|
-
};
|
|
255
|
-
};
|
|
256
|
-
userInfo: {
|
|
257
|
-
description: string;
|
|
258
|
-
control: {
|
|
259
|
-
type: string;
|
|
260
|
-
};
|
|
261
|
-
};
|
|
262
|
-
maxcount: {
|
|
263
|
-
description: string;
|
|
264
|
-
control: {
|
|
265
|
-
type: string;
|
|
266
|
-
};
|
|
267
|
-
};
|
|
268
|
-
filterOptions: {
|
|
269
|
-
description: string;
|
|
270
|
-
control: {
|
|
271
|
-
type: string;
|
|
272
|
-
};
|
|
273
|
-
};
|
|
274
|
-
mediaUseType: {
|
|
275
|
-
description: string;
|
|
276
|
-
control: {
|
|
277
|
-
type: string;
|
|
278
|
-
};
|
|
279
|
-
};
|
|
280
|
-
aiThumbList: {
|
|
281
|
-
description: string;
|
|
282
|
-
control: {
|
|
283
|
-
type: string;
|
|
284
|
-
};
|
|
285
|
-
};
|
|
286
|
-
videoThumbOptions: {
|
|
287
|
-
description: string;
|
|
288
|
-
control: {
|
|
289
|
-
type: string;
|
|
290
|
-
};
|
|
291
|
-
};
|
|
292
|
-
onSubmit: {
|
|
293
|
-
action: string;
|
|
294
|
-
};
|
|
295
|
-
onUpdateVis: {
|
|
296
|
-
action: string;
|
|
297
|
-
};
|
|
298
|
-
};
|
|
299
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { Ref } from 'vue';
|
|
2
|
-
declare type HideElementType = {
|
|
3
|
-
width: number;
|
|
4
|
-
el: HTMLDivElement;
|
|
5
|
-
};
|
|
6
|
-
export declare function useResponsiveFilter(filterItemsRef: Ref<HTMLElement | undefined>): {
|
|
7
|
-
moreBtnRef: Ref<HTMLElement | undefined, HTMLElement | undefined>;
|
|
8
|
-
popperPanelRef: Ref<HTMLElement | undefined, HTMLElement | undefined>;
|
|
9
|
-
hiddenElementList: Ref<{
|
|
10
|
-
width: number;
|
|
11
|
-
el: HTMLDivElement;
|
|
12
|
-
}[], HideElementType[] | {
|
|
13
|
-
width: number;
|
|
14
|
-
el: HTMLDivElement;
|
|
15
|
-
}[]>;
|
|
16
|
-
visible: Ref<boolean, boolean>;
|
|
17
|
-
show: () => void;
|
|
18
|
-
hide: () => void;
|
|
19
|
-
refreshLayout: () => Promise<void>;
|
|
20
|
-
};
|
|
21
|
-
export {};
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { ref, onMounted, nextTick, onUnmounted } from "vue";
|
|
2
|
-
import usePopper from "../../hooks/usePopper.js";
|
|
3
|
-
const getRect = (el) => {
|
|
4
|
-
if (!el || typeof el.getClientRects !== "function")
|
|
5
|
-
return { right: 0, width: 0 };
|
|
6
|
-
const rects = el.getClientRects();
|
|
7
|
-
if (rects.length === 0)
|
|
8
|
-
return { right: 0, width: 0 };
|
|
9
|
-
const rect = rects[0];
|
|
10
|
-
return {
|
|
11
|
-
right: rect.right,
|
|
12
|
-
width: rect.width
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
function useResponsiveFilter(filterItemsRef) {
|
|
16
|
-
const moreBtnRef = ref();
|
|
17
|
-
const popperPanelRef = ref();
|
|
18
|
-
const { initPopper, show, visible, hide } = usePopper(
|
|
19
|
-
popperPanelRef,
|
|
20
|
-
moreBtnRef
|
|
21
|
-
);
|
|
22
|
-
const windowWidth = ref(0);
|
|
23
|
-
const filterContainerRightBoundary = ref(0);
|
|
24
|
-
const hiddenElementList = ref([]);
|
|
25
|
-
const initWidths = () => {
|
|
26
|
-
var _a, _b;
|
|
27
|
-
windowWidth.value = ((_a = document.body) == null ? void 0 : _a.clientWidth) || 0;
|
|
28
|
-
const containerElement = (_b = filterItemsRef.value) == null ? void 0 : _b.parentElement;
|
|
29
|
-
if (containerElement) {
|
|
30
|
-
filterContainerRightBoundary.value = getRect(containerElement).right;
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
const initResizeListener = () => {
|
|
34
|
-
window.addEventListener("resize", refreshLayout);
|
|
35
|
-
};
|
|
36
|
-
const removeResizeListener = () => {
|
|
37
|
-
window.removeEventListener("resize", refreshLayout);
|
|
38
|
-
};
|
|
39
|
-
const hideElement = (el) => {
|
|
40
|
-
var _a, _b, _c;
|
|
41
|
-
const { width } = getRect(el);
|
|
42
|
-
if (width > 0 && ((_a = filterItemsRef.value) == null ? void 0 : _a.contains(el))) {
|
|
43
|
-
hiddenElementList.value.push({ width, el });
|
|
44
|
-
(_b = filterItemsRef.value) == null ? void 0 : _b.removeChild(el);
|
|
45
|
-
(_c = popperPanelRef.value) == null ? void 0 : _c.insertBefore(el, popperPanelRef.value.firstChild);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
const showElement = () => {
|
|
49
|
-
var _a, _b;
|
|
50
|
-
if (!hiddenElementList.value.length || !filterItemsRef.value)
|
|
51
|
-
return;
|
|
52
|
-
const popEl = hiddenElementList.value.pop();
|
|
53
|
-
if (!popEl)
|
|
54
|
-
return;
|
|
55
|
-
const { el } = popEl;
|
|
56
|
-
(_a = popperPanelRef.value) == null ? void 0 : _a.removeChild(el);
|
|
57
|
-
(_b = filterItemsRef.value) == null ? void 0 : _b.appendChild(el);
|
|
58
|
-
};
|
|
59
|
-
const checkOverflow = () => {
|
|
60
|
-
if (!filterItemsRef.value)
|
|
61
|
-
return -1;
|
|
62
|
-
const containerRight = filterContainerRightBoundary.value;
|
|
63
|
-
const children = filterItemsRef.value.children;
|
|
64
|
-
let currentRightmostBoundary = getRect(filterItemsRef.value).right - getRect(filterItemsRef.value).width;
|
|
65
|
-
for (let i = children.length - 1; i >= 0; i--) {
|
|
66
|
-
const item = children[i];
|
|
67
|
-
if (!item || !item.classList || !item.classList.contains("filter-item"))
|
|
68
|
-
continue;
|
|
69
|
-
const itemRect = getRect(item);
|
|
70
|
-
if (itemRect.right > containerRight - 400) {
|
|
71
|
-
hideElement(item);
|
|
72
|
-
} else {
|
|
73
|
-
currentRightmostBoundary = Math.max(
|
|
74
|
-
currentRightmostBoundary,
|
|
75
|
-
itemRect.right
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return currentRightmostBoundary;
|
|
80
|
-
};
|
|
81
|
-
const refreshLayout = async () => {
|
|
82
|
-
await nextTick();
|
|
83
|
-
initWidths();
|
|
84
|
-
if (!filterItemsRef.value || !popperPanelRef.value)
|
|
85
|
-
return;
|
|
86
|
-
const containerRight = filterContainerRightBoundary.value;
|
|
87
|
-
let lastVisibleItemRight = checkOverflow();
|
|
88
|
-
if (lastVisibleItemRight === -1 && filterItemsRef.value.children.length > 0) {
|
|
89
|
-
lastVisibleItemRight = getRect(filterItemsRef.value).left;
|
|
90
|
-
} else if (filterItemsRef.value.children.length === 0) {
|
|
91
|
-
lastVisibleItemRight = getRect(filterItemsRef.value).left;
|
|
92
|
-
}
|
|
93
|
-
await nextTick();
|
|
94
|
-
let availableSpace = containerRight - lastVisibleItemRight;
|
|
95
|
-
while (hiddenElementList.value.length > 0) {
|
|
96
|
-
const nextHiddenItem = hiddenElementList.value[hiddenElementList.value.length - 1];
|
|
97
|
-
const nextHiddenItemWidth = nextHiddenItem.width;
|
|
98
|
-
if (availableSpace > nextHiddenItemWidth + 10) {
|
|
99
|
-
showElement();
|
|
100
|
-
await nextTick();
|
|
101
|
-
const visibleElements = Array.from(
|
|
102
|
-
filterItemsRef.value.children
|
|
103
|
-
);
|
|
104
|
-
if (visibleElements.length > 0) {
|
|
105
|
-
lastVisibleItemRight = visibleElements.reduce((maxRight, el) => {
|
|
106
|
-
var _a;
|
|
107
|
-
if ((_a = el.classList) == null ? void 0 : _a.contains("filter-item")) {
|
|
108
|
-
return Math.max(maxRight, getRect(el).right);
|
|
109
|
-
}
|
|
110
|
-
return maxRight;
|
|
111
|
-
}, getRect(filterItemsRef.value).left);
|
|
112
|
-
} else {
|
|
113
|
-
lastVisibleItemRight = getRect(filterItemsRef.value).left;
|
|
114
|
-
}
|
|
115
|
-
availableSpace = containerRight - lastVisibleItemRight;
|
|
116
|
-
} else {
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
onMounted(async () => {
|
|
122
|
-
initResizeListener();
|
|
123
|
-
initPopper("bottom-start", [0, 40]);
|
|
124
|
-
await nextTick();
|
|
125
|
-
initWidths();
|
|
126
|
-
await nextTick();
|
|
127
|
-
refreshLayout();
|
|
128
|
-
});
|
|
129
|
-
onUnmounted(() => {
|
|
130
|
-
removeResizeListener();
|
|
131
|
-
});
|
|
132
|
-
return {
|
|
133
|
-
moreBtnRef,
|
|
134
|
-
popperPanelRef,
|
|
135
|
-
hiddenElementList,
|
|
136
|
-
visible,
|
|
137
|
-
show,
|
|
138
|
-
hide,
|
|
139
|
-
refreshLayout
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
export { useResponsiveFilter };
|
|
@@ -1,144 +0,0 @@
|
|
|
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 - 400) {
|
|
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;
|