@deot/vc-components 1.0.6 → 1.0.7

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 CHANGED
@@ -6,10 +6,10 @@ const vue = require('vue');
6
6
  const lodashEs = require('lodash-es');
7
7
  const helperResize = require('@deot/helper-resize');
8
8
  const Utils = require('@deot/helper-utils');
9
- const helperValidator = require('@deot/helper-validator');
10
- const vcShared = require('@deot/vc-shared');
11
9
  const $ = require('@deot/helper-dom');
10
+ const vcShared = require('@deot/vc-shared');
12
11
  const vcHooks = require('@deot/vc-hooks');
12
+ const helperValidator = require('@deot/helper-validator');
13
13
  const helperCache = require('@deot/helper-cache');
14
14
  const helperScheduler = require('@deot/helper-scheduler');
15
15
  const helperWheel = require('@deot/helper-wheel');
@@ -80,7 +80,7 @@ class Instance {
80
80
  }
81
81
  const VcInstance = new Instance();
82
82
 
83
- const props$1h = {
83
+ const props$1j = {
84
84
  tag: {
85
85
  type: String,
86
86
  default: "div"
@@ -89,10 +89,10 @@ const props$1h = {
89
89
 
90
90
  /** @jsxImportSource vue */
91
91
 
92
- const COMPONENT_NAME$1x = 'vc-action-sheet';
92
+ const COMPONENT_NAME$1A = 'vc-action-sheet';
93
93
  const ActionSheet = /* @__PURE__ */ vue.defineComponent({
94
- name: COMPONENT_NAME$1x,
95
- props: props$1h,
94
+ name: COMPONENT_NAME$1A,
95
+ props: props$1j,
96
96
  setup(props, {
97
97
  slots
98
98
  }) {
@@ -106,7 +106,7 @@ const ActionSheet = /* @__PURE__ */ vue.defineComponent({
106
106
 
107
107
  const MActionSheet = ActionSheet;
108
108
 
109
- const props$1g = {
109
+ const props$1i = {
110
110
  modelValue: {
111
111
  type: Boolean,
112
112
  default: true
@@ -133,7 +133,7 @@ const props$1g = {
133
133
  }
134
134
  };
135
135
 
136
- const props$1f = {
136
+ const props$1h = {
137
137
  type: String,
138
138
  inherit: {
139
139
  type: Boolean,
@@ -186,7 +186,7 @@ class Manager {
186
186
  icons = await this.parser(data, url);
187
187
  try {
188
188
  window.localStorage.setItem(key, JSON.stringify(icons));
189
- } catch (e) {
189
+ } catch {
190
190
  setTimeout(() => {
191
191
  this.clearResource();
192
192
  window.localStorage.setItem(key, JSON.stringify(icons));
@@ -278,10 +278,10 @@ const IconManager = new Manager();
278
278
 
279
279
  /** @jsxImportSource vue */
280
280
 
281
- const COMPONENT_NAME$1w = 'vc-icon';
281
+ const COMPONENT_NAME$1z = 'vc-icon';
282
282
  const Icon = /* @__PURE__ */ vue.defineComponent({
283
- name: COMPONENT_NAME$1w,
284
- props: props$1f,
283
+ name: COMPONENT_NAME$1z,
284
+ props: props$1h,
285
285
  setup(props) {
286
286
  const viewBox = vue.ref('0 0 1024 1024');
287
287
  const path = vue.ref([]);
@@ -314,7 +314,7 @@ const Icon = /* @__PURE__ */ vue.defineComponent({
314
314
  }
315
315
  });
316
316
 
317
- const props$1e = {
317
+ const props$1g = {
318
318
  /**
319
319
  * 进入/离开持续时间
320
320
  * {enter: 300, leave: 300}
@@ -479,10 +479,10 @@ const useTransition = () => {
479
479
  };
480
480
  };
481
481
 
482
- const COMPONENT_NAME$1v = "vc-transition";
482
+ const COMPONENT_NAME$1y = "vc-transition";
483
483
  const Transition = vue.defineComponent({
484
- name: COMPONENT_NAME$1v,
485
- props: props$1e,
484
+ name: COMPONENT_NAME$1y,
485
+ props: props$1g,
486
486
  // 当不声明emits的情况下,事件存在于attrs中
487
487
  inheritAttrs: false,
488
488
  setup(props, { slots, attrs }) {
@@ -502,10 +502,10 @@ const Transition = vue.defineComponent({
502
502
  }
503
503
  });
504
504
 
505
- const COMPONENT_NAME$1u = "vc-transition-collapse";
505
+ const COMPONENT_NAME$1x = "vc-transition-collapse";
506
506
  const TransitionCollapse = vue.defineComponent({
507
- name: COMPONENT_NAME$1u,
508
- props: props$1e,
507
+ name: COMPONENT_NAME$1x,
508
+ props: props$1g,
509
509
  // 当不声明emits的情况下,事件存在于attrs中
510
510
  inheritAttrs: false,
511
511
  setup(props, { slots, attrs: _attrs }) {
@@ -623,11 +623,11 @@ const TransitionCollapse = vue.defineComponent({
623
623
  }
624
624
  });
625
625
 
626
- const COMPONENT_NAME$1t = "vc-transition-fade";
626
+ const COMPONENT_NAME$1w = "vc-transition-fade";
627
627
  const TransitionFade = vue.defineComponent({
628
- name: COMPONENT_NAME$1t,
628
+ name: COMPONENT_NAME$1w,
629
629
  props: {
630
- ...props$1e,
630
+ ...props$1g,
631
631
  // inheritAttrs必须是false
632
632
  style: {
633
633
  type: Object,
@@ -660,11 +660,11 @@ const TransitionFade = vue.defineComponent({
660
660
  }
661
661
  });
662
662
 
663
- const COMPONENT_NAME$1s = "vc-transition-scale";
663
+ const COMPONENT_NAME$1v = "vc-transition-scale";
664
664
  const TransitionScale = vue.defineComponent({
665
- name: COMPONENT_NAME$1s,
665
+ name: COMPONENT_NAME$1v,
666
666
  props: {
667
- ...props$1e,
667
+ ...props$1g,
668
668
  mode: {
669
669
  type: String,
670
670
  default: "both",
@@ -702,15 +702,15 @@ const TransitionScale = vue.defineComponent({
702
702
  }
703
703
  });
704
704
 
705
- const COMPONENT_NAME$1r = "vc-transition-slide";
705
+ const COMPONENT_NAME$1u = "vc-transition-slide";
706
706
  const TransitionSlide = vue.defineComponent({
707
- name: COMPONENT_NAME$1r,
707
+ name: COMPONENT_NAME$1u,
708
708
  props: {
709
- ...props$1e,
709
+ ...props$1g,
710
710
  mode: {
711
711
  type: String,
712
712
  default: "left",
713
- validator: (v) => /^(left|right|down|up|none)(|-part)$/.test(v)
713
+ validator: (v) => /^(left|right|top|bottom|none)(|-part)$/.test(v)
714
714
  },
715
715
  // inheritAttrs必须是false
716
716
  style: {
@@ -744,11 +744,11 @@ const TransitionSlide = vue.defineComponent({
744
744
  }
745
745
  });
746
746
 
747
- const COMPONENT_NAME$1q = "vc-transition-zoom";
747
+ const COMPONENT_NAME$1t = "vc-transition-zoom";
748
748
  const TransitionZoom = vue.defineComponent({
749
- name: COMPONENT_NAME$1q,
749
+ name: COMPONENT_NAME$1t,
750
750
  props: {
751
- ...props$1e,
751
+ ...props$1g,
752
752
  mode: {
753
753
  type: String,
754
754
  default: "x",
@@ -788,7 +788,7 @@ const TransitionZoom = vue.defineComponent({
788
788
 
789
789
  /** @jsxImportSource vue */
790
790
 
791
- const COMPONENT_NAME$1p = 'vc-alert';
791
+ const COMPONENT_NAME$1s = 'vc-alert';
792
792
 
793
793
  // [color, borderColor, backgroundColor], -> CSS
794
794
  const THEME_MAP = {
@@ -798,8 +798,8 @@ const THEME_MAP = {
798
798
  warning: ['#ffbf00', '#ffe58f', '#fffbe6']
799
799
  };
800
800
  const Alert = /* @__PURE__ */ vue.defineComponent({
801
- name: COMPONENT_NAME$1p,
802
- props: props$1g,
801
+ name: COMPONENT_NAME$1s,
802
+ props: props$1i,
803
803
  setup(props, {
804
804
  slots,
805
805
  emit
@@ -888,7 +888,7 @@ const Alert = /* @__PURE__ */ vue.defineComponent({
888
888
 
889
889
  const MAlert = Alert;
890
890
 
891
- const props$1d = {
891
+ const props$1f = {
892
892
  tag: {
893
893
  type: String,
894
894
  default: "div"
@@ -897,10 +897,10 @@ const props$1d = {
897
897
 
898
898
  /** @jsxImportSource vue */
899
899
 
900
- const COMPONENT_NAME$1o = 'vc-artboard';
900
+ const COMPONENT_NAME$1r = 'vc-artboard';
901
901
  const Artboard = /* @__PURE__ */ vue.defineComponent({
902
- name: COMPONENT_NAME$1o,
903
- props: props$1d,
902
+ name: COMPONENT_NAME$1r,
903
+ props: props$1f,
904
904
  setup(props, {
905
905
  slots
906
906
  }) {
@@ -914,7 +914,7 @@ const Artboard = /* @__PURE__ */ vue.defineComponent({
914
914
 
915
915
  const MArtboard = Artboard;
916
916
 
917
- const props$1c = {
917
+ const props$1e = {
918
918
  size: {
919
919
  type: Number,
920
920
  default: 28
@@ -938,10 +938,10 @@ const props$1c = {
938
938
 
939
939
  /** @jsxImportSource vue */
940
940
 
941
- const COMPONENT_NAME$1n = 'vc-spin';
941
+ const COMPONENT_NAME$1q = 'vc-spin';
942
942
  const Spin = /* @__PURE__ */ vue.defineComponent({
943
- name: COMPONENT_NAME$1n,
944
- props: props$1c,
943
+ name: COMPONENT_NAME$1q,
944
+ props: props$1e,
945
945
  setup(props, {
946
946
  slots
947
947
  }) {
@@ -975,7 +975,7 @@ const Spin = /* @__PURE__ */ vue.defineComponent({
975
975
  }
976
976
  });
977
977
 
978
- const props$1b = {
978
+ const props$1d = {
979
979
  wait: {
980
980
  type: Number,
981
981
  default: 250
@@ -991,10 +991,10 @@ const props$1b = {
991
991
  exclude: RegExp
992
992
  };
993
993
 
994
- const COMPONENT_NAME$1m = "vc-debounce";
994
+ const COMPONENT_NAME$1p = "vc-debounce";
995
995
  const Debounce = vue.defineComponent({
996
- name: COMPONENT_NAME$1m,
997
- props: props$1b,
996
+ name: COMPONENT_NAME$1p,
997
+ props: props$1d,
998
998
  /**
999
999
  * 不声明emits使得事件被透传放入attrs中, 这样可以让所有的事件透传
1000
1000
  * 如事件onClick
@@ -1035,7 +1035,7 @@ const Debounce = vue.defineComponent({
1035
1035
  }
1036
1036
  });
1037
1037
 
1038
- const props$1a = {
1038
+ const props$1c = {
1039
1039
  tag: {
1040
1040
  type: String,
1041
1041
  default: "button"
@@ -1065,18 +1065,18 @@ const props$1a = {
1065
1065
 
1066
1066
  /** @jsxImportSource vue */
1067
1067
 
1068
- const COMPONENT_NAME$1l = 'vc-button';
1068
+ const COMPONENT_NAME$1o = 'vc-button';
1069
1069
  const Button = /* @__PURE__ */ vue.defineComponent({
1070
- name: COMPONENT_NAME$1l,
1070
+ name: COMPONENT_NAME$1o,
1071
1071
  emits: ['click'],
1072
- props: props$1a,
1072
+ props: props$1c,
1073
1073
  setup(props, {
1074
1074
  slots
1075
1075
  }) {
1076
1076
  const vm = vue.getCurrentInstance();
1077
1077
  const hasSlot = vue.ref(true);
1078
1078
  const isLoading = vue.ref(false);
1079
- const group = vue.inject('button-group', {
1079
+ const group = vue.inject('vc-button-group', {
1080
1080
  size: 'medium',
1081
1081
  vertical: false,
1082
1082
  circle: false
@@ -1126,7 +1126,7 @@ const Button = /* @__PURE__ */ vue.defineComponent({
1126
1126
  }
1127
1127
  });
1128
1128
 
1129
- const props$19 = {
1129
+ const props$1b = {
1130
1130
  vertical: {
1131
1131
  type: Boolean,
1132
1132
  default: false
@@ -1147,14 +1147,14 @@ const props$19 = {
1147
1147
 
1148
1148
  /** @jsxImportSource vue */
1149
1149
 
1150
- const COMPONENT_NAME$1k = 'vc-button-group';
1150
+ const COMPONENT_NAME$1n = 'vc-button-group';
1151
1151
  const ButtonGroup = /* @__PURE__ */ vue.defineComponent({
1152
- name: COMPONENT_NAME$1k,
1153
- props: props$19,
1152
+ name: COMPONENT_NAME$1n,
1153
+ props: props$1b,
1154
1154
  setup(props, {
1155
1155
  slots
1156
1156
  }) {
1157
- vue.provide('button-group', props);
1157
+ vue.provide('vc-button-group', props);
1158
1158
  const classes = vue.computed(() => ({
1159
1159
  'is-vertical': props.vertical,
1160
1160
  'is-circle': props.circle,
@@ -1174,7 +1174,7 @@ const ButtonGroup = /* @__PURE__ */ vue.defineComponent({
1174
1174
  const MButton = Button;
1175
1175
  const MButtonGroup = ButtonGroup;
1176
1176
 
1177
- const props$18 = {
1177
+ const props$1a = {
1178
1178
  tag: {
1179
1179
  type: String,
1180
1180
  default: "div"
@@ -1183,10 +1183,10 @@ const props$18 = {
1183
1183
 
1184
1184
  /** @jsxImportSource vue */
1185
1185
 
1186
- const COMPONENT_NAME$1j = 'vc-calendar';
1186
+ const COMPONENT_NAME$1m = 'vc-calendar';
1187
1187
  const Calendar = /* @__PURE__ */ vue.defineComponent({
1188
- name: COMPONENT_NAME$1j,
1189
- props: props$18,
1188
+ name: COMPONENT_NAME$1m,
1189
+ props: props$1a,
1190
1190
  setup(props, {
1191
1191
  slots
1192
1192
  }) {
@@ -1200,7 +1200,7 @@ const Calendar = /* @__PURE__ */ vue.defineComponent({
1200
1200
 
1201
1201
  const MCalendar = Calendar;
1202
1202
 
1203
- const props$17 = {
1203
+ const props$19 = {
1204
1204
  border: {
1205
1205
  type: Boolean,
1206
1206
  default: true
@@ -1223,10 +1223,10 @@ const props$17 = {
1223
1223
 
1224
1224
  /** @jsxImportSource vue */
1225
1225
 
1226
- const COMPONENT_NAME$1i = 'vc-card';
1226
+ const COMPONENT_NAME$1l = 'vc-card';
1227
1227
  const Card = /* @__PURE__ */ vue.defineComponent({
1228
- name: COMPONENT_NAME$1i,
1229
- props: props$17,
1228
+ name: COMPONENT_NAME$1l,
1229
+ props: props$19,
1230
1230
  setup(props, {
1231
1231
  slots
1232
1232
  }) {
@@ -1252,7 +1252,7 @@ const Card = /* @__PURE__ */ vue.defineComponent({
1252
1252
 
1253
1253
  const MCard = Card;
1254
1254
 
1255
- const props$16 = {
1255
+ const props$18 = {
1256
1256
  tag: {
1257
1257
  type: String,
1258
1258
  default: "div"
@@ -1261,10 +1261,10 @@ const props$16 = {
1261
1261
 
1262
1262
  /** @jsxImportSource vue */
1263
1263
 
1264
- const COMPONENT_NAME$1h = 'vc-carousel';
1264
+ const COMPONENT_NAME$1k = 'vc-carousel';
1265
1265
  const Carousel = /* @__PURE__ */ vue.defineComponent({
1266
- name: COMPONENT_NAME$1h,
1267
- props: props$16,
1266
+ name: COMPONENT_NAME$1k,
1267
+ props: props$18,
1268
1268
  setup(props, {
1269
1269
  slots
1270
1270
  }) {
@@ -1278,7 +1278,7 @@ const Carousel = /* @__PURE__ */ vue.defineComponent({
1278
1278
 
1279
1279
  const MCarousel = Carousel;
1280
1280
 
1281
- const props$15 = {
1281
+ const props$17 = {
1282
1282
  tag: {
1283
1283
  type: String,
1284
1284
  default: "div"
@@ -1287,10 +1287,10 @@ const props$15 = {
1287
1287
 
1288
1288
  /** @jsxImportSource vue */
1289
1289
 
1290
- const COMPONENT_NAME$1g = 'vc-cascader';
1290
+ const COMPONENT_NAME$1j = 'vc-cascader';
1291
1291
  const Cascader = /* @__PURE__ */ vue.defineComponent({
1292
- name: COMPONENT_NAME$1g,
1293
- props: props$15,
1292
+ name: COMPONENT_NAME$1j,
1293
+ props: props$17,
1294
1294
  setup(props, {
1295
1295
  slots
1296
1296
  }) {
@@ -1343,7 +1343,7 @@ const EVENTS = [
1343
1343
  "contextmenu"
1344
1344
  ];
1345
1345
 
1346
- const props$14 = {
1346
+ const props$16 = {
1347
1347
  options: Object,
1348
1348
  pluginOptions: Object,
1349
1349
  theme: [String, Object],
@@ -1355,10 +1355,10 @@ const props$14 = {
1355
1355
 
1356
1356
  /** @jsxImportSource vue */
1357
1357
 
1358
- const COMPONENT_NAME$1f = 'vc-chart';
1358
+ const COMPONENT_NAME$1i = 'vc-chart';
1359
1359
  const Chart = /* @__PURE__ */ vue.defineComponent({
1360
- name: COMPONENT_NAME$1f,
1361
- props: props$14,
1360
+ name: COMPONENT_NAME$1i,
1361
+ props: props$16,
1362
1362
  emits: [...EVENTS, 'ready'],
1363
1363
  setup(props, {
1364
1364
  emit,
@@ -1472,7 +1472,7 @@ const Chart = /* @__PURE__ */ vue.defineComponent({
1472
1472
 
1473
1473
  const MChart = Chart;
1474
1474
 
1475
- const props$13 = {
1475
+ const props$15 = {
1476
1476
  tag: {
1477
1477
  type: String,
1478
1478
  default: "div"
@@ -1481,10 +1481,10 @@ const props$13 = {
1481
1481
 
1482
1482
  /** @jsxImportSource vue */
1483
1483
 
1484
- const COMPONENT_NAME$1e = 'vc-checkbox';
1484
+ const COMPONENT_NAME$1h = 'vc-checkbox';
1485
1485
  const Checkbox = /* @__PURE__ */ vue.defineComponent({
1486
- name: COMPONENT_NAME$1e,
1487
- props: props$13,
1486
+ name: COMPONENT_NAME$1h,
1487
+ props: props$15,
1488
1488
  setup(props, {
1489
1489
  slots
1490
1490
  }) {
@@ -1498,7 +1498,7 @@ const Checkbox = /* @__PURE__ */ vue.defineComponent({
1498
1498
 
1499
1499
  const MCheckbox = Checkbox;
1500
1500
 
1501
- const props$12 = {
1501
+ const props$14 = {
1502
1502
  tag: {
1503
1503
  type: String,
1504
1504
  default: "div"
@@ -1507,10 +1507,10 @@ const props$12 = {
1507
1507
 
1508
1508
  /** @jsxImportSource vue */
1509
1509
 
1510
- const COMPONENT_NAME$1d = 'vc-clipboard';
1510
+ const COMPONENT_NAME$1g = 'vc-clipboard';
1511
1511
  const Clipboard = /* @__PURE__ */ vue.defineComponent({
1512
- name: COMPONENT_NAME$1d,
1513
- props: props$12,
1512
+ name: COMPONENT_NAME$1g,
1513
+ props: props$14,
1514
1514
  setup(props, {
1515
1515
  slots
1516
1516
  }) {
@@ -1524,31 +1524,247 @@ const Clipboard = /* @__PURE__ */ vue.defineComponent({
1524
1524
 
1525
1525
  const MClipboard = Clipboard;
1526
1526
 
1527
+ const props$13 = {
1528
+ tag: {
1529
+ type: String,
1530
+ default: "div"
1531
+ },
1532
+ accordion: {
1533
+ type: Boolean,
1534
+ default: false
1535
+ },
1536
+ modelValue: {
1537
+ type: [Array, String, Number]
1538
+ },
1539
+ alive: {
1540
+ type: Boolean,
1541
+ default: true
1542
+ },
1543
+ // TODO: 添加默认样式
1544
+ styleless: {
1545
+ type: Boolean,
1546
+ default: false
1547
+ }
1548
+ };
1549
+
1550
+ const COMPONENT_NAME$1f = "vc-collapse";
1551
+ const Collapse = vue.defineComponent({
1552
+ name: COMPONENT_NAME$1f,
1553
+ props: props$13,
1554
+ emits: ["update:moodelValue", "change"],
1555
+ setup(props, { slots, emit }) {
1556
+ const instance = vue.getCurrentInstance();
1557
+ const currentValue = vue.ref();
1558
+ const items = vue.ref([]);
1559
+ const sync = () => {
1560
+ const v = props.accordion ? currentValue.value[0] : currentValue.value;
1561
+ emit("update:moodelValue", v);
1562
+ emit("change", v);
1563
+ };
1564
+ const setActive = () => {
1565
+ const activeKey = currentValue.value;
1566
+ vue.nextTick(() => {
1567
+ items.value.forEach((child, index) => {
1568
+ const value = typeof child.props.value !== "undefined" ? child.props.value : index;
1569
+ child.exposed.toggle(activeKey.indexOf(value) > -1);
1570
+ });
1571
+ });
1572
+ };
1573
+ const toggle = (item) => {
1574
+ const activeKey = currentValue.value;
1575
+ const index = activeKey.indexOf(item.value);
1576
+ if (!item.visible) {
1577
+ if (index > -1) {
1578
+ activeKey.splice(index, 1);
1579
+ }
1580
+ } else if (index < 0) {
1581
+ activeKey.push(item.value);
1582
+ }
1583
+ currentValue.value = props.accordion ? activeKey.slice(-1) : activeKey;
1584
+ sync();
1585
+ };
1586
+ const add = (item, setValue) => {
1587
+ if (!item) return;
1588
+ vue.nextTick(() => {
1589
+ if (instance.vnode.el) {
1590
+ const index = Array.from(instance.vnode.el.children).filter((i) => /vcm?-collapse-item/.test(i.className)).indexOf(item.vnode.el);
1591
+ if (index != -1) {
1592
+ items.value.splice(index, 0, item);
1593
+ typeof item.props.value === "undefined" && setValue(index);
1594
+ return;
1595
+ }
1596
+ }
1597
+ items.value.push(item);
1598
+ typeof item.props.value === "undefined" && setValue(items.value.length - 1);
1599
+ });
1600
+ };
1601
+ const remove = (item, setValue) => {
1602
+ if (!item) return;
1603
+ items.value.splice(items.value.indexOf(item), 1);
1604
+ items.value.forEach((_, index) => setValue(index));
1605
+ };
1606
+ vue.provide("vc-collapse", {
1607
+ props,
1608
+ toggle,
1609
+ add,
1610
+ remove
1611
+ });
1612
+ vue.watch(
1613
+ () => props.modelValue,
1614
+ (v) => {
1615
+ if (v === currentValue.value) return;
1616
+ currentValue.value = props.accordion && typeof v !== "undefined" ? Array.isArray(v) ? v : [v] : Array.isArray(v) ? v : [];
1617
+ },
1618
+ { immediate: true }
1619
+ );
1620
+ vue.watch(
1621
+ () => currentValue.value,
1622
+ setActive,
1623
+ { deep: true }
1624
+ );
1625
+ vue.onMounted(setActive);
1626
+ return () => {
1627
+ return vue.h(
1628
+ props.tag,
1629
+ {
1630
+ class: [{ "vc-collapse": !props.styleless }]
1631
+ },
1632
+ slots.default?.()
1633
+ );
1634
+ };
1635
+ }
1636
+ });
1637
+
1638
+ const props$12 = {
1639
+ tag: {
1640
+ type: String,
1641
+ default: "div"
1642
+ },
1643
+ value: {
1644
+ type: [String, Number]
1645
+ }
1646
+ };
1647
+
1527
1648
  const props$11 = {
1528
1649
  tag: {
1529
1650
  type: String,
1530
1651
  default: "div"
1652
+ },
1653
+ modelValue: {
1654
+ type: Boolean,
1655
+ default: false
1656
+ },
1657
+ // 子节点每次toggle不销毁
1658
+ alive: {
1659
+ type: Boolean,
1660
+ default: true
1531
1661
  }
1532
1662
  };
1533
1663
 
1534
1664
  /** @jsxImportSource vue */
1535
1665
 
1536
- const COMPONENT_NAME$1c = 'vc-collapse';
1537
- const Collapse = /* @__PURE__ */ vue.defineComponent({
1538
- name: COMPONENT_NAME$1c,
1666
+ function _isSlot$2(s) {
1667
+ return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !vue.isVNode(s);
1668
+ }
1669
+ const COMPONENT_NAME$1e = 'vc-expand';
1670
+ const Expand = /* @__PURE__ */ vue.defineComponent({
1671
+ name: COMPONENT_NAME$1e,
1539
1672
  props: props$11,
1540
1673
  setup(props, {
1541
1674
  slots
1542
1675
  }) {
1676
+ const isActive = vue.ref(false);
1677
+ const Content = props.tag;
1678
+ vue.watch(() => props.modelValue, v => {
1679
+ isActive.value = v;
1680
+ }, {
1681
+ immediate: true
1682
+ });
1543
1683
  return () => {
1544
- return vue.createVNode("div", {
1545
- "class": "vc-collapse"
1546
- }, [slots?.default?.()]);
1684
+ let _slot;
1685
+ return vue.createVNode(TransitionCollapse, {
1686
+ "duration": {
1687
+ enter: 200,
1688
+ leave: 200
1689
+ }
1690
+ }, _isSlot$2(_slot = vue.withDirectives(vue.createVNode(Content, null, {
1691
+ default: () => [(props.alive || !props.alive && isActive.value) && slots.default?.()]
1692
+ }), [[vue.vShow, isActive.value]])) ? _slot : {
1693
+ default: () => [_slot]
1694
+ });
1695
+ };
1696
+ }
1697
+ });
1698
+
1699
+ /** @jsxImportSource vue */
1700
+
1701
+ const COMPONENT_NAME$1d = 'vc-collapse-item';
1702
+ const CollapseItem = /* @__PURE__ */ vue.defineComponent({
1703
+ name: COMPONENT_NAME$1d,
1704
+ props: props$12,
1705
+ setup(props, {
1706
+ slots,
1707
+ expose
1708
+ }) {
1709
+ const Content = props.tag;
1710
+ const instance = vue.getCurrentInstance();
1711
+ const isActive = vue.ref(false);
1712
+ const current = vue.ref();
1713
+ const collapse = vue.inject('vc-collapse');
1714
+ const handleToggle = () => {
1715
+ collapse.toggle({
1716
+ value: typeof props.value !== 'undefined' ? props.value : current.value,
1717
+ visible: !isActive.value
1718
+ });
1719
+ };
1720
+ const alive = vue.computed(() => {
1721
+ return collapse.props.alive;
1722
+ });
1723
+ const styleless = vue.computed(() => {
1724
+ return collapse.props.styleless;
1725
+ });
1726
+ const setValue = v => current.value = v;
1727
+ vue.onBeforeMount(() => {
1728
+ collapse.add?.(instance, setValue);
1729
+ });
1730
+ vue.onBeforeUnmount(() => {
1731
+ collapse.remove?.(instance, setValue);
1732
+ });
1733
+ expose({
1734
+ isActive,
1735
+ toggle: v => isActive.value = v
1736
+ });
1737
+ return () => {
1738
+ return vue.createVNode(Content, {
1739
+ "class": [{
1740
+ 'vc-collapse-item': !styleless.value
1741
+ }]
1742
+ }, {
1743
+ default: () => [vue.createVNode("div", {
1744
+ "class": [{
1745
+ 'vc-collapse-item__title': !styleless.value
1746
+ }],
1747
+ "onClick": handleToggle
1748
+ }, [slots.default?.(), slots.icon?.({
1749
+ visible: isActive.value
1750
+ })]), vue.createVNode(Expand, {
1751
+ "modelValue": isActive.value,
1752
+ "alive": alive.value,
1753
+ "onChange": v => isActive.value = v
1754
+ }, {
1755
+ default: () => [vue.createVNode("div", {
1756
+ "class": [{
1757
+ 'vc-collapse-item__content': !styleless.value
1758
+ }]
1759
+ }, [slots.content?.()])]
1760
+ })]
1761
+ });
1547
1762
  };
1548
1763
  }
1549
1764
  });
1550
1765
 
1551
1766
  const MCollapse = Collapse;
1767
+ const MCollapseItem = CollapseItem;
1552
1768
 
1553
1769
  const props$10 = {
1554
1770
  tag: {
@@ -1559,9 +1775,9 @@ const props$10 = {
1559
1775
 
1560
1776
  /** @jsxImportSource vue */
1561
1777
 
1562
- const COMPONENT_NAME$1b = 'vc-color-picker';
1778
+ const COMPONENT_NAME$1c = 'vc-color-picker';
1563
1779
  const ColorPicker = /* @__PURE__ */ vue.defineComponent({
1564
- name: COMPONENT_NAME$1b,
1780
+ name: COMPONENT_NAME$1c,
1565
1781
  props: props$10,
1566
1782
  setup(props, {
1567
1783
  slots
@@ -1585,9 +1801,9 @@ const props$$ = {
1585
1801
 
1586
1802
  /** @jsxImportSource vue */
1587
1803
 
1588
- const COMPONENT_NAME$1a = 'vc-countdown';
1804
+ const COMPONENT_NAME$1b = 'vc-countdown';
1589
1805
  const Countdown = /* @__PURE__ */ vue.defineComponent({
1590
- name: COMPONENT_NAME$1a,
1806
+ name: COMPONENT_NAME$1b,
1591
1807
  props: props$$,
1592
1808
  setup(props, {
1593
1809
  slots
@@ -1609,9 +1825,9 @@ const props$_ = {
1609
1825
  }
1610
1826
  };
1611
1827
 
1612
- const COMPONENT_NAME$19 = "vc-customer";
1828
+ const COMPONENT_NAME$1a = "vc-customer";
1613
1829
  const Customer = vue.defineComponent({
1614
- name: COMPONENT_NAME$19,
1830
+ name: COMPONENT_NAME$1a,
1615
1831
  props: props$_,
1616
1832
  setup(props, context) {
1617
1833
  return () => vue.h(() => {
@@ -1631,9 +1847,9 @@ const props$Z = {
1631
1847
 
1632
1848
  /** @jsxImportSource vue */
1633
1849
 
1634
- const COMPONENT_NAME$18 = 'vc-date-picker';
1850
+ const COMPONENT_NAME$19 = 'vc-date-picker';
1635
1851
  const DatePicker = /* @__PURE__ */ vue.defineComponent({
1636
- name: COMPONENT_NAME$18,
1852
+ name: COMPONENT_NAME$19,
1637
1853
  props: props$Z,
1638
1854
  setup(props, {
1639
1855
  slots
@@ -1657,9 +1873,9 @@ const props$Y = {
1657
1873
 
1658
1874
  /** @jsxImportSource vue */
1659
1875
 
1660
- const COMPONENT_NAME$17 = 'vc-divider';
1876
+ const COMPONENT_NAME$18 = 'vc-divider';
1661
1877
  const Divider = /* @__PURE__ */ vue.defineComponent({
1662
- name: COMPONENT_NAME$17,
1878
+ name: COMPONENT_NAME$18,
1663
1879
  props: props$Y,
1664
1880
  setup(props, {
1665
1881
  slots
@@ -1674,1090 +1890,1286 @@ const Divider = /* @__PURE__ */ vue.defineComponent({
1674
1890
 
1675
1891
  const MDivider = Divider;
1676
1892
 
1677
- const props$X = {
1678
- tag: {
1679
- type: String,
1680
- default: "div"
1681
- }
1682
- };
1683
-
1684
- /** @jsxImportSource vue */
1685
-
1686
- const COMPONENT_NAME$16 = 'vc-drawer';
1687
- const Drawer = /* @__PURE__ */ vue.defineComponent({
1688
- name: COMPONENT_NAME$16,
1689
- props: props$X,
1690
- setup(props, {
1691
- slots
1692
- }) {
1693
- return () => {
1694
- return vue.createVNode("div", {
1695
- "class": "vc-drawer"
1696
- }, [slots?.default?.()]);
1697
- };
1698
- }
1699
- });
1700
-
1701
- const MDrawer = Drawer;
1702
-
1703
- const props$W = {
1704
- tag: {
1705
- type: String,
1706
- default: "div"
1707
- }
1708
- };
1709
-
1710
- /** @jsxImportSource vue */
1711
-
1712
- const COMPONENT_NAME$15 = 'vc-dropdown';
1713
- const Dropdown = /* @__PURE__ */ vue.defineComponent({
1714
- name: COMPONENT_NAME$15,
1715
- props: props$W,
1716
- setup(props, {
1717
- slots
1718
- }) {
1719
- return () => {
1720
- return vue.createVNode("div", {
1721
- "class": "vc-dropdown"
1722
- }, [slots?.default?.()]);
1723
- };
1724
- }
1725
- });
1726
-
1727
- const MDropdown = Dropdown;
1728
-
1729
- const props$V = {
1730
- tag: {
1731
- type: String,
1732
- default: "div"
1733
- }
1893
+ const defaults = {
1894
+ tag: "div",
1895
+ el: "body",
1896
+ alive: false,
1897
+ multiple: false,
1898
+ aliveRegExp: { className: /(vc-hack-alive|vc-hack-cp)/ },
1899
+ aliveVisibleKey: "isVisible",
1900
+ aliveUpdateKey: "update",
1901
+ leaveDelay: 300,
1902
+ autoDestroy: true,
1903
+ components: {},
1904
+ uses: {},
1905
+ fragment: false,
1906
+ insertion: "last"
1734
1907
  };
1735
1908
 
1736
- /** @jsxImportSource vue */
1737
-
1738
- const COMPONENT_NAME$14 = 'vc-editor';
1739
- const Editor = /* @__PURE__ */ vue.defineComponent({
1740
- name: COMPONENT_NAME$14,
1741
- props: props$V,
1742
- setup(props, {
1743
- slots
1744
- }) {
1745
- return () => {
1746
- return vue.createVNode("div", {
1747
- "class": "vc-editor"
1748
- }, [slots?.default?.()]);
1909
+ class PortalLeaf {
1910
+ app;
1911
+ /**
1912
+ * 目标的实例,挂载到app上
1913
+ */
1914
+ wrapper;
1915
+ propsData;
1916
+ /**
1917
+ * 销毁的函数,挂载到app上,避免冲突
1918
+ */
1919
+ destroy;
1920
+ /**
1921
+ * 自动销毁的标记,挂载到app上,避免冲突
1922
+ */
1923
+ autoDestroy;
1924
+ target;
1925
+ constructor(target) {
1926
+ this.target = target;
1927
+ this.autoDestroy = false;
1928
+ this.destroy = /* istanbul ignore next */
1929
+ () => {
1930
+ throw new VcError("portal", "未注册的destroy方法");
1749
1931
  };
1750
1932
  }
1751
- });
1752
-
1753
- const MEditor = Editor;
1754
-
1755
- const props$U = {
1756
- tag: {
1757
- type: String,
1758
- default: "div"
1933
+ then(resolve, reject) {
1934
+ return this.target.then(resolve, reject);
1759
1935
  }
1760
- };
1761
-
1762
- /** @jsxImportSource vue */
1763
-
1764
- const COMPONENT_NAME$13 = 'vc-expand';
1765
- const Expand = /* @__PURE__ */ vue.defineComponent({
1766
- name: COMPONENT_NAME$13,
1767
- props: props$U,
1768
- setup(props, {
1769
- slots
1770
- }) {
1771
- return () => {
1772
- return vue.createVNode("div", {
1773
- "class": "vc-expand"
1774
- }, [slots?.default?.()]);
1775
- };
1936
+ catch(callback) {
1937
+ return this.target.catch(callback);
1776
1938
  }
1777
- });
1778
-
1779
- const MExpand = Expand;
1780
-
1781
- const props$T = {
1782
- tag: {
1783
- type: String,
1784
- default: "form"
1785
- },
1786
- model: {
1787
- type: Object
1788
- },
1789
- rules: {
1790
- type: Object
1791
- },
1792
- labelWidth: {
1793
- type: Number
1794
- },
1795
- showMessage: {
1796
- type: Boolean,
1797
- default: true
1798
- },
1799
- inline: {
1800
- type: Boolean,
1801
- default: false
1802
- },
1803
- labelPosition: {
1804
- type: String,
1805
- default: "right"
1806
- },
1807
- autocomplete: {
1808
- type: String,
1809
- default: "off"
1810
- },
1811
- styleless: {
1812
- type: Boolean,
1813
- default: false
1939
+ finally(callback) {
1940
+ return this.target.finally(callback);
1814
1941
  }
1815
- };
1942
+ }
1816
1943
 
1817
- const useForm = (expose, options = {}) => {
1818
- const instance = vue.getCurrentInstance();
1819
- const props = instance.props;
1820
- const fields = [];
1821
- vue.provide("form", {
1822
- props,
1823
- add: (field) => {
1824
- field && fields.push(field);
1825
- },
1826
- remove: (field) => {
1827
- field && fields.splice(fields.indexOf(field), 1);
1828
- }
1829
- });
1830
- const filterFields = (fields$) => {
1831
- return !fields$ ? fields : fields.filter((item) => fields$.includes(item.props.prop));
1832
- };
1833
- const getField = (prop) => {
1834
- const field = fields.find((item) => item.props.prop === prop);
1835
- if (!field) throw new VcError("form", "请选择有用的prop值");
1836
- return field;
1837
- };
1838
- const showToast = (msg) => {
1839
- props.showMessage && options.throwToast?.(msg);
1840
- };
1841
- const sortErrors = async (errors) => {
1842
- const positions = await Promise.all(fields.map((item) => item.exposed.getPosition()));
1944
+ const COMPONENT_NAME$17 = "vc-portal";
1945
+ class Portal {
1946
+ /**
1947
+ * 清理Portals类型组件
1948
+ * @param name 清理的组件名, boolean表示全部leafs是否强制清理
1949
+ */
1950
+ static clear(name) {
1843
1951
  try {
1844
- return [...errors].toSorted((a, b) => {
1845
- const aIndex = fields.findIndex((i) => i.props.prop === a.prop);
1846
- const bIndex = fields.findIndex((i) => i.props.prop === b.prop);
1847
- const aPosition = positions[aIndex];
1848
- const bPosition = positions[bIndex];
1849
- if (aPosition.top != bPosition.top) return aPosition.top - bPosition.top;
1850
- return aPosition.left - bPosition.left;
1851
- });
1852
- } catch (e) {
1853
- return errors;
1854
- }
1855
- };
1856
- const scrollIntoView = (prop) => {
1857
- const field = getField(prop);
1858
- field.vnode?.el?.scrollIntoView?.({
1859
- behavior: "smooth",
1860
- block: "center"
1861
- });
1862
- };
1863
- const reset = (options$ = {}) => {
1864
- const { fields: fields$, original = {} } = options$;
1865
- filterFields(fields$).forEach((field) => {
1866
- let v;
1867
- try {
1868
- v = Utils.getPropByPath(original, field.props.prop).v;
1869
- } catch (e) {
1952
+ let force = false;
1953
+ let target = /* @__PURE__ */ new Map();
1954
+ if (name && typeof name !== "boolean") {
1955
+ let names = [];
1956
+ if (typeof name === "string") {
1957
+ names = [name];
1958
+ } else if (name instanceof Array && name.length > 0) {
1959
+ names = name;
1960
+ }
1961
+ names.forEach((i) => target.set(i, ""));
1962
+ force = true;
1963
+ } else {
1964
+ force = !!name;
1965
+ target = Portal.leafs;
1966
+ }
1967
+ for (const key of target.keys()) {
1968
+ const leaf = Portal.leafs.get(key);
1969
+ if (leaf && (force === true || leaf.autoDestroy === true)) {
1970
+ leaf.destroy();
1971
+ }
1870
1972
  }
1871
- field.exposed.reset(v);
1872
- });
1873
- };
1874
- const validate = async (options$ = {}) => {
1875
- const { scroll = true, fields: fields$ } = options$;
1876
- if (!fields.length) {
1877
- return;
1878
- }
1879
- const results = await Promise.allSettled(
1880
- filterFields(fields$).map((item) => item.exposed.validate(""))
1881
- );
1882
- const originErrors = results.filter((i) => i.status === "rejected").map((i) => i.reason);
1883
- if (!originErrors.length) return;
1884
- const errors = await sortErrors(originErrors);
1885
- showToast(errors[0].msg || errors[0].message);
1886
- scroll && scrollIntoView(errors[0].prop);
1887
- throw errors;
1888
- };
1889
- const validateField = async (prop, options$ = {}) => {
1890
- try {
1891
- await validate({
1892
- ...options$,
1893
- fields: [prop]
1894
- });
1895
1973
  } catch (e) {
1896
- throw e[0];
1974
+ /* istanbul ignore next -- @preserve */
1975
+ throw new VcError("instance", e);
1897
1976
  }
1898
- };
1899
- expose({
1900
- reset,
1901
- validate,
1902
- // 单个操作
1903
- getField,
1904
- validateField
1905
- });
1906
- };
1907
-
1908
- const COMPONENT_NAME$12 = "vc-form";
1909
- const Form = vue.defineComponent({
1910
- name: COMPONENT_NAME$12,
1911
- props: props$T,
1912
- setup(props, { slots, expose }) {
1913
- useForm(expose);
1914
- return () => {
1915
- return vue.h(
1916
- props.tag,
1917
- {
1918
- class: "vc-form",
1919
- autocomplete: props.autocomplete
1920
- },
1921
- slots
1922
- );
1923
- };
1924
1977
  }
1925
- });
1926
-
1927
- const props$S = {
1928
- label: {
1929
- type: String,
1930
- default: ""
1931
- },
1932
- labelWidth: {
1933
- type: Number
1934
- },
1935
- prop: {
1936
- type: String
1937
- },
1938
- required: {
1939
- type: [Boolean, String],
1940
- default: false
1941
- },
1942
- error: {
1943
- type: String
1944
- },
1945
- rules: {
1946
- type: [Array, Object]
1947
- },
1948
- resetByRulesChanged: {
1949
- type: Boolean,
1950
- default: false
1951
- },
1952
- showMessage: {
1953
- type: Boolean,
1954
- default: true
1955
- },
1956
- labelFor: {
1957
- type: String
1958
- },
1959
- styleless: {
1960
- type: Boolean,
1961
- default: false
1962
- },
1963
- labelPosition: {
1964
- type: String,
1965
- default: "right"
1966
- },
1967
- contentStyle: String
1968
- };
1969
-
1970
- const filterEmpty = (val) => {
1971
- if (val instanceof Array) {
1972
- val = val.filter((i) => i !== "");
1978
+ /**
1979
+ * 清理全部Portals
1980
+ */
1981
+ static clearAll() {
1982
+ try {
1983
+ Portal.leafs.forEach((leaf) => leaf.destroy());
1984
+ } catch (e) {
1985
+ /* istanbul ignore next -- @preserve */
1986
+ throw new VcError("instance", e);
1987
+ }
1973
1988
  }
1974
- return val;
1975
- };
1976
- const toRules = (rules) => {
1977
- return rules instanceof Array ? rules : rules ? [rules] : [];
1978
- };
1979
- const useFormItem = (expose) => {
1980
- const form = vue.inject("form");
1981
- const instance = vue.getCurrentInstance();
1982
- const props = instance.props;
1983
- const { slots } = instance;
1984
- if (!form?.props) {
1985
- throw new VcError("form-item", "form-item需要在form内使用");
1989
+ static leafs = /* @__PURE__ */ new Map();
1990
+ wrapper;
1991
+ globalOptions;
1992
+ constructor(wrapper, options) {
1993
+ this.wrapper = wrapper;
1994
+ this.globalOptions = {
1995
+ ...options,
1996
+ name: options?.name || wrapper.name || Utils__namespace.getUid(COMPONENT_NAME$17)
1997
+ };
1986
1998
  }
1987
- const formItem = vue.inject("form-item", {});
1988
- const validateState = vue.ref("");
1989
- const validateMessage = vue.ref("");
1990
- let validateDisabled = false;
1991
- let initialValue;
1992
- const currentRules = vue.computed(() => {
1993
- const formRules = form.props.rules;
1994
- const formItemBindRules = toRules(props.rules);
1995
- let formItemRules = formItemBindRules;
1996
- if (!formItemRules.length && formRules && props.prop) {
1997
- try {
1998
- const key = props.prop.replace(/\.[0-9]+\./g, ".");
1999
- const { v } = Utils.getPropByPath(formRules, key);
2000
- formItemRules = toRules(v);
2001
- } catch {
2002
- const rules = formRules[props.prop];
2003
- formItemRules = toRules(rules);
2004
- }
2005
- }
2006
- return formItemRules;
2007
- });
2008
- const isRequired = vue.computed(() => {
2009
- if (!currentRules.value.length) {
2010
- return !!props.required;
1999
+ popup(propsData, options) {
2000
+ if (!options) {
2001
+ options = propsData || {};
2002
+ } else {
2003
+ options.propsData = propsData;
2011
2004
  }
2012
- let required = false;
2013
- for (let i = 0; i < currentRules.value.length; i++) {
2014
- const rule = currentRules.value[i];
2015
- required = !!rule.required;
2016
- if (required) break;
2005
+ const $options = { ...this.getDefaultOptions(), ...options };
2006
+ const { onFulfilled, onRejected, ...rest } = $options;
2007
+ let onFulfilled$ = (
2008
+ /* istanbul ignore next -- @preserve */
2009
+ () => {
2010
+ }
2011
+ );
2012
+ let onRejected$ = (
2013
+ /* istanbul ignore next -- @preserve */
2014
+ () => {
2015
+ }
2016
+ );
2017
+ const target = new Promise((resolve, reject) => {
2018
+ onFulfilled$ = (v) => {
2019
+ onFulfilled?.(v);
2020
+ resolve(v);
2021
+ };
2022
+ onRejected$ = (v) => {
2023
+ onRejected?.(v);
2024
+ reject(v);
2025
+ };
2026
+ });
2027
+ return this.render(rest, target, onFulfilled$, onRejected$);
2028
+ }
2029
+ /**
2030
+ * 销毁当前Portal下的节点
2031
+ * @param target [description]
2032
+ */
2033
+ destroy = (target) => {
2034
+ const { multiple, name } = this.getDefaultOptions();
2035
+ target = target || name;
2036
+ const instance = typeof target === "object" ? target : Portal.leafs.get(target);
2037
+ if (instance) {
2038
+ instance.destroy();
2039
+ } else if (multiple) {
2040
+ Portal.leafs.forEach((item, key) => {
2041
+ if (key.includes(name)) {
2042
+ item.destroy();
2043
+ }
2044
+ });
2017
2045
  }
2018
- return required;
2019
- });
2020
- const labelPosition = vue.computed(() => {
2021
- return props.labelPosition || form.props.labelPosition;
2022
- });
2023
- const classes = vue.computed(() => {
2046
+ };
2047
+ getDefaultOptions() {
2024
2048
  return {
2025
- "is-require": isRequired.value,
2026
- "is-error": validateState.value === "error",
2027
- "is-validating": validateState.value === "validating",
2028
- "is-inline": form.props.inline,
2029
- "is-nest": isNest.value,
2030
- [`is-${labelPosition.value}`]: true
2049
+ ...defaults,
2050
+ ...VcInstance.options.Portal,
2051
+ ...this.globalOptions
2031
2052
  };
2032
- });
2033
- const isNest = vue.computed(() => {
2034
- return !!formItem.change;
2035
- });
2036
- const isNestLast = vue.ref(false);
2037
- const hasLabel = vue.computed(() => {
2038
- return !!props.label || slots.label;
2039
- });
2040
- const labelStyle = vue.computed(() => {
2041
- const labelWidth = props.labelWidth === 0 || props.labelWidth ? props.labelWidth : isNest.value ? 0 : form.props.labelWidth;
2042
- return {
2043
- width: labelPosition.value !== "top" && labelWidth && labelWidth > 0 ? `${labelWidth}px` : "auto",
2044
- textAlign: labelPosition.value === "top" ? "left" : labelPosition.value
2053
+ }
2054
+ createCallback(getLeaf, delay, callback) {
2055
+ return (...args) => {
2056
+ const done = () => {
2057
+ const leaf = getLeaf();
2058
+ /* istanbul ignore next -- @preserve */
2059
+ if (!leaf) {
2060
+ throw new VcError("portal", "实例不存在或已卸载");
2061
+ }
2062
+ leaf.destroy();
2063
+ };
2064
+ delay ? setTimeout(done, delay) : done();
2065
+ callback?.(...args);
2045
2066
  };
2046
- });
2047
- const contentStyle = vue.computed(() => {
2048
- const labelWidth = props.labelWidth === 0 || props.labelWidth ? props.labelWidth : form.props.labelWidth;
2049
- return [
2050
- {
2051
- marginLeft: !hasLabel.value && isNest.value ? 0 : labelWidth && labelWidth > 0 ? `${labelWidth}px` : "unset",
2052
- marginBottom: isNest.value && !isNestLast.value ? `20px` : 0
2053
- },
2054
- props.contentStyle
2055
- ];
2056
- });
2057
- const isStyleless = vue.computed(() => {
2058
- return props.styleless || form.props.styleless;
2059
- });
2060
- const fieldValue = vue.computed(() => {
2061
- const model = form.props.model;
2062
- if (!model || !props.prop) {
2063
- return;
2064
- }
2065
- let path = props.prop;
2066
- if (path.includes(":")) {
2067
- path = path.replace(/:/, ".");
2068
- }
2069
- return Utils.getPropByPath(model, path).v;
2070
- });
2071
- const showError = vue.computed(() => {
2072
- return validateState.value === "error" && props.showMessage && form.props.showMessage;
2073
- });
2074
- vue.watch(
2075
- () => props.error,
2076
- (v) => {
2077
- validateMessage.value = v || "";
2078
- validateState.value = v === "" ? "" : "error";
2079
- }
2080
- );
2081
- const reset = (v) => {
2082
- validateState.value = "";
2083
- validateMessage.value = "";
2084
- const model = form.props.model;
2085
- if (!props.prop) return;
2086
- const { o, k } = Utils.getPropByPath(model, props.prop);
2087
- if (!k) return;
2088
- validateDisabled = true;
2089
- o[k] = v !== null && v !== void 0 ? v : Array.isArray(fieldValue.value) ? [].concat(initialValue) : initialValue;
2090
- };
2091
- const validate = async (trigger) => {
2092
- if (!props.prop) return;
2093
- let rules = currentRules.value.filter((rule) => !rule.trigger || rule.trigger.includes(trigger));
2094
- if (!rules.length) {
2095
- if (!props.required) {
2096
- return;
2097
- } else {
2098
- rules = [{
2099
- required: true,
2100
- message: typeof props.required === "string" ? props.required : void 0
2101
- }];
2067
+ }
2068
+ render(options, target, onFulfilled, onRejected) {
2069
+ const {
2070
+ el,
2071
+ tag,
2072
+ alive,
2073
+ aliveRegExp,
2074
+ aliveVisibleKey,
2075
+ aliveUpdateKey,
2076
+ name: name$,
2077
+ leaveDelay,
2078
+ autoDestroy,
2079
+ multiple,
2080
+ fragment,
2081
+ onDestroyed,
2082
+ onBeforeCreate,
2083
+ insertion,
2084
+ // 全局注册
2085
+ globalProperties,
2086
+ install,
2087
+ components,
2088
+ uses,
2089
+ slots,
2090
+ parent,
2091
+ propsData,
2092
+ ...rest
2093
+ } = options;
2094
+ let useAllNodes = fragment;
2095
+ const name = multiple ? `${name$}__${Utils__namespace.getUid(COMPONENT_NAME$17)}` : name$;
2096
+ const container = document.createElement(tag);
2097
+ const root = typeof el === "object" ? el : document.querySelector(el || "body");
2098
+ !alive && Portal.leafs.get(name)?.destroy();
2099
+ const propsData$ = propsData || rest;
2100
+ let leaf = new PortalLeaf(target);
2101
+ const isDestroyed = () => {
2102
+ const leaf$ = Portal.leafs.get(name);
2103
+ return !leaf$ || leaf$ !== leaf;
2104
+ };
2105
+ const $onDestroyed = (...args) => {
2106
+ if (isDestroyed()) return;
2107
+ onDestroyed?.(...args);
2108
+ leaf.app?.unmount();
2109
+ /* istanbul ignore else -- @preserve */
2110
+ if (useAllNodes) {
2111
+ root?.contains(container) && root.removeChild(container);
2112
+ } else if (container && container._children) {
2113
+ container._children.forEach((i) => {
2114
+ root?.contains(i) && root.removeChild(i);
2115
+ });
2102
2116
  }
2103
- }
2104
- validateState.value = "validating";
2105
- const descriptor = {};
2106
- descriptor[props.prop] = rules;
2107
- const validator = new helperValidator.Validator(descriptor);
2108
- const model = {};
2109
- model[props.prop] = filterEmpty(fieldValue.value);
2110
- try {
2111
- await validator.validate(model, { first: false });
2112
- validateState.value = "success";
2113
- validateMessage.value = "";
2114
- } catch (errors) {
2115
- validateState.value = "error";
2116
- validateMessage.value = errors[0].message;
2117
- throw {
2118
- prop: props.prop,
2119
- message: validateMessage.value
2120
- };
2121
- }
2122
- validateDisabled = false;
2123
- };
2124
- const handleFieldBlur = () => {
2125
- if (!props.prop) {
2126
- formItem.blur?.();
2127
- return;
2128
- }
2129
- validate("blur");
2130
- };
2131
- const handleFieldChange = () => {
2132
- if (!props.prop) {
2133
- formItem.change?.();
2134
- return;
2135
- }
2136
- if (validateDisabled) {
2137
- validateDisabled = false;
2138
- return;
2139
- }
2140
- validate("change");
2141
- };
2142
- const getPosition = async () => {
2143
- let el = instance.vnode.el;
2144
- try {
2145
- while (el && !el.getBoundingClientRect) {
2146
- el = el.nextSibling;
2117
+ Portal.leafs.delete(name);
2118
+ };
2119
+ const $onRejected = this.createCallback(() => leaf, leaveDelay, onRejected);
2120
+ const $onFulfilled = this.createCallback(() => leaf, leaveDelay, onFulfilled);
2121
+ if (alive && Portal.leafs.has(name)) {
2122
+ leaf = Portal.leafs.get(name);
2123
+ leaf.target = target;
2124
+ leaf.propsData.value = propsData$;
2125
+ leaf.wrapper?.[aliveUpdateKey]?.(options);
2126
+ } else {
2127
+ const wrapper = this.wrapper;
2128
+ const app = vue.createApp({
2129
+ name: COMPONENT_NAME$17,
2130
+ parent,
2131
+ setup() {
2132
+ if (alive) {
2133
+ const handleExtra = (e) => {
2134
+ try {
2135
+ const path = e.path || $__namespace.composedPath(e);
2136
+ /* istanbul ignore else -- @preserve */
2137
+ if (container && e.target && !container.contains(e.target) && !path?.some((item) => vcShared.Utils.eleInRegExp(item, aliveRegExp))) {
2138
+ /* istanbul ignore else -- @preserve */
2139
+ if (leaf.wrapper && leaf.wrapper?.[aliveVisibleKey]) {
2140
+ leaf.wrapper[aliveVisibleKey] = false;
2141
+ }
2142
+ leaveDelay ? setTimeout($onDestroyed, leaveDelay) : $onDestroyed();
2143
+ }
2144
+ } catch (error) {
2145
+ /* istanbul ignore next -- @preserve */
2146
+ throw new VcError("portal", error);
2147
+ }
2148
+ };
2149
+ vue.onMounted(() => {
2150
+ document.addEventListener("click", handleExtra, true);
2151
+ });
2152
+ vue.onBeforeUnmount(() => {
2153
+ document.removeEventListener("click", handleExtra, true);
2154
+ });
2155
+ }
2156
+ const propsData1 = vue.ref(propsData$);
2157
+ const propsData2 = vue.ref();
2158
+ leaf.propsData = propsData1;
2159
+ const allowMounted = vue.ref(typeof onBeforeCreate !== "function");
2160
+ if (!allowMounted.value) {
2161
+ const result = onBeforeCreate(propsData$);
2162
+ if (result && result.then) {
2163
+ result.then((response) => {
2164
+ if (isDestroyed()) return;
2165
+ allowMounted.value = true;
2166
+ propsData2.value = response;
2167
+ }).catch((error) => {
2168
+ $onDestroyed(error);
2169
+ });
2170
+ } else {
2171
+ allowMounted.value = true;
2172
+ propsData2.value = result;
2173
+ }
2174
+ }
2175
+ return () => allowMounted.value && vue.h(
2176
+ wrapper,
2177
+ {
2178
+ ...propsData1.value,
2179
+ ...propsData2.value,
2180
+ ref: (vm) => leaf.wrapper = vm,
2181
+ onPortalFulfilled: (...args) => $onFulfilled(...args),
2182
+ onPortalRejected: (...args) => $onRejected(...args),
2183
+ onPortalDestroyed: (...args) => $onDestroyed(...args)
2184
+ },
2185
+ slots || void 0
2186
+ );
2187
+ }
2188
+ });
2189
+ leaf.app = app;
2190
+ if (globalProperties) {
2191
+ app.config.globalProperties = globalProperties;
2147
2192
  }
2148
- ;
2149
- const rect = el.getBoundingClientRect();
2150
- return {
2151
- top: rect.top,
2152
- left: rect.left
2153
- };
2154
- } catch (e) {
2155
- throw new VcError("form-item", "form-item位置计算错误");
2156
- }
2157
- };
2158
- const fields = vue.reactive([]);
2159
- vue.provide("form-item", {
2160
- fields,
2161
- blur: handleFieldBlur,
2162
- change: handleFieldChange,
2163
- message: validateMessage,
2164
- add: (field) => {
2165
- field && fields.push(field);
2166
- },
2167
- remove: (field) => {
2168
- field && fields.splice(fields.indexOf(field), 1);
2169
- }
2170
- });
2171
- vue.onMounted(() => {
2172
- if (props.prop) {
2173
- form.add?.(instance);
2174
- initialValue = lodashEs.cloneDeep(fieldValue.value);
2175
- }
2176
- formItem.add?.(instance);
2177
- });
2178
- vue.onBeforeUnmount(() => {
2179
- form.remove?.(instance);
2180
- formItem.remove?.(instance);
2181
- });
2182
- vue.watch(
2183
- () => props.rules,
2184
- () => {
2185
- props.resetByRulesChanged && reset();
2193
+ for (const key in components) {
2194
+ app.component(key, components[key]);
2195
+ }
2196
+ for (const key in uses) {
2197
+ app.use(uses[key]);
2198
+ }
2199
+ install?.(app);
2200
+ app.mount(container);
2186
2201
  }
2187
- );
2188
- vue.watch(
2189
- () => formItem.fields?.length,
2190
- async (v) => {
2191
- if (!isNest.value || !v) return isNestLast.value = false;
2192
- const fields$ = [...vue.toRaw(formItem.fields)];
2193
- const positions = await Promise.all(fields$.map((item) => item.exposed.getPosition()));
2194
- const sortFields = fields$.toSorted((a, b) => {
2195
- const aIndex = fields$.findIndex((i) => i === a);
2196
- const bIndex = fields$.findIndex((i) => i === b);
2197
- const aPosition = positions[aIndex];
2198
- const bPosition = positions[bIndex];
2199
- if (aPosition.top != bPosition.top) return aPosition.top - bPosition.top;
2200
- return aPosition.left - bPosition.left;
2202
+ leaf.destroy = $onDestroyed;
2203
+ leaf.autoDestroy = !!autoDestroy;
2204
+ Portal.leafs.set(name, leaf);
2205
+ const append = (root$, child$) => {
2206
+ if (!root$ || !child$) return;
2207
+ if (insertion === "first") {
2208
+ const firstEl = root$.firstElementChild;
2209
+ if (firstEl) {
2210
+ root$.insertBefore(child$, firstEl);
2211
+ return;
2212
+ }
2213
+ }
2214
+ root$.appendChild(child$);
2215
+ };
2216
+ if (fragment || typeof container._children === "undefined" && !Array.from(container.children).length) {
2217
+ useAllNodes = true;
2218
+ container.parentElement === null && append(root, container);
2219
+ } else if (!container._children) {
2220
+ container._children = [];
2221
+ let childs = Array.from(container.children);
2222
+ if (insertion === "first") {
2223
+ childs = childs.reverse();
2224
+ }
2225
+ childs.forEach((i) => {
2226
+ append(root, i);
2227
+ container._children?.push?.(i);
2201
2228
  });
2202
- isNestLast.value = sortFields[sortFields.length - 1] === instance;
2203
2229
  }
2204
- );
2205
- expose({
2206
- validate,
2207
- reset,
2208
- getPosition
2230
+ return leaf;
2231
+ }
2232
+ }
2233
+
2234
+ const props$X = {
2235
+ tag: {
2236
+ type: String,
2237
+ default: "div"
2238
+ }
2239
+ };
2240
+
2241
+ const COMPONENT_NAME$16 = 'vc-portal-view';
2242
+
2243
+ /**
2244
+ * 写法不同,但与vue@2.x 保持一致
2245
+ */
2246
+ const PortalView = /* @__PURE__ */ vue.defineComponent({
2247
+ name: COMPONENT_NAME$16,
2248
+ props: props$X,
2249
+ setup(props, {
2250
+ slots
2251
+ }) {
2252
+ return () => {
2253
+ /**
2254
+ * 考虑占位的情况下需要渲染default
2255
+ */
2256
+ return vue.h(vue.Fragment, [vue.h(props.tag, {
2257
+ class: 'vc-portal-view'
2258
+ }, slots?.default?.()), vue.h(vue.Teleport, {
2259
+ to: 'body'
2260
+ }, slots?.content?.())]);
2261
+ };
2262
+ }
2263
+ });
2264
+
2265
+ const props$W = {
2266
+ title: String,
2267
+ content: {
2268
+ type: [String, Function],
2269
+ default: ""
2270
+ },
2271
+ modelValue: {
2272
+ type: Boolean,
2273
+ default: false
2274
+ },
2275
+ width: {
2276
+ type: Number,
2277
+ default: 300
2278
+ },
2279
+ height: {
2280
+ type: Number,
2281
+ default: 300
2282
+ },
2283
+ mask: {
2284
+ type: Boolean,
2285
+ default: true
2286
+ },
2287
+ maskClosable: {
2288
+ type: Boolean,
2289
+ default: true
2290
+ },
2291
+ scrollable: {
2292
+ type: Boolean,
2293
+ default: false
2294
+ },
2295
+ placement: {
2296
+ type: String,
2297
+ default: "right"
2298
+ // top/right/left/bottom
2299
+ },
2300
+ maskStyle: [Object, String],
2301
+ wrapperClass: [Object, String],
2302
+ wrapperStyle: [Object, String],
2303
+ closeWithCancel: {
2304
+ type: Boolean,
2305
+ default: true
2306
+ // 如果关闭, cancel只能是取消的按钮
2307
+ },
2308
+ okText: {
2309
+ type: [String, Boolean],
2310
+ default: "确定"
2311
+ },
2312
+ cancelText: {
2313
+ type: [String, Boolean],
2314
+ default: "取消"
2315
+ },
2316
+ footer: {
2317
+ type: Boolean,
2318
+ default: true
2319
+ },
2320
+ /**
2321
+ * 兼容portal设计, 实现Promise方式
2322
+ */
2323
+ onOk: {
2324
+ type: Function
2325
+ },
2326
+ onCancel: {
2327
+ type: Function
2328
+ }
2329
+ };
2330
+
2331
+ /** @jsxImportSource vue */
2332
+
2333
+ function _isSlot$1(s) {
2334
+ return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !vue.isVNode(s);
2335
+ }
2336
+ const COMPONENT_NAME$15 = 'vc-drawer';
2337
+ const DrawerView = /* @__PURE__ */ vue.defineComponent({
2338
+ name: COMPONENT_NAME$15,
2339
+ props: props$W,
2340
+ emits: ['close', 'update:modelValue', 'visible-change'],
2341
+ setup(props, {
2342
+ emit,
2343
+ slots,
2344
+ expose
2345
+ }) {
2346
+ const instance = vue.getCurrentInstance();
2347
+ const isActive = vue.ref(false);
2348
+ const classes = vue.computed(() => {
2349
+ return {
2350
+ [`is-${props.placement}`]: true
2351
+ };
2352
+ });
2353
+ const style = vue.computed(() => {
2354
+ return props.placement === 'top' || props.placement === 'bottom' ? {
2355
+ height: `${props.height}px`
2356
+ } : {
2357
+ width: `${props.width}px`
2358
+ };
2359
+ });
2360
+ vue.watch(() => props.modelValue, v => {
2361
+ isActive.value = v;
2362
+ }, {
2363
+ immediate: true
2364
+ });
2365
+ const handleBefore = (e, hook) => {
2366
+ if (!isActive.value) return;
2367
+ const fn = hook && hook(e);
2368
+ if (fn && fn.then) {
2369
+ return fn.then(res => {
2370
+ isActive.value = false;
2371
+ return res;
2372
+ });
2373
+ } else if (!fn || fn === true) {
2374
+ isActive.value = false;
2375
+ }
2376
+ };
2377
+
2378
+ // 关闭事件
2379
+ const handleClose = (e, closable) => {
2380
+ if (closable || props.maskClosable && e.target.classList.contains('vc-drawer__wrapper')) {
2381
+ // 用户主要取消与关闭事件关联
2382
+ if (props.closeWithCancel) {
2383
+ handleBefore(e, handleCancel);
2384
+ } else {
2385
+ isActive.value = false;
2386
+ }
2387
+ }
2388
+ };
2389
+
2390
+ /**
2391
+ * 动画执行后关闭, 关闭事件都会被执行
2392
+ * visible-change 由移除之后触发
2393
+ * 同时close兼容portal设计
2394
+ */
2395
+ const handleRemove = () => {
2396
+ !instance.isUnmounted && (emit('close'), emit('update:modelValue', false), emit('visible-change', false));
2397
+ };
2398
+
2399
+ // 用户点击确定的回调 兼容portal设计
2400
+ const handleOk = (...rest) => {
2401
+ const ok = instance.vnode.props?.onOk || props.onOk || (() => {});
2402
+ return ok(...rest);
2403
+ };
2404
+
2405
+ // 用户点击取消按钮时为取消 兼容portal设计
2406
+ const handleCancel = (...rest) => {
2407
+ const cancel = instance.vnode.props?.onCancel || props.onCancel || (() => {});
2408
+ return cancel(...rest);
2409
+ };
2410
+ vcHooks.useScrollbar(isActive);
2411
+ expose({
2412
+ isActive,
2413
+ // for portal
2414
+ toggle(v) {
2415
+ v = typeof v === 'boolean' ? v : !isActive.value;
2416
+ isActive.value = v;
2417
+ }
2418
+ });
2419
+ return () => {
2420
+ let _slot, _slot2;
2421
+ return vue.createVNode("div", {
2422
+ "class": [classes.value, 'vc-drawer']
2423
+ }, [vue.createVNode(TransitionFade, {
2424
+ "delay": 50
2425
+ }, _isSlot$1(_slot = vue.withDirectives(vue.createVNode("div", {
2426
+ "style": props.maskStyle,
2427
+ "class": "vc-drawer__mask",
2428
+ "onClick": e => handleClose(e, props.maskClosable)
2429
+ }, null), [[vue.vShow, props.mask && isActive.value]])) ? _slot : {
2430
+ default: () => [_slot]
2431
+ }), vue.createVNode(TransitionSlide, {
2432
+ "mode": props.placement,
2433
+ "onAfterLeave": handleRemove
2434
+ }, _isSlot$1(_slot2 = vue.withDirectives(vue.createVNode("div", {
2435
+ "class": [props.wrapperClass, 'vc-drawer__wrapper'],
2436
+ "style": [style.value, props.wrapperStyle]
2437
+ }, [vue.createVNode("div", {
2438
+ "class": "vc-drawer__container"
2439
+ }, [vue.createVNode("div", {
2440
+ "class": "vc-drawer__header"
2441
+ }, [slots.header ? slots.header() : typeof props.title === 'string' ? vue.createVNode("div", {
2442
+ "class": "vc-drawer__title",
2443
+ "innerHTML": props.title
2444
+ }, null) : typeof props.title === 'function' && vue.createVNode(Customer, {
2445
+ "render": props.title
2446
+ }, null), vue.createVNode("a", {
2447
+ "class": "vc-drawer__close",
2448
+ "onClick": e => handleClose(e, true)
2449
+ }, [vue.createVNode(Icon, {
2450
+ "type": "close"
2451
+ }, null)])]), vue.createVNode("div", {
2452
+ "class": ['vc-drawer__content']
2453
+ }, [typeof props.content === 'string' ? vue.createVNode("div", {
2454
+ "innerHTML": props.content
2455
+ }, null) : typeof props.content === 'function' ? vue.createVNode(Customer, {
2456
+ "render": props.content
2457
+ }, null) : null, slots.default?.()]), props.footer && (props.cancelText || props.okText) && vue.createVNode("div", {
2458
+ "class": ['vc-drawer__footer']
2459
+ }, [slots['footer-extra']?.(), !slots.footer ? vue.createVNode(vue.Fragment, null, [props.cancelText && vue.createVNode(Button, {
2460
+ "style": "margin-right: 8px;",
2461
+ "onClick": e => handleBefore(e, handleCancel)
2462
+ }, {
2463
+ default: () => [props.cancelText]
2464
+ }), props.okText && vue.createVNode(Button, {
2465
+ "type": "primary",
2466
+ "onClick": e => handleBefore(e, handleOk)
2467
+ }, {
2468
+ default: () => [props.okText]
2469
+ })]) : slots.footer?.()])])]), [[vue.vShow, isActive.value]])) ? _slot2 : {
2470
+ default: () => [_slot2]
2471
+ })]);
2472
+ };
2473
+ }
2474
+ });
2475
+
2476
+ const Drawer = new Portal(DrawerView, {
2477
+ leaveDelay: 0,
2478
+ multiple: true
2479
+ });
2480
+ const destroy$5 = () => Drawer.destroy();
2481
+ const open$1 = (options) => {
2482
+ const leaf = Drawer.popup({
2483
+ ...options,
2484
+ onFulfilled: options.onClose,
2485
+ // 当组件内使用emit('close'),避免重复触发
2486
+ onClose: null
2209
2487
  });
2210
- return {
2211
- isNest,
2212
- isStyleless,
2213
- isNestLast,
2214
- validateMessage,
2215
- classes,
2216
- labelStyle,
2217
- contentStyle,
2218
- showError,
2219
- labelPosition
2220
- };
2488
+ leaf.wrapper.toggle?.(true);
2489
+ return leaf;
2490
+ };
2491
+
2492
+ const drawer = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
2493
+ __proto__: null,
2494
+ destroy: destroy$5,
2495
+ open: open$1
2496
+ }, Symbol.toStringTag, { value: 'Module' }));
2497
+
2498
+ const MDrawerView = DrawerView;
2499
+
2500
+ const props$V = {
2501
+ tag: {
2502
+ type: String,
2503
+ default: "div"
2504
+ }
2505
+ };
2506
+
2507
+ /** @jsxImportSource vue */
2508
+
2509
+ const COMPONENT_NAME$14 = 'vc-dropdown';
2510
+ const Dropdown = /* @__PURE__ */ vue.defineComponent({
2511
+ name: COMPONENT_NAME$14,
2512
+ props: props$V,
2513
+ setup(props, {
2514
+ slots
2515
+ }) {
2516
+ return () => {
2517
+ return vue.createVNode("div", {
2518
+ "class": "vc-dropdown"
2519
+ }, [slots?.default?.()]);
2520
+ };
2521
+ }
2522
+ });
2523
+
2524
+ const MDropdown = Dropdown;
2525
+
2526
+ const props$U = {
2527
+ tag: {
2528
+ type: String,
2529
+ default: "div"
2530
+ }
2221
2531
  };
2222
2532
 
2223
2533
  /** @jsxImportSource vue */
2224
2534
 
2225
- const COMPONENT_NAME$11 = 'vc-form-item';
2226
- const FormItem = /* @__PURE__ */ vue.defineComponent({
2227
- name: COMPONENT_NAME$11,
2228
- props: props$S,
2535
+ const COMPONENT_NAME$13 = 'vc-editor';
2536
+ const Editor = /* @__PURE__ */ vue.defineComponent({
2537
+ name: COMPONENT_NAME$13,
2538
+ props: props$U,
2229
2539
  setup(props, {
2230
- slots,
2231
- expose
2540
+ slots
2232
2541
  }) {
2233
- const it = useFormItem(expose);
2234
- const {
2235
- isStyleless,
2236
- isNest,
2237
- classes,
2238
- labelStyle,
2239
- contentStyle,
2240
- showError,
2241
- validateMessage
2242
- } = it;
2243
- const {
2244
- label,
2245
- labelFor
2246
- } = props;
2247
- const errorColorClass = 'vc-form-item__error';
2248
2542
  return () => {
2249
- if (isStyleless.value) return [slots.default?.(), slots.error?.({
2250
- show: showError.value,
2251
- nest: isNest.value,
2252
- message: validateMessage.value,
2253
- class: errorColorClass
2254
- })];
2255
2543
  return vue.createVNode("div", {
2256
- "class": ['vc-form-item', classes.value]
2257
- }, [vue.createVNode("div", {
2258
- "style": labelStyle.value,
2259
- "class": "vc-form-item__label",
2260
- "for": labelFor
2261
- }, [vue.createVNode("label", null, [label || slots.label?.()])]), vue.createVNode("div", {
2262
- "class": "vc-form-item__wrapper"
2263
- }, [vue.createVNode("div", {
2264
- "class": "vc-form-item__content",
2265
- "style": contentStyle.value
2266
- }, [slots.default?.(), slots.error ? slots.error({
2267
- show: showError.value,
2268
- nest: isNest.value,
2269
- message: validateMessage.value,
2270
- class: errorColorClass
2271
- }) : vue.createVNode(TransitionFade, null, {
2272
- default: () => [vue.withDirectives(vue.createVNode("div", {
2273
- "class": ['vc-form-item__tip', isNest.value ? 'is-nest' : '', errorColorClass]
2274
- }, [validateMessage.value]), [[vue.vShow, showError.value]])]
2275
- })])])]);
2544
+ "class": "vc-editor"
2545
+ }, [slots?.default?.()]);
2276
2546
  };
2277
2547
  }
2278
2548
  });
2279
2549
 
2280
- const props$R = {
2281
- ...props$T,
2282
- showToast: {
2550
+ const MEditor = Editor;
2551
+
2552
+ const MExpand = Expand;
2553
+
2554
+ const props$T = {
2555
+ tag: {
2556
+ type: String,
2557
+ default: "form"
2558
+ },
2559
+ model: {
2560
+ type: Object
2561
+ },
2562
+ rules: {
2563
+ type: Object
2564
+ },
2565
+ labelWidth: {
2566
+ type: Number
2567
+ },
2568
+ showMessage: {
2283
2569
  type: Boolean,
2284
- default: false
2570
+ default: true
2285
2571
  },
2286
- border: {
2572
+ inline: {
2287
2573
  type: Boolean,
2288
2574
  default: false
2289
- }
2290
- };
2291
-
2292
- const props$Q = {
2293
- content: [String, Function],
2294
- maskClosable: {
2295
- type: Boolean,
2296
- default: true
2297
2575
  },
2298
- // 单位ms
2299
- duration: {
2300
- type: Number,
2301
- default: 3e3
2576
+ labelPosition: {
2577
+ type: String,
2578
+ default: "right"
2302
2579
  },
2303
- mode: {
2580
+ autocomplete: {
2304
2581
  type: String,
2305
- default: "info",
2306
- validator: (val) => ["info", "loading", "success", "warning", "error"].includes(val)
2582
+ default: "off"
2583
+ },
2584
+ styleless: {
2585
+ type: Boolean,
2586
+ default: false
2307
2587
  }
2308
2588
  };
2309
2589
 
2310
- const MSpin = Spin;
2311
-
2312
- const MTransition = Transition;
2313
- const MTransitionCollapse = TransitionCollapse;
2314
- const MTransitionFade = TransitionFade;
2315
- const MTransitionScale = TransitionScale;
2316
- const MTransitionSlide = TransitionSlide;
2317
- const MTransitionZoom = TransitionZoom;
2318
-
2319
- /** @jsxImportSource vue */
2320
-
2321
- const COMPONENT_NAME$10 = 'vcm-toast';
2322
- const MToastView = /* @__PURE__ */ vue.defineComponent({
2323
- name: COMPONENT_NAME$10,
2324
- emits: ['close', 'portal-fulfilled'],
2325
- props: props$Q,
2326
- setup(props, {
2327
- emit,
2328
- expose
2329
- }) {
2330
- const isActive = vue.ref(false);
2331
- const currentContent = vue.ref();
2332
- const setContent = v => {
2333
- currentContent.value = v;
2334
- };
2335
-
2336
- // 兼容Portal设计
2337
- const handleRemove = () => {
2338
- emit('close');
2339
- emit('portal-fulfilled');
2340
- };
2341
- const handleClose = () => {
2342
- if (props.maskClosable) {
2343
- isActive.value = false;
2344
- }
2345
- };
2346
- vue.watch(() => props.content, setContent, {
2347
- immediate: true
2590
+ const useForm = (expose, options = {}) => {
2591
+ const instance = vue.getCurrentInstance();
2592
+ const props = instance.props;
2593
+ const fields = [];
2594
+ vue.provide("form", {
2595
+ props,
2596
+ add: (field) => {
2597
+ field && fields.push(field);
2598
+ },
2599
+ remove: (field) => {
2600
+ field && fields.splice(fields.indexOf(field), 1);
2601
+ }
2602
+ });
2603
+ const filterFields = (fields$) => {
2604
+ return !fields$ ? fields : fields.filter((item) => fields$.includes(item.props.prop));
2605
+ };
2606
+ const getField = (prop) => {
2607
+ const field = fields.find((item) => item.props.prop === prop);
2608
+ if (!field) throw new VcError("form", "请选择有用的prop值");
2609
+ return field;
2610
+ };
2611
+ const showToast = (msg) => {
2612
+ props.showMessage && options.throwToast?.(msg);
2613
+ };
2614
+ const sortErrors = async (errors) => {
2615
+ const positions = await Promise.all(fields.map((item) => item.exposed.getPosition()));
2616
+ try {
2617
+ return [...errors].toSorted((a, b) => {
2618
+ const aIndex = fields.findIndex((i) => i.props.prop === a.prop);
2619
+ const bIndex = fields.findIndex((i) => i.props.prop === b.prop);
2620
+ const aPosition = positions[aIndex];
2621
+ const bPosition = positions[bIndex];
2622
+ if (aPosition.top != bPosition.top) return aPosition.top - bPosition.top;
2623
+ return aPosition.left - bPosition.left;
2624
+ });
2625
+ } catch {
2626
+ return errors;
2627
+ }
2628
+ };
2629
+ const scrollIntoView = (prop) => {
2630
+ const field = getField(prop);
2631
+ field.vnode?.el?.scrollIntoView?.({
2632
+ behavior: "smooth",
2633
+ block: "center"
2348
2634
  });
2349
- let timer;
2350
- vue.onMounted(() => {
2351
- isActive.value = true;
2352
- if (props.duration !== 0) {
2353
- timer = setTimeout(() => isActive.value = false, props.duration);
2635
+ };
2636
+ const reset = (options$ = {}) => {
2637
+ const { fields: fields$, original = {} } = options$;
2638
+ filterFields(fields$).forEach((field) => {
2639
+ let v;
2640
+ try {
2641
+ v = Utils.getPropByPath(original, field.props.prop).v;
2642
+ } catch {
2354
2643
  }
2644
+ field.exposed.reset(v);
2355
2645
  });
2356
- vue.onUnmounted(() => {
2357
- timer && clearTimeout(timer);
2358
- });
2359
- const exposes = ['destroy', 'remove', 'close', 'hide'].reduce((pre, key) => {
2360
- pre[key] = handleRemove;
2361
- return pre;
2362
- }, {});
2363
- expose(exposes);
2646
+ };
2647
+ const validate = async (options$ = {}) => {
2648
+ const { scroll = true, fields: fields$ } = options$;
2649
+ if (!fields.length) {
2650
+ return;
2651
+ }
2652
+ const results = await Promise.allSettled(
2653
+ filterFields(fields$).map((item) => item.exposed.validate(""))
2654
+ );
2655
+ const originErrors = results.filter((i) => i.status === "rejected").map((i) => i.reason);
2656
+ if (!originErrors.length) return;
2657
+ const errors = await sortErrors(originErrors);
2658
+ showToast(errors[0].msg || errors[0].message);
2659
+ scroll && scrollIntoView(errors[0].prop);
2660
+ throw errors;
2661
+ };
2662
+ const validateField = async (prop, options$ = {}) => {
2663
+ try {
2664
+ await validate({
2665
+ ...options$,
2666
+ fields: [prop]
2667
+ });
2668
+ } catch (e) {
2669
+ throw e[0];
2670
+ }
2671
+ };
2672
+ expose({
2673
+ reset,
2674
+ validate,
2675
+ // 单个操作
2676
+ getField,
2677
+ validateField
2678
+ });
2679
+ };
2680
+
2681
+ const COMPONENT_NAME$12 = "vc-form";
2682
+ const Form = vue.defineComponent({
2683
+ name: COMPONENT_NAME$12,
2684
+ props: props$T,
2685
+ setup(props, { slots, expose }) {
2686
+ useForm(expose);
2364
2687
  return () => {
2365
- return vue.createVNode("div", {
2366
- "class": "vcm-toast"
2367
- }, [vue.createVNode("div", {
2368
- "class": "vcm-toast__bg",
2369
- "onClick": handleClose,
2370
- "onTouchmove": vue.withModifiers(() => {}, ['prevent'])
2371
- }, null), vue.createVNode(MTransitionFade, {
2372
- "duration": {
2373
- enter: 300,
2374
- leave: 150
2688
+ return vue.h(
2689
+ props.tag,
2690
+ {
2691
+ class: "vc-form",
2692
+ autocomplete: props.autocomplete
2375
2693
  },
2376
- "onAfterLeave": handleRemove
2377
- }, {
2378
- default: () => [vue.withDirectives(vue.createVNode("div", {
2379
- "class": "vcm-toast__wrapper"
2380
- }, [props.mode === 'loading' && vue.createVNode(MSpin, {
2381
- "class": "vcm-toast__loading"
2382
- }, null), typeof currentContent.value === 'string' ? vue.createVNode("div", {
2383
- "class": "vcm-toast__content",
2384
- "innerHTML": currentContent.value
2385
- }, null) : typeof currentContent.value === 'function' ? vue.createVNode(MCustomer, {
2386
- "render": currentContent.value
2387
- }, null) : null]), [[vue.vShow, isActive.value]])]
2388
- })]);
2694
+ slots
2695
+ );
2389
2696
  };
2390
2697
  }
2391
2698
  });
2392
2699
 
2393
- const defaults = {
2394
- tag: "div",
2395
- el: "body",
2396
- alive: false,
2397
- multiple: false,
2398
- aliveRegExp: { className: /(vc-hack-alive|vc-hack-cp)/ },
2399
- aliveVisibleKey: "isVisible",
2400
- aliveUpdateKey: "update",
2401
- leaveDelay: 300,
2402
- autoDestroy: true,
2403
- components: {},
2404
- uses: {},
2405
- fragment: false,
2406
- insertion: "last"
2700
+ const props$S = {
2701
+ label: {
2702
+ type: String,
2703
+ default: ""
2704
+ },
2705
+ labelWidth: {
2706
+ type: Number
2707
+ },
2708
+ prop: {
2709
+ type: String
2710
+ },
2711
+ required: {
2712
+ type: [Boolean, String],
2713
+ default: false
2714
+ },
2715
+ // 控制`*`是否展示
2716
+ asterisk: {
2717
+ type: Boolean,
2718
+ default: true
2719
+ },
2720
+ error: {
2721
+ type: String
2722
+ },
2723
+ rules: {
2724
+ type: [Array, Object]
2725
+ },
2726
+ resetByRulesChanged: {
2727
+ type: Boolean,
2728
+ default: false
2729
+ },
2730
+ showMessage: {
2731
+ type: Boolean,
2732
+ default: true
2733
+ },
2734
+ labelFor: {
2735
+ type: String
2736
+ },
2737
+ styleless: {
2738
+ type: Boolean,
2739
+ default: false
2740
+ },
2741
+ labelPosition: {
2742
+ type: String,
2743
+ default: "right"
2744
+ },
2745
+ contentStyle: String
2407
2746
  };
2408
2747
 
2409
- class PortalLeaf {
2410
- app;
2411
- /**
2412
- * 目标的实例,挂载到app上
2413
- */
2414
- wrapper;
2415
- propsData;
2416
- /**
2417
- * 销毁的函数,挂载到app上,避免冲突
2418
- */
2419
- destroy;
2420
- /**
2421
- * 自动销毁的标记,挂载到app上,避免冲突
2422
- */
2423
- autoDestroy;
2424
- target;
2425
- constructor(target) {
2426
- this.target = target;
2427
- this.autoDestroy = false;
2428
- this.destroy = /* istanbul ignore next */
2429
- () => {
2430
- throw new VcError("portal", "未注册的destroy方法");
2431
- };
2432
- }
2433
- then(resolve, reject) {
2434
- return this.target.then(resolve, reject);
2435
- }
2436
- catch(callback) {
2437
- return this.target.catch(callback);
2748
+ const filterEmpty = (val) => {
2749
+ if (val instanceof Array) {
2750
+ val = val.filter((i) => i !== "");
2438
2751
  }
2439
- finally(callback) {
2440
- return this.target.finally(callback);
2752
+ return val;
2753
+ };
2754
+ const toRules = (rules) => {
2755
+ return rules instanceof Array ? rules : rules ? [rules] : [];
2756
+ };
2757
+ const useFormItem = (expose) => {
2758
+ const form = vue.inject("form");
2759
+ const instance = vue.getCurrentInstance();
2760
+ const props = instance.props;
2761
+ const { slots } = instance;
2762
+ if (!form?.props) {
2763
+ throw new VcError("form-item", "form-item需要在form内使用");
2441
2764
  }
2442
- }
2443
-
2444
- const COMPONENT_NAME$$ = "vc-portal";
2445
- class Portal {
2446
- /**
2447
- * 清理Portals类型组件
2448
- * @param name 清理的组件名, boolean表示全部leafs是否强制清理
2449
- */
2450
- static clear(name) {
2451
- try {
2452
- let force = false;
2453
- let target = /* @__PURE__ */ new Map();
2454
- if (name && typeof name !== "boolean") {
2455
- let names = [];
2456
- if (typeof name === "string") {
2457
- names = [name];
2458
- } else if (name instanceof Array && name.length > 0) {
2459
- names = name;
2460
- }
2461
- names.forEach((i) => target.set(i, ""));
2462
- force = true;
2765
+ const formItem = vue.inject("vc-form-item", {});
2766
+ const validateState = vue.ref("");
2767
+ const validateMessage = vue.ref("");
2768
+ let validateDisabled = false;
2769
+ let initialValue;
2770
+ const currentRules = vue.computed(() => {
2771
+ const formRules = form.props.rules;
2772
+ const formItemBindRules = toRules(props.rules);
2773
+ let formItemRules = formItemBindRules;
2774
+ if (!formItemRules.length && formRules && props.prop) {
2775
+ try {
2776
+ const key = props.prop.replace(/\.[0-9]+\./g, ".");
2777
+ const { v } = Utils.getPropByPath(formRules, key);
2778
+ formItemRules = toRules(v);
2779
+ } catch {
2780
+ const rules = formRules[props.prop];
2781
+ formItemRules = toRules(rules);
2782
+ }
2783
+ }
2784
+ return formItemRules;
2785
+ });
2786
+ const isRequired = vue.computed(() => {
2787
+ if (!currentRules.value.length) {
2788
+ return !!props.required;
2789
+ }
2790
+ let required = false;
2791
+ for (let i = 0; i < currentRules.value.length; i++) {
2792
+ const rule = currentRules.value[i];
2793
+ required = !!rule.required;
2794
+ if (required) break;
2795
+ }
2796
+ return required;
2797
+ });
2798
+ const labelPosition = vue.computed(() => {
2799
+ return props.labelPosition || form.props.labelPosition;
2800
+ });
2801
+ const classes = vue.computed(() => {
2802
+ return {
2803
+ "is-require": isRequired.value && props.asterisk,
2804
+ "is-error": validateState.value === "error",
2805
+ "is-validating": validateState.value === "validating",
2806
+ "is-inline": form.props.inline,
2807
+ "is-nest": isNest.value,
2808
+ [`is-${labelPosition.value}`]: true
2809
+ };
2810
+ });
2811
+ const isNest = vue.computed(() => {
2812
+ return !!formItem.change;
2813
+ });
2814
+ const isNestLast = vue.ref(false);
2815
+ const hasLabel = vue.computed(() => {
2816
+ return !!props.label || slots.label;
2817
+ });
2818
+ const labelStyle = vue.computed(() => {
2819
+ const labelWidth = props.labelWidth === 0 || props.labelWidth ? props.labelWidth : isNest.value ? 0 : form.props.labelWidth;
2820
+ return {
2821
+ width: labelPosition.value !== "top" && labelWidth && labelWidth > 0 ? `${labelWidth}px` : "auto",
2822
+ textAlign: labelPosition.value === "top" ? "left" : labelPosition.value
2823
+ };
2824
+ });
2825
+ const contentStyle = vue.computed(() => {
2826
+ const labelWidth = props.labelWidth === 0 || props.labelWidth ? props.labelWidth : form.props.labelWidth;
2827
+ return [
2828
+ {
2829
+ marginLeft: !hasLabel.value && isNest.value ? 0 : labelWidth && labelWidth > 0 ? `${labelWidth}px` : "unset",
2830
+ marginBottom: isNest.value && !isNestLast.value ? `20px` : 0
2831
+ },
2832
+ props.contentStyle
2833
+ ];
2834
+ });
2835
+ const isStyleless = vue.computed(() => {
2836
+ return props.styleless || form.props.styleless;
2837
+ });
2838
+ const fieldValue = vue.computed(() => {
2839
+ const model = form.props.model;
2840
+ if (!model || !props.prop) {
2841
+ return;
2842
+ }
2843
+ let path = props.prop;
2844
+ if (path.includes(":")) {
2845
+ path = path.replace(/:/, ".");
2846
+ }
2847
+ return Utils.getPropByPath(model, path).v;
2848
+ });
2849
+ const showError = vue.computed(() => {
2850
+ return validateState.value === "error" && props.showMessage && form.props.showMessage;
2851
+ });
2852
+ vue.watch(
2853
+ () => props.error,
2854
+ (v) => {
2855
+ validateMessage.value = v || "";
2856
+ validateState.value = v === "" ? "" : "error";
2857
+ }
2858
+ );
2859
+ const reset = (v) => {
2860
+ validateState.value = "";
2861
+ validateMessage.value = "";
2862
+ const model = form.props.model;
2863
+ if (!props.prop) return;
2864
+ const { o, k } = Utils.getPropByPath(model, props.prop);
2865
+ if (!k) return;
2866
+ validateDisabled = true;
2867
+ o[k] = v !== null && v !== void 0 ? v : Array.isArray(fieldValue.value) ? [].concat(initialValue) : initialValue;
2868
+ };
2869
+ const validate = async (trigger) => {
2870
+ if (!props.prop) return;
2871
+ let rules = currentRules.value.filter((rule) => !rule.trigger || rule.trigger.includes(trigger));
2872
+ if (!rules.length) {
2873
+ if (!props.required) {
2874
+ return;
2463
2875
  } else {
2464
- force = !!name;
2465
- target = Portal.leafs;
2466
- }
2467
- for (const key of target.keys()) {
2468
- const leaf = Portal.leafs.get(key);
2469
- if (leaf && (force === true || leaf.autoDestroy === true)) {
2470
- leaf.destroy();
2471
- }
2876
+ rules = [{
2877
+ required: true,
2878
+ message: typeof props.required === "string" ? props.required : void 0
2879
+ }];
2472
2880
  }
2473
- } catch (e) {
2474
- /* istanbul ignore next -- @preserve */
2475
- throw new VcError("instance", e);
2476
2881
  }
2477
- }
2478
- /**
2479
- * 清理全部Portals
2480
- */
2481
- static clearAll() {
2882
+ validateState.value = "validating";
2883
+ const descriptor = {};
2884
+ descriptor[props.prop] = rules;
2885
+ const validator = new helperValidator.Validator(descriptor);
2886
+ const model = {};
2887
+ model[props.prop] = filterEmpty(fieldValue.value);
2482
2888
  try {
2483
- Portal.leafs.forEach((leaf) => leaf.destroy());
2484
- } catch (e) {
2485
- /* istanbul ignore next -- @preserve */
2486
- throw new VcError("instance", e);
2487
- }
2488
- }
2489
- static leafs = /* @__PURE__ */ new Map();
2490
- wrapper;
2491
- globalOptions;
2492
- constructor(wrapper, options) {
2493
- this.wrapper = wrapper;
2494
- this.globalOptions = {
2495
- ...options,
2496
- name: options?.name || wrapper.name || Utils__namespace.getUid(COMPONENT_NAME$$)
2497
- };
2498
- }
2499
- popup(propsData, options) {
2500
- if (!options) {
2501
- options = propsData || {};
2502
- } else {
2503
- options.propsData = propsData;
2504
- }
2505
- const $options = { ...this.getDefaultOptions(), ...options };
2506
- const { onFulfilled, onRejected, ...rest } = $options;
2507
- let onFulfilled$ = (
2508
- /* istanbul ignore next -- @preserve */
2509
- () => {
2510
- }
2511
- );
2512
- let onRejected$ = (
2513
- /* istanbul ignore next -- @preserve */
2514
- () => {
2515
- }
2516
- );
2517
- const target = new Promise((resolve, reject) => {
2518
- onFulfilled$ = (v) => {
2519
- onFulfilled?.(v);
2520
- resolve(v);
2521
- };
2522
- onRejected$ = (v) => {
2523
- onRejected?.(v);
2524
- reject(v);
2889
+ await validator.validate(model, { first: false });
2890
+ validateState.value = "success";
2891
+ validateMessage.value = "";
2892
+ } catch (errors) {
2893
+ validateState.value = "error";
2894
+ validateMessage.value = errors[0].message;
2895
+ throw {
2896
+ prop: props.prop,
2897
+ message: validateMessage.value
2525
2898
  };
2526
- });
2527
- return this.render(rest, target, onFulfilled$, onRejected$);
2528
- }
2529
- /**
2530
- * 销毁当前Portal下的节点
2531
- * @param target [description]
2532
- */
2533
- destroy = (target) => {
2534
- const { multiple, name } = this.getDefaultOptions();
2535
- target = target || name;
2536
- const instance = typeof target === "object" ? target : Portal.leafs.get(target);
2537
- if (instance) {
2538
- instance.destroy();
2539
- } else if (multiple) {
2540
- Portal.leafs.forEach((item, key) => {
2541
- if (key.includes(name)) {
2542
- item.destroy();
2543
- }
2544
- });
2545
2899
  }
2900
+ validateDisabled = false;
2546
2901
  };
2547
- getDefaultOptions() {
2548
- return {
2549
- ...defaults,
2550
- ...VcInstance.options.Portal,
2551
- ...this.globalOptions
2552
- };
2553
- }
2554
- createCallback(getLeaf, delay, callback) {
2555
- return (...args) => {
2556
- const done = () => {
2557
- const leaf = getLeaf();
2558
- /* istanbul ignore next -- @preserve */
2559
- if (!leaf) {
2560
- throw new VcError("portal", "实例不存在或已卸载");
2561
- }
2562
- leaf.destroy();
2563
- };
2564
- delay ? setTimeout(done, delay) : done();
2565
- callback?.(...args);
2566
- };
2567
- }
2568
- render(options, target, onFulfilled, onRejected) {
2569
- const {
2570
- el,
2571
- tag,
2572
- alive,
2573
- aliveRegExp,
2574
- aliveVisibleKey,
2575
- aliveUpdateKey,
2576
- name: name$,
2577
- leaveDelay,
2578
- autoDestroy,
2579
- multiple,
2580
- fragment,
2581
- onDestroyed,
2582
- onBeforeCreate,
2583
- insertion,
2584
- // 全局注册
2585
- globalProperties,
2586
- install,
2587
- components,
2588
- uses,
2589
- slots,
2590
- parent,
2591
- propsData,
2592
- ...rest
2593
- } = options;
2594
- let useAllNodes = fragment;
2595
- const name = multiple ? `${name$}__${Utils__namespace.getUid(COMPONENT_NAME$$)}` : name$;
2596
- const container = document.createElement(tag);
2597
- const root = typeof el === "object" ? el : document.querySelector(el || "body");
2598
- !alive && Portal.leafs.get(name)?.destroy();
2599
- const propsData$ = propsData || rest;
2600
- let leaf = new PortalLeaf(target);
2601
- const isDestroyed = () => {
2602
- const leaf$ = Portal.leafs.get(name);
2603
- return !leaf$ || leaf$ !== leaf;
2604
- };
2605
- const $onDestroyed = (...args) => {
2606
- if (isDestroyed()) return;
2607
- onDestroyed?.(...args);
2608
- leaf.app?.unmount();
2609
- /* istanbul ignore else -- @preserve */
2610
- if (useAllNodes) {
2611
- root?.contains(container) && root.removeChild(container);
2612
- } else if (container && container._children) {
2613
- container._children.forEach((i) => {
2614
- root?.contains(i) && root.removeChild(i);
2615
- });
2616
- }
2617
- Portal.leafs.delete(name);
2618
- };
2619
- const $onRejected = this.createCallback(() => leaf, leaveDelay, onRejected);
2620
- const $onFulfilled = this.createCallback(() => leaf, leaveDelay, onFulfilled);
2621
- if (alive && Portal.leafs.has(name)) {
2622
- leaf = Portal.leafs.get(name);
2623
- leaf.target = target;
2624
- leaf.propsData.value = propsData$;
2625
- leaf.wrapper?.[aliveUpdateKey]?.(options);
2626
- } else {
2627
- const wrapper = this.wrapper;
2628
- const app = vue.createApp({
2629
- name: COMPONENT_NAME$$,
2630
- parent,
2631
- setup() {
2632
- if (alive) {
2633
- const handleExtra = (e) => {
2634
- try {
2635
- const path = e.path || $__namespace.composedPath(e);
2636
- /* istanbul ignore else -- @preserve */
2637
- if (container && e.target && !container.contains(e.target) && !path?.some((item) => vcShared.Utils.eleInRegExp(item, aliveRegExp))) {
2638
- /* istanbul ignore else -- @preserve */
2639
- if (leaf.wrapper && leaf.wrapper?.[aliveVisibleKey]) {
2640
- leaf.wrapper[aliveVisibleKey] = false;
2641
- }
2642
- leaveDelay ? setTimeout($onDestroyed, leaveDelay) : $onDestroyed();
2643
- }
2644
- } catch (error) {
2645
- /* istanbul ignore next -- @preserve */
2646
- throw new VcError("portal", error);
2647
- }
2648
- };
2649
- vue.onMounted(() => {
2650
- document.addEventListener("click", handleExtra, true);
2651
- });
2652
- vue.onBeforeUnmount(() => {
2653
- document.removeEventListener("click", handleExtra, true);
2654
- });
2655
- }
2656
- const propsData1 = vue.ref(propsData$);
2657
- const propsData2 = vue.ref();
2658
- leaf.propsData = propsData1;
2659
- const allowMounted = vue.ref(typeof onBeforeCreate !== "function");
2660
- if (!allowMounted.value) {
2661
- const result = onBeforeCreate(propsData$);
2662
- if (result && result.then) {
2663
- result.then((response) => {
2664
- if (isDestroyed()) return;
2665
- allowMounted.value = true;
2666
- propsData2.value = response;
2667
- }).catch((error) => {
2668
- $onDestroyed(error);
2669
- });
2670
- } else {
2671
- allowMounted.value = true;
2672
- propsData2.value = result;
2673
- }
2674
- }
2675
- return () => allowMounted.value && vue.h(
2676
- wrapper,
2677
- {
2678
- ...propsData1.value,
2679
- ...propsData2.value,
2680
- ref: (vm) => leaf.wrapper = vm,
2681
- onPortalFulfilled: (...args) => $onFulfilled(...args),
2682
- onPortalRejected: (...args) => $onRejected(...args),
2683
- onPortalDestroyed: (...args) => $onDestroyed(...args)
2684
- },
2685
- slots || void 0
2686
- );
2687
- }
2688
- });
2689
- leaf.app = app;
2690
- if (globalProperties) {
2691
- app.config.globalProperties = globalProperties;
2692
- }
2693
- for (const key in components) {
2694
- app.component(key, components[key]);
2695
- }
2696
- for (const key in uses) {
2697
- app.use(uses[key]);
2698
- }
2699
- install?.(app);
2700
- app.mount(container);
2902
+ const handleFieldBlur = () => {
2903
+ if (!props.prop) {
2904
+ formItem.blur?.();
2905
+ return;
2701
2906
  }
2702
- leaf.destroy = $onDestroyed;
2703
- leaf.autoDestroy = !!autoDestroy;
2704
- Portal.leafs.set(name, leaf);
2705
- const append = (root$, child$) => {
2706
- if (!root$ || !child$) return;
2707
- if (insertion === "first") {
2708
- const firstEl = root$.firstElementChild;
2709
- if (firstEl) {
2710
- root$.insertBefore(child$, firstEl);
2711
- return;
2712
- }
2713
- }
2714
- root$.appendChild(child$);
2715
- };
2716
- if (fragment || typeof container._children === "undefined" && !Array.from(container.children).length) {
2717
- useAllNodes = true;
2718
- container.parentElement === null && append(root, container);
2719
- } else if (!container._children) {
2720
- container._children = [];
2721
- let childs = Array.from(container.children);
2722
- if (insertion === "first") {
2723
- childs = childs.reverse();
2907
+ validate("blur");
2908
+ };
2909
+ const handleFieldChange = () => {
2910
+ if (!props.prop) {
2911
+ formItem.change?.();
2912
+ return;
2913
+ }
2914
+ if (validateDisabled) {
2915
+ validateDisabled = false;
2916
+ return;
2917
+ }
2918
+ validate("change");
2919
+ };
2920
+ const getPosition = async () => {
2921
+ let el = instance.vnode.el;
2922
+ try {
2923
+ while (el && !el.getBoundingClientRect) {
2924
+ el = el.nextSibling;
2724
2925
  }
2725
- childs.forEach((i) => {
2726
- append(root, i);
2727
- container._children?.push?.(i);
2926
+ ;
2927
+ const rect = el.getBoundingClientRect();
2928
+ return {
2929
+ top: rect.top,
2930
+ left: rect.left
2931
+ };
2932
+ } catch {
2933
+ throw new VcError("form-item", "form-item位置计算错误");
2934
+ }
2935
+ };
2936
+ const fields = vue.reactive([]);
2937
+ vue.provide("vc-form-item", {
2938
+ fields,
2939
+ blur: handleFieldBlur,
2940
+ change: handleFieldChange,
2941
+ message: validateMessage,
2942
+ add: (field) => {
2943
+ field && fields.push(field);
2944
+ },
2945
+ remove: (field) => {
2946
+ field && fields.splice(fields.indexOf(field), 1);
2947
+ }
2948
+ });
2949
+ vue.onMounted(() => {
2950
+ if (props.prop) {
2951
+ form.add?.(instance);
2952
+ initialValue = lodashEs.cloneDeep(fieldValue.value);
2953
+ }
2954
+ formItem.add?.(instance);
2955
+ });
2956
+ vue.onBeforeUnmount(() => {
2957
+ form.remove?.(instance);
2958
+ formItem.remove?.(instance);
2959
+ });
2960
+ vue.watch(
2961
+ () => props.rules,
2962
+ () => {
2963
+ props.resetByRulesChanged && reset();
2964
+ }
2965
+ );
2966
+ vue.watch(
2967
+ () => formItem.fields?.length,
2968
+ async (v) => {
2969
+ if (!isNest.value || !v) return isNestLast.value = false;
2970
+ const fields$ = [...vue.toRaw(formItem.fields)];
2971
+ const positions = await Promise.all(fields$.map((item) => item.exposed.getPosition()));
2972
+ const sortFields = fields$.toSorted((a, b) => {
2973
+ const aIndex = fields$.findIndex((i) => i === a);
2974
+ const bIndex = fields$.findIndex((i) => i === b);
2975
+ const aPosition = positions[aIndex];
2976
+ const bPosition = positions[bIndex];
2977
+ if (aPosition.top != bPosition.top) return aPosition.top - bPosition.top;
2978
+ return aPosition.left - bPosition.left;
2728
2979
  });
2980
+ isNestLast.value = sortFields[sortFields.length - 1] === instance;
2729
2981
  }
2730
- return leaf;
2982
+ );
2983
+ expose({
2984
+ validate,
2985
+ reset,
2986
+ getPosition
2987
+ });
2988
+ return {
2989
+ isNest,
2990
+ isStyleless,
2991
+ isNestLast,
2992
+ validateMessage,
2993
+ classes,
2994
+ labelStyle,
2995
+ contentStyle,
2996
+ showError,
2997
+ labelPosition
2998
+ };
2999
+ };
3000
+
3001
+ /** @jsxImportSource vue */
3002
+
3003
+ const COMPONENT_NAME$11 = 'vc-form-item';
3004
+ const FormItem = /* @__PURE__ */ vue.defineComponent({
3005
+ name: COMPONENT_NAME$11,
3006
+ props: props$S,
3007
+ setup(props, {
3008
+ slots,
3009
+ expose
3010
+ }) {
3011
+ const it = useFormItem(expose);
3012
+ const {
3013
+ isStyleless,
3014
+ isNest,
3015
+ classes,
3016
+ labelStyle,
3017
+ contentStyle,
3018
+ showError,
3019
+ validateMessage
3020
+ } = it;
3021
+ const {
3022
+ label,
3023
+ labelFor
3024
+ } = props;
3025
+ const errorColorClass = 'vc-form-item__error';
3026
+ return () => {
3027
+ if (isStyleless.value) return [slots.default?.(), slots.error?.({
3028
+ show: showError.value,
3029
+ nest: isNest.value,
3030
+ message: validateMessage.value,
3031
+ class: errorColorClass
3032
+ })];
3033
+ return vue.createVNode("div", {
3034
+ "class": ['vc-form-item', classes.value]
3035
+ }, [vue.createVNode("div", {
3036
+ "style": labelStyle.value,
3037
+ "class": "vc-form-item__label",
3038
+ "for": labelFor
3039
+ }, [vue.createVNode("label", null, [label || slots.label?.()])]), vue.createVNode("div", {
3040
+ "class": "vc-form-item__wrapper"
3041
+ }, [vue.createVNode("div", {
3042
+ "class": "vc-form-item__content",
3043
+ "style": contentStyle.value
3044
+ }, [slots.default?.(), slots.error ? slots.error({
3045
+ show: showError.value,
3046
+ nest: isNest.value,
3047
+ message: validateMessage.value,
3048
+ class: errorColorClass
3049
+ }) : vue.createVNode(TransitionFade, null, {
3050
+ default: () => [vue.withDirectives(vue.createVNode("div", {
3051
+ "class": ['vc-form-item__tip', isNest.value ? 'is-nest' : '', errorColorClass]
3052
+ }, [validateMessage.value]), [[vue.vShow, showError.value]])]
3053
+ })])])]);
3054
+ };
2731
3055
  }
2732
- }
3056
+ });
2733
3057
 
2734
- const props$P = {
2735
- tag: {
3058
+ const props$R = {
3059
+ ...props$T,
3060
+ showToast: {
3061
+ type: Boolean,
3062
+ default: false
3063
+ },
3064
+ border: {
3065
+ type: Boolean,
3066
+ default: false
3067
+ }
3068
+ };
3069
+
3070
+ const props$Q = {
3071
+ content: [String, Function],
3072
+ maskClosable: {
3073
+ type: Boolean,
3074
+ default: true
3075
+ },
3076
+ // 单位ms
3077
+ duration: {
3078
+ type: Number,
3079
+ default: 3e3
3080
+ },
3081
+ mode: {
2736
3082
  type: String,
2737
- default: "div"
3083
+ default: "info",
3084
+ validator: (val) => ["info", "loading", "success", "warning", "error"].includes(val)
2738
3085
  }
2739
3086
  };
2740
3087
 
2741
- const COMPONENT_NAME$_ = 'vc-portal-view';
3088
+ const MSpin = Spin;
2742
3089
 
2743
- /**
2744
- * 写法不同,但与vue@2.x 保持一致
2745
- */
2746
- const PortalView = /* @__PURE__ */ vue.defineComponent({
2747
- name: COMPONENT_NAME$_,
2748
- props: props$P,
3090
+ const MTransition = Transition;
3091
+ const MTransitionCollapse = TransitionCollapse;
3092
+ const MTransitionFade = TransitionFade;
3093
+ const MTransitionScale = TransitionScale;
3094
+ const MTransitionSlide = TransitionSlide;
3095
+ const MTransitionZoom = TransitionZoom;
3096
+
3097
+ /** @jsxImportSource vue */
3098
+
3099
+ const COMPONENT_NAME$10 = 'vcm-toast';
3100
+ const MToastView = /* @__PURE__ */ vue.defineComponent({
3101
+ name: COMPONENT_NAME$10,
3102
+ emits: ['close', 'portal-fulfilled'],
3103
+ props: props$Q,
2749
3104
  setup(props, {
2750
- slots
3105
+ emit,
3106
+ expose
2751
3107
  }) {
3108
+ const isActive = vue.ref(false);
3109
+ const currentContent = vue.ref();
3110
+ let timer;
3111
+ const setDuration = v => {
3112
+ timer && clearTimeout(timer);
3113
+ if (v === 0) return;
3114
+ timer = setTimeout(() => isActive.value = false, v);
3115
+ };
3116
+ const setContent = v => {
3117
+ currentContent.value = v;
3118
+ };
3119
+
3120
+ // 兼容Portal设计
3121
+ const handleRemove = () => {
3122
+ emit('close');
3123
+ emit('portal-fulfilled');
3124
+ };
3125
+ const handleClose = () => {
3126
+ if (props.maskClosable) {
3127
+ isActive.value = false;
3128
+ }
3129
+ };
3130
+ vue.watch(() => props.content, setContent, {
3131
+ immediate: true
3132
+ });
3133
+ vue.onMounted(() => {
3134
+ isActive.value = true;
3135
+ setDuration(props.duration);
3136
+ });
3137
+ vue.onUnmounted(() => {
3138
+ timer && clearTimeout(timer);
3139
+ });
3140
+ const exposes = ['destroy', 'remove', 'close', 'hide'].reduce((pre, key) => {
3141
+ pre[key] = handleRemove;
3142
+ return pre;
3143
+ }, {
3144
+ setContent,
3145
+ setDuration
3146
+ });
3147
+ expose(exposes);
2752
3148
  return () => {
2753
- /**
2754
- * 考虑占位的情况下需要渲染default
2755
- */
2756
- return vue.h(vue.Fragment, [vue.h(props.tag, {
2757
- class: 'vc-portal-view'
2758
- }, slots?.default?.()), vue.h(vue.Teleport, {
2759
- to: 'body'
2760
- }, slots?.content?.())]);
3149
+ return vue.createVNode("div", {
3150
+ "class": "vcm-toast"
3151
+ }, [vue.createVNode("div", {
3152
+ "class": "vcm-toast__bg",
3153
+ "onClick": handleClose,
3154
+ "onTouchmove": vue.withModifiers(() => {}, ['prevent'])
3155
+ }, null), vue.createVNode(MTransitionFade, {
3156
+ "duration": {
3157
+ enter: 300,
3158
+ leave: 150
3159
+ },
3160
+ "onAfterLeave": handleRemove
3161
+ }, {
3162
+ default: () => [vue.withDirectives(vue.createVNode("div", {
3163
+ "class": "vcm-toast__wrapper"
3164
+ }, [props.mode === 'loading' && vue.createVNode(MSpin, {
3165
+ "class": "vcm-toast__loading"
3166
+ }, null), typeof currentContent.value === 'string' ? vue.createVNode("div", {
3167
+ "class": "vcm-toast__content",
3168
+ "innerHTML": currentContent.value
3169
+ }, null) : typeof currentContent.value === 'function' ? vue.createVNode(MCustomer, {
3170
+ "render": currentContent.value
3171
+ }, null) : null]), [[vue.vShow, isActive.value]])]
3172
+ })]);
2761
3173
  };
2762
3174
  }
2763
3175
  });
@@ -2797,9 +3209,9 @@ const MToast$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
2797
3209
  warning: warning$3
2798
3210
  }, Symbol.toStringTag, { value: 'Module' }));
2799
3211
 
2800
- const COMPONENT_NAME$Z = "vcm-form";
3212
+ const COMPONENT_NAME$$ = "vcm-form";
2801
3213
  const MForm = vue.defineComponent({
2802
- name: COMPONENT_NAME$Z,
3214
+ name: COMPONENT_NAME$$,
2803
3215
  props: props$R,
2804
3216
  setup(props, { slots, expose }) {
2805
3217
  useForm(expose, {
@@ -2820,7 +3232,7 @@ const MForm = vue.defineComponent({
2820
3232
  }
2821
3233
  });
2822
3234
 
2823
- const props$O = {
3235
+ const props$P = {
2824
3236
  ...props$S,
2825
3237
  indent: {
2826
3238
  type: Number,
@@ -2830,10 +3242,10 @@ const props$O = {
2830
3242
 
2831
3243
  /** @jsxImportSource vue */
2832
3244
 
2833
- const COMPONENT_NAME$Y = 'vcm-form-item';
3245
+ const COMPONENT_NAME$_ = 'vcm-form-item';
2834
3246
  const MFormItem = /* @__PURE__ */ vue.defineComponent({
2835
- name: COMPONENT_NAME$Y,
2836
- props: props$O,
3247
+ name: COMPONENT_NAME$_,
3248
+ props: props$P,
2837
3249
  setup(props, {
2838
3250
  slots,
2839
3251
  expose
@@ -2886,9 +3298,9 @@ const MFormItem = /* @__PURE__ */ vue.defineComponent({
2886
3298
  }
2887
3299
  });
2888
3300
 
2889
- const COMPONENT_NAME$X = "vc-fragment";
3301
+ const COMPONENT_NAME$Z = "vc-fragment";
2890
3302
  const Fragment = vue.defineComponent({
2891
- name: COMPONENT_NAME$X,
3303
+ name: COMPONENT_NAME$Z,
2892
3304
  setup(_, { slots }) {
2893
3305
  return () => vue.h(vue.Fragment, slots.default?.());
2894
3306
  }
@@ -2896,7 +3308,7 @@ const Fragment = vue.defineComponent({
2896
3308
 
2897
3309
  const MFragment = Fragment;
2898
3310
 
2899
- const props$N = {
3311
+ const props$O = {
2900
3312
  tag: {
2901
3313
  type: String,
2902
3314
  default: "div"
@@ -2905,10 +3317,10 @@ const props$N = {
2905
3317
 
2906
3318
  /** @jsxImportSource vue */
2907
3319
 
2908
- const COMPONENT_NAME$W = 'vc-html-to-image';
3320
+ const COMPONENT_NAME$Y = 'vc-html-to-image';
2909
3321
  const HTMLToImage = /* @__PURE__ */ vue.defineComponent({
2910
- name: COMPONENT_NAME$W,
2911
- props: props$N,
3322
+ name: COMPONENT_NAME$Y,
3323
+ props: props$O,
2912
3324
  setup(props, {
2913
3325
  slots
2914
3326
  }) {
@@ -2924,7 +3336,7 @@ const MHTMLToImage = HTMLToImage;
2924
3336
 
2925
3337
  const MIcon = Icon;
2926
3338
 
2927
- const props$M = {
3339
+ const props$N = {
2928
3340
  src: String,
2929
3341
  fit: String,
2930
3342
  lazy: Boolean,
@@ -2983,7 +3395,7 @@ const IMGStore$1 = new IMGStore();
2983
3395
 
2984
3396
  /** @jsxImportSource vue */
2985
3397
 
2986
- const COMPONENT_NAME$V = 'vc-image';
3398
+ const COMPONENT_NAME$X = 'vc-image';
2987
3399
  let isSupportObjectFit = false;
2988
3400
  window.addEventListener('DOMContentLoaded', () => {
2989
3401
  isSupportObjectFit = !vcShared.IS_SERVER && document.documentElement.style.objectFit !== undefined;
@@ -2996,9 +3408,9 @@ const ObjectFit = {
2996
3408
  SCALE_DOWN: 'scale-down'
2997
3409
  };
2998
3410
  const Image = /* @__PURE__ */ vue.defineComponent({
2999
- name: COMPONENT_NAME$V,
3411
+ name: COMPONENT_NAME$X,
3000
3412
  inheritAttrs: false,
3001
- props: props$M,
3413
+ props: props$N,
3002
3414
  setup(props, {
3003
3415
  slots,
3004
3416
  emit
@@ -3192,7 +3604,7 @@ const Image = /* @__PURE__ */ vue.defineComponent({
3192
3604
 
3193
3605
  const MImage = Image;
3194
3606
 
3195
- const props$L = {
3607
+ const props$M = {
3196
3608
  tag: {
3197
3609
  type: String,
3198
3610
  default: "div"
@@ -3201,10 +3613,10 @@ const props$L = {
3201
3613
 
3202
3614
  /** @jsxImportSource vue */
3203
3615
 
3204
- const COMPONENT_NAME$U = 'vc-image-crop';
3616
+ const COMPONENT_NAME$W = 'vc-image-crop';
3205
3617
  const ImageCrop = /* @__PURE__ */ vue.defineComponent({
3206
- name: COMPONENT_NAME$U,
3207
- props: props$L,
3618
+ name: COMPONENT_NAME$W,
3619
+ props: props$M,
3208
3620
  setup(props, {
3209
3621
  slots
3210
3622
  }) {
@@ -3218,7 +3630,7 @@ const ImageCrop = /* @__PURE__ */ vue.defineComponent({
3218
3630
 
3219
3631
  const MImageCrop = ImageCrop;
3220
3632
 
3221
- const props$K = {
3633
+ const props$L = {
3222
3634
  tag: {
3223
3635
  type: String,
3224
3636
  default: "div"
@@ -3227,10 +3639,10 @@ const props$K = {
3227
3639
 
3228
3640
  /** @jsxImportSource vue */
3229
3641
 
3230
- const COMPONENT_NAME$T = 'vc-image-preview';
3642
+ const COMPONENT_NAME$V = 'vc-image-preview';
3231
3643
  const ImagePreview = /* @__PURE__ */ vue.defineComponent({
3232
- name: COMPONENT_NAME$T,
3233
- props: props$K,
3644
+ name: COMPONENT_NAME$V,
3645
+ props: props$L,
3234
3646
  setup(props, {
3235
3647
  slots
3236
3648
  }) {
@@ -3244,7 +3656,7 @@ const ImagePreview = /* @__PURE__ */ vue.defineComponent({
3244
3656
 
3245
3657
  const MImagePreview = ImagePreview;
3246
3658
 
3247
- const props$J = {
3659
+ const props$K = {
3248
3660
  tag: {
3249
3661
  type: String,
3250
3662
  default: "div"
@@ -3253,10 +3665,10 @@ const props$J = {
3253
3665
 
3254
3666
  /** @jsxImportSource vue */
3255
3667
 
3256
- const COMPONENT_NAME$S = 'vc-image-processing';
3668
+ const COMPONENT_NAME$U = 'vc-image-processing';
3257
3669
  const ImageProcessing = /* @__PURE__ */ vue.defineComponent({
3258
- name: COMPONENT_NAME$S,
3259
- props: props$J,
3670
+ name: COMPONENT_NAME$U,
3671
+ props: props$K,
3260
3672
  setup(props, {
3261
3673
  slots
3262
3674
  }) {
@@ -3270,7 +3682,7 @@ const ImageProcessing = /* @__PURE__ */ vue.defineComponent({
3270
3682
 
3271
3683
  const MImageProcessing = ImageProcessing;
3272
3684
 
3273
- const props$I = {
3685
+ const props$J = {
3274
3686
  // Array, 作为select等数组存放临时值
3275
3687
  modelValue: {
3276
3688
  type: [String, Number, Array],
@@ -3369,7 +3781,7 @@ const useInput = (input) => {
3369
3781
  const isFocus = vue.ref(false);
3370
3782
  const isClearing = vue.ref(false);
3371
3783
  const isOnComposition = vue.ref(false);
3372
- const formItem = vue.inject("form-item", {});
3784
+ const formItem = vue.inject("vc-form-item", {});
3373
3785
  vue.watch(
3374
3786
  () => props.modelValue,
3375
3787
  (v) => {
@@ -3524,12 +3936,12 @@ const useNativeEmitter = (input, expose) => {
3524
3936
 
3525
3937
  /** @jsxImportSource vue */
3526
3938
 
3527
- const COMPONENT_NAME$R = 'vc-input';
3939
+ const COMPONENT_NAME$T = 'vc-input';
3528
3940
  const Input = /* @__PURE__ */ vue.defineComponent({
3529
- name: COMPONENT_NAME$R,
3941
+ name: COMPONENT_NAME$T,
3530
3942
  inheritAttrs: false,
3531
3943
  props: {
3532
- ...props$I,
3944
+ ...props$J,
3533
3945
  indicator: {
3534
3946
  type: [Boolean, Object],
3535
3947
  default: false
@@ -3630,8 +4042,8 @@ const Input = /* @__PURE__ */ vue.defineComponent({
3630
4042
  }
3631
4043
  });
3632
4044
 
3633
- const props$H = {
3634
- ...props$I,
4045
+ const props$I = {
4046
+ ...props$J,
3635
4047
  min: {
3636
4048
  type: Number,
3637
4049
  default: 0
@@ -3846,10 +4258,10 @@ const useInputNumber = () => {
3846
4258
 
3847
4259
  /** @jsxImportSource vue */
3848
4260
 
3849
- const COMPONENT_NAME$Q = 'vc-input-number';
4261
+ const COMPONENT_NAME$S = 'vc-input-number';
3850
4262
  const InputNumber = /* @__PURE__ */ vue.defineComponent({
3851
- name: COMPONENT_NAME$Q,
3852
- props: props$H,
4263
+ name: COMPONENT_NAME$S,
4264
+ props: props$I,
3853
4265
  inheritAttrs: false,
3854
4266
  setup(props, {
3855
4267
  slots,
@@ -3900,8 +4312,8 @@ const InputNumber = /* @__PURE__ */ vue.defineComponent({
3900
4312
  }
3901
4313
  });
3902
4314
 
3903
- const props$G = {
3904
- ...props$I,
4315
+ const props$H = {
4316
+ ...props$J,
3905
4317
  enterText: {
3906
4318
  type: [Boolean, String],
3907
4319
  default: true
@@ -3910,10 +4322,10 @@ const props$G = {
3910
4322
 
3911
4323
  /** @jsxImportSource vue */
3912
4324
 
3913
- const COMPONENT_NAME$P = 'vc-input-search';
4325
+ const COMPONENT_NAME$R = 'vc-input-search';
3914
4326
  const InputSearch = /* @__PURE__ */ vue.defineComponent({
3915
- name: COMPONENT_NAME$P,
3916
- props: props$G,
4327
+ name: COMPONENT_NAME$R,
4328
+ props: props$H,
3917
4329
  inheritAttrs: false,
3918
4330
  setup(props, {
3919
4331
  emit,
@@ -3947,12 +4359,12 @@ const InputSearch = /* @__PURE__ */ vue.defineComponent({
3947
4359
 
3948
4360
  /** @jsxImportSource vue */
3949
4361
 
3950
- const COMPONENT_NAME$O = 'vcm-input';
4362
+ const COMPONENT_NAME$Q = 'vcm-input';
3951
4363
  const MInput = /* @__PURE__ */ vue.defineComponent({
3952
- name: COMPONENT_NAME$O,
4364
+ name: COMPONENT_NAME$Q,
3953
4365
  inheritAttrs: false,
3954
4366
  props: {
3955
- ...props$I,
4367
+ ...props$J,
3956
4368
  right: {
3957
4369
  type: Boolean,
3958
4370
  default: false
@@ -4038,10 +4450,10 @@ const MInput = /* @__PURE__ */ vue.defineComponent({
4038
4450
 
4039
4451
  /** @jsxImportSource vue */
4040
4452
 
4041
- const COMPONENT_NAME$N = 'vcm-input-number';
4453
+ const COMPONENT_NAME$P = 'vcm-input-number';
4042
4454
  const MInputNumber = /* @__PURE__ */ vue.defineComponent({
4043
- name: COMPONENT_NAME$N,
4044
- props: props$H,
4455
+ name: COMPONENT_NAME$P,
4456
+ props: props$I,
4045
4457
  inheritAttrs: false,
4046
4458
  setup(props, {
4047
4459
  slots,
@@ -4089,11 +4501,11 @@ const MInputNumber = /* @__PURE__ */ vue.defineComponent({
4089
4501
 
4090
4502
  /** @jsxImportSource vue */
4091
4503
 
4092
- const COMPONENT_NAME$M = 'vcm-input-search';
4504
+ const COMPONENT_NAME$O = 'vcm-input-search';
4093
4505
  const MInputSearch = /* @__PURE__ */ vue.defineComponent({
4094
- name: COMPONENT_NAME$M,
4506
+ name: COMPONENT_NAME$O,
4095
4507
  props: {
4096
- ...props$G,
4508
+ ...props$H,
4097
4509
  cancelText: {
4098
4510
  type: String,
4099
4511
  default: '取消'
@@ -4153,7 +4565,7 @@ const MInputSearch = /* @__PURE__ */ vue.defineComponent({
4153
4565
  }
4154
4566
  });
4155
4567
 
4156
- const props$F = {
4568
+ const props$G = {
4157
4569
  tag: {
4158
4570
  type: String,
4159
4571
  default: "div"
@@ -4168,12 +4580,12 @@ const props$F = {
4168
4580
  }
4169
4581
  };
4170
4582
 
4171
- const COMPONENT_NAME$L = "vcm-list";
4583
+ const COMPONENT_NAME$N = "vcm-list";
4172
4584
  const MList = vue.defineComponent({
4173
- name: COMPONENT_NAME$L,
4174
- props: props$F,
4585
+ name: COMPONENT_NAME$N,
4586
+ props: props$G,
4175
4587
  setup(props, { slots }) {
4176
- vue.provide("list", { props });
4588
+ vue.provide("vc-list", { props });
4177
4589
  return () => {
4178
4590
  return vue.h(
4179
4591
  props.tag,
@@ -4191,7 +4603,7 @@ const MList = vue.defineComponent({
4191
4603
  }
4192
4604
  });
4193
4605
 
4194
- const props$E = {
4606
+ const props$F = {
4195
4607
  tag: {
4196
4608
  type: String,
4197
4609
  default: "div"
@@ -4225,17 +4637,17 @@ const props$E = {
4225
4637
 
4226
4638
  /** @jsxImportSource vue */
4227
4639
 
4228
- const COMPONENT_NAME$K = 'vcm-list-item';
4640
+ const COMPONENT_NAME$M = 'vcm-list-item';
4229
4641
  const HTTP_REGEX = /[a-zA-z]+:\/\/[^\s]*/;
4230
4642
  const MListItem = /* @__PURE__ */ vue.defineComponent({
4231
- name: COMPONENT_NAME$K,
4232
- props: props$E,
4643
+ name: COMPONENT_NAME$M,
4644
+ props: props$F,
4233
4645
  emits: ['click'],
4234
4646
  setup(props, {
4235
4647
  slots,
4236
4648
  emit
4237
4649
  }) {
4238
- const list = vue.inject('list', {});
4650
+ const list = vue.inject('vc-list', {});
4239
4651
  const classes = vue.computed(() => {
4240
4652
  const hasList = !!list.props;
4241
4653
  return {
@@ -4303,7 +4715,7 @@ const MListItem = /* @__PURE__ */ vue.defineComponent({
4303
4715
  }
4304
4716
  });
4305
4717
 
4306
- const props$D = {
4718
+ const props$E = {
4307
4719
  tag: {
4308
4720
  type: String,
4309
4721
  default: "div"
@@ -4312,10 +4724,10 @@ const props$D = {
4312
4724
 
4313
4725
  /** @jsxImportSource vue */
4314
4726
 
4315
- const COMPONENT_NAME$J = 'vc-marquee';
4727
+ const COMPONENT_NAME$L = 'vc-marquee';
4316
4728
  const Marquee = /* @__PURE__ */ vue.defineComponent({
4317
- name: COMPONENT_NAME$J,
4318
- props: props$D,
4729
+ name: COMPONENT_NAME$L,
4730
+ props: props$E,
4319
4731
  setup(props, {
4320
4732
  slots
4321
4733
  }) {
@@ -4329,7 +4741,7 @@ const Marquee = /* @__PURE__ */ vue.defineComponent({
4329
4741
 
4330
4742
  const MMarquee = Marquee;
4331
4743
 
4332
- const props$C = {
4744
+ const props$D = {
4333
4745
  content: [String, Function],
4334
4746
  mask: {
4335
4747
  type: Boolean,
@@ -4367,11 +4779,11 @@ const props$C = {
4367
4779
 
4368
4780
  /** @jsxImportSource vue */
4369
4781
 
4370
- const COMPONENT_NAME$I = 'vc-message';
4782
+ const COMPONENT_NAME$K = 'vc-message';
4371
4783
  const MessageView = /* @__PURE__ */ vue.defineComponent({
4372
- name: COMPONENT_NAME$I,
4784
+ name: COMPONENT_NAME$K,
4373
4785
  emits: ['before-close', 'close', 'portal-fulfilled'],
4374
- props: props$C,
4786
+ props: props$D,
4375
4787
  setup(props, {
4376
4788
  emit,
4377
4789
  expose
@@ -4379,6 +4791,12 @@ const MessageView = /* @__PURE__ */ vue.defineComponent({
4379
4791
  const instance = vue.getCurrentInstance();
4380
4792
  const isActive = vue.ref(false);
4381
4793
  const currentContent = vue.ref();
4794
+ let timer;
4795
+ const setDuration = v => {
4796
+ timer && clearTimeout(timer);
4797
+ if (v === 0) return;
4798
+ timer = setTimeout(() => isActive.value = false, v);
4799
+ };
4382
4800
  const setContent = v => {
4383
4801
  currentContent.value = v;
4384
4802
  };
@@ -4404,12 +4822,9 @@ const MessageView = /* @__PURE__ */ vue.defineComponent({
4404
4822
  vue.watch(() => props.content, setContent, {
4405
4823
  immediate: true
4406
4824
  });
4407
- let timer;
4408
4825
  vue.onMounted(() => {
4409
4826
  isActive.value = true;
4410
- if (props.duration !== 0) {
4411
- timer = setTimeout(() => isActive.value = false, props.duration);
4412
- }
4827
+ setDuration(props.duration);
4413
4828
  });
4414
4829
  vue.onUnmounted(() => {
4415
4830
  timer && clearTimeout(timer);
@@ -4418,7 +4833,8 @@ const MessageView = /* @__PURE__ */ vue.defineComponent({
4418
4833
  pre[key] = handleRemove;
4419
4834
  return pre;
4420
4835
  }, {
4421
- setContent
4836
+ setContent,
4837
+ setDuration
4422
4838
  });
4423
4839
  expose(exposes);
4424
4840
  return () => {
@@ -4428,7 +4844,7 @@ const MessageView = /* @__PURE__ */ vue.defineComponent({
4428
4844
  "class": "vc-message__mask",
4429
4845
  "onClick": e => handleClose(e, props.maskClosable)
4430
4846
  }, null), vue.createVNode(TransitionSlide, {
4431
- "mode": "up",
4847
+ "mode": "bottom",
4432
4848
  "onAfterLeave": handleRemove
4433
4849
  }, {
4434
4850
  default: () => [vue.withDirectives(vue.createVNode("div", {
@@ -4508,7 +4924,7 @@ const Message$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty(
4508
4924
 
4509
4925
  const MMessage = Message$1;
4510
4926
 
4511
- const props$B = {
4927
+ const props$C = {
4512
4928
  modelValue: {
4513
4929
  type: Boolean,
4514
4930
  default: false
@@ -4588,12 +5004,12 @@ const props$B = {
4588
5004
 
4589
5005
  /** @jsxImportSource vue */
4590
5006
 
4591
- const COMPONENT_NAME$H = 'vc-modal';
5007
+ const COMPONENT_NAME$J = 'vc-modal';
4592
5008
  let zIndexNumber = 1002;
4593
5009
  const ModalView = /* @__PURE__ */ vue.defineComponent({
4594
- name: COMPONENT_NAME$H,
5010
+ name: COMPONENT_NAME$J,
4595
5011
  emits: ['update:modelValue', 'close', 'portal-fulfilled', 'visible-change', 'ok', 'cancel'],
4596
- props: props$B,
5012
+ props: props$C,
4597
5013
  setup(props, {
4598
5014
  slots,
4599
5015
  emit,
@@ -4820,6 +5236,10 @@ const ModalView = /* @__PURE__ */ vue.defineComponent({
4820
5236
  expose({
4821
5237
  isActive,
4822
5238
  // for portal
5239
+ toggle(v) {
5240
+ v = typeof v === 'boolean' ? v : !isActive.value;
5241
+ isActive.value = v;
5242
+ },
4823
5243
  resetOrigin
4824
5244
  });
4825
5245
  return () => {
@@ -4910,7 +5330,7 @@ const create$2 = (mode) => (options) => {
4910
5330
  // 当组件内使用emit('close'),避免重复触发
4911
5331
  onClose: null
4912
5332
  });
4913
- leaf.wrapper.isActive = true;
5333
+ leaf.wrapper.toggle?.(true);
4914
5334
  return leaf;
4915
5335
  };
4916
5336
  const destroy$2 = () => Modal.destroy();
@@ -4928,7 +5348,7 @@ const modal$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
4928
5348
  warning: warning$1
4929
5349
  }, Symbol.toStringTag, { value: 'Module' }));
4930
5350
 
4931
- const props$A = {
5351
+ const props$B = {
4932
5352
  mode: {
4933
5353
  type: String,
4934
5354
  validator: (v) => /(alert|operation)/.test(v),
@@ -4990,11 +5410,11 @@ const props$A = {
4990
5410
 
4991
5411
  /** @jsxImportSource vue */
4992
5412
 
4993
- const COMPONENT_NAME$G = 'vc-modal';
5413
+ const COMPONENT_NAME$I = 'vc-modal';
4994
5414
  const MModalView = /* @__PURE__ */ vue.defineComponent({
4995
- name: COMPONENT_NAME$G,
5415
+ name: COMPONENT_NAME$I,
4996
5416
  emits: ['update:modelValue', 'portal-fulfilled', 'close', 'ok', 'cancel'],
4997
- props: props$A,
5417
+ props: props$B,
4998
5418
  setup(props, {
4999
5419
  slots,
5000
5420
  emit,
@@ -5167,7 +5587,7 @@ const modal = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
5167
5587
  operation
5168
5588
  }, Symbol.toStringTag, { value: 'Module' }));
5169
5589
 
5170
- const props$z = {
5590
+ const props$A = {
5171
5591
  title: [String, Function],
5172
5592
  content: [String, Function],
5173
5593
  // 单位ms
@@ -5197,40 +5617,31 @@ const props$z = {
5197
5617
 
5198
5618
  /** @jsxImportSource vue */
5199
5619
 
5200
- const COMPONENT_NAME$F = 'vc-notice';
5620
+ const COMPONENT_NAME$H = 'vc-notice';
5201
5621
  const NoticeView = /* @__PURE__ */ vue.defineComponent({
5202
- name: COMPONENT_NAME$F,
5203
- props: props$z,
5622
+ name: COMPONENT_NAME$H,
5623
+ props: props$A,
5204
5624
  emits: ['portal-fulfilled', 'close', 'before-close'],
5205
5625
  setup(props, {
5206
- emit
5626
+ emit,
5627
+ expose
5207
5628
  }) {
5208
5629
  const instance = vue.getCurrentInstance();
5209
5630
  const isActive = vue.ref(false);
5210
5631
  const currentTitle = vue.ref();
5211
5632
  const currentContent = vue.ref();
5633
+ let timer;
5634
+ const setDuration = v => {
5635
+ timer && clearTimeout(timer);
5636
+ if (v === 0) return;
5637
+ timer = setTimeout(() => isActive.value = false, v);
5638
+ };
5212
5639
  const setTitle = v => {
5213
5640
  currentTitle.value = v;
5214
5641
  };
5215
5642
  const setContent = v => {
5216
5643
  currentContent.value = v;
5217
5644
  };
5218
- vue.watch(() => props.title, setTitle, {
5219
- immediate: true
5220
- });
5221
- vue.watch(() => props.content, setContent, {
5222
- immediate: true
5223
- });
5224
- let timer;
5225
- vue.onMounted(() => {
5226
- isActive.value = true;
5227
- if (props.duration !== 0) {
5228
- timer = setTimeout(() => isActive.value = false, props.duration);
5229
- }
5230
- });
5231
- vue.onUnmounted(() => {
5232
- timer && clearTimeout(timer);
5233
- });
5234
5645
 
5235
5646
  // 兼容Portal设计
5236
5647
  const handleRemove = () => {
@@ -5250,6 +5661,27 @@ const NoticeView = /* @__PURE__ */ vue.defineComponent({
5250
5661
  isActive.value = false;
5251
5662
  }
5252
5663
  };
5664
+ vue.watch(() => props.title, setTitle, {
5665
+ immediate: true
5666
+ });
5667
+ vue.watch(() => props.content, setContent, {
5668
+ immediate: true
5669
+ });
5670
+ vue.onMounted(() => {
5671
+ isActive.value = true;
5672
+ setDuration(props.duration);
5673
+ });
5674
+ vue.onUnmounted(() => {
5675
+ timer && clearTimeout(timer);
5676
+ });
5677
+ const exposes = ['destroy', 'remove', 'close', 'hide'].reduce((pre, key) => {
5678
+ pre[key] = handleRemove;
5679
+ return pre;
5680
+ }, {
5681
+ setContent,
5682
+ setDuration
5683
+ });
5684
+ expose(exposes);
5253
5685
  return () => {
5254
5686
  return vue.createVNode("div", {
5255
5687
  "class": ['vc-notice', {
@@ -5360,7 +5792,7 @@ const Notice$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
5360
5792
 
5361
5793
  const MNotice = Notice$1;
5362
5794
 
5363
- const props$y = {
5795
+ const props$z = {
5364
5796
  tag: {
5365
5797
  type: String,
5366
5798
  default: "div"
@@ -5369,10 +5801,10 @@ const props$y = {
5369
5801
 
5370
5802
  /** @jsxImportSource vue */
5371
5803
 
5372
- const COMPONENT_NAME$E = 'vc-option';
5804
+ const COMPONENT_NAME$G = 'vc-option';
5373
5805
  const Option = /* @__PURE__ */ vue.defineComponent({
5374
- name: COMPONENT_NAME$E,
5375
- props: props$y,
5806
+ name: COMPONENT_NAME$G,
5807
+ props: props$z,
5376
5808
  setup(props, {
5377
5809
  slots
5378
5810
  }) {
@@ -5386,7 +5818,7 @@ const Option = /* @__PURE__ */ vue.defineComponent({
5386
5818
 
5387
5819
  const MOption = Option;
5388
5820
 
5389
- const props$x = {
5821
+ const props$y = {
5390
5822
  tag: {
5391
5823
  type: String,
5392
5824
  default: "div"
@@ -5395,10 +5827,10 @@ const props$x = {
5395
5827
 
5396
5828
  /** @jsxImportSource vue */
5397
5829
 
5398
- const COMPONENT_NAME$D = 'vc-page';
5830
+ const COMPONENT_NAME$F = 'vc-page';
5399
5831
  const Page = /* @__PURE__ */ vue.defineComponent({
5400
- name: COMPONENT_NAME$D,
5401
- props: props$x,
5832
+ name: COMPONENT_NAME$F,
5833
+ props: props$y,
5402
5834
  setup(props, {
5403
5835
  slots
5404
5836
  }) {
@@ -5412,7 +5844,7 @@ const Page = /* @__PURE__ */ vue.defineComponent({
5412
5844
 
5413
5845
  const MPage = Page;
5414
5846
 
5415
- const props$w = {
5847
+ const props$x = {
5416
5848
  tag: {
5417
5849
  type: String,
5418
5850
  default: "div"
@@ -5421,10 +5853,10 @@ const props$w = {
5421
5853
 
5422
5854
  /** @jsxImportSource vue */
5423
5855
 
5424
- const COMPONENT_NAME$C = 'vc-picker';
5856
+ const COMPONENT_NAME$E = 'vc-picker';
5425
5857
  const Picker = /* @__PURE__ */ vue.defineComponent({
5426
- name: COMPONENT_NAME$C,
5427
- props: props$w,
5858
+ name: COMPONENT_NAME$E,
5859
+ props: props$x,
5428
5860
  setup(props, {
5429
5861
  slots
5430
5862
  }) {
@@ -5438,7 +5870,7 @@ const Picker = /* @__PURE__ */ vue.defineComponent({
5438
5870
 
5439
5871
  const MPicker = Picker;
5440
5872
 
5441
- const props$v = {
5873
+ const props$w = {
5442
5874
  tag: {
5443
5875
  type: String,
5444
5876
  default: "div"
@@ -5447,10 +5879,10 @@ const props$v = {
5447
5879
 
5448
5880
  /** @jsxImportSource vue */
5449
5881
 
5450
- const COMPONENT_NAME$B = 'vc-popconfirm';
5882
+ const COMPONENT_NAME$D = 'vc-popconfirm';
5451
5883
  const Popconfirm = /* @__PURE__ */ vue.defineComponent({
5452
- name: COMPONENT_NAME$B,
5453
- props: props$v,
5884
+ name: COMPONENT_NAME$D,
5885
+ props: props$w,
5454
5886
  setup(props, {
5455
5887
  slots
5456
5888
  }) {
@@ -5464,7 +5896,7 @@ const Popconfirm = /* @__PURE__ */ vue.defineComponent({
5464
5896
 
5465
5897
  const MPopconfirm = Popconfirm;
5466
5898
 
5467
- const props$u = {
5899
+ const props$v = {
5468
5900
  modelValue: Boolean,
5469
5901
  animation: String,
5470
5902
  placement: {
@@ -5543,7 +5975,7 @@ const wrapperKeys = [
5543
5975
  "autoWidth",
5544
5976
  "always"
5545
5977
  ];
5546
- const props$t = {
5978
+ const props$u = {
5547
5979
  trigger: {
5548
5980
  type: String,
5549
5981
  default: "hover",
@@ -5561,7 +5993,7 @@ const props$t = {
5561
5993
  type: Boolean,
5562
5994
  default: true
5563
5995
  },
5564
- ...lodashEs.pick(props$u, wrapperKeys)
5996
+ ...lodashEs.pick(props$v, wrapperKeys)
5565
5997
  };
5566
5998
 
5567
5999
  const EXTRA_DISTANCE = 4;
@@ -5822,10 +6254,10 @@ const usePos = () => {
5822
6254
  function _isSlot(s) {
5823
6255
  return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !vue.isVNode(s);
5824
6256
  }
5825
- const COMPONENT_NAME$A = 'vc-popover-wrapper';
6257
+ const COMPONENT_NAME$C = 'vc-popover-wrapper';
5826
6258
  const PopoverWrapper = /* @__PURE__ */ vue.defineComponent({
5827
- name: COMPONENT_NAME$A,
5828
- props: props$u,
6259
+ name: COMPONENT_NAME$C,
6260
+ props: props$v,
5829
6261
  emits: ['portal-fulfilled', 'close'],
5830
6262
  setup(props, {
5831
6263
  emit,
@@ -6035,7 +6467,11 @@ const PopoverWrapper = /* @__PURE__ */ vue.defineComponent({
6035
6467
  props.alone && props.hover && removeEvents();
6036
6468
  });
6037
6469
  expose({
6038
- isActive
6470
+ isActive,
6471
+ toggle(v) {
6472
+ v = typeof v === 'boolean' ? v : !isActive.value;
6473
+ isActive.value = v;
6474
+ }
6039
6475
  });
6040
6476
  return () => {
6041
6477
  let _slot;
@@ -6075,10 +6511,10 @@ const PopoverPortal = new Portal(PopoverWrapper);
6075
6511
 
6076
6512
  /** @jsxImportSource vue */
6077
6513
 
6078
- const COMPONENT_NAME$z = 'vc-popover';
6514
+ const COMPONENT_NAME$B = 'vc-popover';
6079
6515
  const Popover = /* @__PURE__ */ vue.defineComponent({
6080
- name: COMPONENT_NAME$z,
6081
- props: props$t,
6516
+ name: COMPONENT_NAME$B,
6517
+ props: props$u,
6082
6518
  emits: ['update:modelValue', 'visible-change', 'ready', 'close'],
6083
6519
  open: PopoverPortal.popup.bind(PopoverPortal),
6084
6520
  setup(props, {
@@ -6172,7 +6608,7 @@ const Popover = /* @__PURE__ */ vue.defineComponent({
6172
6608
  portalClass
6173
6609
  });
6174
6610
  } else if (popperInstance && popperInstance.wrapper) {
6175
- popperInstance.wrapper.isActive = false;
6611
+ popperInstance.wrapper.toggle(false);
6176
6612
  }
6177
6613
  };
6178
6614
  vue.watch(() => props.modelValue, v => {
@@ -6215,7 +6651,7 @@ const Popover = /* @__PURE__ */ vue.defineComponent({
6215
6651
 
6216
6652
  const MPopover = Popover;
6217
6653
 
6218
- const props$s = {
6654
+ const props$t = {
6219
6655
  tag: {
6220
6656
  type: String,
6221
6657
  default: "div"
@@ -6224,10 +6660,10 @@ const props$s = {
6224
6660
 
6225
6661
  /** @jsxImportSource vue */
6226
6662
 
6227
- const COMPONENT_NAME$y = 'vc-popup';
6663
+ const COMPONENT_NAME$A = 'vc-popup';
6228
6664
  const Popup = /* @__PURE__ */ vue.defineComponent({
6229
- name: COMPONENT_NAME$y,
6230
- props: props$s,
6665
+ name: COMPONENT_NAME$A,
6666
+ props: props$t,
6231
6667
  setup(props, {
6232
6668
  slots
6233
6669
  }) {
@@ -6243,7 +6679,7 @@ const MPopup = Popup;
6243
6679
 
6244
6680
  const MPortal = Portal;
6245
6681
 
6246
- const props$r = {
6682
+ const props$s = {
6247
6683
  tag: {
6248
6684
  type: String,
6249
6685
  default: "div"
@@ -6252,10 +6688,10 @@ const props$r = {
6252
6688
 
6253
6689
  /** @jsxImportSource vue */
6254
6690
 
6255
- const COMPONENT_NAME$x = 'vc-print';
6691
+ const COMPONENT_NAME$z = 'vc-print';
6256
6692
  const Print = /* @__PURE__ */ vue.defineComponent({
6257
- name: COMPONENT_NAME$x,
6258
- props: props$r,
6693
+ name: COMPONENT_NAME$z,
6694
+ props: props$s,
6259
6695
  setup(props, {
6260
6696
  slots
6261
6697
  }) {
@@ -6269,7 +6705,7 @@ const Print = /* @__PURE__ */ vue.defineComponent({
6269
6705
 
6270
6706
  const MPrint = Print;
6271
6707
 
6272
- const props$q = {
6708
+ const props$r = {
6273
6709
  tag: {
6274
6710
  type: String,
6275
6711
  default: "div"
@@ -6278,10 +6714,10 @@ const props$q = {
6278
6714
 
6279
6715
  /** @jsxImportSource vue */
6280
6716
 
6281
- const COMPONENT_NAME$w = 'vc-progress';
6717
+ const COMPONENT_NAME$y = 'vc-progress';
6282
6718
  const Progress = /* @__PURE__ */ vue.defineComponent({
6283
- name: COMPONENT_NAME$w,
6284
- props: props$q,
6719
+ name: COMPONENT_NAME$y,
6720
+ props: props$r,
6285
6721
  setup(props, {
6286
6722
  slots
6287
6723
  }) {
@@ -6295,7 +6731,7 @@ const Progress = /* @__PURE__ */ vue.defineComponent({
6295
6731
 
6296
6732
  const MProgress = Progress;
6297
6733
 
6298
- const props$p = {
6734
+ const props$q = {
6299
6735
  tag: {
6300
6736
  type: String,
6301
6737
  default: "div"
@@ -6304,10 +6740,10 @@ const props$p = {
6304
6740
 
6305
6741
  /** @jsxImportSource vue */
6306
6742
 
6307
- const COMPONENT_NAME$v = 'vc-radio';
6743
+ const COMPONENT_NAME$x = 'vc-radio';
6308
6744
  const Radio = /* @__PURE__ */ vue.defineComponent({
6309
- name: COMPONENT_NAME$v,
6310
- props: props$p,
6745
+ name: COMPONENT_NAME$x,
6746
+ props: props$q,
6311
6747
  setup(props, {
6312
6748
  slots
6313
6749
  }) {
@@ -6321,7 +6757,7 @@ const Radio = /* @__PURE__ */ vue.defineComponent({
6321
6757
 
6322
6758
  const MRadio = Radio;
6323
6759
 
6324
- const props$o = {
6760
+ const props$p = {
6325
6761
  tag: {
6326
6762
  type: String,
6327
6763
  default: "div"
@@ -6330,10 +6766,10 @@ const props$o = {
6330
6766
 
6331
6767
  /** @jsxImportSource vue */
6332
6768
 
6333
- const COMPONENT_NAME$u = 'vc-rate';
6769
+ const COMPONENT_NAME$w = 'vc-rate';
6334
6770
  const Rate = /* @__PURE__ */ vue.defineComponent({
6335
- name: COMPONENT_NAME$u,
6336
- props: props$o,
6771
+ name: COMPONENT_NAME$w,
6772
+ props: props$p,
6337
6773
  setup(props, {
6338
6774
  slots
6339
6775
  }) {
@@ -6347,7 +6783,7 @@ const Rate = /* @__PURE__ */ vue.defineComponent({
6347
6783
 
6348
6784
  const MRate = Rate;
6349
6785
 
6350
- const props$n = {
6786
+ const props$o = {
6351
6787
  data: {
6352
6788
  type: Array,
6353
6789
  default: () => []
@@ -6398,7 +6834,7 @@ const props$n = {
6398
6834
  renderRefresh: Function
6399
6835
  };
6400
6836
 
6401
- const props$m = {
6837
+ const props$n = {
6402
6838
  vertical: Boolean,
6403
6839
  wrapperSize: {
6404
6840
  type: Number,
@@ -6453,7 +6889,7 @@ const barKeys$1 = [
6453
6889
  "thumbStyle",
6454
6890
  "thumbClass"
6455
6891
  ];
6456
- const props$l = {
6892
+ const props$m = {
6457
6893
  // 如果存在滚动条宽度为false, 不存在则为true
6458
6894
  // 为false的情况下才能使用track-offset
6459
6895
  native: {
@@ -6484,7 +6920,7 @@ const props$l = {
6484
6920
  scrollX: Number,
6485
6921
  scrollY: Number,
6486
6922
  fit: Boolean,
6487
- ...lodashEs.pick(props$m, barKeys$1)
6923
+ ...lodashEs.pick(props$n, barKeys$1)
6488
6924
  };
6489
6925
 
6490
6926
  const barKeys = [
@@ -6499,7 +6935,7 @@ const barKeys = [
6499
6935
  "autoResize",
6500
6936
  "native"
6501
6937
  ];
6502
- const props$k = {
6938
+ const props$l = {
6503
6939
  tag: {
6504
6940
  type: String,
6505
6941
  default: "div"
@@ -6532,13 +6968,13 @@ const props$k = {
6532
6968
  type: Boolean,
6533
6969
  default: true
6534
6970
  },
6535
- barTo: props$l.to,
6536
- ...lodashEs.pick(props$l, barKeys)
6971
+ barTo: props$m.to,
6972
+ ...lodashEs.pick(props$m, barKeys)
6537
6973
  };
6538
6974
 
6539
6975
  /** @jsxImportSource vue */
6540
6976
 
6541
- const COMPONENT_NAME$t = 'vc-scroller-track';
6977
+ const COMPONENT_NAME$v = 'vc-scroller-track';
6542
6978
  const BAR_MAP = {
6543
6979
  vertical: {
6544
6980
  scroll: 'scrollTop',
@@ -6558,8 +6994,8 @@ const BAR_MAP = {
6558
6994
  }
6559
6995
  };
6560
6996
  const Track = /* @__PURE__ */ vue.defineComponent({
6561
- name: COMPONENT_NAME$t,
6562
- props: props$m,
6997
+ name: COMPONENT_NAME$v,
6998
+ props: props$n,
6563
6999
  emits: ['change'],
6564
7000
  setup(props, {
6565
7001
  emit,
@@ -6744,10 +7180,10 @@ const Track = /* @__PURE__ */ vue.defineComponent({
6744
7180
 
6745
7181
  /** @jsxImportSource vue */
6746
7182
 
6747
- const COMPONENT_NAME$s = 'vc-scroller-bar';
7183
+ const COMPONENT_NAME$u = 'vc-scroller-bar';
6748
7184
  const Bar = /* @__PURE__ */ vue.defineComponent({
6749
- name: COMPONENT_NAME$s,
6750
- props: props$l,
7185
+ name: COMPONENT_NAME$u,
7186
+ props: props$m,
6751
7187
  emits: ['change'],
6752
7188
  setup(props, {
6753
7189
  emit,
@@ -6960,7 +7396,7 @@ const useScroller = (expose) => {
6960
7396
 
6961
7397
  /** @jsxImportSource vue */
6962
7398
 
6963
- const COMPONENT_NAME$r = 'vc-scroller';
7399
+ const COMPONENT_NAME$t = 'vc-scroller';
6964
7400
 
6965
7401
  /**
6966
7402
  * 作为备选方案,目前推荐使用ScrollerWheel
@@ -6971,8 +7407,8 @@ const COMPONENT_NAME$r = 'vc-scroller';
6971
7407
  * 2. 增加了一层嵌套
6972
7408
  */
6973
7409
  const Scroller = /* @__PURE__ */ vue.defineComponent({
6974
- name: COMPONENT_NAME$r,
6975
- props: props$k,
7410
+ name: COMPONENT_NAME$t,
7411
+ props: props$l,
6976
7412
  emits: ['scroll'],
6977
7413
  setup(props, {
6978
7414
  slots,
@@ -7032,7 +7468,7 @@ const Scroller = /* @__PURE__ */ vue.defineComponent({
7032
7468
 
7033
7469
  /** @jsxImportSource vue */
7034
7470
 
7035
- const COMPONENT_NAME$q = 'vc-scroller-wheel';
7471
+ const COMPONENT_NAME$s = 'vc-scroller-wheel';
7036
7472
 
7037
7473
  /**
7038
7474
  * 为减少一层嵌套,为去除滚动bar的抖动,使用wheel模拟
@@ -7054,8 +7490,8 @@ const COMPONENT_NAME$q = 'vc-scroller-wheel';
7054
7490
  * 设置scrollTop不会reflow和repaint,不需要考虑transfrom来改变content(transform也只在draw完成)
7055
7491
  */
7056
7492
  const ScrollerWheel = /* @__PURE__ */ vue.defineComponent({
7057
- name: COMPONENT_NAME$q,
7058
- props: props$k,
7493
+ name: COMPONENT_NAME$s,
7494
+ props: props$l,
7059
7495
  emits: ['scroll'],
7060
7496
  setup(props, {
7061
7497
  slots,
@@ -7159,9 +7595,9 @@ const ScrollerWheel = /* @__PURE__ */ vue.defineComponent({
7159
7595
 
7160
7596
  /** @jsxImportSource vue */
7161
7597
 
7162
- const COMPONENT_NAME$p = 'vc-recycle-list-scroll-state';
7598
+ const COMPONENT_NAME$r = 'vc-recycle-list-scroll-state';
7163
7599
  const ScrollState = /* @__PURE__ */ vue.defineComponent({
7164
- name: COMPONENT_NAME$p,
7600
+ name: COMPONENT_NAME$r,
7165
7601
  setup(_, {
7166
7602
  slots
7167
7603
  }) {
@@ -7232,7 +7668,7 @@ const STATUS_MAP = {
7232
7668
  }
7233
7669
  };
7234
7670
 
7235
- const props$j = {
7671
+ const props$k = {
7236
7672
  inverted: {
7237
7673
  type: Boolean,
7238
7674
  default: false
@@ -7291,13 +7727,13 @@ const useDirectionKeys = () => {
7291
7727
 
7292
7728
  /** @jsxImportSource vue */
7293
7729
 
7294
- const COMPONENT_NAME$o = 'vc-recycle-list-container';
7730
+ const COMPONENT_NAME$q = 'vc-recycle-list-container';
7295
7731
 
7296
7732
  // TODO: 抽离
7297
7733
  const transformKey = $__namespace.prefixStyle('transform').camel;
7298
7734
  const Container = /* @__PURE__ */ vue.defineComponent({
7299
- name: COMPONENT_NAME$o,
7300
- props: props$j,
7735
+ name: COMPONENT_NAME$q,
7736
+ props: props$k,
7301
7737
  emits: ['refresh'],
7302
7738
  setup(props, {
7303
7739
  slots
@@ -7394,16 +7830,16 @@ const Container = /* @__PURE__ */ vue.defineComponent({
7394
7830
 
7395
7831
  /** @jsxImportSource vue */
7396
7832
 
7397
- const COMPONENT_NAME$n = 'vc-recycle-list-item';
7833
+ const COMPONENT_NAME$p = 'vc-recycle-list-item';
7398
7834
  const Item = /* @__PURE__ */ vue.defineComponent({
7399
- name: COMPONENT_NAME$n,
7835
+ name: COMPONENT_NAME$p,
7400
7836
  props: {
7401
7837
  vertical: {
7402
7838
  type: Boolean,
7403
7839
  default: true
7404
7840
  }
7405
7841
  },
7406
- emits: ['resize'],
7842
+ emits: ['resize', 'change'],
7407
7843
  setup(_, {
7408
7844
  emit,
7409
7845
  slots
@@ -7415,9 +7851,10 @@ const Item = /* @__PURE__ */ vue.defineComponent({
7415
7851
  const handleResize = () => {
7416
7852
  const v = current.value.getBoundingClientRect()[K.size];
7417
7853
  const changed = offsetSize.value != v;
7418
- if (hasInitial && changed) {
7854
+ if (changed) {
7419
7855
  offsetSize.value = v;
7420
- emit('resize');
7856
+ hasInitial && emit('resize', v);
7857
+ emit('change', v);
7421
7858
  }
7422
7859
  hasInitial = true;
7423
7860
  };
@@ -7438,10 +7875,10 @@ const Item = /* @__PURE__ */ vue.defineComponent({
7438
7875
 
7439
7876
  /** @jsxImportSource vue */
7440
7877
 
7441
- const COMPONENT_NAME$m = 'vc-recycle-list';
7878
+ const COMPONENT_NAME$o = 'vc-recycle-list';
7442
7879
  const RecycleList = /* @__PURE__ */ vue.defineComponent({
7443
- name: COMPONENT_NAME$m,
7444
- props: props$n,
7880
+ name: COMPONENT_NAME$o,
7881
+ props: props$o,
7445
7882
  emits: ['scroll'],
7446
7883
  setup(props, {
7447
7884
  slots,
@@ -7985,18 +8422,18 @@ const RecycleList = /* @__PURE__ */ vue.defineComponent({
7985
8422
 
7986
8423
  const MRecycleList = RecycleList;
7987
8424
 
7988
- const props$i = {
8425
+ const props$j = {
7989
8426
  tag: {
7990
8427
  type: String,
7991
8428
  default: "div"
7992
8429
  }
7993
8430
  };
7994
8431
 
7995
- const COMPONENT_NAME$l = "vc-resizer";
8432
+ const COMPONENT_NAME$n = "vc-resizer";
7996
8433
  const Resizer = vue.defineComponent({
7997
- name: COMPONENT_NAME$l,
7998
- props: props$i,
7999
- emit: ["resize"],
8434
+ name: COMPONENT_NAME$n,
8435
+ props: props$j,
8436
+ emit: ["resize", "change"],
8000
8437
  setup(props, { emit, slots }) {
8001
8438
  const width = vue.ref(0);
8002
8439
  const height = vue.ref(0);
@@ -8022,8 +8459,9 @@ const Resizer = vue.defineComponent({
8022
8459
  const widthChanged = width.value != width$;
8023
8460
  heightChanged && (height.value = height$);
8024
8461
  widthChanged && (width.value = width$);
8025
- if (hasInitial && (heightChanged || widthChanged)) {
8026
- emit("resize", currentExposed.value);
8462
+ if (heightChanged || widthChanged) {
8463
+ hasInitial && emit("resize", currentExposed.value);
8464
+ emit("change", currentExposed.value);
8027
8465
  }
8028
8466
  hasInitial = true;
8029
8467
  };
@@ -8050,7 +8488,7 @@ const MResizer = Resizer;
8050
8488
 
8051
8489
  const MScroller = Scroller;
8052
8490
 
8053
- const props$h = {
8491
+ const props$i = {
8054
8492
  tag: {
8055
8493
  type: String,
8056
8494
  default: "div"
@@ -8059,10 +8497,10 @@ const props$h = {
8059
8497
 
8060
8498
  /** @jsxImportSource vue */
8061
8499
 
8062
- const COMPONENT_NAME$k = 'vc-select';
8500
+ const COMPONENT_NAME$m = 'vc-select';
8063
8501
  const Select = /* @__PURE__ */ vue.defineComponent({
8064
- name: COMPONENT_NAME$k,
8065
- props: props$h,
8502
+ name: COMPONENT_NAME$m,
8503
+ props: props$i,
8066
8504
  setup(props, {
8067
8505
  slots
8068
8506
  }) {
@@ -8076,7 +8514,7 @@ const Select = /* @__PURE__ */ vue.defineComponent({
8076
8514
 
8077
8515
  const MSelect = Select;
8078
8516
 
8079
- const props$g = {
8517
+ const props$h = {
8080
8518
  tag: {
8081
8519
  type: String,
8082
8520
  default: "div"
@@ -8085,10 +8523,10 @@ const props$g = {
8085
8523
 
8086
8524
  /** @jsxImportSource vue */
8087
8525
 
8088
- const COMPONENT_NAME$j = 'vc-slider';
8526
+ const COMPONENT_NAME$l = 'vc-slider';
8089
8527
  const Slider = /* @__PURE__ */ vue.defineComponent({
8090
- name: COMPONENT_NAME$j,
8091
- props: props$g,
8528
+ name: COMPONENT_NAME$l,
8529
+ props: props$h,
8092
8530
  setup(props, {
8093
8531
  slots
8094
8532
  }) {
@@ -8102,7 +8540,7 @@ const Slider = /* @__PURE__ */ vue.defineComponent({
8102
8540
 
8103
8541
  const MSlider = Slider;
8104
8542
 
8105
- const props$f = {
8543
+ const props$g = {
8106
8544
  tag: {
8107
8545
  type: String,
8108
8546
  default: "div"
@@ -8111,10 +8549,10 @@ const props$f = {
8111
8549
 
8112
8550
  /** @jsxImportSource vue */
8113
8551
 
8114
- const COMPONENT_NAME$i = 'vc-sort-list';
8552
+ const COMPONENT_NAME$k = 'vc-sort-list';
8115
8553
  const SortList = /* @__PURE__ */ vue.defineComponent({
8116
- name: COMPONENT_NAME$i,
8117
- props: props$f,
8554
+ name: COMPONENT_NAME$k,
8555
+ props: props$g,
8118
8556
  setup(props, {
8119
8557
  slots
8120
8558
  }) {
@@ -8128,7 +8566,7 @@ const SortList = /* @__PURE__ */ vue.defineComponent({
8128
8566
 
8129
8567
  const MSortList = SortList;
8130
8568
 
8131
- const props$e = {
8569
+ const props$f = {
8132
8570
  tag: {
8133
8571
  type: String,
8134
8572
  default: "div"
@@ -8137,10 +8575,10 @@ const props$e = {
8137
8575
 
8138
8576
  /** @jsxImportSource vue */
8139
8577
 
8140
- const COMPONENT_NAME$h = 'vc-steps';
8578
+ const COMPONENT_NAME$j = 'vc-steps';
8141
8579
  const Steps = /* @__PURE__ */ vue.defineComponent({
8142
- name: COMPONENT_NAME$h,
8143
- props: props$e,
8580
+ name: COMPONENT_NAME$j,
8581
+ props: props$f,
8144
8582
  setup(props, {
8145
8583
  slots
8146
8584
  }) {
@@ -8154,7 +8592,7 @@ const Steps = /* @__PURE__ */ vue.defineComponent({
8154
8592
 
8155
8593
  const MSteps = Steps;
8156
8594
 
8157
- const props$d = {
8595
+ const props$e = {
8158
8596
  tag: {
8159
8597
  type: String,
8160
8598
  default: "div"
@@ -8163,10 +8601,10 @@ const props$d = {
8163
8601
 
8164
8602
  /** @jsxImportSource vue */
8165
8603
 
8166
- const COMPONENT_NAME$g = 'vc-switch';
8604
+ const COMPONENT_NAME$i = 'vc-switch';
8167
8605
  const Switch = /* @__PURE__ */ vue.defineComponent({
8168
- name: COMPONENT_NAME$g,
8169
- props: props$d,
8606
+ name: COMPONENT_NAME$i,
8607
+ props: props$e,
8170
8608
  setup(props, {
8171
8609
  slots
8172
8610
  }) {
@@ -8180,7 +8618,7 @@ const Switch = /* @__PURE__ */ vue.defineComponent({
8180
8618
 
8181
8619
  const MSwitch = Switch;
8182
8620
 
8183
- const props$c = {
8621
+ const props$d = {
8184
8622
  tag: {
8185
8623
  type: String,
8186
8624
  default: "div"
@@ -8189,10 +8627,10 @@ const props$c = {
8189
8627
 
8190
8628
  /** @jsxImportSource vue */
8191
8629
 
8192
- const COMPONENT_NAME$f = 'vc-table';
8630
+ const COMPONENT_NAME$h = 'vc-table';
8193
8631
  const Table = /* @__PURE__ */ vue.defineComponent({
8194
- name: COMPONENT_NAME$f,
8195
- props: props$c,
8632
+ name: COMPONENT_NAME$h,
8633
+ props: props$d,
8196
8634
  setup(props, {
8197
8635
  slots
8198
8636
  }) {
@@ -8206,7 +8644,7 @@ const Table = /* @__PURE__ */ vue.defineComponent({
8206
8644
 
8207
8645
  const MTable = Table;
8208
8646
 
8209
- const props$b = {
8647
+ const props$c = {
8210
8648
  type: {
8211
8649
  type: String,
8212
8650
  validator: (v) => /^(line|card)$/.test(v),
@@ -8314,7 +8752,7 @@ const useTabs = (options = {}) => {
8314
8752
  if (!item) return;
8315
8753
  list.value.splice(list.value.indexOf(item.props), 1);
8316
8754
  };
8317
- vue.provide("tabs", {
8755
+ vue.provide("vc-tabs", {
8318
8756
  props,
8319
8757
  currentValue,
8320
8758
  refresh,
@@ -8361,10 +8799,10 @@ const useTabs = (options = {}) => {
8361
8799
 
8362
8800
  /** @jsxImportSource vue */
8363
8801
 
8364
- const COMPONENT_NAME$e = 'vc-tabs';
8802
+ const COMPONENT_NAME$g = 'vc-tabs';
8365
8803
  const Tabs = /* @__PURE__ */ vue.defineComponent({
8366
- name: COMPONENT_NAME$e,
8367
- props: props$b,
8804
+ name: COMPONENT_NAME$g,
8805
+ props: props$c,
8368
8806
  emits: ['update:modelValue', 'change', 'click'],
8369
8807
  setup(props, {
8370
8808
  slots
@@ -8529,7 +8967,7 @@ const Tabs = /* @__PURE__ */ vue.defineComponent({
8529
8967
  }
8530
8968
  });
8531
8969
 
8532
- const props$a = {
8970
+ const props$b = {
8533
8971
  value: {
8534
8972
  type: [String, Number]
8535
8973
  },
@@ -8556,7 +8994,7 @@ const useTabsPane = () => {
8556
8994
  const { props } = instance;
8557
8995
  const currentValue = vue.ref(void 0);
8558
8996
  const isLoaded = vue.ref(false);
8559
- const tabs = vue.inject("tabs", {});
8997
+ const tabs = vue.inject("vc-tabs", {});
8560
8998
  const isActive = vue.computed(() => {
8561
8999
  const state = tabs.currentValue.value === (props.value || currentValue.value);
8562
9000
  if (!isLoaded.value && state) {
@@ -8611,10 +9049,10 @@ const useTabsPane = () => {
8611
9049
 
8612
9050
  /** @jsxImportSource vue */
8613
9051
 
8614
- const COMPONENT_NAME$d = 'vc-tabs-pane';
9052
+ const COMPONENT_NAME$f = 'vc-tabs-pane';
8615
9053
  const TabsPane = /* @__PURE__ */ vue.defineComponent({
8616
- name: COMPONENT_NAME$d,
8617
- props: props$a,
9054
+ name: COMPONENT_NAME$f,
9055
+ props: props$b,
8618
9056
  setup(_, {
8619
9057
  slots
8620
9058
  }) {
@@ -8629,8 +9067,329 @@ const TabsPane = /* @__PURE__ */ vue.defineComponent({
8629
9067
  }
8630
9068
  });
8631
9069
 
8632
- const MTabs = Tabs;
8633
- const MTabsPane = TabsPane;
9070
+ const props$a = {
9071
+ ...props$c,
9072
+ theme: {
9073
+ type: String,
9074
+ default: "light",
9075
+ validator: (v) => /(light|dark)/.test(v)
9076
+ },
9077
+ barStyle: {
9078
+ type: [Object, Array],
9079
+ default: () => ({})
9080
+ },
9081
+ autoAfloatWidth: {
9082
+ type: Boolean,
9083
+ default: true
9084
+ },
9085
+ average: {
9086
+ type: Boolean,
9087
+ default: true
9088
+ },
9089
+ showWrapper: {
9090
+ type: Boolean,
9091
+ default: true
9092
+ },
9093
+ sticky: {
9094
+ type: Boolean,
9095
+ default: false
9096
+ },
9097
+ offsetTop: {
9098
+ type: Number,
9099
+ default: 0
9100
+ },
9101
+ showStep: {
9102
+ type: Boolean,
9103
+ default: false
9104
+ }
9105
+ };
9106
+
9107
+ /** @jsxImportSource vue */
9108
+
9109
+ const COMPONENT_NAME$e = 'vcm-tabs';
9110
+ const MTabs = /* @__PURE__ */ vue.defineComponent({
9111
+ name: COMPONENT_NAME$e,
9112
+ props: props$a,
9113
+ emits: ['update:modelValue', 'change', 'click'],
9114
+ setup(props, {
9115
+ slots
9116
+ }) {
9117
+ const instance = vue.getCurrentInstance();
9118
+ const wrapper = vue.ref(null);
9119
+ const content = vue.ref(null);
9120
+ const scroll = vue.ref(null);
9121
+ const nav = vue.ref(null);
9122
+ const top = vue.ref(0);
9123
+ const isFixed = vue.ref(false);
9124
+ const placeholderH = vue.ref(53);
9125
+ const startX = vue.ref(0);
9126
+ const isTouching = vue.ref(false);
9127
+ const scrollViewW = vue.ref(0); // 滚动容器宽度
9128
+ const scrollContentW = vue.ref(0); // 滚动内容宽度
9129
+ const baseX = vue.ref(0);
9130
+ const isDark = vue.computed(() => {
9131
+ return props.theme === 'dark';
9132
+ });
9133
+ const fixedStyle = vue.computed(() => {
9134
+ return isFixed.value ? {
9135
+ top: `${props.offsetTop}px`
9136
+ } : {};
9137
+ });
9138
+
9139
+ // eslint-disable-next-line prefer-const
9140
+ let tabs;
9141
+
9142
+ // TODO: 找到父层滚动条
9143
+ const handleScroll = lodashEs.throttle(() => {
9144
+ isFixed.value = document.scrollingElement.scrollTop + props.offsetTop > top.value;
9145
+ }, 100);
9146
+ const handleTouchstart = e => {
9147
+ isTouching.value = true;
9148
+ startX.value = e.touches[0].pageX;
9149
+ baseX.value = tabs.scrollOffset.value;
9150
+ };
9151
+ const handleTouchmove = lodashEs.throttle(e => {
9152
+ const touchPageX = e.touches[0].pageX;
9153
+ // 与touchstart时触点位置的距离偏移值,大于0时为触点向右移,反之向左
9154
+ const changedX = touchPageX - startX.value;
9155
+ if (changedX > 0) {
9156
+ if (tabs.scrollOffset.value >= 0) {
9157
+ tabs.scrollOffset.value = 0;
9158
+ return;
9159
+ }
9160
+ } else if (Math.abs(tabs.scrollOffset.value) + scrollViewW.value >= scrollContentW.value) {
9161
+ tabs.scrollOffset.value = -(scrollContentW.value - scrollViewW.value);
9162
+ return;
9163
+ }
9164
+ tabs.scrollOffset.value = baseX.value + touchPageX - startX.value;
9165
+ }, 17);
9166
+ const handleTouchend = () => {
9167
+ isTouching.value = false;
9168
+ // TODO: 惯性滚动、回弹 (体验优化)
9169
+ };
9170
+ const handleStep = flag => {
9171
+ if (!tabs.scrollable.value) return;
9172
+ const moveX = flag * scrollViewW.value;
9173
+ let offsetX = tabs.scrollOffset.value + moveX;
9174
+ if (offsetX < -(scrollContentW.value - scrollViewW.value) || offsetX > 0) {
9175
+ offsetX = flag === -1 ? -(scrollContentW.value - scrollViewW.value) : 0;
9176
+ }
9177
+ tabs.scrollOffset.value = offsetX;
9178
+ };
9179
+
9180
+ /**
9181
+ * 使用Resize时, 切换页面失效,换种方案
9182
+ */
9183
+ const refreshTop = lodashEs.debounce(() => {
9184
+ if (props.sticky) {
9185
+ top.value = content.value.offsetTop - placeholderH.value;
9186
+ isFixed.value = document.scrollingElement.scrollTop + props.offsetTop > top.value;
9187
+ }
9188
+ }, 250, {
9189
+ leading: true,
9190
+ trailing: true
9191
+ });
9192
+
9193
+ /**
9194
+ * 将选中的item滚动至可视区(尽量往中间靠)
9195
+ */
9196
+ const scrollToActive = () => {
9197
+ if (!tabs.scrollable.value) return;
9198
+ const activeEl = instance.vnode.el.querySelector(`.vcm-tabs__item[data-id="${tabs.currentValue.value}"]`);
9199
+ if (!activeEl) return;
9200
+ const contentEl = nav.value;
9201
+ const activeRect = activeEl.getBoundingClientRect();
9202
+ const viewRect = scroll.value.getBoundingClientRect();
9203
+ const contentRect = contentEl.getBoundingClientRect();
9204
+ let offset = 0;
9205
+ if (activeRect.width < viewRect.width) {
9206
+ // targetOffset为最理想的情况下,可以滚动到正中间,此时activeEl距scrollView的左右边距
9207
+ const targetOffset = (viewRect.width - activeRect.width) / 2;
9208
+ // offsetLeft其实等价于activeEl.offsetLeft,
9209
+ // 但是调试时发现这两个值在小数位会有差距,offsetLeft一直是整数,所以还是决定用下面这种方式计算offsetLeft
9210
+ const offsetLeft = activeRect.left - contentRect.left;
9211
+ if (offsetLeft - viewRect.left <= targetOffset) {
9212
+ // 左边距离不足以到正中间的情况
9213
+ offset = 0;
9214
+ } else if (contentRect.right - activeRect.right <= targetOffset) {
9215
+ // 右边距离不足以到正中间的情况
9216
+ offset = viewRect.width - contentRect.width; // 负值
9217
+ } else {
9218
+ offset = targetOffset - offsetLeft; // 可以滚动到正中间的理想情况
9219
+ }
9220
+ }
9221
+ tabs.scrollOffset.value = offset;
9222
+ };
9223
+ const operateDOMScrollEvents = type => {
9224
+ const fn = type === 'add' ? window.addEventListener : window.removeEventListener;
9225
+ fn('scroll', handleScroll);
9226
+ fn('touchstart', handleTouchstart, false);
9227
+ fn('touchmove', handleTouchmove, false);
9228
+ fn('touchend', handleTouchend, false);
9229
+ };
9230
+
9231
+ /**
9232
+ * 处理是否需要滚动
9233
+ */
9234
+ const refreshScroll = () => {
9235
+ const viewEl = scroll.value;
9236
+ scrollViewW.value = viewEl.offsetWidth;
9237
+ scrollContentW.value = nav.value.offsetWidth;
9238
+ if (scrollContentW.value > scrollViewW.value) {
9239
+ operateDOMScrollEvents('remove');
9240
+ operateDOMScrollEvents('add');
9241
+ tabs.scrollable.value = true;
9242
+ } else if (tabs.scrollable.value) {
9243
+ operateDOMScrollEvents('remove');
9244
+ tabs.scrollable.value = false;
9245
+ }
9246
+ tabs.scrollable.value && scrollToActive();
9247
+ };
9248
+
9249
+ /**
9250
+ * 刷新当前标签底下的滑块位置
9251
+ */
9252
+ const refreshAfloat = () => {
9253
+ if (!props.showWrapper) return;
9254
+ vue.nextTick(() => {
9255
+ const index = tabs.getTabIndex(tabs.currentValue.value);
9256
+ if (instance.isUnmounted) return;
9257
+ const items = nav.value.querySelectorAll(`.vcm-tabs__item`);
9258
+ const $ = items[index];
9259
+
9260
+ // 暂时写死42
9261
+ tabs.afloatWidth.value = $ ? isDark.value ? 20 : props.autoAfloatWidth ? $.querySelector('span').offsetWidth : $.offsetWidth : 0;
9262
+ if (!Array.from(items).length) return;
9263
+ let offset = 0;
9264
+ const basicOffset = $ ? ($.offsetWidth - tabs.afloatWidth.value) / 2 : 0;
9265
+ if (index > 0) {
9266
+ for (let i = 0; i < index; i++) {
9267
+ offset += parseFloat(items[i].offsetWidth);
9268
+ }
9269
+ }
9270
+ tabs.afloatOffset.value = offset + basicOffset;
9271
+ refreshScroll();
9272
+ });
9273
+ };
9274
+
9275
+ /**
9276
+ * TODO: 在height: 100%容器内滚动,让其带有粘性
9277
+ * @param type ~
9278
+ */
9279
+ const operateDOMEvents = type => {
9280
+ if (!props.sticky) return;
9281
+ const fn = type === 'add' ? window.addEventListener : window.removeEventListener;
9282
+ fn('scroll', handleScroll);
9283
+ };
9284
+ tabs = useTabs({
9285
+ content,
9286
+ wrapper,
9287
+ refreshAfloat,
9288
+ refreshScroll,
9289
+ scrollToActive
9290
+ });
9291
+ const scrollStyle = vue.computed(() => {
9292
+ return {
9293
+ transition: isTouching.value ? '' : 'transform 300ms ease-in-out',
9294
+ transform: `translate3d(${tabs.scrollOffset.value}px, 0, 0)`
9295
+ };
9296
+ });
9297
+ vue.onMounted(() => {
9298
+ refreshTop();
9299
+ operateDOMEvents('add');
9300
+ vue.nextTick(refreshScroll);
9301
+ });
9302
+ vue.onUpdated(refreshTop);
9303
+ vue.onUnmounted(() => {
9304
+ operateDOMEvents('remove');
9305
+ operateDOMScrollEvents('remove');
9306
+ });
9307
+ vue.watch(() => props.theme, refreshAfloat);
9308
+ vue.watch(() => props.average, refreshAfloat);
9309
+ vue.watch(() => props.showStep, () => vue.nextTick(refreshScroll));
9310
+ return () => {
9311
+ return vue.createVNode("div", {
9312
+ "class": [tabs.classes.value, 'vcm-tabs']
9313
+ }, [props.showWrapper && vue.createVNode("div", {
9314
+ "ref": wrapper,
9315
+ "style": [props.barStyle, fixedStyle.value],
9316
+ "class": [{
9317
+ 'is-fixed': isFixed
9318
+ }, 'vcm-tabs__bar']
9319
+ }, [vue.createVNode("slot", {
9320
+ "name": "prepend"
9321
+ }, null), slots.prepend?.(), props.showStep && tabs.scrollable.value && vue.createVNode("div", {
9322
+ "class": "vcm-tabs__step is-left",
9323
+ "onClick": () => handleStep(1)
9324
+ }, [vue.createVNode(Icon, {
9325
+ "type": "left"
9326
+ }, null)]), vue.createVNode("div", {
9327
+ "ref": scroll,
9328
+ "class": "vcm-tabs__scroll"
9329
+ }, [vue.createVNode("div", {
9330
+ "ref": nav,
9331
+ "style": scrollStyle.value,
9332
+ "class": "vcm-tabs__nav"
9333
+ }, [props.afloat && vue.createVNode("div", {
9334
+ "style": tabs.afloatStyle.value,
9335
+ "class": "vcm-tabs__afloat"
9336
+ }, null), tabs.list.value.map((item, index) => {
9337
+ return vue.createVNode("div", {
9338
+ "key": index,
9339
+ "data-id": item.value,
9340
+ "class": [{
9341
+ 'is-active': (item.value || index) == tabs.currentValue.value,
9342
+ 'is-average': props.average
9343
+ }, 'vcm-tabs__item'],
9344
+ "onClick": () => tabs.handleChange(index)
9345
+ }, [slots.label ? slots.label({
9346
+ it: item,
9347
+ index
9348
+ }) : typeof item.label === 'string' ? vue.createVNode("span", {
9349
+ "innerHTML": item.label
9350
+ }, null) : typeof item.label === 'function' && vue.createVNode(Customer, {
9351
+ "render": item.label,
9352
+ "it": item,
9353
+ "index": index
9354
+ }, null)]);
9355
+ })])]), props.showStep && tabs.scrollable.value && vue.createVNode("div", {
9356
+ "class": "vcm-tabs__step is-right",
9357
+ "onClick": () => handleStep(-1)
9358
+ }, [vue.createVNode(Icon, {
9359
+ "type": "right"
9360
+ }, null)]), slots.append?.()]), isFixed.value && vue.createVNode("div", {
9361
+ "style": {
9362
+ height: `${placeholderH.value}px`
9363
+ },
9364
+ "class": "vcm-tabs__placeholder"
9365
+ }, null), vue.createVNode("div", {
9366
+ "ref": content,
9367
+ "style": tabs.contentStyle.value,
9368
+ "class": "vcm-tabs__content"
9369
+ }, [slots.default?.()])]);
9370
+ };
9371
+ }
9372
+ });
9373
+
9374
+ /** @jsxImportSource vue */
9375
+
9376
+ const COMPONENT_NAME$d = 'vcm-tabs-pane';
9377
+ const MTabsPane = /* @__PURE__ */ vue.defineComponent({
9378
+ name: COMPONENT_NAME$d,
9379
+ props: props$b,
9380
+ setup(_, {
9381
+ slots
9382
+ }) {
9383
+ const tabsPane = useTabsPane();
9384
+ return () => {
9385
+ return vue.createVNode("div", {
9386
+ "class": "vcm-tabs-pane",
9387
+ "style": tabsPane.style.value,
9388
+ "name": tabsPane.currentValue.value
9389
+ }, [tabsPane.isReady && slots.default?.()]);
9390
+ };
9391
+ }
9392
+ });
8634
9393
 
8635
9394
  const props$9 = {
8636
9395
  tag: {
@@ -9067,13 +9826,15 @@ exports.Chart = Chart;
9067
9826
  exports.Checkbox = Checkbox;
9068
9827
  exports.Clipboard = Clipboard;
9069
9828
  exports.Collapse = Collapse;
9829
+ exports.CollapseItem = CollapseItem;
9070
9830
  exports.ColorPicker = ColorPicker;
9071
9831
  exports.Countdown = Countdown;
9072
9832
  exports.Customer = Customer;
9073
9833
  exports.DatePicker = DatePicker;
9074
9834
  exports.Debounce = Debounce;
9075
9835
  exports.Divider = Divider;
9076
- exports.Drawer = Drawer;
9836
+ exports.Drawer = drawer;
9837
+ exports.DrawerView = DrawerView;
9077
9838
  exports.Dropdown = Dropdown;
9078
9839
  exports.Editor = Editor;
9079
9840
  exports.Expand = Expand;
@@ -9105,13 +9866,14 @@ exports.MChart = MChart;
9105
9866
  exports.MCheckbox = MCheckbox;
9106
9867
  exports.MClipboard = MClipboard;
9107
9868
  exports.MCollapse = MCollapse;
9869
+ exports.MCollapseItem = MCollapseItem;
9108
9870
  exports.MColorPicker = MColorPicker;
9109
9871
  exports.MCountdown = MCountdown;
9110
9872
  exports.MCustomer = MCustomer;
9111
9873
  exports.MDatePicker = MDatePicker;
9112
9874
  exports.MDebounce = Debounce;
9113
9875
  exports.MDivider = MDivider;
9114
- exports.MDrawer = MDrawer;
9876
+ exports.MDrawerView = MDrawerView;
9115
9877
  exports.MDropdown = MDropdown;
9116
9878
  exports.MEditor = MEditor;
9117
9879
  exports.MExpand = MExpand;