@deot/vc-components 1.0.47 → 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 +138 -53
- package/dist/index.d.ts +147 -111
- package/dist/index.iife.js +166 -81
- package/dist/index.js +140 -55
- package/dist/index.style.css +1 -1
- package/dist/index.umd.cjs +166 -81
- 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",
|
|
@@ -8863,27 +8917,6 @@ const props$T = {
|
|
|
8863
8917
|
}
|
|
8864
8918
|
};
|
|
8865
8919
|
|
|
8866
|
-
let scrollBarWidth;
|
|
8867
|
-
const getScrollBarWidth = () => {
|
|
8868
|
-
if (scrollBarWidth !== void 0) return scrollBarWidth;
|
|
8869
|
-
const outer = document.createElement("div");
|
|
8870
|
-
outer.className = "vc-scrollbar__wrap";
|
|
8871
|
-
outer.style.visibility = "hidden";
|
|
8872
|
-
outer.style.width = "100px";
|
|
8873
|
-
outer.style.position = "absolute";
|
|
8874
|
-
outer.style.top = "-9999px";
|
|
8875
|
-
document.body.appendChild(outer);
|
|
8876
|
-
const widthNoScroll = outer.offsetWidth;
|
|
8877
|
-
outer.style.overflow = "scroll";
|
|
8878
|
-
const inner = document.createElement("div");
|
|
8879
|
-
inner.style.width = "100%";
|
|
8880
|
-
outer.appendChild(inner);
|
|
8881
|
-
const widthWithScroll = inner.offsetWidth;
|
|
8882
|
-
outer.parentNode?.removeChild?.(outer);
|
|
8883
|
-
scrollBarWidth = widthNoScroll - widthWithScroll;
|
|
8884
|
-
return scrollBarWidth;
|
|
8885
|
-
};
|
|
8886
|
-
|
|
8887
8920
|
const barKeys$1 = [
|
|
8888
8921
|
"always",
|
|
8889
8922
|
"thumbMinSize",
|
|
@@ -14347,13 +14380,13 @@ const Select = /* @__PURE__ */ vue.defineComponent({
|
|
|
14347
14380
|
"readonly": true,
|
|
14348
14381
|
"placeholder": its.value.attrs?.placeholder || '请选择'
|
|
14349
14382
|
}, {
|
|
14350
|
-
prepend: () => {
|
|
14351
|
-
|
|
14352
|
-
|
|
14353
|
-
|
|
14383
|
+
prepend: slots.prepend || props.label ? () => {
|
|
14384
|
+
slots.prepend ? slots.prepend() : vue.createVNode("div", {
|
|
14385
|
+
"class": "vc-select__prepend"
|
|
14386
|
+
}, [vue.createVNode("span", {
|
|
14354
14387
|
"class": "vc-select__label"
|
|
14355
|
-
}, [props.label]);
|
|
14356
|
-
},
|
|
14388
|
+
}, [props.label])]);
|
|
14389
|
+
} : null,
|
|
14357
14390
|
content: multiple.value && currentValue.value && currentValue.value.length > 0 ? () => {
|
|
14358
14391
|
return vue.createVNode("div", {
|
|
14359
14392
|
"class": [classes.value, 'vc-select__tags']
|
|
@@ -19995,10 +20028,13 @@ const props$c = {
|
|
|
19995
20028
|
barStyle: [Object, String],
|
|
19996
20029
|
contentStyle: [Object, String],
|
|
19997
20030
|
barClass: [Object, String],
|
|
19998
|
-
contentClass: [Object, String]
|
|
20031
|
+
contentClass: [Object, String],
|
|
20032
|
+
affixable: Boolean,
|
|
20033
|
+
affixOptions: Object
|
|
19999
20034
|
};
|
|
20000
20035
|
|
|
20001
20036
|
const useTabs = (options = {}) => {
|
|
20037
|
+
const affix = vue.inject("vc-affix", null);
|
|
20002
20038
|
const instance = vue.getCurrentInstance();
|
|
20003
20039
|
const { props, emit } = instance;
|
|
20004
20040
|
const tabsId = vue.ref(Utils.getUid("tabs"));
|
|
@@ -20040,10 +20076,56 @@ const useTabs = (options = {}) => {
|
|
|
20040
20076
|
[`is-${props.theme}`]: !!props.theme
|
|
20041
20077
|
};
|
|
20042
20078
|
});
|
|
20079
|
+
const hasAnchor = vue.computed(() => {
|
|
20080
|
+
return list.value.some((item) => !!item.anchor);
|
|
20081
|
+
});
|
|
20043
20082
|
const refresh = () => {
|
|
20044
20083
|
options?.refreshAfloat?.();
|
|
20045
20084
|
};
|
|
20046
|
-
|
|
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) => {
|
|
20047
20129
|
if (timer.value) return;
|
|
20048
20130
|
timer.value = setTimeout(() => timer.value = null, 300);
|
|
20049
20131
|
const nav = list.value[index];
|
|
@@ -20052,7 +20134,7 @@ const useTabs = (options = {}) => {
|
|
|
20052
20134
|
emit("update:modelValue", currentValue.value);
|
|
20053
20135
|
emit("change", currentValue.value);
|
|
20054
20136
|
emit("click", currentValue.value);
|
|
20055
|
-
|
|
20137
|
+
scrollTo && scrollToAnchor(nav.anchor);
|
|
20056
20138
|
};
|
|
20057
20139
|
const handleResize = () => {
|
|
20058
20140
|
if (instance.isUnmounted) return;
|
|
@@ -20062,10 +20144,13 @@ const useTabs = (options = {}) => {
|
|
|
20062
20144
|
vue.onMounted(() => {
|
|
20063
20145
|
helperResize.Resize.on(options.wrapper.value, handleResize);
|
|
20064
20146
|
options.scrollToActive && vue.nextTick(options.scrollToActive);
|
|
20147
|
+
affix?.onScroll?.(handleAffixScroll);
|
|
20065
20148
|
});
|
|
20066
20149
|
vue.onBeforeUnmount(() => {
|
|
20067
20150
|
helperResize.Resize.off(options.wrapper.value, handleResize);
|
|
20068
20151
|
timer.value && clearTimeout(timer.value);
|
|
20152
|
+
affix?.offScroll?.(handleAffixScroll);
|
|
20153
|
+
scrollToAnchorTimer && clearTimeout(scrollToAnchorTimer);
|
|
20069
20154
|
});
|
|
20070
20155
|
const add = (item, setValue) => {
|
|
20071
20156
|
if (!item) return;
|