@varlet/ui 1.27.8 → 1.27.10

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.
Files changed (66) hide show
  1. package/es/badge/Badge.js +1 -1
  2. package/es/bottom-navigation-item/BottomNavigationItem.js +3 -1
  3. package/es/card/Card.js +228 -19
  4. package/es/card/card.css +1 -1
  5. package/es/card/card.less +108 -5
  6. package/es/card/props.js +25 -0
  7. package/es/index-bar/IndexBar.js +4 -4
  8. package/es/index-bar/props.js +1 -1
  9. package/es/loading/Loading.js +5 -14
  10. package/es/loading/loading.css +1 -1
  11. package/es/loading/loading.less +20 -0
  12. package/es/picker/Picker.js +2 -1
  13. package/es/progress/Progress.js +14 -11
  14. package/es/progress/progress.css +1 -1
  15. package/es/progress/progress.less +3 -0
  16. package/es/progress/props.js +1 -1
  17. package/es/rate/Rate.js +4 -2
  18. package/es/rate/props.js +2 -4
  19. package/es/rate/rate.css +1 -1
  20. package/es/rate/rate.less +7 -0
  21. package/es/select/Select.js +3 -1
  22. package/es/slider/Slider.js +10 -9
  23. package/es/style.css +1 -1
  24. package/es/switch/Switch.js +22 -19
  25. package/es/switch/props.js +1 -2
  26. package/es/switch/switch.css +1 -1
  27. package/es/switch/switch.less +18 -4
  28. package/es/utils/elements.js +13 -0
  29. package/es/utils/jest.js +19 -0
  30. package/es/varlet.esm.js +334 -96
  31. package/highlight/attributes.json +21 -5
  32. package/highlight/tags.json +6 -2
  33. package/highlight/web-types.json +50 -6
  34. package/lib/badge/Badge.js +1 -1
  35. package/lib/bottom-navigation-item/BottomNavigationItem.js +3 -1
  36. package/lib/card/Card.js +228 -15
  37. package/lib/card/card.css +1 -1
  38. package/lib/card/card.less +108 -5
  39. package/lib/card/props.js +25 -0
  40. package/lib/index-bar/IndexBar.js +3 -3
  41. package/lib/index-bar/props.js +1 -1
  42. package/lib/loading/Loading.js +6 -15
  43. package/lib/loading/loading.css +1 -1
  44. package/lib/loading/loading.less +20 -0
  45. package/lib/picker/Picker.js +2 -1
  46. package/lib/progress/Progress.js +15 -11
  47. package/lib/progress/progress.css +1 -1
  48. package/lib/progress/progress.less +3 -0
  49. package/lib/progress/props.js +1 -1
  50. package/lib/rate/Rate.js +3 -1
  51. package/lib/rate/props.js +2 -4
  52. package/lib/rate/rate.css +1 -1
  53. package/lib/rate/rate.less +7 -0
  54. package/lib/select/Select.js +3 -1
  55. package/lib/slider/Slider.js +9 -8
  56. package/lib/style.css +1 -1
  57. package/lib/switch/Switch.js +22 -19
  58. package/lib/switch/props.js +1 -2
  59. package/lib/switch/switch.css +1 -1
  60. package/lib/switch/switch.less +18 -4
  61. package/lib/utils/elements.js +17 -1
  62. package/lib/utils/jest.js +21 -0
  63. package/package.json +10 -9
  64. package/types/card.d.ts +9 -0
  65. package/types/indexBar.d.ts +1 -1
  66. package/umd/varlet.js +4 -4
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, computed, nextTick } from 'vue';
2
2
  import { useValidation, createNamespace, call } from '../utils/components';
3
- import { toNumber } from '../utils/shared';
3
+ import { multiplySizeUnit } from '../utils/elements';
4
4
  import { useForm } from '../form/provide';
5
5
  import { props } from './props';
6
6
  import VarFormDetails from '../form-details';
@@ -28,18 +28,18 @@ export function render(_ctx, _cache) {
28
28
  style: _normalizeStyle(_ctx.styleComputed.switch)
29
29
  }, [_createElementVNode("div", {
30
30
  style: _normalizeStyle(_ctx.styleComputed.track),
31
- class: _normalizeClass(_ctx.classes(_ctx.n('track'), [_ctx.modelValue === _ctx.activeValue, _ctx.n('track-active')], [_ctx.errorMessage, _ctx.n('track-error')]))
31
+ class: _normalizeClass(_ctx.classes(_ctx.n('track'), [_ctx.modelValue === _ctx.activeValue, _ctx.n('track--active')], [_ctx.errorMessage, _ctx.n('track--error')]))
32
32
  }, null, 6
33
33
  /* CLASS, STYLE */
34
34
  ), _withDirectives((_openBlock(), _createElementBlock("div", {
35
- class: _normalizeClass(_ctx.n('ripple')),
35
+ class: _normalizeClass(_ctx.classes(_ctx.n('ripple'), [_ctx.modelValue === _ctx.activeValue, _ctx.n('ripple--active')])),
36
36
  style: _normalizeStyle(_ctx.styleComputed.ripple)
37
37
  }, [_createElementVNode("div", {
38
38
  style: _normalizeStyle(_ctx.styleComputed.handle),
39
- class: _normalizeClass(_ctx.classes(_ctx.n('handle'), 'var-elevation--2', [_ctx.modelValue === _ctx.activeValue, _ctx.n('handle-active')], [_ctx.errorMessage, _ctx.n('handle-error')]))
39
+ class: _normalizeClass(_ctx.classes(_ctx.n('handle'), 'var-elevation--2', [_ctx.modelValue === _ctx.activeValue, _ctx.n('handle--active')], [_ctx.errorMessage, _ctx.n('handle--error')]))
40
40
  }, [_ctx.loading ? (_openBlock(), _createBlock(_component_var_loading, {
41
41
  key: 0,
42
- radius: _ctx.toNumber(_ctx.size) / 2 - 2
42
+ radius: _ctx.radius
43
43
  }, null, 8
44
44
  /* PROPS */
45
45
  , ["radius"])) : _createCommentVNode("v-if", true)], 6
@@ -95,35 +95,38 @@ export default defineComponent({
95
95
  loadingColor,
96
96
  activeValue
97
97
  } = props;
98
- var sizeNum = toNumber(size);
99
- var switchWidth = sizeNum * 2;
100
- var switchHeight = sizeNum * 1.2;
101
98
  return {
102
99
  handle: {
103
- width: size + "px",
104
- height: size + "px",
100
+ width: multiplySizeUnit(size),
101
+ height: multiplySizeUnit(size),
105
102
  backgroundColor: modelValue === activeValue ? color || '' : closeColor || '',
106
103
  color: loadingColor && loadingColor
107
104
  },
108
105
  ripple: {
109
- left: modelValue === activeValue ? sizeNum / 2 + "px" : "-" + sizeNum / 2 + "px",
106
+ left: modelValue === activeValue ? multiplySizeUnit(size, 0.5) : "-" + multiplySizeUnit(size, 0.5),
110
107
  color: modelValue === activeValue ? color || '' : closeColor || '#999',
111
- width: sizeNum * 2 + "px",
112
- height: sizeNum * 2 + "px"
108
+ width: multiplySizeUnit(size, 2),
109
+ height: multiplySizeUnit(size, 2)
113
110
  },
114
111
  track: {
115
- height: switchHeight * 0.6 + "px",
116
- width: switchWidth - 2 + "px",
117
- borderRadius: switchWidth / 3 + "px",
112
+ height: multiplySizeUnit(size, 0.72),
113
+ width: multiplySizeUnit(size, 1.9),
114
+ borderRadius: multiplySizeUnit(size, 2 / 3),
118
115
  filter: modelValue === activeValue || errorMessage != null && errorMessage.value ? 'opacity(.6)' : 'brightness(.6)',
119
116
  backgroundColor: modelValue === activeValue ? color || '' : closeColor || ''
120
117
  },
121
118
  switch: {
122
- height: switchHeight + "px",
123
- width: switchWidth + "px"
119
+ height: multiplySizeUnit(size, 1.2),
120
+ width: multiplySizeUnit(size, 2)
124
121
  }
125
122
  };
126
123
  });
124
+ var radius = computed(() => {
125
+ var {
126
+ size = '5.333vw'
127
+ } = props;
128
+ return multiplySizeUnit(size, 0.4);
129
+ });
127
130
 
128
131
  var switchActive = event => {
129
132
  var {
@@ -160,7 +163,7 @@ export default defineComponent({
160
163
  n,
161
164
  classes,
162
165
  switchActive,
163
- toNumber,
166
+ radius,
164
167
  styleComputed,
165
168
  errorMessage,
166
169
  formDisabled: form == null ? void 0 : form.disabled,
@@ -30,8 +30,7 @@ export var props = {
30
30
  type: String
31
31
  },
32
32
  size: {
33
- type: [String, Number],
34
- default: 20
33
+ type: [String, Number]
35
34
  },
36
35
  rules: {
37
36
  type: Array
@@ -1 +1 @@
1
- :root { --switch-track-background: #fff; --switch-track-active-background: var(--color-primary); --switch-track-error-background: var(--color-danger); --switch-ripple-color: var(--color-primary); --switch-handle-background: #fff; --switch-handle-color: #fff; --switch-handle-active-background: var(--color-primary); --switch-handle-error-background: var(--color-danger);}.var-switch { display: inline-block;}.var-switch__block { position: relative; display: flex; cursor: pointer; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); align-items: center; justify-content: center;}.var-switch--disable { filter: opacity(0.6); cursor: not-allowed;}.var-switch__track { background: var(--switch-track-background); transition: background-color 0.25s; filter: opacity(0.6);}.var-switch__track-active { background-color: var(--switch-track-active-background);}.var-switch__track-error { background-color: var(--switch-track-error-background) !important;}.var-switch__ripple { position: absolute; display: flex; align-items: center; justify-content: center; color: var(--switch-ripple-color); border-radius: 50%; overflow: hidden; transition: 0.3s var(--cubic-bezier);}.var-switch__handle { border-radius: 50%; background-color: var(--switch-handle-background); display: flex; align-items: center; justify-content: center; color: var(--switch-handle-color); transition: background-color 0.25s;}.var-switch__handle-active { background-color: var(--switch-handle-active-background);}.var-switch__handle-error { background-color: var(--switch-handle-error-background) !important;}
1
+ :root { --switch-track-background: #fff; --switch-track-active-background: var(--color-primary); --switch-track-error-background: var(--color-danger); --switch-ripple-color: var(--color-primary); --switch-handle-background: #fff; --switch-handle-color: #fff; --switch-handle-active-background: var(--color-primary); --switch-handle-error-background: var(--color-danger);}.var-switch { display: inline-block;}.var-switch__block { position: relative; display: flex; cursor: pointer; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); align-items: center; justify-content: center; height: 24px; width: 40px;}.var-switch--disable { filter: opacity(0.6); cursor: not-allowed;}.var-switch__track { background: var(--switch-track-background); transition: background-color 0.25s; filter: opacity(0.6); height: 14.4px; width: 38px; border-radius: calc(20px * 2 / 3);}.var-switch__track--active { background-color: var(--switch-track-active-background);}.var-switch__track--error { background-color: var(--switch-track-error-background) !important;}.var-switch__ripple { position: absolute; display: flex; align-items: center; justify-content: center; color: var(--switch-ripple-color); border-radius: 50%; overflow: hidden; transition: 0.3s var(--cubic-bezier); width: 40px; height: 40px; left: -10px;}.var-switch__ripple--active { left: 10px;}.var-switch__handle { border-radius: 50%; background-color: var(--switch-handle-background); display: flex; align-items: center; justify-content: center; color: var(--switch-handle-color); transition: background-color 0.25s; width: 20px; height: 20px;}.var-switch__handle--active { background-color: var(--switch-handle-active-background);}.var-switch__handle--error { background-color: var(--switch-handle-error-background) !important;}
@@ -28,6 +28,8 @@
28
28
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
29
29
  align-items: center;
30
30
  justify-content: center;
31
+ height: 24px;
32
+ width: 40px;
31
33
  }
32
34
 
33
35
  &--disable {
@@ -39,12 +41,15 @@
39
41
  background: var(--switch-track-background);
40
42
  transition: background-color 0.25s;
41
43
  filter: opacity(0.6);
44
+ height: 14.4px;
45
+ width: 38px;
46
+ border-radius: calc(20px * 2 / 3);
42
47
 
43
- &-active {
48
+ &--active {
44
49
  background-color: var(--switch-track-active-background);
45
50
  }
46
51
 
47
- &-error {
52
+ &--error {
48
53
  background-color: var(--switch-track-error-background) !important;
49
54
  }
50
55
  }
@@ -58,6 +63,13 @@
58
63
  border-radius: 50%;
59
64
  overflow: hidden;
60
65
  transition: 0.3s var(--cubic-bezier);
66
+ width: 40px;
67
+ height: 40px;
68
+ left: -10px;
69
+
70
+ &--active {
71
+ left: 10px;
72
+ }
61
73
  }
62
74
 
63
75
  &__handle {
@@ -68,12 +80,14 @@
68
80
  justify-content: center;
69
81
  color: var(--switch-handle-color);
70
82
  transition: background-color 0.25s;
83
+ width: 20px;
84
+ height: 20px;
71
85
 
72
- &-active {
86
+ &--active {
73
87
  background-color: var(--switch-handle-active-background);
74
88
  }
75
89
 
76
- &-error {
90
+ &--error {
77
91
  background-color: var(--switch-handle-error-background) !important;
78
92
  }
79
93
  }
@@ -145,6 +145,19 @@ export var toSizeUnit = value => {
145
145
 
146
146
  return toPxNum(value) + "px";
147
147
  };
148
+ export var multiplySizeUnit = function (value, quantity) {
149
+ if (quantity === void 0) {
150
+ quantity = 1;
151
+ }
152
+
153
+ if (value == null) {
154
+ return undefined;
155
+ }
156
+
157
+ var legalSize = toSizeUnit(value);
158
+ var unit = legalSize.match(/(vh|%|rem|px|vw)$/)[0];
159
+ return "" + parseFloat(legalSize) * quantity + unit;
160
+ };
148
161
  export function requestAnimationFrame(fn) {
149
162
  return globalThis.requestAnimationFrame ? globalThis.requestAnimationFrame(fn) : globalThis.setTimeout(fn, 16);
150
163
  }
package/es/utils/jest.js CHANGED
@@ -250,4 +250,23 @@ export function mockScrollTo(Element) {
250
250
  this.scrollTop = y;
251
251
  }
252
252
  };
253
+ }
254
+ export function mockIndexBarOwnTop() {
255
+ var originForEach = Array.prototype.forEach; // eslint-disable-next-line no-extend-native
256
+
257
+ Array.prototype.forEach = function (fn, thisArg) {
258
+ var changedArr = this.map((value, index) => {
259
+ if (value.ownTop && !value.ownTop.value) value.ownTop.value = (index + 1) * 50;
260
+ return value;
261
+ });
262
+ originForEach.call(changedArr, fn, thisArg);
263
+ };
264
+
265
+ return {
266
+ mockRestore() {
267
+ // eslint-disable-next-line no-extend-native
268
+ Array.prototype.forEach = originForEach;
269
+ }
270
+
271
+ };
253
272
  }