@deot/vc-components 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -106,58 +106,33 @@ const ActionSheet = /* @__PURE__ */ vue.defineComponent({
106
106
  const MActionSheet = ActionSheet;
107
107
 
108
108
  const props$1f = {
109
- tag: {
109
+ modelValue: {
110
+ type: Boolean,
111
+ default: true
112
+ },
113
+ type: {
110
114
  type: String,
111
- default: "div"
112
- }
113
- };
114
-
115
- /** @jsxImportSource vue */
116
-
117
- const COMPONENT_NAME$1v = 'vc-alert';
118
- const Alert = /* @__PURE__ */ vue.defineComponent({
119
- name: COMPONENT_NAME$1v,
120
- props: props$1f,
121
- setup(props, {
122
- slots
123
- }) {
124
- return () => {
125
- return vue.createVNode("div", {
126
- "class": "vc-alert"
127
- }, [slots?.default?.()]);
128
- };
129
- }
130
- });
131
-
132
- const MAlert = Alert;
133
-
134
- const props$1e = {
135
- tag: {
115
+ default: "info"
116
+ },
117
+ title: {
136
118
  type: String,
137
- default: "div"
119
+ default: ""
120
+ },
121
+ desc: {
122
+ type: String,
123
+ default: ""
124
+ },
125
+ icon: {
126
+ type: [String, Boolean],
127
+ default: true
128
+ },
129
+ closable: {
130
+ type: Boolean,
131
+ default: false
138
132
  }
139
133
  };
140
134
 
141
- /** @jsxImportSource vue */
142
-
143
- const COMPONENT_NAME$1u = 'vc-artboard';
144
- const Artboard = /* @__PURE__ */ vue.defineComponent({
145
- name: COMPONENT_NAME$1u,
146
- props: props$1e,
147
- setup(props, {
148
- slots
149
- }) {
150
- return () => {
151
- return vue.createVNode("div", {
152
- "class": "vc-artboard"
153
- }, [slots?.default?.()]);
154
- };
155
- }
156
- });
157
-
158
- const MArtboard = Artboard;
159
-
160
- const props$1d = {
135
+ const props$1e = {
161
136
  type: String,
162
137
  inherit: {
163
138
  type: Boolean,
@@ -302,10 +277,10 @@ const IconManager = new Manager();
302
277
 
303
278
  /** @jsxImportSource vue */
304
279
 
305
- const COMPONENT_NAME$1t = 'vc-icon';
280
+ const COMPONENT_NAME$1v = 'vc-icon';
306
281
  const Icon = /* @__PURE__ */ vue.defineComponent({
307
- name: COMPONENT_NAME$1t,
308
- props: props$1d,
282
+ name: COMPONENT_NAME$1v,
283
+ props: props$1e,
309
284
  setup(props) {
310
285
  const viewBox = vue.ref('0 0 1024 1024');
311
286
  const path = vue.ref([]);
@@ -338,501 +313,581 @@ const Icon = /* @__PURE__ */ vue.defineComponent({
338
313
  }
339
314
  });
340
315
 
341
- const props$1c = {
342
- size: {
343
- type: Number,
344
- default: 28
345
- },
346
- foreground: {
347
- type: String,
348
- default: "#ccc"
349
- },
350
- background: {
351
- type: String,
352
- default: "var(--vc-color-primary)"
353
- },
316
+ const props$1d = {
354
317
  /**
355
- * 待开发
318
+ * 进入/离开持续时间
319
+ * {enter: 300, leave: 300}
356
320
  */
357
- fixed: {
358
- type: Boolean,
359
- default: false
360
- }
361
- };
362
-
363
- /** @jsxImportSource vue */
364
-
365
- const COMPONENT_NAME$1s = 'vc-spin';
366
- const Spin = /* @__PURE__ */ vue.defineComponent({
367
- name: COMPONENT_NAME$1s,
368
- props: props$1c,
369
- setup(props, {
370
- slots
371
- }) {
372
- return () => {
373
- return vue.createVNode("div", {
374
- "class": "vc-spin"
375
- }, [vue.createVNode("span", {
376
- "style": {
377
- fontSize: `${props.size}px`
378
- }
379
- }, [slots?.loading?.() || vue.createVNode("svg", {
380
- "xmlns": "http://www.w3.org/2000/svg",
381
- "version": "1.1",
382
- "viewBox": "0 0 32 32",
383
- "width": "100%",
384
- "height": "100%"
385
- }, [vue.createVNode("path", {
386
- "stroke": props.foreground,
387
- "d": "M 16 2 A 14 14 0 1 0 30 15",
388
- "fill": "none",
389
- "stroke-width": "2",
390
- "stroke-linecap": "round"
391
- }, null), vue.createVNode("path", {
392
- "stroke": props.background,
393
- "d": "M 16 2 A 14 14 0 0 1 30 15",
394
- "fill": "none",
395
- "stroke-width": "2",
396
- "stroke-linecap": "round"
397
- }, null)])]), slots?.default?.()]);
398
- };
399
- }
400
- });
401
-
402
- const props$1b = {
403
- wait: {
404
- type: Number,
405
- default: 250
406
- },
407
- tag: {
408
- type: [String, Object],
409
- default: "div"
321
+ duration: {
322
+ type: [Number, Object],
323
+ default: 300
410
324
  },
411
- include: {
412
- type: RegExp,
413
- default: () => /^on([A-Z])/
325
+ /**
326
+ * 进入/离开延迟时间
327
+ */
328
+ delay: {
329
+ type: [Number, Object],
330
+ default: 0
414
331
  },
415
- exclude: RegExp
416
- };
417
-
418
- const COMPONENT_NAME$1r = "vc-debounce";
419
- const Debounce = vue.defineComponent({
420
- name: COMPONENT_NAME$1r,
421
- props: props$1b,
422
332
  /**
423
- * 不声明emits使得事件被透传放入attrs中, 这样可以让所有的事件透传
424
- * 如事件onClick
425
- * 当inheritAttrs为true时:因为emits为声明onClick会覆盖到`props.tag`上,使得我们重写的onClick无效
426
- * 当inheritAttrs为false时: 透传的onClick不会被重载,这样我们就可以重写onClick
333
+ * `transition-group` component.
334
+ */
335
+ group: Boolean,
336
+ /**
337
+ * `transition-group` tag, v3版本默认值无
427
338
  */
428
- inheritAttrs: false,
429
- setup(props, { slots, attrs }) {
430
- const listener = vue.ref({});
431
- vue.watch(
432
- [() => props.wait, () => props.exclude, () => props.include],
433
- () => {
434
- const { wait, exclude, include } = props;
435
- const ons = Object.entries(attrs).reduce((pre, [key, callback]) => {
436
- /* istanbul ignore else -- @preserve */
437
- if ((!exclude || !exclude.test(key)) && (!include || include.test(key)) && typeof callback === "function") {
438
- pre[key] = lodashEs.debounce(callback, wait, {
439
- leading: true,
440
- trailing: false
441
- });
442
- }
443
- return pre;
444
- }, {});
445
- if (Object.keys(listener.value).length !== Object.keys(ons).length) {
446
- listener.value = ons;
447
- }
448
- },
449
- {
450
- immediate: true
451
- }
452
- );
453
- return () => {
454
- return vue.h(props.tag, {
455
- ...attrs,
456
- ...listener.value
457
- }, slots.default?.());
458
- };
459
- }
460
- });
461
-
462
- const props$1a = {
463
339
  tag: {
464
340
  type: String,
465
- default: "button"
341
+ default: void 0
466
342
  },
467
- type: {
343
+ /**
344
+ * 变换的初始位置, 可以用style代替, 更短~~
345
+ */
346
+ origin: {
468
347
  type: String,
469
- default: "default"
348
+ default: ""
470
349
  },
471
- size: {
472
- type: String,
473
- default: "medium"
350
+ /**
351
+ * 在转换期间应用的元素样式。这些样式应用于@beforeEnter和@beforeLeave钩子
352
+ * inheritAttrs必须是false
353
+ */
354
+ style: {
355
+ type: Object,
356
+ default: () => {
357
+ return {
358
+ animationFillMode: "both",
359
+ animationTimingFunction: "ease-out"
360
+ };
361
+ }
474
362
  },
475
- wait: {
476
- type: Number,
477
- default: 250
363
+ prefix: {
364
+ type: String,
365
+ default: "vc-transition"
478
366
  },
479
- icon: String,
480
- disabled: Boolean,
481
- circle: Boolean,
482
- round: Boolean,
483
- long: Boolean,
484
- htmlType: {
367
+ mode: {
485
368
  type: String,
486
- default: "button"
369
+ default: "none"
487
370
  }
488
371
  };
489
372
 
490
- /** @jsxImportSource vue */
491
-
492
- const COMPONENT_NAME$1q = 'vc-button';
493
- const Button = /* @__PURE__ */ vue.defineComponent({
494
- name: COMPONENT_NAME$1q,
495
- emits: ['click'],
496
- props: props$1a,
497
- setup(props, {
498
- slots
499
- }) {
500
- const vm = vue.getCurrentInstance();
501
- const hasSlot = vue.ref(true);
502
- const isLoading = vue.ref(false);
503
- const group = vue.inject('button-group', {
504
- size: 'medium',
505
- vertical: false,
506
- circle: false
507
- });
508
- const classes = vue.computed(() => ({
509
- 'is-circle': props.circle || group.circle,
510
- 'is-alone': !hasSlot.value,
511
- 'is-round': props.round,
512
- 'is-long': props.long,
513
- 'is-disabled': props.disabled,
514
- [`is-${props.size}`]: true,
515
- [`is-${props.type}`]: true
516
- }));
517
- const handleClick = (...args) => {
518
- const fn = vm.vnode.props?.['onClick']?.(...args);
519
- if (fn && fn.then) {
520
- isLoading.value = true;
521
- fn.finally(() => {
522
- isLoading.value = false;
523
- });
524
- }
373
+ const trim = (str) => str.trim().replace(/\s+/g, " ");
374
+ const useTransition = () => {
375
+ const instance = vue.getCurrentInstance();
376
+ const attrs = instance.attrs;
377
+ const props = instance.props;
378
+ const Wrapper = vue.computed(() => {
379
+ return props.group ? vue.TransitionGroup : vue.Transition;
380
+ });
381
+ const classes = vue.computed(() => {
382
+ const modeClass = props.mode !== "none" ? `is-${props.mode.replace(/-/g, " is-")}` : "";
383
+ return {
384
+ enterActiveClass: trim(`${attrs.enterActiveClass || ""} ${props.prefix} ${modeClass} is-in`),
385
+ leaveActiveClass: trim(`${attrs.leaveActiveClass || ""} ${props.prefix} ${modeClass} is-out`),
386
+ moveClass: props.group ? trim(`${attrs.moveClass || ""} ${props.prefix} ${modeClass} is-move`) : void 0
525
387
  };
526
- vue.onMounted(() => {
527
- hasSlot.value = slots.default !== undefined;
388
+ });
389
+ const clearStyles = (el) => {
390
+ Object.keys(props.style).forEach((key) => {
391
+ const v = props.style[key];
392
+ v && el.style.removeProperty(
393
+ key.replace(/([A-Z])/g, "-$1").toLowerCase()
394
+ );
528
395
  });
529
- return () => {
530
- return vue.createVNode(Debounce, {
531
- "tag": props.tag,
532
- "class": {
533
- 'vc-button': true,
534
- ...classes.value
535
- },
536
- "wait": props.wait,
537
- "disabled": props.disabled,
538
- "type": props.htmlType,
539
- "onClick": handleClick
540
- }, {
541
- default: () => [props.icon && vue.createVNode(Icon, {
542
- "type": props.icon
543
- }, null), isLoading.value && vue.createVNode(Spin, {
544
- "size": 12,
545
- "foreground": props.type === 'default' ? '#ccc' : '#fff',
546
- "class": "vc-button__loading"
547
- }, null), hasSlot.value && vue.createVNode("span", null, [slots?.default?.()])]
548
- });
396
+ el.style.removeProperty("animation-duration");
397
+ el.style.removeProperty("animation-delay");
398
+ };
399
+ const resetAbsolute = (el) => {
400
+ props.group && (el.style.position = "absolute");
401
+ };
402
+ const resetOrigin = (el) => {
403
+ props.origin && (el.style.transformOrigin = props.origin);
404
+ };
405
+ const resetStyles = (el) => {
406
+ resetOrigin(el);
407
+ Object.keys(props.style).forEach((key) => {
408
+ const v = props.style[key];
409
+ v && (el.style[key] = v);
410
+ });
411
+ };
412
+ const handleBeforeEnter = (el) => {
413
+ const duration = props.duration.enter || props.duration;
414
+ el.style.animationDuration = `${duration}ms`;
415
+ const delay = props.delay.enter || props.delay;
416
+ el.style.animationDelay = `${delay}ms`;
417
+ resetStyles(el);
418
+ attrs.onBeforeEnter?.(el);
419
+ };
420
+ const createNext = (callback, duration) => {
421
+ let hasDone = false;
422
+ return (immediate = true) => {
423
+ if (hasDone) return;
424
+ hasDone = true;
425
+ const done = () => callback?.();
426
+ immediate ? done() : setTimeout(done, duration);
549
427
  };
550
- }
551
- });
552
-
553
- const props$19 = {
554
- vertical: {
555
- type: Boolean,
556
- default: false
557
- },
558
- circle: {
559
- type: Boolean,
560
- default: false
561
- },
562
- size: {
563
- type: String,
564
- default: "medium"
565
- },
566
- fragment: {
567
- type: Boolean,
568
- default: false
569
- }
428
+ };
429
+ const handleEnter = async (el, done) => {
430
+ const duration = props.duration.enter || props.duration;
431
+ const next = createNext(done, duration);
432
+ try {
433
+ await attrs.onEnter?.(el, next);
434
+ } finally {
435
+ next(false);
436
+ }
437
+ };
438
+ const handleAfterEnter = (el) => {
439
+ clearStyles(el);
440
+ attrs.onAfterEnter?.(el);
441
+ };
442
+ const handleBeforeLeave = (el) => {
443
+ const duration = props.duration.leave || props.duration;
444
+ el.style.animationDuration = `${duration}ms`;
445
+ const delay = props.delay.leave || props.delay;
446
+ el.style.animationDelay = `${delay}ms`;
447
+ resetStyles(el);
448
+ attrs.onBeforeLeave?.(el);
449
+ };
450
+ const handleLeave = async (el, done) => {
451
+ const duration = props.duration.leave || props.duration;
452
+ const next = createNext(done, duration);
453
+ try {
454
+ resetAbsolute(el);
455
+ await attrs.onLeave?.(el, next);
456
+ } finally {
457
+ next(props.group ? true : false);
458
+ }
459
+ };
460
+ const handleAfterLeave = (el) => {
461
+ clearStyles(el);
462
+ attrs.onAfterLeave?.(el);
463
+ };
464
+ return {
465
+ Wrapper,
466
+ resetStyles,
467
+ resetAbsolute,
468
+ classes,
469
+ createNext,
470
+ listeners: {
471
+ onBeforeEnter: handleBeforeEnter,
472
+ onEnter: handleEnter,
473
+ onAfterEnter: handleAfterEnter,
474
+ onBeforeLeave: handleBeforeLeave,
475
+ onLeave: handleLeave,
476
+ onAfterLeave: handleAfterLeave
477
+ }
478
+ };
570
479
  };
571
480
 
572
- /** @jsxImportSource vue */
573
-
574
- const COMPONENT_NAME$1p = 'vc-button-group';
575
- const ButtonGroup = /* @__PURE__ */ vue.defineComponent({
576
- name: COMPONENT_NAME$1p,
577
- props: props$19,
578
- setup(props, {
579
- slots
580
- }) {
581
- vue.provide('button-group', props);
582
- const classes = vue.computed(() => ({
583
- 'is-vertical': props.vertical,
584
- 'is-circle': props.circle,
585
- [`is-${props.size}`]: !!props.size
586
- }));
481
+ const COMPONENT_NAME$1u = "vc-transition";
482
+ const Transition = vue.defineComponent({
483
+ name: COMPONENT_NAME$1u,
484
+ props: props$1d,
485
+ // 当不声明emits的情况下,事件存在于attrs中
486
+ inheritAttrs: false,
487
+ setup(props, { slots, attrs }) {
488
+ const { Wrapper, listeners, classes } = useTransition();
587
489
  return () => {
588
- return props.fragment ? slots?.default?.() : vue.createVNode("div", {
589
- "class": {
590
- 'vc-button-group': true,
591
- ...classes.value
592
- }
593
- }, [slots?.default?.()]);
490
+ return vue.h(
491
+ Wrapper.value,
492
+ {
493
+ ...attrs,
494
+ ...listeners,
495
+ ...classes.value,
496
+ tag: props.tag
497
+ },
498
+ slots
499
+ );
594
500
  };
595
501
  }
596
502
  });
597
503
 
598
- const MButton = Button;
599
- const MButtonGroup = ButtonGroup;
600
-
601
- const props$18 = {
602
- tag: {
603
- type: String,
604
- default: "div"
605
- }
606
- };
607
-
608
- /** @jsxImportSource vue */
609
-
610
- const COMPONENT_NAME$1o = 'vc-calendar';
611
- const Calendar = /* @__PURE__ */ vue.defineComponent({
612
- name: COMPONENT_NAME$1o,
613
- props: props$18,
614
- setup(props, {
615
- slots
616
- }) {
617
- return () => {
618
- return vue.createVNode("div", {
619
- "class": "vc-calendar"
620
- }, [slots?.default?.()]);
504
+ const COMPONENT_NAME$1t = "vc-transition-collapse";
505
+ const TransitionCollapse = vue.defineComponent({
506
+ name: COMPONENT_NAME$1t,
507
+ props: props$1d,
508
+ // 当不声明emits的情况下,事件存在于attrs中
509
+ inheritAttrs: false,
510
+ setup(props, { slots, attrs: _attrs }) {
511
+ const attrs = _attrs;
512
+ const { Wrapper, resetStyles, resetAbsolute, createNext } = useTransition();
513
+ const getTransitionStyle = (duration) => {
514
+ const style = `
515
+ ${duration}ms height ease-in-out,
516
+ ${duration}ms padding-top ease-in-out,
517
+ ${duration}ms padding-bottom ease-in-out
518
+ `;
519
+ return style;
621
520
  };
622
- }
623
- });
624
-
625
- const MCalendar = Calendar;
626
-
627
- const props$17 = {
628
- tag: {
629
- type: String,
630
- default: "div"
631
- }
632
- };
633
-
634
- /** @jsxImportSource vue */
635
-
636
- const COMPONENT_NAME$1n = 'vc-card';
637
- const Card = /* @__PURE__ */ vue.defineComponent({
638
- name: COMPONENT_NAME$1n,
639
- props: props$17,
640
- setup(props, {
641
- slots
642
- }) {
643
- return () => {
644
- return vue.createVNode("div", {
645
- "class": "vc-card"
646
- }, [slots?.default?.()]);
521
+ const handleBeforeEnter = (el) => {
522
+ const duration = props.duration.enter || props.duration;
523
+ el.style.transition = getTransitionStyle(duration);
524
+ /* istanbul ignore next -- @preserve */
525
+ if (!el.dataset) {
526
+ el.dataset = {};
527
+ }
528
+ el.dataset.oldPaddingTop = el.style.paddingTop;
529
+ el.dataset.oldPaddingBottom = el.style.paddingBottom;
530
+ el.style.height = "0px";
531
+ el.style.paddingTop = "0px";
532
+ el.style.paddingBottom = "0px";
533
+ resetStyles(el);
534
+ attrs.onBeforeEnter?.(el);
647
535
  };
648
- }
649
- });
650
-
651
- const MCard = Card;
652
-
653
- const props$16 = {
654
- tag: {
655
- type: String,
656
- default: "div"
657
- }
658
- };
659
-
660
- /** @jsxImportSource vue */
661
-
662
- const COMPONENT_NAME$1m = 'vc-carousel';
663
- const Carousel = /* @__PURE__ */ vue.defineComponent({
664
- name: COMPONENT_NAME$1m,
665
- props: props$16,
666
- setup(props, {
667
- slots
668
- }) {
669
- return () => {
670
- return vue.createVNode("div", {
671
- "class": "vc-carousel"
672
- }, [slots?.default?.()]);
536
+ const handleEnter = async (el, done) => {
537
+ const duration = props.duration.enter || props.duration;
538
+ const next = createNext(done, duration);
539
+ try {
540
+ el.dataset.oldOverflow = el.style.overflow;
541
+ /* istanbul ignore next -- @preserve */
542
+ if (el.scrollHeight !== 0) {
543
+ el.style.height = el.scrollHeight + "px";
544
+ el.style.paddingTop = el.dataset.oldPaddingTop + "px";
545
+ el.style.paddingBottom = el.dataset.oldPaddingBottom + "px";
546
+ } else {
547
+ el.style.height = "";
548
+ el.style.paddingTop = el.dataset.oldPaddingTop + "px";
549
+ el.style.paddingBottom = el.dataset.oldPaddingBottom + "px";
550
+ }
551
+ el.style.overflow = "hidden";
552
+ attrs.onEnter?.(el);
553
+ } finally {
554
+ next(false);
555
+ }
556
+ };
557
+ const handleAfterEnter = (el) => {
558
+ el.style.transition = "";
559
+ el.style.height = "";
560
+ el.style.overflow = el.dataset.oldOverflow || "";
561
+ attrs.onAfterEnter?.(el);
562
+ };
563
+ const handleBeforeLeave = (el) => {
564
+ /* istanbul ignore next -- @preserve */
565
+ if (!el.dataset) {
566
+ el.dataset = {};
567
+ }
568
+ el.dataset.oldPaddingTop = el.style.paddingTop;
569
+ el.dataset.oldPaddingBottom = el.style.paddingBottom;
570
+ el.dataset.oldOverflow = el.style.overflow;
571
+ el.style.height = el.scrollHeight + "px";
572
+ el.style.overflow = "hidden";
573
+ resetStyles(el);
574
+ attrs.onBeforeLeave?.(el);
575
+ };
576
+ const handleLeave = (el, done) => {
577
+ const duration = props.duration.leave || props.duration;
578
+ const next = createNext(done, duration);
579
+ try {
580
+ const leaveDuration = props.duration.leave || props.duration;
581
+ /* istanbul ignore next -- @preserve */
582
+ if (el.scrollHeight !== 0) {
583
+ el.style.transition = getTransitionStyle(leaveDuration);
584
+ el.style.height = "0px";
585
+ el.style.paddingTop = "0px";
586
+ el.style.paddingBottom = "0px";
587
+ }
588
+ resetAbsolute(el);
589
+ attrs.onLeave?.(el);
590
+ } finally {
591
+ next(props.group ? true : false);
592
+ }
593
+ };
594
+ const handleAfterLeave = (el) => {
595
+ el.style.transition = "";
596
+ el.style.height = "";
597
+ el.style.overflow = el.dataset.oldOverflow || "";
598
+ el.style.paddingTop = el.dataset.oldPaddingTop || "";
599
+ el.style.paddingBottom = el.dataset.oldPaddingBottom || "";
600
+ attrs.onAfterLeave?.(el);
601
+ };
602
+ const listeners = {
603
+ onBeforeEnter: handleBeforeEnter,
604
+ onEnter: handleEnter,
605
+ onAfterEnter: handleAfterEnter,
606
+ onBeforeLeave: handleBeforeLeave,
607
+ onLeave: handleLeave,
608
+ onAfterLeave: handleAfterLeave
673
609
  };
674
- }
675
- });
676
-
677
- const MCarousel = Carousel;
678
-
679
- const props$15 = {
680
- tag: {
681
- type: String,
682
- default: "div"
683
- }
684
- };
685
-
686
- /** @jsxImportSource vue */
687
-
688
- const COMPONENT_NAME$1l = 'vc-cascader';
689
- const Cascader = /* @__PURE__ */ vue.defineComponent({
690
- name: COMPONENT_NAME$1l,
691
- props: props$15,
692
- setup(props, {
693
- slots
694
- }) {
695
610
  return () => {
696
- return vue.createVNode("div", {
697
- "class": "vc-cascader"
698
- }, [slots?.default?.()]);
611
+ return vue.h(
612
+ Wrapper.value,
613
+ {
614
+ ...attrs,
615
+ ...listeners,
616
+ tag: props.tag,
617
+ moveClass: props.group ? `${attrs.moveClass || ""} vc-transition-collapse is-move` : void 0
618
+ },
619
+ slots
620
+ );
699
621
  };
700
622
  }
701
623
  });
702
624
 
703
- const MCascader = Cascader;
704
-
705
- const props$14 = {
706
- tag: {
707
- type: String,
708
- default: "div"
709
- }
710
- };
711
-
712
- /** @jsxImportSource vue */
713
-
714
- const COMPONENT_NAME$1k = 'vc-chart';
715
- const Chart = /* @__PURE__ */ vue.defineComponent({
716
- name: COMPONENT_NAME$1k,
717
- props: props$14,
718
- setup(props, {
719
- slots
720
- }) {
625
+ const COMPONENT_NAME$1s = "vc-transition-fade";
626
+ const TransitionFade = vue.defineComponent({
627
+ name: COMPONENT_NAME$1s,
628
+ props: {
629
+ ...props$1d,
630
+ // inheritAttrs必须是false
631
+ style: {
632
+ type: Object,
633
+ default: () => ({
634
+ animationFillMode: "both",
635
+ animationTimingFunction: void 0
636
+ })
637
+ },
638
+ prefix: {
639
+ type: String,
640
+ default: "vc-transition-fade"
641
+ }
642
+ },
643
+ // 当不声明emits的情况下,事件存在于attrs中
644
+ inheritAttrs: false,
645
+ setup(props, { slots, attrs }) {
646
+ const { Wrapper, listeners, classes } = useTransition();
721
647
  return () => {
722
- return vue.createVNode("div", {
723
- "class": "vc-chart"
724
- }, [slots?.default?.()]);
648
+ return vue.h(
649
+ Wrapper.value,
650
+ {
651
+ ...attrs,
652
+ ...listeners,
653
+ ...classes.value,
654
+ tag: props.tag
655
+ },
656
+ slots
657
+ );
725
658
  };
726
659
  }
727
660
  });
728
661
 
729
- const MChart = Chart;
730
-
731
- const props$13 = {
732
- tag: {
733
- type: String,
734
- default: "div"
735
- }
736
- };
737
-
738
- /** @jsxImportSource vue */
739
-
740
- const COMPONENT_NAME$1j = 'vc-checkbox';
741
- const Checkbox = /* @__PURE__ */ vue.defineComponent({
742
- name: COMPONENT_NAME$1j,
743
- props: props$13,
744
- setup(props, {
745
- slots
746
- }) {
662
+ const COMPONENT_NAME$1r = "vc-transition-scale";
663
+ const TransitionScale = vue.defineComponent({
664
+ name: COMPONENT_NAME$1r,
665
+ props: {
666
+ ...props$1d,
667
+ mode: {
668
+ type: String,
669
+ default: "both",
670
+ validator: (v) => /(part|both|y|x|none)/.test(v)
671
+ },
672
+ // inheritAttrs必须是false
673
+ style: {
674
+ type: Object,
675
+ default: () => ({
676
+ animationFillMode: "both",
677
+ animationTimingFunction: void 0
678
+ })
679
+ },
680
+ prefix: {
681
+ type: String,
682
+ default: "vc-transition-scale"
683
+ }
684
+ },
685
+ // 当不声明emits的情况下,事件存在于attrs中
686
+ inheritAttrs: false,
687
+ setup(props, { slots, attrs }) {
688
+ const { Wrapper, listeners, classes } = useTransition();
747
689
  return () => {
748
- return vue.createVNode("div", {
749
- "class": "vc-checkbox"
750
- }, [slots?.default?.()]);
690
+ return vue.h(
691
+ Wrapper.value,
692
+ {
693
+ ...attrs,
694
+ ...listeners,
695
+ ...classes.value,
696
+ tag: props.tag
697
+ },
698
+ slots
699
+ );
751
700
  };
752
701
  }
753
702
  });
754
703
 
755
- const MCheckbox = Checkbox;
756
-
757
- const props$12 = {
758
- tag: {
759
- type: String,
760
- default: "div"
761
- }
762
- };
763
-
764
- /** @jsxImportSource vue */
765
-
766
- const COMPONENT_NAME$1i = 'vc-clipboard';
767
- const Clipboard = /* @__PURE__ */ vue.defineComponent({
768
- name: COMPONENT_NAME$1i,
769
- props: props$12,
770
- setup(props, {
771
- slots
772
- }) {
704
+ const COMPONENT_NAME$1q = "vc-transition-slide";
705
+ const TransitionSlide = vue.defineComponent({
706
+ name: COMPONENT_NAME$1q,
707
+ props: {
708
+ ...props$1d,
709
+ mode: {
710
+ type: String,
711
+ default: "left",
712
+ validator: (v) => /^(left|right|down|up|none)(|-part)$/.test(v)
713
+ },
714
+ // inheritAttrs必须是false
715
+ style: {
716
+ type: Object,
717
+ default: () => ({
718
+ animationFillMode: "both",
719
+ animationTimingFunction: void 0
720
+ })
721
+ },
722
+ prefix: {
723
+ type: String,
724
+ default: "vc-transition-slide"
725
+ }
726
+ },
727
+ // 当不声明emits的情况下,事件存在于attrs中
728
+ inheritAttrs: false,
729
+ setup(props, { slots, attrs }) {
730
+ const { Wrapper, listeners, classes } = useTransition();
773
731
  return () => {
774
- return vue.createVNode("div", {
775
- "class": "vc-clipboard"
776
- }, [slots?.default?.()]);
732
+ return vue.h(
733
+ Wrapper.value,
734
+ {
735
+ ...attrs,
736
+ ...listeners,
737
+ ...classes.value,
738
+ tag: props.tag
739
+ },
740
+ slots
741
+ );
777
742
  };
778
743
  }
779
744
  });
780
745
 
781
- const MClipboard = Clipboard;
782
-
783
- const props$11 = {
784
- tag: {
785
- type: String,
786
- default: "div"
787
- }
788
- };
789
-
790
- /** @jsxImportSource vue */
791
-
792
- const COMPONENT_NAME$1h = 'vc-collapse';
793
- const Collapse = /* @__PURE__ */ vue.defineComponent({
794
- name: COMPONENT_NAME$1h,
795
- props: props$11,
796
- setup(props, {
797
- slots
798
- }) {
746
+ const COMPONENT_NAME$1p = "vc-transition-zoom";
747
+ const TransitionZoom = vue.defineComponent({
748
+ name: COMPONENT_NAME$1p,
749
+ props: {
750
+ ...props$1d,
751
+ mode: {
752
+ type: String,
753
+ default: "x",
754
+ validator: (v) => /^(x|y|center|none)$/.test(v)
755
+ },
756
+ // inheritAttrs必须是false
757
+ style: {
758
+ type: Object,
759
+ default: () => ({
760
+ animationFillMode: "both",
761
+ animationTimingFunction: void 0
762
+ })
763
+ },
764
+ prefix: {
765
+ type: String,
766
+ default: "vc-transition-zoom"
767
+ }
768
+ },
769
+ // 当不声明emits的情况下,事件存在于attrs中
770
+ inheritAttrs: false,
771
+ setup(props, { slots, attrs }) {
772
+ const { Wrapper, listeners, classes } = useTransition();
799
773
  return () => {
800
- return vue.createVNode("div", {
801
- "class": "vc-collapse"
802
- }, [slots?.default?.()]);
774
+ return vue.h(
775
+ Wrapper.value,
776
+ {
777
+ ...attrs,
778
+ ...listeners,
779
+ ...classes.value,
780
+ tag: props.tag
781
+ },
782
+ slots
783
+ );
803
784
  };
804
785
  }
805
786
  });
806
787
 
807
- const MCollapse = Collapse;
808
-
809
- const props$10 = {
810
- tag: {
811
- type: String,
812
- default: "div"
813
- }
814
- };
815
-
816
788
  /** @jsxImportSource vue */
817
789
 
818
- const COMPONENT_NAME$1g = 'vc-color-picker';
819
- const ColorPicker = /* @__PURE__ */ vue.defineComponent({
820
- name: COMPONENT_NAME$1g,
821
- props: props$10,
790
+ const COMPONENT_NAME$1o = 'vc-alert';
791
+
792
+ // [color, borderColor, backgroundColor], -> CSS
793
+ const THEME_MAP = {
794
+ info: ['#5495f6', '#91d5ff', '#e6f7ff'],
795
+ success: ['#52c41a', '#b7eb8f', '#f6ffed'],
796
+ error: ['#ed4014', '#ffb08f', '#fbe9e9'],
797
+ warning: ['#ffbf00', '#ffe58f', '#fffbe6']
798
+ };
799
+ const Alert = /* @__PURE__ */ vue.defineComponent({
800
+ name: COMPONENT_NAME$1o,
801
+ props: props$1f,
822
802
  setup(props, {
823
- slots
803
+ slots,
804
+ emit
824
805
  }) {
806
+ const isActive = vue.ref(false);
807
+ const showIcon = vue.computed(() => props.icon !== false);
808
+ const containerStyle = vue.computed(() => {
809
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
810
+ const [_, borderColor, backgroundColor] = THEME_MAP[props.type];
811
+ return {
812
+ borderColor,
813
+ backgroundColor
814
+ };
815
+ });
816
+ const iconStyle = vue.computed(() => {
817
+ const [color] = THEME_MAP[props.type];
818
+ return {
819
+ color
820
+ };
821
+ });
822
+ const titleStyle = vue.computed(() => {
823
+ const [color] = THEME_MAP[props.type];
824
+ return props.desc || slots.desc ? {
825
+ marginBottom: '5px',
826
+ fontSize: '14px',
827
+ color
828
+ } : {};
829
+ });
830
+ const descStyle = vue.computed(() => {
831
+ const [color] = THEME_MAP[props.type];
832
+ return {
833
+ color,
834
+ opacity: '.7'
835
+ };
836
+ });
837
+ const iconType = vue.computed(() => {
838
+ return typeof props.icon === 'string' && props.icon ? props.icon : props.type;
839
+ });
840
+ const handleClose = () => {
841
+ isActive.value = false;
842
+ emit('close');
843
+ emit('update:modelValue', false);
844
+ emit('visible-change', false);
845
+ };
846
+ vue.watch(() => props.modelValue, v => {
847
+ isActive.value = v;
848
+ }, {
849
+ immediate: true
850
+ });
825
851
  return () => {
826
- return vue.createVNode("div", {
827
- "class": "vc-color-picker"
828
- }, [slots?.default?.()]);
852
+ return vue.createVNode(TransitionFade, null, {
853
+ default: () => [isActive.value && vue.createVNode("div", {
854
+ "class": [`is-${props.type}`, {
855
+ 'has-icon': showIcon.value,
856
+ 'has-desc': props.desc || slots.desc
857
+ }, 'vc-alert'],
858
+ "style": containerStyle.value
859
+ }, [showIcon.value && vue.createVNode(Icon, {
860
+ "type": iconType.value,
861
+ "style": iconStyle.value,
862
+ "class": "vc-alert__icon"
863
+ }, null), vue.createVNode("div", {
864
+ "class": "vc-alert__content"
865
+ }, [vue.createVNode("div", {
866
+ "class": "vc-alert__message"
867
+ }, [props.title ? vue.createVNode("div", {
868
+ "style": titleStyle.value,
869
+ "innerHTML": props.title
870
+ }, null) : vue.createVNode("div", {
871
+ "style": titleStyle.value
872
+ }, [slots?.default?.()]), props.desc ? vue.createVNode("div", {
873
+ "style": descStyle.value,
874
+ "innerHTML": props.desc
875
+ }, null) : slots.desc && vue.createVNode("div", {
876
+ "style": descStyle.value
877
+ }, [slots.desc?.()])]), props.closable && vue.createVNode("div", {
878
+ "class": "vc-alert__close",
879
+ "onClick": handleClose
880
+ }, [slots.close ? slots.close() : vue.createVNode(Icon, {
881
+ "type": "close"
882
+ }, null)])])])]
883
+ });
829
884
  };
830
885
  }
831
886
  });
832
887
 
833
- const MColorPicker = ColorPicker;
888
+ const MAlert = Alert;
834
889
 
835
- const props$$ = {
890
+ const props$1c = {
836
891
  tag: {
837
892
  type: String,
838
893
  default: "div"
@@ -841,96 +896,284 @@ const props$$ = {
841
896
 
842
897
  /** @jsxImportSource vue */
843
898
 
844
- const COMPONENT_NAME$1f = 'vc-countdown';
845
- const Countdown = /* @__PURE__ */ vue.defineComponent({
846
- name: COMPONENT_NAME$1f,
847
- props: props$$,
899
+ const COMPONENT_NAME$1n = 'vc-artboard';
900
+ const Artboard = /* @__PURE__ */ vue.defineComponent({
901
+ name: COMPONENT_NAME$1n,
902
+ props: props$1c,
848
903
  setup(props, {
849
904
  slots
850
905
  }) {
851
906
  return () => {
852
907
  return vue.createVNode("div", {
853
- "class": "vc-countdown"
908
+ "class": "vc-artboard"
854
909
  }, [slots?.default?.()]);
855
910
  };
856
911
  }
857
912
  });
858
913
 
859
- const MCountdown = Countdown;
860
-
861
- const props$_ = {
862
- render: {
863
- type: Function,
864
- default: () => null
865
- }
866
- };
867
-
868
- const COMPONENT_NAME$1e = "vc-customer";
869
- const Customer = vue.defineComponent({
870
- name: COMPONENT_NAME$1e,
871
- props: props$_,
872
- setup(props, context) {
873
- return () => vue.h(() => {
874
- return props.render(context.attrs, context);
875
- });
876
- }
877
- });
878
-
879
- const MCustomer = Customer;
914
+ const MArtboard = Artboard;
880
915
 
881
- const props$Z = {
882
- tag: {
916
+ const props$1b = {
917
+ size: {
918
+ type: Number,
919
+ default: 28
920
+ },
921
+ foreground: {
883
922
  type: String,
884
- default: "div"
923
+ default: "#ccc"
924
+ },
925
+ background: {
926
+ type: String,
927
+ default: "var(--vc-color-primary)"
928
+ },
929
+ /**
930
+ * 待开发
931
+ */
932
+ fixed: {
933
+ type: Boolean,
934
+ default: false
885
935
  }
886
936
  };
887
937
 
888
938
  /** @jsxImportSource vue */
889
939
 
890
- const COMPONENT_NAME$1d = 'vc-date-picker';
891
- const DatePicker = /* @__PURE__ */ vue.defineComponent({
892
- name: COMPONENT_NAME$1d,
893
- props: props$Z,
940
+ const COMPONENT_NAME$1m = 'vc-spin';
941
+ const Spin = /* @__PURE__ */ vue.defineComponent({
942
+ name: COMPONENT_NAME$1m,
943
+ props: props$1b,
894
944
  setup(props, {
895
945
  slots
896
946
  }) {
897
947
  return () => {
898
948
  return vue.createVNode("div", {
899
- "class": "vc-date-picker"
900
- }, [slots?.default?.()]);
949
+ "class": "vc-spin"
950
+ }, [vue.createVNode("span", {
951
+ "style": {
952
+ fontSize: `${props.size}px`
953
+ }
954
+ }, [slots?.loading?.() || vue.createVNode("svg", {
955
+ "xmlns": "http://www.w3.org/2000/svg",
956
+ "version": "1.1",
957
+ "viewBox": "0 0 32 32",
958
+ "width": "100%",
959
+ "height": "100%"
960
+ }, [vue.createVNode("path", {
961
+ "stroke": props.foreground,
962
+ "d": "M 16 2 A 14 14 0 1 0 30 15",
963
+ "fill": "none",
964
+ "stroke-width": "2",
965
+ "stroke-linecap": "round"
966
+ }, null), vue.createVNode("path", {
967
+ "stroke": props.background,
968
+ "d": "M 16 2 A 14 14 0 0 1 30 15",
969
+ "fill": "none",
970
+ "stroke-width": "2",
971
+ "stroke-linecap": "round"
972
+ }, null)])]), slots?.default?.()]);
901
973
  };
902
974
  }
903
975
  });
904
976
 
905
- const MDatePicker = DatePicker;
906
-
907
- const props$Y = {
977
+ const props$1a = {
978
+ wait: {
979
+ type: Number,
980
+ default: 250
981
+ },
908
982
  tag: {
909
- type: String,
983
+ type: [String, Object],
910
984
  default: "div"
911
- }
985
+ },
986
+ include: {
987
+ type: RegExp,
988
+ default: () => /^on([A-Z])/
989
+ },
990
+ exclude: RegExp
912
991
  };
913
992
 
914
- /** @jsxImportSource vue */
993
+ const COMPONENT_NAME$1l = "vc-debounce";
994
+ const Debounce = vue.defineComponent({
995
+ name: COMPONENT_NAME$1l,
996
+ props: props$1a,
997
+ /**
998
+ * 不声明emits使得事件被透传放入attrs中, 这样可以让所有的事件透传
999
+ * 如事件onClick
1000
+ * 当inheritAttrs为true时:因为emits为声明onClick会覆盖到`props.tag`上,使得我们重写的onClick无效
1001
+ * 当inheritAttrs为false时: 透传的onClick不会被重载,这样我们就可以重写onClick
1002
+ */
1003
+ inheritAttrs: false,
1004
+ setup(props, { slots, attrs }) {
1005
+ const listener = vue.ref({});
1006
+ vue.watch(
1007
+ [() => props.wait, () => props.exclude, () => props.include],
1008
+ () => {
1009
+ const { wait, exclude, include } = props;
1010
+ const ons = Object.entries(attrs).reduce((pre, [key, callback]) => {
1011
+ /* istanbul ignore else -- @preserve */
1012
+ if ((!exclude || !exclude.test(key)) && (!include || include.test(key)) && typeof callback === "function") {
1013
+ pre[key] = lodashEs.debounce(callback, wait, {
1014
+ leading: true,
1015
+ trailing: false
1016
+ });
1017
+ }
1018
+ return pre;
1019
+ }, {});
1020
+ if (Object.keys(listener.value).length !== Object.keys(ons).length) {
1021
+ listener.value = ons;
1022
+ }
1023
+ },
1024
+ {
1025
+ immediate: true
1026
+ }
1027
+ );
1028
+ return () => {
1029
+ return vue.h(props.tag, {
1030
+ ...attrs,
1031
+ ...listener.value
1032
+ }, slots.default?.());
1033
+ };
1034
+ }
1035
+ });
915
1036
 
916
- const COMPONENT_NAME$1c = 'vc-divider';
917
- const Divider = /* @__PURE__ */ vue.defineComponent({
918
- name: COMPONENT_NAME$1c,
919
- props: props$Y,
1037
+ const props$19 = {
1038
+ tag: {
1039
+ type: String,
1040
+ default: "button"
1041
+ },
1042
+ type: {
1043
+ type: String,
1044
+ default: "default"
1045
+ },
1046
+ size: {
1047
+ type: String,
1048
+ default: "medium"
1049
+ },
1050
+ wait: {
1051
+ type: Number,
1052
+ default: 250
1053
+ },
1054
+ icon: String,
1055
+ disabled: Boolean,
1056
+ circle: Boolean,
1057
+ round: Boolean,
1058
+ long: Boolean,
1059
+ htmlType: {
1060
+ type: String,
1061
+ default: "button"
1062
+ }
1063
+ };
1064
+
1065
+ /** @jsxImportSource vue */
1066
+
1067
+ const COMPONENT_NAME$1k = 'vc-button';
1068
+ const Button = /* @__PURE__ */ vue.defineComponent({
1069
+ name: COMPONENT_NAME$1k,
1070
+ emits: ['click'],
1071
+ props: props$19,
920
1072
  setup(props, {
921
1073
  slots
922
1074
  }) {
1075
+ const vm = vue.getCurrentInstance();
1076
+ const hasSlot = vue.ref(true);
1077
+ const isLoading = vue.ref(false);
1078
+ const group = vue.inject('button-group', {
1079
+ size: 'medium',
1080
+ vertical: false,
1081
+ circle: false
1082
+ });
1083
+ const classes = vue.computed(() => ({
1084
+ 'is-circle': props.circle || group.circle,
1085
+ 'is-alone': !hasSlot.value,
1086
+ 'is-round': props.round,
1087
+ 'is-long': props.long,
1088
+ 'is-disabled': props.disabled,
1089
+ [`is-${props.size}`]: true,
1090
+ [`is-${props.type}`]: true
1091
+ }));
1092
+ const handleClick = (...args) => {
1093
+ const fn = vm.vnode.props?.['onClick']?.(...args);
1094
+ if (fn && fn.then) {
1095
+ isLoading.value = true;
1096
+ fn.finally(() => {
1097
+ isLoading.value = false;
1098
+ });
1099
+ }
1100
+ };
1101
+ vue.onMounted(() => {
1102
+ hasSlot.value = slots.default !== undefined;
1103
+ });
923
1104
  return () => {
924
- return vue.createVNode("div", {
925
- "class": "vc-divider"
1105
+ return vue.createVNode(Debounce, {
1106
+ "tag": props.tag,
1107
+ "class": {
1108
+ 'vc-button': true,
1109
+ ...classes.value
1110
+ },
1111
+ "wait": props.wait,
1112
+ "disabled": props.disabled,
1113
+ "type": props.htmlType,
1114
+ "onClick": handleClick
1115
+ }, {
1116
+ default: () => [props.icon && vue.createVNode(Icon, {
1117
+ "type": props.icon
1118
+ }, null), isLoading.value && vue.createVNode(Spin, {
1119
+ "size": 12,
1120
+ "foreground": props.type === 'default' ? '#ccc' : '#fff',
1121
+ "class": "vc-button__loading"
1122
+ }, null), hasSlot.value && vue.createVNode("span", null, [slots?.default?.()])]
1123
+ });
1124
+ };
1125
+ }
1126
+ });
1127
+
1128
+ const props$18 = {
1129
+ vertical: {
1130
+ type: Boolean,
1131
+ default: false
1132
+ },
1133
+ circle: {
1134
+ type: Boolean,
1135
+ default: false
1136
+ },
1137
+ size: {
1138
+ type: String,
1139
+ default: "medium"
1140
+ },
1141
+ fragment: {
1142
+ type: Boolean,
1143
+ default: false
1144
+ }
1145
+ };
1146
+
1147
+ /** @jsxImportSource vue */
1148
+
1149
+ const COMPONENT_NAME$1j = 'vc-button-group';
1150
+ const ButtonGroup = /* @__PURE__ */ vue.defineComponent({
1151
+ name: COMPONENT_NAME$1j,
1152
+ props: props$18,
1153
+ setup(props, {
1154
+ slots
1155
+ }) {
1156
+ vue.provide('button-group', props);
1157
+ const classes = vue.computed(() => ({
1158
+ 'is-vertical': props.vertical,
1159
+ 'is-circle': props.circle,
1160
+ [`is-${props.size}`]: !!props.size
1161
+ }));
1162
+ return () => {
1163
+ return props.fragment ? slots?.default?.() : vue.createVNode("div", {
1164
+ "class": {
1165
+ 'vc-button-group': true,
1166
+ ...classes.value
1167
+ }
926
1168
  }, [slots?.default?.()]);
927
1169
  };
928
1170
  }
929
1171
  });
930
1172
 
931
- const MDivider = Divider;
1173
+ const MButton = Button;
1174
+ const MButtonGroup = ButtonGroup;
932
1175
 
933
- const props$X = {
1176
+ const props$17 = {
934
1177
  tag: {
935
1178
  type: String,
936
1179
  default: "div"
@@ -939,24 +1182,76 @@ const props$X = {
939
1182
 
940
1183
  /** @jsxImportSource vue */
941
1184
 
942
- const COMPONENT_NAME$1b = 'vc-drawer';
943
- const Drawer = /* @__PURE__ */ vue.defineComponent({
944
- name: COMPONENT_NAME$1b,
945
- props: props$X,
1185
+ const COMPONENT_NAME$1i = 'vc-calendar';
1186
+ const Calendar = /* @__PURE__ */ vue.defineComponent({
1187
+ name: COMPONENT_NAME$1i,
1188
+ props: props$17,
946
1189
  setup(props, {
947
1190
  slots
948
1191
  }) {
949
1192
  return () => {
950
1193
  return vue.createVNode("div", {
951
- "class": "vc-drawer"
1194
+ "class": "vc-calendar"
952
1195
  }, [slots?.default?.()]);
953
1196
  };
954
1197
  }
955
1198
  });
956
1199
 
957
- const MDrawer = Drawer;
1200
+ const MCalendar = Calendar;
958
1201
 
959
- const props$W = {
1202
+ const props$16 = {
1203
+ border: {
1204
+ type: Boolean,
1205
+ default: true
1206
+ },
1207
+ shadow: {
1208
+ type: Boolean,
1209
+ default: false
1210
+ },
1211
+ padding: {
1212
+ type: Number,
1213
+ default: 16
1214
+ },
1215
+ title: {
1216
+ type: String
1217
+ },
1218
+ icon: {
1219
+ type: String
1220
+ }
1221
+ };
1222
+
1223
+ /** @jsxImportSource vue */
1224
+
1225
+ const COMPONENT_NAME$1h = 'vc-card';
1226
+ const Card = /* @__PURE__ */ vue.defineComponent({
1227
+ name: COMPONENT_NAME$1h,
1228
+ props: props$16,
1229
+ setup(props, {
1230
+ slots
1231
+ }) {
1232
+ return () => {
1233
+ return vue.createVNode("div", {
1234
+ "class": [{
1235
+ 'is-border': props.border,
1236
+ 'is-shadow': props.shadow
1237
+ }, 'vc-card']
1238
+ }, [(props.title || slots.title) && vue.createVNode("div", {
1239
+ "class": "vc-card__header"
1240
+ }, [slots.title ? slots.title?.() : props.title && vue.createVNode("p", null, [props.icon && vue.createVNode(Icon, {
1241
+ "type": props.icon
1242
+ }, null), vue.createVNode("span", null, [props.title])])]), slots.extra && vue.createVNode("div", {
1243
+ "class": "vc-card__extra"
1244
+ }, [slots.extra?.()]), vue.createVNode("div", {
1245
+ "style": `padding: ${props.padding}px`,
1246
+ "class": "vc-card__body"
1247
+ }, [slots.default?.()])]);
1248
+ };
1249
+ }
1250
+ });
1251
+
1252
+ const MCard = Card;
1253
+
1254
+ const props$15 = {
960
1255
  tag: {
961
1256
  type: String,
962
1257
  default: "div"
@@ -965,24 +1260,24 @@ const props$W = {
965
1260
 
966
1261
  /** @jsxImportSource vue */
967
1262
 
968
- const COMPONENT_NAME$1a = 'vc-dropdown';
969
- const Dropdown = /* @__PURE__ */ vue.defineComponent({
970
- name: COMPONENT_NAME$1a,
971
- props: props$W,
1263
+ const COMPONENT_NAME$1g = 'vc-carousel';
1264
+ const Carousel = /* @__PURE__ */ vue.defineComponent({
1265
+ name: COMPONENT_NAME$1g,
1266
+ props: props$15,
972
1267
  setup(props, {
973
1268
  slots
974
1269
  }) {
975
1270
  return () => {
976
1271
  return vue.createVNode("div", {
977
- "class": "vc-dropdown"
1272
+ "class": "vc-carousel"
978
1273
  }, [slots?.default?.()]);
979
1274
  };
980
1275
  }
981
1276
  });
982
1277
 
983
- const MDropdown = Dropdown;
1278
+ const MCarousel = Carousel;
984
1279
 
985
- const props$V = {
1280
+ const props$14 = {
986
1281
  tag: {
987
1282
  type: String,
988
1283
  default: "div"
@@ -991,24 +1286,24 @@ const props$V = {
991
1286
 
992
1287
  /** @jsxImportSource vue */
993
1288
 
994
- const COMPONENT_NAME$19 = 'vc-editor';
995
- const Editor = /* @__PURE__ */ vue.defineComponent({
996
- name: COMPONENT_NAME$19,
997
- props: props$V,
1289
+ const COMPONENT_NAME$1f = 'vc-cascader';
1290
+ const Cascader = /* @__PURE__ */ vue.defineComponent({
1291
+ name: COMPONENT_NAME$1f,
1292
+ props: props$14,
998
1293
  setup(props, {
999
1294
  slots
1000
1295
  }) {
1001
1296
  return () => {
1002
1297
  return vue.createVNode("div", {
1003
- "class": "vc-editor"
1298
+ "class": "vc-cascader"
1004
1299
  }, [slots?.default?.()]);
1005
1300
  };
1006
1301
  }
1007
1302
  });
1008
1303
 
1009
- const MEditor = Editor;
1304
+ const MCascader = Cascader;
1010
1305
 
1011
- const props$U = {
1306
+ const props$13 = {
1012
1307
  tag: {
1013
1308
  type: String,
1014
1309
  default: "div"
@@ -1017,767 +1312,468 @@ const props$U = {
1017
1312
 
1018
1313
  /** @jsxImportSource vue */
1019
1314
 
1020
- const COMPONENT_NAME$18 = 'vc-expand';
1021
- const Expand = /* @__PURE__ */ vue.defineComponent({
1022
- name: COMPONENT_NAME$18,
1023
- props: props$U,
1315
+ const COMPONENT_NAME$1e = 'vc-chart';
1316
+ const Chart = /* @__PURE__ */ vue.defineComponent({
1317
+ name: COMPONENT_NAME$1e,
1318
+ props: props$13,
1024
1319
  setup(props, {
1025
1320
  slots
1026
1321
  }) {
1027
1322
  return () => {
1028
1323
  return vue.createVNode("div", {
1029
- "class": "vc-expand"
1324
+ "class": "vc-chart"
1030
1325
  }, [slots?.default?.()]);
1031
1326
  };
1032
1327
  }
1033
1328
  });
1034
1329
 
1035
- const MExpand = Expand;
1330
+ const MChart = Chart;
1036
1331
 
1037
- const props$T = {
1332
+ const props$12 = {
1038
1333
  tag: {
1039
1334
  type: String,
1040
- default: "form"
1041
- },
1042
- model: {
1043
- type: Object
1044
- },
1045
- rules: {
1046
- type: Object
1047
- },
1048
- labelWidth: {
1049
- type: Number
1050
- },
1051
- showMessage: {
1052
- type: Boolean,
1053
- default: true
1054
- },
1055
- inline: {
1056
- type: Boolean,
1057
- default: false
1058
- },
1059
- labelPosition: {
1060
- type: String,
1061
- default: "right"
1062
- },
1063
- autocomplete: {
1064
- type: String,
1065
- default: "off"
1066
- },
1067
- styleless: {
1068
- type: Boolean,
1069
- default: false
1335
+ default: "div"
1070
1336
  }
1071
1337
  };
1072
1338
 
1073
- const useForm = (expose, options = {}) => {
1074
- const instance = vue.getCurrentInstance();
1075
- const props = instance.props;
1076
- const fields = [];
1077
- vue.provide("form", {
1078
- props,
1079
- add: (field) => {
1080
- field && fields.push(field);
1081
- },
1082
- remove: (field) => {
1083
- field && fields.splice(fields.indexOf(field), 1);
1084
- }
1085
- });
1086
- const filterFields = (fields$) => {
1087
- return !fields$ ? fields : fields.filter((item) => fields$.includes(item.props.prop));
1088
- };
1089
- const getField = (prop) => {
1090
- const field = fields.find((item) => item.props.prop === prop);
1091
- if (!field) throw new VcError("form", "请选择有用的prop值");
1092
- return field;
1093
- };
1094
- const showToast = (msg) => {
1095
- props.showMessage && options.throwToast?.(msg);
1096
- };
1097
- const sortErrors = async (errors) => {
1098
- const positions = await Promise.all(fields.map((item) => item.exposed.getPosition()));
1099
- try {
1100
- return [...errors].toSorted((a, b) => {
1101
- const aIndex = fields.findIndex((i) => i.props.prop === a.prop);
1102
- const bIndex = fields.findIndex((i) => i.props.prop === b.prop);
1103
- const aPosition = positions[aIndex];
1104
- const bPosition = positions[bIndex];
1105
- if (aPosition.top != bPosition.top) return aPosition.top - bPosition.top;
1106
- return aPosition.left - bPosition.left;
1107
- });
1108
- } catch (e) {
1109
- return errors;
1110
- }
1111
- };
1112
- const scrollIntoView = (prop) => {
1113
- const field = getField(prop);
1114
- field.vnode?.el?.scrollIntoView?.({
1115
- behavior: "smooth",
1116
- block: "center"
1117
- });
1118
- };
1119
- const reset = (options$ = {}) => {
1120
- const { fields: fields$, original = {} } = options$;
1121
- filterFields(fields$).forEach((field) => {
1122
- let v;
1123
- try {
1124
- v = Utils.getPropByPath(original, field.props.prop).v;
1125
- } catch (e) {
1126
- }
1127
- field.exposed.reset(v);
1128
- });
1129
- };
1130
- const validate = async (options$ = {}) => {
1131
- const { scroll = true, fields: fields$ } = options$;
1132
- if (!fields.length) {
1133
- return;
1134
- }
1135
- const results = await Promise.allSettled(
1136
- filterFields(fields$).map((item) => item.exposed.validate(""))
1137
- );
1138
- const originErrors = results.filter((i) => i.status === "rejected").map((i) => i.reason);
1139
- if (!originErrors.length) return;
1140
- const errors = await sortErrors(originErrors);
1141
- showToast(errors[0].msg || errors[0].message);
1142
- scroll && scrollIntoView(errors[0].prop);
1143
- throw errors;
1144
- };
1145
- const validateField = async (prop, options$ = {}) => {
1146
- try {
1147
- await validate({
1148
- ...options$,
1149
- fields: [prop]
1150
- });
1151
- } catch (e) {
1152
- throw e[0];
1153
- }
1154
- };
1155
- expose({
1156
- reset,
1157
- validate,
1158
- // 单个操作
1159
- getField,
1160
- validateField
1161
- });
1162
- };
1339
+ /** @jsxImportSource vue */
1163
1340
 
1164
- const COMPONENT_NAME$17 = "vc-form";
1165
- const Form = vue.defineComponent({
1166
- name: COMPONENT_NAME$17,
1167
- props: props$T,
1168
- setup(props, { slots, expose }) {
1169
- useForm(expose);
1341
+ const COMPONENT_NAME$1d = 'vc-checkbox';
1342
+ const Checkbox = /* @__PURE__ */ vue.defineComponent({
1343
+ name: COMPONENT_NAME$1d,
1344
+ props: props$12,
1345
+ setup(props, {
1346
+ slots
1347
+ }) {
1170
1348
  return () => {
1171
- return vue.h(
1172
- props.tag,
1173
- {
1174
- class: "vc-form",
1175
- autocomplete: props.autocomplete
1176
- },
1177
- slots
1178
- );
1349
+ return vue.createVNode("div", {
1350
+ "class": "vc-checkbox"
1351
+ }, [slots?.default?.()]);
1179
1352
  };
1180
1353
  }
1181
1354
  });
1182
1355
 
1183
- const props$S = {
1184
- label: {
1185
- type: String,
1186
- default: ""
1187
- },
1188
- labelWidth: {
1189
- type: Number
1190
- },
1191
- prop: {
1192
- type: String
1193
- },
1194
- required: {
1195
- type: [Boolean, String],
1196
- default: false
1197
- },
1198
- error: {
1199
- type: String
1200
- },
1201
- rules: {
1202
- type: [Array, Object]
1203
- },
1204
- resetByRulesChanged: {
1205
- type: Boolean,
1206
- default: false
1207
- },
1208
- showMessage: {
1209
- type: Boolean,
1210
- default: true
1211
- },
1212
- labelFor: {
1213
- type: String
1214
- },
1215
- styleless: {
1216
- type: Boolean,
1217
- default: false
1218
- },
1219
- labelPosition: {
1356
+ const MCheckbox = Checkbox;
1357
+
1358
+ const props$11 = {
1359
+ tag: {
1220
1360
  type: String,
1221
- default: "right"
1222
- },
1223
- contentStyle: String
1361
+ default: "div"
1362
+ }
1224
1363
  };
1225
1364
 
1226
- const filterEmpty = (val) => {
1227
- if (val instanceof Array) {
1228
- val = val.filter((i) => i !== "");
1365
+ /** @jsxImportSource vue */
1366
+
1367
+ const COMPONENT_NAME$1c = 'vc-clipboard';
1368
+ const Clipboard = /* @__PURE__ */ vue.defineComponent({
1369
+ name: COMPONENT_NAME$1c,
1370
+ props: props$11,
1371
+ setup(props, {
1372
+ slots
1373
+ }) {
1374
+ return () => {
1375
+ return vue.createVNode("div", {
1376
+ "class": "vc-clipboard"
1377
+ }, [slots?.default?.()]);
1378
+ };
1379
+ }
1380
+ });
1381
+
1382
+ const MClipboard = Clipboard;
1383
+
1384
+ const props$10 = {
1385
+ tag: {
1386
+ type: String,
1387
+ default: "div"
1229
1388
  }
1230
- return val;
1231
- };
1232
- const toRules = (rules) => {
1233
- return rules instanceof Array ? rules : rules ? [rules] : [];
1234
1389
  };
1235
- const useFormItem = (expose) => {
1236
- const form = vue.inject("form");
1237
- const instance = vue.getCurrentInstance();
1238
- const props = instance.props;
1239
- const { slots } = instance;
1240
- if (!form?.props) {
1241
- throw new VcError("form-item", "form-item需要在form内使用");
1390
+
1391
+ /** @jsxImportSource vue */
1392
+
1393
+ const COMPONENT_NAME$1b = 'vc-collapse';
1394
+ const Collapse = /* @__PURE__ */ vue.defineComponent({
1395
+ name: COMPONENT_NAME$1b,
1396
+ props: props$10,
1397
+ setup(props, {
1398
+ slots
1399
+ }) {
1400
+ return () => {
1401
+ return vue.createVNode("div", {
1402
+ "class": "vc-collapse"
1403
+ }, [slots?.default?.()]);
1404
+ };
1242
1405
  }
1243
- const formItem = vue.inject("form-item", {});
1244
- const validateState = vue.ref("");
1245
- const validateMessage = vue.ref("");
1246
- let validateDisabled = false;
1247
- let initialValue;
1248
- const currentRules = vue.computed(() => {
1249
- const formRules = form.props.rules;
1250
- const formItemBindRules = toRules(props.rules);
1251
- let formItemRules = formItemBindRules;
1252
- if (!formItemRules.length && formRules && props.prop) {
1253
- try {
1254
- const key = props.prop.replace(/\.[0-9]+\./g, ".");
1255
- const { v } = Utils.getPropByPath(formRules, key);
1256
- formItemRules = toRules(v);
1257
- } catch {
1258
- const rules = formRules[props.prop];
1259
- formItemRules = toRules(rules);
1260
- }
1261
- }
1262
- return formItemRules;
1263
- });
1264
- const isRequired = vue.computed(() => {
1265
- if (!currentRules.value.length) {
1266
- return !!props.required;
1267
- }
1268
- let required = false;
1269
- for (let i = 0; i < currentRules.value.length; i++) {
1270
- const rule = currentRules.value[i];
1271
- required = !!rule.required;
1272
- if (required) break;
1273
- }
1274
- return required;
1275
- });
1276
- const labelPosition = vue.computed(() => {
1277
- return props.labelPosition || form.props.labelPosition;
1278
- });
1279
- const classes = vue.computed(() => {
1280
- return {
1281
- "is-require": isRequired.value,
1282
- "is-error": validateState.value === "error",
1283
- "is-validating": validateState.value === "validating",
1284
- "is-inline": form.props.inline,
1285
- "is-nest": isNest.value,
1286
- [`is-${labelPosition.value}`]: true
1406
+ });
1407
+
1408
+ const MCollapse = Collapse;
1409
+
1410
+ const props$$ = {
1411
+ tag: {
1412
+ type: String,
1413
+ default: "div"
1414
+ }
1415
+ };
1416
+
1417
+ /** @jsxImportSource vue */
1418
+
1419
+ const COMPONENT_NAME$1a = 'vc-color-picker';
1420
+ const ColorPicker = /* @__PURE__ */ vue.defineComponent({
1421
+ name: COMPONENT_NAME$1a,
1422
+ props: props$$,
1423
+ setup(props, {
1424
+ slots
1425
+ }) {
1426
+ return () => {
1427
+ return vue.createVNode("div", {
1428
+ "class": "vc-color-picker"
1429
+ }, [slots?.default?.()]);
1287
1430
  };
1288
- });
1289
- const isNest = vue.computed(() => {
1290
- return !!formItem.change;
1291
- });
1292
- const isNestLast = vue.ref(false);
1293
- const hasLabel = vue.computed(() => {
1294
- return !!props.label || slots.label;
1295
- });
1296
- const labelStyle = vue.computed(() => {
1297
- const labelWidth = props.labelWidth === 0 || props.labelWidth ? props.labelWidth : isNest.value ? 0 : form.props.labelWidth;
1298
- return {
1299
- width: labelPosition.value !== "top" && labelWidth && labelWidth > 0 ? `${labelWidth}px` : "auto",
1300
- textAlign: labelPosition.value === "top" ? "left" : labelPosition.value
1431
+ }
1432
+ });
1433
+
1434
+ const MColorPicker = ColorPicker;
1435
+
1436
+ const props$_ = {
1437
+ tag: {
1438
+ type: String,
1439
+ default: "div"
1440
+ }
1441
+ };
1442
+
1443
+ /** @jsxImportSource vue */
1444
+
1445
+ const COMPONENT_NAME$19 = 'vc-countdown';
1446
+ const Countdown = /* @__PURE__ */ vue.defineComponent({
1447
+ name: COMPONENT_NAME$19,
1448
+ props: props$_,
1449
+ setup(props, {
1450
+ slots
1451
+ }) {
1452
+ return () => {
1453
+ return vue.createVNode("div", {
1454
+ "class": "vc-countdown"
1455
+ }, [slots?.default?.()]);
1301
1456
  };
1302
- });
1303
- const contentStyle = vue.computed(() => {
1304
- const labelWidth = props.labelWidth === 0 || props.labelWidth ? props.labelWidth : form.props.labelWidth;
1305
- return [
1306
- {
1307
- marginLeft: !hasLabel.value && isNest.value ? 0 : labelWidth && labelWidth > 0 ? `${labelWidth}px` : "unset",
1308
- marginBottom: isNest.value && !isNestLast.value ? `20px` : 0
1309
- },
1310
- props.contentStyle
1311
- ];
1312
- });
1313
- const isStyleless = vue.computed(() => {
1314
- return props.styleless || form.props.styleless;
1315
- });
1316
- const fieldValue = vue.computed(() => {
1317
- const model = form.props.model;
1318
- if (!model || !props.prop) {
1319
- return;
1320
- }
1321
- let path = props.prop;
1322
- if (path.includes(":")) {
1323
- path = path.replace(/:/, ".");
1324
- }
1325
- return Utils.getPropByPath(model, path).v;
1326
- });
1327
- const showError = vue.computed(() => {
1328
- return validateState.value === "error" && props.showMessage && form.props.showMessage;
1329
- });
1330
- vue.watch(
1331
- () => props.error,
1332
- (v) => {
1333
- validateMessage.value = v || "";
1334
- validateState.value = v === "" ? "" : "error";
1335
- }
1336
- );
1337
- const reset = (v) => {
1338
- validateState.value = "";
1339
- validateMessage.value = "";
1340
- const model = form.props.model;
1341
- if (!props.prop) return;
1342
- const { o, k } = Utils.getPropByPath(model, props.prop);
1343
- if (!k) return;
1344
- validateDisabled = true;
1345
- o[k] = v !== null && v !== void 0 ? v : Array.isArray(fieldValue.value) ? [].concat(initialValue) : initialValue;
1346
- };
1347
- const validate = async (trigger) => {
1348
- if (!props.prop) return;
1349
- let rules = currentRules.value.filter((rule) => !rule.trigger || rule.trigger.includes(trigger));
1350
- if (!rules.length) {
1351
- if (!props.required) {
1352
- return;
1353
- } else {
1354
- rules = [{
1355
- required: true,
1356
- message: typeof props.required === "string" ? props.required : void 0
1357
- }];
1358
- }
1359
- }
1360
- validateState.value = "validating";
1361
- const descriptor = {};
1362
- descriptor[props.prop] = rules;
1363
- const validator = new helperValidator.Validator(descriptor);
1364
- const model = {};
1365
- model[props.prop] = filterEmpty(fieldValue.value);
1366
- try {
1367
- await validator.validate(model, { first: false });
1368
- validateState.value = "success";
1369
- validateMessage.value = "";
1370
- } catch (errors) {
1371
- validateState.value = "error";
1372
- validateMessage.value = errors[0].message;
1373
- throw {
1374
- prop: props.prop,
1375
- message: validateMessage.value
1376
- };
1377
- }
1378
- validateDisabled = false;
1379
- };
1380
- const handleFieldBlur = () => {
1381
- if (!props.prop) {
1382
- formItem.blur?.();
1383
- return;
1384
- }
1385
- validate("blur");
1386
- };
1387
- const handleFieldChange = () => {
1388
- if (!props.prop) {
1389
- formItem.change?.();
1390
- return;
1391
- }
1392
- if (validateDisabled) {
1393
- validateDisabled = false;
1394
- return;
1395
- }
1396
- validate("change");
1397
- };
1398
- const getPosition = async () => {
1399
- let el = instance.vnode.el;
1400
- try {
1401
- while (el && !el.getBoundingClientRect) {
1402
- el = el.nextSibling;
1403
- }
1404
- ;
1405
- const rect = el.getBoundingClientRect();
1406
- return {
1407
- top: rect.top,
1408
- left: rect.left
1409
- };
1410
- } catch (e) {
1411
- throw new VcError("form-item", "form-item位置计算错误");
1412
- }
1413
- };
1414
- const fields = vue.reactive([]);
1415
- vue.provide("form-item", {
1416
- fields,
1417
- blur: handleFieldBlur,
1418
- change: handleFieldChange,
1419
- message: validateMessage,
1420
- add: (field) => {
1421
- field && fields.push(field);
1422
- },
1423
- remove: (field) => {
1424
- field && fields.splice(fields.indexOf(field), 1);
1425
- }
1426
- });
1427
- vue.onMounted(() => {
1428
- if (props.prop) {
1429
- form.add?.(instance);
1430
- initialValue = lodashEs.cloneDeep(fieldValue.value);
1431
- }
1432
- formItem.add?.(instance);
1433
- });
1434
- vue.onBeforeUnmount(() => {
1435
- form.remove?.(instance);
1436
- formItem.remove?.(instance);
1437
- });
1438
- vue.watch(
1439
- () => props.rules,
1440
- () => {
1441
- props.resetByRulesChanged && reset();
1442
- }
1443
- );
1444
- vue.watch(
1445
- () => formItem.fields?.length,
1446
- async (v) => {
1447
- if (!isNest.value || !v) return isNestLast.value = false;
1448
- const fields$ = [...vue.toRaw(formItem.fields)];
1449
- const positions = await Promise.all(fields$.map((item) => item.exposed.getPosition()));
1450
- const sortFields = fields$.toSorted((a, b) => {
1451
- const aIndex = fields$.findIndex((i) => i === a);
1452
- const bIndex = fields$.findIndex((i) => i === b);
1453
- const aPosition = positions[aIndex];
1454
- const bPosition = positions[bIndex];
1455
- if (aPosition.top != bPosition.top) return aPosition.top - bPosition.top;
1456
- return aPosition.left - bPosition.left;
1457
- });
1458
- isNestLast.value = sortFields[sortFields.length - 1] === instance;
1459
- }
1460
- );
1461
- expose({
1462
- validate,
1463
- reset,
1464
- getPosition
1465
- });
1466
- return {
1467
- isNest,
1468
- isStyleless,
1469
- isNestLast,
1470
- validateMessage,
1471
- classes,
1472
- labelStyle,
1473
- contentStyle,
1474
- showError,
1475
- labelPosition
1476
- };
1457
+ }
1458
+ });
1459
+
1460
+ const MCountdown = Countdown;
1461
+
1462
+ const props$Z = {
1463
+ render: {
1464
+ type: Function,
1465
+ default: () => null
1466
+ }
1477
1467
  };
1478
1468
 
1479
- const props$R = {
1480
- /**
1481
- * 进入/离开持续时间
1482
- * {enter: 300, leave: 300}
1483
- */
1484
- duration: {
1485
- type: [Number, Object],
1486
- default: 300
1487
- },
1488
- /**
1489
- * 进入/离开延迟时间
1490
- */
1491
- delay: {
1492
- type: [Number, Object],
1493
- default: 0
1494
- },
1495
- /**
1496
- * `transition-group` component.
1497
- */
1498
- group: Boolean,
1499
- /**
1500
- * `transition-group` tag, v3版本默认值无
1501
- */
1469
+ const COMPONENT_NAME$18 = "vc-customer";
1470
+ const Customer = vue.defineComponent({
1471
+ name: COMPONENT_NAME$18,
1472
+ props: props$Z,
1473
+ setup(props, context) {
1474
+ return () => vue.h(() => {
1475
+ return props.render(context.attrs, context);
1476
+ });
1477
+ }
1478
+ });
1479
+
1480
+ const MCustomer = Customer;
1481
+
1482
+ const props$Y = {
1502
1483
  tag: {
1503
1484
  type: String,
1504
- default: void 0
1505
- },
1506
- /**
1507
- * 变换的初始位置, 可以用style代替, 更短~~
1508
- */
1509
- origin: {
1485
+ default: "div"
1486
+ }
1487
+ };
1488
+
1489
+ /** @jsxImportSource vue */
1490
+
1491
+ const COMPONENT_NAME$17 = 'vc-date-picker';
1492
+ const DatePicker = /* @__PURE__ */ vue.defineComponent({
1493
+ name: COMPONENT_NAME$17,
1494
+ props: props$Y,
1495
+ setup(props, {
1496
+ slots
1497
+ }) {
1498
+ return () => {
1499
+ return vue.createVNode("div", {
1500
+ "class": "vc-date-picker"
1501
+ }, [slots?.default?.()]);
1502
+ };
1503
+ }
1504
+ });
1505
+
1506
+ const MDatePicker = DatePicker;
1507
+
1508
+ const props$X = {
1509
+ tag: {
1510
1510
  type: String,
1511
- default: ""
1511
+ default: "div"
1512
+ }
1513
+ };
1514
+
1515
+ /** @jsxImportSource vue */
1516
+
1517
+ const COMPONENT_NAME$16 = 'vc-divider';
1518
+ const Divider = /* @__PURE__ */ vue.defineComponent({
1519
+ name: COMPONENT_NAME$16,
1520
+ props: props$X,
1521
+ setup(props, {
1522
+ slots
1523
+ }) {
1524
+ return () => {
1525
+ return vue.createVNode("div", {
1526
+ "class": "vc-divider"
1527
+ }, [slots?.default?.()]);
1528
+ };
1529
+ }
1530
+ });
1531
+
1532
+ const MDivider = Divider;
1533
+
1534
+ const props$W = {
1535
+ tag: {
1536
+ type: String,
1537
+ default: "div"
1538
+ }
1539
+ };
1540
+
1541
+ /** @jsxImportSource vue */
1542
+
1543
+ const COMPONENT_NAME$15 = 'vc-drawer';
1544
+ const Drawer = /* @__PURE__ */ vue.defineComponent({
1545
+ name: COMPONENT_NAME$15,
1546
+ props: props$W,
1547
+ setup(props, {
1548
+ slots
1549
+ }) {
1550
+ return () => {
1551
+ return vue.createVNode("div", {
1552
+ "class": "vc-drawer"
1553
+ }, [slots?.default?.()]);
1554
+ };
1555
+ }
1556
+ });
1557
+
1558
+ const MDrawer = Drawer;
1559
+
1560
+ const props$V = {
1561
+ tag: {
1562
+ type: String,
1563
+ default: "div"
1564
+ }
1565
+ };
1566
+
1567
+ /** @jsxImportSource vue */
1568
+
1569
+ const COMPONENT_NAME$14 = 'vc-dropdown';
1570
+ const Dropdown = /* @__PURE__ */ vue.defineComponent({
1571
+ name: COMPONENT_NAME$14,
1572
+ props: props$V,
1573
+ setup(props, {
1574
+ slots
1575
+ }) {
1576
+ return () => {
1577
+ return vue.createVNode("div", {
1578
+ "class": "vc-dropdown"
1579
+ }, [slots?.default?.()]);
1580
+ };
1581
+ }
1582
+ });
1583
+
1584
+ const MDropdown = Dropdown;
1585
+
1586
+ const props$U = {
1587
+ tag: {
1588
+ type: String,
1589
+ default: "div"
1590
+ }
1591
+ };
1592
+
1593
+ /** @jsxImportSource vue */
1594
+
1595
+ const COMPONENT_NAME$13 = 'vc-editor';
1596
+ const Editor = /* @__PURE__ */ vue.defineComponent({
1597
+ name: COMPONENT_NAME$13,
1598
+ props: props$U,
1599
+ setup(props, {
1600
+ slots
1601
+ }) {
1602
+ return () => {
1603
+ return vue.createVNode("div", {
1604
+ "class": "vc-editor"
1605
+ }, [slots?.default?.()]);
1606
+ };
1607
+ }
1608
+ });
1609
+
1610
+ const MEditor = Editor;
1611
+
1612
+ const props$T = {
1613
+ tag: {
1614
+ type: String,
1615
+ default: "div"
1616
+ }
1617
+ };
1618
+
1619
+ /** @jsxImportSource vue */
1620
+
1621
+ const COMPONENT_NAME$12 = 'vc-expand';
1622
+ const Expand = /* @__PURE__ */ vue.defineComponent({
1623
+ name: COMPONENT_NAME$12,
1624
+ props: props$T,
1625
+ setup(props, {
1626
+ slots
1627
+ }) {
1628
+ return () => {
1629
+ return vue.createVNode("div", {
1630
+ "class": "vc-expand"
1631
+ }, [slots?.default?.()]);
1632
+ };
1633
+ }
1634
+ });
1635
+
1636
+ const MExpand = Expand;
1637
+
1638
+ const props$S = {
1639
+ tag: {
1640
+ type: String,
1641
+ default: "form"
1512
1642
  },
1513
- /**
1514
- * 在转换期间应用的元素样式。这些样式应用于@beforeEnter和@beforeLeave钩子
1515
- * inheritAttrs必须是false
1516
- */
1517
- style: {
1518
- type: Object,
1519
- default: () => {
1520
- return {
1521
- animationFillMode: "both",
1522
- animationTimingFunction: "ease-out"
1523
- };
1524
- }
1643
+ model: {
1644
+ type: Object
1525
1645
  },
1526
- prefix: {
1646
+ rules: {
1647
+ type: Object
1648
+ },
1649
+ labelWidth: {
1650
+ type: Number
1651
+ },
1652
+ showMessage: {
1653
+ type: Boolean,
1654
+ default: true
1655
+ },
1656
+ inline: {
1657
+ type: Boolean,
1658
+ default: false
1659
+ },
1660
+ labelPosition: {
1527
1661
  type: String,
1528
- default: "vc-transition"
1662
+ default: "right"
1529
1663
  },
1530
- mode: {
1664
+ autocomplete: {
1531
1665
  type: String,
1532
- default: "none"
1666
+ default: "off"
1667
+ },
1668
+ styleless: {
1669
+ type: Boolean,
1670
+ default: false
1533
1671
  }
1534
1672
  };
1535
-
1536
- const trim = (str) => str.trim().replace(/\s+/g, " ");
1537
- const useTransition = () => {
1673
+
1674
+ const useForm = (expose, options = {}) => {
1538
1675
  const instance = vue.getCurrentInstance();
1539
- const attrs = instance.attrs;
1540
1676
  const props = instance.props;
1541
- const Wrapper = vue.computed(() => {
1542
- return props.group ? vue.TransitionGroup : vue.Transition;
1543
- });
1544
- const classes = vue.computed(() => {
1545
- const modeClass = props.mode !== "none" ? `is-${props.mode.replace(/-/g, " is-")}` : "";
1546
- return {
1547
- enterActiveClass: trim(`${attrs.enterActiveClass || ""} ${props.prefix} ${modeClass} is-in`),
1548
- leaveActiveClass: trim(`${attrs.leaveActiveClass || ""} ${props.prefix} ${modeClass} is-out`),
1549
- moveClass: props.group ? trim(`${attrs.moveClass || ""} ${props.prefix} ${modeClass} is-move`) : void 0
1550
- };
1551
- });
1552
- const clearStyles = (el) => {
1553
- Object.keys(props.style).forEach((key) => {
1554
- const v = props.style[key];
1555
- v && el.style.removeProperty(
1556
- key.replace(/([A-Z])/g, "-$1").toLowerCase()
1557
- );
1558
- });
1559
- el.style.removeProperty("animation-duration");
1560
- el.style.removeProperty("animation-delay");
1561
- };
1562
- const resetAbsolute = (el) => {
1563
- props.group && (el.style.position = "absolute");
1564
- };
1565
- const resetOrigin = (el) => {
1566
- props.origin && (el.style.transformOrigin = props.origin);
1567
- };
1568
- const resetStyles = (el) => {
1569
- resetOrigin(el);
1570
- Object.keys(props.style).forEach((key) => {
1571
- const v = props.style[key];
1572
- v && (el.style[key] = v);
1573
- });
1574
- };
1575
- const handleBeforeEnter = (el) => {
1576
- const duration = props.duration.enter || props.duration;
1577
- el.style.animationDuration = `${duration}ms`;
1578
- const delay = props.delay.enter || props.delay;
1579
- el.style.animationDelay = `${delay}ms`;
1580
- resetStyles(el);
1581
- attrs.onBeforeEnter?.(el);
1582
- };
1583
- const createNext = (callback, duration) => {
1584
- let hasDone = false;
1585
- return (immediate = true) => {
1586
- if (hasDone) return;
1587
- hasDone = true;
1588
- const done = () => callback?.();
1589
- immediate ? done() : setTimeout(done, duration);
1590
- };
1591
- };
1592
- const handleEnter = async (el, done) => {
1593
- const duration = props.duration.enter || props.duration;
1594
- const next = createNext(done, duration);
1595
- try {
1596
- await attrs.onEnter?.(el, next);
1597
- } finally {
1598
- next(false);
1677
+ const fields = [];
1678
+ vue.provide("form", {
1679
+ props,
1680
+ add: (field) => {
1681
+ field && fields.push(field);
1682
+ },
1683
+ remove: (field) => {
1684
+ field && fields.splice(fields.indexOf(field), 1);
1599
1685
  }
1686
+ });
1687
+ const filterFields = (fields$) => {
1688
+ return !fields$ ? fields : fields.filter((item) => fields$.includes(item.props.prop));
1600
1689
  };
1601
- const handleAfterEnter = (el) => {
1602
- clearStyles(el);
1603
- attrs.onAfterEnter?.(el);
1690
+ const getField = (prop) => {
1691
+ const field = fields.find((item) => item.props.prop === prop);
1692
+ if (!field) throw new VcError("form", "请选择有用的prop值");
1693
+ return field;
1604
1694
  };
1605
- const handleBeforeLeave = (el) => {
1606
- const duration = props.duration.leave || props.duration;
1607
- el.style.animationDuration = `${duration}ms`;
1608
- const delay = props.delay.leave || props.delay;
1609
- el.style.animationDelay = `${delay}ms`;
1610
- resetStyles(el);
1611
- attrs.onBeforeLeave?.(el);
1695
+ const showToast = (msg) => {
1696
+ props.showMessage && options.throwToast?.(msg);
1612
1697
  };
1613
- const handleLeave = async (el, done) => {
1614
- const duration = props.duration.leave || props.duration;
1615
- const next = createNext(done, duration);
1698
+ const sortErrors = async (errors) => {
1699
+ const positions = await Promise.all(fields.map((item) => item.exposed.getPosition()));
1616
1700
  try {
1617
- resetAbsolute(el);
1618
- await attrs.onLeave?.(el, next);
1619
- } finally {
1620
- next(props.group ? true : false);
1621
- }
1622
- };
1623
- const handleAfterLeave = (el) => {
1624
- clearStyles(el);
1625
- attrs.onAfterLeave?.(el);
1626
- };
1627
- return {
1628
- Wrapper,
1629
- resetStyles,
1630
- resetAbsolute,
1631
- classes,
1632
- createNext,
1633
- listeners: {
1634
- onBeforeEnter: handleBeforeEnter,
1635
- onEnter: handleEnter,
1636
- onAfterEnter: handleAfterEnter,
1637
- onBeforeLeave: handleBeforeLeave,
1638
- onLeave: handleLeave,
1639
- onAfterLeave: handleAfterLeave
1701
+ return [...errors].toSorted((a, b) => {
1702
+ const aIndex = fields.findIndex((i) => i.props.prop === a.prop);
1703
+ const bIndex = fields.findIndex((i) => i.props.prop === b.prop);
1704
+ const aPosition = positions[aIndex];
1705
+ const bPosition = positions[bIndex];
1706
+ if (aPosition.top != bPosition.top) return aPosition.top - bPosition.top;
1707
+ return aPosition.left - bPosition.left;
1708
+ });
1709
+ } catch (e) {
1710
+ return errors;
1640
1711
  }
1641
1712
  };
1642
- };
1643
-
1644
- const COMPONENT_NAME$16 = "vc-transition";
1645
- const Transition = vue.defineComponent({
1646
- name: COMPONENT_NAME$16,
1647
- props: props$R,
1648
- // 当不声明emits的情况下,事件存在于attrs中
1649
- inheritAttrs: false,
1650
- setup(props, { slots, attrs }) {
1651
- const { Wrapper, listeners, classes } = useTransition();
1652
- return () => {
1653
- return vue.h(
1654
- Wrapper.value,
1655
- {
1656
- ...attrs,
1657
- ...listeners,
1658
- ...classes.value,
1659
- tag: props.tag
1660
- },
1661
- slots
1662
- );
1663
- };
1664
- }
1665
- });
1666
-
1667
- const COMPONENT_NAME$15 = "vc-transition-collapse";
1668
- const TransitionCollapse = vue.defineComponent({
1669
- name: COMPONENT_NAME$15,
1670
- props: props$R,
1671
- // 当不声明emits的情况下,事件存在于attrs中
1672
- inheritAttrs: false,
1673
- setup(props, { slots, attrs: _attrs }) {
1674
- const attrs = _attrs;
1675
- const { Wrapper, resetStyles, resetAbsolute, createNext } = useTransition();
1676
- const getTransitionStyle = (duration) => {
1677
- const style = `
1678
- ${duration}ms height ease-in-out,
1679
- ${duration}ms padding-top ease-in-out,
1680
- ${duration}ms padding-bottom ease-in-out
1681
- `;
1682
- return style;
1683
- };
1684
- const handleBeforeEnter = (el) => {
1685
- const duration = props.duration.enter || props.duration;
1686
- el.style.transition = getTransitionStyle(duration);
1687
- /* istanbul ignore next -- @preserve */
1688
- if (!el.dataset) {
1689
- el.dataset = {};
1690
- }
1691
- el.dataset.oldPaddingTop = el.style.paddingTop;
1692
- el.dataset.oldPaddingBottom = el.style.paddingBottom;
1693
- el.style.height = "0px";
1694
- el.style.paddingTop = "0px";
1695
- el.style.paddingBottom = "0px";
1696
- resetStyles(el);
1697
- attrs.onBeforeEnter?.(el);
1698
- };
1699
- const handleEnter = async (el, done) => {
1700
- const duration = props.duration.enter || props.duration;
1701
- const next = createNext(done, duration);
1702
- try {
1703
- el.dataset.oldOverflow = el.style.overflow;
1704
- /* istanbul ignore next -- @preserve */
1705
- if (el.scrollHeight !== 0) {
1706
- el.style.height = el.scrollHeight + "px";
1707
- el.style.paddingTop = el.dataset.oldPaddingTop + "px";
1708
- el.style.paddingBottom = el.dataset.oldPaddingBottom + "px";
1709
- } else {
1710
- el.style.height = "";
1711
- el.style.paddingTop = el.dataset.oldPaddingTop + "px";
1712
- el.style.paddingBottom = el.dataset.oldPaddingBottom + "px";
1713
- }
1714
- el.style.overflow = "hidden";
1715
- attrs.onEnter?.(el);
1716
- } finally {
1717
- next(false);
1718
- }
1719
- };
1720
- const handleAfterEnter = (el) => {
1721
- el.style.transition = "";
1722
- el.style.height = "";
1723
- el.style.overflow = el.dataset.oldOverflow || "";
1724
- attrs.onAfterEnter?.(el);
1725
- };
1726
- const handleBeforeLeave = (el) => {
1727
- /* istanbul ignore next -- @preserve */
1728
- if (!el.dataset) {
1729
- el.dataset = {};
1730
- }
1731
- el.dataset.oldPaddingTop = el.style.paddingTop;
1732
- el.dataset.oldPaddingBottom = el.style.paddingBottom;
1733
- el.dataset.oldOverflow = el.style.overflow;
1734
- el.style.height = el.scrollHeight + "px";
1735
- el.style.overflow = "hidden";
1736
- resetStyles(el);
1737
- attrs.onBeforeLeave?.(el);
1738
- };
1739
- const handleLeave = (el, done) => {
1740
- const duration = props.duration.leave || props.duration;
1741
- const next = createNext(done, duration);
1742
- try {
1743
- const leaveDuration = props.duration.leave || props.duration;
1744
- /* istanbul ignore next -- @preserve */
1745
- if (el.scrollHeight !== 0) {
1746
- el.style.transition = getTransitionStyle(leaveDuration);
1747
- el.style.height = "0px";
1748
- el.style.paddingTop = "0px";
1749
- el.style.paddingBottom = "0px";
1750
- }
1751
- resetAbsolute(el);
1752
- attrs.onLeave?.(el);
1753
- } finally {
1754
- next(props.group ? true : false);
1755
- }
1756
- };
1757
- const handleAfterLeave = (el) => {
1758
- el.style.transition = "";
1759
- el.style.height = "";
1760
- el.style.overflow = el.dataset.oldOverflow || "";
1761
- el.style.paddingTop = el.dataset.oldPaddingTop || "";
1762
- el.style.paddingBottom = el.dataset.oldPaddingBottom || "";
1763
- attrs.onAfterLeave?.(el);
1764
- };
1765
- const listeners = {
1766
- onBeforeEnter: handleBeforeEnter,
1767
- onEnter: handleEnter,
1768
- onAfterEnter: handleAfterEnter,
1769
- onBeforeLeave: handleBeforeLeave,
1770
- onLeave: handleLeave,
1771
- onAfterLeave: handleAfterLeave
1772
- };
1713
+ const scrollIntoView = (prop) => {
1714
+ const field = getField(prop);
1715
+ field.vnode?.el?.scrollIntoView?.({
1716
+ behavior: "smooth",
1717
+ block: "center"
1718
+ });
1719
+ };
1720
+ const reset = (options$ = {}) => {
1721
+ const { fields: fields$, original = {} } = options$;
1722
+ filterFields(fields$).forEach((field) => {
1723
+ let v;
1724
+ try {
1725
+ v = Utils.getPropByPath(original, field.props.prop).v;
1726
+ } catch (e) {
1727
+ }
1728
+ field.exposed.reset(v);
1729
+ });
1730
+ };
1731
+ const validate = async (options$ = {}) => {
1732
+ const { scroll = true, fields: fields$ } = options$;
1733
+ if (!fields.length) {
1734
+ return;
1735
+ }
1736
+ const results = await Promise.allSettled(
1737
+ filterFields(fields$).map((item) => item.exposed.validate(""))
1738
+ );
1739
+ const originErrors = results.filter((i) => i.status === "rejected").map((i) => i.reason);
1740
+ if (!originErrors.length) return;
1741
+ const errors = await sortErrors(originErrors);
1742
+ showToast(errors[0].msg || errors[0].message);
1743
+ scroll && scrollIntoView(errors[0].prop);
1744
+ throw errors;
1745
+ };
1746
+ const validateField = async (prop, options$ = {}) => {
1747
+ try {
1748
+ await validate({
1749
+ ...options$,
1750
+ fields: [prop]
1751
+ });
1752
+ } catch (e) {
1753
+ throw e[0];
1754
+ }
1755
+ };
1756
+ expose({
1757
+ reset,
1758
+ validate,
1759
+ // 单个操作
1760
+ getField,
1761
+ validateField
1762
+ });
1763
+ };
1764
+
1765
+ const COMPONENT_NAME$11 = "vc-form";
1766
+ const Form = vue.defineComponent({
1767
+ name: COMPONENT_NAME$11,
1768
+ props: props$S,
1769
+ setup(props, { slots, expose }) {
1770
+ useForm(expose);
1773
1771
  return () => {
1774
1772
  return vue.h(
1775
- Wrapper.value,
1773
+ props.tag,
1776
1774
  {
1777
- ...attrs,
1778
- ...listeners,
1779
- tag: props.tag,
1780
- moveClass: props.group ? `${attrs.moveClass || ""} vc-transition-collapse is-move` : void 0
1775
+ class: "vc-form",
1776
+ autocomplete: props.autocomplete
1781
1777
  },
1782
1778
  slots
1783
1779
  );
@@ -1785,175 +1781,308 @@ const TransitionCollapse = vue.defineComponent({
1785
1781
  }
1786
1782
  });
1787
1783
 
1788
- const COMPONENT_NAME$14 = "vc-transition-fade";
1789
- const TransitionFade = vue.defineComponent({
1790
- name: COMPONENT_NAME$14,
1791
- props: {
1792
- ...props$R,
1793
- // inheritAttrs必须是false
1794
- style: {
1795
- type: Object,
1796
- default: () => ({
1797
- animationFillMode: "both",
1798
- animationTimingFunction: void 0
1799
- })
1800
- },
1801
- prefix: {
1802
- type: String,
1803
- default: "vc-transition-fade"
1784
+ const props$R = {
1785
+ label: {
1786
+ type: String,
1787
+ default: ""
1788
+ },
1789
+ labelWidth: {
1790
+ type: Number
1791
+ },
1792
+ prop: {
1793
+ type: String
1794
+ },
1795
+ required: {
1796
+ type: [Boolean, String],
1797
+ default: false
1798
+ },
1799
+ error: {
1800
+ type: String
1801
+ },
1802
+ rules: {
1803
+ type: [Array, Object]
1804
+ },
1805
+ resetByRulesChanged: {
1806
+ type: Boolean,
1807
+ default: false
1808
+ },
1809
+ showMessage: {
1810
+ type: Boolean,
1811
+ default: true
1812
+ },
1813
+ labelFor: {
1814
+ type: String
1815
+ },
1816
+ styleless: {
1817
+ type: Boolean,
1818
+ default: false
1819
+ },
1820
+ labelPosition: {
1821
+ type: String,
1822
+ default: "right"
1823
+ },
1824
+ contentStyle: String
1825
+ };
1826
+
1827
+ const filterEmpty = (val) => {
1828
+ if (val instanceof Array) {
1829
+ val = val.filter((i) => i !== "");
1830
+ }
1831
+ return val;
1832
+ };
1833
+ const toRules = (rules) => {
1834
+ return rules instanceof Array ? rules : rules ? [rules] : [];
1835
+ };
1836
+ const useFormItem = (expose) => {
1837
+ const form = vue.inject("form");
1838
+ const instance = vue.getCurrentInstance();
1839
+ const props = instance.props;
1840
+ const { slots } = instance;
1841
+ if (!form?.props) {
1842
+ throw new VcError("form-item", "form-item需要在form内使用");
1843
+ }
1844
+ const formItem = vue.inject("form-item", {});
1845
+ const validateState = vue.ref("");
1846
+ const validateMessage = vue.ref("");
1847
+ let validateDisabled = false;
1848
+ let initialValue;
1849
+ const currentRules = vue.computed(() => {
1850
+ const formRules = form.props.rules;
1851
+ const formItemBindRules = toRules(props.rules);
1852
+ let formItemRules = formItemBindRules;
1853
+ if (!formItemRules.length && formRules && props.prop) {
1854
+ try {
1855
+ const key = props.prop.replace(/\.[0-9]+\./g, ".");
1856
+ const { v } = Utils.getPropByPath(formRules, key);
1857
+ formItemRules = toRules(v);
1858
+ } catch {
1859
+ const rules = formRules[props.prop];
1860
+ formItemRules = toRules(rules);
1861
+ }
1862
+ }
1863
+ return formItemRules;
1864
+ });
1865
+ const isRequired = vue.computed(() => {
1866
+ if (!currentRules.value.length) {
1867
+ return !!props.required;
1868
+ }
1869
+ let required = false;
1870
+ for (let i = 0; i < currentRules.value.length; i++) {
1871
+ const rule = currentRules.value[i];
1872
+ required = !!rule.required;
1873
+ if (required) break;
1874
+ }
1875
+ return required;
1876
+ });
1877
+ const labelPosition = vue.computed(() => {
1878
+ return props.labelPosition || form.props.labelPosition;
1879
+ });
1880
+ const classes = vue.computed(() => {
1881
+ return {
1882
+ "is-require": isRequired.value,
1883
+ "is-error": validateState.value === "error",
1884
+ "is-validating": validateState.value === "validating",
1885
+ "is-inline": form.props.inline,
1886
+ "is-nest": isNest.value,
1887
+ [`is-${labelPosition.value}`]: true
1888
+ };
1889
+ });
1890
+ const isNest = vue.computed(() => {
1891
+ return !!formItem.change;
1892
+ });
1893
+ const isNestLast = vue.ref(false);
1894
+ const hasLabel = vue.computed(() => {
1895
+ return !!props.label || slots.label;
1896
+ });
1897
+ const labelStyle = vue.computed(() => {
1898
+ const labelWidth = props.labelWidth === 0 || props.labelWidth ? props.labelWidth : isNest.value ? 0 : form.props.labelWidth;
1899
+ return {
1900
+ width: labelPosition.value !== "top" && labelWidth && labelWidth > 0 ? `${labelWidth}px` : "auto",
1901
+ textAlign: labelPosition.value === "top" ? "left" : labelPosition.value
1902
+ };
1903
+ });
1904
+ const contentStyle = vue.computed(() => {
1905
+ const labelWidth = props.labelWidth === 0 || props.labelWidth ? props.labelWidth : form.props.labelWidth;
1906
+ return [
1907
+ {
1908
+ marginLeft: !hasLabel.value && isNest.value ? 0 : labelWidth && labelWidth > 0 ? `${labelWidth}px` : "unset",
1909
+ marginBottom: isNest.value && !isNestLast.value ? `20px` : 0
1910
+ },
1911
+ props.contentStyle
1912
+ ];
1913
+ });
1914
+ const isStyleless = vue.computed(() => {
1915
+ return props.styleless || form.props.styleless;
1916
+ });
1917
+ const fieldValue = vue.computed(() => {
1918
+ const model = form.props.model;
1919
+ if (!model || !props.prop) {
1920
+ return;
1921
+ }
1922
+ let path = props.prop;
1923
+ if (path.includes(":")) {
1924
+ path = path.replace(/:/, ".");
1925
+ }
1926
+ return Utils.getPropByPath(model, path).v;
1927
+ });
1928
+ const showError = vue.computed(() => {
1929
+ return validateState.value === "error" && props.showMessage && form.props.showMessage;
1930
+ });
1931
+ vue.watch(
1932
+ () => props.error,
1933
+ (v) => {
1934
+ validateMessage.value = v || "";
1935
+ validateState.value = v === "" ? "" : "error";
1936
+ }
1937
+ );
1938
+ const reset = (v) => {
1939
+ validateState.value = "";
1940
+ validateMessage.value = "";
1941
+ const model = form.props.model;
1942
+ if (!props.prop) return;
1943
+ const { o, k } = Utils.getPropByPath(model, props.prop);
1944
+ if (!k) return;
1945
+ validateDisabled = true;
1946
+ o[k] = v !== null && v !== void 0 ? v : Array.isArray(fieldValue.value) ? [].concat(initialValue) : initialValue;
1947
+ };
1948
+ const validate = async (trigger) => {
1949
+ if (!props.prop) return;
1950
+ let rules = currentRules.value.filter((rule) => !rule.trigger || rule.trigger.includes(trigger));
1951
+ if (!rules.length) {
1952
+ if (!props.required) {
1953
+ return;
1954
+ } else {
1955
+ rules = [{
1956
+ required: true,
1957
+ message: typeof props.required === "string" ? props.required : void 0
1958
+ }];
1959
+ }
1960
+ }
1961
+ validateState.value = "validating";
1962
+ const descriptor = {};
1963
+ descriptor[props.prop] = rules;
1964
+ const validator = new helperValidator.Validator(descriptor);
1965
+ const model = {};
1966
+ model[props.prop] = filterEmpty(fieldValue.value);
1967
+ try {
1968
+ await validator.validate(model, { first: false });
1969
+ validateState.value = "success";
1970
+ validateMessage.value = "";
1971
+ } catch (errors) {
1972
+ validateState.value = "error";
1973
+ validateMessage.value = errors[0].message;
1974
+ throw {
1975
+ prop: props.prop,
1976
+ message: validateMessage.value
1977
+ };
1804
1978
  }
1805
- },
1806
- // 当不声明emits的情况下,事件存在于attrs中
1807
- inheritAttrs: false,
1808
- setup(props, { slots, attrs }) {
1809
- const { Wrapper, listeners, classes } = useTransition();
1810
- return () => {
1811
- return vue.h(
1812
- Wrapper.value,
1813
- {
1814
- ...attrs,
1815
- ...listeners,
1816
- ...classes.value,
1817
- tag: props.tag
1818
- },
1819
- slots
1820
- );
1821
- };
1822
- }
1823
- });
1824
-
1825
- const COMPONENT_NAME$13 = "vc-transition-scale";
1826
- const TransitionScale = vue.defineComponent({
1827
- name: COMPONENT_NAME$13,
1828
- props: {
1829
- ...props$R,
1830
- mode: {
1831
- type: String,
1832
- default: "both",
1833
- validator: (v) => /(part|both|y|x|none)/.test(v)
1834
- },
1835
- // inheritAttrs必须是false
1836
- style: {
1837
- type: Object,
1838
- default: () => ({
1839
- animationFillMode: "both",
1840
- animationTimingFunction: void 0
1841
- })
1842
- },
1843
- prefix: {
1844
- type: String,
1845
- default: "vc-transition-scale"
1979
+ validateDisabled = false;
1980
+ };
1981
+ const handleFieldBlur = () => {
1982
+ if (!props.prop) {
1983
+ formItem.blur?.();
1984
+ return;
1846
1985
  }
1847
- },
1848
- // 当不声明emits的情况下,事件存在于attrs中
1849
- inheritAttrs: false,
1850
- setup(props, { slots, attrs }) {
1851
- const { Wrapper, listeners, classes } = useTransition();
1852
- return () => {
1853
- return vue.h(
1854
- Wrapper.value,
1855
- {
1856
- ...attrs,
1857
- ...listeners,
1858
- ...classes.value,
1859
- tag: props.tag
1860
- },
1861
- slots
1862
- );
1863
- };
1864
- }
1865
- });
1866
-
1867
- const COMPONENT_NAME$12 = "vc-transition-slide";
1868
- const TransitionSlide = vue.defineComponent({
1869
- name: COMPONENT_NAME$12,
1870
- props: {
1871
- ...props$R,
1872
- mode: {
1873
- type: String,
1874
- default: "left",
1875
- validator: (v) => /^(left|right|down|up|none)(|-part)$/.test(v)
1876
- },
1877
- // inheritAttrs必须是false
1878
- style: {
1879
- type: Object,
1880
- default: () => ({
1881
- animationFillMode: "both",
1882
- animationTimingFunction: void 0
1883
- })
1884
- },
1885
- prefix: {
1886
- type: String,
1887
- default: "vc-transition-slide"
1986
+ validate("blur");
1987
+ };
1988
+ const handleFieldChange = () => {
1989
+ if (!props.prop) {
1990
+ formItem.change?.();
1991
+ return;
1888
1992
  }
1889
- },
1890
- // 当不声明emits的情况下,事件存在于attrs中
1891
- inheritAttrs: false,
1892
- setup(props, { slots, attrs }) {
1893
- const { Wrapper, listeners, classes } = useTransition();
1894
- return () => {
1895
- return vue.h(
1896
- Wrapper.value,
1897
- {
1898
- ...attrs,
1899
- ...listeners,
1900
- ...classes.value,
1901
- tag: props.tag
1902
- },
1903
- slots
1904
- );
1905
- };
1906
- }
1907
- });
1908
-
1909
- const COMPONENT_NAME$11 = "vc-transition-zoom";
1910
- const TransitionZoom = vue.defineComponent({
1911
- name: COMPONENT_NAME$11,
1912
- props: {
1913
- ...props$R,
1914
- mode: {
1915
- type: String,
1916
- default: "x",
1917
- validator: (v) => /^(x|y|center|none)$/.test(v)
1918
- },
1919
- // inheritAttrs必须是false
1920
- style: {
1921
- type: Object,
1922
- default: () => ({
1923
- animationFillMode: "both",
1924
- animationTimingFunction: void 0
1925
- })
1993
+ if (validateDisabled) {
1994
+ validateDisabled = false;
1995
+ return;
1996
+ }
1997
+ validate("change");
1998
+ };
1999
+ const getPosition = async () => {
2000
+ let el = instance.vnode.el;
2001
+ try {
2002
+ while (el && !el.getBoundingClientRect) {
2003
+ el = el.nextSibling;
2004
+ }
2005
+ ;
2006
+ const rect = el.getBoundingClientRect();
2007
+ return {
2008
+ top: rect.top,
2009
+ left: rect.left
2010
+ };
2011
+ } catch (e) {
2012
+ throw new VcError("form-item", "form-item位置计算错误");
2013
+ }
2014
+ };
2015
+ const fields = vue.reactive([]);
2016
+ vue.provide("form-item", {
2017
+ fields,
2018
+ blur: handleFieldBlur,
2019
+ change: handleFieldChange,
2020
+ message: validateMessage,
2021
+ add: (field) => {
2022
+ field && fields.push(field);
1926
2023
  },
1927
- prefix: {
1928
- type: String,
1929
- default: "vc-transition-zoom"
2024
+ remove: (field) => {
2025
+ field && fields.splice(fields.indexOf(field), 1);
1930
2026
  }
1931
- },
1932
- // 当不声明emits的情况下,事件存在于attrs中
1933
- inheritAttrs: false,
1934
- setup(props, { slots, attrs }) {
1935
- const { Wrapper, listeners, classes } = useTransition();
1936
- return () => {
1937
- return vue.h(
1938
- Wrapper.value,
1939
- {
1940
- ...attrs,
1941
- ...listeners,
1942
- ...classes.value,
1943
- tag: props.tag
1944
- },
1945
- slots
1946
- );
1947
- };
1948
- }
1949
- });
2027
+ });
2028
+ vue.onMounted(() => {
2029
+ if (props.prop) {
2030
+ form.add?.(instance);
2031
+ initialValue = lodashEs.cloneDeep(fieldValue.value);
2032
+ }
2033
+ formItem.add?.(instance);
2034
+ });
2035
+ vue.onBeforeUnmount(() => {
2036
+ form.remove?.(instance);
2037
+ formItem.remove?.(instance);
2038
+ });
2039
+ vue.watch(
2040
+ () => props.rules,
2041
+ () => {
2042
+ props.resetByRulesChanged && reset();
2043
+ }
2044
+ );
2045
+ vue.watch(
2046
+ () => formItem.fields?.length,
2047
+ async (v) => {
2048
+ if (!isNest.value || !v) return isNestLast.value = false;
2049
+ const fields$ = [...vue.toRaw(formItem.fields)];
2050
+ const positions = await Promise.all(fields$.map((item) => item.exposed.getPosition()));
2051
+ const sortFields = fields$.toSorted((a, b) => {
2052
+ const aIndex = fields$.findIndex((i) => i === a);
2053
+ const bIndex = fields$.findIndex((i) => i === b);
2054
+ const aPosition = positions[aIndex];
2055
+ const bPosition = positions[bIndex];
2056
+ if (aPosition.top != bPosition.top) return aPosition.top - bPosition.top;
2057
+ return aPosition.left - bPosition.left;
2058
+ });
2059
+ isNestLast.value = sortFields[sortFields.length - 1] === instance;
2060
+ }
2061
+ );
2062
+ expose({
2063
+ validate,
2064
+ reset,
2065
+ getPosition
2066
+ });
2067
+ return {
2068
+ isNest,
2069
+ isStyleless,
2070
+ isNestLast,
2071
+ validateMessage,
2072
+ classes,
2073
+ labelStyle,
2074
+ contentStyle,
2075
+ showError,
2076
+ labelPosition
2077
+ };
2078
+ };
1950
2079
 
1951
2080
  /** @jsxImportSource vue */
1952
2081
 
1953
2082
  const COMPONENT_NAME$10 = 'vc-form-item';
1954
2083
  const FormItem = /* @__PURE__ */ vue.defineComponent({
1955
2084
  name: COMPONENT_NAME$10,
1956
- props: props$S,
2085
+ props: props$R,
1957
2086
  setup(props, {
1958
2087
  slots,
1959
2088
  expose
@@ -2006,7 +2135,7 @@ const FormItem = /* @__PURE__ */ vue.defineComponent({
2006
2135
  });
2007
2136
 
2008
2137
  const props$Q = {
2009
- ...props$T,
2138
+ ...props$S,
2010
2139
  showToast: {
2011
2140
  type: Boolean,
2012
2141
  default: false
@@ -2544,7 +2673,7 @@ const MForm = vue.defineComponent({
2544
2673
  });
2545
2674
 
2546
2675
  const props$N = {
2547
- ...props$S,
2676
+ ...props$R,
2548
2677
  indent: {
2549
2678
  type: Number,
2550
2679
  default: 12
@@ -5291,7 +5420,8 @@ const PopoverWrapper = /* @__PURE__ */ vue.defineComponent({
5291
5420
  emits: ['portal-fulfilled', 'close'],
5292
5421
  setup(props, {
5293
5422
  emit,
5294
- slots
5423
+ slots,
5424
+ expose
5295
5425
  }) {
5296
5426
  const {
5297
5427
  getPopupStyle,
@@ -5495,6 +5625,9 @@ const PopoverWrapper = /* @__PURE__ */ vue.defineComponent({
5495
5625
  helperResize.Resize.off(vnode.el, handleWrapperResize);
5496
5626
  props.alone && props.hover && removeEvents();
5497
5627
  });
5628
+ expose({
5629
+ isActive
5630
+ });
5498
5631
  return () => {
5499
5632
  let _slot;
5500
5633
  return vue.createVNode(TransitionScale, {