@deot/vc 1.0.47 → 1.0.49
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.d.ts +158 -98
- package/dist/index.iife.js +177 -93
- package/dist/index.umd.cjs +177 -93
- package/package.json +4 -4
package/dist/index.umd.cjs
CHANGED
|
@@ -224,7 +224,7 @@
|
|
|
224
224
|
return !!(overflow.match(/(scroll|auto)/) || className?.test(el.className));
|
|
225
225
|
};
|
|
226
226
|
|
|
227
|
-
const getScroller = (el, options) => {
|
|
227
|
+
const getScroller$1 = (el, options) => {
|
|
228
228
|
if (IS_SERVER$2 || !el) return null;
|
|
229
229
|
let parent = el;
|
|
230
230
|
while (parent) {
|
|
@@ -9153,6 +9153,10 @@
|
|
|
9153
9153
|
});
|
|
9154
9154
|
const MActionSheet = ActionSheet;
|
|
9155
9155
|
const props$1s = {
|
|
9156
|
+
modelValue: {
|
|
9157
|
+
type: Boolean,
|
|
9158
|
+
default: false
|
|
9159
|
+
},
|
|
9156
9160
|
zIndex: {
|
|
9157
9161
|
type: [Number, String],
|
|
9158
9162
|
default: 1
|
|
@@ -9179,14 +9183,42 @@
|
|
|
9179
9183
|
type: String
|
|
9180
9184
|
}
|
|
9181
9185
|
};
|
|
9182
|
-
|
|
9186
|
+
let scrollBarWidth;
|
|
9187
|
+
const getScrollBarWidth = () => {
|
|
9188
|
+
if (scrollBarWidth !== void 0) return scrollBarWidth;
|
|
9189
|
+
const outer = document.createElement("div");
|
|
9190
|
+
outer.className = "vc-scrollbar__wrap";
|
|
9191
|
+
outer.style.visibility = "hidden";
|
|
9192
|
+
outer.style.width = "100px";
|
|
9193
|
+
outer.style.position = "absolute";
|
|
9194
|
+
outer.style.top = "-9999px";
|
|
9195
|
+
document.body.appendChild(outer);
|
|
9196
|
+
const widthNoScroll = outer.offsetWidth;
|
|
9197
|
+
outer.style.overflow = "scroll";
|
|
9198
|
+
const inner = document.createElement("div");
|
|
9199
|
+
inner.style.width = "100%";
|
|
9200
|
+
outer.appendChild(inner);
|
|
9201
|
+
const widthWithScroll = inner.offsetWidth;
|
|
9202
|
+
outer.parentNode?.removeChild?.(outer);
|
|
9203
|
+
scrollBarWidth = widthNoScroll - widthWithScroll;
|
|
9204
|
+
return scrollBarWidth;
|
|
9205
|
+
};
|
|
9183
9206
|
const SCROLLER_WHEEL_REG = /vc-scroller-wheel/;
|
|
9207
|
+
const getScroller = (el2) => {
|
|
9208
|
+
return getScroller$1(el2, { className: SCROLLER_WHEEL_REG });
|
|
9209
|
+
};
|
|
9210
|
+
const isWheel = (el2) => {
|
|
9211
|
+
return SCROLLER_WHEEL_REG.test(el2?.className || "");
|
|
9212
|
+
};
|
|
9213
|
+
const COMPONENT_NAME$27 = "vc-affix";
|
|
9184
9214
|
const Affix = /* @__PURE__ */ vue.defineComponent({
|
|
9185
9215
|
name: COMPONENT_NAME$27,
|
|
9216
|
+
emits: ["update:modelValue"],
|
|
9186
9217
|
props: props$1s,
|
|
9187
9218
|
setup(props2, {
|
|
9188
9219
|
slots,
|
|
9189
|
-
expose
|
|
9220
|
+
expose,
|
|
9221
|
+
emit
|
|
9190
9222
|
}) {
|
|
9191
9223
|
const scrollerInstance = vue.inject("vc-scroller", null);
|
|
9192
9224
|
const scroller = vue.shallowRef();
|
|
@@ -9201,9 +9233,7 @@
|
|
|
9201
9233
|
const isActive = vue.ref(false);
|
|
9202
9234
|
const transformY = vue.ref(0);
|
|
9203
9235
|
const windowHeight = vue.ref(window.innerHeight);
|
|
9204
|
-
const isVcScrollerWheel = vue.computed(() =>
|
|
9205
|
-
return SCROLLER_WHEEL_REG.test(scroller.value?.className || "");
|
|
9206
|
-
});
|
|
9236
|
+
const isVcScrollerWheel = vue.computed(() => isWheel(scroller.value));
|
|
9207
9237
|
const currentStyle = vue.computed(() => {
|
|
9208
9238
|
if (!isActive.value) return {};
|
|
9209
9239
|
return {
|
|
@@ -9224,7 +9254,8 @@
|
|
|
9224
9254
|
};
|
|
9225
9255
|
});
|
|
9226
9256
|
const setCurrentRect = () => {
|
|
9227
|
-
const rect = current.value
|
|
9257
|
+
const rect = current.value?.getBoundingClientRect?.();
|
|
9258
|
+
if (!rect) return;
|
|
9228
9259
|
Object.assign(currentRect, {
|
|
9229
9260
|
top: rect.top,
|
|
9230
9261
|
bottom: rect.bottom,
|
|
@@ -9249,7 +9280,7 @@
|
|
|
9249
9280
|
transformY.value = Math.min(containerRect.bottom - currentHeightOffset, 0) + transformOffsetY;
|
|
9250
9281
|
} else {
|
|
9251
9282
|
isActive.value = currentRect.bottom - containerRect.top >= containerRect.height - props2.offset;
|
|
9252
|
-
transformY.value =
|
|
9283
|
+
transformY.value = transformOffsetY;
|
|
9253
9284
|
}
|
|
9254
9285
|
};
|
|
9255
9286
|
const setFixedStatus = () => {
|
|
@@ -9276,36 +9307,57 @@
|
|
|
9276
9307
|
}
|
|
9277
9308
|
}
|
|
9278
9309
|
};
|
|
9310
|
+
const offScroll = (handler) => {
|
|
9311
|
+
if (isVcScrollerWheel.value) {
|
|
9312
|
+
scrollerInstance?.off(handler);
|
|
9313
|
+
} else {
|
|
9314
|
+
scroller.value?.removeEventListener("scroll", handler);
|
|
9315
|
+
}
|
|
9316
|
+
};
|
|
9317
|
+
const onScroll = (handler, options) => {
|
|
9318
|
+
vue.nextTick(() => {
|
|
9319
|
+
if (isVcScrollerWheel.value) {
|
|
9320
|
+
scrollerInstance?.on(handler);
|
|
9321
|
+
} else {
|
|
9322
|
+
scroller.value?.addEventListener("scroll", handler);
|
|
9323
|
+
}
|
|
9324
|
+
options?.first && handler();
|
|
9325
|
+
});
|
|
9326
|
+
return () => offScroll(handler);
|
|
9327
|
+
};
|
|
9279
9328
|
const refresh = () => {
|
|
9329
|
+
if (props2.disabled) return;
|
|
9280
9330
|
setCurrentRect();
|
|
9281
9331
|
scroller.value instanceof Window || props2.fixed ? setFixedStatus() : setAbsoluteStatus();
|
|
9332
|
+
emit("update:modelValue", isActive.value);
|
|
9282
9333
|
};
|
|
9283
9334
|
vue.onMounted(() => {
|
|
9284
9335
|
if (typeof props2.target === "string") {
|
|
9285
9336
|
base.value = document.querySelector(props2.target) ?? void 0;
|
|
9286
9337
|
}
|
|
9287
9338
|
!base.value && (base.value = document.documentElement);
|
|
9288
|
-
scroller.value = getScroller(current.value
|
|
9289
|
-
|
|
9339
|
+
scroller.value = getScroller(current.value);
|
|
9340
|
+
onScroll(refresh, {
|
|
9341
|
+
first: true
|
|
9290
9342
|
});
|
|
9291
|
-
if (isVcScrollerWheel.value) {
|
|
9292
|
-
scrollerInstance?.on(refresh);
|
|
9293
|
-
} else {
|
|
9294
|
-
scroller.value?.addEventListener("scroll", refresh);
|
|
9295
|
-
}
|
|
9296
|
-
refresh();
|
|
9297
|
-
});
|
|
9298
|
-
vue.onBeforeUnmount(() => {
|
|
9299
|
-
if (isVcScrollerWheel.value) {
|
|
9300
|
-
scrollerInstance?.off(refresh);
|
|
9301
|
-
} else {
|
|
9302
|
-
scroller.value?.removeEventListener("scroll", refresh);
|
|
9303
|
-
}
|
|
9304
9343
|
});
|
|
9344
|
+
vue.onBeforeUnmount(() => offScroll(refresh));
|
|
9305
9345
|
expose({
|
|
9306
|
-
refresh
|
|
9346
|
+
refresh,
|
|
9347
|
+
onScroll,
|
|
9348
|
+
offScroll
|
|
9349
|
+
});
|
|
9350
|
+
vue.provide("vc-affix", {
|
|
9351
|
+
props: props2,
|
|
9352
|
+
isActive,
|
|
9353
|
+
refresh,
|
|
9354
|
+
onScroll,
|
|
9355
|
+
offScroll
|
|
9307
9356
|
});
|
|
9308
9357
|
return () => {
|
|
9358
|
+
if (props2.disabled) return slots?.default?.({
|
|
9359
|
+
active: false
|
|
9360
|
+
});
|
|
9309
9361
|
return vue.createVNode("div", {
|
|
9310
9362
|
"ref": current,
|
|
9311
9363
|
"class": "vc-affix",
|
|
@@ -17456,26 +17508,6 @@
|
|
|
17456
17508
|
default: () => [0, 0]
|
|
17457
17509
|
}
|
|
17458
17510
|
};
|
|
17459
|
-
let scrollBarWidth;
|
|
17460
|
-
const getScrollBarWidth = () => {
|
|
17461
|
-
if (scrollBarWidth !== void 0) return scrollBarWidth;
|
|
17462
|
-
const outer = document.createElement("div");
|
|
17463
|
-
outer.className = "vc-scrollbar__wrap";
|
|
17464
|
-
outer.style.visibility = "hidden";
|
|
17465
|
-
outer.style.width = "100px";
|
|
17466
|
-
outer.style.position = "absolute";
|
|
17467
|
-
outer.style.top = "-9999px";
|
|
17468
|
-
document.body.appendChild(outer);
|
|
17469
|
-
const widthNoScroll = outer.offsetWidth;
|
|
17470
|
-
outer.style.overflow = "scroll";
|
|
17471
|
-
const inner = document.createElement("div");
|
|
17472
|
-
inner.style.width = "100%";
|
|
17473
|
-
outer.appendChild(inner);
|
|
17474
|
-
const widthWithScroll = inner.offsetWidth;
|
|
17475
|
-
outer.parentNode?.removeChild?.(outer);
|
|
17476
|
-
scrollBarWidth = widthNoScroll - widthWithScroll;
|
|
17477
|
-
return scrollBarWidth;
|
|
17478
|
-
};
|
|
17479
17511
|
const barKeys$1 = [
|
|
17480
17512
|
"always",
|
|
17481
17513
|
"thumbMinSize",
|
|
@@ -19900,7 +19932,14 @@
|
|
|
19900
19932
|
labelStyle: [Object, String],
|
|
19901
19933
|
labelClass: [Object, String],
|
|
19902
19934
|
errorStyle: [Object, String],
|
|
19903
|
-
errorClass: [Object, String]
|
|
19935
|
+
errorClass: [Object, String],
|
|
19936
|
+
// 给nestFormItem统一注入
|
|
19937
|
+
nestedContentStyle: [Object, String],
|
|
19938
|
+
nestedContentClass: [Object, String],
|
|
19939
|
+
nestedLabelStyle: [Object, String],
|
|
19940
|
+
nestedLabelClass: [Object, String],
|
|
19941
|
+
nestedErrorStyle: [Object, String],
|
|
19942
|
+
nestedErrorClass: [Object, String]
|
|
19904
19943
|
};
|
|
19905
19944
|
const useForm = (expose, options = {}) => {
|
|
19906
19945
|
const instance = vue.getCurrentInstance();
|
|
@@ -20116,31 +20155,32 @@
|
|
|
20116
20155
|
});
|
|
20117
20156
|
const classes = vue.computed(() => {
|
|
20118
20157
|
return {
|
|
20119
|
-
"is-
|
|
20158
|
+
"is-required": isRequired.value && props2.asterisk,
|
|
20120
20159
|
"is-error": validateState.value === "error",
|
|
20121
20160
|
"is-validating": validateState.value === "validating",
|
|
20122
20161
|
"is-inline": form.props.inline,
|
|
20123
|
-
"is-
|
|
20162
|
+
"is-nested": isNested.value,
|
|
20124
20163
|
"is-alone": !props2.showMessage,
|
|
20125
20164
|
// 用于单独去除form-item的默认margin_bottom
|
|
20126
20165
|
[`is-${labelPosition.value}`]: true
|
|
20127
20166
|
};
|
|
20128
20167
|
});
|
|
20129
|
-
const
|
|
20168
|
+
const isNested = vue.computed(() => {
|
|
20130
20169
|
return !!formItem.change;
|
|
20131
20170
|
});
|
|
20132
|
-
const
|
|
20171
|
+
const isNestedLast = vue.ref(false);
|
|
20133
20172
|
const hasLabel = vue.computed(() => {
|
|
20134
20173
|
return !!props2.label || slots.label;
|
|
20135
20174
|
});
|
|
20136
20175
|
const labelStyle = vue.computed(() => {
|
|
20137
|
-
const labelWidth = props2.labelWidth === 0 || props2.labelWidth ? props2.labelWidth :
|
|
20176
|
+
const labelWidth = props2.labelWidth === 0 || props2.labelWidth ? props2.labelWidth : isNested.value ? 0 : form.props.labelWidth;
|
|
20138
20177
|
return [
|
|
20139
20178
|
{
|
|
20140
20179
|
width: labelPosition.value !== "top" && labelWidth && labelWidth > 0 ? `${labelWidth}px` : "auto",
|
|
20141
20180
|
textAlign: labelPosition.value === "top" ? "left" : labelPosition.value
|
|
20142
20181
|
},
|
|
20143
20182
|
form.props.labelStyle,
|
|
20183
|
+
isNested.value && form.props.nestedLabelStyle,
|
|
20144
20184
|
props2.labelStyle
|
|
20145
20185
|
];
|
|
20146
20186
|
});
|
|
@@ -20148,24 +20188,25 @@
|
|
|
20148
20188
|
const labelWidth = props2.labelWidth === 0 || props2.labelWidth ? props2.labelWidth : form.props.labelWidth;
|
|
20149
20189
|
return [
|
|
20150
20190
|
{
|
|
20151
|
-
marginLeft: !hasLabel.value &&
|
|
20152
|
-
marginBottom:
|
|
20191
|
+
marginLeft: labelPosition.value === "top" || !hasLabel.value && isNested.value ? 0 : labelWidth && labelWidth > 0 ? `${labelWidth}px` : "unset",
|
|
20192
|
+
marginBottom: isNested.value && !isNestedLast.value ? `20px` : 0
|
|
20153
20193
|
},
|
|
20154
20194
|
form.props.contentStyle,
|
|
20195
|
+
isNested.value && form.props.nestedContentStyle,
|
|
20155
20196
|
props2.contentStyle
|
|
20156
20197
|
];
|
|
20157
20198
|
});
|
|
20158
20199
|
const errorStyle = vue.computed(() => {
|
|
20159
|
-
return [form.props.errorStyle, props2.errorStyle];
|
|
20200
|
+
return [form.props.errorStyle, isNested.value && form.props.nestedErrorStyle, props2.errorStyle];
|
|
20160
20201
|
});
|
|
20161
20202
|
const labelClass = vue.computed(() => {
|
|
20162
|
-
return [form.props.labelClass, props2.labelClass];
|
|
20203
|
+
return [form.props.labelClass, isNested.value && form.props.nestedLabelClass, props2.labelClass];
|
|
20163
20204
|
});
|
|
20164
20205
|
const contentClass = vue.computed(() => {
|
|
20165
|
-
return [form.props.contentClass, props2.contentClass];
|
|
20206
|
+
return [form.props.contentClass, isNested.value && form.props.nestedContentClass, props2.contentClass];
|
|
20166
20207
|
});
|
|
20167
20208
|
const errorClass = vue.computed(() => {
|
|
20168
|
-
return [form.props.errorClass, props2.errorClass];
|
|
20209
|
+
return [form.props.errorClass, isNested.value && form.props.nestedErrorClass, props2.errorClass];
|
|
20169
20210
|
});
|
|
20170
20211
|
const isStyleless = vue.computed(() => {
|
|
20171
20212
|
return props2.styleless || form.props.styleless;
|
|
@@ -20302,7 +20343,7 @@
|
|
|
20302
20343
|
vue.watch(
|
|
20303
20344
|
() => formItem.fields?.length,
|
|
20304
20345
|
async (v) => {
|
|
20305
|
-
if (!
|
|
20346
|
+
if (!isNested.value || !v) return isNestedLast.value = false;
|
|
20306
20347
|
const fields$ = [...vue.toRaw(formItem.fields)];
|
|
20307
20348
|
const positions = await Promise.all(fields$.map((item) => item.exposed.getPosition()));
|
|
20308
20349
|
const sortFields = fields$.toSorted((a, b) => {
|
|
@@ -20313,7 +20354,7 @@
|
|
|
20313
20354
|
if (aPosition.top != bPosition.top) return aPosition.top - bPosition.top;
|
|
20314
20355
|
return aPosition.left - bPosition.left;
|
|
20315
20356
|
});
|
|
20316
|
-
|
|
20357
|
+
isNestedLast.value = sortFields[sortFields.length - 1] === instance;
|
|
20317
20358
|
}
|
|
20318
20359
|
);
|
|
20319
20360
|
expose({
|
|
@@ -20322,9 +20363,9 @@
|
|
|
20322
20363
|
getPosition
|
|
20323
20364
|
});
|
|
20324
20365
|
return {
|
|
20325
|
-
|
|
20366
|
+
isNested,
|
|
20326
20367
|
isStyleless,
|
|
20327
|
-
|
|
20368
|
+
isNestedLast,
|
|
20328
20369
|
validateMessage,
|
|
20329
20370
|
classes,
|
|
20330
20371
|
labelStyle,
|
|
@@ -20348,7 +20389,7 @@
|
|
|
20348
20389
|
const it = useFormItem(expose);
|
|
20349
20390
|
const {
|
|
20350
20391
|
isStyleless,
|
|
20351
|
-
|
|
20392
|
+
isNested,
|
|
20352
20393
|
classes,
|
|
20353
20394
|
labelStyle,
|
|
20354
20395
|
contentStyle,
|
|
@@ -20359,39 +20400,35 @@
|
|
|
20359
20400
|
showError,
|
|
20360
20401
|
validateMessage
|
|
20361
20402
|
} = it;
|
|
20362
|
-
const {
|
|
20363
|
-
label,
|
|
20364
|
-
labelFor
|
|
20365
|
-
} = props2;
|
|
20366
20403
|
const errorColorClass = "vc-form-item__error";
|
|
20367
20404
|
return () => {
|
|
20368
20405
|
if (isStyleless.value) return [slots.default?.(), slots.error?.({
|
|
20369
20406
|
show: showError.value,
|
|
20370
|
-
|
|
20407
|
+
nested: isNested.value,
|
|
20371
20408
|
message: validateMessage.value,
|
|
20372
20409
|
class: [errorColorClass, ...errorClass.value],
|
|
20373
20410
|
style: errorStyle.value
|
|
20374
20411
|
})];
|
|
20375
20412
|
return vue.createVNode("div", {
|
|
20376
20413
|
"class": ["vc-form-item", classes.value]
|
|
20377
|
-
}, [(label || slots.label) && vue.createVNode("div", {
|
|
20414
|
+
}, [(props2.label || slots.label) && vue.createVNode("div", {
|
|
20378
20415
|
"style": labelStyle.value,
|
|
20379
20416
|
"class": ["vc-form-item__label", ...labelClass.value],
|
|
20380
|
-
"for": labelFor
|
|
20381
|
-
}, [vue.createVNode("label", null, [label || slots.label?.()])]), vue.createVNode("div", {
|
|
20417
|
+
"for": props2.labelFor
|
|
20418
|
+
}, [vue.createVNode("label", null, [props2.label || slots.label?.()])]), vue.createVNode("div", {
|
|
20382
20419
|
"class": "vc-form-item__wrapper"
|
|
20383
20420
|
}, [vue.createVNode("div", {
|
|
20384
20421
|
"class": ["vc-form-item__content", ...contentClass.value],
|
|
20385
20422
|
"style": contentStyle.value
|
|
20386
20423
|
}, [slots.default?.(), slots.error ? slots.error({
|
|
20387
20424
|
show: showError.value,
|
|
20388
|
-
nest:
|
|
20425
|
+
nest: isNested.value,
|
|
20389
20426
|
message: validateMessage.value,
|
|
20390
20427
|
class: [errorColorClass, ...errorClass.value],
|
|
20391
20428
|
style: errorStyle.value
|
|
20392
20429
|
}) : vue.createVNode(TransitionFade, null, {
|
|
20393
20430
|
default: () => [vue.withDirectives(vue.createVNode("div", {
|
|
20394
|
-
"class": ["vc-form-item__tip",
|
|
20431
|
+
"class": ["vc-form-item__tip", isNested.value ? "is-nested" : "", errorColorClass, ...errorClass.value],
|
|
20395
20432
|
"style": [errorStyle.value]
|
|
20396
20433
|
}, [validateMessage.value]), [[vue.vShow, showError.value]])]
|
|
20397
20434
|
})])])]);
|
|
@@ -20456,41 +20493,36 @@
|
|
|
20456
20493
|
labelClass,
|
|
20457
20494
|
contentClass,
|
|
20458
20495
|
errorClass,
|
|
20459
|
-
|
|
20496
|
+
isNested,
|
|
20460
20497
|
showError,
|
|
20461
20498
|
validateMessage
|
|
20462
20499
|
} = it;
|
|
20463
|
-
const {
|
|
20464
|
-
label,
|
|
20465
|
-
labelFor,
|
|
20466
|
-
showMessage
|
|
20467
|
-
} = props2;
|
|
20468
20500
|
const errorColorClass = "vcm-form-item__error";
|
|
20469
20501
|
return () => {
|
|
20470
20502
|
if (isStyleless.value) return [slots.default?.(), slots.error?.({
|
|
20471
20503
|
show: showError.value,
|
|
20472
|
-
|
|
20504
|
+
nested: isNested.value,
|
|
20473
20505
|
message: validateMessage.value,
|
|
20474
20506
|
class: [errorColorClass, ...errorClass.value],
|
|
20475
20507
|
style: errorStyle.value
|
|
20476
20508
|
})];
|
|
20477
20509
|
return vue.createVNode("div", {
|
|
20478
20510
|
"style": {
|
|
20479
|
-
paddingLeft: `${
|
|
20511
|
+
paddingLeft: `${isNested.value ? 0 : props2.indent}px`
|
|
20480
20512
|
},
|
|
20481
20513
|
"class": [classes.value, "vcm-form-item"]
|
|
20482
20514
|
}, [vue.createVNode("div", {
|
|
20483
20515
|
"class": "vcm-form-item__wrapper"
|
|
20484
20516
|
}, [(props2.label || slots.label) && vue.createVNode("label", {
|
|
20485
|
-
"for": labelFor,
|
|
20517
|
+
"for": props2.labelFor,
|
|
20486
20518
|
"style": labelStyle.value,
|
|
20487
20519
|
"class": ["vcm-form-item__label", ...labelClass.value]
|
|
20488
|
-
}, [label || slots.label?.()]), vue.createVNode("div", {
|
|
20520
|
+
}, [props2.label || slots.label?.()]), vue.createVNode("div", {
|
|
20489
20521
|
"style": contentStyle.value,
|
|
20490
20522
|
"class": ["vcm-form-item__content", ...contentClass.value]
|
|
20491
|
-
}, [slots.default?.(), showMessage && showError.value && vue.createVNode("div", {
|
|
20523
|
+
}, [slots.default?.(), props2.showMessage && showError.value && vue.createVNode("div", {
|
|
20492
20524
|
"class": [{
|
|
20493
|
-
"is-
|
|
20525
|
+
"is-nested": isNested.value
|
|
20494
20526
|
}, errorColorClass, ...errorClass.value],
|
|
20495
20527
|
"style": errorStyle.value
|
|
20496
20528
|
}, [slots.error ? slots.error({
|
|
@@ -20630,7 +20662,7 @@
|
|
|
20630
20662
|
} else if (typeof wrapper === "string") {
|
|
20631
20663
|
scroller.value = document.querySelector(wrapper);
|
|
20632
20664
|
} else {
|
|
20633
|
-
scroller.value = getScroller(instance.vnode.el);
|
|
20665
|
+
scroller.value = getScroller$1(instance.vnode.el);
|
|
20634
20666
|
}
|
|
20635
20667
|
};
|
|
20636
20668
|
const initPlaceholder = () => {
|
|
@@ -22612,13 +22644,13 @@
|
|
|
22612
22644
|
"readonly": true,
|
|
22613
22645
|
"placeholder": its.value.attrs?.placeholder || "请选择"
|
|
22614
22646
|
}, {
|
|
22615
|
-
prepend: () => {
|
|
22616
|
-
|
|
22617
|
-
|
|
22618
|
-
|
|
22647
|
+
prepend: slots.prepend || props2.label ? () => {
|
|
22648
|
+
slots.prepend ? slots.prepend() : vue.createVNode("div", {
|
|
22649
|
+
"class": "vc-select__prepend"
|
|
22650
|
+
}, [vue.createVNode("span", {
|
|
22619
22651
|
"class": "vc-select__label"
|
|
22620
|
-
}, [props2.label]);
|
|
22621
|
-
},
|
|
22652
|
+
}, [props2.label])]);
|
|
22653
|
+
} : null,
|
|
22622
22654
|
content: multiple.value && currentValue.value && currentValue.value.length > 0 ? () => {
|
|
22623
22655
|
return vue.createVNode("div", {
|
|
22624
22656
|
"class": [classes.value, "vc-select__tags"]
|
|
@@ -27988,9 +28020,12 @@
|
|
|
27988
28020
|
barStyle: [Object, String],
|
|
27989
28021
|
contentStyle: [Object, String],
|
|
27990
28022
|
barClass: [Object, String],
|
|
27991
|
-
contentClass: [Object, String]
|
|
28023
|
+
contentClass: [Object, String],
|
|
28024
|
+
affixable: Boolean,
|
|
28025
|
+
affixOptions: Object
|
|
27992
28026
|
};
|
|
27993
28027
|
const useTabs = (options = {}) => {
|
|
28028
|
+
const affix = vue.inject("vc-affix", null);
|
|
27994
28029
|
const instance = vue.getCurrentInstance();
|
|
27995
28030
|
const { props: props2, emit } = instance;
|
|
27996
28031
|
const tabsId = vue.ref(getUid("tabs"));
|
|
@@ -28032,10 +28067,56 @@
|
|
|
28032
28067
|
[`is-${props2.theme}`]: !!props2.theme
|
|
28033
28068
|
};
|
|
28034
28069
|
});
|
|
28070
|
+
const hasAnchor = vue.computed(() => {
|
|
28071
|
+
return list.value.some((item) => !!item.anchor);
|
|
28072
|
+
});
|
|
28035
28073
|
const refresh = () => {
|
|
28036
28074
|
options?.refreshAfloat?.();
|
|
28037
28075
|
};
|
|
28038
|
-
|
|
28076
|
+
let scrollToAnchorTimer;
|
|
28077
|
+
const scrollToAnchor = (anchor) => {
|
|
28078
|
+
if (!anchor) return;
|
|
28079
|
+
const el2 = document.querySelector(anchor);
|
|
28080
|
+
if (!el2) return;
|
|
28081
|
+
const scroller = getScroller(instance.vnode.el);
|
|
28082
|
+
scrollIntoView(scroller, {
|
|
28083
|
+
duration: 250,
|
|
28084
|
+
from: scroller.scrollTop,
|
|
28085
|
+
to: scroller.scrollTop + el2.getBoundingClientRect().top - scroller.getBoundingClientRect().top - (!affix || affix.props.placement !== "bottom" ? instance.vnode.el.offsetHeight : 0) - (affix && affix.props.placement !== "bottom" ? affix.props.offset : 0)
|
|
28086
|
+
});
|
|
28087
|
+
scrollToAnchorTimer && clearTimeout(scrollToAnchorTimer);
|
|
28088
|
+
scrollToAnchorTimer = setTimeout(() => scrollToAnchorTimer = null, 300);
|
|
28089
|
+
};
|
|
28090
|
+
const handleAffixScroll = () => {
|
|
28091
|
+
if (!hasAnchor.value || scrollToAnchorTimer) return;
|
|
28092
|
+
const scroller = getScroller(instance.vnode.el);
|
|
28093
|
+
const scrollTop = scroller?.scrollTop;
|
|
28094
|
+
if (typeof scrollTop !== "number") return;
|
|
28095
|
+
for (let i = 0; i < list.value.length; i++) {
|
|
28096
|
+
const nav = list.value[i];
|
|
28097
|
+
const anchor = nav.anchor;
|
|
28098
|
+
if (!anchor) continue;
|
|
28099
|
+
const el2 = document.querySelector(anchor);
|
|
28100
|
+
if (!el2) continue;
|
|
28101
|
+
const elTop = el2.getBoundingClientRect().top - scroller.getBoundingClientRect().top + scroller.scrollTop;
|
|
28102
|
+
const nextNav = list.value[i + 1];
|
|
28103
|
+
let nextElTop;
|
|
28104
|
+
if (nextNav && nextNav.anchor) {
|
|
28105
|
+
const nextEl = document.querySelector(nextNav.anchor);
|
|
28106
|
+
if (nextEl) {
|
|
28107
|
+
nextElTop = nextEl.getBoundingClientRect().top - scroller.getBoundingClientRect().top + scroller.scrollTop;
|
|
28108
|
+
}
|
|
28109
|
+
}
|
|
28110
|
+
const allowDistance = 2;
|
|
28111
|
+
if (scrollTop >= elTop - allowDistance && (typeof nextElTop === "undefined" || scrollTop < nextElTop - allowDistance)) {
|
|
28112
|
+
if (getTabIndex(currentValue.value) !== i) {
|
|
28113
|
+
handleChange(i, false);
|
|
28114
|
+
}
|
|
28115
|
+
break;
|
|
28116
|
+
}
|
|
28117
|
+
}
|
|
28118
|
+
};
|
|
28119
|
+
const handleChange = (index, scrollTo = true) => {
|
|
28039
28120
|
if (timer.value) return;
|
|
28040
28121
|
timer.value = setTimeout(() => timer.value = null, 300);
|
|
28041
28122
|
const nav = list.value[index];
|
|
@@ -28044,7 +28125,7 @@
|
|
|
28044
28125
|
emit("update:modelValue", currentValue.value);
|
|
28045
28126
|
emit("change", currentValue.value);
|
|
28046
28127
|
emit("click", currentValue.value);
|
|
28047
|
-
|
|
28128
|
+
scrollTo && scrollToAnchor(nav.anchor);
|
|
28048
28129
|
};
|
|
28049
28130
|
const handleResize = () => {
|
|
28050
28131
|
if (instance.isUnmounted) return;
|
|
@@ -28054,10 +28135,13 @@
|
|
|
28054
28135
|
vue.onMounted(() => {
|
|
28055
28136
|
Resize.on(options.wrapper.value, handleResize);
|
|
28056
28137
|
options.scrollToActive && vue.nextTick(options.scrollToActive);
|
|
28138
|
+
affix?.onScroll?.(handleAffixScroll);
|
|
28057
28139
|
});
|
|
28058
28140
|
vue.onBeforeUnmount(() => {
|
|
28059
28141
|
Resize.off(options.wrapper.value, handleResize);
|
|
28060
28142
|
timer.value && clearTimeout(timer.value);
|
|
28143
|
+
affix?.offScroll?.(handleAffixScroll);
|
|
28144
|
+
scrollToAnchorTimer && clearTimeout(scrollToAnchorTimer);
|
|
28061
28145
|
});
|
|
28062
28146
|
const add = (item, setValue) => {
|
|
28063
28147
|
if (!item) return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deot/vc",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.49",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"access": "public"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@deot/vc-components": "^1.0.
|
|
23
|
-
"@deot/vc-hooks": "^1.0.
|
|
24
|
-
"@deot/vc-shared": "^1.0.
|
|
22
|
+
"@deot/vc-components": "^1.0.49",
|
|
23
|
+
"@deot/vc-hooks": "^1.0.49",
|
|
24
|
+
"@deot/vc-shared": "^1.0.49"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"vue": "*"
|