@deot/vc-components 1.0.46 → 1.0.48
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.cjs +143 -50
- package/dist/index.d.ts +159 -111
- package/dist/index.iife.js +171 -78
- package/dist/index.js +145 -52
- package/dist/index.style.css +1 -1
- package/dist/index.umd.cjs +171 -78
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -128,6 +128,10 @@ const ActionSheet = /* @__PURE__ */ vue.defineComponent({
|
|
|
128
128
|
const MActionSheet = ActionSheet;
|
|
129
129
|
|
|
130
130
|
const props$1s = {
|
|
131
|
+
modelValue: {
|
|
132
|
+
type: Boolean,
|
|
133
|
+
default: false
|
|
134
|
+
},
|
|
131
135
|
zIndex: {
|
|
132
136
|
type: [Number, String],
|
|
133
137
|
default: 1
|
|
@@ -155,16 +159,45 @@ const props$1s = {
|
|
|
155
159
|
}
|
|
156
160
|
};
|
|
157
161
|
|
|
162
|
+
let scrollBarWidth;
|
|
163
|
+
const getScrollBarWidth = () => {
|
|
164
|
+
if (scrollBarWidth !== void 0) return scrollBarWidth;
|
|
165
|
+
const outer = document.createElement("div");
|
|
166
|
+
outer.className = "vc-scrollbar__wrap";
|
|
167
|
+
outer.style.visibility = "hidden";
|
|
168
|
+
outer.style.width = "100px";
|
|
169
|
+
outer.style.position = "absolute";
|
|
170
|
+
outer.style.top = "-9999px";
|
|
171
|
+
document.body.appendChild(outer);
|
|
172
|
+
const widthNoScroll = outer.offsetWidth;
|
|
173
|
+
outer.style.overflow = "scroll";
|
|
174
|
+
const inner = document.createElement("div");
|
|
175
|
+
inner.style.width = "100%";
|
|
176
|
+
outer.appendChild(inner);
|
|
177
|
+
const widthWithScroll = inner.offsetWidth;
|
|
178
|
+
outer.parentNode?.removeChild?.(outer);
|
|
179
|
+
scrollBarWidth = widthNoScroll - widthWithScroll;
|
|
180
|
+
return scrollBarWidth;
|
|
181
|
+
};
|
|
182
|
+
const SCROLLER_WHEEL_REG = /vc-scroller-wheel/;
|
|
183
|
+
const getScroller = (el) => {
|
|
184
|
+
return $.getScroller(el, { className: SCROLLER_WHEEL_REG });
|
|
185
|
+
};
|
|
186
|
+
const isWheel = (el) => {
|
|
187
|
+
return SCROLLER_WHEEL_REG.test(el?.className || "");
|
|
188
|
+
};
|
|
189
|
+
|
|
158
190
|
/** @jsxImportSource vue */
|
|
159
191
|
|
|
160
192
|
const COMPONENT_NAME$27 = 'vc-affix';
|
|
161
|
-
const SCROLLER_WHEEL_REG = /vc-scroller-wheel/;
|
|
162
193
|
const Affix = /* @__PURE__ */ vue.defineComponent({
|
|
163
194
|
name: COMPONENT_NAME$27,
|
|
195
|
+
emits: ['update:modelValue'],
|
|
164
196
|
props: props$1s,
|
|
165
197
|
setup(props, {
|
|
166
198
|
slots,
|
|
167
|
-
expose
|
|
199
|
+
expose,
|
|
200
|
+
emit
|
|
168
201
|
}) {
|
|
169
202
|
const scrollerInstance = vue.inject('vc-scroller', null);
|
|
170
203
|
const scroller = vue.shallowRef(); // 当前元素所在的滚动容器
|
|
@@ -180,9 +213,7 @@ const Affix = /* @__PURE__ */ vue.defineComponent({
|
|
|
180
213
|
const isActive = vue.ref(false);
|
|
181
214
|
const transformY = vue.ref(0);
|
|
182
215
|
const windowHeight = vue.ref(window.innerHeight);
|
|
183
|
-
const isVcScrollerWheel = vue.computed(() =>
|
|
184
|
-
return SCROLLER_WHEEL_REG.test(scroller.value?.className || '');
|
|
185
|
-
});
|
|
216
|
+
const isVcScrollerWheel = vue.computed(() => isWheel(scroller.value));
|
|
186
217
|
const currentStyle = vue.computed(() => {
|
|
187
218
|
if (!isActive.value) return {};
|
|
188
219
|
return {
|
|
@@ -203,7 +234,8 @@ const Affix = /* @__PURE__ */ vue.defineComponent({
|
|
|
203
234
|
};
|
|
204
235
|
});
|
|
205
236
|
const setCurrentRect = () => {
|
|
206
|
-
const rect = current.value
|
|
237
|
+
const rect = current.value?.getBoundingClientRect?.();
|
|
238
|
+
if (!rect) return;
|
|
207
239
|
Object.assign(currentRect, {
|
|
208
240
|
top: rect.top,
|
|
209
241
|
bottom: rect.bottom,
|
|
@@ -230,7 +262,7 @@ const Affix = /* @__PURE__ */ vue.defineComponent({
|
|
|
230
262
|
transformY.value = Math.min(containerRect.bottom - currentHeightOffset, 0) + transformOffsetY;
|
|
231
263
|
} else {
|
|
232
264
|
isActive.value = currentRect.bottom - containerRect.top >= containerRect.height - props.offset;
|
|
233
|
-
transformY.value =
|
|
265
|
+
transformY.value = transformOffsetY;
|
|
234
266
|
}
|
|
235
267
|
};
|
|
236
268
|
const setFixedStatus = () => {
|
|
@@ -257,36 +289,58 @@ const Affix = /* @__PURE__ */ vue.defineComponent({
|
|
|
257
289
|
}
|
|
258
290
|
}
|
|
259
291
|
};
|
|
292
|
+
const offScroll = handler => {
|
|
293
|
+
if (isVcScrollerWheel.value) {
|
|
294
|
+
scrollerInstance?.off(handler);
|
|
295
|
+
} else {
|
|
296
|
+
scroller.value?.removeEventListener('scroll', handler);
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
const onScroll = (handler, options) => {
|
|
300
|
+
// nextTick目的在与onMounted后执行
|
|
301
|
+
vue.nextTick(() => {
|
|
302
|
+
if (isVcScrollerWheel.value) {
|
|
303
|
+
scrollerInstance?.on(handler);
|
|
304
|
+
} else {
|
|
305
|
+
scroller.value?.addEventListener('scroll', handler);
|
|
306
|
+
}
|
|
307
|
+
options?.first && handler();
|
|
308
|
+
});
|
|
309
|
+
return () => offScroll(handler);
|
|
310
|
+
};
|
|
260
311
|
const refresh = () => {
|
|
312
|
+
if (props.disabled) return;
|
|
261
313
|
setCurrentRect();
|
|
262
314
|
scroller.value instanceof Window || props.fixed ? setFixedStatus() : setAbsoluteStatus();
|
|
315
|
+
emit('update:modelValue', isActive.value);
|
|
263
316
|
};
|
|
264
317
|
vue.onMounted(() => {
|
|
265
318
|
if (typeof props.target === 'string') {
|
|
266
319
|
base.value = document.querySelector(props.target) ?? void 0;
|
|
267
320
|
}
|
|
268
321
|
!base.value && (base.value = document.documentElement);
|
|
269
|
-
scroller.value =
|
|
270
|
-
|
|
322
|
+
scroller.value = getScroller(current.value);
|
|
323
|
+
onScroll(refresh, {
|
|
324
|
+
first: true
|
|
271
325
|
});
|
|
272
|
-
if (isVcScrollerWheel.value) {
|
|
273
|
-
scrollerInstance?.on(refresh);
|
|
274
|
-
} else {
|
|
275
|
-
scroller.value?.addEventListener('scroll', refresh);
|
|
276
|
-
}
|
|
277
|
-
refresh();
|
|
278
|
-
});
|
|
279
|
-
vue.onBeforeUnmount(() => {
|
|
280
|
-
if (isVcScrollerWheel.value) {
|
|
281
|
-
scrollerInstance?.off(refresh);
|
|
282
|
-
} else {
|
|
283
|
-
scroller.value?.removeEventListener('scroll', refresh);
|
|
284
|
-
}
|
|
285
326
|
});
|
|
327
|
+
vue.onBeforeUnmount(() => offScroll(refresh));
|
|
286
328
|
expose({
|
|
287
|
-
refresh
|
|
329
|
+
refresh,
|
|
330
|
+
onScroll,
|
|
331
|
+
offScroll
|
|
332
|
+
});
|
|
333
|
+
vue.provide('vc-affix', {
|
|
334
|
+
props,
|
|
335
|
+
isActive,
|
|
336
|
+
refresh,
|
|
337
|
+
onScroll,
|
|
338
|
+
offScroll
|
|
288
339
|
});
|
|
289
340
|
return () => {
|
|
341
|
+
if (props.disabled) return slots?.default?.({
|
|
342
|
+
active: false
|
|
343
|
+
});
|
|
290
344
|
return vue.createVNode("div", {
|
|
291
345
|
"ref": current,
|
|
292
346
|
"class": "vc-affix",
|
|
@@ -3750,7 +3804,8 @@ const props$19 = {
|
|
|
3750
3804
|
nullValue: {
|
|
3751
3805
|
type: [Number, String, Object],
|
|
3752
3806
|
default: void 0
|
|
3753
|
-
}
|
|
3807
|
+
},
|
|
3808
|
+
label: String
|
|
3754
3809
|
};
|
|
3755
3810
|
|
|
3756
3811
|
const props$18 = {
|
|
@@ -8862,27 +8917,6 @@ const props$T = {
|
|
|
8862
8917
|
}
|
|
8863
8918
|
};
|
|
8864
8919
|
|
|
8865
|
-
let scrollBarWidth;
|
|
8866
|
-
const getScrollBarWidth = () => {
|
|
8867
|
-
if (scrollBarWidth !== void 0) return scrollBarWidth;
|
|
8868
|
-
const outer = document.createElement("div");
|
|
8869
|
-
outer.className = "vc-scrollbar__wrap";
|
|
8870
|
-
outer.style.visibility = "hidden";
|
|
8871
|
-
outer.style.width = "100px";
|
|
8872
|
-
outer.style.position = "absolute";
|
|
8873
|
-
outer.style.top = "-9999px";
|
|
8874
|
-
document.body.appendChild(outer);
|
|
8875
|
-
const widthNoScroll = outer.offsetWidth;
|
|
8876
|
-
outer.style.overflow = "scroll";
|
|
8877
|
-
const inner = document.createElement("div");
|
|
8878
|
-
inner.style.width = "100%";
|
|
8879
|
-
outer.appendChild(inner);
|
|
8880
|
-
const widthWithScroll = inner.offsetWidth;
|
|
8881
|
-
outer.parentNode?.removeChild?.(outer);
|
|
8882
|
-
scrollBarWidth = widthNoScroll - widthWithScroll;
|
|
8883
|
-
return scrollBarWidth;
|
|
8884
|
-
};
|
|
8885
|
-
|
|
8886
8920
|
const barKeys$1 = [
|
|
8887
8921
|
"always",
|
|
8888
8922
|
"thumbMinSize",
|
|
@@ -14330,7 +14364,7 @@ const Select = /* @__PURE__ */ vue.defineComponent({
|
|
|
14330
14364
|
"style": its.value.style,
|
|
14331
14365
|
"animation": "y",
|
|
14332
14366
|
"onMouseenter": () => isHover.value = true,
|
|
14333
|
-
"
|
|
14367
|
+
"onMouseleave": () => isHover.value = false,
|
|
14334
14368
|
"onReady": () => emit('ready'),
|
|
14335
14369
|
"onClose": () => emit('close'),
|
|
14336
14370
|
"onVisibleChange": () => emit('visible-change', isActive.value),
|
|
@@ -14346,6 +14380,13 @@ const Select = /* @__PURE__ */ vue.defineComponent({
|
|
|
14346
14380
|
"readonly": true,
|
|
14347
14381
|
"placeholder": its.value.attrs?.placeholder || '请选择'
|
|
14348
14382
|
}, {
|
|
14383
|
+
prepend: slots.prepend || props.label ? () => {
|
|
14384
|
+
slots.prepend ? slots.prepend() : vue.createVNode("div", {
|
|
14385
|
+
"class": "vc-select__prepend"
|
|
14386
|
+
}, [vue.createVNode("span", {
|
|
14387
|
+
"class": "vc-select__label"
|
|
14388
|
+
}, [props.label])]);
|
|
14389
|
+
} : null,
|
|
14349
14390
|
content: multiple.value && currentValue.value && currentValue.value.length > 0 ? () => {
|
|
14350
14391
|
return vue.createVNode("div", {
|
|
14351
14392
|
"class": [classes.value, 'vc-select__tags']
|
|
@@ -14367,7 +14408,7 @@ const Select = /* @__PURE__ */ vue.defineComponent({
|
|
|
14367
14408
|
}, [vue.createVNode(Icon, {
|
|
14368
14409
|
"type": showClear.value ? 'clear' : icon.value,
|
|
14369
14410
|
"class": [{
|
|
14370
|
-
'is-arrow': !showClear
|
|
14411
|
+
'is-arrow': !showClear.value
|
|
14371
14412
|
}, 'vc-select__icon'],
|
|
14372
14413
|
"onClick": handleClear
|
|
14373
14414
|
}, null)]);
|
|
@@ -19987,10 +20028,13 @@ const props$c = {
|
|
|
19987
20028
|
barStyle: [Object, String],
|
|
19988
20029
|
contentStyle: [Object, String],
|
|
19989
20030
|
barClass: [Object, String],
|
|
19990
|
-
contentClass: [Object, String]
|
|
20031
|
+
contentClass: [Object, String],
|
|
20032
|
+
affixable: Boolean,
|
|
20033
|
+
affixOptions: Object
|
|
19991
20034
|
};
|
|
19992
20035
|
|
|
19993
20036
|
const useTabs = (options = {}) => {
|
|
20037
|
+
const affix = vue.inject("vc-affix", null);
|
|
19994
20038
|
const instance = vue.getCurrentInstance();
|
|
19995
20039
|
const { props, emit } = instance;
|
|
19996
20040
|
const tabsId = vue.ref(Utils.getUid("tabs"));
|
|
@@ -20032,10 +20076,56 @@ const useTabs = (options = {}) => {
|
|
|
20032
20076
|
[`is-${props.theme}`]: !!props.theme
|
|
20033
20077
|
};
|
|
20034
20078
|
});
|
|
20079
|
+
const hasAnchor = vue.computed(() => {
|
|
20080
|
+
return list.value.some((item) => !!item.anchor);
|
|
20081
|
+
});
|
|
20035
20082
|
const refresh = () => {
|
|
20036
20083
|
options?.refreshAfloat?.();
|
|
20037
20084
|
};
|
|
20038
|
-
|
|
20085
|
+
let scrollToAnchorTimer;
|
|
20086
|
+
const scrollToAnchor = (anchor) => {
|
|
20087
|
+
if (!anchor) return;
|
|
20088
|
+
const el = document.querySelector(anchor);
|
|
20089
|
+
if (!el) return;
|
|
20090
|
+
const scroller = getScroller(instance.vnode.el);
|
|
20091
|
+
$.scrollIntoView(scroller, {
|
|
20092
|
+
duration: 250,
|
|
20093
|
+
from: scroller.scrollTop,
|
|
20094
|
+
to: scroller.scrollTop + el.getBoundingClientRect().top - scroller.getBoundingClientRect().top - (!affix || affix.props.placement !== "bottom" ? instance.vnode.el.offsetHeight : 0) - (affix && affix.props.placement !== "bottom" ? affix.props.offset : 0)
|
|
20095
|
+
});
|
|
20096
|
+
scrollToAnchorTimer && clearTimeout(scrollToAnchorTimer);
|
|
20097
|
+
scrollToAnchorTimer = setTimeout(() => scrollToAnchorTimer = null, 300);
|
|
20098
|
+
};
|
|
20099
|
+
const handleAffixScroll = () => {
|
|
20100
|
+
if (!hasAnchor.value || scrollToAnchorTimer) return;
|
|
20101
|
+
const scroller = getScroller(instance.vnode.el);
|
|
20102
|
+
const scrollTop = scroller?.scrollTop;
|
|
20103
|
+
if (typeof scrollTop !== "number") return;
|
|
20104
|
+
for (let i = 0; i < list.value.length; i++) {
|
|
20105
|
+
const nav = list.value[i];
|
|
20106
|
+
const anchor = nav.anchor;
|
|
20107
|
+
if (!anchor) continue;
|
|
20108
|
+
const el = document.querySelector(anchor);
|
|
20109
|
+
if (!el) continue;
|
|
20110
|
+
const elTop = el.getBoundingClientRect().top - scroller.getBoundingClientRect().top + scroller.scrollTop;
|
|
20111
|
+
const nextNav = list.value[i + 1];
|
|
20112
|
+
let nextElTop;
|
|
20113
|
+
if (nextNav && nextNav.anchor) {
|
|
20114
|
+
const nextEl = document.querySelector(nextNav.anchor);
|
|
20115
|
+
if (nextEl) {
|
|
20116
|
+
nextElTop = nextEl.getBoundingClientRect().top - scroller.getBoundingClientRect().top + scroller.scrollTop;
|
|
20117
|
+
}
|
|
20118
|
+
}
|
|
20119
|
+
const allowDistance = 2;
|
|
20120
|
+
if (scrollTop >= elTop - allowDistance && (typeof nextElTop === "undefined" || scrollTop < nextElTop - allowDistance)) {
|
|
20121
|
+
if (getTabIndex(currentValue.value) !== i) {
|
|
20122
|
+
handleChange(i, false);
|
|
20123
|
+
}
|
|
20124
|
+
break;
|
|
20125
|
+
}
|
|
20126
|
+
}
|
|
20127
|
+
};
|
|
20128
|
+
const handleChange = (index, scrollTo = true) => {
|
|
20039
20129
|
if (timer.value) return;
|
|
20040
20130
|
timer.value = setTimeout(() => timer.value = null, 300);
|
|
20041
20131
|
const nav = list.value[index];
|
|
@@ -20044,7 +20134,7 @@ const useTabs = (options = {}) => {
|
|
|
20044
20134
|
emit("update:modelValue", currentValue.value);
|
|
20045
20135
|
emit("change", currentValue.value);
|
|
20046
20136
|
emit("click", currentValue.value);
|
|
20047
|
-
|
|
20137
|
+
scrollTo && scrollToAnchor(nav.anchor);
|
|
20048
20138
|
};
|
|
20049
20139
|
const handleResize = () => {
|
|
20050
20140
|
if (instance.isUnmounted) return;
|
|
@@ -20054,10 +20144,13 @@ const useTabs = (options = {}) => {
|
|
|
20054
20144
|
vue.onMounted(() => {
|
|
20055
20145
|
helperResize.Resize.on(options.wrapper.value, handleResize);
|
|
20056
20146
|
options.scrollToActive && vue.nextTick(options.scrollToActive);
|
|
20147
|
+
affix?.onScroll?.(handleAffixScroll);
|
|
20057
20148
|
});
|
|
20058
20149
|
vue.onBeforeUnmount(() => {
|
|
20059
20150
|
helperResize.Resize.off(options.wrapper.value, handleResize);
|
|
20060
20151
|
timer.value && clearTimeout(timer.value);
|
|
20152
|
+
affix?.offScroll?.(handleAffixScroll);
|
|
20153
|
+
scrollToAnchorTimer && clearTimeout(scrollToAnchorTimer);
|
|
20061
20154
|
});
|
|
20062
20155
|
const add = (item, setValue) => {
|
|
20063
20156
|
if (!item) return;
|