@deot/vc-components 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.cjs +177 -92
- package/dist/index.d.ts +177 -111
- package/dist/index.iife.js +205 -120
- package/dist/index.js +179 -94
- package/dist/index.style.css +1 -1
- package/dist/index.umd.cjs +205 -120
- package/package.json +1 -1
package/dist/index.umd.cjs
CHANGED
|
@@ -92,6 +92,38 @@
|
|
|
92
92
|
|
|
93
93
|
const MActionSheet = ActionSheet;
|
|
94
94
|
|
|
95
|
+
const props$1s = {
|
|
96
|
+
modelValue: {
|
|
97
|
+
type: Boolean,
|
|
98
|
+
default: false
|
|
99
|
+
},
|
|
100
|
+
zIndex: {
|
|
101
|
+
type: [Number, String],
|
|
102
|
+
default: 1
|
|
103
|
+
},
|
|
104
|
+
// TODO: left/right
|
|
105
|
+
placement: {
|
|
106
|
+
type: String,
|
|
107
|
+
default: "top"
|
|
108
|
+
},
|
|
109
|
+
disabled: {
|
|
110
|
+
type: Boolean,
|
|
111
|
+
default: false
|
|
112
|
+
},
|
|
113
|
+
fixed: {
|
|
114
|
+
type: Boolean,
|
|
115
|
+
default: true
|
|
116
|
+
},
|
|
117
|
+
offset: {
|
|
118
|
+
type: Number,
|
|
119
|
+
default: 0
|
|
120
|
+
},
|
|
121
|
+
// -> 固钉始终保持在容器内, 超过范围则隐藏(请注意容器避免出现滚动条) 仅fixed为true有效
|
|
122
|
+
target: {
|
|
123
|
+
type: String
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
95
127
|
const IS_SERVER$3 = typeof window === "undefined";
|
|
96
128
|
|
|
97
129
|
const hasClass = (el, cls) => {
|
|
@@ -189,7 +221,7 @@
|
|
|
189
221
|
return !!(overflow.match(/(scroll|auto)/) || className?.test(el.className));
|
|
190
222
|
};
|
|
191
223
|
|
|
192
|
-
const getScroller = (el, options) => {
|
|
224
|
+
const getScroller$1 = (el, options) => {
|
|
193
225
|
if (IS_SERVER$3 || !el) return null;
|
|
194
226
|
let parent = el;
|
|
195
227
|
while (parent) {
|
|
@@ -308,44 +340,45 @@
|
|
|
308
340
|
return target;
|
|
309
341
|
};
|
|
310
342
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
343
|
+
let scrollBarWidth;
|
|
344
|
+
const getScrollBarWidth = () => {
|
|
345
|
+
if (scrollBarWidth !== void 0) return scrollBarWidth;
|
|
346
|
+
const outer = document.createElement("div");
|
|
347
|
+
outer.className = "vc-scrollbar__wrap";
|
|
348
|
+
outer.style.visibility = "hidden";
|
|
349
|
+
outer.style.width = "100px";
|
|
350
|
+
outer.style.position = "absolute";
|
|
351
|
+
outer.style.top = "-9999px";
|
|
352
|
+
document.body.appendChild(outer);
|
|
353
|
+
const widthNoScroll = outer.offsetWidth;
|
|
354
|
+
outer.style.overflow = "scroll";
|
|
355
|
+
const inner = document.createElement("div");
|
|
356
|
+
inner.style.width = "100%";
|
|
357
|
+
outer.appendChild(inner);
|
|
358
|
+
const widthWithScroll = inner.offsetWidth;
|
|
359
|
+
outer.parentNode?.removeChild?.(outer);
|
|
360
|
+
scrollBarWidth = widthNoScroll - widthWithScroll;
|
|
361
|
+
return scrollBarWidth;
|
|
362
|
+
};
|
|
363
|
+
const SCROLLER_WHEEL_REG = /vc-scroller-wheel/;
|
|
364
|
+
const getScroller = (el) => {
|
|
365
|
+
return getScroller$1(el, { className: SCROLLER_WHEEL_REG });
|
|
366
|
+
};
|
|
367
|
+
const isWheel = (el) => {
|
|
368
|
+
return SCROLLER_WHEEL_REG.test(el?.className || "");
|
|
337
369
|
};
|
|
338
370
|
|
|
339
371
|
/** @jsxImportSource vue */
|
|
340
372
|
|
|
341
373
|
const COMPONENT_NAME$27 = 'vc-affix';
|
|
342
|
-
const SCROLLER_WHEEL_REG = /vc-scroller-wheel/;
|
|
343
374
|
const Affix = /* @__PURE__ */ vue.defineComponent({
|
|
344
375
|
name: COMPONENT_NAME$27,
|
|
376
|
+
emits: ['update:modelValue'],
|
|
345
377
|
props: props$1s,
|
|
346
378
|
setup(props, {
|
|
347
379
|
slots,
|
|
348
|
-
expose
|
|
380
|
+
expose,
|
|
381
|
+
emit
|
|
349
382
|
}) {
|
|
350
383
|
const scrollerInstance = vue.inject('vc-scroller', null);
|
|
351
384
|
const scroller = vue.shallowRef(); // 当前元素所在的滚动容器
|
|
@@ -361,9 +394,7 @@
|
|
|
361
394
|
const isActive = vue.ref(false);
|
|
362
395
|
const transformY = vue.ref(0);
|
|
363
396
|
const windowHeight = vue.ref(window.innerHeight);
|
|
364
|
-
const isVcScrollerWheel = vue.computed(() =>
|
|
365
|
-
return SCROLLER_WHEEL_REG.test(scroller.value?.className || '');
|
|
366
|
-
});
|
|
397
|
+
const isVcScrollerWheel = vue.computed(() => isWheel(scroller.value));
|
|
367
398
|
const currentStyle = vue.computed(() => {
|
|
368
399
|
if (!isActive.value) return {};
|
|
369
400
|
return {
|
|
@@ -384,7 +415,8 @@
|
|
|
384
415
|
};
|
|
385
416
|
});
|
|
386
417
|
const setCurrentRect = () => {
|
|
387
|
-
const rect = current.value
|
|
418
|
+
const rect = current.value?.getBoundingClientRect?.();
|
|
419
|
+
if (!rect) return;
|
|
388
420
|
Object.assign(currentRect, {
|
|
389
421
|
top: rect.top,
|
|
390
422
|
bottom: rect.bottom,
|
|
@@ -411,7 +443,7 @@
|
|
|
411
443
|
transformY.value = Math.min(containerRect.bottom - currentHeightOffset, 0) + transformOffsetY;
|
|
412
444
|
} else {
|
|
413
445
|
isActive.value = currentRect.bottom - containerRect.top >= containerRect.height - props.offset;
|
|
414
|
-
transformY.value =
|
|
446
|
+
transformY.value = transformOffsetY;
|
|
415
447
|
}
|
|
416
448
|
};
|
|
417
449
|
const setFixedStatus = () => {
|
|
@@ -438,36 +470,58 @@
|
|
|
438
470
|
}
|
|
439
471
|
}
|
|
440
472
|
};
|
|
473
|
+
const offScroll = handler => {
|
|
474
|
+
if (isVcScrollerWheel.value) {
|
|
475
|
+
scrollerInstance?.off(handler);
|
|
476
|
+
} else {
|
|
477
|
+
scroller.value?.removeEventListener('scroll', handler);
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
const onScroll = (handler, options) => {
|
|
481
|
+
// nextTick目的在与onMounted后执行
|
|
482
|
+
vue.nextTick(() => {
|
|
483
|
+
if (isVcScrollerWheel.value) {
|
|
484
|
+
scrollerInstance?.on(handler);
|
|
485
|
+
} else {
|
|
486
|
+
scroller.value?.addEventListener('scroll', handler);
|
|
487
|
+
}
|
|
488
|
+
options?.first && handler();
|
|
489
|
+
});
|
|
490
|
+
return () => offScroll(handler);
|
|
491
|
+
};
|
|
441
492
|
const refresh = () => {
|
|
493
|
+
if (props.disabled) return;
|
|
442
494
|
setCurrentRect();
|
|
443
495
|
scroller.value instanceof Window || props.fixed ? setFixedStatus() : setAbsoluteStatus();
|
|
496
|
+
emit('update:modelValue', isActive.value);
|
|
444
497
|
};
|
|
445
498
|
vue.onMounted(() => {
|
|
446
499
|
if (typeof props.target === 'string') {
|
|
447
500
|
base.value = document.querySelector(props.target) ?? void 0;
|
|
448
501
|
}
|
|
449
502
|
!base.value && (base.value = document.documentElement);
|
|
450
|
-
scroller.value = getScroller(current.value
|
|
451
|
-
|
|
503
|
+
scroller.value = getScroller(current.value);
|
|
504
|
+
onScroll(refresh, {
|
|
505
|
+
first: true
|
|
452
506
|
});
|
|
453
|
-
if (isVcScrollerWheel.value) {
|
|
454
|
-
scrollerInstance?.on(refresh);
|
|
455
|
-
} else {
|
|
456
|
-
scroller.value?.addEventListener('scroll', refresh);
|
|
457
|
-
}
|
|
458
|
-
refresh();
|
|
459
|
-
});
|
|
460
|
-
vue.onBeforeUnmount(() => {
|
|
461
|
-
if (isVcScrollerWheel.value) {
|
|
462
|
-
scrollerInstance?.off(refresh);
|
|
463
|
-
} else {
|
|
464
|
-
scroller.value?.removeEventListener('scroll', refresh);
|
|
465
|
-
}
|
|
466
507
|
});
|
|
508
|
+
vue.onBeforeUnmount(() => offScroll(refresh));
|
|
467
509
|
expose({
|
|
468
|
-
refresh
|
|
510
|
+
refresh,
|
|
511
|
+
onScroll,
|
|
512
|
+
offScroll
|
|
513
|
+
});
|
|
514
|
+
vue.provide('vc-affix', {
|
|
515
|
+
props,
|
|
516
|
+
isActive,
|
|
517
|
+
refresh,
|
|
518
|
+
onScroll,
|
|
519
|
+
offScroll
|
|
469
520
|
});
|
|
470
521
|
return () => {
|
|
522
|
+
if (props.disabled) return slots?.default?.({
|
|
523
|
+
active: false
|
|
524
|
+
});
|
|
471
525
|
return vue.createVNode("div", {
|
|
472
526
|
"ref": current,
|
|
473
527
|
"class": "vc-affix",
|
|
@@ -14394,27 +14448,6 @@
|
|
|
14394
14448
|
}
|
|
14395
14449
|
};
|
|
14396
14450
|
|
|
14397
|
-
let scrollBarWidth;
|
|
14398
|
-
const getScrollBarWidth = () => {
|
|
14399
|
-
if (scrollBarWidth !== void 0) return scrollBarWidth;
|
|
14400
|
-
const outer = document.createElement("div");
|
|
14401
|
-
outer.className = "vc-scrollbar__wrap";
|
|
14402
|
-
outer.style.visibility = "hidden";
|
|
14403
|
-
outer.style.width = "100px";
|
|
14404
|
-
outer.style.position = "absolute";
|
|
14405
|
-
outer.style.top = "-9999px";
|
|
14406
|
-
document.body.appendChild(outer);
|
|
14407
|
-
const widthNoScroll = outer.offsetWidth;
|
|
14408
|
-
outer.style.overflow = "scroll";
|
|
14409
|
-
const inner = document.createElement("div");
|
|
14410
|
-
inner.style.width = "100%";
|
|
14411
|
-
outer.appendChild(inner);
|
|
14412
|
-
const widthWithScroll = inner.offsetWidth;
|
|
14413
|
-
outer.parentNode?.removeChild?.(outer);
|
|
14414
|
-
scrollBarWidth = widthNoScroll - widthWithScroll;
|
|
14415
|
-
return scrollBarWidth;
|
|
14416
|
-
};
|
|
14417
|
-
|
|
14418
14451
|
const barKeys$1 = [
|
|
14419
14452
|
"always",
|
|
14420
14453
|
"thumbMinSize",
|
|
@@ -19869,7 +19902,14 @@
|
|
|
19869
19902
|
labelStyle: [Object, String],
|
|
19870
19903
|
labelClass: [Object, String],
|
|
19871
19904
|
errorStyle: [Object, String],
|
|
19872
|
-
errorClass: [Object, String]
|
|
19905
|
+
errorClass: [Object, String],
|
|
19906
|
+
// 给nestFormItem统一注入
|
|
19907
|
+
nestedContentStyle: [Object, String],
|
|
19908
|
+
nestedContentClass: [Object, String],
|
|
19909
|
+
nestedLabelStyle: [Object, String],
|
|
19910
|
+
nestedLabelClass: [Object, String],
|
|
19911
|
+
nestedErrorStyle: [Object, String],
|
|
19912
|
+
nestedErrorClass: [Object, String]
|
|
19873
19913
|
};
|
|
19874
19914
|
|
|
19875
19915
|
const useForm = (expose, options = {}) => {
|
|
@@ -20221,31 +20261,32 @@
|
|
|
20221
20261
|
});
|
|
20222
20262
|
const classes = vue.computed(() => {
|
|
20223
20263
|
return {
|
|
20224
|
-
"is-
|
|
20264
|
+
"is-required": isRequired.value && props.asterisk,
|
|
20225
20265
|
"is-error": validateState.value === "error",
|
|
20226
20266
|
"is-validating": validateState.value === "validating",
|
|
20227
20267
|
"is-inline": form.props.inline,
|
|
20228
|
-
"is-
|
|
20268
|
+
"is-nested": isNested.value,
|
|
20229
20269
|
"is-alone": !props.showMessage,
|
|
20230
20270
|
// 用于单独去除form-item的默认margin_bottom
|
|
20231
20271
|
[`is-${labelPosition.value}`]: true
|
|
20232
20272
|
};
|
|
20233
20273
|
});
|
|
20234
|
-
const
|
|
20274
|
+
const isNested = vue.computed(() => {
|
|
20235
20275
|
return !!formItem.change;
|
|
20236
20276
|
});
|
|
20237
|
-
const
|
|
20277
|
+
const isNestedLast = vue.ref(false);
|
|
20238
20278
|
const hasLabel = vue.computed(() => {
|
|
20239
20279
|
return !!props.label || slots.label;
|
|
20240
20280
|
});
|
|
20241
20281
|
const labelStyle = vue.computed(() => {
|
|
20242
|
-
const labelWidth = props.labelWidth === 0 || props.labelWidth ? props.labelWidth :
|
|
20282
|
+
const labelWidth = props.labelWidth === 0 || props.labelWidth ? props.labelWidth : isNested.value ? 0 : form.props.labelWidth;
|
|
20243
20283
|
return [
|
|
20244
20284
|
{
|
|
20245
20285
|
width: labelPosition.value !== "top" && labelWidth && labelWidth > 0 ? `${labelWidth}px` : "auto",
|
|
20246
20286
|
textAlign: labelPosition.value === "top" ? "left" : labelPosition.value
|
|
20247
20287
|
},
|
|
20248
20288
|
form.props.labelStyle,
|
|
20289
|
+
isNested.value && form.props.nestedLabelStyle,
|
|
20249
20290
|
props.labelStyle
|
|
20250
20291
|
];
|
|
20251
20292
|
});
|
|
@@ -20253,24 +20294,25 @@
|
|
|
20253
20294
|
const labelWidth = props.labelWidth === 0 || props.labelWidth ? props.labelWidth : form.props.labelWidth;
|
|
20254
20295
|
return [
|
|
20255
20296
|
{
|
|
20256
|
-
marginLeft: !hasLabel.value &&
|
|
20257
|
-
marginBottom:
|
|
20297
|
+
marginLeft: labelPosition.value === "top" || !hasLabel.value && isNested.value ? 0 : labelWidth && labelWidth > 0 ? `${labelWidth}px` : "unset",
|
|
20298
|
+
marginBottom: isNested.value && !isNestedLast.value ? `20px` : 0
|
|
20258
20299
|
},
|
|
20259
20300
|
form.props.contentStyle,
|
|
20301
|
+
isNested.value && form.props.nestedContentStyle,
|
|
20260
20302
|
props.contentStyle
|
|
20261
20303
|
];
|
|
20262
20304
|
});
|
|
20263
20305
|
const errorStyle = vue.computed(() => {
|
|
20264
|
-
return [form.props.errorStyle, props.errorStyle];
|
|
20306
|
+
return [form.props.errorStyle, isNested.value && form.props.nestedErrorStyle, props.errorStyle];
|
|
20265
20307
|
});
|
|
20266
20308
|
const labelClass = vue.computed(() => {
|
|
20267
|
-
return [form.props.labelClass, props.labelClass];
|
|
20309
|
+
return [form.props.labelClass, isNested.value && form.props.nestedLabelClass, props.labelClass];
|
|
20268
20310
|
});
|
|
20269
20311
|
const contentClass = vue.computed(() => {
|
|
20270
|
-
return [form.props.contentClass, props.contentClass];
|
|
20312
|
+
return [form.props.contentClass, isNested.value && form.props.nestedContentClass, props.contentClass];
|
|
20271
20313
|
});
|
|
20272
20314
|
const errorClass = vue.computed(() => {
|
|
20273
|
-
return [form.props.errorClass, props.errorClass];
|
|
20315
|
+
return [form.props.errorClass, isNested.value && form.props.nestedErrorClass, props.errorClass];
|
|
20274
20316
|
});
|
|
20275
20317
|
const isStyleless = vue.computed(() => {
|
|
20276
20318
|
return props.styleless || form.props.styleless;
|
|
@@ -20407,7 +20449,7 @@
|
|
|
20407
20449
|
vue.watch(
|
|
20408
20450
|
() => formItem.fields?.length,
|
|
20409
20451
|
async (v) => {
|
|
20410
|
-
if (!
|
|
20452
|
+
if (!isNested.value || !v) return isNestedLast.value = false;
|
|
20411
20453
|
const fields$ = [...vue.toRaw(formItem.fields)];
|
|
20412
20454
|
const positions = await Promise.all(fields$.map((item) => item.exposed.getPosition()));
|
|
20413
20455
|
const sortFields = fields$.toSorted((a, b) => {
|
|
@@ -20418,7 +20460,7 @@
|
|
|
20418
20460
|
if (aPosition.top != bPosition.top) return aPosition.top - bPosition.top;
|
|
20419
20461
|
return aPosition.left - bPosition.left;
|
|
20420
20462
|
});
|
|
20421
|
-
|
|
20463
|
+
isNestedLast.value = sortFields[sortFields.length - 1] === instance;
|
|
20422
20464
|
}
|
|
20423
20465
|
);
|
|
20424
20466
|
expose({
|
|
@@ -20427,9 +20469,9 @@
|
|
|
20427
20469
|
getPosition
|
|
20428
20470
|
});
|
|
20429
20471
|
return {
|
|
20430
|
-
|
|
20472
|
+
isNested,
|
|
20431
20473
|
isStyleless,
|
|
20432
|
-
|
|
20474
|
+
isNestedLast,
|
|
20433
20475
|
validateMessage,
|
|
20434
20476
|
classes,
|
|
20435
20477
|
labelStyle,
|
|
@@ -20456,7 +20498,7 @@
|
|
|
20456
20498
|
const it = useFormItem(expose);
|
|
20457
20499
|
const {
|
|
20458
20500
|
isStyleless,
|
|
20459
|
-
|
|
20501
|
+
isNested,
|
|
20460
20502
|
classes,
|
|
20461
20503
|
labelStyle,
|
|
20462
20504
|
contentStyle,
|
|
@@ -20467,39 +20509,35 @@
|
|
|
20467
20509
|
showError,
|
|
20468
20510
|
validateMessage
|
|
20469
20511
|
} = it;
|
|
20470
|
-
const {
|
|
20471
|
-
label,
|
|
20472
|
-
labelFor
|
|
20473
|
-
} = props;
|
|
20474
20512
|
const errorColorClass = 'vc-form-item__error';
|
|
20475
20513
|
return () => {
|
|
20476
20514
|
if (isStyleless.value) return [slots.default?.(), slots.error?.({
|
|
20477
20515
|
show: showError.value,
|
|
20478
|
-
|
|
20516
|
+
nested: isNested.value,
|
|
20479
20517
|
message: validateMessage.value,
|
|
20480
20518
|
class: [errorColorClass, ...errorClass.value],
|
|
20481
20519
|
style: errorStyle.value
|
|
20482
20520
|
})];
|
|
20483
20521
|
return vue.createVNode("div", {
|
|
20484
20522
|
"class": ['vc-form-item', classes.value]
|
|
20485
|
-
}, [(label || slots.label) && vue.createVNode("div", {
|
|
20523
|
+
}, [(props.label || slots.label) && vue.createVNode("div", {
|
|
20486
20524
|
"style": labelStyle.value,
|
|
20487
20525
|
"class": ['vc-form-item__label', ...labelClass.value],
|
|
20488
|
-
"for": labelFor
|
|
20489
|
-
}, [vue.createVNode("label", null, [label || slots.label?.()])]), vue.createVNode("div", {
|
|
20526
|
+
"for": props.labelFor
|
|
20527
|
+
}, [vue.createVNode("label", null, [props.label || slots.label?.()])]), vue.createVNode("div", {
|
|
20490
20528
|
"class": "vc-form-item__wrapper"
|
|
20491
20529
|
}, [vue.createVNode("div", {
|
|
20492
20530
|
"class": ['vc-form-item__content', ...contentClass.value],
|
|
20493
20531
|
"style": contentStyle.value
|
|
20494
20532
|
}, [slots.default?.(), slots.error ? slots.error({
|
|
20495
20533
|
show: showError.value,
|
|
20496
|
-
nest:
|
|
20534
|
+
nest: isNested.value,
|
|
20497
20535
|
message: validateMessage.value,
|
|
20498
20536
|
class: [errorColorClass, ...errorClass.value],
|
|
20499
20537
|
style: errorStyle.value
|
|
20500
20538
|
}) : vue.createVNode(TransitionFade, null, {
|
|
20501
20539
|
default: () => [vue.withDirectives(vue.createVNode("div", {
|
|
20502
|
-
"class": ['vc-form-item__tip',
|
|
20540
|
+
"class": ['vc-form-item__tip', isNested.value ? 'is-nested' : '', errorColorClass, ...errorClass.value],
|
|
20503
20541
|
"style": [errorStyle.value]
|
|
20504
20542
|
}, [validateMessage.value]), [[vue.vShow, showError.value]])]
|
|
20505
20543
|
})])])]);
|
|
@@ -20570,41 +20608,36 @@
|
|
|
20570
20608
|
labelClass,
|
|
20571
20609
|
contentClass,
|
|
20572
20610
|
errorClass,
|
|
20573
|
-
|
|
20611
|
+
isNested,
|
|
20574
20612
|
showError,
|
|
20575
20613
|
validateMessage
|
|
20576
20614
|
} = it;
|
|
20577
|
-
const {
|
|
20578
|
-
label,
|
|
20579
|
-
labelFor,
|
|
20580
|
-
showMessage
|
|
20581
|
-
} = props;
|
|
20582
20615
|
const errorColorClass = 'vcm-form-item__error';
|
|
20583
20616
|
return () => {
|
|
20584
20617
|
if (isStyleless.value) return [slots.default?.(), slots.error?.({
|
|
20585
20618
|
show: showError.value,
|
|
20586
|
-
|
|
20619
|
+
nested: isNested.value,
|
|
20587
20620
|
message: validateMessage.value,
|
|
20588
20621
|
class: [errorColorClass, ...errorClass.value],
|
|
20589
20622
|
style: errorStyle.value
|
|
20590
20623
|
})];
|
|
20591
20624
|
return vue.createVNode("div", {
|
|
20592
20625
|
"style": {
|
|
20593
|
-
paddingLeft: `${
|
|
20626
|
+
paddingLeft: `${isNested.value ? 0 : props.indent}px`
|
|
20594
20627
|
},
|
|
20595
20628
|
"class": [classes.value, 'vcm-form-item']
|
|
20596
20629
|
}, [vue.createVNode("div", {
|
|
20597
20630
|
"class": "vcm-form-item__wrapper"
|
|
20598
20631
|
}, [(props.label || slots.label) && vue.createVNode("label", {
|
|
20599
|
-
"for": labelFor,
|
|
20632
|
+
"for": props.labelFor,
|
|
20600
20633
|
"style": labelStyle.value,
|
|
20601
20634
|
"class": ['vcm-form-item__label', ...labelClass.value]
|
|
20602
|
-
}, [label || slots.label?.()]), vue.createVNode("div", {
|
|
20635
|
+
}, [props.label || slots.label?.()]), vue.createVNode("div", {
|
|
20603
20636
|
"style": contentStyle.value,
|
|
20604
20637
|
"class": ['vcm-form-item__content', ...contentClass.value]
|
|
20605
|
-
}, [slots.default?.(), showMessage && showError.value && vue.createVNode("div", {
|
|
20638
|
+
}, [slots.default?.(), props.showMessage && showError.value && vue.createVNode("div", {
|
|
20606
20639
|
"class": [{
|
|
20607
|
-
'is-
|
|
20640
|
+
'is-nested': isNested.value
|
|
20608
20641
|
}, errorColorClass, ...errorClass.value],
|
|
20609
20642
|
"style": errorStyle.value
|
|
20610
20643
|
}, [slots.error ? slots.error({
|
|
@@ -21131,7 +21164,7 @@
|
|
|
21131
21164
|
} else if (typeof wrapper === 'string') {
|
|
21132
21165
|
scroller.value = document.querySelector(wrapper);
|
|
21133
21166
|
} else {
|
|
21134
|
-
scroller.value = getScroller(instance.vnode.el);
|
|
21167
|
+
scroller.value = getScroller$1(instance.vnode.el);
|
|
21135
21168
|
}
|
|
21136
21169
|
};
|
|
21137
21170
|
const initPlaceholder = () => {
|
|
@@ -23267,13 +23300,13 @@
|
|
|
23267
23300
|
"readonly": true,
|
|
23268
23301
|
"placeholder": its.value.attrs?.placeholder || '请选择'
|
|
23269
23302
|
}, {
|
|
23270
|
-
prepend: () => {
|
|
23271
|
-
|
|
23272
|
-
|
|
23273
|
-
|
|
23303
|
+
prepend: slots.prepend || props.label ? () => {
|
|
23304
|
+
slots.prepend ? slots.prepend() : vue.createVNode("div", {
|
|
23305
|
+
"class": "vc-select__prepend"
|
|
23306
|
+
}, [vue.createVNode("span", {
|
|
23274
23307
|
"class": "vc-select__label"
|
|
23275
|
-
}, [props.label]);
|
|
23276
|
-
},
|
|
23308
|
+
}, [props.label])]);
|
|
23309
|
+
} : null,
|
|
23277
23310
|
content: multiple.value && currentValue.value && currentValue.value.length > 0 ? () => {
|
|
23278
23311
|
return vue.createVNode("div", {
|
|
23279
23312
|
"class": [classes.value, 'vc-select__tags']
|
|
@@ -29029,10 +29062,13 @@
|
|
|
29029
29062
|
barStyle: [Object, String],
|
|
29030
29063
|
contentStyle: [Object, String],
|
|
29031
29064
|
barClass: [Object, String],
|
|
29032
|
-
contentClass: [Object, String]
|
|
29065
|
+
contentClass: [Object, String],
|
|
29066
|
+
affixable: Boolean,
|
|
29067
|
+
affixOptions: Object
|
|
29033
29068
|
};
|
|
29034
29069
|
|
|
29035
29070
|
const useTabs = (options = {}) => {
|
|
29071
|
+
const affix = vue.inject("vc-affix", null);
|
|
29036
29072
|
const instance = vue.getCurrentInstance();
|
|
29037
29073
|
const { props, emit } = instance;
|
|
29038
29074
|
const tabsId = vue.ref(getUid("tabs"));
|
|
@@ -29074,10 +29110,56 @@
|
|
|
29074
29110
|
[`is-${props.theme}`]: !!props.theme
|
|
29075
29111
|
};
|
|
29076
29112
|
});
|
|
29113
|
+
const hasAnchor = vue.computed(() => {
|
|
29114
|
+
return list.value.some((item) => !!item.anchor);
|
|
29115
|
+
});
|
|
29077
29116
|
const refresh = () => {
|
|
29078
29117
|
options?.refreshAfloat?.();
|
|
29079
29118
|
};
|
|
29080
|
-
|
|
29119
|
+
let scrollToAnchorTimer;
|
|
29120
|
+
const scrollToAnchor = (anchor) => {
|
|
29121
|
+
if (!anchor) return;
|
|
29122
|
+
const el = document.querySelector(anchor);
|
|
29123
|
+
if (!el) return;
|
|
29124
|
+
const scroller = getScroller(instance.vnode.el);
|
|
29125
|
+
scrollIntoView(scroller, {
|
|
29126
|
+
duration: 250,
|
|
29127
|
+
from: scroller.scrollTop,
|
|
29128
|
+
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)
|
|
29129
|
+
});
|
|
29130
|
+
scrollToAnchorTimer && clearTimeout(scrollToAnchorTimer);
|
|
29131
|
+
scrollToAnchorTimer = setTimeout(() => scrollToAnchorTimer = null, 300);
|
|
29132
|
+
};
|
|
29133
|
+
const handleAffixScroll = () => {
|
|
29134
|
+
if (!hasAnchor.value || scrollToAnchorTimer) return;
|
|
29135
|
+
const scroller = getScroller(instance.vnode.el);
|
|
29136
|
+
const scrollTop = scroller?.scrollTop;
|
|
29137
|
+
if (typeof scrollTop !== "number") return;
|
|
29138
|
+
for (let i = 0; i < list.value.length; i++) {
|
|
29139
|
+
const nav = list.value[i];
|
|
29140
|
+
const anchor = nav.anchor;
|
|
29141
|
+
if (!anchor) continue;
|
|
29142
|
+
const el = document.querySelector(anchor);
|
|
29143
|
+
if (!el) continue;
|
|
29144
|
+
const elTop = el.getBoundingClientRect().top - scroller.getBoundingClientRect().top + scroller.scrollTop;
|
|
29145
|
+
const nextNav = list.value[i + 1];
|
|
29146
|
+
let nextElTop;
|
|
29147
|
+
if (nextNav && nextNav.anchor) {
|
|
29148
|
+
const nextEl = document.querySelector(nextNav.anchor);
|
|
29149
|
+
if (nextEl) {
|
|
29150
|
+
nextElTop = nextEl.getBoundingClientRect().top - scroller.getBoundingClientRect().top + scroller.scrollTop;
|
|
29151
|
+
}
|
|
29152
|
+
}
|
|
29153
|
+
const allowDistance = 2;
|
|
29154
|
+
if (scrollTop >= elTop - allowDistance && (typeof nextElTop === "undefined" || scrollTop < nextElTop - allowDistance)) {
|
|
29155
|
+
if (getTabIndex(currentValue.value) !== i) {
|
|
29156
|
+
handleChange(i, false);
|
|
29157
|
+
}
|
|
29158
|
+
break;
|
|
29159
|
+
}
|
|
29160
|
+
}
|
|
29161
|
+
};
|
|
29162
|
+
const handleChange = (index, scrollTo = true) => {
|
|
29081
29163
|
if (timer.value) return;
|
|
29082
29164
|
timer.value = setTimeout(() => timer.value = null, 300);
|
|
29083
29165
|
const nav = list.value[index];
|
|
@@ -29086,7 +29168,7 @@
|
|
|
29086
29168
|
emit("update:modelValue", currentValue.value);
|
|
29087
29169
|
emit("change", currentValue.value);
|
|
29088
29170
|
emit("click", currentValue.value);
|
|
29089
|
-
|
|
29171
|
+
scrollTo && scrollToAnchor(nav.anchor);
|
|
29090
29172
|
};
|
|
29091
29173
|
const handleResize = () => {
|
|
29092
29174
|
if (instance.isUnmounted) return;
|
|
@@ -29096,10 +29178,13 @@
|
|
|
29096
29178
|
vue.onMounted(() => {
|
|
29097
29179
|
Resize.on(options.wrapper.value, handleResize);
|
|
29098
29180
|
options.scrollToActive && vue.nextTick(options.scrollToActive);
|
|
29181
|
+
affix?.onScroll?.(handleAffixScroll);
|
|
29099
29182
|
});
|
|
29100
29183
|
vue.onBeforeUnmount(() => {
|
|
29101
29184
|
Resize.off(options.wrapper.value, handleResize);
|
|
29102
29185
|
timer.value && clearTimeout(timer.value);
|
|
29186
|
+
affix?.offScroll?.(handleAffixScroll);
|
|
29187
|
+
scrollToAnchorTimer && clearTimeout(scrollToAnchorTimer);
|
|
29103
29188
|
});
|
|
29104
29189
|
const add = (item, setValue) => {
|
|
29105
29190
|
if (!item) return;
|