@mingto/mt-ui 1.1.47 → 1.1.48

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.es.js CHANGED
@@ -7231,10 +7231,12 @@ var MtImage = withInstall$1(/* @__PURE__ */ defineComponent({
7231
7231
  return [ns.b()];
7232
7232
  });
7233
7233
  const imageStyles = computed(() => {
7234
- return {
7235
- width: props.width ? convertValueToViewportWidth(props.width) : void 0,
7236
- height: props.height ? convertValueToViewportWidth(props.height) : void 0
7237
- };
7234
+ const styles = {};
7235
+ Object.assign(styles, ns.cssVarBlock({
7236
+ ...props.width ? { width: convertValueToViewportWidth(props.width) } : {},
7237
+ ...props.height ? { height: convertValueToViewportWidth(props.height) } : {}
7238
+ }));
7239
+ return styles;
7238
7240
  });
7239
7241
  const hasLoadError = ref(false);
7240
7242
  const isLoading = ref(true);
@@ -10317,8 +10319,12 @@ var MtPopover = withInstall$1(/* @__PURE__ */ defineComponent({
10317
10319
  */
10318
10320
  var posterComponent = defineComponent({
10319
10321
  inheritAttrs: false,
10322
+ props: { dialogEvents: {
10323
+ type: Object,
10324
+ default: () => ({})
10325
+ } },
10320
10326
  emits: ["close"],
10321
- setup(_props, { slots, emit, attrs, expose }) {
10327
+ setup(props, { slots, emit, attrs, expose }) {
10322
10328
  /**
10323
10329
  * 控制弹窗显示状态的响应式变量。
10324
10330
  */
@@ -10350,6 +10356,7 @@ var posterComponent = defineComponent({
10350
10356
  return () => createVNode(MtDialog, {
10351
10357
  modelValue: visible.value,
10352
10358
  ...attrs,
10359
+ ...props.dialogEvents,
10353
10360
  "onUpdate:modelValue": handleUpdateModelValue,
10354
10361
  "onClosed": handleClosed,
10355
10362
  "ref": dialogRef
@@ -10405,10 +10412,14 @@ function Poster(options) {
10405
10412
  /**
10406
10413
  * 合并弹窗组件的事件处理函数。
10407
10414
  */
10408
- const dialogEvents = { onClose() {
10409
- options?.events?.onClose?.();
10410
- render(null, container);
10411
- } };
10415
+ const dialogEvents = {
10416
+ ...options.dialogEvents,
10417
+ onClose() {
10418
+ options.dialogEvents?.onClose?.();
10419
+ options?.events?.onClose?.();
10420
+ render(null, container);
10421
+ }
10422
+ };
10412
10423
  document.body.appendChild(container);
10413
10424
  /**
10414
10425
  * 动态加载内容组件并渲染弹窗。
@@ -10421,7 +10432,7 @@ function Poster(options) {
10421
10432
  });
10422
10433
  dialogVNode = createVNode(posterComponent, {
10423
10434
  ...dialogProps,
10424
- ...dialogEvents
10435
+ dialogEvents
10425
10436
  }, { default: () => contentVNode });
10426
10437
  render(dialogVNode, container);
10427
10438
  });
@@ -10532,7 +10543,7 @@ var MtProgress = withInstall$1(/* @__PURE__ */ defineComponent({
10532
10543
  });
10533
10544
  const progressStyles = computed(() => {
10534
10545
  const styles = {};
10535
- styles.height = convertValueToViewportWidth(props.strokeWidth);
10546
+ Object.assign(styles, ns.cssVarBlock({ height: convertValueToViewportWidth(props.strokeWidth) }));
10536
10547
  return styles;
10537
10548
  });
10538
10549
  const innerStyles = computed(() => {
@@ -10545,8 +10556,10 @@ var MtProgress = withInstall$1(/* @__PURE__ */ defineComponent({
10545
10556
  });
10546
10557
  const circleStyles = computed(() => {
10547
10558
  const styles = {};
10548
- styles.width = convertValueToViewportWidth(props.width);
10549
- styles.height = convertValueToViewportWidth(props.width);
10559
+ Object.assign(styles, ns.cssVarBlock({
10560
+ width: convertValueToViewportWidth(props.width),
10561
+ height: convertValueToViewportWidth(props.width)
10562
+ }));
10550
10563
  return styles;
10551
10564
  });
10552
10565
  const content = computed(() => {
@@ -19514,8 +19527,7 @@ var MtTabs = withInstall$1(/* @__PURE__ */ defineComponent({
19514
19527
  const emits = __emit;
19515
19528
  const ns = useNamespace("tabs");
19516
19529
  const tabsRef = ref();
19517
- const barStyles = ref({});
19518
- const lineStyles = ref({});
19530
+ const mounted = ref(false);
19519
19531
  const currentTabName = computed({
19520
19532
  get() {
19521
19533
  return props.modelValue;
@@ -19530,50 +19542,40 @@ var MtTabs = withInstall$1(/* @__PURE__ */ defineComponent({
19530
19542
  onChange,
19531
19543
  type: props.type
19532
19544
  });
19533
- function getActiveTabElement() {
19534
- if (!tabsRef.value) return null;
19535
- for (let index = 0; index < children.length; index++) {
19536
- const child = children[index];
19537
- if (!child.exposed || !isTabContext(child.exposed) || !child.exposed.isActive.value) continue;
19538
- return tabsRef.value.querySelector(`#tab-${index}`);
19539
- }
19540
- return null;
19541
- }
19542
- async function updateActiveStyles() {
19543
- await nextTick();
19544
- const $el = getActiveTabElement();
19545
- if (!$el) {
19546
- barStyles.value = {};
19547
- lineStyles.value = {};
19548
- return;
19549
- }
19550
- barStyles.value = {
19551
- width: `${$el.clientWidth}px`,
19552
- left: `${$el.offsetLeft}px`
19553
- };
19545
+ const barStyles = computed(() => {
19554
19546
  const styles = {};
19555
- const tabStyles = window.getComputedStyle($el);
19556
- styles.width = `${$el.clientWidth - beParsedAsNumber(tabStyles.paddingLeft) - beParsedAsNumber(tabStyles.paddingRight)}px`;
19557
- styles.left = `${$el.offsetLeft + beParsedAsNumber(tabStyles.paddingLeft)}px`;
19558
- lineStyles.value = styles;
19559
- }
19547
+ if (tabsRef.value) children.forEach((child, index) => {
19548
+ const $el = tabsRef.value.querySelector(`#tab-${index}`);
19549
+ if (!$el) return;
19550
+ if (!child.exposed || !isTabContext(child.exposed) || !unref(child.exposed.isActive)) return;
19551
+ styles.width = `${$el.clientWidth}px`;
19552
+ styles.left = `${$el.offsetLeft}px`;
19553
+ });
19554
+ return styles;
19555
+ });
19556
+ const lineStyles = computed(() => {
19557
+ const styles = {};
19558
+ if (tabsRef.value) children.forEach((child, index) => {
19559
+ const $el = tabsRef.value.querySelector(`#tab-${index}`);
19560
+ if (!$el) return;
19561
+ if (!child.exposed || !isTabContext(child.exposed) || !unref(child.exposed.isActive)) return;
19562
+ const tabStyles = window.getComputedStyle($el);
19563
+ const paddingLeft = beParsedAsNumber(tabStyles.paddingLeft);
19564
+ const paddingRight = beParsedAsNumber(tabStyles.paddingRight);
19565
+ styles.width = `${Math.max($el.clientWidth - paddingLeft - paddingRight, 0)}px`;
19566
+ styles.left = `${$el.offsetLeft + paddingLeft}px`;
19567
+ });
19568
+ return styles;
19569
+ });
19560
19570
  const tabsClasses = computed(() => {
19561
19571
  return [ns.b(), ns.m(props.type)];
19562
19572
  });
19563
19573
  function onChange(tabName) {
19564
19574
  currentTabName.value = tabName;
19565
19575
  }
19566
- watch(() => [
19567
- currentTabName.value,
19568
- children.length,
19569
- props.type
19570
- ], updateActiveStyles, { flush: "post" });
19571
- onMounted(() => {
19572
- updateActiveStyles();
19573
- window.addEventListener("resize", updateActiveStyles);
19574
- });
19575
- onBeforeUnmount(() => {
19576
- window.removeEventListener("resize", updateActiveStyles);
19576
+ onMounted(async () => {
19577
+ await nextTick();
19578
+ mounted.value = true;
19577
19579
  });
19578
19580
  return (_ctx, _cache) => {
19579
19581
  return openBlock(), createElementBlock("div", {
@@ -19586,12 +19588,12 @@ var MtTabs = withInstall$1(/* @__PURE__ */ defineComponent({
19586
19588
  class: normalizeClass(unref(ns).e("active-bar")),
19587
19589
  style: normalizeStyle(barStyles.value)
19588
19590
  }, null, 6)) : createCommentVNode("", true),
19589
- props.type === "line" ? (openBlock(), createElementBlock("div", {
19591
+ renderSlot(_ctx.$slots, "default"),
19592
+ props.type === "line" ? (openBlock(), createElementBlock("span", {
19590
19593
  key: 1,
19591
19594
  class: normalizeClass(unref(ns).e("active-line")),
19592
19595
  style: normalizeStyle(lineStyles.value)
19593
- }, null, 6)) : createCommentVNode("", true),
19594
- renderSlot(_ctx.$slots, "default")
19596
+ }, null, 6)) : createCommentVNode("", true)
19595
19597
  ], 2);
19596
19598
  };
19597
19599
  }
@@ -19738,6 +19740,12 @@ var MtTooltip = withInstall$1(/* @__PURE__ */ defineComponent({
19738
19740
  disabled: props.disabled,
19739
19741
  visible: props.visible,
19740
19742
  offset: props.offset,
19743
+ "show-arrow": props["visible-arrow"],
19744
+ "popper-options": props["popper-options"],
19745
+ "show-after": props["show-after"],
19746
+ "hide-after": props["hide-after"],
19747
+ "auto-close": props["auto-close"],
19748
+ "popper-class": props["popper-class"],
19741
19749
  enterable: props.enterable,
19742
19750
  "onUpdate:visible": _cache[0] || (_cache[0] = ($event) => emits("update:visible", $event))
19743
19751
  }), createSlots({ _: 2 }, [unref(slots).default ? {
@@ -19757,6 +19765,12 @@ var MtTooltip = withInstall$1(/* @__PURE__ */ defineComponent({
19757
19765
  "disabled",
19758
19766
  "visible",
19759
19767
  "offset",
19768
+ "show-arrow",
19769
+ "popper-options",
19770
+ "show-after",
19771
+ "hide-after",
19772
+ "auto-close",
19773
+ "popper-class",
19760
19774
  "enterable"
19761
19775
  ]);
19762
19776
  };
package/dist/index.umd.js CHANGED
@@ -7262,10 +7262,12 @@
7262
7262
  return [ns.b()];
7263
7263
  });
7264
7264
  const imageStyles = (0, vue.computed)(() => {
7265
- return {
7266
- width: props.width ? convertValueToViewportWidth(props.width) : void 0,
7267
- height: props.height ? convertValueToViewportWidth(props.height) : void 0
7268
- };
7265
+ const styles = {};
7266
+ Object.assign(styles, ns.cssVarBlock({
7267
+ ...props.width ? { width: convertValueToViewportWidth(props.width) } : {},
7268
+ ...props.height ? { height: convertValueToViewportWidth(props.height) } : {}
7269
+ }));
7270
+ return styles;
7269
7271
  });
7270
7272
  const hasLoadError = (0, vue.ref)(false);
7271
7273
  const isLoading = (0, vue.ref)(true);
@@ -10376,8 +10378,12 @@
10376
10378
  */
10377
10379
  var posterComponent = (0, vue.defineComponent)({
10378
10380
  inheritAttrs: false,
10381
+ props: { dialogEvents: {
10382
+ type: Object,
10383
+ default: () => ({})
10384
+ } },
10379
10385
  emits: ["close"],
10380
- setup(_props, { slots, emit, attrs, expose }) {
10386
+ setup(props, { slots, emit, attrs, expose }) {
10381
10387
  /**
10382
10388
  * 控制弹窗显示状态的响应式变量。
10383
10389
  */
@@ -10409,6 +10415,7 @@
10409
10415
  return () => (0, vue.createVNode)(MtDialog, {
10410
10416
  modelValue: visible.value,
10411
10417
  ...attrs,
10418
+ ...props.dialogEvents,
10412
10419
  "onUpdate:modelValue": handleUpdateModelValue,
10413
10420
  "onClosed": handleClosed,
10414
10421
  "ref": dialogRef
@@ -10464,10 +10471,14 @@
10464
10471
  /**
10465
10472
  * 合并弹窗组件的事件处理函数。
10466
10473
  */
10467
- const dialogEvents = { onClose() {
10468
- options?.events?.onClose?.();
10469
- (0, vue.render)(null, container);
10470
- } };
10474
+ const dialogEvents = {
10475
+ ...options.dialogEvents,
10476
+ onClose() {
10477
+ options.dialogEvents?.onClose?.();
10478
+ options?.events?.onClose?.();
10479
+ (0, vue.render)(null, container);
10480
+ }
10481
+ };
10471
10482
  document.body.appendChild(container);
10472
10483
  /**
10473
10484
  * 动态加载内容组件并渲染弹窗。
@@ -10480,7 +10491,7 @@
10480
10491
  });
10481
10492
  dialogVNode = (0, vue.createVNode)(posterComponent, {
10482
10493
  ...dialogProps,
10483
- ...dialogEvents
10494
+ dialogEvents
10484
10495
  }, { default: () => contentVNode });
10485
10496
  (0, vue.render)(dialogVNode, container);
10486
10497
  });
@@ -10591,7 +10602,7 @@
10591
10602
  });
10592
10603
  const progressStyles = (0, vue.computed)(() => {
10593
10604
  const styles = {};
10594
- styles.height = convertValueToViewportWidth(props.strokeWidth);
10605
+ Object.assign(styles, ns.cssVarBlock({ height: convertValueToViewportWidth(props.strokeWidth) }));
10595
10606
  return styles;
10596
10607
  });
10597
10608
  const innerStyles = (0, vue.computed)(() => {
@@ -10604,8 +10615,10 @@
10604
10615
  });
10605
10616
  const circleStyles = (0, vue.computed)(() => {
10606
10617
  const styles = {};
10607
- styles.width = convertValueToViewportWidth(props.width);
10608
- styles.height = convertValueToViewportWidth(props.width);
10618
+ Object.assign(styles, ns.cssVarBlock({
10619
+ width: convertValueToViewportWidth(props.width),
10620
+ height: convertValueToViewportWidth(props.width)
10621
+ }));
10609
10622
  return styles;
10610
10623
  });
10611
10624
  const content = (0, vue.computed)(() => {
@@ -19588,8 +19601,7 @@ triggerRef });
19588
19601
  const emits = __emit;
19589
19602
  const ns = useNamespace("tabs");
19590
19603
  const tabsRef = (0, vue.ref)();
19591
- const barStyles = (0, vue.ref)({});
19592
- const lineStyles = (0, vue.ref)({});
19604
+ const mounted = (0, vue.ref)(false);
19593
19605
  const currentTabName = (0, vue.computed)({
19594
19606
  get() {
19595
19607
  return props.modelValue;
@@ -19604,50 +19616,40 @@ triggerRef });
19604
19616
  onChange,
19605
19617
  type: props.type
19606
19618
  });
19607
- function getActiveTabElement() {
19608
- if (!tabsRef.value) return null;
19609
- for (let index = 0; index < children.length; index++) {
19610
- const child = children[index];
19611
- if (!child.exposed || !isTabContext(child.exposed) || !child.exposed.isActive.value) continue;
19612
- return tabsRef.value.querySelector(`#tab-${index}`);
19613
- }
19614
- return null;
19615
- }
19616
- async function updateActiveStyles() {
19617
- await (0, vue.nextTick)();
19618
- const $el = getActiveTabElement();
19619
- if (!$el) {
19620
- barStyles.value = {};
19621
- lineStyles.value = {};
19622
- return;
19623
- }
19624
- barStyles.value = {
19625
- width: `${$el.clientWidth}px`,
19626
- left: `${$el.offsetLeft}px`
19627
- };
19619
+ const barStyles = (0, vue.computed)(() => {
19628
19620
  const styles = {};
19629
- const tabStyles = window.getComputedStyle($el);
19630
- styles.width = `${$el.clientWidth - (0, _mingto_tools.beParsedAsNumber)(tabStyles.paddingLeft) - (0, _mingto_tools.beParsedAsNumber)(tabStyles.paddingRight)}px`;
19631
- styles.left = `${$el.offsetLeft + (0, _mingto_tools.beParsedAsNumber)(tabStyles.paddingLeft)}px`;
19632
- lineStyles.value = styles;
19633
- }
19621
+ if (tabsRef.value) children.forEach((child, index) => {
19622
+ const $el = tabsRef.value.querySelector(`#tab-${index}`);
19623
+ if (!$el) return;
19624
+ if (!child.exposed || !isTabContext(child.exposed) || !(0, vue.unref)(child.exposed.isActive)) return;
19625
+ styles.width = `${$el.clientWidth}px`;
19626
+ styles.left = `${$el.offsetLeft}px`;
19627
+ });
19628
+ return styles;
19629
+ });
19630
+ const lineStyles = (0, vue.computed)(() => {
19631
+ const styles = {};
19632
+ if (tabsRef.value) children.forEach((child, index) => {
19633
+ const $el = tabsRef.value.querySelector(`#tab-${index}`);
19634
+ if (!$el) return;
19635
+ if (!child.exposed || !isTabContext(child.exposed) || !(0, vue.unref)(child.exposed.isActive)) return;
19636
+ const tabStyles = window.getComputedStyle($el);
19637
+ const paddingLeft = (0, _mingto_tools.beParsedAsNumber)(tabStyles.paddingLeft);
19638
+ const paddingRight = (0, _mingto_tools.beParsedAsNumber)(tabStyles.paddingRight);
19639
+ styles.width = `${Math.max($el.clientWidth - paddingLeft - paddingRight, 0)}px`;
19640
+ styles.left = `${$el.offsetLeft + paddingLeft}px`;
19641
+ });
19642
+ return styles;
19643
+ });
19634
19644
  const tabsClasses = (0, vue.computed)(() => {
19635
19645
  return [ns.b(), ns.m(props.type)];
19636
19646
  });
19637
19647
  function onChange(tabName) {
19638
19648
  currentTabName.value = tabName;
19639
19649
  }
19640
- (0, vue.watch)(() => [
19641
- currentTabName.value,
19642
- children.length,
19643
- props.type
19644
- ], updateActiveStyles, { flush: "post" });
19645
- (0, vue.onMounted)(() => {
19646
- updateActiveStyles();
19647
- window.addEventListener("resize", updateActiveStyles);
19648
- });
19649
- (0, vue.onBeforeUnmount)(() => {
19650
- window.removeEventListener("resize", updateActiveStyles);
19650
+ (0, vue.onMounted)(async () => {
19651
+ await (0, vue.nextTick)();
19652
+ mounted.value = true;
19651
19653
  });
19652
19654
  return (_ctx, _cache) => {
19653
19655
  return (0, vue.openBlock)(), (0, vue.createElementBlock)("div", {
@@ -19660,12 +19662,12 @@ triggerRef });
19660
19662
  class: (0, vue.normalizeClass)((0, vue.unref)(ns).e("active-bar")),
19661
19663
  style: (0, vue.normalizeStyle)(barStyles.value)
19662
19664
  }, null, 6)) : (0, vue.createCommentVNode)("", true),
19663
- props.type === "line" ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("div", {
19665
+ (0, vue.renderSlot)(_ctx.$slots, "default"),
19666
+ props.type === "line" ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("span", {
19664
19667
  key: 1,
19665
19668
  class: (0, vue.normalizeClass)((0, vue.unref)(ns).e("active-line")),
19666
19669
  style: (0, vue.normalizeStyle)(lineStyles.value)
19667
- }, null, 6)) : (0, vue.createCommentVNode)("", true),
19668
- (0, vue.renderSlot)(_ctx.$slots, "default")
19670
+ }, null, 6)) : (0, vue.createCommentVNode)("", true)
19669
19671
  ], 2);
19670
19672
  };
19671
19673
  }
@@ -19816,6 +19818,12 @@ triggerRef });
19816
19818
  disabled: props.disabled,
19817
19819
  visible: props.visible,
19818
19820
  offset: props.offset,
19821
+ "show-arrow": props["visible-arrow"],
19822
+ "popper-options": props["popper-options"],
19823
+ "show-after": props["show-after"],
19824
+ "hide-after": props["hide-after"],
19825
+ "auto-close": props["auto-close"],
19826
+ "popper-class": props["popper-class"],
19819
19827
  enterable: props.enterable,
19820
19828
  "onUpdate:visible": _cache[0] || (_cache[0] = ($event) => emits("update:visible", $event))
19821
19829
  }), (0, vue.createSlots)({ _: 2 }, [(0, vue.unref)(slots).default ? {
@@ -19835,6 +19843,12 @@ triggerRef });
19835
19843
  "disabled",
19836
19844
  "visible",
19837
19845
  "offset",
19846
+ "show-arrow",
19847
+ "popper-options",
19848
+ "show-after",
19849
+ "hide-after",
19850
+ "auto-close",
19851
+ "popper-class",
19838
19852
  "enterable"
19839
19853
  ]);
19840
19854
  };
@@ -1,4 +1,4 @@
1
- export declare const MtMessage: ((options: import('./src/message').MessageParamsNormalized | import('./src/message').MessageParamsNormalized["message"]) => void) & Record<"error" | "success" | "warning", (options: import('./src/message').MessageParamsNormalized | import('./src/message').MessageParamsNormalized["message"]) => void> & {
1
+ export declare const MtMessage: ((options: import('./src/message').MessageParamsNormalized | import('./src/message').MessageParamsNormalized["message"]) => import('./src/message').MessageHandler) & Record<"error" | "success" | "warning", (options: import('./src/message').MessageParamsNormalized | import('./src/message').MessageParamsNormalized["message"]) => import('./src/message').MessageHandler> & {
2
2
  closeAll: (type?: import('./src/message').MessageTypes) => void;
3
3
  } & import('vue').Plugin;
4
4
  export default MtMessage;
@@ -56,14 +56,14 @@ declare const messageProps: {
56
56
  };
57
57
  type MessageProps = ExtractPropTypes<typeof messageProps>;
58
58
  type MessageInstance = InstanceType<typeof MessageConstructor>;
59
- type MessageFunction = {
60
- (options: MessageParamsNormalized | MessageParamsNormalized['message']): void;
61
- } & Record<MessageTypes, (options: MessageParamsNormalized | MessageParamsNormalized['message']) => void> & {
62
- closeAll: (type?: MessageTypes) => void;
63
- };
64
59
  interface MessageHandler {
65
60
  close: () => void;
66
61
  }
62
+ type MessageFunction = {
63
+ (options: MessageParamsNormalized | MessageParamsNormalized['message']): MessageHandler;
64
+ } & Record<MessageTypes, (options: MessageParamsNormalized | MessageParamsNormalized['message']) => MessageHandler> & {
65
+ closeAll: (type?: MessageTypes) => void;
66
+ };
67
67
  type MessageParamsNormalized = Partial<Omit<MessageProps, 'id'>> & Pick<MessageProps, 'message'>;
68
68
  export type { MessageFunction, MessageHandler, MessageInstance, MessageParamsNormalized, MessageProps, MessageTypes, };
69
69
  export { messageProps, messageTypes, };
@@ -1,5 +1,8 @@
1
1
  import { Component } from 'vue';
2
2
  import { DialogProps } from '../../dialog';
3
+ type DialogEvents = {
4
+ onClose?: () => void;
5
+ };
3
6
  /**
4
7
  * PosterOptions 接口定义了 Poster 函数的参数结构。
5
8
  */
@@ -25,7 +28,7 @@ interface PosterOptions {
25
28
  /**
26
29
  * 传递给弹窗组件的事件处理函数。
27
30
  */
28
- dialogEvents?: Record<string, (...args: unknown[]) => void>;
31
+ dialogEvents?: DialogEvents;
29
32
  }
30
33
  /**
31
34
  * PosterReturn 接口定义了 Poster 函数的返回值结构。