@varlet/ui 3.0.3 → 3.0.4

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/lib/varlet.cjs.js CHANGED
@@ -45,6 +45,7 @@ var isEmpty = (val) => val === void 0 || val === null || val === "" || Array.isA
45
45
  var isWindow = (val) => val === window;
46
46
  var supportTouch = () => inBrowser() && "ontouchstart" in window;
47
47
  var inBrowser = () => typeof window !== "undefined";
48
+ var inMobile = () => inBrowser() && /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
48
49
  var { hasOwnProperty } = Object.prototype;
49
50
  var hasOwn = (val, key) => hasOwnProperty.call(val, key);
50
51
  var uniq = (arr) => [...new Set(arr)];
@@ -810,13 +811,16 @@ function setStyles(element) {
810
811
  position === "static" && (element.style.position = "relative");
811
812
  zIndex === "auto" && (element.style.zIndex = "1");
812
813
  }
814
+ function isTouchEvent(event) {
815
+ return hasOwn(event, "touches");
816
+ }
813
817
  function computeRippleStyles(element, event) {
814
818
  const { top: top2, left: left2 } = getRect(element);
815
819
  const { clientWidth, clientHeight } = element;
816
820
  const radius = Math.sqrt(clientWidth ** 2 + clientHeight ** 2) / 2;
817
821
  const size = radius * 2;
818
- const localX = event.touches[0].clientX - left2;
819
- const localY = event.touches[0].clientY - top2;
822
+ const localX = isTouchEvent(event) ? event.touches[0].clientX - left2 : clientWidth / 2;
823
+ const localY = isTouchEvent(event) ? event.touches[0].clientY - top2 : clientHeight / 2;
820
824
  const centerX = (clientWidth - radius * 2) / 2;
821
825
  const centerY = (clientHeight - radius * 2) / 2;
822
826
  const x = localX - radius;
@@ -876,6 +880,21 @@ function forbidRippleTask() {
876
880
  _ripple.tasker && window.clearTimeout(_ripple.tasker);
877
881
  _ripple.tasker = null;
878
882
  }
883
+ let hasKeyboardRipple = false;
884
+ function createKeyboardRipple(event) {
885
+ if (hasKeyboardRipple || !(event.key === " " || event.key === "Enter")) {
886
+ return;
887
+ }
888
+ createRipple.call(this, event);
889
+ hasKeyboardRipple = true;
890
+ }
891
+ function removeKeyboardRipple() {
892
+ if (!hasKeyboardRipple) {
893
+ return;
894
+ }
895
+ removeRipple.call(this);
896
+ hasKeyboardRipple = false;
897
+ }
879
898
  function mounted$2(el, binding) {
880
899
  var _a;
881
900
  el._ripple = __spreadProps$8(__spreadValues$u({
@@ -886,6 +905,9 @@ function mounted$2(el, binding) {
886
905
  el.addEventListener("touchstart", createRipple, { passive: true });
887
906
  el.addEventListener("touchmove", forbidRippleTask, { passive: true });
888
907
  el.addEventListener("dragstart", removeRipple, { passive: true });
908
+ el.addEventListener("keydown", createKeyboardRipple);
909
+ el.addEventListener("keyup", removeKeyboardRipple);
910
+ el.addEventListener("blur", removeKeyboardRipple);
889
911
  document.addEventListener("touchend", el._ripple.removeRipple, { passive: true });
890
912
  document.addEventListener("touchcancel", el._ripple.removeRipple, { passive: true });
891
913
  document.addEventListener("dragend", el._ripple.removeRipple, { passive: true });
@@ -2188,7 +2210,12 @@ const props$1d = {
2188
2210
  round: Boolean,
2189
2211
  image: String,
2190
2212
  imageLinearGradient: String,
2191
- safeAreaTop: Boolean
2213
+ safeAreaTop: Boolean,
2214
+ zIndex: {
2215
+ type: [Number, String],
2216
+ default: 1
2217
+ },
2218
+ fixed: Boolean
2192
2219
  };
2193
2220
  const { name: name$1d, n: n$1k, classes: classes$16 } = createNamespace("app-bar");
2194
2221
  function __render__$1k(_ctx, _cache) {
@@ -2201,6 +2228,7 @@ function __render__$1k(_ctx, _cache) {
2201
2228
  _ctx.n("$--box"),
2202
2229
  [_ctx.safeAreaTop, _ctx.n("--safe-area-top")],
2203
2230
  [_ctx.round, _ctx.n("--round")],
2231
+ [_ctx.fixed, _ctx.n("--fixed")],
2204
2232
  _ctx.formatElevation(_ctx.elevation, 3)
2205
2233
  )
2206
2234
  ),
@@ -2308,18 +2336,20 @@ const __sfc__$1l = vue.defineComponent({
2308
2336
  const paddingLeft = vue.ref();
2309
2337
  const paddingRight = vue.ref();
2310
2338
  const rootStyles = vue.computed(() => {
2311
- const { image, color, textColor, imageLinearGradient } = props2;
2339
+ const { image, color, textColor, imageLinearGradient, zIndex } = props2;
2312
2340
  if (image != null) {
2313
2341
  const gradient = imageLinearGradient ? `linear-gradient(${imageLinearGradient}), ` : "";
2314
2342
  return {
2315
2343
  "background-image": `${gradient}url(${image})`,
2316
2344
  "background-position": "center center",
2317
- "background-size": "cover"
2345
+ "background-size": "cover",
2346
+ "z-index": zIndex
2318
2347
  };
2319
2348
  }
2320
2349
  return {
2321
2350
  background: color,
2322
- color: textColor
2351
+ color: textColor,
2352
+ "z-index": zIndex
2323
2353
  };
2324
2354
  });
2325
2355
  onSmartMounted(computePadding);
@@ -2998,17 +3028,15 @@ withPropsDefaultsSetter(stdin_default$5z, props$1a);
2998
3028
  const _LoadingComponent = stdin_default$5z;
2999
3029
  var stdin_default$5y = stdin_default$5z;
3000
3030
  const props$19 = {
3001
- hovering: {
3002
- type: Boolean,
3003
- default: true
3004
- }
3031
+ hovering: Boolean,
3032
+ focusing: Boolean
3005
3033
  };
3006
3034
  const { name: name$19, n: n$1g, classes: classes$12 } = createNamespace("hover-overlay");
3007
3035
  function __render__$1g(_ctx, _cache) {
3008
3036
  return vue.openBlock(), vue.createElementBlock(
3009
3037
  "div",
3010
3038
  {
3011
- class: vue.normalizeClass(_ctx.classes(_ctx.n(), [_ctx.hovering, _ctx.n("--hovering")]))
3039
+ class: vue.normalizeClass(_ctx.classes(_ctx.n(), [_ctx.hovering, _ctx.n("--hovering")], [_ctx.focusing, _ctx.n("--focusing")]))
3012
3040
  },
3013
3041
  null,
3014
3042
  2
@@ -3043,11 +3071,10 @@ function shouldDisabled(arg) {
3043
3071
  if (!arg) {
3044
3072
  return false;
3045
3073
  }
3046
- const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
3047
- if (arg === "desktop" && isMobile) {
3074
+ if (arg === "desktop" && inMobile()) {
3048
3075
  return true;
3049
3076
  }
3050
- if (arg === "mobile" && !isMobile) {
3077
+ if (arg === "mobile" && !inMobile()) {
3051
3078
  return true;
3052
3079
  }
3053
3080
  return false;
@@ -3261,7 +3288,9 @@ function __render__$1f(_ctx, _cache) {
3261
3288
  type: _ctx.nativeType,
3262
3289
  disabled: _ctx.disabled,
3263
3290
  onClick: _cache[0] || (_cache[0] = (...args) => _ctx.handleClick && _ctx.handleClick(...args)),
3264
- onTouchstart: _cache[1] || (_cache[1] = (...args) => _ctx.handleTouchstart && _ctx.handleTouchstart(...args))
3291
+ onTouchstart: _cache[1] || (_cache[1] = (...args) => _ctx.handleTouchstart && _ctx.handleTouchstart(...args)),
3292
+ onFocus: _cache[2] || (_cache[2] = ($event) => _ctx.isEffectFocusing = true),
3293
+ onBlur: _cache[3] || (_cache[3] = ($event) => _ctx.isEffectFocusing = false)
3265
3294
  }, [
3266
3295
  _ctx.loading || _ctx.pending ? (vue.openBlock(), vue.createBlock(_component_var_loading, {
3267
3296
  key: 0,
@@ -3284,8 +3313,9 @@ function __render__$1f(_ctx, _cache) {
3284
3313
  /* CLASS */
3285
3314
  ),
3286
3315
  vue.createVNode(_component_var_hover_overlay, {
3287
- hovering: _ctx.disabled || _ctx.loading || _ctx.pending ? false : _ctx.hovering
3288
- }, null, 8, ["hovering"])
3316
+ hovering: _ctx.disabled || _ctx.loading || _ctx.pending ? false : _ctx.hovering,
3317
+ focusing: _ctx.disabled || _ctx.loading || _ctx.pending ? false : _ctx.isEffectFocusing
3318
+ }, null, 8, ["hovering", "focusing"])
3289
3319
  ], 46, _hoisted_1$q)), [
3290
3320
  [_directive_ripple, { disabled: _ctx.disabled || !_ctx.ripple || _ctx.loading || _ctx.pending }],
3291
3321
  [_directive_hover, _ctx.handleHovering, "desktop"]
@@ -3300,6 +3330,7 @@ const __sfc__$1g = vue.defineComponent({
3300
3330
  directives: { Ripple: stdin_default$5T, Hover: stdin_default$5v },
3301
3331
  props: props$18,
3302
3332
  setup(props2) {
3333
+ const isEffectFocusing = inMobile() ? vue.computed(() => false) : vue.ref(false);
3303
3334
  const pending = vue.ref(false);
3304
3335
  const { buttonGroup } = useButtonGroup();
3305
3336
  const { hovering, handleHovering } = useHoverOverlay();
@@ -3361,7 +3392,8 @@ const __sfc__$1g = vue.defineComponent({
3361
3392
  classes: classes$11,
3362
3393
  handleHovering,
3363
3394
  handleClick,
3364
- handleTouchstart
3395
+ handleTouchstart,
3396
+ isEffectFocusing
3365
3397
  };
3366
3398
  }
3367
3399
  });
@@ -13442,6 +13474,7 @@ function usePopover(options) {
13442
13474
  call(options["onUpdate:show"], false);
13443
13475
  };
13444
13476
  useClickOutside(getReference, "click", handleClickOutside);
13477
+ onWindowResize(resize);
13445
13478
  vue.watch(() => [options.offsetX, options.offsetY, options.placement, options.strategy], resize);
13446
13479
  vue.watch(() => options.disabled, close);
13447
13480
  vue.onMounted(() => {
@@ -14591,6 +14624,7 @@ const props$F = {
14591
14624
  },
14592
14625
  alt: String,
14593
14626
  title: String,
14627
+ referrerpolicy: String,
14594
14628
  width: [String, Number],
14595
14629
  height: [String, Number],
14596
14630
  radius: {
@@ -14610,8 +14644,8 @@ const props$F = {
14610
14644
  onError: defineListenerProp()
14611
14645
  };
14612
14646
  const { name: name$F, n: n$I, classes: classes$B } = createNamespace("image");
14613
- const _hoisted_1$j = ["alt", "title", "lazy-loading", "lazy-error"];
14614
- const _hoisted_2$c = ["alt", "title", "src"];
14647
+ const _hoisted_1$j = ["alt", "title", "referrerpolicy", "lazy-loading", "lazy-error"];
14648
+ const _hoisted_2$c = ["alt", "title", "referrerpolicy", "src"];
14615
14649
  function __render__$J(_ctx, _cache) {
14616
14650
  var _a;
14617
14651
  const _directive_lazy = vue.resolveDirective("lazy");
@@ -14633,6 +14667,7 @@ function __render__$J(_ctx, _cache) {
14633
14667
  class: vue.normalizeClass(_ctx.n("image")),
14634
14668
  alt: _ctx.alt,
14635
14669
  title: _ctx.title,
14670
+ referrerpolicy: _ctx.referrerpolicy,
14636
14671
  "lazy-loading": _ctx.loading,
14637
14672
  "lazy-error": _ctx.error,
14638
14673
  style: vue.normalizeStyle({ objectFit: _ctx.fit }),
@@ -14647,6 +14682,7 @@ function __render__$J(_ctx, _cache) {
14647
14682
  class: vue.normalizeClass(_ctx.n("image")),
14648
14683
  alt: _ctx.alt,
14649
14684
  title: _ctx.title,
14685
+ referrerpolicy: _ctx.referrerpolicy,
14650
14686
  style: vue.normalizeStyle({ objectFit: _ctx.fit }),
14651
14687
  src: _ctx.src,
14652
14688
  onLoad: _cache[2] || (_cache[2] = (...args) => _ctx.handleLoad && _ctx.handleLoad(...args)),
@@ -23971,7 +24007,8 @@ var stdin_default$2r = {
23971
24007
  "--form-details-message-margin-right": "4px"
23972
24008
  };
23973
24009
  var stdin_default$2q = {
23974
- "--hover-overlay-opacity": "0.15"
24010
+ "--hover-overlay-opacity": "var(--opacity-hover)",
24011
+ "--hover-overlay-focusing-opacity": "var(--opacity-focus)"
23975
24012
  };
23976
24013
  var stdin_default$2p = {
23977
24014
  "--icon-size": "20px"
@@ -24186,6 +24223,8 @@ var stdin_default$28 = __spreadValues$3(__spreadValues$3(__spreadValues$3(__spre
24186
24223
  "--color-outline": "rgba(255, 255, 255, 0.2)",
24187
24224
  "--color-on-surface-variant": "#fff",
24188
24225
  "--opacity-disabled": "0.6",
24226
+ "--opacity-hover": "0.15",
24227
+ "--opacity-focus": "0.2",
24189
24228
  "--cubic-bezier": "cubic-bezier(0.25, 0.8, 0.5, 1)",
24190
24229
  "--shadow-key-umbra-opacity": "rgba(0, 0, 0, 0.2)",
24191
24230
  "--shadow-key-penumbra-opacity": "rgba(0, 0, 0, 0.14)",
@@ -24234,7 +24273,8 @@ var stdin_default$27 = {
24234
24273
  "--button-large-font-size": "var(--font-size-lg)"
24235
24274
  };
24236
24275
  var stdin_default$26 = {
24237
- "--hover-overlay-opacity": "0.12"
24276
+ "--hover-overlay-opacity": "var(--opacity-hover)",
24277
+ "--hover-overlay-focusing-opacity": "var(--opacity-focus)"
24238
24278
  };
24239
24279
  var stdin_default$25 = {
24240
24280
  "--menu-background-color": "var(--color-surface-container)",
@@ -25088,6 +25128,8 @@ var stdin_default$18 = __spreadValues$2(__spreadValues$2(__spreadValues$2(__spre
25088
25128
  "--color-outline": "#CAC4D0",
25089
25129
  "--color-on-surface-variant": "#49454F",
25090
25130
  "--opacity-disabled": "0.6",
25131
+ "--opacity-hover": "0.12",
25132
+ "--opacity-focus": "0.2",
25091
25133
  "--cubic-bezier": "cubic-bezier(0.25, 0.8, 0.5, 1)",
25092
25134
  "--shadow-key-umbra-opacity": "rgba(0, 0, 0, 0.2)",
25093
25135
  "--shadow-key-penumbra-opacity": "rgba(0, 0, 0, 0.14)",
@@ -25136,7 +25178,8 @@ var stdin_default$17 = {
25136
25178
  "--button-large-font-size": "var(--font-size-lg)"
25137
25179
  };
25138
25180
  var stdin_default$16 = {
25139
- "--hover-overlay-opacity": "0.12"
25181
+ "--hover-overlay-opacity": "var(--opacity-hover)",
25182
+ "--hover-overlay-focusing-opacity": "var(--opacity-focus)"
25140
25183
  };
25141
25184
  var stdin_default$15 = {
25142
25185
  "--menu-background-color": "var(--color-surface-container)",
@@ -26008,6 +26051,8 @@ var stdin_default$8 = __spreadValues$1(__spreadValues$1(__spreadValues$1(__sprea
26008
26051
  "--color-outline": "#49454F",
26009
26052
  "--color-on-surface-variant": "#CAC4D0",
26010
26053
  "--opacity-disabled": "0.6",
26054
+ "--opacity-hover": "0.12",
26055
+ "--opacity-focus": "0.2",
26011
26056
  "--cubic-bezier": "cubic-bezier(0.25, 0.8, 0.5, 1)",
26012
26057
  "--shadow-key-umbra-opacity": "rgba(0, 0, 0, 0.2)",
26013
26058
  "--shadow-key-penumbra-opacity": "rgba(0, 0, 0, 0.14)",
@@ -27709,7 +27754,7 @@ withInstall(stdin_default$1);
27709
27754
  withPropsDefaultsSetter(stdin_default$1, props);
27710
27755
  const _WatermarkComponent = stdin_default$1;
27711
27756
  var stdin_default = stdin_default$1;
27712
- const version = "3.0.3";
27757
+ const version = "3.0.4";
27713
27758
  function install(app) {
27714
27759
  stdin_default$5H.install && app.use(stdin_default$5H);
27715
27760
  stdin_default$5F.install && app.use(stdin_default$5F);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varlet/ui",
3
- "version": "3.0.3",
3
+ "version": "3.0.4",
4
4
  "description": "A material like components library",
5
5
  "main": "lib/varlet.cjs.js",
6
6
  "module": "es/index.mjs",
@@ -48,9 +48,9 @@
48
48
  "@popperjs/core": "^2.11.6",
49
49
  "dayjs": "^1.10.4",
50
50
  "decimal.js": "^10.2.1",
51
- "@varlet/icons": "3.0.3",
52
- "@varlet/use": "3.0.3",
53
- "@varlet/shared": "3.0.3"
51
+ "@varlet/icons": "3.0.4",
52
+ "@varlet/use": "3.0.4",
53
+ "@varlet/shared": "3.0.4"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@vue/runtime-core": "3.4.15",
@@ -66,9 +66,9 @@
66
66
  "typescript": "^5.1.5",
67
67
  "vue": "3.4.15",
68
68
  "vue-router": "4.2.0",
69
- "@varlet/ui": "3.0.3",
70
- "@varlet/cli": "3.0.3",
71
- "@varlet/touch-emulator": "3.0.3"
69
+ "@varlet/cli": "3.0.4",
70
+ "@varlet/ui": "3.0.4",
71
+ "@varlet/touch-emulator": "3.0.4"
72
72
  },
73
73
  "scripts": {
74
74
  "dev": "varlet-cli dev",
package/types/appBar.d.ts CHANGED
@@ -15,6 +15,8 @@ export interface AppBarProps extends BasicAttributes {
15
15
  image?: string
16
16
  imageLinearGradient?: string
17
17
  safeAreaTop?: boolean
18
+ fixed?: boolean
19
+ zIndex?: number | string
18
20
  }
19
21
 
20
22
  export class AppBar extends VarComponent {
package/types/image.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { VarComponent, BasicAttributes, ListenerProp, SetPropsDefaults } from './varComponent'
2
- import { VNode } from 'vue'
2
+ import { VNode, ImgHTMLAttributes } from 'vue'
3
3
 
4
4
  export declare const imageProps: Record<keyof ImageProps, any>
5
5
 
@@ -10,6 +10,7 @@ export interface ImageProps extends BasicAttributes {
10
10
  fit?: ImageFit
11
11
  title?: string
12
12
  alt?: string
13
+ referrerpolicy?: ImgHTMLAttributes['referrerpolicy']
13
14
  width?: string | number
14
15
  height?: string | number
15
16
  radius?: string | number
package/types/input.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { VarComponent, BasicAttributes, ListenerProp, Variant as InputVariant, SetPropsDefaults } from './varComponent'
2
- import { VNode } from 'vue'
2
+ import { VNode, InputHTMLAttributes } from 'vue'
3
3
 
4
4
  export declare const inputProps: Record<keyof InputProps, any>
5
5
 
@@ -29,7 +29,7 @@ export interface InputProps extends BasicAttributes {
29
29
  autofocus?: boolean
30
30
  validateTrigger?: InputValidateTrigger[]
31
31
  rules?: Array<(v: string) => any>
32
- enterkeyhint?: string
32
+ enterkeyhint?: InputHTMLAttributes['enterKeyHint']
33
33
  onFocus?: ListenerProp<(e: Event) => void>
34
34
  onBlur?: ListenerProp<(e: Event) => void>
35
35
  onClick?: ListenerProp<(e: Event) => void>
@@ -1231,6 +1231,10 @@ export interface StyleVars {
1231
1231
  colorOnSurfaceVariant?: string
1232
1232
  '--opacity-disabled'?: string
1233
1233
  opacityDisabled?: string
1234
+ '--opacity-hover'?: string
1235
+ opacityHover?: string
1236
+ '--opacity-focus'?: string
1237
+ opacityFocus?: string
1234
1238
  '--cubic-bezier'?: string
1235
1239
  cubicBezier?: string
1236
1240
  '--shadow-key-umbra-opacity'?: string
@@ -1,5 +1,5 @@
1
1
  import { VarComponent, BasicAttributes, ListenerProp, SetPropsDefaults } from './varComponent'
2
- import { VNode } from 'vue'
2
+ import { VNode, InputHTMLAttributes } from 'vue'
3
3
 
4
4
  export declare const uploaderProps: Record<keyof UploaderProps, any>
5
5
 
@@ -33,7 +33,7 @@ export type UploaderCapture = boolean | 'user' | 'environment'
33
33
  export interface UploaderProps extends BasicAttributes {
34
34
  modelValue?: VarFile[]
35
35
  accept?: string
36
- capture?: UploaderCapture
36
+ capture?: InputHTMLAttributes['capture']
37
37
  multiple?: boolean
38
38
  readonly?: boolean
39
39
  disabled?: boolean