@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/README.md CHANGED
@@ -94,6 +94,7 @@ The following projects are maintained by the official team for a long time.
94
94
  | [@varlet/cli](https://github.com/varletjs/varlet/tree/dev/packages/varlet-cli) | `Vue3 component library rapid prototyping tool` |
95
95
  | [@varlet/touch-emulator](https://github.com/varletjs/varlet/tree/dev/packages/varlet-touch-emulator) | `Desktop adapter, so that the mobile component library can run on the desktop` |
96
96
  | [@varlet/ui-playground](https://github.com/varletjs/varlet/tree/dev/packages/varlet-ui-playground) | `Varlet component library online editing tool` |
97
+ | [@varlet/import-resolver](https://github.com/varletjs/varlet/tree/dev/packages/varlet-import-resolver) | `A resolver for` [unplugin-vue-components](https://github.com/unplugin/unplugin-vue-components) ` used to implement Varlet and import it on demand` |
97
98
  | [varlet-vscode-extension](https://github.com/varletjs/varlet/tree/dev/packages/varlet-vscode-extension) | `Varlet Component Library VSCode Plugin` |
98
99
  | [vscode-theme-varlet](https://github.com/varletjs/vscode-theme-varlet) | `Varlet VSCode Theme` |
99
100
  | [varlet-app-example](https://github.com/varletjs/varlet-app-template) | `Varlet component library app template` |
package/README.zh-CN.md CHANGED
@@ -94,6 +94,7 @@ createApp(App).use(Varlet).mount('#app')
94
94
  | [@varlet/cli](https://github.com/varletjs/varlet/tree/dev/packages/varlet-cli) | `Vue3 组件库快速成型工具` |
95
95
  | [@varlet/touch-emulator](https://github.com/varletjs/varlet/tree/dev/packages/varlet-touch-emulator) | `桌面端适配器,让移动端组件库可以在桌面端运行` |
96
96
  | [@varlet/ui-playground](https://github.com/varletjs/varlet/tree/dev/packages/varlet-ui-playground) | `Varlet 组件库在线编辑工具` |
97
+ | [@varlet/import-resolver](https://github.com/varletjs/varlet/tree/dev/packages/varlet-import-resolver) | [unplugin-vue-components](https://github.com/unplugin/unplugin-vue-components) `的一个解析器,用于实现 Varlet 按需引入` |
97
98
  | [varlet-vscode-extension](https://github.com/varletjs/varlet/tree/dev/packages/varlet-vscode-extension) | `Varlet 组件库 VSCode 插件` |
98
99
  | [vscode-theme-varlet](https://github.com/varletjs/vscode-theme-varlet) | `Varlet VSCode 主题` |
99
100
  | [varlet-app-example](https://github.com/varletjs/varlet-app-template) | `Varlet 组件库移动端模板` |
@@ -14,6 +14,7 @@ function __render__(_ctx, _cache) {
14
14
  _ctx.n("$--box"),
15
15
  [_ctx.safeAreaTop, _ctx.n("--safe-area-top")],
16
16
  [_ctx.round, _ctx.n("--round")],
17
+ [_ctx.fixed, _ctx.n("--fixed")],
17
18
  _ctx.formatElevation(_ctx.elevation, 3)
18
19
  )
19
20
  ),
@@ -121,18 +122,20 @@ const __sfc__ = defineComponent({
121
122
  const paddingLeft = ref();
122
123
  const paddingRight = ref();
123
124
  const rootStyles = computed(() => {
124
- const { image, color, textColor, imageLinearGradient } = props2;
125
+ const { image, color, textColor, imageLinearGradient, zIndex } = props2;
125
126
  if (image != null) {
126
127
  const gradient = imageLinearGradient ? `linear-gradient(${imageLinearGradient}), ` : "";
127
128
  return {
128
129
  "background-image": `${gradient}url(${image})`,
129
130
  "background-position": "center center",
130
- "background-size": "cover"
131
+ "background-size": "cover",
132
+ "z-index": zIndex
131
133
  };
132
134
  }
133
135
  return {
134
136
  background: color,
135
- color: textColor
137
+ color: textColor,
138
+ "z-index": zIndex
136
139
  };
137
140
  });
138
141
  onSmartMounted(computePadding);
@@ -1 +1 @@
1
- :root { --app-bar-color: var(--color-primary); --app-bar-title-padding: 0 12px; --app-bar-title-font-size: var(--font-size-lg); --app-bar-text-color: #fff; --app-bar-height: 54px; --app-bar-left-gap: 6px; --app-bar-right-gap: 6px; --app-bar-border-radius: 4px; --app-bar-font-size: var(--font-size-lg);}.var-app-bar { position: relative; width: 100%; font-size: var(--app-bar-font-size); background: var(--app-bar-color); color: var(--app-bar-text-color); transition: background-color 0.25s;}.var-app-bar__toolbar { position: relative; display: flex; justify-content: center; align-items: center; height: var(--app-bar-height);}.var-app-bar__title { font-size: var(--app-bar-title-font-size); flex: 1; display: flex; justify-content: center; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; padding: var(--app-bar-title-padding);}.var-app-bar__left,.var-app-bar__right { display: flex; align-items: center; height: 100%;}.var-app-bar__left { position: absolute; top: 0; left: var(--app-bar-left-gap);}.var-app-bar__right { position: absolute; top: 0; right: var(--app-bar-right-gap);}.var-app-bar--round { border-radius: var(--app-bar-border-radius);}.var-app-bar--safe-area-top { padding-top: constant(safe-area-inset-top); padding-top: env(safe-area-inset-top); box-sizing: content-box !important;}
1
+ :root { --app-bar-color: var(--color-primary); --app-bar-title-padding: 0 12px; --app-bar-title-font-size: var(--font-size-lg); --app-bar-text-color: #fff; --app-bar-height: 54px; --app-bar-left-gap: 6px; --app-bar-right-gap: 6px; --app-bar-border-radius: 4px; --app-bar-font-size: var(--font-size-lg);}.var-app-bar { position: relative; width: 100%; font-size: var(--app-bar-font-size); background: var(--app-bar-color); color: var(--app-bar-text-color); transition: background-color 0.25s;}.var-app-bar__toolbar { position: relative; display: flex; justify-content: center; align-items: center; height: var(--app-bar-height);}.var-app-bar__title { font-size: var(--app-bar-title-font-size); flex: 1; display: flex; justify-content: center; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; padding: var(--app-bar-title-padding);}.var-app-bar__left,.var-app-bar__right { display: flex; align-items: center; height: 100%;}.var-app-bar__left { position: absolute; top: 0; left: var(--app-bar-left-gap);}.var-app-bar__right { position: absolute; top: 0; right: var(--app-bar-right-gap);}.var-app-bar--round { border-radius: var(--app-bar-border-radius);}.var-app-bar--safe-area-top { padding-top: constant(safe-area-inset-top); padding-top: env(safe-area-inset-top); box-sizing: content-box !important;}.var-app-bar--fixed { position: fixed; top: 0; left: 0;}
@@ -13,7 +13,12 @@ const props = {
13
13
  round: Boolean,
14
14
  image: String,
15
15
  imageLinearGradient: String,
16
- safeAreaTop: Boolean
16
+ safeAreaTop: Boolean,
17
+ zIndex: {
18
+ type: [Number, String],
19
+ default: 1
20
+ },
21
+ fixed: Boolean
17
22
  };
18
23
  export {
19
24
  props
@@ -6,7 +6,7 @@ import { computed, defineComponent, ref } from "vue";
6
6
  import { props } from "./props.mjs";
7
7
  import { createNamespace, formatElevation } from "../utils/components.mjs";
8
8
  import { useButtonGroup } from "./provide.mjs";
9
- import { isArray, call } from "@varlet/shared";
9
+ import { isArray, call, inMobile } from "@varlet/shared";
10
10
  const { name, n, classes } = createNamespace("button");
11
11
  import { resolveComponent as _resolveComponent, normalizeClass as _normalizeClass, openBlock as _openBlock, createBlock as _createBlock, createCommentVNode as _createCommentVNode, renderSlot as _renderSlot, createElementVNode as _createElementVNode, createVNode as _createVNode, normalizeStyle as _normalizeStyle, resolveDirective as _resolveDirective, createElementBlock as _createElementBlock, withDirectives as _withDirectives, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
12
12
  const _withScopeId = (n2) => (_pushScopeId(""), n2 = n2(), _popScopeId(), n2);
@@ -41,7 +41,9 @@ function __render__(_ctx, _cache) {
41
41
  type: _ctx.nativeType,
42
42
  disabled: _ctx.disabled,
43
43
  onClick: _cache[0] || (_cache[0] = (...args) => _ctx.handleClick && _ctx.handleClick(...args)),
44
- onTouchstart: _cache[1] || (_cache[1] = (...args) => _ctx.handleTouchstart && _ctx.handleTouchstart(...args))
44
+ onTouchstart: _cache[1] || (_cache[1] = (...args) => _ctx.handleTouchstart && _ctx.handleTouchstart(...args)),
45
+ onFocus: _cache[2] || (_cache[2] = ($event) => _ctx.isEffectFocusing = true),
46
+ onBlur: _cache[3] || (_cache[3] = ($event) => _ctx.isEffectFocusing = false)
45
47
  }, [
46
48
  _ctx.loading || _ctx.pending ? (_openBlock(), _createBlock(_component_var_loading, {
47
49
  key: 0,
@@ -64,8 +66,9 @@ function __render__(_ctx, _cache) {
64
66
  /* CLASS */
65
67
  ),
66
68
  _createVNode(_component_var_hover_overlay, {
67
- hovering: _ctx.disabled || _ctx.loading || _ctx.pending ? false : _ctx.hovering
68
- }, null, 8, ["hovering"])
69
+ hovering: _ctx.disabled || _ctx.loading || _ctx.pending ? false : _ctx.hovering,
70
+ focusing: _ctx.disabled || _ctx.loading || _ctx.pending ? false : _ctx.isEffectFocusing
71
+ }, null, 8, ["hovering", "focusing"])
69
72
  ], 46, _hoisted_1)), [
70
73
  [_directive_ripple, { disabled: _ctx.disabled || !_ctx.ripple || _ctx.loading || _ctx.pending }],
71
74
  [_directive_hover, _ctx.handleHovering, "desktop"]
@@ -80,6 +83,7 @@ const __sfc__ = defineComponent({
80
83
  directives: { Ripple, Hover },
81
84
  props,
82
85
  setup(props2) {
86
+ const isEffectFocusing = inMobile() ? computed(() => false) : ref(false);
83
87
  const pending = ref(false);
84
88
  const { buttonGroup } = useButtonGroup();
85
89
  const { hovering, handleHovering } = useHoverOverlay();
@@ -141,7 +145,8 @@ const __sfc__ = defineComponent({
141
145
  classes,
142
146
  handleHovering,
143
147
  handleClick,
144
- handleTouchstart
148
+ handleTouchstart,
149
+ isEffectFocusing
145
150
  };
146
151
  }
147
152
  });
@@ -1,13 +1,12 @@
1
- import { isFunction, camelize } from "@varlet/shared";
1
+ import { isFunction, camelize, inMobile } from "@varlet/shared";
2
2
  function shouldDisabled(arg) {
3
3
  if (!arg) {
4
4
  return false;
5
5
  }
6
- const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
7
- if (arg === "desktop" && isMobile) {
6
+ if (arg === "desktop" && inMobile()) {
8
7
  return true;
9
8
  }
10
- if (arg === "mobile" && !isMobile) {
9
+ if (arg === "mobile" && !inMobile()) {
11
10
  return true;
12
11
  }
13
12
  return false;
@@ -7,7 +7,7 @@ function __render__(_ctx, _cache) {
7
7
  return _openBlock(), _createElementBlock(
8
8
  "div",
9
9
  {
10
- class: _normalizeClass(_ctx.classes(_ctx.n(), [_ctx.hovering, _ctx.n("--hovering")]))
10
+ class: _normalizeClass(_ctx.classes(_ctx.n(), [_ctx.hovering, _ctx.n("--hovering")], [_ctx.focusing, _ctx.n("--focusing")]))
11
11
  },
12
12
  null,
13
13
  2
@@ -1 +1 @@
1
- :root { --hover-overlay-opacity: 0.15;}.var-hover-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; border-radius: inherit; background-color: currentColor; opacity: 0; transition: opacity 0.15s; will-change: opacity; pointer-events: none;}.var-hover-overlay--hovering { opacity: var(--hover-overlay-opacity);}
1
+ :root { --hover-overlay-opacity: var(--opacity-hover); --hover-overlay-focusing-opacity: var(--opacity-focus);}.var-hover-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; border-radius: inherit; background-color: currentColor; opacity: 0; transition: opacity 0.15s; will-change: opacity; pointer-events: none;}.var-hover-overlay--hovering { opacity: var(--hover-overlay-opacity);}.var-hover-overlay--focusing { opacity: var(--hover-overlay-focusing-opacity);}
@@ -1,8 +1,6 @@
1
1
  const props = {
2
- hovering: {
3
- type: Boolean,
4
- default: true
5
- }
2
+ hovering: Boolean,
3
+ focusing: Boolean
6
4
  };
7
5
  export {
8
6
  props
@@ -1,2 +1,3 @@
1
+ import '../../styles/common.css'
1
2
  import '../hoverOverlay.css'
2
3
  import '../HoverOverlaySfc.css'
@@ -8,8 +8,8 @@ import { call } from "@varlet/shared";
8
8
  const { name, n, classes } = createNamespace("image");
9
9
  import { normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle, resolveDirective as _resolveDirective, withDirectives as _withDirectives, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, renderSlot as _renderSlot, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
10
10
  const _withScopeId = (n2) => (_pushScopeId(""), n2 = n2(), _popScopeId(), n2);
11
- const _hoisted_1 = ["alt", "title", "lazy-loading", "lazy-error"];
12
- const _hoisted_2 = ["alt", "title", "src"];
11
+ const _hoisted_1 = ["alt", "title", "referrerpolicy", "lazy-loading", "lazy-error"];
12
+ const _hoisted_2 = ["alt", "title", "referrerpolicy", "src"];
13
13
  function __render__(_ctx, _cache) {
14
14
  var _a;
15
15
  const _directive_lazy = _resolveDirective("lazy");
@@ -31,6 +31,7 @@ function __render__(_ctx, _cache) {
31
31
  class: _normalizeClass(_ctx.n("image")),
32
32
  alt: _ctx.alt,
33
33
  title: _ctx.title,
34
+ referrerpolicy: _ctx.referrerpolicy,
34
35
  "lazy-loading": _ctx.loading,
35
36
  "lazy-error": _ctx.error,
36
37
  style: _normalizeStyle({ objectFit: _ctx.fit }),
@@ -45,6 +46,7 @@ function __render__(_ctx, _cache) {
45
46
  class: _normalizeClass(_ctx.n("image")),
46
47
  alt: _ctx.alt,
47
48
  title: _ctx.title,
49
+ referrerpolicy: _ctx.referrerpolicy,
48
50
  style: _normalizeStyle({ objectFit: _ctx.fit }),
49
51
  src: _ctx.src,
50
52
  onLoad: _cache[2] || (_cache[2] = (...args) => _ctx.handleLoad && _ctx.handleLoad(...args)),
@@ -7,6 +7,7 @@ const props = {
7
7
  },
8
8
  alt: String,
9
9
  title: String,
10
+ referrerpolicy: String,
10
11
  width: [String, Number],
11
12
  height: [String, Number],
12
13
  radius: {
@@ -262,7 +262,7 @@ import './tooltip/style/index.mjs'
262
262
  import './uploader/style/index.mjs'
263
263
  import './watermark/style/index.mjs'
264
264
 
265
- const version = '3.0.3'
265
+ const version = '3.0.4'
266
266
 
267
267
  function install(app) {
268
268
  ActionSheet.install && app.use(ActionSheet)
package/es/index.mjs CHANGED
@@ -174,7 +174,7 @@ export * from './tooltip/index.mjs'
174
174
  export * from './uploader/index.mjs'
175
175
  export * from './watermark/index.mjs'
176
176
 
177
- const version = '3.0.3'
177
+ const version = '3.0.4'
178
178
 
179
179
  function install(app) {
180
180
  ActionSheet.install && app.use(ActionSheet)
@@ -40,7 +40,7 @@ var __async = (__this, __arguments, generator) => {
40
40
  import flip from "@popperjs/core/lib/modifiers/flip.js";
41
41
  import offset from "@popperjs/core/lib/modifiers/offset.js";
42
42
  import computeStyles from "@popperjs/core/lib/modifiers/computeStyles.js";
43
- import { useClickOutside, useVModel } from "@varlet/use";
43
+ import { onWindowResize, useClickOutside, useVModel } from "@varlet/use";
44
44
  import { doubleRaf, getStyle, call } from "@varlet/shared";
45
45
  import { toPxNum } from "../utils/elements.mjs";
46
46
  import { onMounted, onUnmounted, ref, watch } from "vue";
@@ -304,6 +304,7 @@ function usePopover(options) {
304
304
  call(options["onUpdate:show"], false);
305
305
  };
306
306
  useClickOutside(getReference, "click", handleClickOutside);
307
+ onWindowResize(resize);
307
308
  watch(() => [options.offsetX, options.offsetY, options.placement, options.strategy], resize);
308
309
  watch(() => options.disabled, close);
309
310
  onMounted(() => {
@@ -18,7 +18,7 @@ var __spreadValues = (a, b) => {
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
20
  import context from "../context/index.mjs";
21
- import { supportTouch, getStyle, getRect } from "@varlet/shared";
21
+ import { supportTouch, getStyle, getRect, hasOwn } from "@varlet/shared";
22
22
  import { createNamespace } from "../utils/components.mjs";
23
23
 
24
24
 
@@ -32,13 +32,16 @@ function setStyles(element) {
32
32
  position === "static" && (element.style.position = "relative");
33
33
  zIndex === "auto" && (element.style.zIndex = "1");
34
34
  }
35
+ function isTouchEvent(event) {
36
+ return hasOwn(event, "touches");
37
+ }
35
38
  function computeRippleStyles(element, event) {
36
39
  const { top, left } = getRect(element);
37
40
  const { clientWidth, clientHeight } = element;
38
41
  const radius = Math.sqrt(clientWidth ** 2 + clientHeight ** 2) / 2;
39
42
  const size = radius * 2;
40
- const localX = event.touches[0].clientX - left;
41
- const localY = event.touches[0].clientY - top;
43
+ const localX = isTouchEvent(event) ? event.touches[0].clientX - left : clientWidth / 2;
44
+ const localY = isTouchEvent(event) ? event.touches[0].clientY - top : clientHeight / 2;
42
45
  const centerX = (clientWidth - radius * 2) / 2;
43
46
  const centerY = (clientHeight - radius * 2) / 2;
44
47
  const x = localX - radius;
@@ -98,6 +101,21 @@ function forbidRippleTask() {
98
101
  _ripple.tasker && window.clearTimeout(_ripple.tasker);
99
102
  _ripple.tasker = null;
100
103
  }
104
+ let hasKeyboardRipple = false;
105
+ function createKeyboardRipple(event) {
106
+ if (hasKeyboardRipple || !(event.key === " " || event.key === "Enter")) {
107
+ return;
108
+ }
109
+ createRipple.call(this, event);
110
+ hasKeyboardRipple = true;
111
+ }
112
+ function removeKeyboardRipple() {
113
+ if (!hasKeyboardRipple) {
114
+ return;
115
+ }
116
+ removeRipple.call(this);
117
+ hasKeyboardRipple = false;
118
+ }
101
119
  function mounted(el, binding) {
102
120
  var _a;
103
121
  el._ripple = __spreadProps(__spreadValues({
@@ -108,6 +126,9 @@ function mounted(el, binding) {
108
126
  el.addEventListener("touchstart", createRipple, { passive: true });
109
127
  el.addEventListener("touchmove", forbidRippleTask, { passive: true });
110
128
  el.addEventListener("dragstart", removeRipple, { passive: true });
129
+ el.addEventListener("keydown", createKeyboardRipple);
130
+ el.addEventListener("keyup", removeKeyboardRipple);
131
+ el.addEventListener("blur", removeKeyboardRipple);
111
132
  document.addEventListener("touchend", el._ripple.removeRipple, { passive: true });
112
133
  document.addEventListener("touchcancel", el._ripple.removeRipple, { passive: true });
113
134
  document.addEventListener("dragend", el._ripple.removeRipple, { passive: true });
@@ -1,7 +1,7 @@
1
1
  import '../../styles/common.css'
2
- import '../SnackbarSfc.css'
3
2
  import '../../styles/elevation.css'
4
3
  import '../../loading/loading.css'
5
4
  import '../../icon/icon.css'
6
5
  import '../snackbar.css'
7
6
  import '../coreSfc.css'
7
+ import '../SnackbarSfc.css'