@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.
- package/es/badge/Badge.js +1 -1
- package/es/bottom-navigation-item/BottomNavigationItem.js +3 -1
- package/es/card/Card.js +228 -19
- package/es/card/card.css +1 -1
- package/es/card/card.less +108 -5
- package/es/card/props.js +25 -0
- package/es/index-bar/IndexBar.js +4 -4
- package/es/index-bar/props.js +1 -1
- package/es/loading/Loading.js +5 -14
- package/es/loading/loading.css +1 -1
- package/es/loading/loading.less +20 -0
- package/es/picker/Picker.js +2 -1
- package/es/progress/Progress.js +14 -11
- package/es/progress/progress.css +1 -1
- package/es/progress/progress.less +3 -0
- package/es/progress/props.js +1 -1
- package/es/rate/Rate.js +4 -2
- package/es/rate/props.js +2 -4
- package/es/rate/rate.css +1 -1
- package/es/rate/rate.less +7 -0
- package/es/select/Select.js +3 -1
- package/es/slider/Slider.js +10 -9
- package/es/style.css +1 -1
- package/es/switch/Switch.js +22 -19
- package/es/switch/props.js +1 -2
- package/es/switch/switch.css +1 -1
- package/es/switch/switch.less +18 -4
- package/es/utils/elements.js +13 -0
- package/es/utils/jest.js +19 -0
- package/es/varlet.esm.js +334 -96
- package/highlight/attributes.json +21 -5
- package/highlight/tags.json +6 -2
- package/highlight/web-types.json +50 -6
- package/lib/badge/Badge.js +1 -1
- package/lib/bottom-navigation-item/BottomNavigationItem.js +3 -1
- package/lib/card/Card.js +228 -15
- package/lib/card/card.css +1 -1
- package/lib/card/card.less +108 -5
- package/lib/card/props.js +25 -0
- package/lib/index-bar/IndexBar.js +3 -3
- package/lib/index-bar/props.js +1 -1
- package/lib/loading/Loading.js +6 -15
- package/lib/loading/loading.css +1 -1
- package/lib/loading/loading.less +20 -0
- package/lib/picker/Picker.js +2 -1
- package/lib/progress/Progress.js +15 -11
- package/lib/progress/progress.css +1 -1
- package/lib/progress/progress.less +3 -0
- package/lib/progress/props.js +1 -1
- package/lib/rate/Rate.js +3 -1
- package/lib/rate/props.js +2 -4
- package/lib/rate/rate.css +1 -1
- package/lib/rate/rate.less +7 -0
- package/lib/select/Select.js +3 -1
- package/lib/slider/Slider.js +9 -8
- package/lib/style.css +1 -1
- package/lib/switch/Switch.js +22 -19
- package/lib/switch/props.js +1 -2
- package/lib/switch/switch.css +1 -1
- package/lib/switch/switch.less +18 -4
- package/lib/utils/elements.js +17 -1
- package/lib/utils/jest.js +21 -0
- package/package.json +10 -9
- package/types/card.d.ts +9 -0
- package/types/indexBar.d.ts +1 -1
- package/umd/varlet.js +4 -4
package/lib/switch/Switch.js
CHANGED
|
@@ -8,7 +8,7 @@ var _vue = require("vue");
|
|
|
8
8
|
|
|
9
9
|
var _components = require("../utils/components");
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _elements = require("../utils/elements");
|
|
12
12
|
|
|
13
13
|
var _provide = require("../form/provide");
|
|
14
14
|
|
|
@@ -44,18 +44,18 @@ function render(_ctx, _cache) {
|
|
|
44
44
|
style: (0, _vue.normalizeStyle)(_ctx.styleComputed.switch)
|
|
45
45
|
}, [(0, _vue.createElementVNode)("div", {
|
|
46
46
|
style: (0, _vue.normalizeStyle)(_ctx.styleComputed.track),
|
|
47
|
-
class: (0, _vue.normalizeClass)(_ctx.classes(_ctx.n('track'), [_ctx.modelValue === _ctx.activeValue, _ctx.n('track
|
|
47
|
+
class: (0, _vue.normalizeClass)(_ctx.classes(_ctx.n('track'), [_ctx.modelValue === _ctx.activeValue, _ctx.n('track--active')], [_ctx.errorMessage, _ctx.n('track--error')]))
|
|
48
48
|
}, null, 6
|
|
49
49
|
/* CLASS, STYLE */
|
|
50
50
|
), (0, _vue.withDirectives)(((0, _vue.openBlock)(), (0, _vue.createElementBlock)("div", {
|
|
51
|
-
class: (0, _vue.normalizeClass)(_ctx.n('ripple')),
|
|
51
|
+
class: (0, _vue.normalizeClass)(_ctx.classes(_ctx.n('ripple'), [_ctx.modelValue === _ctx.activeValue, _ctx.n('ripple--active')])),
|
|
52
52
|
style: (0, _vue.normalizeStyle)(_ctx.styleComputed.ripple)
|
|
53
53
|
}, [(0, _vue.createElementVNode)("div", {
|
|
54
54
|
style: (0, _vue.normalizeStyle)(_ctx.styleComputed.handle),
|
|
55
|
-
class: (0, _vue.normalizeClass)(_ctx.classes(_ctx.n('handle'), 'var-elevation--2', [_ctx.modelValue === _ctx.activeValue, _ctx.n('handle
|
|
55
|
+
class: (0, _vue.normalizeClass)(_ctx.classes(_ctx.n('handle'), 'var-elevation--2', [_ctx.modelValue === _ctx.activeValue, _ctx.n('handle--active')], [_ctx.errorMessage, _ctx.n('handle--error')]))
|
|
56
56
|
}, [_ctx.loading ? ((0, _vue.openBlock)(), (0, _vue.createBlock)(_component_var_loading, {
|
|
57
57
|
key: 0,
|
|
58
|
-
radius: _ctx.
|
|
58
|
+
radius: _ctx.radius
|
|
59
59
|
}, null, 8
|
|
60
60
|
/* PROPS */
|
|
61
61
|
, ["radius"])) : (0, _vue.createCommentVNode)("v-if", true)], 6
|
|
@@ -112,35 +112,38 @@ var _default = (0, _vue.defineComponent)({
|
|
|
112
112
|
loadingColor,
|
|
113
113
|
activeValue
|
|
114
114
|
} = props;
|
|
115
|
-
var sizeNum = (0, _shared.toNumber)(size);
|
|
116
|
-
var switchWidth = sizeNum * 2;
|
|
117
|
-
var switchHeight = sizeNum * 1.2;
|
|
118
115
|
return {
|
|
119
116
|
handle: {
|
|
120
|
-
width: size
|
|
121
|
-
height: size
|
|
117
|
+
width: (0, _elements.multiplySizeUnit)(size),
|
|
118
|
+
height: (0, _elements.multiplySizeUnit)(size),
|
|
122
119
|
backgroundColor: modelValue === activeValue ? color || '' : closeColor || '',
|
|
123
120
|
color: loadingColor && loadingColor
|
|
124
121
|
},
|
|
125
122
|
ripple: {
|
|
126
|
-
left: modelValue === activeValue ?
|
|
123
|
+
left: modelValue === activeValue ? (0, _elements.multiplySizeUnit)(size, 0.5) : "-" + (0, _elements.multiplySizeUnit)(size, 0.5),
|
|
127
124
|
color: modelValue === activeValue ? color || '' : closeColor || '#999',
|
|
128
|
-
width:
|
|
129
|
-
height:
|
|
125
|
+
width: (0, _elements.multiplySizeUnit)(size, 2),
|
|
126
|
+
height: (0, _elements.multiplySizeUnit)(size, 2)
|
|
130
127
|
},
|
|
131
128
|
track: {
|
|
132
|
-
height:
|
|
133
|
-
width:
|
|
134
|
-
borderRadius:
|
|
129
|
+
height: (0, _elements.multiplySizeUnit)(size, 0.72),
|
|
130
|
+
width: (0, _elements.multiplySizeUnit)(size, 1.9),
|
|
131
|
+
borderRadius: (0, _elements.multiplySizeUnit)(size, 2 / 3),
|
|
135
132
|
filter: modelValue === activeValue || errorMessage != null && errorMessage.value ? 'opacity(.6)' : 'brightness(.6)',
|
|
136
133
|
backgroundColor: modelValue === activeValue ? color || '' : closeColor || ''
|
|
137
134
|
},
|
|
138
135
|
switch: {
|
|
139
|
-
height:
|
|
140
|
-
width:
|
|
136
|
+
height: (0, _elements.multiplySizeUnit)(size, 1.2),
|
|
137
|
+
width: (0, _elements.multiplySizeUnit)(size, 2)
|
|
141
138
|
}
|
|
142
139
|
};
|
|
143
140
|
});
|
|
141
|
+
var radius = (0, _vue.computed)(() => {
|
|
142
|
+
var {
|
|
143
|
+
size = '5.333vw'
|
|
144
|
+
} = props;
|
|
145
|
+
return (0, _elements.multiplySizeUnit)(size, 0.4);
|
|
146
|
+
});
|
|
144
147
|
|
|
145
148
|
var switchActive = event => {
|
|
146
149
|
var {
|
|
@@ -177,7 +180,7 @@ var _default = (0, _vue.defineComponent)({
|
|
|
177
180
|
n,
|
|
178
181
|
classes,
|
|
179
182
|
switchActive,
|
|
180
|
-
|
|
183
|
+
radius,
|
|
181
184
|
styleComputed,
|
|
182
185
|
errorMessage,
|
|
183
186
|
formDisabled: form == null ? void 0 : form.disabled,
|
package/lib/switch/props.js
CHANGED
package/lib/switch/switch.css
CHANGED
|
@@ -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
|
|
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;}
|
package/lib/switch/switch.less
CHANGED
|
@@ -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
|
-
|
|
48
|
+
&--active {
|
|
44
49
|
background-color: var(--switch-track-active-background);
|
|
45
50
|
}
|
|
46
51
|
|
|
47
|
-
|
|
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
|
-
|
|
86
|
+
&--active {
|
|
73
87
|
background-color: var(--switch-handle-active-background);
|
|
74
88
|
}
|
|
75
89
|
|
|
76
|
-
|
|
90
|
+
&--error {
|
|
77
91
|
background-color: var(--switch-handle-error-background) !important;
|
|
78
92
|
}
|
|
79
93
|
}
|
package/lib/utils/elements.js
CHANGED
|
@@ -12,7 +12,7 @@ exports.getScrollTop = getScrollTop;
|
|
|
12
12
|
exports.getTop = getTop;
|
|
13
13
|
exports.getTranslate = getTranslate;
|
|
14
14
|
exports.inViewport = inViewport;
|
|
15
|
-
exports.isVw = exports.isVh = exports.isRem = exports.isPx = exports.isPercent = void 0;
|
|
15
|
+
exports.multiplySizeUnit = exports.isVw = exports.isVh = exports.isRem = exports.isPx = exports.isPercent = void 0;
|
|
16
16
|
exports.nextTickFrame = nextTickFrame;
|
|
17
17
|
exports.requestAnimationFrame = requestAnimationFrame;
|
|
18
18
|
exports.scrollTo = scrollTo;
|
|
@@ -195,6 +195,22 @@ var toSizeUnit = value => {
|
|
|
195
195
|
|
|
196
196
|
exports.toSizeUnit = toSizeUnit;
|
|
197
197
|
|
|
198
|
+
var multiplySizeUnit = function (value, quantity) {
|
|
199
|
+
if (quantity === void 0) {
|
|
200
|
+
quantity = 1;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (value == null) {
|
|
204
|
+
return undefined;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
var legalSize = toSizeUnit(value);
|
|
208
|
+
var unit = legalSize.match(/(vh|%|rem|px|vw)$/)[0];
|
|
209
|
+
return "" + parseFloat(legalSize) * quantity + unit;
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
exports.multiplySizeUnit = multiplySizeUnit;
|
|
213
|
+
|
|
198
214
|
function requestAnimationFrame(fn) {
|
|
199
215
|
return globalThis.requestAnimationFrame ? globalThis.requestAnimationFrame(fn) : globalThis.setTimeout(fn, 16);
|
|
200
216
|
}
|
package/lib/utils/jest.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.mockConsole = mockConsole;
|
|
|
7
7
|
exports.mockDoubleRaf = mockDoubleRaf;
|
|
8
8
|
exports.mockFileReader = mockFileReader;
|
|
9
9
|
exports.mockImageNaturalSize = mockImageNaturalSize;
|
|
10
|
+
exports.mockIndexBarOwnTop = mockIndexBarOwnTop;
|
|
10
11
|
exports.mockOffset = mockOffset;
|
|
11
12
|
exports.mockScrollTo = mockScrollTo;
|
|
12
13
|
exports.mockStubs = mockStubs;
|
|
@@ -281,4 +282,24 @@ function mockScrollTo(Element) {
|
|
|
281
282
|
this.scrollTop = y;
|
|
282
283
|
}
|
|
283
284
|
};
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function mockIndexBarOwnTop() {
|
|
288
|
+
var originForEach = Array.prototype.forEach; // eslint-disable-next-line no-extend-native
|
|
289
|
+
|
|
290
|
+
Array.prototype.forEach = function (fn, thisArg) {
|
|
291
|
+
var changedArr = this.map((value, index) => {
|
|
292
|
+
if (value.ownTop && !value.ownTop.value) value.ownTop.value = (index + 1) * 50;
|
|
293
|
+
return value;
|
|
294
|
+
});
|
|
295
|
+
originForEach.call(changedArr, fn, thisArg);
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
return {
|
|
299
|
+
mockRestore() {
|
|
300
|
+
// eslint-disable-next-line no-extend-native
|
|
301
|
+
Array.prototype.forEach = originForEach;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
};
|
|
284
305
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varlet/ui",
|
|
3
|
-
"version": "1.27.
|
|
3
|
+
"version": "1.27.10",
|
|
4
4
|
"description": "A material like components library",
|
|
5
5
|
"module": "es/index.js",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -39,21 +39,22 @@
|
|
|
39
39
|
},
|
|
40
40
|
"gitHead": "ee9c3866bedad96c86365b0f9888a3a6bb781b1f",
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@varlet/icons": "1.27.
|
|
42
|
+
"@varlet/icons": "1.27.10",
|
|
43
43
|
"dayjs": "^1.10.4",
|
|
44
44
|
"decimal.js": "^10.2.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@varlet/cli": "1.27.
|
|
48
|
-
"@varlet/touch-emulator": "1.27.
|
|
49
|
-
"@vue/test-utils": "2.0.0-rc.6",
|
|
47
|
+
"@varlet/cli": "1.27.10",
|
|
48
|
+
"@varlet/touch-emulator": "1.27.10",
|
|
50
49
|
"@vue/runtime-core": "3.2.25",
|
|
51
|
-
"
|
|
52
|
-
"lodash-es": "^4.17.21",
|
|
50
|
+
"@vue/test-utils": "2.0.0-rc.6",
|
|
53
51
|
"clipboard": "^2.0.6",
|
|
52
|
+
"live-server": "^1.2.1",
|
|
53
|
+
"lodash-es": "^4.17.21",
|
|
54
|
+
"postcss-px-to-viewport": "^1.1.1",
|
|
55
|
+
"typescript": "^4.4.4",
|
|
54
56
|
"vue": "3.2.25",
|
|
55
|
-
"vue-router": "4.0.12"
|
|
56
|
-
"live-server": "^1.2.1"
|
|
57
|
+
"vue-router": "4.0.12"
|
|
57
58
|
},
|
|
58
59
|
"browserslist": [
|
|
59
60
|
"Chrome >= 51",
|
package/types/card.d.ts
CHANGED
|
@@ -3,7 +3,12 @@ import { VarComponent } from './varComponent'
|
|
|
3
3
|
export interface CardProps {
|
|
4
4
|
src?: string
|
|
5
5
|
fit?: 'fill' | 'contain' | 'cover' | 'none' | 'scale-down'
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated use imageHeight instead
|
|
8
|
+
*/
|
|
6
9
|
height?: string | number
|
|
10
|
+
imageHeight?: string | number
|
|
11
|
+
imageWidth?: string | number
|
|
7
12
|
alt?: string
|
|
8
13
|
title?: string
|
|
9
14
|
subtitle?: string
|
|
@@ -11,6 +16,10 @@ export interface CardProps {
|
|
|
11
16
|
elevation?: string | number
|
|
12
17
|
ripple?: boolean
|
|
13
18
|
onClick?: (e: Event) => void
|
|
19
|
+
layout?: 'row' | 'column'
|
|
20
|
+
floating?: boolean
|
|
21
|
+
floatingDuration?: number
|
|
22
|
+
'onUpdate:floating'?: (value: boolean) => void
|
|
14
23
|
}
|
|
15
24
|
|
|
16
25
|
export class Card extends VarComponent {
|
package/types/indexBar.d.ts
CHANGED