@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.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { reactive, defineComponent, createVNode, inject, shallowRef, ref, computed, onMounted, onBeforeUnmount, watch, getCurrentInstance, TransitionGroup, Transition as Transition$1, h,
|
|
1
|
+
import { reactive, defineComponent, createVNode, inject, shallowRef, ref, computed, onMounted, onBeforeUnmount, provide, nextTick, watch, getCurrentInstance, TransitionGroup, Transition as Transition$1, h, mergeProps, withModifiers, createApp, Fragment as Fragment$1, Teleport, onUnmounted, withDirectives, vShow, isVNode, onBeforeMount, createTextVNode, toRaw, onUpdated, resolveComponent, useAttrs as useAttrs$1 } from 'vue';
|
|
2
2
|
import * as $ from '@deot/helper-dom';
|
|
3
|
-
import { getScroller, composedPath, scrollIntoView, prefixStyle, getStyle, removeClass, addClass, hasClass } from '@deot/helper-dom';
|
|
3
|
+
import { getScroller as getScroller$1, composedPath, scrollIntoView, prefixStyle, getStyle, removeClass, addClass, hasClass } from '@deot/helper-dom';
|
|
4
4
|
import * as Utils from '@deot/helper-utils';
|
|
5
5
|
import { raf, getUid, preZero, getPropByPath, throttle as throttle$1, hasOwn } from '@deot/helper-utils';
|
|
6
6
|
import { debounce, cloneDeep, pick, isEqualWith, startCase, throttle, concat, max, merge, isEmpty as isEmpty$1, kebabCase, difference } from 'lodash-es';
|
|
@@ -106,6 +106,10 @@ const ActionSheet = /* @__PURE__ */ defineComponent({
|
|
|
106
106
|
const MActionSheet = ActionSheet;
|
|
107
107
|
|
|
108
108
|
const props$1s = {
|
|
109
|
+
modelValue: {
|
|
110
|
+
type: Boolean,
|
|
111
|
+
default: false
|
|
112
|
+
},
|
|
109
113
|
zIndex: {
|
|
110
114
|
type: [Number, String],
|
|
111
115
|
default: 1
|
|
@@ -133,16 +137,45 @@ const props$1s = {
|
|
|
133
137
|
}
|
|
134
138
|
};
|
|
135
139
|
|
|
140
|
+
let scrollBarWidth;
|
|
141
|
+
const getScrollBarWidth = () => {
|
|
142
|
+
if (scrollBarWidth !== void 0) return scrollBarWidth;
|
|
143
|
+
const outer = document.createElement("div");
|
|
144
|
+
outer.className = "vc-scrollbar__wrap";
|
|
145
|
+
outer.style.visibility = "hidden";
|
|
146
|
+
outer.style.width = "100px";
|
|
147
|
+
outer.style.position = "absolute";
|
|
148
|
+
outer.style.top = "-9999px";
|
|
149
|
+
document.body.appendChild(outer);
|
|
150
|
+
const widthNoScroll = outer.offsetWidth;
|
|
151
|
+
outer.style.overflow = "scroll";
|
|
152
|
+
const inner = document.createElement("div");
|
|
153
|
+
inner.style.width = "100%";
|
|
154
|
+
outer.appendChild(inner);
|
|
155
|
+
const widthWithScroll = inner.offsetWidth;
|
|
156
|
+
outer.parentNode?.removeChild?.(outer);
|
|
157
|
+
scrollBarWidth = widthNoScroll - widthWithScroll;
|
|
158
|
+
return scrollBarWidth;
|
|
159
|
+
};
|
|
160
|
+
const SCROLLER_WHEEL_REG = /vc-scroller-wheel/;
|
|
161
|
+
const getScroller = (el) => {
|
|
162
|
+
return getScroller$1(el, { className: SCROLLER_WHEEL_REG });
|
|
163
|
+
};
|
|
164
|
+
const isWheel = (el) => {
|
|
165
|
+
return SCROLLER_WHEEL_REG.test(el?.className || "");
|
|
166
|
+
};
|
|
167
|
+
|
|
136
168
|
/** @jsxImportSource vue */
|
|
137
169
|
|
|
138
170
|
const COMPONENT_NAME$27 = 'vc-affix';
|
|
139
|
-
const SCROLLER_WHEEL_REG = /vc-scroller-wheel/;
|
|
140
171
|
const Affix = /* @__PURE__ */ defineComponent({
|
|
141
172
|
name: COMPONENT_NAME$27,
|
|
173
|
+
emits: ['update:modelValue'],
|
|
142
174
|
props: props$1s,
|
|
143
175
|
setup(props, {
|
|
144
176
|
slots,
|
|
145
|
-
expose
|
|
177
|
+
expose,
|
|
178
|
+
emit
|
|
146
179
|
}) {
|
|
147
180
|
const scrollerInstance = inject('vc-scroller', null);
|
|
148
181
|
const scroller = shallowRef(); // 当前元素所在的滚动容器
|
|
@@ -158,9 +191,7 @@ const Affix = /* @__PURE__ */ defineComponent({
|
|
|
158
191
|
const isActive = ref(false);
|
|
159
192
|
const transformY = ref(0);
|
|
160
193
|
const windowHeight = ref(window.innerHeight);
|
|
161
|
-
const isVcScrollerWheel = computed(() =>
|
|
162
|
-
return SCROLLER_WHEEL_REG.test(scroller.value?.className || '');
|
|
163
|
-
});
|
|
194
|
+
const isVcScrollerWheel = computed(() => isWheel(scroller.value));
|
|
164
195
|
const currentStyle = computed(() => {
|
|
165
196
|
if (!isActive.value) return {};
|
|
166
197
|
return {
|
|
@@ -181,7 +212,8 @@ const Affix = /* @__PURE__ */ defineComponent({
|
|
|
181
212
|
};
|
|
182
213
|
});
|
|
183
214
|
const setCurrentRect = () => {
|
|
184
|
-
const rect = current.value
|
|
215
|
+
const rect = current.value?.getBoundingClientRect?.();
|
|
216
|
+
if (!rect) return;
|
|
185
217
|
Object.assign(currentRect, {
|
|
186
218
|
top: rect.top,
|
|
187
219
|
bottom: rect.bottom,
|
|
@@ -208,7 +240,7 @@ const Affix = /* @__PURE__ */ defineComponent({
|
|
|
208
240
|
transformY.value = Math.min(containerRect.bottom - currentHeightOffset, 0) + transformOffsetY;
|
|
209
241
|
} else {
|
|
210
242
|
isActive.value = currentRect.bottom - containerRect.top >= containerRect.height - props.offset;
|
|
211
|
-
transformY.value =
|
|
243
|
+
transformY.value = transformOffsetY;
|
|
212
244
|
}
|
|
213
245
|
};
|
|
214
246
|
const setFixedStatus = () => {
|
|
@@ -235,36 +267,58 @@ const Affix = /* @__PURE__ */ defineComponent({
|
|
|
235
267
|
}
|
|
236
268
|
}
|
|
237
269
|
};
|
|
270
|
+
const offScroll = handler => {
|
|
271
|
+
if (isVcScrollerWheel.value) {
|
|
272
|
+
scrollerInstance?.off(handler);
|
|
273
|
+
} else {
|
|
274
|
+
scroller.value?.removeEventListener('scroll', handler);
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
const onScroll = (handler, options) => {
|
|
278
|
+
// nextTick目的在与onMounted后执行
|
|
279
|
+
nextTick(() => {
|
|
280
|
+
if (isVcScrollerWheel.value) {
|
|
281
|
+
scrollerInstance?.on(handler);
|
|
282
|
+
} else {
|
|
283
|
+
scroller.value?.addEventListener('scroll', handler);
|
|
284
|
+
}
|
|
285
|
+
options?.first && handler();
|
|
286
|
+
});
|
|
287
|
+
return () => offScroll(handler);
|
|
288
|
+
};
|
|
238
289
|
const refresh = () => {
|
|
290
|
+
if (props.disabled) return;
|
|
239
291
|
setCurrentRect();
|
|
240
292
|
scroller.value instanceof Window || props.fixed ? setFixedStatus() : setAbsoluteStatus();
|
|
293
|
+
emit('update:modelValue', isActive.value);
|
|
241
294
|
};
|
|
242
295
|
onMounted(() => {
|
|
243
296
|
if (typeof props.target === 'string') {
|
|
244
297
|
base.value = document.querySelector(props.target) ?? void 0;
|
|
245
298
|
}
|
|
246
299
|
!base.value && (base.value = document.documentElement);
|
|
247
|
-
scroller.value = getScroller(current.value
|
|
248
|
-
|
|
300
|
+
scroller.value = getScroller(current.value);
|
|
301
|
+
onScroll(refresh, {
|
|
302
|
+
first: true
|
|
249
303
|
});
|
|
250
|
-
if (isVcScrollerWheel.value) {
|
|
251
|
-
scrollerInstance?.on(refresh);
|
|
252
|
-
} else {
|
|
253
|
-
scroller.value?.addEventListener('scroll', refresh);
|
|
254
|
-
}
|
|
255
|
-
refresh();
|
|
256
|
-
});
|
|
257
|
-
onBeforeUnmount(() => {
|
|
258
|
-
if (isVcScrollerWheel.value) {
|
|
259
|
-
scrollerInstance?.off(refresh);
|
|
260
|
-
} else {
|
|
261
|
-
scroller.value?.removeEventListener('scroll', refresh);
|
|
262
|
-
}
|
|
263
304
|
});
|
|
305
|
+
onBeforeUnmount(() => offScroll(refresh));
|
|
264
306
|
expose({
|
|
265
|
-
refresh
|
|
307
|
+
refresh,
|
|
308
|
+
onScroll,
|
|
309
|
+
offScroll
|
|
310
|
+
});
|
|
311
|
+
provide('vc-affix', {
|
|
312
|
+
props,
|
|
313
|
+
isActive,
|
|
314
|
+
refresh,
|
|
315
|
+
onScroll,
|
|
316
|
+
offScroll
|
|
266
317
|
});
|
|
267
318
|
return () => {
|
|
319
|
+
if (props.disabled) return slots?.default?.({
|
|
320
|
+
active: false
|
|
321
|
+
});
|
|
268
322
|
return createVNode("div", {
|
|
269
323
|
"ref": current,
|
|
270
324
|
"class": "vc-affix",
|
|
@@ -3728,7 +3782,8 @@ const props$19 = {
|
|
|
3728
3782
|
nullValue: {
|
|
3729
3783
|
type: [Number, String, Object],
|
|
3730
3784
|
default: void 0
|
|
3731
|
-
}
|
|
3785
|
+
},
|
|
3786
|
+
label: String
|
|
3732
3787
|
};
|
|
3733
3788
|
|
|
3734
3789
|
const props$18 = {
|
|
@@ -8840,27 +8895,6 @@ const props$T = {
|
|
|
8840
8895
|
}
|
|
8841
8896
|
};
|
|
8842
8897
|
|
|
8843
|
-
let scrollBarWidth;
|
|
8844
|
-
const getScrollBarWidth = () => {
|
|
8845
|
-
if (scrollBarWidth !== void 0) return scrollBarWidth;
|
|
8846
|
-
const outer = document.createElement("div");
|
|
8847
|
-
outer.className = "vc-scrollbar__wrap";
|
|
8848
|
-
outer.style.visibility = "hidden";
|
|
8849
|
-
outer.style.width = "100px";
|
|
8850
|
-
outer.style.position = "absolute";
|
|
8851
|
-
outer.style.top = "-9999px";
|
|
8852
|
-
document.body.appendChild(outer);
|
|
8853
|
-
const widthNoScroll = outer.offsetWidth;
|
|
8854
|
-
outer.style.overflow = "scroll";
|
|
8855
|
-
const inner = document.createElement("div");
|
|
8856
|
-
inner.style.width = "100%";
|
|
8857
|
-
outer.appendChild(inner);
|
|
8858
|
-
const widthWithScroll = inner.offsetWidth;
|
|
8859
|
-
outer.parentNode?.removeChild?.(outer);
|
|
8860
|
-
scrollBarWidth = widthNoScroll - widthWithScroll;
|
|
8861
|
-
return scrollBarWidth;
|
|
8862
|
-
};
|
|
8863
|
-
|
|
8864
8898
|
const barKeys$1 = [
|
|
8865
8899
|
"always",
|
|
8866
8900
|
"thumbMinSize",
|
|
@@ -14308,7 +14342,7 @@ const Select = /* @__PURE__ */ defineComponent({
|
|
|
14308
14342
|
"style": its.value.style,
|
|
14309
14343
|
"animation": "y",
|
|
14310
14344
|
"onMouseenter": () => isHover.value = true,
|
|
14311
|
-
"
|
|
14345
|
+
"onMouseleave": () => isHover.value = false,
|
|
14312
14346
|
"onReady": () => emit('ready'),
|
|
14313
14347
|
"onClose": () => emit('close'),
|
|
14314
14348
|
"onVisibleChange": () => emit('visible-change', isActive.value),
|
|
@@ -14324,6 +14358,13 @@ const Select = /* @__PURE__ */ defineComponent({
|
|
|
14324
14358
|
"readonly": true,
|
|
14325
14359
|
"placeholder": its.value.attrs?.placeholder || '请选择'
|
|
14326
14360
|
}, {
|
|
14361
|
+
prepend: slots.prepend || props.label ? () => {
|
|
14362
|
+
slots.prepend ? slots.prepend() : createVNode("div", {
|
|
14363
|
+
"class": "vc-select__prepend"
|
|
14364
|
+
}, [createVNode("span", {
|
|
14365
|
+
"class": "vc-select__label"
|
|
14366
|
+
}, [props.label])]);
|
|
14367
|
+
} : null,
|
|
14327
14368
|
content: multiple.value && currentValue.value && currentValue.value.length > 0 ? () => {
|
|
14328
14369
|
return createVNode("div", {
|
|
14329
14370
|
"class": [classes.value, 'vc-select__tags']
|
|
@@ -14345,7 +14386,7 @@ const Select = /* @__PURE__ */ defineComponent({
|
|
|
14345
14386
|
}, [createVNode(Icon, {
|
|
14346
14387
|
"type": showClear.value ? 'clear' : icon.value,
|
|
14347
14388
|
"class": [{
|
|
14348
|
-
'is-arrow': !showClear
|
|
14389
|
+
'is-arrow': !showClear.value
|
|
14349
14390
|
}, 'vc-select__icon'],
|
|
14350
14391
|
"onClick": handleClear
|
|
14351
14392
|
}, null)]);
|
|
@@ -19965,10 +20006,13 @@ const props$c = {
|
|
|
19965
20006
|
barStyle: [Object, String],
|
|
19966
20007
|
contentStyle: [Object, String],
|
|
19967
20008
|
barClass: [Object, String],
|
|
19968
|
-
contentClass: [Object, String]
|
|
20009
|
+
contentClass: [Object, String],
|
|
20010
|
+
affixable: Boolean,
|
|
20011
|
+
affixOptions: Object
|
|
19969
20012
|
};
|
|
19970
20013
|
|
|
19971
20014
|
const useTabs = (options = {}) => {
|
|
20015
|
+
const affix = inject("vc-affix", null);
|
|
19972
20016
|
const instance = getCurrentInstance();
|
|
19973
20017
|
const { props, emit } = instance;
|
|
19974
20018
|
const tabsId = ref(getUid("tabs"));
|
|
@@ -20010,10 +20054,56 @@ const useTabs = (options = {}) => {
|
|
|
20010
20054
|
[`is-${props.theme}`]: !!props.theme
|
|
20011
20055
|
};
|
|
20012
20056
|
});
|
|
20057
|
+
const hasAnchor = computed(() => {
|
|
20058
|
+
return list.value.some((item) => !!item.anchor);
|
|
20059
|
+
});
|
|
20013
20060
|
const refresh = () => {
|
|
20014
20061
|
options?.refreshAfloat?.();
|
|
20015
20062
|
};
|
|
20016
|
-
|
|
20063
|
+
let scrollToAnchorTimer;
|
|
20064
|
+
const scrollToAnchor = (anchor) => {
|
|
20065
|
+
if (!anchor) return;
|
|
20066
|
+
const el = document.querySelector(anchor);
|
|
20067
|
+
if (!el) return;
|
|
20068
|
+
const scroller = getScroller(instance.vnode.el);
|
|
20069
|
+
scrollIntoView(scroller, {
|
|
20070
|
+
duration: 250,
|
|
20071
|
+
from: scroller.scrollTop,
|
|
20072
|
+
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)
|
|
20073
|
+
});
|
|
20074
|
+
scrollToAnchorTimer && clearTimeout(scrollToAnchorTimer);
|
|
20075
|
+
scrollToAnchorTimer = setTimeout(() => scrollToAnchorTimer = null, 300);
|
|
20076
|
+
};
|
|
20077
|
+
const handleAffixScroll = () => {
|
|
20078
|
+
if (!hasAnchor.value || scrollToAnchorTimer) return;
|
|
20079
|
+
const scroller = getScroller(instance.vnode.el);
|
|
20080
|
+
const scrollTop = scroller?.scrollTop;
|
|
20081
|
+
if (typeof scrollTop !== "number") return;
|
|
20082
|
+
for (let i = 0; i < list.value.length; i++) {
|
|
20083
|
+
const nav = list.value[i];
|
|
20084
|
+
const anchor = nav.anchor;
|
|
20085
|
+
if (!anchor) continue;
|
|
20086
|
+
const el = document.querySelector(anchor);
|
|
20087
|
+
if (!el) continue;
|
|
20088
|
+
const elTop = el.getBoundingClientRect().top - scroller.getBoundingClientRect().top + scroller.scrollTop;
|
|
20089
|
+
const nextNav = list.value[i + 1];
|
|
20090
|
+
let nextElTop;
|
|
20091
|
+
if (nextNav && nextNav.anchor) {
|
|
20092
|
+
const nextEl = document.querySelector(nextNav.anchor);
|
|
20093
|
+
if (nextEl) {
|
|
20094
|
+
nextElTop = nextEl.getBoundingClientRect().top - scroller.getBoundingClientRect().top + scroller.scrollTop;
|
|
20095
|
+
}
|
|
20096
|
+
}
|
|
20097
|
+
const allowDistance = 2;
|
|
20098
|
+
if (scrollTop >= elTop - allowDistance && (typeof nextElTop === "undefined" || scrollTop < nextElTop - allowDistance)) {
|
|
20099
|
+
if (getTabIndex(currentValue.value) !== i) {
|
|
20100
|
+
handleChange(i, false);
|
|
20101
|
+
}
|
|
20102
|
+
break;
|
|
20103
|
+
}
|
|
20104
|
+
}
|
|
20105
|
+
};
|
|
20106
|
+
const handleChange = (index, scrollTo = true) => {
|
|
20017
20107
|
if (timer.value) return;
|
|
20018
20108
|
timer.value = setTimeout(() => timer.value = null, 300);
|
|
20019
20109
|
const nav = list.value[index];
|
|
@@ -20022,7 +20112,7 @@ const useTabs = (options = {}) => {
|
|
|
20022
20112
|
emit("update:modelValue", currentValue.value);
|
|
20023
20113
|
emit("change", currentValue.value);
|
|
20024
20114
|
emit("click", currentValue.value);
|
|
20025
|
-
|
|
20115
|
+
scrollTo && scrollToAnchor(nav.anchor);
|
|
20026
20116
|
};
|
|
20027
20117
|
const handleResize = () => {
|
|
20028
20118
|
if (instance.isUnmounted) return;
|
|
@@ -20032,10 +20122,13 @@ const useTabs = (options = {}) => {
|
|
|
20032
20122
|
onMounted(() => {
|
|
20033
20123
|
Resize.on(options.wrapper.value, handleResize);
|
|
20034
20124
|
options.scrollToActive && nextTick(options.scrollToActive);
|
|
20125
|
+
affix?.onScroll?.(handleAffixScroll);
|
|
20035
20126
|
});
|
|
20036
20127
|
onBeforeUnmount(() => {
|
|
20037
20128
|
Resize.off(options.wrapper.value, handleResize);
|
|
20038
20129
|
timer.value && clearTimeout(timer.value);
|
|
20130
|
+
affix?.offScroll?.(handleAffixScroll);
|
|
20131
|
+
scrollToAnchorTimer && clearTimeout(scrollToAnchorTimer);
|
|
20039
20132
|
});
|
|
20040
20133
|
const add = (item, setValue) => {
|
|
20041
20134
|
if (!item) return;
|