@deot/vc 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.
@@ -3696,138 +3696,6 @@
3696
3696
  return flatten(value, JSON.parse);
3697
3697
  };
3698
3698
 
3699
- class Validator {
3700
- static falsy = [void 0, null, ""];
3701
- rules = {};
3702
- paths;
3703
- original;
3704
- constructor(rules, paths, original) {
3705
- this.updateRules(rules);
3706
- this.paths = paths || [];
3707
- this.original = original;
3708
- }
3709
- /**
3710
- * 构建统一规则类型的Rule[], 也可供外部使用
3711
- * @param rules ~
3712
- */
3713
- updateRules(rules) {
3714
- if (!rules)
3715
- return;
3716
- Object.keys(rules).forEach((field) => {
3717
- const rule = rules[field];
3718
- this.rules[field] = (Array.isArray(rule) ? rule : [rule]).map((rule$) => {
3719
- if (typeof rule$ === "function") {
3720
- return { validate: rule$ };
3721
- }
3722
- if (typeof rule$ === "string" || rule$ instanceof RegExp) {
3723
- rule$ = { pattern: rule$ };
3724
- }
3725
- if (typeof rule$ === "boolean") {
3726
- rule$ = { required: rule$ };
3727
- }
3728
- const { validate, pattern, required, enum: enum$ = [] } = rule$;
3729
- if (validate && rule$.fields) {
3730
- rule$.fields = void 0;
3731
- }
3732
- if (!validate && pattern) {
3733
- const pattern$ = typeof pattern === "string" ? new RegExp(pattern) : pattern;
3734
- return {
3735
- ...rule$,
3736
- validate: (v) => pattern$.test(v)
3737
- };
3738
- }
3739
- if (!validate && required) {
3740
- return {
3741
- ...rule$,
3742
- validate: (v) => Array.isArray(v) ? !!v.length && v.every((j) => Validator.falsy.every((i) => j !== i)) : Validator.falsy.every((i) => v !== i)
3743
- };
3744
- }
3745
- if (!validate && enum$.length) {
3746
- return {
3747
- ...rule$,
3748
- validate: (v) => enum$.some((i) => v === i)
3749
- };
3750
- }
3751
- return rule$;
3752
- });
3753
- });
3754
- }
3755
- async validate(source, options) {
3756
- options = options || {};
3757
- if (!Object.keys(this.rules).length) {
3758
- return;
3759
- }
3760
- const needCheckFields = options.fields || Object.keys(this.rules);
3761
- const errors = [];
3762
- for (let i = 0; i < needCheckFields.length; i++) {
3763
- const field = needCheckFields[i];
3764
- const rules = this.rules[field];
3765
- const value = source[field];
3766
- const original = this.original;
3767
- for (let j = 0; j < rules.length; j++) {
3768
- const rule = rules[j];
3769
- const { validate = () => {
3770
- }, transform = (x) => x, fields: fields$ } = rule;
3771
- const paths = [...this.paths, field];
3772
- if (typeof options._index !== "undefined") {
3773
- paths.splice(paths.length - 1, 0, options._index);
3774
- }
3775
- const value$ = transform(value, { field, source, paths, original });
3776
- if (fields$) {
3777
- const isArray = Array.isArray(value$);
3778
- const value$$ = isArray ? value$ : [value$];
3779
- if (value$$.every((v) => v && typeof v === "object")) {
3780
- const validator = new Validator(fields$, paths);
3781
- for (let k = 0; k < value$$.length; k++) {
3782
- try {
3783
- await validator.validate(value$$[k], { _index: isArray ? k : void 0, first: options.first, original });
3784
- } catch (errors$) {
3785
- errors.push(...errors$);
3786
- if (errors$.length && options.first)
3787
- break;
3788
- }
3789
- }
3790
- continue;
3791
- }
3792
- }
3793
- let result = validate(value$, { field, source, paths, original });
3794
- let message$ = "";
3795
- if (result instanceof Promise) {
3796
- try {
3797
- await result;
3798
- } catch (e) {
3799
- result = false;
3800
- message$ = e.message || e;
3801
- }
3802
- } else if (typeof result === "string") {
3803
- message$ = result;
3804
- result = false;
3805
- }
3806
- if (result === false) {
3807
- errors.push({
3808
- paths,
3809
- message: message$ || rule.message || "",
3810
- field,
3811
- value: value$
3812
- });
3813
- if (options.first)
3814
- break;
3815
- }
3816
- }
3817
- if (errors.length && options.first)
3818
- break;
3819
- }
3820
- if (errors.length) {
3821
- const errors$ = errors.map((i) => {
3822
- const { message, ...extra } = i;
3823
- i.message = typeof message === "function" ? message(extra) : message;
3824
- return i;
3825
- });
3826
- return Promise.reject(errors$);
3827
- }
3828
- }
3829
- }
3830
-
3831
3699
  const IS_SERVER$2 = typeof window === "undefined";
3832
3700
 
3833
3701
  const composedPath = (e) => {
@@ -3969,6 +3837,138 @@
3969
3837
  };
3970
3838
  };
3971
3839
 
3840
+ class Validator {
3841
+ static falsy = [void 0, null, ""];
3842
+ rules = {};
3843
+ paths;
3844
+ original;
3845
+ constructor(rules, paths, original) {
3846
+ this.updateRules(rules);
3847
+ this.paths = paths || [];
3848
+ this.original = original;
3849
+ }
3850
+ /**
3851
+ * 构建统一规则类型的Rule[], 也可供外部使用
3852
+ * @param rules ~
3853
+ */
3854
+ updateRules(rules) {
3855
+ if (!rules)
3856
+ return;
3857
+ Object.keys(rules).forEach((field) => {
3858
+ const rule = rules[field];
3859
+ this.rules[field] = (Array.isArray(rule) ? rule : [rule]).map((rule$) => {
3860
+ if (typeof rule$ === "function") {
3861
+ return { validate: rule$ };
3862
+ }
3863
+ if (typeof rule$ === "string" || rule$ instanceof RegExp) {
3864
+ rule$ = { pattern: rule$ };
3865
+ }
3866
+ if (typeof rule$ === "boolean") {
3867
+ rule$ = { required: rule$ };
3868
+ }
3869
+ const { validate, pattern, required, enum: enum$ = [] } = rule$;
3870
+ if (validate && rule$.fields) {
3871
+ rule$.fields = void 0;
3872
+ }
3873
+ if (!validate && pattern) {
3874
+ const pattern$ = typeof pattern === "string" ? new RegExp(pattern) : pattern;
3875
+ return {
3876
+ ...rule$,
3877
+ validate: (v) => pattern$.test(v)
3878
+ };
3879
+ }
3880
+ if (!validate && required) {
3881
+ return {
3882
+ ...rule$,
3883
+ validate: (v) => Array.isArray(v) ? !!v.length && v.every((j) => Validator.falsy.every((i) => j !== i)) : Validator.falsy.every((i) => v !== i)
3884
+ };
3885
+ }
3886
+ if (!validate && enum$.length) {
3887
+ return {
3888
+ ...rule$,
3889
+ validate: (v) => enum$.some((i) => v === i)
3890
+ };
3891
+ }
3892
+ return rule$;
3893
+ });
3894
+ });
3895
+ }
3896
+ async validate(source, options) {
3897
+ options = options || {};
3898
+ if (!Object.keys(this.rules).length) {
3899
+ return;
3900
+ }
3901
+ const needCheckFields = options.fields || Object.keys(this.rules);
3902
+ const errors = [];
3903
+ for (let i = 0; i < needCheckFields.length; i++) {
3904
+ const field = needCheckFields[i];
3905
+ const rules = this.rules[field];
3906
+ const value = source[field];
3907
+ const original = this.original;
3908
+ for (let j = 0; j < rules.length; j++) {
3909
+ const rule = rules[j];
3910
+ const { validate = () => {
3911
+ }, transform = (x) => x, fields: fields$ } = rule;
3912
+ const paths = [...this.paths, field];
3913
+ if (typeof options._index !== "undefined") {
3914
+ paths.splice(paths.length - 1, 0, options._index);
3915
+ }
3916
+ const value$ = transform(value, { field, source, paths, original });
3917
+ if (fields$) {
3918
+ const isArray = Array.isArray(value$);
3919
+ const value$$ = isArray ? value$ : [value$];
3920
+ if (value$$.every((v) => v && typeof v === "object")) {
3921
+ const validator = new Validator(fields$, paths);
3922
+ for (let k = 0; k < value$$.length; k++) {
3923
+ try {
3924
+ await validator.validate(value$$[k], { _index: isArray ? k : void 0, first: options.first, original });
3925
+ } catch (errors$) {
3926
+ errors.push(...errors$);
3927
+ if (errors$.length && options.first)
3928
+ break;
3929
+ }
3930
+ }
3931
+ continue;
3932
+ }
3933
+ }
3934
+ let result = validate(value$, { field, source, paths, original });
3935
+ let message$ = "";
3936
+ if (result instanceof Promise) {
3937
+ try {
3938
+ await result;
3939
+ } catch (e) {
3940
+ result = false;
3941
+ message$ = e.message || e;
3942
+ }
3943
+ } else if (typeof result === "string") {
3944
+ message$ = result;
3945
+ result = false;
3946
+ }
3947
+ if (result === false) {
3948
+ errors.push({
3949
+ paths,
3950
+ message: message$ || rule.message || "",
3951
+ field,
3952
+ value: value$
3953
+ });
3954
+ if (options.first)
3955
+ break;
3956
+ }
3957
+ }
3958
+ if (errors.length && options.first)
3959
+ break;
3960
+ }
3961
+ if (errors.length) {
3962
+ const errors$ = errors.map((i) => {
3963
+ const { message, ...extra } = i;
3964
+ i.message = typeof message === "function" ? message(extra) : message;
3965
+ return i;
3966
+ });
3967
+ return Promise.reject(errors$);
3968
+ }
3969
+ }
3970
+ }
3971
+
3972
3972
  class ACache {
3973
3973
  options;
3974
3974
  constructor() {
@@ -5415,16 +5415,16 @@
5415
5415
  }
5416
5416
  }
5417
5417
  const VcInstance = new Instance();
5418
- const props$1h = {
5418
+ const props$1j = {
5419
5419
  tag: {
5420
5420
  type: String,
5421
5421
  default: "div"
5422
5422
  }
5423
5423
  };
5424
- const COMPONENT_NAME$1x = "vc-action-sheet";
5424
+ const COMPONENT_NAME$1A = "vc-action-sheet";
5425
5425
  const ActionSheet = /* @__PURE__ */ vue.defineComponent({
5426
- name: COMPONENT_NAME$1x,
5427
- props: props$1h,
5426
+ name: COMPONENT_NAME$1A,
5427
+ props: props$1j,
5428
5428
  setup(props2, {
5429
5429
  slots
5430
5430
  }) {
@@ -5436,7 +5436,7 @@
5436
5436
  }
5437
5437
  });
5438
5438
  const MActionSheet = ActionSheet;
5439
- const props$1g = {
5439
+ const props$1i = {
5440
5440
  modelValue: {
5441
5441
  type: Boolean,
5442
5442
  default: true
@@ -5462,7 +5462,7 @@
5462
5462
  default: false
5463
5463
  }
5464
5464
  };
5465
- const props$1f = {
5465
+ const props$1h = {
5466
5466
  type: String,
5467
5467
  inherit: {
5468
5468
  type: Boolean,
@@ -5514,7 +5514,7 @@
5514
5514
  icons = await this.parser(data, url);
5515
5515
  try {
5516
5516
  window.localStorage.setItem(key, JSON.stringify(icons));
5517
- } catch (e) {
5517
+ } catch {
5518
5518
  setTimeout(() => {
5519
5519
  this.clearResource();
5520
5520
  window.localStorage.setItem(key, JSON.stringify(icons));
@@ -5603,10 +5603,10 @@
5603
5603
  }
5604
5604
  }
5605
5605
  const IconManager = new Manager();
5606
- const COMPONENT_NAME$1w = "vc-icon";
5606
+ const COMPONENT_NAME$1z = "vc-icon";
5607
5607
  const Icon = /* @__PURE__ */ vue.defineComponent({
5608
- name: COMPONENT_NAME$1w,
5609
- props: props$1f,
5608
+ name: COMPONENT_NAME$1z,
5609
+ props: props$1h,
5610
5610
  setup(props2) {
5611
5611
  const viewBox = vue.ref("0 0 1024 1024");
5612
5612
  const path = vue.ref([]);
@@ -5638,7 +5638,7 @@
5638
5638
  };
5639
5639
  }
5640
5640
  });
5641
- const props$1e = {
5641
+ const props$1g = {
5642
5642
  /**
5643
5643
  * 进入/离开持续时间
5644
5644
  * {enter: 300, leave: 300}
@@ -5801,10 +5801,10 @@
5801
5801
  }
5802
5802
  };
5803
5803
  };
5804
- const COMPONENT_NAME$1v = "vc-transition";
5804
+ const COMPONENT_NAME$1y = "vc-transition";
5805
5805
  const Transition = vue.defineComponent({
5806
- name: COMPONENT_NAME$1v,
5807
- props: props$1e,
5806
+ name: COMPONENT_NAME$1y,
5807
+ props: props$1g,
5808
5808
  // 当不声明emits的情况下,事件存在于attrs中
5809
5809
  inheritAttrs: false,
5810
5810
  setup(props2, { slots, attrs }) {
@@ -5823,10 +5823,10 @@
5823
5823
  };
5824
5824
  }
5825
5825
  });
5826
- const COMPONENT_NAME$1u = "vc-transition-collapse";
5826
+ const COMPONENT_NAME$1x = "vc-transition-collapse";
5827
5827
  const TransitionCollapse = vue.defineComponent({
5828
- name: COMPONENT_NAME$1u,
5829
- props: props$1e,
5828
+ name: COMPONENT_NAME$1x,
5829
+ props: props$1g,
5830
5830
  // 当不声明emits的情况下,事件存在于attrs中
5831
5831
  inheritAttrs: false,
5832
5832
  setup(props2, { slots, attrs: _attrs }) {
@@ -5943,11 +5943,11 @@
5943
5943
  };
5944
5944
  }
5945
5945
  });
5946
- const COMPONENT_NAME$1t = "vc-transition-fade";
5946
+ const COMPONENT_NAME$1w = "vc-transition-fade";
5947
5947
  const TransitionFade = vue.defineComponent({
5948
- name: COMPONENT_NAME$1t,
5948
+ name: COMPONENT_NAME$1w,
5949
5949
  props: {
5950
- ...props$1e,
5950
+ ...props$1g,
5951
5951
  // inheritAttrs必须是false
5952
5952
  style: {
5953
5953
  type: Object,
@@ -5979,11 +5979,11 @@
5979
5979
  };
5980
5980
  }
5981
5981
  });
5982
- const COMPONENT_NAME$1s = "vc-transition-scale";
5982
+ const COMPONENT_NAME$1v = "vc-transition-scale";
5983
5983
  const TransitionScale = vue.defineComponent({
5984
- name: COMPONENT_NAME$1s,
5984
+ name: COMPONENT_NAME$1v,
5985
5985
  props: {
5986
- ...props$1e,
5986
+ ...props$1g,
5987
5987
  mode: {
5988
5988
  type: String,
5989
5989
  default: "both",
@@ -6020,15 +6020,15 @@
6020
6020
  };
6021
6021
  }
6022
6022
  });
6023
- const COMPONENT_NAME$1r = "vc-transition-slide";
6023
+ const COMPONENT_NAME$1u = "vc-transition-slide";
6024
6024
  const TransitionSlide = vue.defineComponent({
6025
- name: COMPONENT_NAME$1r,
6025
+ name: COMPONENT_NAME$1u,
6026
6026
  props: {
6027
- ...props$1e,
6027
+ ...props$1g,
6028
6028
  mode: {
6029
6029
  type: String,
6030
6030
  default: "left",
6031
- validator: (v) => /^(left|right|down|up|none)(|-part)$/.test(v)
6031
+ validator: (v) => /^(left|right|top|bottom|none)(|-part)$/.test(v)
6032
6032
  },
6033
6033
  // inheritAttrs必须是false
6034
6034
  style: {
@@ -6061,11 +6061,11 @@
6061
6061
  };
6062
6062
  }
6063
6063
  });
6064
- const COMPONENT_NAME$1q = "vc-transition-zoom";
6064
+ const COMPONENT_NAME$1t = "vc-transition-zoom";
6065
6065
  const TransitionZoom = vue.defineComponent({
6066
- name: COMPONENT_NAME$1q,
6066
+ name: COMPONENT_NAME$1t,
6067
6067
  props: {
6068
- ...props$1e,
6068
+ ...props$1g,
6069
6069
  mode: {
6070
6070
  type: String,
6071
6071
  default: "x",
@@ -6102,7 +6102,7 @@
6102
6102
  };
6103
6103
  }
6104
6104
  });
6105
- const COMPONENT_NAME$1p = "vc-alert";
6105
+ const COMPONENT_NAME$1s = "vc-alert";
6106
6106
  const THEME_MAP = {
6107
6107
  info: ["#5495f6", "#91d5ff", "#e6f7ff"],
6108
6108
  success: ["#52c41a", "#b7eb8f", "#f6ffed"],
@@ -6110,8 +6110,8 @@
6110
6110
  warning: ["#ffbf00", "#ffe58f", "#fffbe6"]
6111
6111
  };
6112
6112
  const Alert = /* @__PURE__ */ vue.defineComponent({
6113
- name: COMPONENT_NAME$1p,
6114
- props: props$1g,
6113
+ name: COMPONENT_NAME$1s,
6114
+ props: props$1i,
6115
6115
  setup(props2, {
6116
6116
  slots,
6117
6117
  emit
@@ -6197,16 +6197,16 @@
6197
6197
  }
6198
6198
  });
6199
6199
  const MAlert = Alert;
6200
- const props$1d = {
6200
+ const props$1f = {
6201
6201
  tag: {
6202
6202
  type: String,
6203
6203
  default: "div"
6204
6204
  }
6205
6205
  };
6206
- const COMPONENT_NAME$1o = "vc-artboard";
6206
+ const COMPONENT_NAME$1r = "vc-artboard";
6207
6207
  const Artboard = /* @__PURE__ */ vue.defineComponent({
6208
- name: COMPONENT_NAME$1o,
6209
- props: props$1d,
6208
+ name: COMPONENT_NAME$1r,
6209
+ props: props$1f,
6210
6210
  setup(props2, {
6211
6211
  slots
6212
6212
  }) {
@@ -6218,7 +6218,7 @@
6218
6218
  }
6219
6219
  });
6220
6220
  const MArtboard = Artboard;
6221
- const props$1c = {
6221
+ const props$1e = {
6222
6222
  size: {
6223
6223
  type: Number,
6224
6224
  default: 28
@@ -6239,10 +6239,10 @@
6239
6239
  default: false
6240
6240
  }
6241
6241
  };
6242
- const COMPONENT_NAME$1n = "vc-spin";
6242
+ const COMPONENT_NAME$1q = "vc-spin";
6243
6243
  const Spin = /* @__PURE__ */ vue.defineComponent({
6244
- name: COMPONENT_NAME$1n,
6245
- props: props$1c,
6244
+ name: COMPONENT_NAME$1q,
6245
+ props: props$1e,
6246
6246
  setup(props2, {
6247
6247
  slots
6248
6248
  }) {
@@ -6275,7 +6275,7 @@
6275
6275
  };
6276
6276
  }
6277
6277
  });
6278
- const props$1b = {
6278
+ const props$1d = {
6279
6279
  wait: {
6280
6280
  type: Number,
6281
6281
  default: 250
@@ -6290,10 +6290,10 @@
6290
6290
  },
6291
6291
  exclude: RegExp
6292
6292
  };
6293
- const COMPONENT_NAME$1m = "vc-debounce";
6293
+ const COMPONENT_NAME$1p = "vc-debounce";
6294
6294
  const Debounce = vue.defineComponent({
6295
- name: COMPONENT_NAME$1m,
6296
- props: props$1b,
6295
+ name: COMPONENT_NAME$1p,
6296
+ props: props$1d,
6297
6297
  /**
6298
6298
  * 不声明emits使得事件被透传放入attrs中, 这样可以让所有的事件透传
6299
6299
  * 如事件onClick
@@ -6333,7 +6333,7 @@
6333
6333
  };
6334
6334
  }
6335
6335
  });
6336
- const props$1a = {
6336
+ const props$1c = {
6337
6337
  tag: {
6338
6338
  type: String,
6339
6339
  default: "button"
@@ -6360,18 +6360,18 @@
6360
6360
  default: "button"
6361
6361
  }
6362
6362
  };
6363
- const COMPONENT_NAME$1l = "vc-button";
6363
+ const COMPONENT_NAME$1o = "vc-button";
6364
6364
  const Button = /* @__PURE__ */ vue.defineComponent({
6365
- name: COMPONENT_NAME$1l,
6365
+ name: COMPONENT_NAME$1o,
6366
6366
  emits: ["click"],
6367
- props: props$1a,
6367
+ props: props$1c,
6368
6368
  setup(props2, {
6369
6369
  slots
6370
6370
  }) {
6371
6371
  const vm = vue.getCurrentInstance();
6372
6372
  const hasSlot = vue.ref(true);
6373
6373
  const isLoading = vue.ref(false);
6374
- const group = vue.inject("button-group", {
6374
+ const group = vue.inject("vc-button-group", {
6375
6375
  size: "medium",
6376
6376
  vertical: false,
6377
6377
  circle: false
@@ -6420,7 +6420,7 @@
6420
6420
  };
6421
6421
  }
6422
6422
  });
6423
- const props$19 = {
6423
+ const props$1b = {
6424
6424
  vertical: {
6425
6425
  type: Boolean,
6426
6426
  default: false
@@ -6438,14 +6438,14 @@
6438
6438
  default: false
6439
6439
  }
6440
6440
  };
6441
- const COMPONENT_NAME$1k = "vc-button-group";
6441
+ const COMPONENT_NAME$1n = "vc-button-group";
6442
6442
  const ButtonGroup = /* @__PURE__ */ vue.defineComponent({
6443
- name: COMPONENT_NAME$1k,
6444
- props: props$19,
6443
+ name: COMPONENT_NAME$1n,
6444
+ props: props$1b,
6445
6445
  setup(props2, {
6446
6446
  slots
6447
6447
  }) {
6448
- vue.provide("button-group", props2);
6448
+ vue.provide("vc-button-group", props2);
6449
6449
  const classes = vue.computed(() => ({
6450
6450
  "is-vertical": props2.vertical,
6451
6451
  "is-circle": props2.circle,
@@ -6463,16 +6463,16 @@
6463
6463
  });
6464
6464
  const MButton = Button;
6465
6465
  const MButtonGroup = ButtonGroup;
6466
- const props$18 = {
6466
+ const props$1a = {
6467
6467
  tag: {
6468
6468
  type: String,
6469
6469
  default: "div"
6470
6470
  }
6471
6471
  };
6472
- const COMPONENT_NAME$1j = "vc-calendar";
6472
+ const COMPONENT_NAME$1m = "vc-calendar";
6473
6473
  const Calendar$1 = /* @__PURE__ */ vue.defineComponent({
6474
- name: COMPONENT_NAME$1j,
6475
- props: props$18,
6474
+ name: COMPONENT_NAME$1m,
6475
+ props: props$1a,
6476
6476
  setup(props2, {
6477
6477
  slots
6478
6478
  }) {
@@ -6484,7 +6484,7 @@
6484
6484
  }
6485
6485
  });
6486
6486
  const MCalendar = Calendar$1;
6487
- const props$17 = {
6487
+ const props$19 = {
6488
6488
  border: {
6489
6489
  type: Boolean,
6490
6490
  default: true
@@ -6504,10 +6504,10 @@
6504
6504
  type: String
6505
6505
  }
6506
6506
  };
6507
- const COMPONENT_NAME$1i = "vc-card";
6507
+ const COMPONENT_NAME$1l = "vc-card";
6508
6508
  const Card = /* @__PURE__ */ vue.defineComponent({
6509
- name: COMPONENT_NAME$1i,
6510
- props: props$17,
6509
+ name: COMPONENT_NAME$1l,
6510
+ props: props$19,
6511
6511
  setup(props2, {
6512
6512
  slots
6513
6513
  }) {
@@ -6531,16 +6531,16 @@
6531
6531
  }
6532
6532
  });
6533
6533
  const MCard = Card;
6534
- const props$16 = {
6534
+ const props$18 = {
6535
6535
  tag: {
6536
6536
  type: String,
6537
6537
  default: "div"
6538
6538
  }
6539
6539
  };
6540
- const COMPONENT_NAME$1h = "vc-carousel";
6540
+ const COMPONENT_NAME$1k = "vc-carousel";
6541
6541
  const Carousel = /* @__PURE__ */ vue.defineComponent({
6542
- name: COMPONENT_NAME$1h,
6543
- props: props$16,
6542
+ name: COMPONENT_NAME$1k,
6543
+ props: props$18,
6544
6544
  setup(props2, {
6545
6545
  slots
6546
6546
  }) {
@@ -6552,16 +6552,16 @@
6552
6552
  }
6553
6553
  });
6554
6554
  const MCarousel = Carousel;
6555
- const props$15 = {
6555
+ const props$17 = {
6556
6556
  tag: {
6557
6557
  type: String,
6558
6558
  default: "div"
6559
6559
  }
6560
6560
  };
6561
- const COMPONENT_NAME$1g = "vc-cascader";
6561
+ const COMPONENT_NAME$1j = "vc-cascader";
6562
6562
  const Cascader = /* @__PURE__ */ vue.defineComponent({
6563
- name: COMPONENT_NAME$1g,
6564
- props: props$15,
6563
+ name: COMPONENT_NAME$1j,
6564
+ props: props$17,
6565
6565
  setup(props2, {
6566
6566
  slots
6567
6567
  }) {
@@ -6611,7 +6611,7 @@
6611
6611
  "globalout",
6612
6612
  "contextmenu"
6613
6613
  ];
6614
- const props$14 = {
6614
+ const props$16 = {
6615
6615
  options: Object,
6616
6616
  pluginOptions: Object,
6617
6617
  theme: [String, Object],
@@ -6620,10 +6620,10 @@
6620
6620
  watchShallow: Boolean,
6621
6621
  manualUpdate: Boolean
6622
6622
  };
6623
- const COMPONENT_NAME$1f = "vc-chart";
6623
+ const COMPONENT_NAME$1i = "vc-chart";
6624
6624
  const Chart = /* @__PURE__ */ vue.defineComponent({
6625
- name: COMPONENT_NAME$1f,
6626
- props: props$14,
6625
+ name: COMPONENT_NAME$1i,
6626
+ props: props$16,
6627
6627
  emits: [...EVENTS, "ready"],
6628
6628
  setup(props2, {
6629
6629
  emit,
@@ -6731,16 +6731,16 @@
6731
6731
  }
6732
6732
  });
6733
6733
  const MChart = Chart;
6734
- const props$13 = {
6734
+ const props$15 = {
6735
6735
  tag: {
6736
6736
  type: String,
6737
6737
  default: "div"
6738
6738
  }
6739
6739
  };
6740
- const COMPONENT_NAME$1e = "vc-checkbox";
6740
+ const COMPONENT_NAME$1h = "vc-checkbox";
6741
6741
  const Checkbox = /* @__PURE__ */ vue.defineComponent({
6742
- name: COMPONENT_NAME$1e,
6743
- props: props$13,
6742
+ name: COMPONENT_NAME$1h,
6743
+ props: props$15,
6744
6744
  setup(props2, {
6745
6745
  slots
6746
6746
  }) {
@@ -6752,16 +6752,16 @@
6752
6752
  }
6753
6753
  });
6754
6754
  const MCheckbox = Checkbox;
6755
- const props$12 = {
6755
+ const props$14 = {
6756
6756
  tag: {
6757
6757
  type: String,
6758
6758
  default: "div"
6759
6759
  }
6760
6760
  };
6761
- const COMPONENT_NAME$1d = "vc-clipboard";
6761
+ const COMPONENT_NAME$1g = "vc-clipboard";
6762
6762
  const Clipboard = /* @__PURE__ */ vue.defineComponent({
6763
- name: COMPONENT_NAME$1d,
6764
- props: props$12,
6763
+ name: COMPONENT_NAME$1g,
6764
+ props: props$14,
6765
6765
  setup(props2, {
6766
6766
  slots
6767
6767
  }) {
@@ -6773,36 +6773,246 @@
6773
6773
  }
6774
6774
  });
6775
6775
  const MClipboard = Clipboard;
6776
+ const props$13 = {
6777
+ tag: {
6778
+ type: String,
6779
+ default: "div"
6780
+ },
6781
+ accordion: {
6782
+ type: Boolean,
6783
+ default: false
6784
+ },
6785
+ modelValue: {
6786
+ type: [Array, String, Number]
6787
+ },
6788
+ alive: {
6789
+ type: Boolean,
6790
+ default: true
6791
+ },
6792
+ // TODO: 添加默认样式
6793
+ styleless: {
6794
+ type: Boolean,
6795
+ default: false
6796
+ }
6797
+ };
6798
+ const COMPONENT_NAME$1f = "vc-collapse";
6799
+ const Collapse = vue.defineComponent({
6800
+ name: COMPONENT_NAME$1f,
6801
+ props: props$13,
6802
+ emits: ["update:moodelValue", "change"],
6803
+ setup(props2, { slots, emit }) {
6804
+ const instance = vue.getCurrentInstance();
6805
+ const currentValue = vue.ref();
6806
+ const items = vue.ref([]);
6807
+ const sync = () => {
6808
+ const v = props2.accordion ? currentValue.value[0] : currentValue.value;
6809
+ emit("update:moodelValue", v);
6810
+ emit("change", v);
6811
+ };
6812
+ const setActive = () => {
6813
+ const activeKey = currentValue.value;
6814
+ vue.nextTick(() => {
6815
+ items.value.forEach((child, index) => {
6816
+ const value = typeof child.props.value !== "undefined" ? child.props.value : index;
6817
+ child.exposed.toggle(activeKey.indexOf(value) > -1);
6818
+ });
6819
+ });
6820
+ };
6821
+ const toggle = (item) => {
6822
+ const activeKey = currentValue.value;
6823
+ const index = activeKey.indexOf(item.value);
6824
+ if (!item.visible) {
6825
+ if (index > -1) {
6826
+ activeKey.splice(index, 1);
6827
+ }
6828
+ } else if (index < 0) {
6829
+ activeKey.push(item.value);
6830
+ }
6831
+ currentValue.value = props2.accordion ? activeKey.slice(-1) : activeKey;
6832
+ sync();
6833
+ };
6834
+ const add = (item, setValue) => {
6835
+ if (!item) return;
6836
+ vue.nextTick(() => {
6837
+ if (instance.vnode.el) {
6838
+ const index = Array.from(instance.vnode.el.children).filter((i) => /vcm?-collapse-item/.test(i.className)).indexOf(item.vnode.el);
6839
+ if (index != -1) {
6840
+ items.value.splice(index, 0, item);
6841
+ typeof item.props.value === "undefined" && setValue(index);
6842
+ return;
6843
+ }
6844
+ }
6845
+ items.value.push(item);
6846
+ typeof item.props.value === "undefined" && setValue(items.value.length - 1);
6847
+ });
6848
+ };
6849
+ const remove = (item, setValue) => {
6850
+ if (!item) return;
6851
+ items.value.splice(items.value.indexOf(item), 1);
6852
+ items.value.forEach((_, index) => setValue(index));
6853
+ };
6854
+ vue.provide("vc-collapse", {
6855
+ props: props2,
6856
+ toggle,
6857
+ add,
6858
+ remove
6859
+ });
6860
+ vue.watch(
6861
+ () => props2.modelValue,
6862
+ (v) => {
6863
+ if (v === currentValue.value) return;
6864
+ currentValue.value = props2.accordion && typeof v !== "undefined" ? Array.isArray(v) ? v : [v] : Array.isArray(v) ? v : [];
6865
+ },
6866
+ { immediate: true }
6867
+ );
6868
+ vue.watch(
6869
+ () => currentValue.value,
6870
+ setActive,
6871
+ { deep: true }
6872
+ );
6873
+ vue.onMounted(setActive);
6874
+ return () => {
6875
+ return vue.h(
6876
+ props2.tag,
6877
+ {
6878
+ class: [{ "vc-collapse": !props2.styleless }]
6879
+ },
6880
+ slots.default?.()
6881
+ );
6882
+ };
6883
+ }
6884
+ });
6885
+ const props$12 = {
6886
+ tag: {
6887
+ type: String,
6888
+ default: "div"
6889
+ },
6890
+ value: {
6891
+ type: [String, Number]
6892
+ }
6893
+ };
6776
6894
  const props$11 = {
6777
6895
  tag: {
6778
6896
  type: String,
6779
6897
  default: "div"
6898
+ },
6899
+ modelValue: {
6900
+ type: Boolean,
6901
+ default: false
6902
+ },
6903
+ // 子节点每次toggle不销毁
6904
+ alive: {
6905
+ type: Boolean,
6906
+ default: true
6780
6907
  }
6781
6908
  };
6782
- const COMPONENT_NAME$1c = "vc-collapse";
6783
- const Collapse = /* @__PURE__ */ vue.defineComponent({
6784
- name: COMPONENT_NAME$1c,
6909
+ function _isSlot$2(s) {
6910
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !vue.isVNode(s);
6911
+ }
6912
+ const COMPONENT_NAME$1e = "vc-expand";
6913
+ const Expand = /* @__PURE__ */ vue.defineComponent({
6914
+ name: COMPONENT_NAME$1e,
6785
6915
  props: props$11,
6786
6916
  setup(props2, {
6787
6917
  slots
6788
6918
  }) {
6919
+ const isActive = vue.ref(false);
6920
+ const Content = props2.tag;
6921
+ vue.watch(() => props2.modelValue, (v) => {
6922
+ isActive.value = v;
6923
+ }, {
6924
+ immediate: true
6925
+ });
6789
6926
  return () => {
6790
- return vue.createVNode("div", {
6791
- "class": "vc-collapse"
6792
- }, [slots?.default?.()]);
6927
+ let _slot;
6928
+ return vue.createVNode(TransitionCollapse, {
6929
+ "duration": {
6930
+ enter: 200,
6931
+ leave: 200
6932
+ }
6933
+ }, _isSlot$2(_slot = vue.withDirectives(vue.createVNode(Content, null, {
6934
+ default: () => [(props2.alive || !props2.alive && isActive.value) && slots.default?.()]
6935
+ }), [[vue.vShow, isActive.value]])) ? _slot : {
6936
+ default: () => [_slot]
6937
+ });
6938
+ };
6939
+ }
6940
+ });
6941
+ const COMPONENT_NAME$1d = "vc-collapse-item";
6942
+ const CollapseItem = /* @__PURE__ */ vue.defineComponent({
6943
+ name: COMPONENT_NAME$1d,
6944
+ props: props$12,
6945
+ setup(props2, {
6946
+ slots,
6947
+ expose
6948
+ }) {
6949
+ const Content = props2.tag;
6950
+ const instance = vue.getCurrentInstance();
6951
+ const isActive = vue.ref(false);
6952
+ const current = vue.ref();
6953
+ const collapse = vue.inject("vc-collapse");
6954
+ const handleToggle = () => {
6955
+ collapse.toggle({
6956
+ value: typeof props2.value !== "undefined" ? props2.value : current.value,
6957
+ visible: !isActive.value
6958
+ });
6959
+ };
6960
+ const alive = vue.computed(() => {
6961
+ return collapse.props.alive;
6962
+ });
6963
+ const styleless = vue.computed(() => {
6964
+ return collapse.props.styleless;
6965
+ });
6966
+ const setValue = (v) => current.value = v;
6967
+ vue.onBeforeMount(() => {
6968
+ collapse.add?.(instance, setValue);
6969
+ });
6970
+ vue.onBeforeUnmount(() => {
6971
+ collapse.remove?.(instance, setValue);
6972
+ });
6973
+ expose({
6974
+ isActive,
6975
+ toggle: (v) => isActive.value = v
6976
+ });
6977
+ return () => {
6978
+ return vue.createVNode(Content, {
6979
+ "class": [{
6980
+ "vc-collapse-item": !styleless.value
6981
+ }]
6982
+ }, {
6983
+ default: () => [vue.createVNode("div", {
6984
+ "class": [{
6985
+ "vc-collapse-item__title": !styleless.value
6986
+ }],
6987
+ "onClick": handleToggle
6988
+ }, [slots.default?.(), slots.icon?.({
6989
+ visible: isActive.value
6990
+ })]), vue.createVNode(Expand, {
6991
+ "modelValue": isActive.value,
6992
+ "alive": alive.value,
6993
+ "onChange": (v) => isActive.value = v
6994
+ }, {
6995
+ default: () => [vue.createVNode("div", {
6996
+ "class": [{
6997
+ "vc-collapse-item__content": !styleless.value
6998
+ }]
6999
+ }, [slots.content?.()])]
7000
+ })]
7001
+ });
6793
7002
  };
6794
7003
  }
6795
7004
  });
6796
7005
  const MCollapse = Collapse;
7006
+ const MCollapseItem = CollapseItem;
6797
7007
  const props$10 = {
6798
7008
  tag: {
6799
7009
  type: String,
6800
7010
  default: "div"
6801
7011
  }
6802
7012
  };
6803
- const COMPONENT_NAME$1b = "vc-color-picker";
7013
+ const COMPONENT_NAME$1c = "vc-color-picker";
6804
7014
  const ColorPicker = /* @__PURE__ */ vue.defineComponent({
6805
- name: COMPONENT_NAME$1b,
7015
+ name: COMPONENT_NAME$1c,
6806
7016
  props: props$10,
6807
7017
  setup(props2, {
6808
7018
  slots
@@ -6821,9 +7031,9 @@
6821
7031
  default: "div"
6822
7032
  }
6823
7033
  };
6824
- const COMPONENT_NAME$1a = "vc-countdown";
7034
+ const COMPONENT_NAME$1b = "vc-countdown";
6825
7035
  const Countdown = /* @__PURE__ */ vue.defineComponent({
6826
- name: COMPONENT_NAME$1a,
7036
+ name: COMPONENT_NAME$1b,
6827
7037
  props: props$$,
6828
7038
  setup(props2, {
6829
7039
  slots
@@ -6842,9 +7052,9 @@
6842
7052
  default: () => null
6843
7053
  }
6844
7054
  };
6845
- const COMPONENT_NAME$19 = "vc-customer";
7055
+ const COMPONENT_NAME$1a = "vc-customer";
6846
7056
  const Customer = vue.defineComponent({
6847
- name: COMPONENT_NAME$19,
7057
+ name: COMPONENT_NAME$1a,
6848
7058
  props: props$_,
6849
7059
  setup(props2, context) {
6850
7060
  return () => vue.h(() => {
@@ -6859,9 +7069,9 @@
6859
7069
  default: "div"
6860
7070
  }
6861
7071
  };
6862
- const COMPONENT_NAME$18 = "vc-date-picker";
7072
+ const COMPONENT_NAME$19 = "vc-date-picker";
6863
7073
  const DatePicker = /* @__PURE__ */ vue.defineComponent({
6864
- name: COMPONENT_NAME$18,
7074
+ name: COMPONENT_NAME$19,
6865
7075
  props: props$Z,
6866
7076
  setup(props2, {
6867
7077
  slots
@@ -6880,9 +7090,9 @@
6880
7090
  default: "div"
6881
7091
  }
6882
7092
  };
6883
- const COMPONENT_NAME$17 = "vc-divider";
7093
+ const COMPONENT_NAME$18 = "vc-divider";
6884
7094
  const Divider = /* @__PURE__ */ vue.defineComponent({
6885
- name: COMPONENT_NAME$17,
7095
+ name: COMPONENT_NAME$18,
6886
7096
  props: props$Y,
6887
7097
  setup(props2, {
6888
7098
  slots
@@ -6895,178 +7105,714 @@
6895
7105
  }
6896
7106
  });
6897
7107
  const MDivider = Divider;
6898
- const props$X = {
6899
- tag: {
6900
- type: String,
6901
- default: "div"
6902
- }
7108
+ const defaults$2 = {
7109
+ tag: "div",
7110
+ el: "body",
7111
+ alive: false,
7112
+ multiple: false,
7113
+ aliveRegExp: { className: /(vc-hack-alive|vc-hack-cp)/ },
7114
+ aliveVisibleKey: "isVisible",
7115
+ aliveUpdateKey: "update",
7116
+ leaveDelay: 300,
7117
+ autoDestroy: true,
7118
+ components: {},
7119
+ uses: {},
7120
+ fragment: false,
7121
+ insertion: "last"
6903
7122
  };
6904
- const COMPONENT_NAME$16 = "vc-drawer";
6905
- const Drawer = /* @__PURE__ */ vue.defineComponent({
6906
- name: COMPONENT_NAME$16,
6907
- props: props$X,
6908
- setup(props2, {
6909
- slots
6910
- }) {
6911
- return () => {
6912
- return vue.createVNode("div", {
6913
- "class": "vc-drawer"
6914
- }, [slots?.default?.()]);
7123
+ class PortalLeaf {
7124
+ app;
7125
+ /**
7126
+ * 目标的实例,挂载到app上
7127
+ */
7128
+ wrapper;
7129
+ propsData;
7130
+ /**
7131
+ * 销毁的函数,挂载到app上,避免冲突
7132
+ */
7133
+ destroy;
7134
+ /**
7135
+ * 自动销毁的标记,挂载到app上,避免冲突
7136
+ */
7137
+ autoDestroy;
7138
+ target;
7139
+ constructor(target) {
7140
+ this.target = target;
7141
+ this.autoDestroy = false;
7142
+ this.destroy = /* istanbul ignore next */
7143
+ () => {
7144
+ throw new VcError("portal", "未注册的destroy方法");
6915
7145
  };
6916
7146
  }
6917
- });
6918
- const MDrawer = Drawer;
6919
- const props$W = {
6920
- tag: {
6921
- type: String,
6922
- default: "div"
7147
+ then(resolve, reject) {
7148
+ return this.target.then(resolve, reject);
6923
7149
  }
6924
- };
6925
- const COMPONENT_NAME$15 = "vc-dropdown";
6926
- const Dropdown = /* @__PURE__ */ vue.defineComponent({
6927
- name: COMPONENT_NAME$15,
6928
- props: props$W,
6929
- setup(props2, {
6930
- slots
6931
- }) {
6932
- return () => {
6933
- return vue.createVNode("div", {
6934
- "class": "vc-dropdown"
6935
- }, [slots?.default?.()]);
6936
- };
7150
+ catch(callback) {
7151
+ return this.target.catch(callback);
6937
7152
  }
6938
- });
6939
- const MDropdown = Dropdown;
6940
- const props$V = {
6941
- tag: {
6942
- type: String,
6943
- default: "div"
7153
+ finally(callback) {
7154
+ return this.target.finally(callback);
6944
7155
  }
6945
- };
6946
- const COMPONENT_NAME$14 = "vc-editor";
6947
- const Editor = /* @__PURE__ */ vue.defineComponent({
6948
- name: COMPONENT_NAME$14,
6949
- props: props$V,
6950
- setup(props2, {
6951
- slots
6952
- }) {
6953
- return () => {
6954
- return vue.createVNode("div", {
6955
- "class": "vc-editor"
6956
- }, [slots?.default?.()]);
6957
- };
7156
+ }
7157
+ const COMPONENT_NAME$17 = "vc-portal";
7158
+ class Portal {
7159
+ /**
7160
+ * 清理Portals类型组件
7161
+ * @param name 清理的组件名, boolean表示全部leafs是否强制清理
7162
+ */
7163
+ static clear(name) {
7164
+ try {
7165
+ let force = false;
7166
+ let target = /* @__PURE__ */ new Map();
7167
+ if (name && typeof name !== "boolean") {
7168
+ let names = [];
7169
+ if (typeof name === "string") {
7170
+ names = [name];
7171
+ } else if (name instanceof Array && name.length > 0) {
7172
+ names = name;
7173
+ }
7174
+ names.forEach((i) => target.set(i, ""));
7175
+ force = true;
7176
+ } else {
7177
+ force = !!name;
7178
+ target = Portal.leafs;
7179
+ }
7180
+ for (const key of target.keys()) {
7181
+ const leaf = Portal.leafs.get(key);
7182
+ if (leaf && (force === true || leaf.autoDestroy === true)) {
7183
+ leaf.destroy();
7184
+ }
7185
+ }
7186
+ } catch (e) {
7187
+ /* istanbul ignore next -- @preserve */
7188
+ throw new VcError("instance", e);
7189
+ }
6958
7190
  }
6959
- });
6960
- const MEditor = Editor;
6961
- const props$U = {
6962
- tag: {
6963
- type: String,
6964
- default: "div"
7191
+ /**
7192
+ * 清理全部Portals
7193
+ */
7194
+ static clearAll() {
7195
+ try {
7196
+ Portal.leafs.forEach((leaf) => leaf.destroy());
7197
+ } catch (e) {
7198
+ /* istanbul ignore next -- @preserve */
7199
+ throw new VcError("instance", e);
7200
+ }
6965
7201
  }
6966
- };
6967
- const COMPONENT_NAME$13 = "vc-expand";
6968
- const Expand = /* @__PURE__ */ vue.defineComponent({
6969
- name: COMPONENT_NAME$13,
6970
- props: props$U,
6971
- setup(props2, {
6972
- slots
6973
- }) {
6974
- return () => {
6975
- return vue.createVNode("div", {
6976
- "class": "vc-expand"
6977
- }, [slots?.default?.()]);
7202
+ static leafs = /* @__PURE__ */ new Map();
7203
+ wrapper;
7204
+ globalOptions;
7205
+ constructor(wrapper, options) {
7206
+ this.wrapper = wrapper;
7207
+ this.globalOptions = {
7208
+ ...options,
7209
+ name: options?.name || wrapper.name || getUid(COMPONENT_NAME$17)
6978
7210
  };
6979
7211
  }
6980
- });
6981
- const MExpand = Expand;
6982
- const props$T = {
6983
- tag: {
6984
- type: String,
6985
- default: "form"
6986
- },
6987
- model: {
6988
- type: Object
6989
- },
6990
- rules: {
6991
- type: Object
6992
- },
6993
- labelWidth: {
6994
- type: Number
6995
- },
6996
- showMessage: {
6997
- type: Boolean,
6998
- default: true
6999
- },
7000
- inline: {
7001
- type: Boolean,
7002
- default: false
7003
- },
7004
- labelPosition: {
7005
- type: String,
7006
- default: "right"
7007
- },
7008
- autocomplete: {
7009
- type: String,
7010
- default: "off"
7011
- },
7012
- styleless: {
7013
- type: Boolean,
7014
- default: false
7015
- }
7016
- };
7017
- const useForm = (expose, options = {}) => {
7018
- const instance = vue.getCurrentInstance();
7019
- const props2 = instance.props;
7020
- const fields = [];
7021
- vue.provide("form", {
7022
- props: props2,
7023
- add: (field) => {
7024
- field && fields.push(field);
7025
- },
7026
- remove: (field) => {
7027
- field && fields.splice(fields.indexOf(field), 1);
7212
+ popup(propsData, options) {
7213
+ if (!options) {
7214
+ options = propsData || {};
7215
+ } else {
7216
+ options.propsData = propsData;
7028
7217
  }
7029
- });
7030
- const filterFields = (fields$) => {
7031
- return !fields$ ? fields : fields.filter((item) => fields$.includes(item.props.prop));
7032
- };
7033
- const getField = (prop) => {
7034
- const field = fields.find((item) => item.props.prop === prop);
7035
- if (!field) throw new VcError("form", "请选择有用的prop值");
7036
- return field;
7037
- };
7038
- const showToast = (msg) => {
7039
- props2.showMessage && options.throwToast?.(msg);
7040
- };
7041
- const sortErrors = async (errors) => {
7042
- const positions = await Promise.all(fields.map((item) => item.exposed.getPosition()));
7043
- try {
7044
- return [...errors].toSorted((a, b) => {
7045
- const aIndex = fields.findIndex((i) => i.props.prop === a.prop);
7046
- const bIndex = fields.findIndex((i) => i.props.prop === b.prop);
7047
- const aPosition = positions[aIndex];
7048
- const bPosition = positions[bIndex];
7049
- if (aPosition.top != bPosition.top) return aPosition.top - bPosition.top;
7050
- return aPosition.left - bPosition.left;
7218
+ const $options = { ...this.getDefaultOptions(), ...options };
7219
+ const { onFulfilled, onRejected, ...rest } = $options;
7220
+ let onFulfilled$ = (
7221
+ /* istanbul ignore next -- @preserve */
7222
+ () => {
7223
+ }
7224
+ );
7225
+ let onRejected$ = (
7226
+ /* istanbul ignore next -- @preserve */
7227
+ () => {
7228
+ }
7229
+ );
7230
+ const target = new Promise((resolve, reject) => {
7231
+ onFulfilled$ = (v) => {
7232
+ onFulfilled?.(v);
7233
+ resolve(v);
7234
+ };
7235
+ onRejected$ = (v) => {
7236
+ onRejected?.(v);
7237
+ reject(v);
7238
+ };
7239
+ });
7240
+ return this.render(rest, target, onFulfilled$, onRejected$);
7241
+ }
7242
+ /**
7243
+ * 销毁当前Portal下的节点
7244
+ * @param target [description]
7245
+ */
7246
+ destroy = (target) => {
7247
+ const { multiple, name } = this.getDefaultOptions();
7248
+ target = target || name;
7249
+ const instance = typeof target === "object" ? target : Portal.leafs.get(target);
7250
+ if (instance) {
7251
+ instance.destroy();
7252
+ } else if (multiple) {
7253
+ Portal.leafs.forEach((item, key) => {
7254
+ if (key.includes(name)) {
7255
+ item.destroy();
7256
+ }
7051
7257
  });
7052
- } catch (e) {
7053
- return errors;
7054
7258
  }
7055
7259
  };
7056
- const scrollIntoView = (prop) => {
7057
- const field = getField(prop);
7058
- field.vnode?.el?.scrollIntoView?.({
7059
- behavior: "smooth",
7060
- block: "center"
7061
- });
7062
- };
7063
- const reset = (options$ = {}) => {
7064
- const { fields: fields$, original = {} } = options$;
7065
- filterFields(fields$).forEach((field) => {
7260
+ getDefaultOptions() {
7261
+ return {
7262
+ ...defaults$2,
7263
+ ...VcInstance.options.Portal,
7264
+ ...this.globalOptions
7265
+ };
7266
+ }
7267
+ createCallback(getLeaf, delay, callback) {
7268
+ return (...args) => {
7269
+ const done = () => {
7270
+ const leaf = getLeaf();
7271
+ /* istanbul ignore next -- @preserve */
7272
+ if (!leaf) {
7273
+ throw new VcError("portal", "实例不存在或已卸载");
7274
+ }
7275
+ leaf.destroy();
7276
+ };
7277
+ delay ? setTimeout(done, delay) : done();
7278
+ callback?.(...args);
7279
+ };
7280
+ }
7281
+ render(options, target, onFulfilled, onRejected) {
7282
+ const {
7283
+ el: el2,
7284
+ tag,
7285
+ alive,
7286
+ aliveRegExp,
7287
+ aliveVisibleKey,
7288
+ aliveUpdateKey,
7289
+ name: name$,
7290
+ leaveDelay,
7291
+ autoDestroy,
7292
+ multiple,
7293
+ fragment,
7294
+ onDestroyed,
7295
+ onBeforeCreate,
7296
+ insertion,
7297
+ // 全局注册
7298
+ globalProperties,
7299
+ install,
7300
+ components,
7301
+ uses,
7302
+ slots,
7303
+ parent,
7304
+ propsData,
7305
+ ...rest
7306
+ } = options;
7307
+ let useAllNodes = fragment;
7308
+ const name = multiple ? `${name$}__${getUid(COMPONENT_NAME$17)}` : name$;
7309
+ const container = document.createElement(tag);
7310
+ const root = typeof el2 === "object" ? el2 : document.querySelector(el2 || "body");
7311
+ !alive && Portal.leafs.get(name)?.destroy();
7312
+ const propsData$ = propsData || rest;
7313
+ let leaf = new PortalLeaf(target);
7314
+ const isDestroyed = () => {
7315
+ const leaf$ = Portal.leafs.get(name);
7316
+ return !leaf$ || leaf$ !== leaf;
7317
+ };
7318
+ const $onDestroyed = (...args) => {
7319
+ if (isDestroyed()) return;
7320
+ onDestroyed?.(...args);
7321
+ leaf.app?.unmount();
7322
+ /* istanbul ignore else -- @preserve */
7323
+ if (useAllNodes) {
7324
+ root?.contains(container) && root.removeChild(container);
7325
+ } else if (container && container._children) {
7326
+ container._children.forEach((i) => {
7327
+ root?.contains(i) && root.removeChild(i);
7328
+ });
7329
+ }
7330
+ Portal.leafs.delete(name);
7331
+ };
7332
+ const $onRejected = this.createCallback(() => leaf, leaveDelay, onRejected);
7333
+ const $onFulfilled = this.createCallback(() => leaf, leaveDelay, onFulfilled);
7334
+ if (alive && Portal.leafs.has(name)) {
7335
+ leaf = Portal.leafs.get(name);
7336
+ leaf.target = target;
7337
+ leaf.propsData.value = propsData$;
7338
+ leaf.wrapper?.[aliveUpdateKey]?.(options);
7339
+ } else {
7340
+ const wrapper = this.wrapper;
7341
+ const app = vue.createApp({
7342
+ name: COMPONENT_NAME$17,
7343
+ parent,
7344
+ setup() {
7345
+ if (alive) {
7346
+ const handleExtra = (e) => {
7347
+ try {
7348
+ const path = e.path || composedPath(e);
7349
+ /* istanbul ignore else -- @preserve */
7350
+ if (container && e.target && !container.contains(e.target) && !path?.some((item) => utils.eleInRegExp(item, aliveRegExp))) {
7351
+ /* istanbul ignore else -- @preserve */
7352
+ if (leaf.wrapper && leaf.wrapper?.[aliveVisibleKey]) {
7353
+ leaf.wrapper[aliveVisibleKey] = false;
7354
+ }
7355
+ leaveDelay ? setTimeout($onDestroyed, leaveDelay) : $onDestroyed();
7356
+ }
7357
+ } catch (error2) {
7358
+ /* istanbul ignore next -- @preserve */
7359
+ throw new VcError("portal", error2);
7360
+ }
7361
+ };
7362
+ vue.onMounted(() => {
7363
+ document.addEventListener("click", handleExtra, true);
7364
+ });
7365
+ vue.onBeforeUnmount(() => {
7366
+ document.removeEventListener("click", handleExtra, true);
7367
+ });
7368
+ }
7369
+ const propsData1 = vue.ref(propsData$);
7370
+ const propsData2 = vue.ref();
7371
+ leaf.propsData = propsData1;
7372
+ const allowMounted = vue.ref(typeof onBeforeCreate !== "function");
7373
+ if (!allowMounted.value) {
7374
+ const result = onBeforeCreate(propsData$);
7375
+ if (result && result.then) {
7376
+ result.then((response) => {
7377
+ if (isDestroyed()) return;
7378
+ allowMounted.value = true;
7379
+ propsData2.value = response;
7380
+ }).catch((error2) => {
7381
+ $onDestroyed(error2);
7382
+ });
7383
+ } else {
7384
+ allowMounted.value = true;
7385
+ propsData2.value = result;
7386
+ }
7387
+ }
7388
+ return () => allowMounted.value && vue.h(
7389
+ wrapper,
7390
+ {
7391
+ ...propsData1.value,
7392
+ ...propsData2.value,
7393
+ ref: (vm) => leaf.wrapper = vm,
7394
+ onPortalFulfilled: (...args) => $onFulfilled(...args),
7395
+ onPortalRejected: (...args) => $onRejected(...args),
7396
+ onPortalDestroyed: (...args) => $onDestroyed(...args)
7397
+ },
7398
+ slots || void 0
7399
+ );
7400
+ }
7401
+ });
7402
+ leaf.app = app;
7403
+ if (globalProperties) {
7404
+ app.config.globalProperties = globalProperties;
7405
+ }
7406
+ for (const key in components) {
7407
+ app.component(key, components[key]);
7408
+ }
7409
+ for (const key in uses) {
7410
+ app.use(uses[key]);
7411
+ }
7412
+ install?.(app);
7413
+ app.mount(container);
7414
+ }
7415
+ leaf.destroy = $onDestroyed;
7416
+ leaf.autoDestroy = !!autoDestroy;
7417
+ Portal.leafs.set(name, leaf);
7418
+ const append = (root$, child$) => {
7419
+ if (!root$ || !child$) return;
7420
+ if (insertion === "first") {
7421
+ const firstEl = root$.firstElementChild;
7422
+ if (firstEl) {
7423
+ root$.insertBefore(child$, firstEl);
7424
+ return;
7425
+ }
7426
+ }
7427
+ root$.appendChild(child$);
7428
+ };
7429
+ if (fragment || typeof container._children === "undefined" && !Array.from(container.children).length) {
7430
+ useAllNodes = true;
7431
+ container.parentElement === null && append(root, container);
7432
+ } else if (!container._children) {
7433
+ container._children = [];
7434
+ let childs = Array.from(container.children);
7435
+ if (insertion === "first") {
7436
+ childs = childs.reverse();
7437
+ }
7438
+ childs.forEach((i) => {
7439
+ append(root, i);
7440
+ container._children?.push?.(i);
7441
+ });
7442
+ }
7443
+ return leaf;
7444
+ }
7445
+ }
7446
+ const props$X = {
7447
+ tag: {
7448
+ type: String,
7449
+ default: "div"
7450
+ }
7451
+ };
7452
+ const COMPONENT_NAME$16 = "vc-portal-view";
7453
+ const PortalView = /* @__PURE__ */ vue.defineComponent({
7454
+ name: COMPONENT_NAME$16,
7455
+ props: props$X,
7456
+ setup(props2, {
7457
+ slots
7458
+ }) {
7459
+ return () => {
7460
+ return vue.h(vue.Fragment, [vue.h(props2.tag, {
7461
+ class: "vc-portal-view"
7462
+ }, slots?.default?.()), vue.h(vue.Teleport, {
7463
+ to: "body"
7464
+ }, slots?.content?.())]);
7465
+ };
7466
+ }
7467
+ });
7468
+ const props$W = {
7469
+ title: String,
7470
+ content: {
7471
+ type: [String, Function],
7472
+ default: ""
7473
+ },
7474
+ modelValue: {
7475
+ type: Boolean,
7476
+ default: false
7477
+ },
7478
+ width: {
7479
+ type: Number,
7480
+ default: 300
7481
+ },
7482
+ height: {
7483
+ type: Number,
7484
+ default: 300
7485
+ },
7486
+ mask: {
7487
+ type: Boolean,
7488
+ default: true
7489
+ },
7490
+ maskClosable: {
7491
+ type: Boolean,
7492
+ default: true
7493
+ },
7494
+ scrollable: {
7495
+ type: Boolean,
7496
+ default: false
7497
+ },
7498
+ placement: {
7499
+ type: String,
7500
+ default: "right"
7501
+ // top/right/left/bottom
7502
+ },
7503
+ maskStyle: [Object, String],
7504
+ wrapperClass: [Object, String],
7505
+ wrapperStyle: [Object, String],
7506
+ closeWithCancel: {
7507
+ type: Boolean,
7508
+ default: true
7509
+ // 如果关闭, cancel只能是取消的按钮
7510
+ },
7511
+ okText: {
7512
+ type: [String, Boolean],
7513
+ default: "确定"
7514
+ },
7515
+ cancelText: {
7516
+ type: [String, Boolean],
7517
+ default: "取消"
7518
+ },
7519
+ footer: {
7520
+ type: Boolean,
7521
+ default: true
7522
+ },
7523
+ /**
7524
+ * 兼容portal设计, 实现Promise方式
7525
+ */
7526
+ onOk: {
7527
+ type: Function
7528
+ },
7529
+ onCancel: {
7530
+ type: Function
7531
+ }
7532
+ };
7533
+ function _isSlot$1(s) {
7534
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !vue.isVNode(s);
7535
+ }
7536
+ const COMPONENT_NAME$15 = "vc-drawer";
7537
+ const DrawerView = /* @__PURE__ */ vue.defineComponent({
7538
+ name: COMPONENT_NAME$15,
7539
+ props: props$W,
7540
+ emits: ["close", "update:modelValue", "visible-change"],
7541
+ setup(props2, {
7542
+ emit,
7543
+ slots,
7544
+ expose
7545
+ }) {
7546
+ const instance = vue.getCurrentInstance();
7547
+ const isActive = vue.ref(false);
7548
+ const classes = vue.computed(() => {
7549
+ return {
7550
+ [`is-${props2.placement}`]: true
7551
+ };
7552
+ });
7553
+ const style = vue.computed(() => {
7554
+ return props2.placement === "top" || props2.placement === "bottom" ? {
7555
+ height: `${props2.height}px`
7556
+ } : {
7557
+ width: `${props2.width}px`
7558
+ };
7559
+ });
7560
+ vue.watch(() => props2.modelValue, (v) => {
7561
+ isActive.value = v;
7562
+ }, {
7563
+ immediate: true
7564
+ });
7565
+ const handleBefore = (e, hook) => {
7566
+ if (!isActive.value) return;
7567
+ const fn = hook && hook(e);
7568
+ if (fn && fn.then) {
7569
+ return fn.then((res) => {
7570
+ isActive.value = false;
7571
+ return res;
7572
+ });
7573
+ } else if (!fn || fn === true) {
7574
+ isActive.value = false;
7575
+ }
7576
+ };
7577
+ const handleClose = (e, closable) => {
7578
+ if (closable || props2.maskClosable && e.target.classList.contains("vc-drawer__wrapper")) {
7579
+ if (props2.closeWithCancel) {
7580
+ handleBefore(e, handleCancel);
7581
+ } else {
7582
+ isActive.value = false;
7583
+ }
7584
+ }
7585
+ };
7586
+ const handleRemove = () => {
7587
+ !instance.isUnmounted && (emit("close"), emit("update:modelValue", false), emit("visible-change", false));
7588
+ };
7589
+ const handleOk = (...rest) => {
7590
+ const ok = instance.vnode.props?.onOk || props2.onOk || (() => {
7591
+ });
7592
+ return ok(...rest);
7593
+ };
7594
+ const handleCancel = (...rest) => {
7595
+ const cancel = instance.vnode.props?.onCancel || props2.onCancel || (() => {
7596
+ });
7597
+ return cancel(...rest);
7598
+ };
7599
+ useScrollbar(isActive);
7600
+ expose({
7601
+ isActive,
7602
+ // for portal
7603
+ toggle(v) {
7604
+ v = typeof v === "boolean" ? v : !isActive.value;
7605
+ isActive.value = v;
7606
+ }
7607
+ });
7608
+ return () => {
7609
+ let _slot, _slot2;
7610
+ return vue.createVNode("div", {
7611
+ "class": [classes.value, "vc-drawer"]
7612
+ }, [vue.createVNode(TransitionFade, {
7613
+ "delay": 50
7614
+ }, _isSlot$1(_slot = vue.withDirectives(vue.createVNode("div", {
7615
+ "style": props2.maskStyle,
7616
+ "class": "vc-drawer__mask",
7617
+ "onClick": (e) => handleClose(e, props2.maskClosable)
7618
+ }, null), [[vue.vShow, props2.mask && isActive.value]])) ? _slot : {
7619
+ default: () => [_slot]
7620
+ }), vue.createVNode(TransitionSlide, {
7621
+ "mode": props2.placement,
7622
+ "onAfterLeave": handleRemove
7623
+ }, _isSlot$1(_slot2 = vue.withDirectives(vue.createVNode("div", {
7624
+ "class": [props2.wrapperClass, "vc-drawer__wrapper"],
7625
+ "style": [style.value, props2.wrapperStyle]
7626
+ }, [vue.createVNode("div", {
7627
+ "class": "vc-drawer__container"
7628
+ }, [vue.createVNode("div", {
7629
+ "class": "vc-drawer__header"
7630
+ }, [slots.header ? slots.header() : typeof props2.title === "string" ? vue.createVNode("div", {
7631
+ "class": "vc-drawer__title",
7632
+ "innerHTML": props2.title
7633
+ }, null) : typeof props2.title === "function" && vue.createVNode(Customer, {
7634
+ "render": props2.title
7635
+ }, null), vue.createVNode("a", {
7636
+ "class": "vc-drawer__close",
7637
+ "onClick": (e) => handleClose(e, true)
7638
+ }, [vue.createVNode(Icon, {
7639
+ "type": "close"
7640
+ }, null)])]), vue.createVNode("div", {
7641
+ "class": ["vc-drawer__content"]
7642
+ }, [typeof props2.content === "string" ? vue.createVNode("div", {
7643
+ "innerHTML": props2.content
7644
+ }, null) : typeof props2.content === "function" ? vue.createVNode(Customer, {
7645
+ "render": props2.content
7646
+ }, null) : null, slots.default?.()]), props2.footer && (props2.cancelText || props2.okText) && vue.createVNode("div", {
7647
+ "class": ["vc-drawer__footer"]
7648
+ }, [slots["footer-extra"]?.(), !slots.footer ? vue.createVNode(vue.Fragment, null, [props2.cancelText && vue.createVNode(Button, {
7649
+ "style": "margin-right: 8px;",
7650
+ "onClick": (e) => handleBefore(e, handleCancel)
7651
+ }, {
7652
+ default: () => [props2.cancelText]
7653
+ }), props2.okText && vue.createVNode(Button, {
7654
+ "type": "primary",
7655
+ "onClick": (e) => handleBefore(e, handleOk)
7656
+ }, {
7657
+ default: () => [props2.okText]
7658
+ })]) : slots.footer?.()])])]), [[vue.vShow, isActive.value]])) ? _slot2 : {
7659
+ default: () => [_slot2]
7660
+ })]);
7661
+ };
7662
+ }
7663
+ });
7664
+ const Drawer = new Portal(DrawerView, {
7665
+ leaveDelay: 0,
7666
+ multiple: true
7667
+ });
7668
+ const destroy$5 = () => Drawer.destroy();
7669
+ const open$1 = (options) => {
7670
+ const leaf = Drawer.popup({
7671
+ ...options,
7672
+ onFulfilled: options.onClose,
7673
+ // 当组件内使用emit('close'),避免重复触发
7674
+ onClose: null
7675
+ });
7676
+ leaf.wrapper.toggle?.(true);
7677
+ return leaf;
7678
+ };
7679
+ const drawer = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7680
+ __proto__: null,
7681
+ destroy: destroy$5,
7682
+ open: open$1
7683
+ }, Symbol.toStringTag, { value: "Module" }));
7684
+ const MDrawerView = DrawerView;
7685
+ const props$V = {
7686
+ tag: {
7687
+ type: String,
7688
+ default: "div"
7689
+ }
7690
+ };
7691
+ const COMPONENT_NAME$14 = "vc-dropdown";
7692
+ const Dropdown = /* @__PURE__ */ vue.defineComponent({
7693
+ name: COMPONENT_NAME$14,
7694
+ props: props$V,
7695
+ setup(props2, {
7696
+ slots
7697
+ }) {
7698
+ return () => {
7699
+ return vue.createVNode("div", {
7700
+ "class": "vc-dropdown"
7701
+ }, [slots?.default?.()]);
7702
+ };
7703
+ }
7704
+ });
7705
+ const MDropdown = Dropdown;
7706
+ const props$U = {
7707
+ tag: {
7708
+ type: String,
7709
+ default: "div"
7710
+ }
7711
+ };
7712
+ const COMPONENT_NAME$13 = "vc-editor";
7713
+ const Editor = /* @__PURE__ */ vue.defineComponent({
7714
+ name: COMPONENT_NAME$13,
7715
+ props: props$U,
7716
+ setup(props2, {
7717
+ slots
7718
+ }) {
7719
+ return () => {
7720
+ return vue.createVNode("div", {
7721
+ "class": "vc-editor"
7722
+ }, [slots?.default?.()]);
7723
+ };
7724
+ }
7725
+ });
7726
+ const MEditor = Editor;
7727
+ const MExpand = Expand;
7728
+ const props$T = {
7729
+ tag: {
7730
+ type: String,
7731
+ default: "form"
7732
+ },
7733
+ model: {
7734
+ type: Object
7735
+ },
7736
+ rules: {
7737
+ type: Object
7738
+ },
7739
+ labelWidth: {
7740
+ type: Number
7741
+ },
7742
+ showMessage: {
7743
+ type: Boolean,
7744
+ default: true
7745
+ },
7746
+ inline: {
7747
+ type: Boolean,
7748
+ default: false
7749
+ },
7750
+ labelPosition: {
7751
+ type: String,
7752
+ default: "right"
7753
+ },
7754
+ autocomplete: {
7755
+ type: String,
7756
+ default: "off"
7757
+ },
7758
+ styleless: {
7759
+ type: Boolean,
7760
+ default: false
7761
+ }
7762
+ };
7763
+ const useForm = (expose, options = {}) => {
7764
+ const instance = vue.getCurrentInstance();
7765
+ const props2 = instance.props;
7766
+ const fields = [];
7767
+ vue.provide("form", {
7768
+ props: props2,
7769
+ add: (field) => {
7770
+ field && fields.push(field);
7771
+ },
7772
+ remove: (field) => {
7773
+ field && fields.splice(fields.indexOf(field), 1);
7774
+ }
7775
+ });
7776
+ const filterFields = (fields$) => {
7777
+ return !fields$ ? fields : fields.filter((item) => fields$.includes(item.props.prop));
7778
+ };
7779
+ const getField = (prop) => {
7780
+ const field = fields.find((item) => item.props.prop === prop);
7781
+ if (!field) throw new VcError("form", "请选择有用的prop值");
7782
+ return field;
7783
+ };
7784
+ const showToast = (msg) => {
7785
+ props2.showMessage && options.throwToast?.(msg);
7786
+ };
7787
+ const sortErrors = async (errors) => {
7788
+ const positions = await Promise.all(fields.map((item) => item.exposed.getPosition()));
7789
+ try {
7790
+ return [...errors].toSorted((a, b) => {
7791
+ const aIndex = fields.findIndex((i) => i.props.prop === a.prop);
7792
+ const bIndex = fields.findIndex((i) => i.props.prop === b.prop);
7793
+ const aPosition = positions[aIndex];
7794
+ const bPosition = positions[bIndex];
7795
+ if (aPosition.top != bPosition.top) return aPosition.top - bPosition.top;
7796
+ return aPosition.left - bPosition.left;
7797
+ });
7798
+ } catch {
7799
+ return errors;
7800
+ }
7801
+ };
7802
+ const scrollIntoView = (prop) => {
7803
+ const field = getField(prop);
7804
+ field.vnode?.el?.scrollIntoView?.({
7805
+ behavior: "smooth",
7806
+ block: "center"
7807
+ });
7808
+ };
7809
+ const reset = (options$ = {}) => {
7810
+ const { fields: fields$, original = {} } = options$;
7811
+ filterFields(fields$).forEach((field) => {
7066
7812
  let v;
7067
7813
  try {
7068
7814
  v = getPropByPath(original, field.props.prop).v;
7069
- } catch (e) {
7815
+ } catch {
7070
7816
  }
7071
7817
  field.exposed.reset(v);
7072
7818
  });
@@ -7137,6 +7883,11 @@
7137
7883
  type: [Boolean, String],
7138
7884
  default: false
7139
7885
  },
7886
+ // 控制`*`是否展示
7887
+ asterisk: {
7888
+ type: Boolean,
7889
+ default: true
7890
+ },
7140
7891
  error: {
7141
7892
  type: String
7142
7893
  },
@@ -7181,7 +7932,7 @@
7181
7932
  if (!form?.props) {
7182
7933
  throw new VcError("form-item", "form-item需要在form内使用");
7183
7934
  }
7184
- const formItem = vue.inject("form-item", {});
7935
+ const formItem = vue.inject("vc-form-item", {});
7185
7936
  const validateState = vue.ref("");
7186
7937
  const validateMessage = vue.ref("");
7187
7938
  let validateDisabled = false;
@@ -7219,7 +7970,7 @@
7219
7970
  });
7220
7971
  const classes = vue.computed(() => {
7221
7972
  return {
7222
- "is-require": isRequired.value,
7973
+ "is-require": isRequired.value && props2.asterisk,
7223
7974
  "is-error": validateState.value === "error",
7224
7975
  "is-validating": validateState.value === "validating",
7225
7976
  "is-inline": form.props.inline,
@@ -7271,667 +8022,313 @@
7271
8022
  vue.watch(
7272
8023
  () => props2.error,
7273
8024
  (v) => {
7274
- validateMessage.value = v || "";
7275
- validateState.value = v === "" ? "" : "error";
7276
- }
7277
- );
7278
- const reset = (v) => {
7279
- validateState.value = "";
7280
- validateMessage.value = "";
7281
- const model = form.props.model;
7282
- if (!props2.prop) return;
7283
- const { o, k } = getPropByPath(model, props2.prop);
7284
- if (!k) return;
7285
- validateDisabled = true;
7286
- o[k] = v !== null && v !== void 0 ? v : Array.isArray(fieldValue.value) ? [].concat(initialValue) : initialValue;
7287
- };
7288
- const validate = async (trigger) => {
7289
- if (!props2.prop) return;
7290
- let rules = currentRules.value.filter((rule) => !rule.trigger || rule.trigger.includes(trigger));
7291
- if (!rules.length) {
7292
- if (!props2.required) {
7293
- return;
7294
- } else {
7295
- rules = [{
7296
- required: true,
7297
- message: typeof props2.required === "string" ? props2.required : void 0
7298
- }];
7299
- }
7300
- }
7301
- validateState.value = "validating";
7302
- const descriptor = {};
7303
- descriptor[props2.prop] = rules;
7304
- const validator = new Validator(descriptor);
7305
- const model = {};
7306
- model[props2.prop] = filterEmpty(fieldValue.value);
7307
- try {
7308
- await validator.validate(model, { first: false });
7309
- validateState.value = "success";
7310
- validateMessage.value = "";
7311
- } catch (errors) {
7312
- validateState.value = "error";
7313
- validateMessage.value = errors[0].message;
7314
- throw {
7315
- prop: props2.prop,
7316
- message: validateMessage.value
7317
- };
7318
- }
7319
- validateDisabled = false;
7320
- };
7321
- const handleFieldBlur = () => {
7322
- if (!props2.prop) {
7323
- formItem.blur?.();
7324
- return;
7325
- }
7326
- validate("blur");
7327
- };
7328
- const handleFieldChange = () => {
7329
- if (!props2.prop) {
7330
- formItem.change?.();
7331
- return;
7332
- }
7333
- if (validateDisabled) {
7334
- validateDisabled = false;
7335
- return;
7336
- }
7337
- validate("change");
7338
- };
7339
- const getPosition = async () => {
7340
- let el2 = instance.vnode.el;
7341
- try {
7342
- while (el2 && !el2.getBoundingClientRect) {
7343
- el2 = el2.nextSibling;
7344
- }
7345
- ;
7346
- const rect = el2.getBoundingClientRect();
7347
- return {
7348
- top: rect.top,
7349
- left: rect.left
7350
- };
7351
- } catch (e) {
7352
- throw new VcError("form-item", "form-item位置计算错误");
7353
- }
7354
- };
7355
- const fields = vue.reactive([]);
7356
- vue.provide("form-item", {
7357
- fields,
7358
- blur: handleFieldBlur,
7359
- change: handleFieldChange,
7360
- message: validateMessage,
7361
- add: (field) => {
7362
- field && fields.push(field);
7363
- },
7364
- remove: (field) => {
7365
- field && fields.splice(fields.indexOf(field), 1);
7366
- }
7367
- });
7368
- vue.onMounted(() => {
7369
- if (props2.prop) {
7370
- form.add?.(instance);
7371
- initialValue = cloneDeep(fieldValue.value);
7372
- }
7373
- formItem.add?.(instance);
7374
- });
7375
- vue.onBeforeUnmount(() => {
7376
- form.remove?.(instance);
7377
- formItem.remove?.(instance);
7378
- });
7379
- vue.watch(
7380
- () => props2.rules,
7381
- () => {
7382
- props2.resetByRulesChanged && reset();
7383
- }
7384
- );
7385
- vue.watch(
7386
- () => formItem.fields?.length,
7387
- async (v) => {
7388
- if (!isNest.value || !v) return isNestLast.value = false;
7389
- const fields$ = [...vue.toRaw(formItem.fields)];
7390
- const positions = await Promise.all(fields$.map((item) => item.exposed.getPosition()));
7391
- const sortFields = fields$.toSorted((a, b) => {
7392
- const aIndex = fields$.findIndex((i) => i === a);
7393
- const bIndex = fields$.findIndex((i) => i === b);
7394
- const aPosition = positions[aIndex];
7395
- const bPosition = positions[bIndex];
7396
- if (aPosition.top != bPosition.top) return aPosition.top - bPosition.top;
7397
- return aPosition.left - bPosition.left;
7398
- });
7399
- isNestLast.value = sortFields[sortFields.length - 1] === instance;
7400
- }
7401
- );
7402
- expose({
7403
- validate,
7404
- reset,
7405
- getPosition
7406
- });
7407
- return {
7408
- isNest,
7409
- isStyleless,
7410
- isNestLast,
7411
- validateMessage,
7412
- classes,
7413
- labelStyle,
7414
- contentStyle,
7415
- showError,
7416
- labelPosition
7417
- };
7418
- };
7419
- const COMPONENT_NAME$11 = "vc-form-item";
7420
- const FormItem = /* @__PURE__ */ vue.defineComponent({
7421
- name: COMPONENT_NAME$11,
7422
- props: props$S,
7423
- setup(props2, {
7424
- slots,
7425
- expose
7426
- }) {
7427
- const it = useFormItem(expose);
7428
- const {
7429
- isStyleless,
7430
- isNest,
7431
- classes,
7432
- labelStyle,
7433
- contentStyle,
7434
- showError,
7435
- validateMessage
7436
- } = it;
7437
- const {
7438
- label,
7439
- labelFor
7440
- } = props2;
7441
- const errorColorClass = "vc-form-item__error";
7442
- return () => {
7443
- if (isStyleless.value) return [slots.default?.(), slots.error?.({
7444
- show: showError.value,
7445
- nest: isNest.value,
7446
- message: validateMessage.value,
7447
- class: errorColorClass
7448
- })];
7449
- return vue.createVNode("div", {
7450
- "class": ["vc-form-item", classes.value]
7451
- }, [vue.createVNode("div", {
7452
- "style": labelStyle.value,
7453
- "class": "vc-form-item__label",
7454
- "for": labelFor
7455
- }, [vue.createVNode("label", null, [label || slots.label?.()])]), vue.createVNode("div", {
7456
- "class": "vc-form-item__wrapper"
7457
- }, [vue.createVNode("div", {
7458
- "class": "vc-form-item__content",
7459
- "style": contentStyle.value
7460
- }, [slots.default?.(), slots.error ? slots.error({
7461
- show: showError.value,
7462
- nest: isNest.value,
7463
- message: validateMessage.value,
7464
- class: errorColorClass
7465
- }) : vue.createVNode(TransitionFade, null, {
7466
- default: () => [vue.withDirectives(vue.createVNode("div", {
7467
- "class": ["vc-form-item__tip", isNest.value ? "is-nest" : "", errorColorClass]
7468
- }, [validateMessage.value]), [[vue.vShow, showError.value]])]
7469
- })])])]);
7470
- };
7471
- }
7472
- });
7473
- const props$R = {
7474
- ...props$T,
7475
- showToast: {
7476
- type: Boolean,
7477
- default: false
7478
- },
7479
- border: {
7480
- type: Boolean,
7481
- default: false
7482
- }
7483
- };
7484
- const props$Q = {
7485
- content: [String, Function],
7486
- maskClosable: {
7487
- type: Boolean,
7488
- default: true
7489
- },
7490
- // 单位ms
7491
- duration: {
7492
- type: Number,
7493
- default: 3e3
7494
- },
7495
- mode: {
7496
- type: String,
7497
- default: "info",
7498
- validator: (val) => ["info", "loading", "success", "warning", "error"].includes(val)
7499
- }
7500
- };
7501
- const MSpin = Spin;
7502
- const MTransition = Transition;
7503
- const MTransitionCollapse = TransitionCollapse;
7504
- const MTransitionFade = TransitionFade;
7505
- const MTransitionScale = TransitionScale;
7506
- const MTransitionSlide = TransitionSlide;
7507
- const MTransitionZoom = TransitionZoom;
7508
- const COMPONENT_NAME$10 = "vcm-toast";
7509
- const MToastView = /* @__PURE__ */ vue.defineComponent({
7510
- name: COMPONENT_NAME$10,
7511
- emits: ["close", "portal-fulfilled"],
7512
- props: props$Q,
7513
- setup(props2, {
7514
- emit,
7515
- expose
7516
- }) {
7517
- const isActive = vue.ref(false);
7518
- const currentContent = vue.ref();
7519
- const setContent = (v) => {
7520
- currentContent.value = v;
7521
- };
7522
- const handleRemove = () => {
7523
- emit("close");
7524
- emit("portal-fulfilled");
7525
- };
7526
- const handleClose = () => {
7527
- if (props2.maskClosable) {
7528
- isActive.value = false;
7529
- }
7530
- };
7531
- vue.watch(() => props2.content, setContent, {
7532
- immediate: true
7533
- });
7534
- let timer;
7535
- vue.onMounted(() => {
7536
- isActive.value = true;
7537
- if (props2.duration !== 0) {
7538
- timer = setTimeout(() => isActive.value = false, props2.duration);
7539
- }
7540
- });
7541
- vue.onUnmounted(() => {
7542
- timer && clearTimeout(timer);
7543
- });
7544
- const exposes = ["destroy", "remove", "close", "hide"].reduce((pre, key) => {
7545
- pre[key] = handleRemove;
7546
- return pre;
7547
- }, {});
7548
- expose(exposes);
7549
- return () => {
7550
- return vue.createVNode("div", {
7551
- "class": "vcm-toast"
7552
- }, [vue.createVNode("div", {
7553
- "class": "vcm-toast__bg",
7554
- "onClick": handleClose,
7555
- "onTouchmove": vue.withModifiers(() => {
7556
- }, ["prevent"])
7557
- }, null), vue.createVNode(MTransitionFade, {
7558
- "duration": {
7559
- enter: 300,
7560
- leave: 150
7561
- },
7562
- "onAfterLeave": handleRemove
7563
- }, {
7564
- default: () => [vue.withDirectives(vue.createVNode("div", {
7565
- "class": "vcm-toast__wrapper"
7566
- }, [props2.mode === "loading" && vue.createVNode(MSpin, {
7567
- "class": "vcm-toast__loading"
7568
- }, null), typeof currentContent.value === "string" ? vue.createVNode("div", {
7569
- "class": "vcm-toast__content",
7570
- "innerHTML": currentContent.value
7571
- }, null) : typeof currentContent.value === "function" ? vue.createVNode(MCustomer, {
7572
- "render": currentContent.value
7573
- }, null) : null]), [[vue.vShow, isActive.value]])]
7574
- })]);
7575
- };
7576
- }
7577
- });
7578
- const defaults$2 = {
7579
- tag: "div",
7580
- el: "body",
7581
- alive: false,
7582
- multiple: false,
7583
- aliveRegExp: { className: /(vc-hack-alive|vc-hack-cp)/ },
7584
- aliveVisibleKey: "isVisible",
7585
- aliveUpdateKey: "update",
7586
- leaveDelay: 300,
7587
- autoDestroy: true,
7588
- components: {},
7589
- uses: {},
7590
- fragment: false,
7591
- insertion: "last"
7592
- };
7593
- class PortalLeaf {
7594
- app;
7595
- /**
7596
- * 目标的实例,挂载到app上
7597
- */
7598
- wrapper;
7599
- propsData;
7600
- /**
7601
- * 销毁的函数,挂载到app上,避免冲突
7602
- */
7603
- destroy;
7604
- /**
7605
- * 自动销毁的标记,挂载到app上,避免冲突
7606
- */
7607
- autoDestroy;
7608
- target;
7609
- constructor(target) {
7610
- this.target = target;
7611
- this.autoDestroy = false;
7612
- this.destroy = /* istanbul ignore next */
7613
- () => {
7614
- throw new VcError("portal", "未注册的destroy方法");
7615
- };
7616
- }
7617
- then(resolve, reject) {
7618
- return this.target.then(resolve, reject);
7619
- }
7620
- catch(callback) {
7621
- return this.target.catch(callback);
7622
- }
7623
- finally(callback) {
7624
- return this.target.finally(callback);
7625
- }
7626
- }
7627
- const COMPONENT_NAME$$ = "vc-portal";
7628
- class Portal {
7629
- /**
7630
- * 清理Portals类型组件
7631
- * @param name 清理的组件名, boolean表示全部leafs是否强制清理
7632
- */
7633
- static clear(name) {
7634
- try {
7635
- let force = false;
7636
- let target = /* @__PURE__ */ new Map();
7637
- if (name && typeof name !== "boolean") {
7638
- let names = [];
7639
- if (typeof name === "string") {
7640
- names = [name];
7641
- } else if (name instanceof Array && name.length > 0) {
7642
- names = name;
7643
- }
7644
- names.forEach((i) => target.set(i, ""));
7645
- force = true;
7646
- } else {
7647
- force = !!name;
7648
- target = Portal.leafs;
7649
- }
7650
- for (const key of target.keys()) {
7651
- const leaf = Portal.leafs.get(key);
7652
- if (leaf && (force === true || leaf.autoDestroy === true)) {
7653
- leaf.destroy();
7654
- }
7655
- }
7656
- } catch (e) {
7657
- /* istanbul ignore next -- @preserve */
7658
- throw new VcError("instance", e);
7659
- }
7660
- }
7661
- /**
7662
- * 清理全部Portals
7663
- */
7664
- static clearAll() {
7665
- try {
7666
- Portal.leafs.forEach((leaf) => leaf.destroy());
7667
- } catch (e) {
7668
- /* istanbul ignore next -- @preserve */
7669
- throw new VcError("instance", e);
7670
- }
7671
- }
7672
- static leafs = /* @__PURE__ */ new Map();
7673
- wrapper;
7674
- globalOptions;
7675
- constructor(wrapper, options) {
7676
- this.wrapper = wrapper;
7677
- this.globalOptions = {
7678
- ...options,
7679
- name: options?.name || wrapper.name || getUid(COMPONENT_NAME$$)
7680
- };
7681
- }
7682
- popup(propsData, options) {
7683
- if (!options) {
7684
- options = propsData || {};
7685
- } else {
7686
- options.propsData = propsData;
7687
- }
7688
- const $options = { ...this.getDefaultOptions(), ...options };
7689
- const { onFulfilled, onRejected, ...rest } = $options;
7690
- let onFulfilled$ = (
7691
- /* istanbul ignore next -- @preserve */
7692
- () => {
7693
- }
7694
- );
7695
- let onRejected$ = (
7696
- /* istanbul ignore next -- @preserve */
7697
- () => {
7698
- }
7699
- );
7700
- const target = new Promise((resolve, reject) => {
7701
- onFulfilled$ = (v) => {
7702
- onFulfilled?.(v);
7703
- resolve(v);
7704
- };
7705
- onRejected$ = (v) => {
7706
- onRejected?.(v);
7707
- reject(v);
7708
- };
7709
- });
7710
- return this.render(rest, target, onFulfilled$, onRejected$);
7711
- }
7712
- /**
7713
- * 销毁当前Portal下的节点
7714
- * @param target [description]
7715
- */
7716
- destroy = (target) => {
7717
- const { multiple, name } = this.getDefaultOptions();
7718
- target = target || name;
7719
- const instance = typeof target === "object" ? target : Portal.leafs.get(target);
7720
- if (instance) {
7721
- instance.destroy();
7722
- } else if (multiple) {
7723
- Portal.leafs.forEach((item, key) => {
7724
- if (key.includes(name)) {
7725
- item.destroy();
7726
- }
7727
- });
7728
- }
7729
- };
7730
- getDefaultOptions() {
7731
- return {
7732
- ...defaults$2,
7733
- ...VcInstance.options.Portal,
7734
- ...this.globalOptions
7735
- };
7736
- }
7737
- createCallback(getLeaf, delay, callback) {
7738
- return (...args) => {
7739
- const done = () => {
7740
- const leaf = getLeaf();
7741
- /* istanbul ignore next -- @preserve */
7742
- if (!leaf) {
7743
- throw new VcError("portal", "实例不存在或已卸载");
7744
- }
7745
- leaf.destroy();
7746
- };
7747
- delay ? setTimeout(done, delay) : done();
7748
- callback?.(...args);
7749
- };
7750
- }
7751
- render(options, target, onFulfilled, onRejected) {
7752
- const {
7753
- el: el2,
7754
- tag,
7755
- alive,
7756
- aliveRegExp,
7757
- aliveVisibleKey,
7758
- aliveUpdateKey,
7759
- name: name$,
7760
- leaveDelay,
7761
- autoDestroy,
7762
- multiple,
7763
- fragment,
7764
- onDestroyed,
7765
- onBeforeCreate,
7766
- insertion,
7767
- // 全局注册
7768
- globalProperties,
7769
- install,
7770
- components,
7771
- uses,
7772
- slots,
7773
- parent,
7774
- propsData,
7775
- ...rest
7776
- } = options;
7777
- let useAllNodes = fragment;
7778
- const name = multiple ? `${name$}__${getUid(COMPONENT_NAME$$)}` : name$;
7779
- const container = document.createElement(tag);
7780
- const root = typeof el2 === "object" ? el2 : document.querySelector(el2 || "body");
7781
- !alive && Portal.leafs.get(name)?.destroy();
7782
- const propsData$ = propsData || rest;
7783
- let leaf = new PortalLeaf(target);
7784
- const isDestroyed = () => {
7785
- const leaf$ = Portal.leafs.get(name);
7786
- return !leaf$ || leaf$ !== leaf;
7787
- };
7788
- const $onDestroyed = (...args) => {
7789
- if (isDestroyed()) return;
7790
- onDestroyed?.(...args);
7791
- leaf.app?.unmount();
7792
- /* istanbul ignore else -- @preserve */
7793
- if (useAllNodes) {
7794
- root?.contains(container) && root.removeChild(container);
7795
- } else if (container && container._children) {
7796
- container._children.forEach((i) => {
7797
- root?.contains(i) && root.removeChild(i);
7798
- });
7799
- }
7800
- Portal.leafs.delete(name);
7801
- };
7802
- const $onRejected = this.createCallback(() => leaf, leaveDelay, onRejected);
7803
- const $onFulfilled = this.createCallback(() => leaf, leaveDelay, onFulfilled);
7804
- if (alive && Portal.leafs.has(name)) {
7805
- leaf = Portal.leafs.get(name);
7806
- leaf.target = target;
7807
- leaf.propsData.value = propsData$;
7808
- leaf.wrapper?.[aliveUpdateKey]?.(options);
7809
- } else {
7810
- const wrapper = this.wrapper;
7811
- const app = vue.createApp({
7812
- name: COMPONENT_NAME$$,
7813
- parent,
7814
- setup() {
7815
- if (alive) {
7816
- const handleExtra = (e) => {
7817
- try {
7818
- const path = e.path || composedPath(e);
7819
- /* istanbul ignore else -- @preserve */
7820
- if (container && e.target && !container.contains(e.target) && !path?.some((item) => utils.eleInRegExp(item, aliveRegExp))) {
7821
- /* istanbul ignore else -- @preserve */
7822
- if (leaf.wrapper && leaf.wrapper?.[aliveVisibleKey]) {
7823
- leaf.wrapper[aliveVisibleKey] = false;
7824
- }
7825
- leaveDelay ? setTimeout($onDestroyed, leaveDelay) : $onDestroyed();
7826
- }
7827
- } catch (error2) {
7828
- /* istanbul ignore next -- @preserve */
7829
- throw new VcError("portal", error2);
7830
- }
7831
- };
7832
- vue.onMounted(() => {
7833
- document.addEventListener("click", handleExtra, true);
7834
- });
7835
- vue.onBeforeUnmount(() => {
7836
- document.removeEventListener("click", handleExtra, true);
7837
- });
7838
- }
7839
- const propsData1 = vue.ref(propsData$);
7840
- const propsData2 = vue.ref();
7841
- leaf.propsData = propsData1;
7842
- const allowMounted = vue.ref(typeof onBeforeCreate !== "function");
7843
- if (!allowMounted.value) {
7844
- const result = onBeforeCreate(propsData$);
7845
- if (result && result.then) {
7846
- result.then((response) => {
7847
- if (isDestroyed()) return;
7848
- allowMounted.value = true;
7849
- propsData2.value = response;
7850
- }).catch((error2) => {
7851
- $onDestroyed(error2);
7852
- });
7853
- } else {
7854
- allowMounted.value = true;
7855
- propsData2.value = result;
7856
- }
7857
- }
7858
- return () => allowMounted.value && vue.h(
7859
- wrapper,
7860
- {
7861
- ...propsData1.value,
7862
- ...propsData2.value,
7863
- ref: (vm) => leaf.wrapper = vm,
7864
- onPortalFulfilled: (...args) => $onFulfilled(...args),
7865
- onPortalRejected: (...args) => $onRejected(...args),
7866
- onPortalDestroyed: (...args) => $onDestroyed(...args)
7867
- },
7868
- slots || void 0
7869
- );
7870
- }
7871
- });
7872
- leaf.app = app;
7873
- if (globalProperties) {
7874
- app.config.globalProperties = globalProperties;
7875
- }
7876
- for (const key in components) {
7877
- app.component(key, components[key]);
7878
- }
7879
- for (const key in uses) {
7880
- app.use(uses[key]);
7881
- }
7882
- install?.(app);
7883
- app.mount(container);
8025
+ validateMessage.value = v || "";
8026
+ validateState.value = v === "" ? "" : "error";
7884
8027
  }
7885
- leaf.destroy = $onDestroyed;
7886
- leaf.autoDestroy = !!autoDestroy;
7887
- Portal.leafs.set(name, leaf);
7888
- const append = (root$, child$) => {
7889
- if (!root$ || !child$) return;
7890
- if (insertion === "first") {
7891
- const firstEl = root$.firstElementChild;
7892
- if (firstEl) {
7893
- root$.insertBefore(child$, firstEl);
7894
- return;
7895
- }
8028
+ );
8029
+ const reset = (v) => {
8030
+ validateState.value = "";
8031
+ validateMessage.value = "";
8032
+ const model = form.props.model;
8033
+ if (!props2.prop) return;
8034
+ const { o, k } = getPropByPath(model, props2.prop);
8035
+ if (!k) return;
8036
+ validateDisabled = true;
8037
+ o[k] = v !== null && v !== void 0 ? v : Array.isArray(fieldValue.value) ? [].concat(initialValue) : initialValue;
8038
+ };
8039
+ const validate = async (trigger) => {
8040
+ if (!props2.prop) return;
8041
+ let rules = currentRules.value.filter((rule) => !rule.trigger || rule.trigger.includes(trigger));
8042
+ if (!rules.length) {
8043
+ if (!props2.required) {
8044
+ return;
8045
+ } else {
8046
+ rules = [{
8047
+ required: true,
8048
+ message: typeof props2.required === "string" ? props2.required : void 0
8049
+ }];
7896
8050
  }
7897
- root$.appendChild(child$);
7898
- };
7899
- if (fragment || typeof container._children === "undefined" && !Array.from(container.children).length) {
7900
- useAllNodes = true;
7901
- container.parentElement === null && append(root, container);
7902
- } else if (!container._children) {
7903
- container._children = [];
7904
- let childs = Array.from(container.children);
7905
- if (insertion === "first") {
7906
- childs = childs.reverse();
8051
+ }
8052
+ validateState.value = "validating";
8053
+ const descriptor = {};
8054
+ descriptor[props2.prop] = rules;
8055
+ const validator = new Validator(descriptor);
8056
+ const model = {};
8057
+ model[props2.prop] = filterEmpty(fieldValue.value);
8058
+ try {
8059
+ await validator.validate(model, { first: false });
8060
+ validateState.value = "success";
8061
+ validateMessage.value = "";
8062
+ } catch (errors) {
8063
+ validateState.value = "error";
8064
+ validateMessage.value = errors[0].message;
8065
+ throw {
8066
+ prop: props2.prop,
8067
+ message: validateMessage.value
8068
+ };
8069
+ }
8070
+ validateDisabled = false;
8071
+ };
8072
+ const handleFieldBlur = () => {
8073
+ if (!props2.prop) {
8074
+ formItem.blur?.();
8075
+ return;
8076
+ }
8077
+ validate("blur");
8078
+ };
8079
+ const handleFieldChange = () => {
8080
+ if (!props2.prop) {
8081
+ formItem.change?.();
8082
+ return;
8083
+ }
8084
+ if (validateDisabled) {
8085
+ validateDisabled = false;
8086
+ return;
8087
+ }
8088
+ validate("change");
8089
+ };
8090
+ const getPosition = async () => {
8091
+ let el2 = instance.vnode.el;
8092
+ try {
8093
+ while (el2 && !el2.getBoundingClientRect) {
8094
+ el2 = el2.nextSibling;
7907
8095
  }
7908
- childs.forEach((i) => {
7909
- append(root, i);
7910
- container._children?.push?.(i);
8096
+ ;
8097
+ const rect = el2.getBoundingClientRect();
8098
+ return {
8099
+ top: rect.top,
8100
+ left: rect.left
8101
+ };
8102
+ } catch {
8103
+ throw new VcError("form-item", "form-item位置计算错误");
8104
+ }
8105
+ };
8106
+ const fields = vue.reactive([]);
8107
+ vue.provide("vc-form-item", {
8108
+ fields,
8109
+ blur: handleFieldBlur,
8110
+ change: handleFieldChange,
8111
+ message: validateMessage,
8112
+ add: (field) => {
8113
+ field && fields.push(field);
8114
+ },
8115
+ remove: (field) => {
8116
+ field && fields.splice(fields.indexOf(field), 1);
8117
+ }
8118
+ });
8119
+ vue.onMounted(() => {
8120
+ if (props2.prop) {
8121
+ form.add?.(instance);
8122
+ initialValue = cloneDeep(fieldValue.value);
8123
+ }
8124
+ formItem.add?.(instance);
8125
+ });
8126
+ vue.onBeforeUnmount(() => {
8127
+ form.remove?.(instance);
8128
+ formItem.remove?.(instance);
8129
+ });
8130
+ vue.watch(
8131
+ () => props2.rules,
8132
+ () => {
8133
+ props2.resetByRulesChanged && reset();
8134
+ }
8135
+ );
8136
+ vue.watch(
8137
+ () => formItem.fields?.length,
8138
+ async (v) => {
8139
+ if (!isNest.value || !v) return isNestLast.value = false;
8140
+ const fields$ = [...vue.toRaw(formItem.fields)];
8141
+ const positions = await Promise.all(fields$.map((item) => item.exposed.getPosition()));
8142
+ const sortFields = fields$.toSorted((a, b) => {
8143
+ const aIndex = fields$.findIndex((i) => i === a);
8144
+ const bIndex = fields$.findIndex((i) => i === b);
8145
+ const aPosition = positions[aIndex];
8146
+ const bPosition = positions[bIndex];
8147
+ if (aPosition.top != bPosition.top) return aPosition.top - bPosition.top;
8148
+ return aPosition.left - bPosition.left;
7911
8149
  });
8150
+ isNestLast.value = sortFields[sortFields.length - 1] === instance;
7912
8151
  }
7913
- return leaf;
8152
+ );
8153
+ expose({
8154
+ validate,
8155
+ reset,
8156
+ getPosition
8157
+ });
8158
+ return {
8159
+ isNest,
8160
+ isStyleless,
8161
+ isNestLast,
8162
+ validateMessage,
8163
+ classes,
8164
+ labelStyle,
8165
+ contentStyle,
8166
+ showError,
8167
+ labelPosition
8168
+ };
8169
+ };
8170
+ const COMPONENT_NAME$11 = "vc-form-item";
8171
+ const FormItem = /* @__PURE__ */ vue.defineComponent({
8172
+ name: COMPONENT_NAME$11,
8173
+ props: props$S,
8174
+ setup(props2, {
8175
+ slots,
8176
+ expose
8177
+ }) {
8178
+ const it = useFormItem(expose);
8179
+ const {
8180
+ isStyleless,
8181
+ isNest,
8182
+ classes,
8183
+ labelStyle,
8184
+ contentStyle,
8185
+ showError,
8186
+ validateMessage
8187
+ } = it;
8188
+ const {
8189
+ label,
8190
+ labelFor
8191
+ } = props2;
8192
+ const errorColorClass = "vc-form-item__error";
8193
+ return () => {
8194
+ if (isStyleless.value) return [slots.default?.(), slots.error?.({
8195
+ show: showError.value,
8196
+ nest: isNest.value,
8197
+ message: validateMessage.value,
8198
+ class: errorColorClass
8199
+ })];
8200
+ return vue.createVNode("div", {
8201
+ "class": ["vc-form-item", classes.value]
8202
+ }, [vue.createVNode("div", {
8203
+ "style": labelStyle.value,
8204
+ "class": "vc-form-item__label",
8205
+ "for": labelFor
8206
+ }, [vue.createVNode("label", null, [label || slots.label?.()])]), vue.createVNode("div", {
8207
+ "class": "vc-form-item__wrapper"
8208
+ }, [vue.createVNode("div", {
8209
+ "class": "vc-form-item__content",
8210
+ "style": contentStyle.value
8211
+ }, [slots.default?.(), slots.error ? slots.error({
8212
+ show: showError.value,
8213
+ nest: isNest.value,
8214
+ message: validateMessage.value,
8215
+ class: errorColorClass
8216
+ }) : vue.createVNode(TransitionFade, null, {
8217
+ default: () => [vue.withDirectives(vue.createVNode("div", {
8218
+ "class": ["vc-form-item__tip", isNest.value ? "is-nest" : "", errorColorClass]
8219
+ }, [validateMessage.value]), [[vue.vShow, showError.value]])]
8220
+ })])])]);
8221
+ };
7914
8222
  }
7915
- }
7916
- const props$P = {
7917
- tag: {
8223
+ });
8224
+ const props$R = {
8225
+ ...props$T,
8226
+ showToast: {
8227
+ type: Boolean,
8228
+ default: false
8229
+ },
8230
+ border: {
8231
+ type: Boolean,
8232
+ default: false
8233
+ }
8234
+ };
8235
+ const props$Q = {
8236
+ content: [String, Function],
8237
+ maskClosable: {
8238
+ type: Boolean,
8239
+ default: true
8240
+ },
8241
+ // 单位ms
8242
+ duration: {
8243
+ type: Number,
8244
+ default: 3e3
8245
+ },
8246
+ mode: {
7918
8247
  type: String,
7919
- default: "div"
8248
+ default: "info",
8249
+ validator: (val) => ["info", "loading", "success", "warning", "error"].includes(val)
7920
8250
  }
7921
8251
  };
7922
- const COMPONENT_NAME$_ = "vc-portal-view";
7923
- const PortalView = /* @__PURE__ */ vue.defineComponent({
7924
- name: COMPONENT_NAME$_,
7925
- props: props$P,
8252
+ const MSpin = Spin;
8253
+ const MTransition = Transition;
8254
+ const MTransitionCollapse = TransitionCollapse;
8255
+ const MTransitionFade = TransitionFade;
8256
+ const MTransitionScale = TransitionScale;
8257
+ const MTransitionSlide = TransitionSlide;
8258
+ const MTransitionZoom = TransitionZoom;
8259
+ const COMPONENT_NAME$10 = "vcm-toast";
8260
+ const MToastView = /* @__PURE__ */ vue.defineComponent({
8261
+ name: COMPONENT_NAME$10,
8262
+ emits: ["close", "portal-fulfilled"],
8263
+ props: props$Q,
7926
8264
  setup(props2, {
7927
- slots
8265
+ emit,
8266
+ expose
7928
8267
  }) {
8268
+ const isActive = vue.ref(false);
8269
+ const currentContent = vue.ref();
8270
+ let timer;
8271
+ const setDuration = (v) => {
8272
+ timer && clearTimeout(timer);
8273
+ if (v === 0) return;
8274
+ timer = setTimeout(() => isActive.value = false, v);
8275
+ };
8276
+ const setContent = (v) => {
8277
+ currentContent.value = v;
8278
+ };
8279
+ const handleRemove = () => {
8280
+ emit("close");
8281
+ emit("portal-fulfilled");
8282
+ };
8283
+ const handleClose = () => {
8284
+ if (props2.maskClosable) {
8285
+ isActive.value = false;
8286
+ }
8287
+ };
8288
+ vue.watch(() => props2.content, setContent, {
8289
+ immediate: true
8290
+ });
8291
+ vue.onMounted(() => {
8292
+ isActive.value = true;
8293
+ setDuration(props2.duration);
8294
+ });
8295
+ vue.onUnmounted(() => {
8296
+ timer && clearTimeout(timer);
8297
+ });
8298
+ const exposes = ["destroy", "remove", "close", "hide"].reduce((pre, key) => {
8299
+ pre[key] = handleRemove;
8300
+ return pre;
8301
+ }, {
8302
+ setContent,
8303
+ setDuration
8304
+ });
8305
+ expose(exposes);
7929
8306
  return () => {
7930
- return vue.h(vue.Fragment, [vue.h(props2.tag, {
7931
- class: "vc-portal-view"
7932
- }, slots?.default?.()), vue.h(vue.Teleport, {
7933
- to: "body"
7934
- }, slots?.content?.())]);
8307
+ return vue.createVNode("div", {
8308
+ "class": "vcm-toast"
8309
+ }, [vue.createVNode("div", {
8310
+ "class": "vcm-toast__bg",
8311
+ "onClick": handleClose,
8312
+ "onTouchmove": vue.withModifiers(() => {
8313
+ }, ["prevent"])
8314
+ }, null), vue.createVNode(MTransitionFade, {
8315
+ "duration": {
8316
+ enter: 300,
8317
+ leave: 150
8318
+ },
8319
+ "onAfterLeave": handleRemove
8320
+ }, {
8321
+ default: () => [vue.withDirectives(vue.createVNode("div", {
8322
+ "class": "vcm-toast__wrapper"
8323
+ }, [props2.mode === "loading" && vue.createVNode(MSpin, {
8324
+ "class": "vcm-toast__loading"
8325
+ }, null), typeof currentContent.value === "string" ? vue.createVNode("div", {
8326
+ "class": "vcm-toast__content",
8327
+ "innerHTML": currentContent.value
8328
+ }, null) : typeof currentContent.value === "function" ? vue.createVNode(MCustomer, {
8329
+ "render": currentContent.value
8330
+ }, null) : null]), [[vue.vShow, isActive.value]])]
8331
+ })]);
7935
8332
  };
7936
8333
  }
7937
8334
  });
@@ -7968,9 +8365,9 @@
7968
8365
  success: success$3,
7969
8366
  warning: warning$3
7970
8367
  }, Symbol.toStringTag, { value: "Module" }));
7971
- const COMPONENT_NAME$Z = "vcm-form";
8368
+ const COMPONENT_NAME$$ = "vcm-form";
7972
8369
  const MForm = vue.defineComponent({
7973
- name: COMPONENT_NAME$Z,
8370
+ name: COMPONENT_NAME$$,
7974
8371
  props: props$R,
7975
8372
  setup(props2, { slots, expose }) {
7976
8373
  useForm(expose, {
@@ -7990,17 +8387,17 @@
7990
8387
  };
7991
8388
  }
7992
8389
  });
7993
- const props$O = {
8390
+ const props$P = {
7994
8391
  ...props$S,
7995
8392
  indent: {
7996
8393
  type: Number,
7997
8394
  default: 12
7998
8395
  }
7999
8396
  };
8000
- const COMPONENT_NAME$Y = "vcm-form-item";
8397
+ const COMPONENT_NAME$_ = "vcm-form-item";
8001
8398
  const MFormItem = /* @__PURE__ */ vue.defineComponent({
8002
- name: COMPONENT_NAME$Y,
8003
- props: props$O,
8399
+ name: COMPONENT_NAME$_,
8400
+ props: props$P,
8004
8401
  setup(props2, {
8005
8402
  slots,
8006
8403
  expose
@@ -8052,24 +8449,24 @@
8052
8449
  };
8053
8450
  }
8054
8451
  });
8055
- const COMPONENT_NAME$X = "vc-fragment";
8452
+ const COMPONENT_NAME$Z = "vc-fragment";
8056
8453
  const Fragment = vue.defineComponent({
8057
- name: COMPONENT_NAME$X,
8454
+ name: COMPONENT_NAME$Z,
8058
8455
  setup(_, { slots }) {
8059
8456
  return () => vue.h(vue.Fragment, slots.default?.());
8060
8457
  }
8061
8458
  });
8062
8459
  const MFragment = Fragment;
8063
- const props$N = {
8460
+ const props$O = {
8064
8461
  tag: {
8065
8462
  type: String,
8066
8463
  default: "div"
8067
8464
  }
8068
8465
  };
8069
- const COMPONENT_NAME$W = "vc-html-to-image";
8466
+ const COMPONENT_NAME$Y = "vc-html-to-image";
8070
8467
  const HTMLToImage = /* @__PURE__ */ vue.defineComponent({
8071
- name: COMPONENT_NAME$W,
8072
- props: props$N,
8468
+ name: COMPONENT_NAME$Y,
8469
+ props: props$O,
8073
8470
  setup(props2, {
8074
8471
  slots
8075
8472
  }) {
@@ -8082,7 +8479,7 @@
8082
8479
  });
8083
8480
  const MHTMLToImage = HTMLToImage;
8084
8481
  const MIcon = Icon;
8085
- const props$M = {
8482
+ const props$N = {
8086
8483
  src: String,
8087
8484
  fit: String,
8088
8485
  lazy: Boolean,
@@ -8137,7 +8534,7 @@
8137
8534
  }
8138
8535
  }
8139
8536
  const IMGStore$1 = new IMGStore();
8140
- const COMPONENT_NAME$V = "vc-image";
8537
+ const COMPONENT_NAME$X = "vc-image";
8141
8538
  let isSupportObjectFit = false;
8142
8539
  window.addEventListener("DOMContentLoaded", () => {
8143
8540
  isSupportObjectFit = !IS_SERVER$3 && document.documentElement.style.objectFit !== void 0;
@@ -8150,9 +8547,9 @@
8150
8547
  SCALE_DOWN: "scale-down"
8151
8548
  };
8152
8549
  const Image$1 = /* @__PURE__ */ vue.defineComponent({
8153
- name: COMPONENT_NAME$V,
8550
+ name: COMPONENT_NAME$X,
8154
8551
  inheritAttrs: false,
8155
- props: props$M,
8552
+ props: props$N,
8156
8553
  setup(props2, {
8157
8554
  slots,
8158
8555
  emit
@@ -8339,16 +8736,16 @@
8339
8736
  }
8340
8737
  });
8341
8738
  const MImage = Image$1;
8342
- const props$L = {
8739
+ const props$M = {
8343
8740
  tag: {
8344
8741
  type: String,
8345
8742
  default: "div"
8346
8743
  }
8347
8744
  };
8348
- const COMPONENT_NAME$U = "vc-image-crop";
8745
+ const COMPONENT_NAME$W = "vc-image-crop";
8349
8746
  const ImageCrop = /* @__PURE__ */ vue.defineComponent({
8350
- name: COMPONENT_NAME$U,
8351
- props: props$L,
8747
+ name: COMPONENT_NAME$W,
8748
+ props: props$M,
8352
8749
  setup(props2, {
8353
8750
  slots
8354
8751
  }) {
@@ -8360,16 +8757,16 @@
8360
8757
  }
8361
8758
  });
8362
8759
  const MImageCrop = ImageCrop;
8363
- const props$K = {
8760
+ const props$L = {
8364
8761
  tag: {
8365
8762
  type: String,
8366
8763
  default: "div"
8367
8764
  }
8368
8765
  };
8369
- const COMPONENT_NAME$T = "vc-image-preview";
8766
+ const COMPONENT_NAME$V = "vc-image-preview";
8370
8767
  const ImagePreview = /* @__PURE__ */ vue.defineComponent({
8371
- name: COMPONENT_NAME$T,
8372
- props: props$K,
8768
+ name: COMPONENT_NAME$V,
8769
+ props: props$L,
8373
8770
  setup(props2, {
8374
8771
  slots
8375
8772
  }) {
@@ -8381,16 +8778,16 @@
8381
8778
  }
8382
8779
  });
8383
8780
  const MImagePreview = ImagePreview;
8384
- const props$J = {
8781
+ const props$K = {
8385
8782
  tag: {
8386
8783
  type: String,
8387
8784
  default: "div"
8388
8785
  }
8389
8786
  };
8390
- const COMPONENT_NAME$S = "vc-image-processing";
8787
+ const COMPONENT_NAME$U = "vc-image-processing";
8391
8788
  const ImageProcessing = /* @__PURE__ */ vue.defineComponent({
8392
- name: COMPONENT_NAME$S,
8393
- props: props$J,
8789
+ name: COMPONENT_NAME$U,
8790
+ props: props$K,
8394
8791
  setup(props2, {
8395
8792
  slots
8396
8793
  }) {
@@ -8402,7 +8799,7 @@
8402
8799
  }
8403
8800
  });
8404
8801
  const MImageProcessing = ImageProcessing;
8405
- const props$I = {
8802
+ const props$J = {
8406
8803
  // Array, 作为select等数组存放临时值
8407
8804
  modelValue: {
8408
8805
  type: [String, Number, Array],
@@ -8499,7 +8896,7 @@
8499
8896
  const isFocus = vue.ref(false);
8500
8897
  const isClearing = vue.ref(false);
8501
8898
  const isOnComposition = vue.ref(false);
8502
- const formItem = vue.inject("form-item", {});
8899
+ const formItem = vue.inject("vc-form-item", {});
8503
8900
  vue.watch(
8504
8901
  () => props2.modelValue,
8505
8902
  (v) => {
@@ -8650,12 +9047,12 @@
8650
9047
  expose?.(exposed);
8651
9048
  return exposed;
8652
9049
  };
8653
- const COMPONENT_NAME$R = "vc-input";
9050
+ const COMPONENT_NAME$T = "vc-input";
8654
9051
  const Input = /* @__PURE__ */ vue.defineComponent({
8655
- name: COMPONENT_NAME$R,
9052
+ name: COMPONENT_NAME$T,
8656
9053
  inheritAttrs: false,
8657
9054
  props: {
8658
- ...props$I,
9055
+ ...props$J,
8659
9056
  indicator: {
8660
9057
  type: [Boolean, Object],
8661
9058
  default: false
@@ -8756,8 +9153,8 @@
8756
9153
  };
8757
9154
  }
8758
9155
  });
8759
- const props$H = {
8760
- ...props$I,
9156
+ const props$I = {
9157
+ ...props$J,
8761
9158
  min: {
8762
9159
  type: Number,
8763
9160
  default: 0
@@ -8968,10 +9365,10 @@
8968
9365
  handleStepper
8969
9366
  };
8970
9367
  };
8971
- const COMPONENT_NAME$Q = "vc-input-number";
9368
+ const COMPONENT_NAME$S = "vc-input-number";
8972
9369
  const InputNumber = /* @__PURE__ */ vue.defineComponent({
8973
- name: COMPONENT_NAME$Q,
8974
- props: props$H,
9370
+ name: COMPONENT_NAME$S,
9371
+ props: props$I,
8975
9372
  inheritAttrs: false,
8976
9373
  setup(props2, {
8977
9374
  slots,
@@ -9021,17 +9418,17 @@
9021
9418
  };
9022
9419
  }
9023
9420
  });
9024
- const props$G = {
9025
- ...props$I,
9421
+ const props$H = {
9422
+ ...props$J,
9026
9423
  enterText: {
9027
9424
  type: [Boolean, String],
9028
9425
  default: true
9029
9426
  }
9030
9427
  };
9031
- const COMPONENT_NAME$P = "vc-input-search";
9428
+ const COMPONENT_NAME$R = "vc-input-search";
9032
9429
  const InputSearch = /* @__PURE__ */ vue.defineComponent({
9033
- name: COMPONENT_NAME$P,
9034
- props: props$G,
9430
+ name: COMPONENT_NAME$R,
9431
+ props: props$H,
9035
9432
  inheritAttrs: false,
9036
9433
  setup(props2, {
9037
9434
  emit,
@@ -9062,12 +9459,12 @@
9062
9459
  };
9063
9460
  }
9064
9461
  });
9065
- const COMPONENT_NAME$O = "vcm-input";
9462
+ const COMPONENT_NAME$Q = "vcm-input";
9066
9463
  const MInput = /* @__PURE__ */ vue.defineComponent({
9067
- name: COMPONENT_NAME$O,
9464
+ name: COMPONENT_NAME$Q,
9068
9465
  inheritAttrs: false,
9069
9466
  props: {
9070
- ...props$I,
9467
+ ...props$J,
9071
9468
  right: {
9072
9469
  type: Boolean,
9073
9470
  default: false
@@ -9151,10 +9548,10 @@
9151
9548
  };
9152
9549
  }
9153
9550
  });
9154
- const COMPONENT_NAME$N = "vcm-input-number";
9551
+ const COMPONENT_NAME$P = "vcm-input-number";
9155
9552
  const MInputNumber = /* @__PURE__ */ vue.defineComponent({
9156
- name: COMPONENT_NAME$N,
9157
- props: props$H,
9553
+ name: COMPONENT_NAME$P,
9554
+ props: props$I,
9158
9555
  inheritAttrs: false,
9159
9556
  setup(props2, {
9160
9557
  slots,
@@ -9199,11 +9596,11 @@
9199
9596
  };
9200
9597
  }
9201
9598
  });
9202
- const COMPONENT_NAME$M = "vcm-input-search";
9599
+ const COMPONENT_NAME$O = "vcm-input-search";
9203
9600
  const MInputSearch = /* @__PURE__ */ vue.defineComponent({
9204
- name: COMPONENT_NAME$M,
9601
+ name: COMPONENT_NAME$O,
9205
9602
  props: {
9206
- ...props$G,
9603
+ ...props$H,
9207
9604
  cancelText: {
9208
9605
  type: String,
9209
9606
  default: "取消"
@@ -9261,7 +9658,7 @@
9261
9658
  };
9262
9659
  }
9263
9660
  });
9264
- const props$F = {
9661
+ const props$G = {
9265
9662
  tag: {
9266
9663
  type: String,
9267
9664
  default: "div"
@@ -9275,12 +9672,12 @@
9275
9672
  default: true
9276
9673
  }
9277
9674
  };
9278
- const COMPONENT_NAME$L = "vcm-list";
9675
+ const COMPONENT_NAME$N = "vcm-list";
9279
9676
  const MList = vue.defineComponent({
9280
- name: COMPONENT_NAME$L,
9281
- props: props$F,
9677
+ name: COMPONENT_NAME$N,
9678
+ props: props$G,
9282
9679
  setup(props2, { slots }) {
9283
- vue.provide("list", { props: props2 });
9680
+ vue.provide("vc-list", { props: props2 });
9284
9681
  return () => {
9285
9682
  return vue.h(
9286
9683
  props2.tag,
@@ -9297,7 +9694,7 @@
9297
9694
  };
9298
9695
  }
9299
9696
  });
9300
- const props$E = {
9697
+ const props$F = {
9301
9698
  tag: {
9302
9699
  type: String,
9303
9700
  default: "div"
@@ -9328,17 +9725,17 @@
9328
9725
  // MListItem是否独立存在
9329
9726
  alone: Boolean
9330
9727
  };
9331
- const COMPONENT_NAME$K = "vcm-list-item";
9728
+ const COMPONENT_NAME$M = "vcm-list-item";
9332
9729
  const HTTP_REGEX = /[a-zA-z]+:\/\/[^\s]*/;
9333
9730
  const MListItem = /* @__PURE__ */ vue.defineComponent({
9334
- name: COMPONENT_NAME$K,
9335
- props: props$E,
9731
+ name: COMPONENT_NAME$M,
9732
+ props: props$F,
9336
9733
  emits: ["click"],
9337
9734
  setup(props2, {
9338
9735
  slots,
9339
9736
  emit
9340
9737
  }) {
9341
- const list = vue.inject("list", {});
9738
+ const list = vue.inject("vc-list", {});
9342
9739
  const classes = vue.computed(() => {
9343
9740
  const hasList = !!list.props;
9344
9741
  return {
@@ -9399,16 +9796,16 @@
9399
9796
  };
9400
9797
  }
9401
9798
  });
9402
- const props$D = {
9799
+ const props$E = {
9403
9800
  tag: {
9404
9801
  type: String,
9405
9802
  default: "div"
9406
9803
  }
9407
9804
  };
9408
- const COMPONENT_NAME$J = "vc-marquee";
9805
+ const COMPONENT_NAME$L = "vc-marquee";
9409
9806
  const Marquee = /* @__PURE__ */ vue.defineComponent({
9410
- name: COMPONENT_NAME$J,
9411
- props: props$D,
9807
+ name: COMPONENT_NAME$L,
9808
+ props: props$E,
9412
9809
  setup(props2, {
9413
9810
  slots
9414
9811
  }) {
@@ -9420,7 +9817,7 @@
9420
9817
  }
9421
9818
  });
9422
9819
  const MMarquee = Marquee;
9423
- const props$C = {
9820
+ const props$D = {
9424
9821
  content: [String, Function],
9425
9822
  mask: {
9426
9823
  type: Boolean,
@@ -9455,11 +9852,11 @@
9455
9852
  // 这个相当于Modal中的onCancel,支持Promise
9456
9853
  onBeforeClose: Function
9457
9854
  };
9458
- const COMPONENT_NAME$I = "vc-message";
9855
+ const COMPONENT_NAME$K = "vc-message";
9459
9856
  const MessageView = /* @__PURE__ */ vue.defineComponent({
9460
- name: COMPONENT_NAME$I,
9857
+ name: COMPONENT_NAME$K,
9461
9858
  emits: ["before-close", "close", "portal-fulfilled"],
9462
- props: props$C,
9859
+ props: props$D,
9463
9860
  setup(props2, {
9464
9861
  emit,
9465
9862
  expose
@@ -9467,6 +9864,12 @@
9467
9864
  const instance = vue.getCurrentInstance();
9468
9865
  const isActive = vue.ref(false);
9469
9866
  const currentContent = vue.ref();
9867
+ let timer;
9868
+ const setDuration = (v) => {
9869
+ timer && clearTimeout(timer);
9870
+ if (v === 0) return;
9871
+ timer = setTimeout(() => isActive.value = false, v);
9872
+ };
9470
9873
  const setContent = (v) => {
9471
9874
  currentContent.value = v;
9472
9875
  };
@@ -9491,12 +9894,9 @@
9491
9894
  vue.watch(() => props2.content, setContent, {
9492
9895
  immediate: true
9493
9896
  });
9494
- let timer;
9495
9897
  vue.onMounted(() => {
9496
9898
  isActive.value = true;
9497
- if (props2.duration !== 0) {
9498
- timer = setTimeout(() => isActive.value = false, props2.duration);
9499
- }
9899
+ setDuration(props2.duration);
9500
9900
  });
9501
9901
  vue.onUnmounted(() => {
9502
9902
  timer && clearTimeout(timer);
@@ -9505,7 +9905,8 @@
9505
9905
  pre[key] = handleRemove;
9506
9906
  return pre;
9507
9907
  }, {
9508
- setContent
9908
+ setContent,
9909
+ setDuration
9509
9910
  });
9510
9911
  expose(exposes);
9511
9912
  return () => {
@@ -9515,7 +9916,7 @@
9515
9916
  "class": "vc-message__mask",
9516
9917
  "onClick": (e) => handleClose(e, props2.maskClosable)
9517
9918
  }, null), vue.createVNode(TransitionSlide, {
9518
- "mode": "up",
9919
+ "mode": "bottom",
9519
9920
  "onAfterLeave": handleRemove
9520
9921
  }, {
9521
9922
  default: () => [vue.withDirectives(vue.createVNode("div", {
@@ -9591,7 +9992,7 @@
9591
9992
  warning: warning$2
9592
9993
  }, Symbol.toStringTag, { value: "Module" }));
9593
9994
  const MMessage = Message$1;
9594
- const props$B = {
9995
+ const props$C = {
9595
9996
  modelValue: {
9596
9997
  type: Boolean,
9597
9998
  default: false
@@ -9668,12 +10069,12 @@
9668
10069
  type: Function
9669
10070
  }
9670
10071
  };
9671
- const COMPONENT_NAME$H = "vc-modal";
10072
+ const COMPONENT_NAME$J = "vc-modal";
9672
10073
  let zIndexNumber = 1002;
9673
10074
  const ModalView = /* @__PURE__ */ vue.defineComponent({
9674
- name: COMPONENT_NAME$H,
10075
+ name: COMPONENT_NAME$J,
9675
10076
  emits: ["update:modelValue", "close", "portal-fulfilled", "visible-change", "ok", "cancel"],
9676
- props: props$B,
10077
+ props: props$C,
9677
10078
  setup(props2, {
9678
10079
  slots,
9679
10080
  emit,
@@ -9861,6 +10262,10 @@
9861
10262
  expose({
9862
10263
  isActive,
9863
10264
  // for portal
10265
+ toggle(v) {
10266
+ v = typeof v === "boolean" ? v : !isActive.value;
10267
+ isActive.value = v;
10268
+ },
9864
10269
  resetOrigin
9865
10270
  });
9866
10271
  return () => {
@@ -9950,7 +10355,7 @@
9950
10355
  // 当组件内使用emit('close'),避免重复触发
9951
10356
  onClose: null
9952
10357
  });
9953
- leaf.wrapper.isActive = true;
10358
+ leaf.wrapper.toggle?.(true);
9954
10359
  return leaf;
9955
10360
  };
9956
10361
  const destroy$2 = () => Modal.destroy();
@@ -9966,7 +10371,7 @@
9966
10371
  success: success$1,
9967
10372
  warning: warning$1
9968
10373
  }, Symbol.toStringTag, { value: "Module" }));
9969
- const props$A = {
10374
+ const props$B = {
9970
10375
  mode: {
9971
10376
  type: String,
9972
10377
  validator: (v) => /(alert|operation)/.test(v),
@@ -10025,11 +10430,11 @@
10025
10430
  type: Function
10026
10431
  }
10027
10432
  };
10028
- const COMPONENT_NAME$G = "vc-modal";
10433
+ const COMPONENT_NAME$I = "vc-modal";
10029
10434
  const MModalView = /* @__PURE__ */ vue.defineComponent({
10030
- name: COMPONENT_NAME$G,
10435
+ name: COMPONENT_NAME$I,
10031
10436
  emits: ["update:modelValue", "portal-fulfilled", "close", "ok", "cancel"],
10032
- props: props$A,
10437
+ props: props$B,
10033
10438
  setup(props2, {
10034
10439
  slots,
10035
10440
  emit,
@@ -10189,7 +10594,7 @@
10189
10594
  destroy: destroy$1,
10190
10595
  operation
10191
10596
  }, Symbol.toStringTag, { value: "Module" }));
10192
- const props$z = {
10597
+ const props$A = {
10193
10598
  title: [String, Function],
10194
10599
  content: [String, Function],
10195
10600
  // 单位ms
@@ -10216,40 +10621,31 @@
10216
10621
  // 这个相当于Modal中的onCancel,支持Promise
10217
10622
  onBeforeClose: Function
10218
10623
  };
10219
- const COMPONENT_NAME$F = "vc-notice";
10624
+ const COMPONENT_NAME$H = "vc-notice";
10220
10625
  const NoticeView = /* @__PURE__ */ vue.defineComponent({
10221
- name: COMPONENT_NAME$F,
10222
- props: props$z,
10626
+ name: COMPONENT_NAME$H,
10627
+ props: props$A,
10223
10628
  emits: ["portal-fulfilled", "close", "before-close"],
10224
10629
  setup(props2, {
10225
- emit
10630
+ emit,
10631
+ expose
10226
10632
  }) {
10227
10633
  const instance = vue.getCurrentInstance();
10228
10634
  const isActive = vue.ref(false);
10229
10635
  const currentTitle = vue.ref();
10230
10636
  const currentContent = vue.ref();
10637
+ let timer;
10638
+ const setDuration = (v) => {
10639
+ timer && clearTimeout(timer);
10640
+ if (v === 0) return;
10641
+ timer = setTimeout(() => isActive.value = false, v);
10642
+ };
10231
10643
  const setTitle = (v) => {
10232
10644
  currentTitle.value = v;
10233
10645
  };
10234
10646
  const setContent = (v) => {
10235
10647
  currentContent.value = v;
10236
10648
  };
10237
- vue.watch(() => props2.title, setTitle, {
10238
- immediate: true
10239
- });
10240
- vue.watch(() => props2.content, setContent, {
10241
- immediate: true
10242
- });
10243
- let timer;
10244
- vue.onMounted(() => {
10245
- isActive.value = true;
10246
- if (props2.duration !== 0) {
10247
- timer = setTimeout(() => isActive.value = false, props2.duration);
10248
- }
10249
- });
10250
- vue.onUnmounted(() => {
10251
- timer && clearTimeout(timer);
10252
- });
10253
10649
  const handleRemove = () => {
10254
10650
  emit("close");
10255
10651
  emit("portal-fulfilled");
@@ -10268,6 +10664,27 @@
10268
10664
  isActive.value = false;
10269
10665
  }
10270
10666
  };
10667
+ vue.watch(() => props2.title, setTitle, {
10668
+ immediate: true
10669
+ });
10670
+ vue.watch(() => props2.content, setContent, {
10671
+ immediate: true
10672
+ });
10673
+ vue.onMounted(() => {
10674
+ isActive.value = true;
10675
+ setDuration(props2.duration);
10676
+ });
10677
+ vue.onUnmounted(() => {
10678
+ timer && clearTimeout(timer);
10679
+ });
10680
+ const exposes = ["destroy", "remove", "close", "hide"].reduce((pre, key) => {
10681
+ pre[key] = handleRemove;
10682
+ return pre;
10683
+ }, {
10684
+ setContent,
10685
+ setDuration
10686
+ });
10687
+ expose(exposes);
10271
10688
  return () => {
10272
10689
  return vue.createVNode("div", {
10273
10690
  "class": ["vc-notice", {
@@ -10374,16 +10791,16 @@
10374
10791
  warning
10375
10792
  }, Symbol.toStringTag, { value: "Module" }));
10376
10793
  const MNotice = Notice$1;
10377
- const props$y = {
10794
+ const props$z = {
10378
10795
  tag: {
10379
10796
  type: String,
10380
10797
  default: "div"
10381
10798
  }
10382
10799
  };
10383
- const COMPONENT_NAME$E = "vc-option";
10800
+ const COMPONENT_NAME$G = "vc-option";
10384
10801
  const Option = /* @__PURE__ */ vue.defineComponent({
10385
- name: COMPONENT_NAME$E,
10386
- props: props$y,
10802
+ name: COMPONENT_NAME$G,
10803
+ props: props$z,
10387
10804
  setup(props2, {
10388
10805
  slots
10389
10806
  }) {
@@ -10395,16 +10812,16 @@
10395
10812
  }
10396
10813
  });
10397
10814
  const MOption = Option;
10398
- const props$x = {
10815
+ const props$y = {
10399
10816
  tag: {
10400
10817
  type: String,
10401
10818
  default: "div"
10402
10819
  }
10403
10820
  };
10404
- const COMPONENT_NAME$D = "vc-page";
10821
+ const COMPONENT_NAME$F = "vc-page";
10405
10822
  const Page = /* @__PURE__ */ vue.defineComponent({
10406
- name: COMPONENT_NAME$D,
10407
- props: props$x,
10823
+ name: COMPONENT_NAME$F,
10824
+ props: props$y,
10408
10825
  setup(props2, {
10409
10826
  slots
10410
10827
  }) {
@@ -10416,16 +10833,16 @@
10416
10833
  }
10417
10834
  });
10418
10835
  const MPage = Page;
10419
- const props$w = {
10836
+ const props$x = {
10420
10837
  tag: {
10421
10838
  type: String,
10422
10839
  default: "div"
10423
10840
  }
10424
10841
  };
10425
- const COMPONENT_NAME$C = "vc-picker";
10842
+ const COMPONENT_NAME$E = "vc-picker";
10426
10843
  const Picker = /* @__PURE__ */ vue.defineComponent({
10427
- name: COMPONENT_NAME$C,
10428
- props: props$w,
10844
+ name: COMPONENT_NAME$E,
10845
+ props: props$x,
10429
10846
  setup(props2, {
10430
10847
  slots
10431
10848
  }) {
@@ -10437,16 +10854,16 @@
10437
10854
  }
10438
10855
  });
10439
10856
  const MPicker = Picker;
10440
- const props$v = {
10857
+ const props$w = {
10441
10858
  tag: {
10442
10859
  type: String,
10443
10860
  default: "div"
10444
10861
  }
10445
10862
  };
10446
- const COMPONENT_NAME$B = "vc-popconfirm";
10863
+ const COMPONENT_NAME$D = "vc-popconfirm";
10447
10864
  const Popconfirm = /* @__PURE__ */ vue.defineComponent({
10448
- name: COMPONENT_NAME$B,
10449
- props: props$v,
10865
+ name: COMPONENT_NAME$D,
10866
+ props: props$w,
10450
10867
  setup(props2, {
10451
10868
  slots
10452
10869
  }) {
@@ -10458,7 +10875,7 @@
10458
10875
  }
10459
10876
  });
10460
10877
  const MPopconfirm = Popconfirm;
10461
- const props$u = {
10878
+ const props$v = {
10462
10879
  modelValue: Boolean,
10463
10880
  animation: String,
10464
10881
  placement: {
@@ -10536,7 +10953,7 @@
10536
10953
  "autoWidth",
10537
10954
  "always"
10538
10955
  ];
10539
- const props$t = {
10956
+ const props$u = {
10540
10957
  trigger: {
10541
10958
  type: String,
10542
10959
  default: "hover",
@@ -10554,7 +10971,7 @@
10554
10971
  type: Boolean,
10555
10972
  default: true
10556
10973
  },
10557
- ...pick(props$u, wrapperKeys)
10974
+ ...pick(props$v, wrapperKeys)
10558
10975
  };
10559
10976
  const EXTRA_DISTANCE = 4;
10560
10977
  const HALF_ARROW = 12.73 / 2;
@@ -10811,10 +11228,10 @@
10811
11228
  function _isSlot(s) {
10812
11229
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !vue.isVNode(s);
10813
11230
  }
10814
- const COMPONENT_NAME$A = "vc-popover-wrapper";
11231
+ const COMPONENT_NAME$C = "vc-popover-wrapper";
10815
11232
  const PopoverWrapper = /* @__PURE__ */ vue.defineComponent({
10816
- name: COMPONENT_NAME$A,
10817
- props: props$u,
11233
+ name: COMPONENT_NAME$C,
11234
+ props: props$v,
10818
11235
  emits: ["portal-fulfilled", "close"],
10819
11236
  setup(props2, {
10820
11237
  emit,
@@ -10993,7 +11410,11 @@
10993
11410
  props2.alone && props2.hover && removeEvents();
10994
11411
  });
10995
11412
  expose({
10996
- isActive
11413
+ isActive,
11414
+ toggle(v) {
11415
+ v = typeof v === "boolean" ? v : !isActive.value;
11416
+ isActive.value = v;
11417
+ }
10997
11418
  });
10998
11419
  return () => {
10999
11420
  let _slot;
@@ -11030,10 +11451,10 @@
11030
11451
  }
11031
11452
  });
11032
11453
  const PopoverPortal = new Portal(PopoverWrapper);
11033
- const COMPONENT_NAME$z = "vc-popover";
11454
+ const COMPONENT_NAME$B = "vc-popover";
11034
11455
  const Popover = /* @__PURE__ */ vue.defineComponent({
11035
- name: COMPONENT_NAME$z,
11036
- props: props$t,
11456
+ name: COMPONENT_NAME$B,
11457
+ props: props$u,
11037
11458
  emits: ["update:modelValue", "visible-change", "ready", "close"],
11038
11459
  open: PopoverPortal.popup.bind(PopoverPortal),
11039
11460
  setup(props2, {
@@ -11115,7 +11536,7 @@
11115
11536
  portalClass
11116
11537
  });
11117
11538
  } else if (popperInstance && popperInstance.wrapper) {
11118
- popperInstance.wrapper.isActive = false;
11539
+ popperInstance.wrapper.toggle(false);
11119
11540
  }
11120
11541
  };
11121
11542
  vue.watch(() => props2.modelValue, (v) => {
@@ -11156,16 +11577,16 @@
11156
11577
  }
11157
11578
  });
11158
11579
  const MPopover = Popover;
11159
- const props$s = {
11580
+ const props$t = {
11160
11581
  tag: {
11161
11582
  type: String,
11162
11583
  default: "div"
11163
11584
  }
11164
11585
  };
11165
- const COMPONENT_NAME$y = "vc-popup";
11586
+ const COMPONENT_NAME$A = "vc-popup";
11166
11587
  const Popup = /* @__PURE__ */ vue.defineComponent({
11167
- name: COMPONENT_NAME$y,
11168
- props: props$s,
11588
+ name: COMPONENT_NAME$A,
11589
+ props: props$t,
11169
11590
  setup(props2, {
11170
11591
  slots
11171
11592
  }) {
@@ -11178,16 +11599,16 @@
11178
11599
  });
11179
11600
  const MPopup = Popup;
11180
11601
  const MPortal = Portal;
11181
- const props$r = {
11602
+ const props$s = {
11182
11603
  tag: {
11183
11604
  type: String,
11184
11605
  default: "div"
11185
11606
  }
11186
11607
  };
11187
- const COMPONENT_NAME$x = "vc-print";
11608
+ const COMPONENT_NAME$z = "vc-print";
11188
11609
  const Print = /* @__PURE__ */ vue.defineComponent({
11189
- name: COMPONENT_NAME$x,
11190
- props: props$r,
11610
+ name: COMPONENT_NAME$z,
11611
+ props: props$s,
11191
11612
  setup(props2, {
11192
11613
  slots
11193
11614
  }) {
@@ -11199,16 +11620,16 @@
11199
11620
  }
11200
11621
  });
11201
11622
  const MPrint = Print;
11202
- const props$q = {
11623
+ const props$r = {
11203
11624
  tag: {
11204
11625
  type: String,
11205
11626
  default: "div"
11206
11627
  }
11207
11628
  };
11208
- const COMPONENT_NAME$w = "vc-progress";
11629
+ const COMPONENT_NAME$y = "vc-progress";
11209
11630
  const Progress = /* @__PURE__ */ vue.defineComponent({
11210
- name: COMPONENT_NAME$w,
11211
- props: props$q,
11631
+ name: COMPONENT_NAME$y,
11632
+ props: props$r,
11212
11633
  setup(props2, {
11213
11634
  slots
11214
11635
  }) {
@@ -11220,16 +11641,16 @@
11220
11641
  }
11221
11642
  });
11222
11643
  const MProgress = Progress;
11223
- const props$p = {
11644
+ const props$q = {
11224
11645
  tag: {
11225
11646
  type: String,
11226
11647
  default: "div"
11227
11648
  }
11228
11649
  };
11229
- const COMPONENT_NAME$v = "vc-radio";
11650
+ const COMPONENT_NAME$x = "vc-radio";
11230
11651
  const Radio = /* @__PURE__ */ vue.defineComponent({
11231
- name: COMPONENT_NAME$v,
11232
- props: props$p,
11652
+ name: COMPONENT_NAME$x,
11653
+ props: props$q,
11233
11654
  setup(props2, {
11234
11655
  slots
11235
11656
  }) {
@@ -11241,16 +11662,16 @@
11241
11662
  }
11242
11663
  });
11243
11664
  const MRadio = Radio;
11244
- const props$o = {
11665
+ const props$p = {
11245
11666
  tag: {
11246
11667
  type: String,
11247
11668
  default: "div"
11248
11669
  }
11249
11670
  };
11250
- const COMPONENT_NAME$u = "vc-rate";
11671
+ const COMPONENT_NAME$w = "vc-rate";
11251
11672
  const Rate = /* @__PURE__ */ vue.defineComponent({
11252
- name: COMPONENT_NAME$u,
11253
- props: props$o,
11673
+ name: COMPONENT_NAME$w,
11674
+ props: props$p,
11254
11675
  setup(props2, {
11255
11676
  slots
11256
11677
  }) {
@@ -11262,7 +11683,7 @@
11262
11683
  }
11263
11684
  });
11264
11685
  const MRate = Rate;
11265
- const props$n = {
11686
+ const props$o = {
11266
11687
  data: {
11267
11688
  type: Array,
11268
11689
  default: () => []
@@ -11312,7 +11733,7 @@
11312
11733
  renderPlaceholder: Function,
11313
11734
  renderRefresh: Function
11314
11735
  };
11315
- const props$m = {
11736
+ const props$n = {
11316
11737
  vertical: Boolean,
11317
11738
  wrapperSize: {
11318
11739
  type: Number,
@@ -11365,7 +11786,7 @@
11365
11786
  "thumbStyle",
11366
11787
  "thumbClass"
11367
11788
  ];
11368
- const props$l = {
11789
+ const props$m = {
11369
11790
  // 如果存在滚动条宽度为false, 不存在则为true
11370
11791
  // 为false的情况下才能使用track-offset
11371
11792
  native: {
@@ -11396,7 +11817,7 @@
11396
11817
  scrollX: Number,
11397
11818
  scrollY: Number,
11398
11819
  fit: Boolean,
11399
- ...pick(props$m, barKeys$1)
11820
+ ...pick(props$n, barKeys$1)
11400
11821
  };
11401
11822
  const barKeys = [
11402
11823
  "always",
@@ -11410,7 +11831,7 @@
11410
11831
  "autoResize",
11411
11832
  "native"
11412
11833
  ];
11413
- const props$k = {
11834
+ const props$l = {
11414
11835
  tag: {
11415
11836
  type: String,
11416
11837
  default: "div"
@@ -11443,10 +11864,10 @@
11443
11864
  type: Boolean,
11444
11865
  default: true
11445
11866
  },
11446
- barTo: props$l.to,
11447
- ...pick(props$l, barKeys)
11867
+ barTo: props$m.to,
11868
+ ...pick(props$m, barKeys)
11448
11869
  };
11449
- const COMPONENT_NAME$t = "vc-scroller-track";
11870
+ const COMPONENT_NAME$v = "vc-scroller-track";
11450
11871
  const BAR_MAP = {
11451
11872
  vertical: {
11452
11873
  scroll: "scrollTop",
@@ -11466,8 +11887,8 @@
11466
11887
  }
11467
11888
  };
11468
11889
  const Track$1 = /* @__PURE__ */ vue.defineComponent({
11469
- name: COMPONENT_NAME$t,
11470
- props: props$m,
11890
+ name: COMPONENT_NAME$v,
11891
+ props: props$n,
11471
11892
  emits: ["change"],
11472
11893
  setup(props2, {
11473
11894
  emit,
@@ -11624,10 +12045,10 @@
11624
12045
  };
11625
12046
  }
11626
12047
  });
11627
- const COMPONENT_NAME$s = "vc-scroller-bar";
12048
+ const COMPONENT_NAME$u = "vc-scroller-bar";
11628
12049
  const Bar = /* @__PURE__ */ vue.defineComponent({
11629
- name: COMPONENT_NAME$s,
11630
- props: props$l,
12050
+ name: COMPONENT_NAME$u,
12051
+ props: props$m,
11631
12052
  emits: ["change"],
11632
12053
  setup(props2, {
11633
12054
  emit,
@@ -11836,10 +12257,10 @@
11836
12257
  refreshPosition
11837
12258
  };
11838
12259
  };
11839
- const COMPONENT_NAME$r = "vc-scroller";
12260
+ const COMPONENT_NAME$t = "vc-scroller";
11840
12261
  const Scroller = /* @__PURE__ */ vue.defineComponent({
11841
- name: COMPONENT_NAME$r,
11842
- props: props$k,
12262
+ name: COMPONENT_NAME$t,
12263
+ props: props$l,
11843
12264
  emits: ["scroll"],
11844
12265
  setup(props2, {
11845
12266
  slots,
@@ -11896,10 +12317,10 @@
11896
12317
  };
11897
12318
  }
11898
12319
  });
11899
- const COMPONENT_NAME$q = "vc-scroller-wheel";
12320
+ const COMPONENT_NAME$s = "vc-scroller-wheel";
11900
12321
  const ScrollerWheel = /* @__PURE__ */ vue.defineComponent({
11901
- name: COMPONENT_NAME$q,
11902
- props: props$k,
12322
+ name: COMPONENT_NAME$s,
12323
+ props: props$l,
11903
12324
  emits: ["scroll"],
11904
12325
  setup(props2, {
11905
12326
  slots,
@@ -11996,9 +12417,9 @@
11996
12417
  };
11997
12418
  }
11998
12419
  });
11999
- const COMPONENT_NAME$p = "vc-recycle-list-scroll-state";
12420
+ const COMPONENT_NAME$r = "vc-recycle-list-scroll-state";
12000
12421
  const ScrollState = /* @__PURE__ */ vue.defineComponent({
12001
- name: COMPONENT_NAME$p,
12422
+ name: COMPONENT_NAME$r,
12002
12423
  setup(_, {
12003
12424
  slots
12004
12425
  }) {
@@ -12067,7 +12488,7 @@
12067
12488
  [REFRESH]: "加载中..."
12068
12489
  }
12069
12490
  };
12070
- const props$j = {
12491
+ const props$k = {
12071
12492
  inverted: {
12072
12493
  type: Boolean,
12073
12494
  default: false
@@ -12122,11 +12543,11 @@
12122
12543
  );
12123
12544
  return keys;
12124
12545
  };
12125
- const COMPONENT_NAME$o = "vc-recycle-list-container";
12546
+ const COMPONENT_NAME$q = "vc-recycle-list-container";
12126
12547
  const transformKey = prefixStyle("transform").camel;
12127
12548
  const Container = /* @__PURE__ */ vue.defineComponent({
12128
- name: COMPONENT_NAME$o,
12129
- props: props$j,
12549
+ name: COMPONENT_NAME$q,
12550
+ props: props$k,
12130
12551
  emits: ["refresh"],
12131
12552
  setup(props2, {
12132
12553
  slots
@@ -12218,16 +12639,16 @@
12218
12639
  };
12219
12640
  }
12220
12641
  });
12221
- const COMPONENT_NAME$n = "vc-recycle-list-item";
12642
+ const COMPONENT_NAME$p = "vc-recycle-list-item";
12222
12643
  const Item = /* @__PURE__ */ vue.defineComponent({
12223
- name: COMPONENT_NAME$n,
12644
+ name: COMPONENT_NAME$p,
12224
12645
  props: {
12225
12646
  vertical: {
12226
12647
  type: Boolean,
12227
12648
  default: true
12228
12649
  }
12229
12650
  },
12230
- emits: ["resize"],
12651
+ emits: ["resize", "change"],
12231
12652
  setup(_, {
12232
12653
  emit,
12233
12654
  slots
@@ -12239,9 +12660,10 @@
12239
12660
  const handleResize = () => {
12240
12661
  const v = current.value.getBoundingClientRect()[K.size];
12241
12662
  const changed = offsetSize.value != v;
12242
- if (hasInitial && changed) {
12663
+ if (changed) {
12243
12664
  offsetSize.value = v;
12244
- emit("resize");
12665
+ hasInitial && emit("resize", v);
12666
+ emit("change", v);
12245
12667
  }
12246
12668
  hasInitial = true;
12247
12669
  };
@@ -12259,10 +12681,10 @@
12259
12681
  };
12260
12682
  }
12261
12683
  });
12262
- const COMPONENT_NAME$m = "vc-recycle-list";
12684
+ const COMPONENT_NAME$o = "vc-recycle-list";
12263
12685
  const RecycleList = /* @__PURE__ */ vue.defineComponent({
12264
- name: COMPONENT_NAME$m,
12265
- props: props$n,
12686
+ name: COMPONENT_NAME$o,
12687
+ props: props$o,
12266
12688
  emits: ["scroll"],
12267
12689
  setup(props2, {
12268
12690
  slots,
@@ -12763,17 +13185,17 @@
12763
13185
  }
12764
13186
  });
12765
13187
  const MRecycleList = RecycleList;
12766
- const props$i = {
13188
+ const props$j = {
12767
13189
  tag: {
12768
13190
  type: String,
12769
13191
  default: "div"
12770
13192
  }
12771
13193
  };
12772
- const COMPONENT_NAME$l = "vc-resizer";
13194
+ const COMPONENT_NAME$n = "vc-resizer";
12773
13195
  const Resizer = vue.defineComponent({
12774
- name: COMPONENT_NAME$l,
12775
- props: props$i,
12776
- emit: ["resize"],
13196
+ name: COMPONENT_NAME$n,
13197
+ props: props$j,
13198
+ emit: ["resize", "change"],
12777
13199
  setup(props2, { emit, slots }) {
12778
13200
  const width = vue.ref(0);
12779
13201
  const height = vue.ref(0);
@@ -12799,8 +13221,9 @@
12799
13221
  const widthChanged = width.value != width$;
12800
13222
  heightChanged && (height.value = height$);
12801
13223
  widthChanged && (width.value = width$);
12802
- if (hasInitial && (heightChanged || widthChanged)) {
12803
- emit("resize", currentExposed.value);
13224
+ if (heightChanged || widthChanged) {
13225
+ hasInitial && emit("resize", currentExposed.value);
13226
+ emit("change", currentExposed.value);
12804
13227
  }
12805
13228
  hasInitial = true;
12806
13229
  };
@@ -12824,16 +13247,16 @@
12824
13247
  });
12825
13248
  const MResizer = Resizer;
12826
13249
  const MScroller = Scroller;
12827
- const props$h = {
13250
+ const props$i = {
12828
13251
  tag: {
12829
13252
  type: String,
12830
13253
  default: "div"
12831
13254
  }
12832
13255
  };
12833
- const COMPONENT_NAME$k = "vc-select";
13256
+ const COMPONENT_NAME$m = "vc-select";
12834
13257
  const Select = /* @__PURE__ */ vue.defineComponent({
12835
- name: COMPONENT_NAME$k,
12836
- props: props$h,
13258
+ name: COMPONENT_NAME$m,
13259
+ props: props$i,
12837
13260
  setup(props2, {
12838
13261
  slots
12839
13262
  }) {
@@ -12845,16 +13268,16 @@
12845
13268
  }
12846
13269
  });
12847
13270
  const MSelect = Select;
12848
- const props$g = {
13271
+ const props$h = {
12849
13272
  tag: {
12850
13273
  type: String,
12851
13274
  default: "div"
12852
13275
  }
12853
13276
  };
12854
- const COMPONENT_NAME$j = "vc-slider";
13277
+ const COMPONENT_NAME$l = "vc-slider";
12855
13278
  const Slider = /* @__PURE__ */ vue.defineComponent({
12856
- name: COMPONENT_NAME$j,
12857
- props: props$g,
13279
+ name: COMPONENT_NAME$l,
13280
+ props: props$h,
12858
13281
  setup(props2, {
12859
13282
  slots
12860
13283
  }) {
@@ -12866,16 +13289,16 @@
12866
13289
  }
12867
13290
  });
12868
13291
  const MSlider = Slider;
12869
- const props$f = {
13292
+ const props$g = {
12870
13293
  tag: {
12871
13294
  type: String,
12872
13295
  default: "div"
12873
13296
  }
12874
13297
  };
12875
- const COMPONENT_NAME$i = "vc-sort-list";
13298
+ const COMPONENT_NAME$k = "vc-sort-list";
12876
13299
  const SortList = /* @__PURE__ */ vue.defineComponent({
12877
- name: COMPONENT_NAME$i,
12878
- props: props$f,
13300
+ name: COMPONENT_NAME$k,
13301
+ props: props$g,
12879
13302
  setup(props2, {
12880
13303
  slots
12881
13304
  }) {
@@ -12887,16 +13310,16 @@
12887
13310
  }
12888
13311
  });
12889
13312
  const MSortList = SortList;
12890
- const props$e = {
13313
+ const props$f = {
12891
13314
  tag: {
12892
13315
  type: String,
12893
13316
  default: "div"
12894
13317
  }
12895
13318
  };
12896
- const COMPONENT_NAME$h = "vc-steps";
13319
+ const COMPONENT_NAME$j = "vc-steps";
12897
13320
  const Steps = /* @__PURE__ */ vue.defineComponent({
12898
- name: COMPONENT_NAME$h,
12899
- props: props$e,
13321
+ name: COMPONENT_NAME$j,
13322
+ props: props$f,
12900
13323
  setup(props2, {
12901
13324
  slots
12902
13325
  }) {
@@ -12908,16 +13331,16 @@
12908
13331
  }
12909
13332
  });
12910
13333
  const MSteps = Steps;
12911
- const props$d = {
13334
+ const props$e = {
12912
13335
  tag: {
12913
13336
  type: String,
12914
13337
  default: "div"
12915
13338
  }
12916
13339
  };
12917
- const COMPONENT_NAME$g = "vc-switch";
13340
+ const COMPONENT_NAME$i = "vc-switch";
12918
13341
  const Switch = /* @__PURE__ */ vue.defineComponent({
12919
- name: COMPONENT_NAME$g,
12920
- props: props$d,
13342
+ name: COMPONENT_NAME$i,
13343
+ props: props$e,
12921
13344
  setup(props2, {
12922
13345
  slots
12923
13346
  }) {
@@ -12929,16 +13352,16 @@
12929
13352
  }
12930
13353
  });
12931
13354
  const MSwitch = Switch;
12932
- const props$c = {
13355
+ const props$d = {
12933
13356
  tag: {
12934
13357
  type: String,
12935
13358
  default: "div"
12936
13359
  }
12937
13360
  };
12938
- const COMPONENT_NAME$f = "vc-table";
13361
+ const COMPONENT_NAME$h = "vc-table";
12939
13362
  const Table = /* @__PURE__ */ vue.defineComponent({
12940
- name: COMPONENT_NAME$f,
12941
- props: props$c,
13363
+ name: COMPONENT_NAME$h,
13364
+ props: props$d,
12942
13365
  setup(props2, {
12943
13366
  slots
12944
13367
  }) {
@@ -12950,7 +13373,7 @@
12950
13373
  }
12951
13374
  });
12952
13375
  const MTable = Table;
12953
- const props$b = {
13376
+ const props$c = {
12954
13377
  type: {
12955
13378
  type: String,
12956
13379
  validator: (v) => /^(line|card)$/.test(v),
@@ -13057,7 +13480,7 @@
13057
13480
  if (!item) return;
13058
13481
  list.value.splice(list.value.indexOf(item.props), 1);
13059
13482
  };
13060
- vue.provide("tabs", {
13483
+ vue.provide("vc-tabs", {
13061
13484
  props: props2,
13062
13485
  currentValue,
13063
13486
  refresh,
@@ -13101,10 +13524,10 @@
13101
13524
  handleChange
13102
13525
  };
13103
13526
  };
13104
- const COMPONENT_NAME$e = "vc-tabs";
13527
+ const COMPONENT_NAME$g = "vc-tabs";
13105
13528
  const Tabs = /* @__PURE__ */ vue.defineComponent({
13106
- name: COMPONENT_NAME$e,
13107
- props: props$b,
13529
+ name: COMPONENT_NAME$g,
13530
+ props: props$c,
13108
13531
  emits: ["update:modelValue", "change", "click"],
13109
13532
  setup(props2, {
13110
13533
  slots
@@ -13249,7 +13672,7 @@
13249
13672
  };
13250
13673
  }
13251
13674
  });
13252
- const props$a = {
13675
+ const props$b = {
13253
13676
  value: {
13254
13677
  type: [String, Number]
13255
13678
  },
@@ -13275,7 +13698,7 @@
13275
13698
  const { props: props2 } = instance;
13276
13699
  const currentValue = vue.ref(void 0);
13277
13700
  const isLoaded = vue.ref(false);
13278
- const tabs = vue.inject("tabs", {});
13701
+ const tabs = vue.inject("vc-tabs", {});
13279
13702
  const isActive = vue.computed(() => {
13280
13703
  const state = tabs.currentValue.value === (props2.value || currentValue.value);
13281
13704
  if (!isLoaded.value && state) {
@@ -13327,10 +13750,10 @@
13327
13750
  currentValue
13328
13751
  };
13329
13752
  };
13330
- const COMPONENT_NAME$d = "vc-tabs-pane";
13753
+ const COMPONENT_NAME$f = "vc-tabs-pane";
13331
13754
  const TabsPane = /* @__PURE__ */ vue.defineComponent({
13332
- name: COMPONENT_NAME$d,
13333
- props: props$a,
13755
+ name: COMPONENT_NAME$f,
13756
+ props: props$b,
13334
13757
  setup(_, {
13335
13758
  slots
13336
13759
  }) {
@@ -13344,8 +13767,289 @@
13344
13767
  };
13345
13768
  }
13346
13769
  });
13347
- const MTabs = Tabs;
13348
- const MTabsPane = TabsPane;
13770
+ const props$a = {
13771
+ ...props$c,
13772
+ theme: {
13773
+ type: String,
13774
+ default: "light",
13775
+ validator: (v) => /(light|dark)/.test(v)
13776
+ },
13777
+ barStyle: {
13778
+ type: [Object, Array],
13779
+ default: () => ({})
13780
+ },
13781
+ autoAfloatWidth: {
13782
+ type: Boolean,
13783
+ default: true
13784
+ },
13785
+ average: {
13786
+ type: Boolean,
13787
+ default: true
13788
+ },
13789
+ showWrapper: {
13790
+ type: Boolean,
13791
+ default: true
13792
+ },
13793
+ sticky: {
13794
+ type: Boolean,
13795
+ default: false
13796
+ },
13797
+ offsetTop: {
13798
+ type: Number,
13799
+ default: 0
13800
+ },
13801
+ showStep: {
13802
+ type: Boolean,
13803
+ default: false
13804
+ }
13805
+ };
13806
+ const COMPONENT_NAME$e = "vcm-tabs";
13807
+ const MTabs = /* @__PURE__ */ vue.defineComponent({
13808
+ name: COMPONENT_NAME$e,
13809
+ props: props$a,
13810
+ emits: ["update:modelValue", "change", "click"],
13811
+ setup(props2, {
13812
+ slots
13813
+ }) {
13814
+ const instance = vue.getCurrentInstance();
13815
+ const wrapper = vue.ref(null);
13816
+ const content = vue.ref(null);
13817
+ const scroll = vue.ref(null);
13818
+ const nav = vue.ref(null);
13819
+ const top = vue.ref(0);
13820
+ const isFixed = vue.ref(false);
13821
+ const placeholderH = vue.ref(53);
13822
+ const startX = vue.ref(0);
13823
+ const isTouching = vue.ref(false);
13824
+ const scrollViewW = vue.ref(0);
13825
+ const scrollContentW = vue.ref(0);
13826
+ const baseX = vue.ref(0);
13827
+ const isDark = vue.computed(() => {
13828
+ return props2.theme === "dark";
13829
+ });
13830
+ const fixedStyle = vue.computed(() => {
13831
+ return isFixed.value ? {
13832
+ top: `${props2.offsetTop}px`
13833
+ } : {};
13834
+ });
13835
+ let tabs;
13836
+ const handleScroll = throttle$2(() => {
13837
+ isFixed.value = document.scrollingElement.scrollTop + props2.offsetTop > top.value;
13838
+ }, 100);
13839
+ const handleTouchstart = (e) => {
13840
+ isTouching.value = true;
13841
+ startX.value = e.touches[0].pageX;
13842
+ baseX.value = tabs.scrollOffset.value;
13843
+ };
13844
+ const handleTouchmove = throttle$2((e) => {
13845
+ const touchPageX = e.touches[0].pageX;
13846
+ const changedX = touchPageX - startX.value;
13847
+ if (changedX > 0) {
13848
+ if (tabs.scrollOffset.value >= 0) {
13849
+ tabs.scrollOffset.value = 0;
13850
+ return;
13851
+ }
13852
+ } else if (Math.abs(tabs.scrollOffset.value) + scrollViewW.value >= scrollContentW.value) {
13853
+ tabs.scrollOffset.value = -(scrollContentW.value - scrollViewW.value);
13854
+ return;
13855
+ }
13856
+ tabs.scrollOffset.value = baseX.value + touchPageX - startX.value;
13857
+ }, 17);
13858
+ const handleTouchend = () => {
13859
+ isTouching.value = false;
13860
+ };
13861
+ const handleStep = (flag) => {
13862
+ if (!tabs.scrollable.value) return;
13863
+ const moveX = flag * scrollViewW.value;
13864
+ let offsetX = tabs.scrollOffset.value + moveX;
13865
+ if (offsetX < -(scrollContentW.value - scrollViewW.value) || offsetX > 0) {
13866
+ offsetX = flag === -1 ? -(scrollContentW.value - scrollViewW.value) : 0;
13867
+ }
13868
+ tabs.scrollOffset.value = offsetX;
13869
+ };
13870
+ const refreshTop = debounce$1(() => {
13871
+ if (props2.sticky) {
13872
+ top.value = content.value.offsetTop - placeholderH.value;
13873
+ isFixed.value = document.scrollingElement.scrollTop + props2.offsetTop > top.value;
13874
+ }
13875
+ }, 250, {
13876
+ leading: true,
13877
+ trailing: true
13878
+ });
13879
+ const scrollToActive = () => {
13880
+ if (!tabs.scrollable.value) return;
13881
+ const activeEl = instance.vnode.el.querySelector(`.vcm-tabs__item[data-id="${tabs.currentValue.value}"]`);
13882
+ if (!activeEl) return;
13883
+ const contentEl = nav.value;
13884
+ const activeRect = activeEl.getBoundingClientRect();
13885
+ const viewRect = scroll.value.getBoundingClientRect();
13886
+ const contentRect = contentEl.getBoundingClientRect();
13887
+ let offset = 0;
13888
+ if (activeRect.width < viewRect.width) {
13889
+ const targetOffset = (viewRect.width - activeRect.width) / 2;
13890
+ const offsetLeft = activeRect.left - contentRect.left;
13891
+ if (offsetLeft - viewRect.left <= targetOffset) {
13892
+ offset = 0;
13893
+ } else if (contentRect.right - activeRect.right <= targetOffset) {
13894
+ offset = viewRect.width - contentRect.width;
13895
+ } else {
13896
+ offset = targetOffset - offsetLeft;
13897
+ }
13898
+ }
13899
+ tabs.scrollOffset.value = offset;
13900
+ };
13901
+ const operateDOMScrollEvents = (type) => {
13902
+ const fn = type === "add" ? window.addEventListener : window.removeEventListener;
13903
+ fn("scroll", handleScroll);
13904
+ fn("touchstart", handleTouchstart, false);
13905
+ fn("touchmove", handleTouchmove, false);
13906
+ fn("touchend", handleTouchend, false);
13907
+ };
13908
+ const refreshScroll = () => {
13909
+ const viewEl = scroll.value;
13910
+ scrollViewW.value = viewEl.offsetWidth;
13911
+ scrollContentW.value = nav.value.offsetWidth;
13912
+ if (scrollContentW.value > scrollViewW.value) {
13913
+ operateDOMScrollEvents("remove");
13914
+ operateDOMScrollEvents("add");
13915
+ tabs.scrollable.value = true;
13916
+ } else if (tabs.scrollable.value) {
13917
+ operateDOMScrollEvents("remove");
13918
+ tabs.scrollable.value = false;
13919
+ }
13920
+ tabs.scrollable.value && scrollToActive();
13921
+ };
13922
+ const refreshAfloat = () => {
13923
+ if (!props2.showWrapper) return;
13924
+ vue.nextTick(() => {
13925
+ const index = tabs.getTabIndex(tabs.currentValue.value);
13926
+ if (instance.isUnmounted) return;
13927
+ const items = nav.value.querySelectorAll(`.vcm-tabs__item`);
13928
+ const $2 = items[index];
13929
+ tabs.afloatWidth.value = $2 ? isDark.value ? 20 : props2.autoAfloatWidth ? $2.querySelector("span").offsetWidth : $2.offsetWidth : 0;
13930
+ if (!Array.from(items).length) return;
13931
+ let offset = 0;
13932
+ const basicOffset = $2 ? ($2.offsetWidth - tabs.afloatWidth.value) / 2 : 0;
13933
+ if (index > 0) {
13934
+ for (let i = 0; i < index; i++) {
13935
+ offset += parseFloat(items[i].offsetWidth);
13936
+ }
13937
+ }
13938
+ tabs.afloatOffset.value = offset + basicOffset;
13939
+ refreshScroll();
13940
+ });
13941
+ };
13942
+ const operateDOMEvents = (type) => {
13943
+ if (!props2.sticky) return;
13944
+ const fn = type === "add" ? window.addEventListener : window.removeEventListener;
13945
+ fn("scroll", handleScroll);
13946
+ };
13947
+ tabs = useTabs({
13948
+ content,
13949
+ wrapper,
13950
+ refreshAfloat,
13951
+ refreshScroll,
13952
+ scrollToActive
13953
+ });
13954
+ const scrollStyle = vue.computed(() => {
13955
+ return {
13956
+ transition: isTouching.value ? "" : "transform 300ms ease-in-out",
13957
+ transform: `translate3d(${tabs.scrollOffset.value}px, 0, 0)`
13958
+ };
13959
+ });
13960
+ vue.onMounted(() => {
13961
+ refreshTop();
13962
+ operateDOMEvents("add");
13963
+ vue.nextTick(refreshScroll);
13964
+ });
13965
+ vue.onUpdated(refreshTop);
13966
+ vue.onUnmounted(() => {
13967
+ operateDOMEvents("remove");
13968
+ operateDOMScrollEvents("remove");
13969
+ });
13970
+ vue.watch(() => props2.theme, refreshAfloat);
13971
+ vue.watch(() => props2.average, refreshAfloat);
13972
+ vue.watch(() => props2.showStep, () => vue.nextTick(refreshScroll));
13973
+ return () => {
13974
+ return vue.createVNode("div", {
13975
+ "class": [tabs.classes.value, "vcm-tabs"]
13976
+ }, [props2.showWrapper && vue.createVNode("div", {
13977
+ "ref": wrapper,
13978
+ "style": [props2.barStyle, fixedStyle.value],
13979
+ "class": [{
13980
+ "is-fixed": isFixed
13981
+ }, "vcm-tabs__bar"]
13982
+ }, [vue.createVNode("slot", {
13983
+ "name": "prepend"
13984
+ }, null), slots.prepend?.(), props2.showStep && tabs.scrollable.value && vue.createVNode("div", {
13985
+ "class": "vcm-tabs__step is-left",
13986
+ "onClick": () => handleStep(1)
13987
+ }, [vue.createVNode(Icon, {
13988
+ "type": "left"
13989
+ }, null)]), vue.createVNode("div", {
13990
+ "ref": scroll,
13991
+ "class": "vcm-tabs__scroll"
13992
+ }, [vue.createVNode("div", {
13993
+ "ref": nav,
13994
+ "style": scrollStyle.value,
13995
+ "class": "vcm-tabs__nav"
13996
+ }, [props2.afloat && vue.createVNode("div", {
13997
+ "style": tabs.afloatStyle.value,
13998
+ "class": "vcm-tabs__afloat"
13999
+ }, null), tabs.list.value.map((item, index) => {
14000
+ return vue.createVNode("div", {
14001
+ "key": index,
14002
+ "data-id": item.value,
14003
+ "class": [{
14004
+ "is-active": (item.value || index) == tabs.currentValue.value,
14005
+ "is-average": props2.average
14006
+ }, "vcm-tabs__item"],
14007
+ "onClick": () => tabs.handleChange(index)
14008
+ }, [slots.label ? slots.label({
14009
+ it: item,
14010
+ index
14011
+ }) : typeof item.label === "string" ? vue.createVNode("span", {
14012
+ "innerHTML": item.label
14013
+ }, null) : typeof item.label === "function" && vue.createVNode(Customer, {
14014
+ "render": item.label,
14015
+ "it": item,
14016
+ "index": index
14017
+ }, null)]);
14018
+ })])]), props2.showStep && tabs.scrollable.value && vue.createVNode("div", {
14019
+ "class": "vcm-tabs__step is-right",
14020
+ "onClick": () => handleStep(-1)
14021
+ }, [vue.createVNode(Icon, {
14022
+ "type": "right"
14023
+ }, null)]), slots.append?.()]), isFixed.value && vue.createVNode("div", {
14024
+ "style": {
14025
+ height: `${placeholderH.value}px`
14026
+ },
14027
+ "class": "vcm-tabs__placeholder"
14028
+ }, null), vue.createVNode("div", {
14029
+ "ref": content,
14030
+ "style": tabs.contentStyle.value,
14031
+ "class": "vcm-tabs__content"
14032
+ }, [slots.default?.()])]);
14033
+ };
14034
+ }
14035
+ });
14036
+ const COMPONENT_NAME$d = "vcm-tabs-pane";
14037
+ const MTabsPane = /* @__PURE__ */ vue.defineComponent({
14038
+ name: COMPONENT_NAME$d,
14039
+ props: props$b,
14040
+ setup(_, {
14041
+ slots
14042
+ }) {
14043
+ const tabsPane = useTabsPane();
14044
+ return () => {
14045
+ return vue.createVNode("div", {
14046
+ "class": "vcm-tabs-pane",
14047
+ "style": tabsPane.style.value,
14048
+ "name": tabsPane.currentValue.value
14049
+ }, [tabsPane.isReady && slots.default?.()]);
14050
+ };
14051
+ }
14052
+ });
13349
14053
  const props$9 = {
13350
14054
  tag: {
13351
14055
  type: String,
@@ -13767,8 +14471,8 @@
13767
14471
  MDebounce: Debounce,
13768
14472
  Divider,
13769
14473
  MDivider,
13770
- Drawer,
13771
- MDrawer,
14474
+ DrawerView,
14475
+ MDrawerView,
13772
14476
  Dropdown,
13773
14477
  MDropdown,
13774
14478
  // DropdownItem,
@@ -13811,8 +14515,8 @@
13811
14515
  MListItem,
13812
14516
  Marquee,
13813
14517
  MMarquee,
13814
- Modal: modal$1,
13815
- MModal: modal,
14518
+ ModalView,
14519
+ MModalView,
13816
14520
  Notice: Notice$1,
13817
14521
  MNotice,
13818
14522
  Option,
@@ -94046,6 +94750,7 @@
94046
94750
  exports.Checkbox = Checkbox;
94047
94751
  exports.Clipboard = Clipboard;
94048
94752
  exports.Collapse = Collapse;
94753
+ exports.CollapseItem = CollapseItem;
94049
94754
  exports.ColorPicker = ColorPicker;
94050
94755
  exports.Components = Components;
94051
94756
  exports.Countdown = Countdown;
@@ -94053,7 +94758,8 @@
94053
94758
  exports.DatePicker = DatePicker;
94054
94759
  exports.Debounce = Debounce;
94055
94760
  exports.Divider = Divider;
94056
- exports.Drawer = Drawer;
94761
+ exports.Drawer = drawer;
94762
+ exports.DrawerView = DrawerView;
94057
94763
  exports.Dropdown = Dropdown;
94058
94764
  exports.Editor = Editor;
94059
94765
  exports.Expand = Expand;
@@ -94085,13 +94791,14 @@
94085
94791
  exports.MCheckbox = MCheckbox;
94086
94792
  exports.MClipboard = MClipboard;
94087
94793
  exports.MCollapse = MCollapse;
94794
+ exports.MCollapseItem = MCollapseItem;
94088
94795
  exports.MColorPicker = MColorPicker;
94089
94796
  exports.MCountdown = MCountdown;
94090
94797
  exports.MCustomer = MCustomer;
94091
94798
  exports.MDatePicker = MDatePicker;
94092
94799
  exports.MDebounce = Debounce;
94093
94800
  exports.MDivider = MDivider;
94094
- exports.MDrawer = MDrawer;
94801
+ exports.MDrawerView = MDrawerView;
94095
94802
  exports.MDropdown = MDropdown;
94096
94803
  exports.MEditor = MEditor;
94097
94804
  exports.MExpand = MExpand;