@varlet/ui 3.20.5 → 3.20.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
3
3
  "framework": "vue",
4
- "version": "3.20.5",
4
+ "version": "3.20.7",
5
5
  "name": "VARLET",
6
6
  "contributions": {
7
7
  "html": {
@@ -4125,6 +4125,15 @@
4125
4125
  "kind": "expression"
4126
4126
  }
4127
4127
  },
4128
+ {
4129
+ "name": "expandable-on-overflow",
4130
+ "description": "Allow expansion only if the text is overflowed",
4131
+ "default": "false",
4132
+ "value": {
4133
+ "type": "boolean",
4134
+ "kind": "expression"
4135
+ }
4136
+ },
4128
4137
  {
4129
4138
  "name": "line-clamp",
4130
4139
  "description": "Maximum number of display lines, see [line-clamp](https://caniuse.com/?search=line-clamp) for compatibility",
@@ -4134,6 +4143,15 @@
4134
4143
  "kind": "expression"
4135
4144
  }
4136
4145
  },
4146
+ {
4147
+ "name": "tooltip-on-overflow",
4148
+ "description": "Show the tooltip only when the text is truncated",
4149
+ "default": "false",
4150
+ "value": {
4151
+ "type": "boolean",
4152
+ "kind": "expression"
4153
+ }
4154
+ },
4137
4155
  {
4138
4156
  "name": "tooltip",
4139
4157
  "description": "Tooltip component props, for deep customization. For more convenience, `sameWidth` defaults to `true` here",
@@ -6788,6 +6806,24 @@
6788
6806
  "type": "boolean | object",
6789
6807
  "kind": "expression"
6790
6808
  }
6809
+ },
6810
+ {
6811
+ "name": "active",
6812
+ "description": "Whether to enable the persistent active effect. It uses a translucent primary-color overlay and text color by default and supports object form `{ color?: string }`",
6813
+ "default": "false",
6814
+ "value": {
6815
+ "type": "boolean | object",
6816
+ "kind": "expression"
6817
+ }
6818
+ },
6819
+ {
6820
+ "name": "disabled",
6821
+ "description": "Whether to disable interaction. When disabled, click, hover, and ripple effects are disabled and only a disabled cursor is shown",
6822
+ "default": "false",
6823
+ "value": {
6824
+ "type": "boolean",
6825
+ "kind": "expression"
6826
+ }
6791
6827
  }
6792
6828
  ],
6793
6829
  "events": [
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
3
3
  "framework": "vue",
4
- "version": "3.20.5",
4
+ "version": "3.20.7",
5
5
  "name": "VARLET",
6
6
  "contributions": {
7
7
  "html": {
@@ -3876,6 +3876,15 @@
3876
3876
  "kind": "expression"
3877
3877
  }
3878
3878
  },
3879
+ {
3880
+ "name": "expandable-on-overflow",
3881
+ "description": "仅在文本被省略时允许展开",
3882
+ "default": "false",
3883
+ "value": {
3884
+ "type": "boolean",
3885
+ "kind": "expression"
3886
+ }
3887
+ },
3879
3888
  {
3880
3889
  "name": "line-clamp",
3881
3890
  "description": "最大显示行数,兼容性见 [line-clamp](https://caniuse.com/?search=line-clamp)",
@@ -3885,6 +3894,15 @@
3885
3894
  "kind": "expression"
3886
3895
  }
3887
3896
  },
3897
+ {
3898
+ "name": "tooltip-on-overflow",
3899
+ "description": "仅在文本被省略时显示 Tooltip",
3900
+ "default": "false",
3901
+ "value": {
3902
+ "type": "boolean",
3903
+ "kind": "expression"
3904
+ }
3905
+ },
3888
3906
  {
3889
3907
  "name": "tooltip",
3890
3908
  "description": "Tooltip 组件配置,用于深度定制。为了更方便使用,`sameWidth` 在这里默认为 `true`",
@@ -6530,6 +6548,24 @@
6530
6548
  "type": "boolean | object",
6531
6549
  "kind": "expression"
6532
6550
  }
6551
+ },
6552
+ {
6553
+ "name": "active",
6554
+ "description": "是否开启常驻激活效果,默认使用主色半透明叠层和文字颜色,支持对象形式 `{ color?: string }`",
6555
+ "default": "false",
6556
+ "value": {
6557
+ "type": "boolean | object",
6558
+ "kind": "expression"
6559
+ }
6560
+ },
6561
+ {
6562
+ "name": "disabled",
6563
+ "description": "是否禁用交互。禁用后不触发点击、悬停和水波效果,仅显示禁用光标",
6564
+ "default": "false",
6565
+ "value": {
6566
+ "type": "boolean",
6567
+ "kind": "expression"
6568
+ }
6533
6569
  }
6534
6570
  ],
6535
6571
  "events": [
package/lib/varlet.cjs.js CHANGED
@@ -18413,7 +18413,9 @@ var stdin_default$99 = stdin_default$397;
18413
18413
  var props$32 = {
18414
18414
  expand: Boolean,
18415
18415
  expandTrigger: String,
18416
+ expandableOnOverflow: Boolean,
18416
18417
  lineClamp: [Number, String],
18418
+ tooltipOnOverflow: Boolean,
18417
18419
  tooltip: {
18418
18420
  type: [Object, Boolean],
18419
18421
  default: true
@@ -18444,11 +18446,12 @@ var _hoisted_1$26 = { key: 0 };
18444
18446
  function __render__$53(_ctx, _cache) {
18445
18447
  const _component_var_tooltip = (0, vue.resolveComponent)("var-tooltip");
18446
18448
  return (0, vue.openBlock)(), (0, vue.createBlock)(_component_var_tooltip, (0, vue.mergeProps)({
18449
+ ref: "rootRef",
18447
18450
  class: _ctx.classes(_ctx.n(), [
18448
18451
  _ctx.lineClamp,
18449
18452
  _ctx.n("--clamp"),
18450
18453
  _ctx.n("--line")
18451
- ], [_ctx.expandTrigger, _ctx.n("--cursor")], [_ctx.expanding, _ctx.n("--expand")]),
18454
+ ], [_ctx.clickable, _ctx.n("--cursor")], [_ctx.expanding, _ctx.n("--expand")]),
18452
18455
  "var-ellipsis-cover": "",
18453
18456
  style: _ctx.rootStyles
18454
18457
  }, _ctx.tooltipProps, { onClick: _ctx.handleClick }), {
@@ -18469,24 +18472,54 @@ var __sfc__$53 = (0, vue.defineComponent)({
18469
18472
  components: { VarTooltip: stdin_default$99 },
18470
18473
  props: props$32,
18471
18474
  setup(props2) {
18475
+ const rootRef = (0, vue.ref)(null);
18476
+ const truncated = (0, vue.ref)(false);
18472
18477
  const expanding = useVModel(props2, "expand");
18478
+ let previousWidth;
18479
+ const clickable = (0, vue.computed)(() => !!props2.expandTrigger && (!props2.expandableOnOverflow || truncated.value || expanding.value));
18473
18480
  const rootStyles = (0, vue.computed)(() => props2.lineClamp ? { "-webkit-line-clamp": props2.lineClamp } : {});
18474
18481
  const tooltipProps = (0, vue.computed)(() => {
18475
- if (props2.tooltip === false) return { disabled: true };
18482
+ if (props2.tooltip === false || props2.tooltipOnOverflow && !truncated.value) return { disabled: true };
18476
18483
  if (props2.tooltip === true) return { sameWidth: true };
18477
18484
  return __spreadValues$13({ sameWidth: true }, props2.tooltip);
18478
18485
  });
18486
+ function getRootElement() {
18487
+ var _a;
18488
+ if (!rootRef.value) return null;
18489
+ return (_a = rootRef.value.$el) != null ? _a : rootRef.value;
18490
+ }
18491
+ function checkTruncated() {
18492
+ const element = getRootElement();
18493
+ if (!element) return;
18494
+ const next = props2.lineClamp ? element.scrollHeight > element.clientHeight : element.scrollWidth > element.clientWidth;
18495
+ if (next !== truncated.value) truncated.value = next;
18496
+ }
18479
18497
  function handleClick() {
18480
- if (!props2.expandTrigger) return;
18498
+ if (!clickable.value) return;
18481
18499
  expanding.value = !expanding.value;
18482
18500
  }
18501
+ function handleResize(entries) {
18502
+ var _a;
18503
+ const width = (_a = entries[0]) == null ? void 0 : _a.contentRect.width;
18504
+ if (width !== void 0 && width !== previousWidth && previousWidth !== void 0 && props2.expandableOnOverflow && expanding.value) expanding.value = false;
18505
+ previousWidth = width;
18506
+ checkTruncated();
18507
+ }
18508
+ useResizeObserver(getRootElement, handleResize);
18509
+ (0, vue.watch)(() => props2.lineClamp, checkTruncated);
18510
+ onSmartMounted(checkTruncated);
18511
+ (0, vue.onUpdated)(checkTruncated);
18483
18512
  return {
18513
+ rootRef,
18514
+ truncated,
18515
+ clickable,
18484
18516
  tooltipProps,
18485
18517
  expanding,
18486
18518
  rootStyles,
18487
18519
  n: n$55,
18488
18520
  classes: classes$44,
18489
- handleClick
18521
+ handleClick,
18522
+ handleResize
18490
18523
  };
18491
18524
  }
18492
18525
  });
@@ -21733,6 +21766,11 @@ var props$55 = {
21733
21766
  type: [Boolean, Object],
21734
21767
  default: false
21735
21768
  },
21769
+ active: {
21770
+ type: [Boolean, Object],
21771
+ default: false
21772
+ },
21773
+ disabled: Boolean,
21736
21774
  onClick: defineListenerProp()
21737
21775
  };
21738
21776
  //#endregion
@@ -21743,18 +21781,26 @@ function __render__$39(_ctx, _cache) {
21743
21781
  const _directive_ripple = (0, vue.resolveDirective)("ripple");
21744
21782
  const _directive_hover = (0, vue.resolveDirective)("hover");
21745
21783
  return (0, vue.withDirectives)(((0, vue.openBlock)(), (0, vue.createElementBlock)("div", {
21746
- class: (0, vue.normalizeClass)(_ctx.classes(_ctx.n(), _ctx.n("$--box"), [_ctx.variant === "standard", _ctx.formatElevation(_ctx.elevation, 2)], [_ctx.onClick || !_ctx.normalizedHoverable.disabled, _ctx.n("--cursor")], [_ctx.round, _ctx.n("--round")], [_ctx.surfaceLow, _ctx.n("--surface-low")], [_ctx.variant === "outlined", _ctx.n("--outlined")], [_ctx.variant === "filled", _ctx.n("--filled")], [_ctx.inline, _ctx.n("$--inline-flex")])),
21784
+ class: (0, vue.normalizeClass)(_ctx.classes(_ctx.n(), _ctx.n("$--box"), [_ctx.variant === "standard", _ctx.formatElevation(_ctx.elevation, 2)], [!_ctx.disabled && (_ctx.onClick || !_ctx.normalizedHoverable.disabled), _ctx.n("--cursor")], [_ctx.disabled, _ctx.n("--disabled")], [!_ctx.disabled && _ctx.normalizedActive.enabled, _ctx.n("--active")], [_ctx.round, _ctx.n("--round")], [_ctx.surfaceLow, _ctx.n("--surface-low")], [_ctx.variant === "outlined", _ctx.n("--outlined")], [_ctx.variant === "filled", _ctx.n("--filled")], [_ctx.inline, _ctx.n("$--inline-flex")])),
21747
21785
  style: (0, vue.normalizeStyle)({
21748
21786
  width: _ctx.toSizeUnit(_ctx.width),
21749
21787
  height: _ctx.toSizeUnit(_ctx.height),
21750
- "border-radius": _ctx.toSizeUnit(_ctx.radius)
21788
+ "border-radius": _ctx.toSizeUnit(_ctx.radius),
21789
+ "--paper-active-color": _ctx.normalizedActive.color
21751
21790
  }),
21752
21791
  onClick: _cache[0] || (_cache[0] = (...args) => _ctx.handleClick && _ctx.handleClick(...args))
21753
- }, [(0, vue.renderSlot)(_ctx.$slots, "default"), (0, vue.createVNode)(_component_var_hover_overlay, {
21754
- hovering: !_ctx.normalizedHoverable.disabled ? _ctx.hovering : false,
21755
- color: _ctx.normalizedHoverable.color
21756
- }, null, 8, ["hovering", "color"])], 6)), [[_directive_ripple, {
21757
- disabled: _ctx.normalizedRipple.disabled,
21792
+ }, [
21793
+ (0, vue.renderSlot)(_ctx.$slots, "default"),
21794
+ (0, vue.createVNode)(_component_var_hover_overlay, {
21795
+ class: (0, vue.normalizeClass)(_ctx.n("active-overlay")),
21796
+ hovering: !_ctx.disabled && _ctx.normalizedActive.enabled
21797
+ }, null, 8, ["class", "hovering"]),
21798
+ (0, vue.createVNode)(_component_var_hover_overlay, {
21799
+ hovering: !_ctx.disabled && !_ctx.normalizedHoverable.disabled ? _ctx.hovering : false,
21800
+ color: _ctx.normalizedHoverable.color
21801
+ }, null, 8, ["hovering", "color"])
21802
+ ], 6)), [[_directive_ripple, {
21803
+ disabled: _ctx.disabled || _ctx.normalizedRipple.disabled,
21758
21804
  color: _ctx.normalizedRipple.color
21759
21805
  }], [
21760
21806
  _directive_hover,
@@ -21775,6 +21821,7 @@ var __sfc__$39 = (0, vue.defineComponent)({
21775
21821
  const { hovering, handleHovering } = useHoverOverlay();
21776
21822
  const normalizedRipple = (0, vue.computed)(() => normalizeRipple(props2.ripple));
21777
21823
  const normalizedHoverable = (0, vue.computed)(() => normalizeHoverable(props2.hoverable));
21824
+ const normalizedActive = (0, vue.computed)(() => normalizeActive(props2.active));
21778
21825
  function normalizeRipple(value) {
21779
21826
  if (isPlainObject(value)) return {
21780
21827
  disabled: !!value.disabled,
@@ -21795,7 +21842,18 @@ var __sfc__$39 = (0, vue.defineComponent)({
21795
21842
  color: void 0
21796
21843
  };
21797
21844
  }
21845
+ function normalizeActive(value) {
21846
+ if (isPlainObject(value)) return {
21847
+ enabled: true,
21848
+ color: value.color
21849
+ };
21850
+ return {
21851
+ enabled: value,
21852
+ color: void 0
21853
+ };
21854
+ }
21798
21855
  function handleClick(e) {
21856
+ if (props2.disabled) return;
21799
21857
  call(props2.onClick, e);
21800
21858
  }
21801
21859
  return {
@@ -21805,6 +21863,7 @@ var __sfc__$39 = (0, vue.defineComponent)({
21805
21863
  surfaceLow,
21806
21864
  normalizedRipple,
21807
21865
  normalizedHoverable,
21866
+ normalizedActive,
21808
21867
  hovering,
21809
21868
  handleHovering,
21810
21869
  toSizeUnit,
@@ -27700,7 +27759,9 @@ var stdin_default$297 = {
27700
27759
  "--paper-outlined-background": "transparent",
27701
27760
  "--paper-filled-background": "var(--color-surface-container-highest)",
27702
27761
  "--paper-outline-color": "var(--color-outline)",
27703
- "--paper-border-radius": "4px"
27762
+ "--paper-border-radius": "4px",
27763
+ "--paper-active-color": "var(--color-primary)",
27764
+ "--paper-active-opacity": "0.2"
27704
27765
  };
27705
27766
  //#endregion
27706
27767
  //#region es/themes/dark/picker.mjs
@@ -29080,7 +29141,9 @@ var stdin_default$221 = {
29080
29141
  "--paper-outlined-background": "transparent",
29081
29142
  "--paper-filled-background": "var(--color-surface-container-highest)",
29082
29143
  "--paper-outline-color": "var(--color-outline)",
29083
- "--paper-border-radius": "12px"
29144
+ "--paper-border-radius": "12px",
29145
+ "--paper-active-color": "var(--color-primary)",
29146
+ "--paper-active-opacity": "0.2"
29084
29147
  };
29085
29148
  //#endregion
29086
29149
  //#region es/themes/md3-dark/picker.mjs
@@ -30445,7 +30508,9 @@ var stdin_default$145 = {
30445
30508
  "--paper-outlined-background": "transparent",
30446
30509
  "--paper-filled-background": "var(--color-surface-container-highest)",
30447
30510
  "--paper-outline-color": "var(--color-outline)",
30448
- "--paper-border-radius": "12px"
30511
+ "--paper-border-radius": "12px",
30512
+ "--paper-active-color": "var(--color-primary)",
30513
+ "--paper-active-opacity": "0.2"
30449
30514
  };
30450
30515
  //#endregion
30451
30516
  //#region es/themes/md3-light/picker.mjs
@@ -32845,7 +32910,7 @@ var _WatermarkComponent = stdin_default$108;
32845
32910
  var stdin_default$102 = stdin_default$108;
32846
32911
  //#endregion
32847
32912
  //#region es/index.bundle.mjs
32848
- var version = "3.20.5";
32913
+ var version = "3.20.7";
32849
32914
  function install(app) {
32850
32915
  stdin_default.install && app.use(stdin_default);
32851
32916
  stdin_default$1.install && app.use(stdin_default$1);