@deot/vc-components 1.0.2 → 1.0.4

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.js CHANGED
@@ -1,5 +1,6 @@
1
- import { reactive, defineComponent, createVNode, ref, watch, getCurrentInstance, computed, TransitionGroup, Transition as Transition$1, h, inject, onMounted, provide, onBeforeUnmount, toRaw, withDirectives, vShow, onUnmounted, withModifiers, createApp, Fragment as Fragment$1, Teleport, nextTick, mergeProps, shallowRef, onUpdated, isVNode, createTextVNode } from 'vue';
2
- import { debounce, cloneDeep, pick, throttle, kebabCase } from 'lodash-es';
1
+ import { reactive, defineComponent, createVNode, ref, watch, getCurrentInstance, computed, TransitionGroup, Transition as Transition$1, h, inject, onMounted, provide, shallowRef, onUnmounted, onBeforeUnmount, toRaw, withDirectives, vShow, withModifiers, createApp, Fragment as Fragment$1, Teleport, createTextVNode, mergeProps, nextTick, onUpdated, isVNode, onBeforeMount } from 'vue';
2
+ import { debounce, cloneDeep, throttle, pick, kebabCase } from 'lodash-es';
3
+ import { Resize } from '@deot/helper-resize';
3
4
  import * as Utils from '@deot/helper-utils';
4
5
  import { getPropByPath, getUid, raf, throttle as throttle$1 } from '@deot/helper-utils';
5
6
  import { Validator } from '@deot/helper-validator';
@@ -7,7 +8,7 @@ import { Utils as Utils$1, IS_SERVER as IS_SERVER$1 } from '@deot/vc-shared';
7
8
  import * as $ from '@deot/helper-dom';
8
9
  import { composedPath } from '@deot/helper-dom';
9
10
  import { useAttrs, useScrollbar, getInstance } from '@deot/vc-hooks';
10
- import { Resize } from '@deot/helper-resize';
11
+ import { Storage } from '@deot/helper-cache';
11
12
  import { Interrupter } from '@deot/helper-scheduler';
12
13
  import { Wheel } from '@deot/helper-wheel';
13
14
  import * as Load from '@deot/helper-load';
@@ -56,7 +57,7 @@ class Instance {
56
57
  }
57
58
  const VcInstance = new Instance();
58
59
 
59
- const props$1g = {
60
+ const props$1h = {
60
61
  tag: {
61
62
  type: String,
62
63
  default: "div"
@@ -65,10 +66,10 @@ const props$1g = {
65
66
 
66
67
  /** @jsxImportSource vue */
67
68
 
68
- const COMPONENT_NAME$1w = 'vc-action-sheet';
69
+ const COMPONENT_NAME$1x = 'vc-action-sheet';
69
70
  const ActionSheet = /* @__PURE__ */ defineComponent({
70
- name: COMPONENT_NAME$1w,
71
- props: props$1g,
71
+ name: COMPONENT_NAME$1x,
72
+ props: props$1h,
72
73
  setup(props, {
73
74
  slots
74
75
  }) {
@@ -82,7 +83,7 @@ const ActionSheet = /* @__PURE__ */ defineComponent({
82
83
 
83
84
  const MActionSheet = ActionSheet;
84
85
 
85
- const props$1f = {
86
+ const props$1g = {
86
87
  modelValue: {
87
88
  type: Boolean,
88
89
  default: true
@@ -109,7 +110,7 @@ const props$1f = {
109
110
  }
110
111
  };
111
112
 
112
- const props$1e = {
113
+ const props$1f = {
113
114
  type: String,
114
115
  inherit: {
115
116
  type: Boolean,
@@ -254,10 +255,10 @@ const IconManager = new Manager();
254
255
 
255
256
  /** @jsxImportSource vue */
256
257
 
257
- const COMPONENT_NAME$1v = 'vc-icon';
258
+ const COMPONENT_NAME$1w = 'vc-icon';
258
259
  const Icon = /* @__PURE__ */ defineComponent({
259
- name: COMPONENT_NAME$1v,
260
- props: props$1e,
260
+ name: COMPONENT_NAME$1w,
261
+ props: props$1f,
261
262
  setup(props) {
262
263
  const viewBox = ref('0 0 1024 1024');
263
264
  const path = ref([]);
@@ -290,7 +291,7 @@ const Icon = /* @__PURE__ */ defineComponent({
290
291
  }
291
292
  });
292
293
 
293
- const props$1d = {
294
+ const props$1e = {
294
295
  /**
295
296
  * 进入/离开持续时间
296
297
  * {enter: 300, leave: 300}
@@ -455,10 +456,10 @@ const useTransition = () => {
455
456
  };
456
457
  };
457
458
 
458
- const COMPONENT_NAME$1u = "vc-transition";
459
+ const COMPONENT_NAME$1v = "vc-transition";
459
460
  const Transition = defineComponent({
460
- name: COMPONENT_NAME$1u,
461
- props: props$1d,
461
+ name: COMPONENT_NAME$1v,
462
+ props: props$1e,
462
463
  // 当不声明emits的情况下,事件存在于attrs中
463
464
  inheritAttrs: false,
464
465
  setup(props, { slots, attrs }) {
@@ -478,10 +479,10 @@ const Transition = defineComponent({
478
479
  }
479
480
  });
480
481
 
481
- const COMPONENT_NAME$1t = "vc-transition-collapse";
482
+ const COMPONENT_NAME$1u = "vc-transition-collapse";
482
483
  const TransitionCollapse = defineComponent({
483
- name: COMPONENT_NAME$1t,
484
- props: props$1d,
484
+ name: COMPONENT_NAME$1u,
485
+ props: props$1e,
485
486
  // 当不声明emits的情况下,事件存在于attrs中
486
487
  inheritAttrs: false,
487
488
  setup(props, { slots, attrs: _attrs }) {
@@ -599,11 +600,11 @@ const TransitionCollapse = defineComponent({
599
600
  }
600
601
  });
601
602
 
602
- const COMPONENT_NAME$1s = "vc-transition-fade";
603
+ const COMPONENT_NAME$1t = "vc-transition-fade";
603
604
  const TransitionFade = defineComponent({
604
- name: COMPONENT_NAME$1s,
605
+ name: COMPONENT_NAME$1t,
605
606
  props: {
606
- ...props$1d,
607
+ ...props$1e,
607
608
  // inheritAttrs必须是false
608
609
  style: {
609
610
  type: Object,
@@ -636,11 +637,11 @@ const TransitionFade = defineComponent({
636
637
  }
637
638
  });
638
639
 
639
- const COMPONENT_NAME$1r = "vc-transition-scale";
640
+ const COMPONENT_NAME$1s = "vc-transition-scale";
640
641
  const TransitionScale = defineComponent({
641
- name: COMPONENT_NAME$1r,
642
+ name: COMPONENT_NAME$1s,
642
643
  props: {
643
- ...props$1d,
644
+ ...props$1e,
644
645
  mode: {
645
646
  type: String,
646
647
  default: "both",
@@ -678,11 +679,11 @@ const TransitionScale = defineComponent({
678
679
  }
679
680
  });
680
681
 
681
- const COMPONENT_NAME$1q = "vc-transition-slide";
682
+ const COMPONENT_NAME$1r = "vc-transition-slide";
682
683
  const TransitionSlide = defineComponent({
683
- name: COMPONENT_NAME$1q,
684
+ name: COMPONENT_NAME$1r,
684
685
  props: {
685
- ...props$1d,
686
+ ...props$1e,
686
687
  mode: {
687
688
  type: String,
688
689
  default: "left",
@@ -720,11 +721,11 @@ const TransitionSlide = defineComponent({
720
721
  }
721
722
  });
722
723
 
723
- const COMPONENT_NAME$1p = "vc-transition-zoom";
724
+ const COMPONENT_NAME$1q = "vc-transition-zoom";
724
725
  const TransitionZoom = defineComponent({
725
- name: COMPONENT_NAME$1p,
726
+ name: COMPONENT_NAME$1q,
726
727
  props: {
727
- ...props$1d,
728
+ ...props$1e,
728
729
  mode: {
729
730
  type: String,
730
731
  default: "x",
@@ -764,7 +765,7 @@ const TransitionZoom = defineComponent({
764
765
 
765
766
  /** @jsxImportSource vue */
766
767
 
767
- const COMPONENT_NAME$1o = 'vc-alert';
768
+ const COMPONENT_NAME$1p = 'vc-alert';
768
769
 
769
770
  // [color, borderColor, backgroundColor], -> CSS
770
771
  const THEME_MAP = {
@@ -774,8 +775,8 @@ const THEME_MAP = {
774
775
  warning: ['#ffbf00', '#ffe58f', '#fffbe6']
775
776
  };
776
777
  const Alert = /* @__PURE__ */ defineComponent({
777
- name: COMPONENT_NAME$1o,
778
- props: props$1f,
778
+ name: COMPONENT_NAME$1p,
779
+ props: props$1g,
779
780
  setup(props, {
780
781
  slots,
781
782
  emit
@@ -864,7 +865,7 @@ const Alert = /* @__PURE__ */ defineComponent({
864
865
 
865
866
  const MAlert = Alert;
866
867
 
867
- const props$1c = {
868
+ const props$1d = {
868
869
  tag: {
869
870
  type: String,
870
871
  default: "div"
@@ -873,10 +874,10 @@ const props$1c = {
873
874
 
874
875
  /** @jsxImportSource vue */
875
876
 
876
- const COMPONENT_NAME$1n = 'vc-artboard';
877
+ const COMPONENT_NAME$1o = 'vc-artboard';
877
878
  const Artboard = /* @__PURE__ */ defineComponent({
878
- name: COMPONENT_NAME$1n,
879
- props: props$1c,
879
+ name: COMPONENT_NAME$1o,
880
+ props: props$1d,
880
881
  setup(props, {
881
882
  slots
882
883
  }) {
@@ -890,7 +891,7 @@ const Artboard = /* @__PURE__ */ defineComponent({
890
891
 
891
892
  const MArtboard = Artboard;
892
893
 
893
- const props$1b = {
894
+ const props$1c = {
894
895
  size: {
895
896
  type: Number,
896
897
  default: 28
@@ -914,10 +915,10 @@ const props$1b = {
914
915
 
915
916
  /** @jsxImportSource vue */
916
917
 
917
- const COMPONENT_NAME$1m = 'vc-spin';
918
+ const COMPONENT_NAME$1n = 'vc-spin';
918
919
  const Spin = /* @__PURE__ */ defineComponent({
919
- name: COMPONENT_NAME$1m,
920
- props: props$1b,
920
+ name: COMPONENT_NAME$1n,
921
+ props: props$1c,
921
922
  setup(props, {
922
923
  slots
923
924
  }) {
@@ -951,7 +952,7 @@ const Spin = /* @__PURE__ */ defineComponent({
951
952
  }
952
953
  });
953
954
 
954
- const props$1a = {
955
+ const props$1b = {
955
956
  wait: {
956
957
  type: Number,
957
958
  default: 250
@@ -967,10 +968,10 @@ const props$1a = {
967
968
  exclude: RegExp
968
969
  };
969
970
 
970
- const COMPONENT_NAME$1l = "vc-debounce";
971
+ const COMPONENT_NAME$1m = "vc-debounce";
971
972
  const Debounce = defineComponent({
972
- name: COMPONENT_NAME$1l,
973
- props: props$1a,
973
+ name: COMPONENT_NAME$1m,
974
+ props: props$1b,
974
975
  /**
975
976
  * 不声明emits使得事件被透传放入attrs中, 这样可以让所有的事件透传
976
977
  * 如事件onClick
@@ -1011,7 +1012,7 @@ const Debounce = defineComponent({
1011
1012
  }
1012
1013
  });
1013
1014
 
1014
- const props$19 = {
1015
+ const props$1a = {
1015
1016
  tag: {
1016
1017
  type: String,
1017
1018
  default: "button"
@@ -1041,11 +1042,11 @@ const props$19 = {
1041
1042
 
1042
1043
  /** @jsxImportSource vue */
1043
1044
 
1044
- const COMPONENT_NAME$1k = 'vc-button';
1045
+ const COMPONENT_NAME$1l = 'vc-button';
1045
1046
  const Button = /* @__PURE__ */ defineComponent({
1046
- name: COMPONENT_NAME$1k,
1047
+ name: COMPONENT_NAME$1l,
1047
1048
  emits: ['click'],
1048
- props: props$19,
1049
+ props: props$1a,
1049
1050
  setup(props, {
1050
1051
  slots
1051
1052
  }) {
@@ -1102,7 +1103,7 @@ const Button = /* @__PURE__ */ defineComponent({
1102
1103
  }
1103
1104
  });
1104
1105
 
1105
- const props$18 = {
1106
+ const props$19 = {
1106
1107
  vertical: {
1107
1108
  type: Boolean,
1108
1109
  default: false
@@ -1123,10 +1124,10 @@ const props$18 = {
1123
1124
 
1124
1125
  /** @jsxImportSource vue */
1125
1126
 
1126
- const COMPONENT_NAME$1j = 'vc-button-group';
1127
+ const COMPONENT_NAME$1k = 'vc-button-group';
1127
1128
  const ButtonGroup = /* @__PURE__ */ defineComponent({
1128
- name: COMPONENT_NAME$1j,
1129
- props: props$18,
1129
+ name: COMPONENT_NAME$1k,
1130
+ props: props$19,
1130
1131
  setup(props, {
1131
1132
  slots
1132
1133
  }) {
@@ -1150,7 +1151,7 @@ const ButtonGroup = /* @__PURE__ */ defineComponent({
1150
1151
  const MButton = Button;
1151
1152
  const MButtonGroup = ButtonGroup;
1152
1153
 
1153
- const props$17 = {
1154
+ const props$18 = {
1154
1155
  tag: {
1155
1156
  type: String,
1156
1157
  default: "div"
@@ -1159,10 +1160,10 @@ const props$17 = {
1159
1160
 
1160
1161
  /** @jsxImportSource vue */
1161
1162
 
1162
- const COMPONENT_NAME$1i = 'vc-calendar';
1163
+ const COMPONENT_NAME$1j = 'vc-calendar';
1163
1164
  const Calendar = /* @__PURE__ */ defineComponent({
1164
- name: COMPONENT_NAME$1i,
1165
- props: props$17,
1165
+ name: COMPONENT_NAME$1j,
1166
+ props: props$18,
1166
1167
  setup(props, {
1167
1168
  slots
1168
1169
  }) {
@@ -1176,7 +1177,7 @@ const Calendar = /* @__PURE__ */ defineComponent({
1176
1177
 
1177
1178
  const MCalendar = Calendar;
1178
1179
 
1179
- const props$16 = {
1180
+ const props$17 = {
1180
1181
  border: {
1181
1182
  type: Boolean,
1182
1183
  default: true
@@ -1199,10 +1200,10 @@ const props$16 = {
1199
1200
 
1200
1201
  /** @jsxImportSource vue */
1201
1202
 
1202
- const COMPONENT_NAME$1h = 'vc-card';
1203
+ const COMPONENT_NAME$1i = 'vc-card';
1203
1204
  const Card = /* @__PURE__ */ defineComponent({
1204
- name: COMPONENT_NAME$1h,
1205
- props: props$16,
1205
+ name: COMPONENT_NAME$1i,
1206
+ props: props$17,
1206
1207
  setup(props, {
1207
1208
  slots
1208
1209
  }) {
@@ -1228,7 +1229,7 @@ const Card = /* @__PURE__ */ defineComponent({
1228
1229
 
1229
1230
  const MCard = Card;
1230
1231
 
1231
- const props$15 = {
1232
+ const props$16 = {
1232
1233
  tag: {
1233
1234
  type: String,
1234
1235
  default: "div"
@@ -1237,10 +1238,10 @@ const props$15 = {
1237
1238
 
1238
1239
  /** @jsxImportSource vue */
1239
1240
 
1240
- const COMPONENT_NAME$1g = 'vc-carousel';
1241
+ const COMPONENT_NAME$1h = 'vc-carousel';
1241
1242
  const Carousel = /* @__PURE__ */ defineComponent({
1242
- name: COMPONENT_NAME$1g,
1243
- props: props$15,
1243
+ name: COMPONENT_NAME$1h,
1244
+ props: props$16,
1244
1245
  setup(props, {
1245
1246
  slots
1246
1247
  }) {
@@ -1254,7 +1255,7 @@ const Carousel = /* @__PURE__ */ defineComponent({
1254
1255
 
1255
1256
  const MCarousel = Carousel;
1256
1257
 
1257
- const props$14 = {
1258
+ const props$15 = {
1258
1259
  tag: {
1259
1260
  type: String,
1260
1261
  default: "div"
@@ -1263,10 +1264,10 @@ const props$14 = {
1263
1264
 
1264
1265
  /** @jsxImportSource vue */
1265
1266
 
1266
- const COMPONENT_NAME$1f = 'vc-cascader';
1267
+ const COMPONENT_NAME$1g = 'vc-cascader';
1267
1268
  const Cascader = /* @__PURE__ */ defineComponent({
1268
- name: COMPONENT_NAME$1f,
1269
- props: props$14,
1269
+ name: COMPONENT_NAME$1g,
1270
+ props: props$15,
1270
1271
  setup(props, {
1271
1272
  slots
1272
1273
  }) {
@@ -1280,25 +1281,167 @@ const Cascader = /* @__PURE__ */ defineComponent({
1280
1281
 
1281
1282
  const MCascader = Cascader;
1282
1283
 
1283
- const props$13 = {
1284
- tag: {
1285
- type: String,
1286
- default: "div"
1287
- }
1284
+ const EVENTS = [
1285
+ "legendselectchanged",
1286
+ "legendselected",
1287
+ "legendunselected",
1288
+ "legendunscroll",
1289
+ "datazoom",
1290
+ "datarangeselected",
1291
+ "timelinechanged",
1292
+ "timelineplaychanged",
1293
+ "restore",
1294
+ "dataviewchanged",
1295
+ "magictypechanged",
1296
+ "geoselectchanged",
1297
+ "geoselected",
1298
+ "geounselected",
1299
+ "pieselectchanged",
1300
+ "pieselected",
1301
+ "pieunselected",
1302
+ "mapselectchanged",
1303
+ "mapselected",
1304
+ "mapunselected",
1305
+ "axisareaselected",
1306
+ "focusnodeadjacency",
1307
+ "unfocusnodeadjacency",
1308
+ "brush",
1309
+ "brushselected",
1310
+ "rendered",
1311
+ "finished",
1312
+ "click",
1313
+ "dblclick",
1314
+ "mouseover",
1315
+ "mouseout",
1316
+ "mousemove",
1317
+ "mousedown",
1318
+ "mouseup",
1319
+ "globalout",
1320
+ "contextmenu"
1321
+ ];
1322
+
1323
+ const props$14 = {
1324
+ options: Object,
1325
+ pluginOptions: Object,
1326
+ theme: [String, Object],
1327
+ group: String,
1328
+ autoResize: Boolean,
1329
+ watchShallow: Boolean,
1330
+ manualUpdate: Boolean
1288
1331
  };
1289
1332
 
1290
1333
  /** @jsxImportSource vue */
1291
1334
 
1292
- const COMPONENT_NAME$1e = 'vc-chart';
1335
+ const COMPONENT_NAME$1f = 'vc-chart';
1293
1336
  const Chart = /* @__PURE__ */ defineComponent({
1294
- name: COMPONENT_NAME$1e,
1295
- props: props$13,
1337
+ name: COMPONENT_NAME$1f,
1338
+ props: props$14,
1339
+ emits: [...EVENTS, 'ready'],
1296
1340
  setup(props, {
1341
+ emit,
1297
1342
  slots
1298
1343
  }) {
1344
+ const instance = getCurrentInstance();
1345
+ const chart = shallowRef(null);
1346
+ const echartsInstance = shallowRef(null);
1347
+ const manualOptions = shallowRef(null);
1348
+ let resizeHandler;
1349
+ let lastArea = 0;
1350
+ const getArea = () => {
1351
+ const el = instance.vnode.el;
1352
+ return el.offsetWidth * el.offsetHeight;
1353
+ };
1354
+ const mergeOptions = (options, notMerge, lazyUpdate) => {
1355
+ if (props.manualUpdate) {
1356
+ manualOptions.value = options;
1357
+ }
1358
+ if (!chart.value) return;
1359
+ chart.value.setOption(options, notMerge, lazyUpdate);
1360
+ };
1361
+ const init = () => {
1362
+ if (chart.value || !echartsInstance.value) {
1363
+ return;
1364
+ }
1365
+ chart.value = echartsInstance.value.init(instance.vnode.el, props.theme, props.pluginOptions);
1366
+ if (props.group) {
1367
+ chart.value.group = props.group;
1368
+ }
1369
+ chart.value.setOption(manualOptions.value || props.options || {}, true);
1370
+
1371
+ // expose ECharts events as custom events
1372
+ EVENTS.forEach(event => {
1373
+ chart.value.on(event, params => {
1374
+ emit(event, params);
1375
+ });
1376
+ });
1377
+ if (props.autoResize) {
1378
+ lastArea = getArea();
1379
+ resizeHandler && Resize.off(instance.vnode.el, resizeHandler);
1380
+ resizeHandler = debounce(() => {
1381
+ if (lastArea === 0) {
1382
+ // emulate initial render for initially hidden charts
1383
+ mergeOptions({}, true);
1384
+ chart.value.resize();
1385
+ mergeOptions(props.options || manualOptions.value || {}, true);
1386
+ } else {
1387
+ chart.value.resize();
1388
+ }
1389
+ lastArea = getArea();
1390
+ }, 100, {
1391
+ leading: true
1392
+ });
1393
+ Resize.on(instance.vnode.el, resizeHandler);
1394
+ }
1395
+ };
1396
+ const destroy = () => {
1397
+ if (!chart.value) return;
1398
+ if (props.autoResize) {
1399
+ resizeHandler && Resize.off(instance.vnode.el, resizeHandler);
1400
+ resizeHandler = null;
1401
+ }
1402
+ chart.value.dispose();
1403
+ chart.value = null;
1404
+ };
1405
+ const refresh = () => {
1406
+ if (!chart.value) return;
1407
+ destroy();
1408
+ init();
1409
+ };
1410
+ watch(() => props.group, v => {
1411
+ chart.value && (chart.value.group = v);
1412
+ });
1413
+ if (!props.manualUpdate) {
1414
+ watch(() => props.options, (val, oldVal) => {
1415
+ if (!chart.value && val) {
1416
+ init();
1417
+ } else {
1418
+ chart.value.setOption(val, val !== oldVal);
1419
+ }
1420
+ }, {
1421
+ deep: !props.watchShallow
1422
+ });
1423
+ }
1424
+ const watched = ['theme', 'pluginOptions', 'autoResize', 'manualUpdate', 'watchShallow'];
1425
+ watched.forEach(prop => watch(() => props[prop], refresh, {
1426
+ deep: true
1427
+ }));
1428
+ onMounted(async () => {
1429
+ const echarts = window.echarts || (await import('echarts'));
1430
+ // 兼容webpack 3.0/4.0 写法
1431
+ echartsInstance.value = echarts.default ? echarts.default : echarts;
1432
+ props.options && init();
1433
+ emit('ready', {
1434
+ instance: chart.value,
1435
+ dependencies: {
1436
+ echarts: echartsInstance.value
1437
+ }
1438
+ });
1439
+ });
1440
+ onUnmounted(destroy);
1299
1441
  return () => {
1300
1442
  return createVNode("div", {
1301
- "class": "vc-chart"
1443
+ "class": "vc-chart",
1444
+ "style": "width: 100%; height: 100%"
1302
1445
  }, [slots?.default?.()]);
1303
1446
  };
1304
1447
  }
@@ -1306,7 +1449,7 @@ const Chart = /* @__PURE__ */ defineComponent({
1306
1449
 
1307
1450
  const MChart = Chart;
1308
1451
 
1309
- const props$12 = {
1452
+ const props$13 = {
1310
1453
  tag: {
1311
1454
  type: String,
1312
1455
  default: "div"
@@ -1315,10 +1458,10 @@ const props$12 = {
1315
1458
 
1316
1459
  /** @jsxImportSource vue */
1317
1460
 
1318
- const COMPONENT_NAME$1d = 'vc-checkbox';
1461
+ const COMPONENT_NAME$1e = 'vc-checkbox';
1319
1462
  const Checkbox = /* @__PURE__ */ defineComponent({
1320
- name: COMPONENT_NAME$1d,
1321
- props: props$12,
1463
+ name: COMPONENT_NAME$1e,
1464
+ props: props$13,
1322
1465
  setup(props, {
1323
1466
  slots
1324
1467
  }) {
@@ -1332,7 +1475,7 @@ const Checkbox = /* @__PURE__ */ defineComponent({
1332
1475
 
1333
1476
  const MCheckbox = Checkbox;
1334
1477
 
1335
- const props$11 = {
1478
+ const props$12 = {
1336
1479
  tag: {
1337
1480
  type: String,
1338
1481
  default: "div"
@@ -1341,10 +1484,10 @@ const props$11 = {
1341
1484
 
1342
1485
  /** @jsxImportSource vue */
1343
1486
 
1344
- const COMPONENT_NAME$1c = 'vc-clipboard';
1487
+ const COMPONENT_NAME$1d = 'vc-clipboard';
1345
1488
  const Clipboard = /* @__PURE__ */ defineComponent({
1346
- name: COMPONENT_NAME$1c,
1347
- props: props$11,
1489
+ name: COMPONENT_NAME$1d,
1490
+ props: props$12,
1348
1491
  setup(props, {
1349
1492
  slots
1350
1493
  }) {
@@ -1358,7 +1501,7 @@ const Clipboard = /* @__PURE__ */ defineComponent({
1358
1501
 
1359
1502
  const MClipboard = Clipboard;
1360
1503
 
1361
- const props$10 = {
1504
+ const props$11 = {
1362
1505
  tag: {
1363
1506
  type: String,
1364
1507
  default: "div"
@@ -1367,10 +1510,10 @@ const props$10 = {
1367
1510
 
1368
1511
  /** @jsxImportSource vue */
1369
1512
 
1370
- const COMPONENT_NAME$1b = 'vc-collapse';
1513
+ const COMPONENT_NAME$1c = 'vc-collapse';
1371
1514
  const Collapse = /* @__PURE__ */ defineComponent({
1372
- name: COMPONENT_NAME$1b,
1373
- props: props$10,
1515
+ name: COMPONENT_NAME$1c,
1516
+ props: props$11,
1374
1517
  setup(props, {
1375
1518
  slots
1376
1519
  }) {
@@ -1384,7 +1527,7 @@ const Collapse = /* @__PURE__ */ defineComponent({
1384
1527
 
1385
1528
  const MCollapse = Collapse;
1386
1529
 
1387
- const props$$ = {
1530
+ const props$10 = {
1388
1531
  tag: {
1389
1532
  type: String,
1390
1533
  default: "div"
@@ -1393,10 +1536,10 @@ const props$$ = {
1393
1536
 
1394
1537
  /** @jsxImportSource vue */
1395
1538
 
1396
- const COMPONENT_NAME$1a = 'vc-color-picker';
1539
+ const COMPONENT_NAME$1b = 'vc-color-picker';
1397
1540
  const ColorPicker = /* @__PURE__ */ defineComponent({
1398
- name: COMPONENT_NAME$1a,
1399
- props: props$$,
1541
+ name: COMPONENT_NAME$1b,
1542
+ props: props$10,
1400
1543
  setup(props, {
1401
1544
  slots
1402
1545
  }) {
@@ -1410,7 +1553,7 @@ const ColorPicker = /* @__PURE__ */ defineComponent({
1410
1553
 
1411
1554
  const MColorPicker = ColorPicker;
1412
1555
 
1413
- const props$_ = {
1556
+ const props$$ = {
1414
1557
  tag: {
1415
1558
  type: String,
1416
1559
  default: "div"
@@ -1419,10 +1562,10 @@ const props$_ = {
1419
1562
 
1420
1563
  /** @jsxImportSource vue */
1421
1564
 
1422
- const COMPONENT_NAME$19 = 'vc-countdown';
1565
+ const COMPONENT_NAME$1a = 'vc-countdown';
1423
1566
  const Countdown = /* @__PURE__ */ defineComponent({
1424
- name: COMPONENT_NAME$19,
1425
- props: props$_,
1567
+ name: COMPONENT_NAME$1a,
1568
+ props: props$$,
1426
1569
  setup(props, {
1427
1570
  slots
1428
1571
  }) {
@@ -1436,17 +1579,17 @@ const Countdown = /* @__PURE__ */ defineComponent({
1436
1579
 
1437
1580
  const MCountdown = Countdown;
1438
1581
 
1439
- const props$Z = {
1582
+ const props$_ = {
1440
1583
  render: {
1441
1584
  type: Function,
1442
1585
  default: () => null
1443
1586
  }
1444
1587
  };
1445
1588
 
1446
- const COMPONENT_NAME$18 = "vc-customer";
1589
+ const COMPONENT_NAME$19 = "vc-customer";
1447
1590
  const Customer = defineComponent({
1448
- name: COMPONENT_NAME$18,
1449
- props: props$Z,
1591
+ name: COMPONENT_NAME$19,
1592
+ props: props$_,
1450
1593
  setup(props, context) {
1451
1594
  return () => h(() => {
1452
1595
  return props.render(context.attrs, context);
@@ -1456,7 +1599,7 @@ const Customer = defineComponent({
1456
1599
 
1457
1600
  const MCustomer = Customer;
1458
1601
 
1459
- const props$Y = {
1602
+ const props$Z = {
1460
1603
  tag: {
1461
1604
  type: String,
1462
1605
  default: "div"
@@ -1465,10 +1608,10 @@ const props$Y = {
1465
1608
 
1466
1609
  /** @jsxImportSource vue */
1467
1610
 
1468
- const COMPONENT_NAME$17 = 'vc-date-picker';
1611
+ const COMPONENT_NAME$18 = 'vc-date-picker';
1469
1612
  const DatePicker = /* @__PURE__ */ defineComponent({
1470
- name: COMPONENT_NAME$17,
1471
- props: props$Y,
1613
+ name: COMPONENT_NAME$18,
1614
+ props: props$Z,
1472
1615
  setup(props, {
1473
1616
  slots
1474
1617
  }) {
@@ -1482,7 +1625,7 @@ const DatePicker = /* @__PURE__ */ defineComponent({
1482
1625
 
1483
1626
  const MDatePicker = DatePicker;
1484
1627
 
1485
- const props$X = {
1628
+ const props$Y = {
1486
1629
  tag: {
1487
1630
  type: String,
1488
1631
  default: "div"
@@ -1491,10 +1634,10 @@ const props$X = {
1491
1634
 
1492
1635
  /** @jsxImportSource vue */
1493
1636
 
1494
- const COMPONENT_NAME$16 = 'vc-divider';
1637
+ const COMPONENT_NAME$17 = 'vc-divider';
1495
1638
  const Divider = /* @__PURE__ */ defineComponent({
1496
- name: COMPONENT_NAME$16,
1497
- props: props$X,
1639
+ name: COMPONENT_NAME$17,
1640
+ props: props$Y,
1498
1641
  setup(props, {
1499
1642
  slots
1500
1643
  }) {
@@ -1508,7 +1651,7 @@ const Divider = /* @__PURE__ */ defineComponent({
1508
1651
 
1509
1652
  const MDivider = Divider;
1510
1653
 
1511
- const props$W = {
1654
+ const props$X = {
1512
1655
  tag: {
1513
1656
  type: String,
1514
1657
  default: "div"
@@ -1517,10 +1660,10 @@ const props$W = {
1517
1660
 
1518
1661
  /** @jsxImportSource vue */
1519
1662
 
1520
- const COMPONENT_NAME$15 = 'vc-drawer';
1663
+ const COMPONENT_NAME$16 = 'vc-drawer';
1521
1664
  const Drawer = /* @__PURE__ */ defineComponent({
1522
- name: COMPONENT_NAME$15,
1523
- props: props$W,
1665
+ name: COMPONENT_NAME$16,
1666
+ props: props$X,
1524
1667
  setup(props, {
1525
1668
  slots
1526
1669
  }) {
@@ -1534,7 +1677,7 @@ const Drawer = /* @__PURE__ */ defineComponent({
1534
1677
 
1535
1678
  const MDrawer = Drawer;
1536
1679
 
1537
- const props$V = {
1680
+ const props$W = {
1538
1681
  tag: {
1539
1682
  type: String,
1540
1683
  default: "div"
@@ -1543,10 +1686,10 @@ const props$V = {
1543
1686
 
1544
1687
  /** @jsxImportSource vue */
1545
1688
 
1546
- const COMPONENT_NAME$14 = 'vc-dropdown';
1689
+ const COMPONENT_NAME$15 = 'vc-dropdown';
1547
1690
  const Dropdown = /* @__PURE__ */ defineComponent({
1548
- name: COMPONENT_NAME$14,
1549
- props: props$V,
1691
+ name: COMPONENT_NAME$15,
1692
+ props: props$W,
1550
1693
  setup(props, {
1551
1694
  slots
1552
1695
  }) {
@@ -1560,7 +1703,7 @@ const Dropdown = /* @__PURE__ */ defineComponent({
1560
1703
 
1561
1704
  const MDropdown = Dropdown;
1562
1705
 
1563
- const props$U = {
1706
+ const props$V = {
1564
1707
  tag: {
1565
1708
  type: String,
1566
1709
  default: "div"
@@ -1569,10 +1712,10 @@ const props$U = {
1569
1712
 
1570
1713
  /** @jsxImportSource vue */
1571
1714
 
1572
- const COMPONENT_NAME$13 = 'vc-editor';
1715
+ const COMPONENT_NAME$14 = 'vc-editor';
1573
1716
  const Editor = /* @__PURE__ */ defineComponent({
1574
- name: COMPONENT_NAME$13,
1575
- props: props$U,
1717
+ name: COMPONENT_NAME$14,
1718
+ props: props$V,
1576
1719
  setup(props, {
1577
1720
  slots
1578
1721
  }) {
@@ -1586,7 +1729,7 @@ const Editor = /* @__PURE__ */ defineComponent({
1586
1729
 
1587
1730
  const MEditor = Editor;
1588
1731
 
1589
- const props$T = {
1732
+ const props$U = {
1590
1733
  tag: {
1591
1734
  type: String,
1592
1735
  default: "div"
@@ -1595,10 +1738,10 @@ const props$T = {
1595
1738
 
1596
1739
  /** @jsxImportSource vue */
1597
1740
 
1598
- const COMPONENT_NAME$12 = 'vc-expand';
1741
+ const COMPONENT_NAME$13 = 'vc-expand';
1599
1742
  const Expand = /* @__PURE__ */ defineComponent({
1600
- name: COMPONENT_NAME$12,
1601
- props: props$T,
1743
+ name: COMPONENT_NAME$13,
1744
+ props: props$U,
1602
1745
  setup(props, {
1603
1746
  slots
1604
1747
  }) {
@@ -1612,7 +1755,7 @@ const Expand = /* @__PURE__ */ defineComponent({
1612
1755
 
1613
1756
  const MExpand = Expand;
1614
1757
 
1615
- const props$S = {
1758
+ const props$T = {
1616
1759
  tag: {
1617
1760
  type: String,
1618
1761
  default: "form"
@@ -1739,10 +1882,10 @@ const useForm = (expose, options = {}) => {
1739
1882
  });
1740
1883
  };
1741
1884
 
1742
- const COMPONENT_NAME$11 = "vc-form";
1885
+ const COMPONENT_NAME$12 = "vc-form";
1743
1886
  const Form = defineComponent({
1744
- name: COMPONENT_NAME$11,
1745
- props: props$S,
1887
+ name: COMPONENT_NAME$12,
1888
+ props: props$T,
1746
1889
  setup(props, { slots, expose }) {
1747
1890
  useForm(expose);
1748
1891
  return () => {
@@ -1758,7 +1901,7 @@ const Form = defineComponent({
1758
1901
  }
1759
1902
  });
1760
1903
 
1761
- const props$R = {
1904
+ const props$S = {
1762
1905
  label: {
1763
1906
  type: String,
1764
1907
  default: ""
@@ -2056,10 +2199,10 @@ const useFormItem = (expose) => {
2056
2199
 
2057
2200
  /** @jsxImportSource vue */
2058
2201
 
2059
- const COMPONENT_NAME$10 = 'vc-form-item';
2202
+ const COMPONENT_NAME$11 = 'vc-form-item';
2060
2203
  const FormItem = /* @__PURE__ */ defineComponent({
2061
- name: COMPONENT_NAME$10,
2062
- props: props$R,
2204
+ name: COMPONENT_NAME$11,
2205
+ props: props$S,
2063
2206
  setup(props, {
2064
2207
  slots,
2065
2208
  expose
@@ -2111,8 +2254,8 @@ const FormItem = /* @__PURE__ */ defineComponent({
2111
2254
  }
2112
2255
  });
2113
2256
 
2114
- const props$Q = {
2115
- ...props$S,
2257
+ const props$R = {
2258
+ ...props$T,
2116
2259
  showToast: {
2117
2260
  type: Boolean,
2118
2261
  default: false
@@ -2123,7 +2266,7 @@ const props$Q = {
2123
2266
  }
2124
2267
  };
2125
2268
 
2126
- const props$P = {
2269
+ const props$Q = {
2127
2270
  content: [String, Function],
2128
2271
  maskClosable: {
2129
2272
  type: Boolean,
@@ -2151,11 +2294,11 @@ const MTransitionZoom = TransitionZoom;
2151
2294
 
2152
2295
  /** @jsxImportSource vue */
2153
2296
 
2154
- const COMPONENT_NAME$$ = 'vcm-toast';
2297
+ const COMPONENT_NAME$10 = 'vcm-toast';
2155
2298
  const MToastView = /* @__PURE__ */ defineComponent({
2156
- name: COMPONENT_NAME$$,
2299
+ name: COMPONENT_NAME$10,
2157
2300
  emits: ['close', 'portal-fulfilled'],
2158
- props: props$P,
2301
+ props: props$Q,
2159
2302
  setup(props, {
2160
2303
  emit,
2161
2304
  expose
@@ -2270,7 +2413,7 @@ class PortalLeaf {
2270
2413
  }
2271
2414
  }
2272
2415
 
2273
- const COMPONENT_NAME$_ = "vc-portal";
2416
+ const COMPONENT_NAME$$ = "vc-portal";
2274
2417
  class Portal {
2275
2418
  /**
2276
2419
  * 清理Portals类型组件
@@ -2322,7 +2465,7 @@ class Portal {
2322
2465
  this.wrapper = wrapper;
2323
2466
  this.globalOptions = {
2324
2467
  ...options,
2325
- name: options?.name || wrapper.name || Utils.getUid(COMPONENT_NAME$_)
2468
+ name: options?.name || wrapper.name || Utils.getUid(COMPONENT_NAME$$)
2326
2469
  };
2327
2470
  }
2328
2471
  popup(propsData, options) {
@@ -2421,7 +2564,7 @@ class Portal {
2421
2564
  ...rest
2422
2565
  } = options;
2423
2566
  let useAllNodes = fragment;
2424
- const name = multiple ? `${name$}__${Utils.getUid(COMPONENT_NAME$_)}` : name$;
2567
+ const name = multiple ? `${name$}__${Utils.getUid(COMPONENT_NAME$$)}` : name$;
2425
2568
  const container = document.createElement(tag);
2426
2569
  const root = typeof el === "object" ? el : document.querySelector(el || "body");
2427
2570
  !alive && Portal.leafs.get(name)?.destroy();
@@ -2455,7 +2598,7 @@ class Portal {
2455
2598
  } else {
2456
2599
  const wrapper = this.wrapper;
2457
2600
  const app = createApp({
2458
- name: COMPONENT_NAME$_,
2601
+ name: COMPONENT_NAME$$,
2459
2602
  parent,
2460
2603
  setup() {
2461
2604
  if (alive) {
@@ -2560,21 +2703,21 @@ class Portal {
2560
2703
  }
2561
2704
  }
2562
2705
 
2563
- const props$O = {
2706
+ const props$P = {
2564
2707
  tag: {
2565
2708
  type: String,
2566
2709
  default: "div"
2567
2710
  }
2568
2711
  };
2569
2712
 
2570
- const COMPONENT_NAME$Z = 'vc-portal-view';
2713
+ const COMPONENT_NAME$_ = 'vc-portal-view';
2571
2714
 
2572
2715
  /**
2573
2716
  * 写法不同,但与vue@2.x 保持一致
2574
2717
  */
2575
2718
  const PortalView = /* @__PURE__ */ defineComponent({
2576
- name: COMPONENT_NAME$Z,
2577
- props: props$O,
2719
+ name: COMPONENT_NAME$_,
2720
+ props: props$P,
2578
2721
  setup(props, {
2579
2722
  slots
2580
2723
  }) {
@@ -2626,10 +2769,10 @@ const MToast$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
2626
2769
  warning: warning$3
2627
2770
  }, Symbol.toStringTag, { value: 'Module' }));
2628
2771
 
2629
- const COMPONENT_NAME$Y = "vcm-form";
2772
+ const COMPONENT_NAME$Z = "vcm-form";
2630
2773
  const MForm = defineComponent({
2631
- name: COMPONENT_NAME$Y,
2632
- props: props$Q,
2774
+ name: COMPONENT_NAME$Z,
2775
+ props: props$R,
2633
2776
  setup(props, { slots, expose }) {
2634
2777
  useForm(expose, {
2635
2778
  throwToast(message) {
@@ -2649,8 +2792,8 @@ const MForm = defineComponent({
2649
2792
  }
2650
2793
  });
2651
2794
 
2652
- const props$N = {
2653
- ...props$R,
2795
+ const props$O = {
2796
+ ...props$S,
2654
2797
  indent: {
2655
2798
  type: Number,
2656
2799
  default: 12
@@ -2659,10 +2802,10 @@ const props$N = {
2659
2802
 
2660
2803
  /** @jsxImportSource vue */
2661
2804
 
2662
- const COMPONENT_NAME$X = 'vcm-form-item';
2805
+ const COMPONENT_NAME$Y = 'vcm-form-item';
2663
2806
  const MFormItem = /* @__PURE__ */ defineComponent({
2664
- name: COMPONENT_NAME$X,
2665
- props: props$N,
2807
+ name: COMPONENT_NAME$Y,
2808
+ props: props$O,
2666
2809
  setup(props, {
2667
2810
  slots,
2668
2811
  expose
@@ -2715,9 +2858,9 @@ const MFormItem = /* @__PURE__ */ defineComponent({
2715
2858
  }
2716
2859
  });
2717
2860
 
2718
- const COMPONENT_NAME$W = "vc-fragment";
2861
+ const COMPONENT_NAME$X = "vc-fragment";
2719
2862
  const Fragment = defineComponent({
2720
- name: COMPONENT_NAME$W,
2863
+ name: COMPONENT_NAME$X,
2721
2864
  setup(_, { slots }) {
2722
2865
  return () => h(Fragment$1, slots.default?.());
2723
2866
  }
@@ -2725,7 +2868,7 @@ const Fragment = defineComponent({
2725
2868
 
2726
2869
  const MFragment = Fragment;
2727
2870
 
2728
- const props$M = {
2871
+ const props$N = {
2729
2872
  tag: {
2730
2873
  type: String,
2731
2874
  default: "div"
@@ -2734,10 +2877,10 @@ const props$M = {
2734
2877
 
2735
2878
  /** @jsxImportSource vue */
2736
2879
 
2737
- const COMPONENT_NAME$V = 'vc-html-to-image';
2880
+ const COMPONENT_NAME$W = 'vc-html-to-image';
2738
2881
  const HTMLToImage = /* @__PURE__ */ defineComponent({
2739
- name: COMPONENT_NAME$V,
2740
- props: props$M,
2882
+ name: COMPONENT_NAME$W,
2883
+ props: props$N,
2741
2884
  setup(props, {
2742
2885
  slots
2743
2886
  }) {
@@ -2753,33 +2896,275 @@ const MHTMLToImage = HTMLToImage;
2753
2896
 
2754
2897
  const MIcon = Icon;
2755
2898
 
2756
- const props$L = {
2757
- tag: {
2758
- type: String,
2759
- default: "div"
2760
- }
2899
+ const props$M = {
2900
+ src: String,
2901
+ fit: String,
2902
+ lazy: Boolean,
2903
+ wrapper: [Object, String]
2761
2904
  };
2762
2905
 
2763
- /** @jsxImportSource vue */
2764
-
2765
- const COMPONENT_NAME$U = 'vc-image';
2766
- const Image = /* @__PURE__ */ defineComponent({
2767
- name: COMPONENT_NAME$U,
2768
- props: props$L,
2906
+ class IMGStore {
2907
+ map;
2908
+ constructor() {
2909
+ this.map = Storage.get("@wya/vc-img:", { session: true }) || {};
2910
+ }
2911
+ add(src, opts = {}) {
2912
+ const { originW, originH } = opts;
2913
+ if (this.map[src] && originW && originH) return;
2914
+ this.map[src] = {
2915
+ originW,
2916
+ originH
2917
+ };
2918
+ Storage.set("@wya/vc-img:", this.map, { session: true });
2919
+ }
2920
+ getSize(src, opts = {}) {
2921
+ const { clientW, clientH, style, wrapperW } = opts;
2922
+ if (!this.map[src]) return {};
2923
+ const { originW, originH } = this.map[src];
2924
+ if (style.width && clientW > 1) {
2925
+ return {
2926
+ w: clientW,
2927
+ h: clientW / originW * originH
2928
+ };
2929
+ } else if (style.height && clientH > 1) {
2930
+ return {
2931
+ w: clientH / originH * originW,
2932
+ h: clientH
2933
+ };
2934
+ } else if (wrapperW && !style.height && !style.width) {
2935
+ if (originW <= wrapperW) {
2936
+ return {
2937
+ w: originW,
2938
+ h: originH
2939
+ };
2940
+ } else {
2941
+ return {
2942
+ w: wrapperW / originW * originW,
2943
+ h: wrapperW / originW * originH
2944
+ };
2945
+ }
2946
+ } else {
2947
+ return {
2948
+ w: originW,
2949
+ h: originH
2950
+ };
2951
+ }
2952
+ }
2953
+ }
2954
+ const IMGStore$1 = new IMGStore();
2955
+
2956
+ /** @jsxImportSource vue */
2957
+
2958
+ const COMPONENT_NAME$V = 'vc-image';
2959
+ let isSupportObjectFit = false;
2960
+ window.addEventListener('DOMContentLoaded', () => {
2961
+ isSupportObjectFit = !IS_SERVER$1 && document.documentElement.style.objectFit !== undefined;
2962
+ });
2963
+ const ObjectFit = {
2964
+ NONE: 'none',
2965
+ CONTAIN: 'contain',
2966
+ COVER: 'cover',
2967
+ FILL: 'fill',
2968
+ SCALE_DOWN: 'scale-down'
2969
+ };
2970
+ const Image = /* @__PURE__ */ defineComponent({
2971
+ name: COMPONENT_NAME$V,
2972
+ inheritAttrs: false,
2973
+ props: props$M,
2769
2974
  setup(props, {
2770
- slots
2975
+ slots,
2976
+ emit
2771
2977
  }) {
2978
+ const instance = getCurrentInstance();
2979
+ const its = useAttrs({
2980
+ merge: false,
2981
+ exclude: ['onLoad', 'onError']
2982
+ });
2983
+ const isLoading = ref(true);
2984
+ const isError = ref(false);
2985
+ const isActive = ref(!props.lazy);
2986
+ const isAuto = ref(false);
2987
+ const originW = ref(0);
2988
+ const originH = ref(0);
2989
+ const pStyle = ref({});
2990
+ const scroller = ref(null);
2991
+ const setScroller = () => {
2992
+ const {
2993
+ wrapper
2994
+ } = props;
2995
+ if (typeof wrapper === 'object') {
2996
+ scroller.value = wrapper;
2997
+ } else if (typeof wrapper === 'string') {
2998
+ scroller.value = document.querySelector(wrapper);
2999
+ } else {
3000
+ scroller.value = $.getScroller(instance.vnode.el);
3001
+ }
3002
+ };
3003
+ const initPlaceholder = () => {
3004
+ isAuto.value = instance.vnode.el.clientHeight === 1 || instance.vnode.el.clientWidth === 1;
3005
+
3006
+ // el上是否有width和height
3007
+ const {
3008
+ width,
3009
+ height
3010
+ } = instance.vnode.el.style;
3011
+ if (width && height) return;
3012
+ const {
3013
+ w,
3014
+ h
3015
+ } = IMGStore$1.getSize(props.src, {
3016
+ clientW: instance.vnode.el.clientWidth,
3017
+ clientH: instance.vnode.el.clientHeight,
3018
+ style: {
3019
+ width,
3020
+ height
3021
+ },
3022
+ wrapperW: scroller.value && scroller.value.clientWidth,
3023
+ // TODO
3024
+ wrapperH: scroller.value && scroller.value.clientHeight
3025
+ });
3026
+ if (w && h) {
3027
+ pStyle.value = {
3028
+ width: `${w}px`,
3029
+ height: `${h}px`
3030
+ };
3031
+ }
3032
+ };
3033
+ let handleLazyLoad;
3034
+ const removeLazyLoadListener = () => {
3035
+ if (!scroller.value || !handleLazyLoad) return;
3036
+ scroller.value.removeEventListener('scroll', handleLazyLoad);
3037
+ scroller.value = null;
3038
+ handleLazyLoad = null;
3039
+ };
3040
+ const addLazyLoadListener = () => {
3041
+ if (scroller.value) {
3042
+ handleLazyLoad = throttle(() => {
3043
+ if ($.contains(scroller.value, instance.vnode.el)) {
3044
+ isActive.value = true;
3045
+ removeLazyLoadListener();
3046
+ }
3047
+ }, 200);
3048
+ scroller.value.addEventListener('scroll', handleLazyLoad);
3049
+ handleLazyLoad();
3050
+ }
3051
+ };
3052
+ const handleLoad = (e, img) => {
3053
+ originW.value = img.naturalWidth || img.width;
3054
+ originH.value = img.naturalHeight || img.height;
3055
+ isLoading.value = false;
3056
+ emit('load', e, img, instance);
3057
+ IMGStore$1.add(props.src, {
3058
+ originW: originW.value,
3059
+ originH: originH.value
3060
+ });
3061
+ };
3062
+ const handleError = (e, img) => {
3063
+ isLoading.value = false;
3064
+ isError.value = true;
3065
+ emit('error', e, img, instance);
3066
+ };
3067
+ const loadImage = () => {
3068
+ if (!props.src) return;
3069
+ // reset status
3070
+ isLoading.value = true;
3071
+ isError.value = false;
3072
+ const img = new window.Image();
3073
+ img.onload = e => handleLoad(e, img);
3074
+ img.onerror = e => handleError(e, img);
3075
+
3076
+ // bind html attrs
3077
+ Object.keys(its.value.attrs || {}).forEach(key => img.setAttribute(key, its.value.attrs[key]));
3078
+ img.src = props.src;
3079
+ };
3080
+ const hackFit = fit => {
3081
+ const {
3082
+ clientWidth: elW,
3083
+ clientHeight: elH
3084
+ } = instance.vnode.el;
3085
+ if (!originW.value || !originH.value || !elW || !elH) return {};
3086
+ const vertical = originW.value / originH.value < 1;
3087
+ if (fit === ObjectFit.SCALE_DOWN) {
3088
+ const isSmaller = originW.value < elW && originH.value < elH;
3089
+ fit = isSmaller ? ObjectFit.NONE : ObjectFit.CONTAIN;
3090
+ }
3091
+ switch (fit) {
3092
+ case ObjectFit.NONE:
3093
+ return {
3094
+ width: 'auto',
3095
+ height: 'auto'
3096
+ };
3097
+ case ObjectFit.CONTAIN:
3098
+ return vertical ? {
3099
+ width: 'auto'
3100
+ } : {
3101
+ height: 'auto'
3102
+ };
3103
+ case ObjectFit.COVER:
3104
+ return vertical ? {
3105
+ height: 'auto'
3106
+ } : {
3107
+ width: 'auto'
3108
+ };
3109
+ default:
3110
+ return {};
3111
+ }
3112
+ };
3113
+ const style = computed(() => {
3114
+ if (!props.fit) return;
3115
+ return isSupportObjectFit ? {
3116
+ 'object-fit': props.fit
3117
+ } : hackFit(props.fit);
3118
+ });
3119
+ const alignCenter = computed(() => {
3120
+ return !isSupportObjectFit && props.fit !== ObjectFit.FILL;
3121
+ });
3122
+ watch(() => props.src, v => {
3123
+ if (!v && !isLoading.value) {
3124
+ isLoading.value = true;
3125
+ }
3126
+ isActive.value && loadImage();
3127
+ });
3128
+ watch(() => isActive.value, v => {
3129
+ v && loadImage();
3130
+ });
3131
+ onMounted(() => {
3132
+ setScroller();
3133
+ initPlaceholder();
3134
+ props.lazy ? addLazyLoadListener() : loadImage();
3135
+ });
3136
+ onBeforeUnmount(() => {
3137
+ props.lazy && removeLazyLoadListener();
3138
+ });
2772
3139
  return () => {
2773
3140
  return createVNode("div", {
2774
- "class": "vc-image"
2775
- }, [slots?.default?.()]);
3141
+ "style": its.value.style,
3142
+ "class": [its.value.class, 'vc-image']
3143
+ }, [isLoading.value && (slots.placeholder ? slots.placeholder() : createVNode("div", {
3144
+ "class": [{
3145
+ 'is-auto': isAuto.value
3146
+ }, 'vc-image__placeholder'],
3147
+ "style": pStyle.value
3148
+ }, null)), !isLoading.value && isError.value && (slots.error ? slots.error() : createVNode("div", {
3149
+ "class": "vc-image__error"
3150
+ }, [createTextVNode(" \u52A0\u8F7D\u5931\u8D25")])), !isLoading.value && !isError.value && createVNode("img", mergeProps({
3151
+ "src": props.src,
3152
+ "style": style.value,
3153
+ "class": [{
3154
+ 'is-center': alignCenter
3155
+ }, 'vc-image__inner']
3156
+ }, {
3157
+ // 包含所有on*都会被绑定, 且listeners中覆盖将由listener内触发(inheritAttrs: false)
3158
+ ...its.value.attrs,
3159
+ ...its.value.listeners
3160
+ }), null)]);
2776
3161
  };
2777
3162
  }
2778
3163
  });
2779
3164
 
2780
3165
  const MImage = Image;
2781
3166
 
2782
- const props$K = {
3167
+ const props$L = {
2783
3168
  tag: {
2784
3169
  type: String,
2785
3170
  default: "div"
@@ -2788,10 +3173,10 @@ const props$K = {
2788
3173
 
2789
3174
  /** @jsxImportSource vue */
2790
3175
 
2791
- const COMPONENT_NAME$T = 'vc-image-crop';
3176
+ const COMPONENT_NAME$U = 'vc-image-crop';
2792
3177
  const ImageCrop = /* @__PURE__ */ defineComponent({
2793
- name: COMPONENT_NAME$T,
2794
- props: props$K,
3178
+ name: COMPONENT_NAME$U,
3179
+ props: props$L,
2795
3180
  setup(props, {
2796
3181
  slots
2797
3182
  }) {
@@ -2805,7 +3190,7 @@ const ImageCrop = /* @__PURE__ */ defineComponent({
2805
3190
 
2806
3191
  const MImageCrop = ImageCrop;
2807
3192
 
2808
- const props$J = {
3193
+ const props$K = {
2809
3194
  tag: {
2810
3195
  type: String,
2811
3196
  default: "div"
@@ -2814,10 +3199,10 @@ const props$J = {
2814
3199
 
2815
3200
  /** @jsxImportSource vue */
2816
3201
 
2817
- const COMPONENT_NAME$S = 'vc-image-preview';
3202
+ const COMPONENT_NAME$T = 'vc-image-preview';
2818
3203
  const ImagePreview = /* @__PURE__ */ defineComponent({
2819
- name: COMPONENT_NAME$S,
2820
- props: props$J,
3204
+ name: COMPONENT_NAME$T,
3205
+ props: props$K,
2821
3206
  setup(props, {
2822
3207
  slots
2823
3208
  }) {
@@ -2831,7 +3216,7 @@ const ImagePreview = /* @__PURE__ */ defineComponent({
2831
3216
 
2832
3217
  const MImagePreview = ImagePreview;
2833
3218
 
2834
- const props$I = {
3219
+ const props$J = {
2835
3220
  tag: {
2836
3221
  type: String,
2837
3222
  default: "div"
@@ -2840,10 +3225,10 @@ const props$I = {
2840
3225
 
2841
3226
  /** @jsxImportSource vue */
2842
3227
 
2843
- const COMPONENT_NAME$R = 'vc-image-processing';
3228
+ const COMPONENT_NAME$S = 'vc-image-processing';
2844
3229
  const ImageProcessing = /* @__PURE__ */ defineComponent({
2845
- name: COMPONENT_NAME$R,
2846
- props: props$I,
3230
+ name: COMPONENT_NAME$S,
3231
+ props: props$J,
2847
3232
  setup(props, {
2848
3233
  slots
2849
3234
  }) {
@@ -2857,7 +3242,7 @@ const ImageProcessing = /* @__PURE__ */ defineComponent({
2857
3242
 
2858
3243
  const MImageProcessing = ImageProcessing;
2859
3244
 
2860
- const props$H = {
3245
+ const props$I = {
2861
3246
  // Array, 作为select等数组存放临时值
2862
3247
  modelValue: {
2863
3248
  type: [String, Number, Array],
@@ -3111,12 +3496,12 @@ const useNativeEmitter = (input, expose) => {
3111
3496
 
3112
3497
  /** @jsxImportSource vue */
3113
3498
 
3114
- const COMPONENT_NAME$Q = 'vc-input';
3499
+ const COMPONENT_NAME$R = 'vc-input';
3115
3500
  const Input = /* @__PURE__ */ defineComponent({
3116
- name: COMPONENT_NAME$Q,
3501
+ name: COMPONENT_NAME$R,
3117
3502
  inheritAttrs: false,
3118
3503
  props: {
3119
- ...props$H,
3504
+ ...props$I,
3120
3505
  indicator: {
3121
3506
  type: [Boolean, Object],
3122
3507
  default: false
@@ -3217,8 +3602,8 @@ const Input = /* @__PURE__ */ defineComponent({
3217
3602
  }
3218
3603
  });
3219
3604
 
3220
- const props$G = {
3221
- ...props$H,
3605
+ const props$H = {
3606
+ ...props$I,
3222
3607
  min: {
3223
3608
  type: Number,
3224
3609
  default: 0
@@ -3433,10 +3818,10 @@ const useInputNumber = () => {
3433
3818
 
3434
3819
  /** @jsxImportSource vue */
3435
3820
 
3436
- const COMPONENT_NAME$P = 'vc-input-number';
3821
+ const COMPONENT_NAME$Q = 'vc-input-number';
3437
3822
  const InputNumber = /* @__PURE__ */ defineComponent({
3438
- name: COMPONENT_NAME$P,
3439
- props: props$G,
3823
+ name: COMPONENT_NAME$Q,
3824
+ props: props$H,
3440
3825
  inheritAttrs: false,
3441
3826
  setup(props, {
3442
3827
  slots,
@@ -3487,8 +3872,8 @@ const InputNumber = /* @__PURE__ */ defineComponent({
3487
3872
  }
3488
3873
  });
3489
3874
 
3490
- const props$F = {
3491
- ...props$H,
3875
+ const props$G = {
3876
+ ...props$I,
3492
3877
  enterText: {
3493
3878
  type: [Boolean, String],
3494
3879
  default: true
@@ -3497,10 +3882,10 @@ const props$F = {
3497
3882
 
3498
3883
  /** @jsxImportSource vue */
3499
3884
 
3500
- const COMPONENT_NAME$O = 'vc-input-search';
3885
+ const COMPONENT_NAME$P = 'vc-input-search';
3501
3886
  const InputSearch = /* @__PURE__ */ defineComponent({
3502
- name: COMPONENT_NAME$O,
3503
- props: props$F,
3887
+ name: COMPONENT_NAME$P,
3888
+ props: props$G,
3504
3889
  inheritAttrs: false,
3505
3890
  setup(props, {
3506
3891
  emit,
@@ -3534,12 +3919,12 @@ const InputSearch = /* @__PURE__ */ defineComponent({
3534
3919
 
3535
3920
  /** @jsxImportSource vue */
3536
3921
 
3537
- const COMPONENT_NAME$N = 'vcm-input';
3922
+ const COMPONENT_NAME$O = 'vcm-input';
3538
3923
  const MInput = /* @__PURE__ */ defineComponent({
3539
- name: COMPONENT_NAME$N,
3924
+ name: COMPONENT_NAME$O,
3540
3925
  inheritAttrs: false,
3541
3926
  props: {
3542
- ...props$H,
3927
+ ...props$I,
3543
3928
  right: {
3544
3929
  type: Boolean,
3545
3930
  default: false
@@ -3625,10 +4010,10 @@ const MInput = /* @__PURE__ */ defineComponent({
3625
4010
 
3626
4011
  /** @jsxImportSource vue */
3627
4012
 
3628
- const COMPONENT_NAME$M = 'vcm-input-number';
4013
+ const COMPONENT_NAME$N = 'vcm-input-number';
3629
4014
  const MInputNumber = /* @__PURE__ */ defineComponent({
3630
- name: COMPONENT_NAME$M,
3631
- props: props$G,
4015
+ name: COMPONENT_NAME$N,
4016
+ props: props$H,
3632
4017
  inheritAttrs: false,
3633
4018
  setup(props, {
3634
4019
  slots,
@@ -3676,11 +4061,11 @@ const MInputNumber = /* @__PURE__ */ defineComponent({
3676
4061
 
3677
4062
  /** @jsxImportSource vue */
3678
4063
 
3679
- const COMPONENT_NAME$L = 'vcm-input-search';
4064
+ const COMPONENT_NAME$M = 'vcm-input-search';
3680
4065
  const MInputSearch = /* @__PURE__ */ defineComponent({
3681
- name: COMPONENT_NAME$L,
4066
+ name: COMPONENT_NAME$M,
3682
4067
  props: {
3683
- ...props$F,
4068
+ ...props$G,
3684
4069
  cancelText: {
3685
4070
  type: String,
3686
4071
  default: '取消'
@@ -3740,7 +4125,7 @@ const MInputSearch = /* @__PURE__ */ defineComponent({
3740
4125
  }
3741
4126
  });
3742
4127
 
3743
- const props$E = {
4128
+ const props$F = {
3744
4129
  tag: {
3745
4130
  type: String,
3746
4131
  default: "div"
@@ -3755,10 +4140,10 @@ const props$E = {
3755
4140
  }
3756
4141
  };
3757
4142
 
3758
- const COMPONENT_NAME$K = "vcm-list";
4143
+ const COMPONENT_NAME$L = "vcm-list";
3759
4144
  const MList = defineComponent({
3760
- name: COMPONENT_NAME$K,
3761
- props: props$E,
4145
+ name: COMPONENT_NAME$L,
4146
+ props: props$F,
3762
4147
  setup(props, { slots }) {
3763
4148
  provide("list", { props });
3764
4149
  return () => {
@@ -3778,7 +4163,7 @@ const MList = defineComponent({
3778
4163
  }
3779
4164
  });
3780
4165
 
3781
- const props$D = {
4166
+ const props$E = {
3782
4167
  tag: {
3783
4168
  type: String,
3784
4169
  default: "div"
@@ -3812,11 +4197,11 @@ const props$D = {
3812
4197
 
3813
4198
  /** @jsxImportSource vue */
3814
4199
 
3815
- const COMPONENT_NAME$J = 'vcm-list-item';
4200
+ const COMPONENT_NAME$K = 'vcm-list-item';
3816
4201
  const HTTP_REGEX = /[a-zA-z]+:\/\/[^\s]*/;
3817
4202
  const MListItem = /* @__PURE__ */ defineComponent({
3818
- name: COMPONENT_NAME$J,
3819
- props: props$D,
4203
+ name: COMPONENT_NAME$K,
4204
+ props: props$E,
3820
4205
  emits: ['click'],
3821
4206
  setup(props, {
3822
4207
  slots,
@@ -3890,7 +4275,7 @@ const MListItem = /* @__PURE__ */ defineComponent({
3890
4275
  }
3891
4276
  });
3892
4277
 
3893
- const props$C = {
4278
+ const props$D = {
3894
4279
  tag: {
3895
4280
  type: String,
3896
4281
  default: "div"
@@ -3899,10 +4284,10 @@ const props$C = {
3899
4284
 
3900
4285
  /** @jsxImportSource vue */
3901
4286
 
3902
- const COMPONENT_NAME$I = 'vc-marquee';
4287
+ const COMPONENT_NAME$J = 'vc-marquee';
3903
4288
  const Marquee = /* @__PURE__ */ defineComponent({
3904
- name: COMPONENT_NAME$I,
3905
- props: props$C,
4289
+ name: COMPONENT_NAME$J,
4290
+ props: props$D,
3906
4291
  setup(props, {
3907
4292
  slots
3908
4293
  }) {
@@ -3916,7 +4301,7 @@ const Marquee = /* @__PURE__ */ defineComponent({
3916
4301
 
3917
4302
  const MMarquee = Marquee;
3918
4303
 
3919
- const props$B = {
4304
+ const props$C = {
3920
4305
  content: [String, Function],
3921
4306
  mask: {
3922
4307
  type: Boolean,
@@ -3953,11 +4338,11 @@ const props$B = {
3953
4338
 
3954
4339
  /** @jsxImportSource vue */
3955
4340
 
3956
- const COMPONENT_NAME$H = 'vc-message';
4341
+ const COMPONENT_NAME$I = 'vc-message';
3957
4342
  const MessageView = /* @__PURE__ */ defineComponent({
3958
- name: COMPONENT_NAME$H,
4343
+ name: COMPONENT_NAME$I,
3959
4344
  emits: ['before-close', 'close', 'portal-fulfilled'],
3960
- props: props$B,
4345
+ props: props$C,
3961
4346
  setup(props, {
3962
4347
  emit,
3963
4348
  expose
@@ -4088,7 +4473,7 @@ const Message$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty(
4088
4473
 
4089
4474
  const MMessage = Message$1;
4090
4475
 
4091
- const props$A = {
4476
+ const props$B = {
4092
4477
  modelValue: {
4093
4478
  type: Boolean,
4094
4479
  default: false
@@ -4168,12 +4553,12 @@ const props$A = {
4168
4553
 
4169
4554
  /** @jsxImportSource vue */
4170
4555
 
4171
- const COMPONENT_NAME$G = 'vc-modal';
4556
+ const COMPONENT_NAME$H = 'vc-modal';
4172
4557
  let zIndexNumber = 1002;
4173
4558
  const ModalView = /* @__PURE__ */ defineComponent({
4174
- name: COMPONENT_NAME$G,
4559
+ name: COMPONENT_NAME$H,
4175
4560
  emits: ['update:modelValue', 'close', 'portal-fulfilled', 'visible-change', 'ok', 'cancel'],
4176
- props: props$A,
4561
+ props: props$B,
4177
4562
  setup(props, {
4178
4563
  slots,
4179
4564
  emit,
@@ -4508,7 +4893,7 @@ const modal$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
4508
4893
  warning: warning$1
4509
4894
  }, Symbol.toStringTag, { value: 'Module' }));
4510
4895
 
4511
- const props$z = {
4896
+ const props$A = {
4512
4897
  mode: {
4513
4898
  type: String,
4514
4899
  validator: (v) => /(alert|operation)/.test(v),
@@ -4570,11 +4955,11 @@ const props$z = {
4570
4955
 
4571
4956
  /** @jsxImportSource vue */
4572
4957
 
4573
- const COMPONENT_NAME$F = 'vc-modal';
4958
+ const COMPONENT_NAME$G = 'vc-modal';
4574
4959
  const MModalView = /* @__PURE__ */ defineComponent({
4575
- name: COMPONENT_NAME$F,
4960
+ name: COMPONENT_NAME$G,
4576
4961
  emits: ['update:modelValue', 'portal-fulfilled', 'close', 'ok', 'cancel'],
4577
- props: props$z,
4962
+ props: props$A,
4578
4963
  setup(props, {
4579
4964
  slots,
4580
4965
  emit,
@@ -4747,7 +5132,7 @@ const modal = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
4747
5132
  operation
4748
5133
  }, Symbol.toStringTag, { value: 'Module' }));
4749
5134
 
4750
- const props$y = {
5135
+ const props$z = {
4751
5136
  title: [String, Function],
4752
5137
  content: [String, Function],
4753
5138
  duration: {
@@ -4776,10 +5161,10 @@ const props$y = {
4776
5161
 
4777
5162
  /** @jsxImportSource vue */
4778
5163
 
4779
- const COMPONENT_NAME$E = 'vc-notice';
5164
+ const COMPONENT_NAME$F = 'vc-notice';
4780
5165
  const NoticeView = /* @__PURE__ */ defineComponent({
4781
- name: COMPONENT_NAME$E,
4782
- props: props$y,
5166
+ name: COMPONENT_NAME$F,
5167
+ props: props$z,
4783
5168
  emits: ['portal-fulfilled', 'close', 'before-close'],
4784
5169
  setup(props, {
4785
5170
  emit
@@ -4928,7 +5313,7 @@ const Notice$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
4928
5313
 
4929
5314
  const MNotice = Notice$1;
4930
5315
 
4931
- const props$x = {
5316
+ const props$y = {
4932
5317
  tag: {
4933
5318
  type: String,
4934
5319
  default: "div"
@@ -4937,10 +5322,10 @@ const props$x = {
4937
5322
 
4938
5323
  /** @jsxImportSource vue */
4939
5324
 
4940
- const COMPONENT_NAME$D = 'vc-option';
5325
+ const COMPONENT_NAME$E = 'vc-option';
4941
5326
  const Option = /* @__PURE__ */ defineComponent({
4942
- name: COMPONENT_NAME$D,
4943
- props: props$x,
5327
+ name: COMPONENT_NAME$E,
5328
+ props: props$y,
4944
5329
  setup(props, {
4945
5330
  slots
4946
5331
  }) {
@@ -4954,7 +5339,7 @@ const Option = /* @__PURE__ */ defineComponent({
4954
5339
 
4955
5340
  const MOption = Option;
4956
5341
 
4957
- const props$w = {
5342
+ const props$x = {
4958
5343
  tag: {
4959
5344
  type: String,
4960
5345
  default: "div"
@@ -4963,10 +5348,10 @@ const props$w = {
4963
5348
 
4964
5349
  /** @jsxImportSource vue */
4965
5350
 
4966
- const COMPONENT_NAME$C = 'vc-page';
5351
+ const COMPONENT_NAME$D = 'vc-page';
4967
5352
  const Page = /* @__PURE__ */ defineComponent({
4968
- name: COMPONENT_NAME$C,
4969
- props: props$w,
5353
+ name: COMPONENT_NAME$D,
5354
+ props: props$x,
4970
5355
  setup(props, {
4971
5356
  slots
4972
5357
  }) {
@@ -4980,7 +5365,7 @@ const Page = /* @__PURE__ */ defineComponent({
4980
5365
 
4981
5366
  const MPage = Page;
4982
5367
 
4983
- const props$v = {
5368
+ const props$w = {
4984
5369
  tag: {
4985
5370
  type: String,
4986
5371
  default: "div"
@@ -4989,10 +5374,10 @@ const props$v = {
4989
5374
 
4990
5375
  /** @jsxImportSource vue */
4991
5376
 
4992
- const COMPONENT_NAME$B = 'vc-picker';
5377
+ const COMPONENT_NAME$C = 'vc-picker';
4993
5378
  const Picker = /* @__PURE__ */ defineComponent({
4994
- name: COMPONENT_NAME$B,
4995
- props: props$v,
5379
+ name: COMPONENT_NAME$C,
5380
+ props: props$w,
4996
5381
  setup(props, {
4997
5382
  slots
4998
5383
  }) {
@@ -5006,7 +5391,7 @@ const Picker = /* @__PURE__ */ defineComponent({
5006
5391
 
5007
5392
  const MPicker = Picker;
5008
5393
 
5009
- const props$u = {
5394
+ const props$v = {
5010
5395
  tag: {
5011
5396
  type: String,
5012
5397
  default: "div"
@@ -5015,10 +5400,10 @@ const props$u = {
5015
5400
 
5016
5401
  /** @jsxImportSource vue */
5017
5402
 
5018
- const COMPONENT_NAME$A = 'vc-popconfirm';
5403
+ const COMPONENT_NAME$B = 'vc-popconfirm';
5019
5404
  const Popconfirm = /* @__PURE__ */ defineComponent({
5020
- name: COMPONENT_NAME$A,
5021
- props: props$u,
5405
+ name: COMPONENT_NAME$B,
5406
+ props: props$v,
5022
5407
  setup(props, {
5023
5408
  slots
5024
5409
  }) {
@@ -5032,7 +5417,7 @@ const Popconfirm = /* @__PURE__ */ defineComponent({
5032
5417
 
5033
5418
  const MPopconfirm = Popconfirm;
5034
5419
 
5035
- const props$t = {
5420
+ const props$u = {
5036
5421
  modelValue: Boolean,
5037
5422
  animation: String,
5038
5423
  placement: {
@@ -5111,7 +5496,7 @@ const wrapperKeys = [
5111
5496
  "autoWidth",
5112
5497
  "always"
5113
5498
  ];
5114
- const props$s = {
5499
+ const props$t = {
5115
5500
  trigger: {
5116
5501
  type: String,
5117
5502
  default: "hover",
@@ -5129,7 +5514,7 @@ const props$s = {
5129
5514
  type: Boolean,
5130
5515
  default: true
5131
5516
  },
5132
- ...pick(props$t, wrapperKeys)
5517
+ ...pick(props$u, wrapperKeys)
5133
5518
  };
5134
5519
 
5135
5520
  const EXTRA_DISTANCE = 4;
@@ -5390,10 +5775,10 @@ const usePos = () => {
5390
5775
  function _isSlot(s) {
5391
5776
  return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
5392
5777
  }
5393
- const COMPONENT_NAME$z = 'vc-popover-wrapper';
5778
+ const COMPONENT_NAME$A = 'vc-popover-wrapper';
5394
5779
  const PopoverWrapper = /* @__PURE__ */ defineComponent({
5395
- name: COMPONENT_NAME$z,
5396
- props: props$t,
5780
+ name: COMPONENT_NAME$A,
5781
+ props: props$u,
5397
5782
  emits: ['portal-fulfilled', 'close'],
5398
5783
  setup(props, {
5399
5784
  emit,
@@ -5643,10 +6028,10 @@ const PopoverPortal = new Portal(PopoverWrapper);
5643
6028
 
5644
6029
  /** @jsxImportSource vue */
5645
6030
 
5646
- const COMPONENT_NAME$y = 'vc-popover';
6031
+ const COMPONENT_NAME$z = 'vc-popover';
5647
6032
  const Popover = /* @__PURE__ */ defineComponent({
5648
- name: COMPONENT_NAME$y,
5649
- props: props$s,
6033
+ name: COMPONENT_NAME$z,
6034
+ props: props$t,
5650
6035
  emits: ['update:modelValue', 'visible-change', 'ready', 'close'],
5651
6036
  open: PopoverPortal.popup.bind(PopoverPortal),
5652
6037
  setup(props, {
@@ -5783,7 +6168,7 @@ const Popover = /* @__PURE__ */ defineComponent({
5783
6168
 
5784
6169
  const MPopover = Popover;
5785
6170
 
5786
- const props$r = {
6171
+ const props$s = {
5787
6172
  tag: {
5788
6173
  type: String,
5789
6174
  default: "div"
@@ -5792,10 +6177,10 @@ const props$r = {
5792
6177
 
5793
6178
  /** @jsxImportSource vue */
5794
6179
 
5795
- const COMPONENT_NAME$x = 'vc-popup';
6180
+ const COMPONENT_NAME$y = 'vc-popup';
5796
6181
  const Popup = /* @__PURE__ */ defineComponent({
5797
- name: COMPONENT_NAME$x,
5798
- props: props$r,
6182
+ name: COMPONENT_NAME$y,
6183
+ props: props$s,
5799
6184
  setup(props, {
5800
6185
  slots
5801
6186
  }) {
@@ -5811,7 +6196,7 @@ const MPopup = Popup;
5811
6196
 
5812
6197
  const MPortal = Portal;
5813
6198
 
5814
- const props$q = {
6199
+ const props$r = {
5815
6200
  tag: {
5816
6201
  type: String,
5817
6202
  default: "div"
@@ -5820,10 +6205,10 @@ const props$q = {
5820
6205
 
5821
6206
  /** @jsxImportSource vue */
5822
6207
 
5823
- const COMPONENT_NAME$w = 'vc-print';
6208
+ const COMPONENT_NAME$x = 'vc-print';
5824
6209
  const Print = /* @__PURE__ */ defineComponent({
5825
- name: COMPONENT_NAME$w,
5826
- props: props$q,
6210
+ name: COMPONENT_NAME$x,
6211
+ props: props$r,
5827
6212
  setup(props, {
5828
6213
  slots
5829
6214
  }) {
@@ -5837,7 +6222,7 @@ const Print = /* @__PURE__ */ defineComponent({
5837
6222
 
5838
6223
  const MPrint = Print;
5839
6224
 
5840
- const props$p = {
6225
+ const props$q = {
5841
6226
  tag: {
5842
6227
  type: String,
5843
6228
  default: "div"
@@ -5846,10 +6231,10 @@ const props$p = {
5846
6231
 
5847
6232
  /** @jsxImportSource vue */
5848
6233
 
5849
- const COMPONENT_NAME$v = 'vc-progress';
6234
+ const COMPONENT_NAME$w = 'vc-progress';
5850
6235
  const Progress = /* @__PURE__ */ defineComponent({
5851
- name: COMPONENT_NAME$v,
5852
- props: props$p,
6236
+ name: COMPONENT_NAME$w,
6237
+ props: props$q,
5853
6238
  setup(props, {
5854
6239
  slots
5855
6240
  }) {
@@ -5863,7 +6248,7 @@ const Progress = /* @__PURE__ */ defineComponent({
5863
6248
 
5864
6249
  const MProgress = Progress;
5865
6250
 
5866
- const props$o = {
6251
+ const props$p = {
5867
6252
  tag: {
5868
6253
  type: String,
5869
6254
  default: "div"
@@ -5872,10 +6257,10 @@ const props$o = {
5872
6257
 
5873
6258
  /** @jsxImportSource vue */
5874
6259
 
5875
- const COMPONENT_NAME$u = 'vc-radio';
6260
+ const COMPONENT_NAME$v = 'vc-radio';
5876
6261
  const Radio = /* @__PURE__ */ defineComponent({
5877
- name: COMPONENT_NAME$u,
5878
- props: props$o,
6262
+ name: COMPONENT_NAME$v,
6263
+ props: props$p,
5879
6264
  setup(props, {
5880
6265
  slots
5881
6266
  }) {
@@ -5889,7 +6274,7 @@ const Radio = /* @__PURE__ */ defineComponent({
5889
6274
 
5890
6275
  const MRadio = Radio;
5891
6276
 
5892
- const props$n = {
6277
+ const props$o = {
5893
6278
  tag: {
5894
6279
  type: String,
5895
6280
  default: "div"
@@ -5898,10 +6283,10 @@ const props$n = {
5898
6283
 
5899
6284
  /** @jsxImportSource vue */
5900
6285
 
5901
- const COMPONENT_NAME$t = 'vc-rate';
6286
+ const COMPONENT_NAME$u = 'vc-rate';
5902
6287
  const Rate = /* @__PURE__ */ defineComponent({
5903
- name: COMPONENT_NAME$t,
5904
- props: props$n,
6288
+ name: COMPONENT_NAME$u,
6289
+ props: props$o,
5905
6290
  setup(props, {
5906
6291
  slots
5907
6292
  }) {
@@ -5915,7 +6300,7 @@ const Rate = /* @__PURE__ */ defineComponent({
5915
6300
 
5916
6301
  const MRate = Rate;
5917
6302
 
5918
- const props$m = {
6303
+ const props$n = {
5919
6304
  data: {
5920
6305
  type: Array,
5921
6306
  default: () => []
@@ -5966,7 +6351,7 @@ const props$m = {
5966
6351
  renderRefresh: Function
5967
6352
  };
5968
6353
 
5969
- const props$l = {
6354
+ const props$m = {
5970
6355
  vertical: Boolean,
5971
6356
  wrapperSize: {
5972
6357
  type: Number,
@@ -6021,7 +6406,7 @@ const barKeys$1 = [
6021
6406
  "thumbStyle",
6022
6407
  "thumbClass"
6023
6408
  ];
6024
- const props$k = {
6409
+ const props$l = {
6025
6410
  // 如果存在滚动条宽度为false, 不存在则为true
6026
6411
  // 为false的情况下才能使用track-offset
6027
6412
  native: {
@@ -6052,7 +6437,7 @@ const props$k = {
6052
6437
  scrollX: Number,
6053
6438
  scrollY: Number,
6054
6439
  fit: Boolean,
6055
- ...pick(props$l, barKeys$1)
6440
+ ...pick(props$m, barKeys$1)
6056
6441
  };
6057
6442
 
6058
6443
  const barKeys = [
@@ -6067,7 +6452,7 @@ const barKeys = [
6067
6452
  "autoResize",
6068
6453
  "native"
6069
6454
  ];
6070
- const props$j = {
6455
+ const props$k = {
6071
6456
  tag: {
6072
6457
  type: String,
6073
6458
  default: "div"
@@ -6100,13 +6485,13 @@ const props$j = {
6100
6485
  type: Boolean,
6101
6486
  default: true
6102
6487
  },
6103
- barTo: props$k.to,
6104
- ...pick(props$k, barKeys)
6488
+ barTo: props$l.to,
6489
+ ...pick(props$l, barKeys)
6105
6490
  };
6106
6491
 
6107
6492
  /** @jsxImportSource vue */
6108
6493
 
6109
- const COMPONENT_NAME$s = 'vc-scroller-track';
6494
+ const COMPONENT_NAME$t = 'vc-scroller-track';
6110
6495
  const BAR_MAP = {
6111
6496
  vertical: {
6112
6497
  scroll: 'scrollTop',
@@ -6126,8 +6511,8 @@ const BAR_MAP = {
6126
6511
  }
6127
6512
  };
6128
6513
  const Track = /* @__PURE__ */ defineComponent({
6129
- name: COMPONENT_NAME$s,
6130
- props: props$l,
6514
+ name: COMPONENT_NAME$t,
6515
+ props: props$m,
6131
6516
  emits: ['change'],
6132
6517
  setup(props, {
6133
6518
  emit,
@@ -6312,10 +6697,10 @@ const Track = /* @__PURE__ */ defineComponent({
6312
6697
 
6313
6698
  /** @jsxImportSource vue */
6314
6699
 
6315
- const COMPONENT_NAME$r = 'vc-scroller-bar';
6700
+ const COMPONENT_NAME$s = 'vc-scroller-bar';
6316
6701
  const Bar = /* @__PURE__ */ defineComponent({
6317
- name: COMPONENT_NAME$r,
6318
- props: props$k,
6702
+ name: COMPONENT_NAME$s,
6703
+ props: props$l,
6319
6704
  emits: ['change'],
6320
6705
  setup(props, {
6321
6706
  emit,
@@ -6528,7 +6913,7 @@ const useScroller = (expose) => {
6528
6913
 
6529
6914
  /** @jsxImportSource vue */
6530
6915
 
6531
- const COMPONENT_NAME$q = 'vc-scroller';
6916
+ const COMPONENT_NAME$r = 'vc-scroller';
6532
6917
 
6533
6918
  /**
6534
6919
  * 作为备选方案,目前推荐使用ScrollerWheel
@@ -6539,8 +6924,8 @@ const COMPONENT_NAME$q = 'vc-scroller';
6539
6924
  * 2. 增加了一层嵌套
6540
6925
  */
6541
6926
  const Scroller = /* @__PURE__ */ defineComponent({
6542
- name: COMPONENT_NAME$q,
6543
- props: props$j,
6927
+ name: COMPONENT_NAME$r,
6928
+ props: props$k,
6544
6929
  emits: ['scroll'],
6545
6930
  setup(props, {
6546
6931
  slots,
@@ -6600,7 +6985,7 @@ const Scroller = /* @__PURE__ */ defineComponent({
6600
6985
 
6601
6986
  /** @jsxImportSource vue */
6602
6987
 
6603
- const COMPONENT_NAME$p = 'vc-scroller-wheel';
6988
+ const COMPONENT_NAME$q = 'vc-scroller-wheel';
6604
6989
 
6605
6990
  /**
6606
6991
  * 为减少一层嵌套,为去除滚动bar的抖动,使用wheel模拟
@@ -6622,8 +7007,8 @@ const COMPONENT_NAME$p = 'vc-scroller-wheel';
6622
7007
  * 设置scrollTop不会reflow和repaint,不需要考虑transfrom来改变content(transform也只在draw完成)
6623
7008
  */
6624
7009
  const ScrollerWheel = /* @__PURE__ */ defineComponent({
6625
- name: COMPONENT_NAME$p,
6626
- props: props$j,
7010
+ name: COMPONENT_NAME$q,
7011
+ props: props$k,
6627
7012
  emits: ['scroll'],
6628
7013
  setup(props, {
6629
7014
  slots,
@@ -6727,9 +7112,9 @@ const ScrollerWheel = /* @__PURE__ */ defineComponent({
6727
7112
 
6728
7113
  /** @jsxImportSource vue */
6729
7114
 
6730
- const COMPONENT_NAME$o = 'vc-recycle-list-scroll-state';
7115
+ const COMPONENT_NAME$p = 'vc-recycle-list-scroll-state';
6731
7116
  const ScrollState = /* @__PURE__ */ defineComponent({
6732
- name: COMPONENT_NAME$o,
7117
+ name: COMPONENT_NAME$p,
6733
7118
  setup(_, {
6734
7119
  slots
6735
7120
  }) {
@@ -6800,7 +7185,7 @@ const STATUS_MAP = {
6800
7185
  }
6801
7186
  };
6802
7187
 
6803
- const props$i = {
7188
+ const props$j = {
6804
7189
  inverted: {
6805
7190
  type: Boolean,
6806
7191
  default: false
@@ -6859,13 +7244,13 @@ const useDirectionKeys = () => {
6859
7244
 
6860
7245
  /** @jsxImportSource vue */
6861
7246
 
6862
- const COMPONENT_NAME$n = 'vc-recycle-list-container';
7247
+ const COMPONENT_NAME$o = 'vc-recycle-list-container';
6863
7248
 
6864
7249
  // TODO: 抽离
6865
7250
  const transformKey = $.prefixStyle('transform').camel;
6866
7251
  const Container = /* @__PURE__ */ defineComponent({
6867
- name: COMPONENT_NAME$n,
6868
- props: props$i,
7252
+ name: COMPONENT_NAME$o,
7253
+ props: props$j,
6869
7254
  emits: ['refresh'],
6870
7255
  setup(props, {
6871
7256
  slots
@@ -6962,9 +7347,9 @@ const Container = /* @__PURE__ */ defineComponent({
6962
7347
 
6963
7348
  /** @jsxImportSource vue */
6964
7349
 
6965
- const COMPONENT_NAME$m = 'vc-recycle-list-item';
7350
+ const COMPONENT_NAME$n = 'vc-recycle-list-item';
6966
7351
  const Item = /* @__PURE__ */ defineComponent({
6967
- name: COMPONENT_NAME$m,
7352
+ name: COMPONENT_NAME$n,
6968
7353
  props: {
6969
7354
  vertical: {
6970
7355
  type: Boolean,
@@ -7006,10 +7391,10 @@ const Item = /* @__PURE__ */ defineComponent({
7006
7391
 
7007
7392
  /** @jsxImportSource vue */
7008
7393
 
7009
- const COMPONENT_NAME$l = 'vc-recycle-list';
7394
+ const COMPONENT_NAME$m = 'vc-recycle-list';
7010
7395
  const RecycleList = /* @__PURE__ */ defineComponent({
7011
- name: COMPONENT_NAME$l,
7012
- props: props$m,
7396
+ name: COMPONENT_NAME$m,
7397
+ props: props$n,
7013
7398
  emits: ['scroll'],
7014
7399
  setup(props, {
7015
7400
  slots,
@@ -7553,17 +7938,17 @@ const RecycleList = /* @__PURE__ */ defineComponent({
7553
7938
 
7554
7939
  const MRecycleList = RecycleList;
7555
7940
 
7556
- const props$h = {
7941
+ const props$i = {
7557
7942
  tag: {
7558
7943
  type: String,
7559
7944
  default: "div"
7560
7945
  }
7561
7946
  };
7562
7947
 
7563
- const COMPONENT_NAME$k = "vc-resizer";
7948
+ const COMPONENT_NAME$l = "vc-resizer";
7564
7949
  const Resizer = defineComponent({
7565
- name: COMPONENT_NAME$k,
7566
- props: props$h,
7950
+ name: COMPONENT_NAME$l,
7951
+ props: props$i,
7567
7952
  emit: ["resize"],
7568
7953
  setup(props, { emit, slots }) {
7569
7954
  const width = ref(0);
@@ -7618,7 +8003,7 @@ const MResizer = Resizer;
7618
8003
 
7619
8004
  const MScroller = Scroller;
7620
8005
 
7621
- const props$g = {
8006
+ const props$h = {
7622
8007
  tag: {
7623
8008
  type: String,
7624
8009
  default: "div"
@@ -7627,10 +8012,10 @@ const props$g = {
7627
8012
 
7628
8013
  /** @jsxImportSource vue */
7629
8014
 
7630
- const COMPONENT_NAME$j = 'vc-select';
8015
+ const COMPONENT_NAME$k = 'vc-select';
7631
8016
  const Select = /* @__PURE__ */ defineComponent({
7632
- name: COMPONENT_NAME$j,
7633
- props: props$g,
8017
+ name: COMPONENT_NAME$k,
8018
+ props: props$h,
7634
8019
  setup(props, {
7635
8020
  slots
7636
8021
  }) {
@@ -7644,7 +8029,7 @@ const Select = /* @__PURE__ */ defineComponent({
7644
8029
 
7645
8030
  const MSelect = Select;
7646
8031
 
7647
- const props$f = {
8032
+ const props$g = {
7648
8033
  tag: {
7649
8034
  type: String,
7650
8035
  default: "div"
@@ -7653,10 +8038,10 @@ const props$f = {
7653
8038
 
7654
8039
  /** @jsxImportSource vue */
7655
8040
 
7656
- const COMPONENT_NAME$i = 'vc-slider';
8041
+ const COMPONENT_NAME$j = 'vc-slider';
7657
8042
  const Slider = /* @__PURE__ */ defineComponent({
7658
- name: COMPONENT_NAME$i,
7659
- props: props$f,
8043
+ name: COMPONENT_NAME$j,
8044
+ props: props$g,
7660
8045
  setup(props, {
7661
8046
  slots
7662
8047
  }) {
@@ -7670,7 +8055,7 @@ const Slider = /* @__PURE__ */ defineComponent({
7670
8055
 
7671
8056
  const MSlider = Slider;
7672
8057
 
7673
- const props$e = {
8058
+ const props$f = {
7674
8059
  tag: {
7675
8060
  type: String,
7676
8061
  default: "div"
@@ -7679,10 +8064,10 @@ const props$e = {
7679
8064
 
7680
8065
  /** @jsxImportSource vue */
7681
8066
 
7682
- const COMPONENT_NAME$h = 'vc-sort-list';
8067
+ const COMPONENT_NAME$i = 'vc-sort-list';
7683
8068
  const SortList = /* @__PURE__ */ defineComponent({
7684
- name: COMPONENT_NAME$h,
7685
- props: props$e,
8069
+ name: COMPONENT_NAME$i,
8070
+ props: props$f,
7686
8071
  setup(props, {
7687
8072
  slots
7688
8073
  }) {
@@ -7696,7 +8081,7 @@ const SortList = /* @__PURE__ */ defineComponent({
7696
8081
 
7697
8082
  const MSortList = SortList;
7698
8083
 
7699
- const props$d = {
8084
+ const props$e = {
7700
8085
  tag: {
7701
8086
  type: String,
7702
8087
  default: "div"
@@ -7705,10 +8090,10 @@ const props$d = {
7705
8090
 
7706
8091
  /** @jsxImportSource vue */
7707
8092
 
7708
- const COMPONENT_NAME$g = 'vc-steps';
8093
+ const COMPONENT_NAME$h = 'vc-steps';
7709
8094
  const Steps = /* @__PURE__ */ defineComponent({
7710
- name: COMPONENT_NAME$g,
7711
- props: props$d,
8095
+ name: COMPONENT_NAME$h,
8096
+ props: props$e,
7712
8097
  setup(props, {
7713
8098
  slots
7714
8099
  }) {
@@ -7722,7 +8107,7 @@ const Steps = /* @__PURE__ */ defineComponent({
7722
8107
 
7723
8108
  const MSteps = Steps;
7724
8109
 
7725
- const props$c = {
8110
+ const props$d = {
7726
8111
  tag: {
7727
8112
  type: String,
7728
8113
  default: "div"
@@ -7731,10 +8116,10 @@ const props$c = {
7731
8116
 
7732
8117
  /** @jsxImportSource vue */
7733
8118
 
7734
- const COMPONENT_NAME$f = 'vc-switch';
8119
+ const COMPONENT_NAME$g = 'vc-switch';
7735
8120
  const Switch = /* @__PURE__ */ defineComponent({
7736
- name: COMPONENT_NAME$f,
7737
- props: props$c,
8121
+ name: COMPONENT_NAME$g,
8122
+ props: props$d,
7738
8123
  setup(props, {
7739
8124
  slots
7740
8125
  }) {
@@ -7748,7 +8133,7 @@ const Switch = /* @__PURE__ */ defineComponent({
7748
8133
 
7749
8134
  const MSwitch = Switch;
7750
8135
 
7751
- const props$b = {
8136
+ const props$c = {
7752
8137
  tag: {
7753
8138
  type: String,
7754
8139
  default: "div"
@@ -7757,10 +8142,10 @@ const props$b = {
7757
8142
 
7758
8143
  /** @jsxImportSource vue */
7759
8144
 
7760
- const COMPONENT_NAME$e = 'vc-table';
8145
+ const COMPONENT_NAME$f = 'vc-table';
7761
8146
  const Table = /* @__PURE__ */ defineComponent({
7762
- name: COMPONENT_NAME$e,
7763
- props: props$b,
8147
+ name: COMPONENT_NAME$f,
8148
+ props: props$c,
7764
8149
  setup(props, {
7765
8150
  slots
7766
8151
  }) {
@@ -7774,31 +8159,430 @@ const Table = /* @__PURE__ */ defineComponent({
7774
8159
 
7775
8160
  const MTable = Table;
7776
8161
 
7777
- const props$a = {
7778
- tag: {
8162
+ const props$b = {
8163
+ type: {
7779
8164
  type: String,
7780
- default: "div"
8165
+ validator: (v) => /^(line|card)$/.test(v),
8166
+ default: "line"
8167
+ },
8168
+ modelValue: {
8169
+ type: [String, Number]
8170
+ },
8171
+ animated: {
8172
+ type: Boolean,
8173
+ default: false
8174
+ },
8175
+ afloat: {
8176
+ type: Boolean,
8177
+ default: true
8178
+ },
8179
+ closable: {
8180
+ type: Boolean,
8181
+ default: false
7781
8182
  }
7782
8183
  };
7783
8184
 
8185
+ const useTabs = (options = {}) => {
8186
+ const instance = getCurrentInstance();
8187
+ const { props, emit } = instance;
8188
+ const tabsId = ref(getUid("tabs"));
8189
+ const list = ref([]);
8190
+ const afloatWidth = ref(0);
8191
+ const afloatOffset = ref(0);
8192
+ const currentValue = ref(void 0);
8193
+ const scrollOffset = ref(0);
8194
+ const scrollable = ref(false);
8195
+ const timer = ref(null);
8196
+ const getTabIndex = (v) => {
8197
+ return list.value.findIndex((nav, index) => (nav.value || index) === v);
8198
+ };
8199
+ const afloatStyle = computed(() => {
8200
+ const style = {
8201
+ width: `${afloatWidth.value}px`,
8202
+ transform: `translate3d(${afloatOffset.value}px, 0px, 0px)`
8203
+ };
8204
+ return style;
8205
+ });
8206
+ const contentStyle = computed(() => {
8207
+ const index = getTabIndex(currentValue.value);
8208
+ const precent = index === 0 ? "0%" : `-${index}00%`;
8209
+ const style = {
8210
+ transform: ""
8211
+ };
8212
+ if (index > -1) {
8213
+ style.transform = `translate3d(${precent}, 0px, 0px)`;
8214
+ }
8215
+ return style;
8216
+ });
8217
+ const classes = computed(() => {
8218
+ return {
8219
+ "is-animated": props.animated,
8220
+ [`is-${props.type}`]: !!props.type,
8221
+ [`is-${props.theme}`]: !!props.theme
8222
+ };
8223
+ });
8224
+ const refresh = () => {
8225
+ options?.refreshAfloat?.();
8226
+ };
8227
+ const handleChange = (index) => {
8228
+ if (timer.value) return;
8229
+ timer.value = setTimeout(() => timer.value = null, 300);
8230
+ const nav = list.value[index];
8231
+ if (nav.disabled) return;
8232
+ currentValue.value = nav.value || index;
8233
+ emit("update:modelValue", currentValue.value);
8234
+ emit("change", currentValue.value);
8235
+ emit("click", currentValue.value);
8236
+ };
8237
+ const handleResize = () => {
8238
+ if (instance.isUnmounted) return;
8239
+ options?.refreshScroll?.();
8240
+ options?.refreshAfloat?.();
8241
+ };
8242
+ onMounted(() => {
8243
+ Resize.on(options.wrapper.value, handleResize);
8244
+ options.scrollToActive && nextTick(options.scrollToActive);
8245
+ });
8246
+ onUnmounted(() => {
8247
+ Resize.off(options.wrapper.value, handleResize);
8248
+ timer.value && clearTimeout(timer.value);
8249
+ });
8250
+ const add = (item, setValue) => {
8251
+ if (!item) return;
8252
+ nextTick(() => {
8253
+ typeof currentValue.value === "undefined" && (currentValue.value = item.proxy.currentValue || 0);
8254
+ if (options.content.value) {
8255
+ const index = Array.from(options.content.value.children).filter((i) => /vcm?-tabs-pane/.test(i.className)).indexOf(item.vnode.el);
8256
+ if (index != -1) {
8257
+ list.value.splice(index, 0, item.props);
8258
+ typeof item.props.value === "undefined" && setValue(index);
8259
+ return;
8260
+ }
8261
+ }
8262
+ list.value.push(item.props);
8263
+ typeof item.props.value === "undefined" && setValue(list.value.length - 1);
8264
+ });
8265
+ };
8266
+ const remove = (item) => {
8267
+ if (!item) return;
8268
+ list.value.splice(list.value.indexOf(item.props), 1);
8269
+ };
8270
+ provide("tabs", {
8271
+ props,
8272
+ currentValue,
8273
+ refresh,
8274
+ add,
8275
+ remove
8276
+ });
8277
+ watch(
8278
+ () => props.modelValue,
8279
+ (v) => {
8280
+ currentValue.value = v;
8281
+ },
8282
+ { immediate: true }
8283
+ );
8284
+ watch(
8285
+ () => currentValue.value,
8286
+ () => {
8287
+ options.refreshAfloat?.();
8288
+ options.scrollToActive?.();
8289
+ }
8290
+ );
8291
+ watch(
8292
+ () => list.value.length,
8293
+ () => {
8294
+ options.refreshAfloat?.();
8295
+ options.scrollToActive?.();
8296
+ }
8297
+ );
8298
+ return {
8299
+ tabsId,
8300
+ list,
8301
+ timer,
8302
+ afloatWidth,
8303
+ afloatOffset,
8304
+ currentValue,
8305
+ scrollOffset,
8306
+ scrollable,
8307
+ afloatStyle,
8308
+ contentStyle,
8309
+ classes,
8310
+ getTabIndex,
8311
+ handleChange
8312
+ };
8313
+ };
8314
+
7784
8315
  /** @jsxImportSource vue */
7785
8316
 
7786
- const COMPONENT_NAME$d = 'vc-tabs';
8317
+ const COMPONENT_NAME$e = 'vc-tabs';
7787
8318
  const Tabs = /* @__PURE__ */ defineComponent({
8319
+ name: COMPONENT_NAME$e,
8320
+ props: props$b,
8321
+ emits: ['update:modelValue', 'change', 'click'],
8322
+ setup(props, {
8323
+ slots
8324
+ }) {
8325
+ const instance = getCurrentInstance();
8326
+ const wrapper = ref(null);
8327
+ const content = ref(null);
8328
+ const scroll = ref(null);
8329
+ const nav = ref(null);
8330
+ // eslint-disable-next-line prefer-const
8331
+ let tabs;
8332
+
8333
+ /**
8334
+ * 刷新是否需要滚动条
8335
+ */
8336
+ const refreshScroll = () => {
8337
+ // 容器
8338
+ const boxWidth = scroll.value.offsetWidth;
8339
+ // 总长度
8340
+ const totalWidth = nav.value.offsetWidth;
8341
+ if (boxWidth < totalWidth) {
8342
+ tabs.scrollable.value = true;
8343
+ totalWidth - tabs.scrollOffset.value < boxWidth && (tabs.scrollOffset.value = totalWidth - boxWidth);
8344
+ } else {
8345
+ tabs.scrollable.value = false;
8346
+ tabs.scrollOffset.value > 0 && (tabs.scrollOffset.value = 0);
8347
+ }
8348
+ };
8349
+
8350
+ /**
8351
+ * 刷新当前标签底下的滑块位置
8352
+ */
8353
+ const refreshAfloat = () => {
8354
+ nextTick(() => {
8355
+ const index = tabs.getTabIndex(tabs.currentValue.value);
8356
+ if (instance.isUnmounted) return;
8357
+ const items = nav.value.querySelectorAll(`.vc-tabs__item`);
8358
+ const $ = items[index];
8359
+ tabs.afloatWidth.value = $ ? parseFloat($.offsetWidth) : 0;
8360
+ if (!Array.from(items).length) return;
8361
+ let offset = 0;
8362
+ if (index > 0) {
8363
+ const gutter = 16; // margin-right -> 16px
8364
+ for (let i = 0; i < index; i++) {
8365
+ offset += parseFloat(items[i].offsetWidth) + gutter;
8366
+ }
8367
+ }
8368
+ tabs.afloatOffset.value = offset;
8369
+ refreshScroll();
8370
+ });
8371
+ };
8372
+ const scrollToActive = () => {
8373
+ if (!tabs.scrollable.value) return;
8374
+ // 这里不直接选择is-active,存在延迟
8375
+ const $ = instance.vnode.el.querySelector(`.vc-tabs__item[name="${tabs.currentValue.value}"]`);
8376
+ if (!$) return;
8377
+ const itemBounding = $.getBoundingClientRect();
8378
+ const scrollBounding = scroll.value.getBoundingClientRect();
8379
+ const navBounding = nav.value.getBoundingClientRect();
8380
+ let offset;
8381
+ if (navBounding.right < scrollBounding.right) {
8382
+ offset = nav.value.offsetWidth - scrollBounding.width;
8383
+ }
8384
+ if (itemBounding.left < scrollBounding.left) {
8385
+ offset = tabs.scrollOffset.value - (scrollBounding.left - itemBounding.left);
8386
+ } else if (itemBounding.right > scrollBounding.right) {
8387
+ offset = tabs.scrollOffset.value + itemBounding.right - scrollBounding.right;
8388
+ }
8389
+ if (tabs.scrollOffset.value !== offset) {
8390
+ tabs.scrollOffset.value = offset;
8391
+ }
8392
+ };
8393
+ tabs = useTabs({
8394
+ content,
8395
+ wrapper,
8396
+ refreshAfloat,
8397
+ refreshScroll,
8398
+ scrollToActive
8399
+ });
8400
+ /**
8401
+ * 上一个
8402
+ */
8403
+ const handlePrev = () => {
8404
+ const boxWidth = scroll.value.offsetWidth;
8405
+ if (!tabs.scrollOffset.value) return;
8406
+ tabs.scrollOffset.value = tabs.scrollOffset.value > boxWidth ? tabs.scrollOffset.value - boxWidth : 0;
8407
+ };
8408
+
8409
+ /**
8410
+ * 下一个
8411
+ */
8412
+ const handleNext = () => {
8413
+ const boxWidth = scroll.value.offsetWidth;
8414
+ const totalWidth = nav.value.offsetWidth;
8415
+ if (totalWidth - tabs.scrollOffset.value <= boxWidth) return;
8416
+ tabs.scrollOffset.value = totalWidth - tabs.scrollOffset.value > boxWidth * 2 ? tabs.scrollOffset.value + boxWidth : totalWidth - boxWidth;
8417
+ };
8418
+ const scrollStyle = computed(() => {
8419
+ const style = {
8420
+ transform: `translate3d(${-tabs.scrollOffset.value}px, 0px, 0px)`
8421
+ };
8422
+ return style;
8423
+ });
8424
+ const isCard = computed(() => {
8425
+ return props.type === 'card';
8426
+ });
8427
+ return () => {
8428
+ return createVNode("div", {
8429
+ "class": [tabs.classes.value, 'vc-tabs']
8430
+ }, [createVNode("div", {
8431
+ "class": "vc-tabs__extra"
8432
+ }, [slots.extra?.()]), createVNode("div", {
8433
+ "ref": wrapper,
8434
+ "style": {
8435
+ padding: tabs.scrollable.value && '0 24px'
8436
+ },
8437
+ "class": "vc-tabs__bar"
8438
+ }, [tabs.scrollable.value && createVNode(Icon, {
8439
+ "class": "vc-tabs__icon is-left",
8440
+ "type": "left",
8441
+ "onClick": handlePrev
8442
+ }, null), tabs.scrollable.value && createVNode(Icon, {
8443
+ "class": "vc-tabs__icon is-right",
8444
+ "type": "right",
8445
+ "onClick": handleNext
8446
+ }, null), createVNode("div", {
8447
+ "ref": scroll,
8448
+ "class": "vc-tabs__scroll"
8449
+ }, [createVNode("div", {
8450
+ "ref": nav,
8451
+ "style": scrollStyle.value,
8452
+ "class": "vc-tabs__nav"
8453
+ }, [!isCard.value && createVNode("div", {
8454
+ "style": tabs.afloatStyle.value,
8455
+ "class": "vc-tabs__afloat"
8456
+ }, null), tabs.list.value.map((item, index) => {
8457
+ return createVNode("div", {
8458
+ "key": index,
8459
+ "class": [{
8460
+ 'is-active': (item.value || index) == tabs.currentValue.value
8461
+ }, 'vc-tabs__item'],
8462
+ "onClick": () => tabs.handleChange(index)
8463
+ }, [slots.label ? slots.label({
8464
+ it: item,
8465
+ index
8466
+ }) : typeof item.label === 'string' ? createVNode("span", {
8467
+ "innerHTML": item.label
8468
+ }, null) : typeof item.label === 'function' && createVNode(Customer, {
8469
+ "render": item.label,
8470
+ "it": item,
8471
+ "index": index
8472
+ }, null), props.closable && item.closable && createVNode(Icon, {
8473
+ "type": "close"
8474
+ }, null)]);
8475
+ })])])]), createVNode("div", {
8476
+ "ref": content,
8477
+ "style": tabs.contentStyle.value,
8478
+ "class": "vc-tabs__content"
8479
+ }, [slots.default?.()])]);
8480
+ };
8481
+ }
8482
+ });
8483
+
8484
+ const props$a = {
8485
+ value: {
8486
+ type: [String, Number]
8487
+ },
8488
+ label: {
8489
+ type: [String, Function],
8490
+ default: ""
8491
+ },
8492
+ /**
8493
+ * 服务端渲染时,lazy设置为false,可以把内容渲染出来;
8494
+ * 不能设置为!IS_SERVER, 会影响客服端激活,不一样会存在问题
8495
+ */
8496
+ lazy: {
8497
+ type: Boolean,
8498
+ default: true
8499
+ },
8500
+ closable: {
8501
+ type: Boolean,
8502
+ default: false
8503
+ }
8504
+ };
8505
+
8506
+ const useTabsPane = () => {
8507
+ const instance = getCurrentInstance();
8508
+ const { props } = instance;
8509
+ const currentValue = ref(void 0);
8510
+ const isLoaded = ref(false);
8511
+ const tabs = inject("tabs", {});
8512
+ const isActive = computed(() => {
8513
+ const state = tabs.currentValue.value === (props.value || currentValue.value);
8514
+ if (!isLoaded.value && state) {
8515
+ isLoaded.value = true;
8516
+ }
8517
+ return state;
8518
+ });
8519
+ const isReady = computed(() => {
8520
+ return !props.lazy || isLoaded.value || isActive.value;
8521
+ });
8522
+ const style = computed(() => {
8523
+ return isActive.value ? {} : {
8524
+ opacity: 0,
8525
+ height: 0,
8526
+ // 避免重用高度
8527
+ overflow: "hidden"
8528
+ // 避免内层的高度影响
8529
+ };
8530
+ });
8531
+ const refresh = () => {
8532
+ !instance.isUnmounted && tabs.refresh?.();
8533
+ };
8534
+ watch(
8535
+ () => props.value,
8536
+ (v) => {
8537
+ currentValue.value = v;
8538
+ },
8539
+ {
8540
+ immediate: true
8541
+ }
8542
+ );
8543
+ watch(
8544
+ () => [props.value, props.label],
8545
+ refresh
8546
+ );
8547
+ onMounted(refresh);
8548
+ onUnmounted(refresh);
8549
+ onBeforeMount(() => {
8550
+ tabs.add?.(instance, (v) => currentValue.value = v);
8551
+ });
8552
+ onBeforeUnmount(() => {
8553
+ tabs.remove?.(instance);
8554
+ });
8555
+ return {
8556
+ isLoaded,
8557
+ isActive,
8558
+ isReady,
8559
+ style,
8560
+ currentValue
8561
+ };
8562
+ };
8563
+
8564
+ /** @jsxImportSource vue */
8565
+
8566
+ const COMPONENT_NAME$d = 'vc-tabs-pane';
8567
+ const TabsPane = /* @__PURE__ */ defineComponent({
7788
8568
  name: COMPONENT_NAME$d,
7789
8569
  props: props$a,
7790
- setup(props, {
8570
+ setup(_, {
7791
8571
  slots
7792
8572
  }) {
8573
+ const tabsPane = useTabsPane();
7793
8574
  return () => {
7794
8575
  return createVNode("div", {
7795
- "class": "vc-tabs"
7796
- }, [slots?.default?.()]);
8576
+ "class": "vc-tabs-pane",
8577
+ "style": tabsPane.style.value,
8578
+ "name": tabsPane.currentValue.value
8579
+ }, [tabsPane.isReady && slots.default?.()]);
7797
8580
  };
7798
8581
  }
7799
8582
  });
7800
8583
 
7801
8584
  const MTabs = Tabs;
8585
+ const MTabsPane = TabsPane;
7802
8586
 
7803
8587
  const props$9 = {
7804
8588
  tag: {
@@ -8222,4 +9006,4 @@ const UploadPicker = /* @__PURE__ */ defineComponent({
8222
9006
 
8223
9007
  const MUploadPicker = UploadPicker;
8224
9008
 
8225
- export { ActionSheet, Alert, Artboard, Button, ButtonGroup, Calendar, Card, Carousel, Cascader, Chart, Checkbox, Clipboard, Collapse, ColorPicker, Countdown, Customer, DatePicker, Debounce, Divider, Drawer, Dropdown, Editor, Expand, Form, FormItem, Fragment, HTMLToImage, Icon, IconManager, Image, ImageCrop, ImagePreview, ImageProcessing, Input, InputNumber, InputSearch, MList as List, MListItem as ListItem, MActionSheet, MAlert, MArtboard, MButton, MButtonGroup, MCalendar, MCard, MCarousel, MCascader, MChart, MCheckbox, MClipboard, MCollapse, MColorPicker, MCountdown, MCustomer, MDatePicker, Debounce as MDebounce, MDivider, MDrawer, MDropdown, MEditor, MExpand, MForm, MFormItem, MFragment, MHTMLToImage, MIcon, MImage, MImageCrop, MImagePreview, MImageProcessing, MInput, MInputNumber, MInputSearch, MList, MListItem, MMarquee, MMessage, modal as MModal, MModalView, MNotice, MOption, MPage, MPicker, MPopconfirm, MPopover, MPopup, MPortal, MPrint, MProgress, MRadio, MRate, MRecycleList, MResizer, MScroller, MSelect, MSlider, MSortList, MSpin, MSteps, MSwitch, MTable, MTabs, MTag, MText, MTextarea, MTimePicker, MTimeline, MToast$1 as MToast, MToastView, MTouch, MTransition, MTransitionCollapse, MTransitionFade, MTransitionScale, MTransitionSlide, MTransitionZoom, MTree, MUpload, MUploadPicker, Marquee, Message$1 as Message, MessageView, modal$1 as Modal, ModalView, Notice$1 as Notice, NoticeView, Option, Page, Picker, Popconfirm, Popover, Popup, Portal, PortalView, Print, Progress, Radio, Rate, RecycleList, Resizer, Scroller, ScrollerWheel, Select, Slider, SortList, Spin, Steps, Switch, Table, Tabs, Tag, Text, Textarea, Theme, ThemeImage, ThemeText, ThemeView, TimePicker, Timeline, Toast, ToastView, Touch, Transition, TransitionCollapse, TransitionFade, TransitionScale, TransitionSlide, TransitionZoom, Tree, Upload, UploadPicker, VcError, VcInstance };
9009
+ export { ActionSheet, Alert, Artboard, Button, ButtonGroup, Calendar, Card, Carousel, Cascader, Chart, Checkbox, Clipboard, Collapse, ColorPicker, Countdown, Customer, DatePicker, Debounce, Divider, Drawer, Dropdown, Editor, Expand, Form, FormItem, Fragment, HTMLToImage, Icon, IconManager, Image, ImageCrop, ImagePreview, ImageProcessing, Input, InputNumber, InputSearch, MList as List, MListItem as ListItem, MActionSheet, MAlert, MArtboard, MButton, MButtonGroup, MCalendar, MCard, MCarousel, MCascader, MChart, MCheckbox, MClipboard, MCollapse, MColorPicker, MCountdown, MCustomer, MDatePicker, Debounce as MDebounce, MDivider, MDrawer, MDropdown, MEditor, MExpand, MForm, MFormItem, MFragment, MHTMLToImage, MIcon, MImage, MImageCrop, MImagePreview, MImageProcessing, MInput, MInputNumber, MInputSearch, MList, MListItem, MMarquee, MMessage, modal as MModal, MModalView, MNotice, MOption, MPage, MPicker, MPopconfirm, MPopover, MPopup, MPortal, MPrint, MProgress, MRadio, MRate, MRecycleList, MResizer, MScroller, MSelect, MSlider, MSortList, MSpin, MSteps, MSwitch, MTable, MTabs, MTabsPane, MTag, MText, MTextarea, MTimePicker, MTimeline, MToast$1 as MToast, MToastView, MTouch, MTransition, MTransitionCollapse, MTransitionFade, MTransitionScale, MTransitionSlide, MTransitionZoom, MTree, MUpload, MUploadPicker, Marquee, Message$1 as Message, MessageView, modal$1 as Modal, ModalView, Notice$1 as Notice, NoticeView, Option, Page, Picker, Popconfirm, Popover, Popup, Portal, PortalView, Print, Progress, Radio, Rate, RecycleList, Resizer, Scroller, ScrollerWheel, Select, Slider, SortList, Spin, Steps, Switch, Table, Tabs, TabsPane, Tag, Text, Textarea, Theme, ThemeImage, ThemeText, ThemeView, TimePicker, Timeline, Toast, ToastView, Touch, Transition, TransitionCollapse, TransitionFade, TransitionScale, TransitionSlide, TransitionZoom, Tree, Upload, UploadPicker, VcError, VcInstance };