@varlet/ui 2.0.6 → 2.1.0-alpha.1667210582672
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/collapse/CollapseSfc.css +1 -1
- package/es/select/Select.js +4 -2
- package/es/slider/Slider.js +89 -76
- package/es/slider/props.js +8 -0
- package/es/slider/slider.css +1 -1
- package/es/style.css +1 -1
- package/es/varlet.esm.js +3851 -3837
- package/highlight/attributes.json +26 -2
- package/highlight/tags.json +6 -0
- package/highlight/web-types.json +61 -3
- package/lib/collapse/CollapseSfc.css +1 -1
- package/lib/select/Select.js +4 -2
- package/lib/slider/Slider.js +89 -76
- package/lib/slider/props.js +8 -0
- package/lib/slider/slider.css +1 -1
- package/lib/snackbar/style/index.js +1 -1
- package/lib/style.css +1 -1
- package/package.json +6 -5
- package/types/select.d.ts +5 -0
- package/types/slider.d.ts +2 -0
- package/umd/varlet.js +7 -7
|
@@ -1465,12 +1465,20 @@
|
|
|
1465
1465
|
},
|
|
1466
1466
|
"var-slider/step": {
|
|
1467
1467
|
"type": "string | number",
|
|
1468
|
-
"description": "
|
|
1468
|
+
"description": "步长,取值必须大于 0 默认值:1"
|
|
1469
1469
|
},
|
|
1470
1470
|
"var-slider/range": {
|
|
1471
1471
|
"type": "boolean",
|
|
1472
1472
|
"description": "是否启用双滑块 默认值:false"
|
|
1473
1473
|
},
|
|
1474
|
+
"var-slider/max": {
|
|
1475
|
+
"type": "string | number",
|
|
1476
|
+
"description": "最大值 默认值:100"
|
|
1477
|
+
},
|
|
1478
|
+
"var-slider/min": {
|
|
1479
|
+
"type": "string | number",
|
|
1480
|
+
"description": "最小值 默认值:0"
|
|
1481
|
+
},
|
|
1474
1482
|
"var-slider/label-visible": {
|
|
1475
1483
|
"type": "string",
|
|
1476
1484
|
"description": "是否显示标签,可选值为 `always normal never` 默认值:normal"
|
|
@@ -1479,14 +1487,30 @@
|
|
|
1479
1487
|
"type": "string",
|
|
1480
1488
|
"description": "标签文字颜色 默认值:#fff"
|
|
1481
1489
|
},
|
|
1490
|
+
"var-slider/label-color": {
|
|
1491
|
+
"type": "string",
|
|
1492
|
+
"description": "标签颜色 默认值:-"
|
|
1493
|
+
},
|
|
1494
|
+
"var-slider/active-color": {
|
|
1495
|
+
"type": "string",
|
|
1496
|
+
"description": "已激活的轨道背景颜色 默认值:-"
|
|
1497
|
+
},
|
|
1498
|
+
"var-slider/track-color": {
|
|
1499
|
+
"type": "string",
|
|
1500
|
+
"description": "轨道背景颜色 默认值:-"
|
|
1501
|
+
},
|
|
1482
1502
|
"var-slider/track-height": {
|
|
1483
1503
|
"type": "string | number",
|
|
1484
|
-
"description": "
|
|
1504
|
+
"description": "轨道的高度 默认值:2"
|
|
1485
1505
|
},
|
|
1486
1506
|
"var-slider/thumb-size": {
|
|
1487
1507
|
"type": "string | number",
|
|
1488
1508
|
"description": "滑块的大小 默认值:12"
|
|
1489
1509
|
},
|
|
1510
|
+
"var-slider/thumb-color": {
|
|
1511
|
+
"type": "string",
|
|
1512
|
+
"description": "滑块的背景颜色 默认值:-"
|
|
1513
|
+
},
|
|
1490
1514
|
"var-slider/disabled": {
|
|
1491
1515
|
"type": "boolean",
|
|
1492
1516
|
"description": "是否禁用 默认值:false"
|
package/highlight/tags.json
CHANGED
|
@@ -549,10 +549,16 @@
|
|
|
549
549
|
"v-model",
|
|
550
550
|
"step",
|
|
551
551
|
"range",
|
|
552
|
+
"max",
|
|
553
|
+
"min",
|
|
552
554
|
"label-visible",
|
|
553
555
|
"label-text-color",
|
|
556
|
+
"label-color",
|
|
557
|
+
"active-color",
|
|
558
|
+
"track-color",
|
|
554
559
|
"track-height",
|
|
555
560
|
"thumb-size",
|
|
561
|
+
"thumb-color",
|
|
556
562
|
"disabled",
|
|
557
563
|
"readonly",
|
|
558
564
|
"rules"
|
package/highlight/web-types.json
CHANGED
|
@@ -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": "2.0.
|
|
4
|
+
"version": "2.0.6",
|
|
5
5
|
"name": "VARLET",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
@@ -4188,6 +4188,10 @@
|
|
|
4188
4188
|
{
|
|
4189
4189
|
"name": "append-icon",
|
|
4190
4190
|
"description": "后置图标"
|
|
4191
|
+
},
|
|
4192
|
+
{
|
|
4193
|
+
"name": "arrow-icon",
|
|
4194
|
+
"description": "箭头图标"
|
|
4191
4195
|
}
|
|
4192
4196
|
]
|
|
4193
4197
|
},
|
|
@@ -4316,7 +4320,7 @@
|
|
|
4316
4320
|
},
|
|
4317
4321
|
{
|
|
4318
4322
|
"name": "step",
|
|
4319
|
-
"description": "
|
|
4323
|
+
"description": "步长,取值必须大于 0",
|
|
4320
4324
|
"default": "1",
|
|
4321
4325
|
"value": {
|
|
4322
4326
|
"type": "string | number",
|
|
@@ -4332,6 +4336,24 @@
|
|
|
4332
4336
|
"kind": "expression"
|
|
4333
4337
|
}
|
|
4334
4338
|
},
|
|
4339
|
+
{
|
|
4340
|
+
"name": "max",
|
|
4341
|
+
"description": "最大值",
|
|
4342
|
+
"default": "100",
|
|
4343
|
+
"value": {
|
|
4344
|
+
"type": "string | number",
|
|
4345
|
+
"kind": "expression"
|
|
4346
|
+
}
|
|
4347
|
+
},
|
|
4348
|
+
{
|
|
4349
|
+
"name": "min",
|
|
4350
|
+
"description": "最小值",
|
|
4351
|
+
"default": "0",
|
|
4352
|
+
"value": {
|
|
4353
|
+
"type": "string | number",
|
|
4354
|
+
"kind": "expression"
|
|
4355
|
+
}
|
|
4356
|
+
},
|
|
4335
4357
|
{
|
|
4336
4358
|
"name": "label-visible",
|
|
4337
4359
|
"description": "是否显示标签,可选值为 `always normal never`",
|
|
@@ -4350,9 +4372,36 @@
|
|
|
4350
4372
|
"kind": "expression"
|
|
4351
4373
|
}
|
|
4352
4374
|
},
|
|
4375
|
+
{
|
|
4376
|
+
"name": "label-color",
|
|
4377
|
+
"description": "标签颜色",
|
|
4378
|
+
"default": "-",
|
|
4379
|
+
"value": {
|
|
4380
|
+
"type": "string",
|
|
4381
|
+
"kind": "expression"
|
|
4382
|
+
}
|
|
4383
|
+
},
|
|
4384
|
+
{
|
|
4385
|
+
"name": "active-color",
|
|
4386
|
+
"description": "已激活的轨道背景颜色",
|
|
4387
|
+
"default": "-",
|
|
4388
|
+
"value": {
|
|
4389
|
+
"type": "string",
|
|
4390
|
+
"kind": "expression"
|
|
4391
|
+
}
|
|
4392
|
+
},
|
|
4393
|
+
{
|
|
4394
|
+
"name": "track-color",
|
|
4395
|
+
"description": "轨道背景颜色",
|
|
4396
|
+
"default": "-",
|
|
4397
|
+
"value": {
|
|
4398
|
+
"type": "string",
|
|
4399
|
+
"kind": "expression"
|
|
4400
|
+
}
|
|
4401
|
+
},
|
|
4353
4402
|
{
|
|
4354
4403
|
"name": "track-height",
|
|
4355
|
-
"description": "
|
|
4404
|
+
"description": "轨道的高度",
|
|
4356
4405
|
"default": "2",
|
|
4357
4406
|
"value": {
|
|
4358
4407
|
"type": "string | number",
|
|
@@ -4368,6 +4417,15 @@
|
|
|
4368
4417
|
"kind": "expression"
|
|
4369
4418
|
}
|
|
4370
4419
|
},
|
|
4420
|
+
{
|
|
4421
|
+
"name": "thumb-color",
|
|
4422
|
+
"description": "滑块的背景颜色",
|
|
4423
|
+
"default": "-",
|
|
4424
|
+
"value": {
|
|
4425
|
+
"type": "string",
|
|
4426
|
+
"kind": "expression"
|
|
4427
|
+
}
|
|
4428
|
+
},
|
|
4371
4429
|
{
|
|
4372
4430
|
"name": "disabled",
|
|
4373
4431
|
"description": "是否禁用",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.var-collapse { position: relative; width: 100%;}
|
|
1
|
+
.var-collapse { position: relative; width: 100%; z-index: 0;}
|
package/lib/select/Select.js
CHANGED
|
@@ -127,14 +127,16 @@ function render(_ctx, _cache) {
|
|
|
127
127
|
/* TEXT, CLASS */
|
|
128
128
|
))])) : ((0, _vue.openBlock)(), (0, _vue.createElementBlock)("span", _hoisted_2, (0, _vue.toDisplayString)(_ctx.label), 1
|
|
129
129
|
/* TEXT */
|
|
130
|
-
)), (0, _vue.
|
|
130
|
+
)), (0, _vue.renderSlot)(_ctx.$slots, "arrow-icon", {
|
|
131
|
+
focus: _ctx.isFocus
|
|
132
|
+
}, () => [(0, _vue.createVNode)(_component_var_icon, {
|
|
131
133
|
class: (0, _vue.normalizeClass)(_ctx.classes(_ctx.n('arrow'), [_ctx.isFocus, _ctx.n('--arrow-rotate')])),
|
|
132
134
|
"var-select-cover": "",
|
|
133
135
|
name: "menu-down",
|
|
134
136
|
transition: 300
|
|
135
137
|
}, null, 8
|
|
136
138
|
/* PROPS */
|
|
137
|
-
, ["class"])], 6
|
|
139
|
+
, ["class"])])], 6
|
|
138
140
|
/* CLASS, STYLE */
|
|
139
141
|
), (0, _vue.createElementVNode)("label", {
|
|
140
142
|
class: (0, _vue.normalizeClass)(_ctx.classes(_ctx.n('placeholder'), 'var--ellipsis', [_ctx.isFocus, _ctx.n('--focus')], [_ctx.errorMessage, _ctx.n('--error')], [_ctx.formDisabled || _ctx.disabled, _ctx.n('--disabled')], _ctx.computePlaceholderState(), [!_ctx.hint, _ctx.n('--placeholder-non-hint')])),
|
package/lib/slider/Slider.js
CHANGED
|
@@ -20,8 +20,6 @@ var _formDetails = _interopRequireDefault(require("../form-details"));
|
|
|
20
20
|
|
|
21
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
22
|
|
|
23
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
24
|
-
|
|
25
23
|
var {
|
|
26
24
|
n,
|
|
27
25
|
classes
|
|
@@ -44,10 +42,6 @@ function render(_ctx, _cache) {
|
|
|
44
42
|
class: (0, _vue.normalizeClass)(_ctx.n())
|
|
45
43
|
}, [(0, _vue.createElementVNode)("div", {
|
|
46
44
|
class: (0, _vue.normalizeClass)(_ctx.classes(_ctx.n('block'), [_ctx.isDisabled, _ctx.n('--disabled')], [_ctx.errorMessage, _ctx.n('--error')])),
|
|
47
|
-
style: (0, _vue.normalizeStyle)({
|
|
48
|
-
height: _ctx.thumbSize === undefined ? _ctx.thumbSize : _ctx.multiplySizeUnit(_ctx.thumbSize, 3),
|
|
49
|
-
margin: _ctx.thumbSize === undefined ? _ctx.thumbSize : "0 " + _ctx.multiplySizeUnit(_ctx.thumbSize, 0.5)
|
|
50
|
-
}),
|
|
51
45
|
ref: "sliderEl",
|
|
52
46
|
onClick: _cache[0] || (_cache[0] = function () {
|
|
53
47
|
return _ctx.click && _ctx.click(...arguments);
|
|
@@ -82,21 +76,19 @@ function render(_ctx, _cache) {
|
|
|
82
76
|
onTouchend: $event => _ctx.end(item.enumValue),
|
|
83
77
|
onTouchcancel: $event => _ctx.end(item.enumValue)
|
|
84
78
|
}, [(0, _vue.renderSlot)(_ctx.$slots, "button", {
|
|
85
|
-
currentValue: item.
|
|
79
|
+
currentValue: item.text
|
|
86
80
|
}, () => [(0, _vue.createElementVNode)("div", {
|
|
87
81
|
class: (0, _vue.normalizeClass)(_ctx.n('thumb-block')),
|
|
88
82
|
style: (0, _vue.normalizeStyle)({
|
|
89
|
-
background: _ctx.thumbColor
|
|
90
|
-
height: _ctx.multiplySizeUnit(_ctx.thumbSize),
|
|
91
|
-
width: _ctx.multiplySizeUnit(_ctx.thumbSize)
|
|
83
|
+
background: _ctx.thumbColor
|
|
92
84
|
})
|
|
93
85
|
}, null, 6
|
|
94
86
|
/* CLASS, STYLE */
|
|
95
87
|
), (0, _vue.createElementVNode)("div", {
|
|
96
88
|
class: (0, _vue.normalizeClass)(_ctx.classes(_ctx.n('thumb-ripple'), [_ctx.thumbsProps[item.enumValue].active, _ctx.n('thumb-ripple--active')])),
|
|
97
|
-
style: (0, _vue.normalizeStyle)(
|
|
89
|
+
style: (0, _vue.normalizeStyle)({
|
|
98
90
|
background: _ctx.thumbColor
|
|
99
|
-
}
|
|
91
|
+
})
|
|
100
92
|
}, null, 6
|
|
101
93
|
/* CLASS, STYLE */
|
|
102
94
|
), (0, _vue.createElementVNode)("div", {
|
|
@@ -107,7 +99,7 @@ function render(_ctx, _cache) {
|
|
|
107
99
|
height: _ctx.thumbSize === undefined ? _ctx.thumbSize : _ctx.multiplySizeUnit(_ctx.thumbSize, 2),
|
|
108
100
|
width: _ctx.thumbSize === undefined ? _ctx.thumbSize : _ctx.multiplySizeUnit(_ctx.thumbSize, 2)
|
|
109
101
|
})
|
|
110
|
-
}, [(0, _vue.createElementVNode)("span", null, (0, _vue.toDisplayString)(item.
|
|
102
|
+
}, [(0, _vue.createElementVNode)("span", null, (0, _vue.toDisplayString)(item.text), 1
|
|
111
103
|
/* TEXT */
|
|
112
104
|
)], 6
|
|
113
105
|
/* CLASS, STYLE */
|
|
@@ -116,8 +108,8 @@ function render(_ctx, _cache) {
|
|
|
116
108
|
, _hoisted_1);
|
|
117
109
|
}), 128
|
|
118
110
|
/* KEYED_FRAGMENT */
|
|
119
|
-
))],
|
|
120
|
-
/* CLASS
|
|
111
|
+
))], 2
|
|
112
|
+
/* CLASS */
|
|
121
113
|
), (0, _vue.createVNode)(_component_var_form_details, {
|
|
122
114
|
"error-message": _ctx.errorMessage,
|
|
123
115
|
class: (0, _vue.normalizeClass)(_ctx.n('form')),
|
|
@@ -167,53 +159,43 @@ var _default = (0, _vue.defineComponent)({
|
|
|
167
159
|
[Thumbs.First]: getThumbProps(),
|
|
168
160
|
[Thumbs.Second]: getThumbProps()
|
|
169
161
|
});
|
|
170
|
-
var
|
|
162
|
+
var scope = (0, _vue.computed)(() => (0, _shared.toNumber)(props.max) - (0, _shared.toNumber)(props.min));
|
|
163
|
+
var unitWidth = (0, _vue.computed)(() => maxWidth.value / scope.value * (0, _shared.toNumber)(props.step));
|
|
171
164
|
var thumbList = (0, _vue.computed)(() => {
|
|
172
|
-
var
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
165
|
+
var {
|
|
166
|
+
modelValue,
|
|
167
|
+
range
|
|
168
|
+
} = props;
|
|
169
|
+
var list = [];
|
|
176
170
|
|
|
177
|
-
if (
|
|
171
|
+
if (range && (0, _shared.isArray)(modelValue)) {
|
|
178
172
|
list = [{
|
|
179
|
-
value:
|
|
180
|
-
enumValue: Thumbs.First
|
|
173
|
+
value: getValue(modelValue[0]),
|
|
174
|
+
enumValue: Thumbs.First,
|
|
175
|
+
text: toPrecision(modelValue[0])
|
|
181
176
|
}, {
|
|
182
|
-
value:
|
|
183
|
-
enumValue: Thumbs.Second
|
|
177
|
+
value: getValue(modelValue[1]),
|
|
178
|
+
enumValue: Thumbs.Second,
|
|
179
|
+
text: toPrecision(modelValue[1])
|
|
180
|
+
}];
|
|
181
|
+
} else if ((0, _shared.isNumber)(modelValue)) {
|
|
182
|
+
list = [{
|
|
183
|
+
value: getValue(modelValue),
|
|
184
|
+
enumValue: Thumbs.First,
|
|
185
|
+
text: toPrecision(modelValue)
|
|
184
186
|
}];
|
|
185
187
|
}
|
|
186
188
|
|
|
187
189
|
return list;
|
|
188
190
|
});
|
|
189
|
-
|
|
190
|
-
var getRippleSize = item => {
|
|
191
|
-
var size;
|
|
192
|
-
|
|
193
|
-
if (props.thumbSize !== undefined) {
|
|
194
|
-
size = thumbsProps[item.enumValue].active ? (0, _elements.multiplySizeUnit)(props.thumbSize, 3) : '0px';
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return {
|
|
198
|
-
height: size,
|
|
199
|
-
width: size
|
|
200
|
-
};
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
var showLabel = type => {
|
|
204
|
-
if (props.labelVisible === 'always') return true;
|
|
205
|
-
if (props.labelVisible === 'never') return false;
|
|
206
|
-
return thumbsProps[type].active;
|
|
207
|
-
};
|
|
208
|
-
|
|
209
191
|
var getFillStyle = (0, _vue.computed)(() => {
|
|
210
192
|
var {
|
|
211
193
|
activeColor,
|
|
212
194
|
range,
|
|
213
195
|
modelValue
|
|
214
196
|
} = props;
|
|
215
|
-
var
|
|
216
|
-
var
|
|
197
|
+
var left = range && (0, _shared.isArray)(modelValue) ? getValue(Math.min(modelValue[0], modelValue[1])) : 0;
|
|
198
|
+
var width = range && (0, _shared.isArray)(modelValue) ? getValue(Math.max(modelValue[0], modelValue[1])) - left : getValue(modelValue);
|
|
217
199
|
return {
|
|
218
200
|
width: width + "%",
|
|
219
201
|
left: left + "%",
|
|
@@ -223,26 +205,52 @@ var _default = (0, _vue.defineComponent)({
|
|
|
223
205
|
var isDisabled = (0, _vue.computed)(() => props.disabled || (form == null ? void 0 : form.disabled.value));
|
|
224
206
|
var isReadonly = (0, _vue.computed)(() => props.readonly || (form == null ? void 0 : form.readonly.value));
|
|
225
207
|
|
|
208
|
+
var showLabel = type => {
|
|
209
|
+
if (props.labelVisible === 'always') return true;
|
|
210
|
+
if (props.labelVisible === 'never') return false;
|
|
211
|
+
return thumbsProps[type].active;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
var getValue = value => {
|
|
215
|
+
var {
|
|
216
|
+
min,
|
|
217
|
+
max
|
|
218
|
+
} = props;
|
|
219
|
+
if (value < (0, _shared.toNumber)(min)) return 0;
|
|
220
|
+
if (value > (0, _shared.toNumber)(max)) return 100;
|
|
221
|
+
return (value - (0, _shared.toNumber)(min)) / scope.value * 100;
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
var toPrecision = value => {
|
|
225
|
+
if (!(0, _shared.isNumber)(value)) return 0;
|
|
226
|
+
var num = value;
|
|
227
|
+
if (num < Number(props.min)) num = Number(props.min);
|
|
228
|
+
if (num > Number(props.max)) num = Number(props.max);
|
|
229
|
+
var isInteger = parseInt("" + num, 10) === num;
|
|
230
|
+
return isInteger ? num : (0, _shared.toNumber)(num.toPrecision(5));
|
|
231
|
+
};
|
|
232
|
+
|
|
226
233
|
var setPercent = (moveDistance, type) => {
|
|
227
234
|
var rangeValue = [];
|
|
228
235
|
var {
|
|
229
236
|
step,
|
|
230
237
|
range,
|
|
231
238
|
modelValue,
|
|
232
|
-
onChange
|
|
239
|
+
onChange,
|
|
240
|
+
min
|
|
233
241
|
} = props;
|
|
234
242
|
var stepNumber = (0, _shared.toNumber)(step);
|
|
235
243
|
var roundDistance = Math.round(moveDistance / unitWidth.value);
|
|
236
|
-
var curValue = roundDistance * stepNumber;
|
|
237
|
-
var prevValue = thumbsProps[type].percentValue;
|
|
238
|
-
thumbsProps[type].percentValue =
|
|
244
|
+
var curValue = roundDistance * stepNumber + (0, _shared.toNumber)(min);
|
|
245
|
+
var prevValue = thumbsProps[type].percentValue * stepNumber + (0, _shared.toNumber)(min);
|
|
246
|
+
thumbsProps[type].percentValue = roundDistance;
|
|
239
247
|
|
|
240
248
|
if (range && (0, _shared.isArray)(modelValue)) {
|
|
241
249
|
rangeValue = type === Thumbs.First ? [curValue, modelValue[1]] : [modelValue[0], curValue];
|
|
242
250
|
}
|
|
243
251
|
|
|
244
252
|
if (prevValue !== curValue) {
|
|
245
|
-
var value = range ? rangeValue : curValue;
|
|
253
|
+
var value = range ? rangeValue.map(value => toPrecision(value)) : toPrecision(curValue);
|
|
246
254
|
(0, _components.call)(onChange, value);
|
|
247
255
|
(0, _components.call)(props['onUpdate:modelValue'], value);
|
|
248
256
|
validateWithTrigger();
|
|
@@ -278,13 +286,15 @@ var _default = (0, _vue.defineComponent)({
|
|
|
278
286
|
var {
|
|
279
287
|
range,
|
|
280
288
|
modelValue,
|
|
281
|
-
onEnd
|
|
289
|
+
onEnd,
|
|
290
|
+
step,
|
|
291
|
+
min
|
|
282
292
|
} = props;
|
|
283
293
|
if (isDisabled.value || isReadonly.value) return;
|
|
284
294
|
var rangeValue = [];
|
|
285
295
|
thumbsProps[type].currentLeft = thumbsProps[type].percentValue * unitWidth.value;
|
|
286
296
|
thumbsProps[type].active = false;
|
|
287
|
-
var curValue = thumbsProps[type].percentValue;
|
|
297
|
+
var curValue = thumbsProps[type].percentValue * (0, _shared.toNumber)(step) + (0, _shared.toNumber)(min);
|
|
288
298
|
|
|
289
299
|
if (range && (0, _shared.isArray)(modelValue)) {
|
|
290
300
|
rangeValue = type === Thumbs.First ? [curValue, modelValue[1]] : [modelValue[0], curValue];
|
|
@@ -311,13 +321,8 @@ var _default = (0, _vue.defineComponent)({
|
|
|
311
321
|
return false;
|
|
312
322
|
}
|
|
313
323
|
|
|
314
|
-
if (stepNumber <
|
|
315
|
-
console.warn('[Varlet] Slider: "step" should be
|
|
316
|
-
return false;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
if (parseInt("" + props.step, 10) !== stepNumber) {
|
|
320
|
-
console.warn('[Varlet] Slider: "step" should be an Integer');
|
|
324
|
+
if (stepNumber < 0) {
|
|
325
|
+
console.warn('[Varlet] Slider: "step" should be > 0');
|
|
321
326
|
return false;
|
|
322
327
|
}
|
|
323
328
|
|
|
@@ -357,27 +362,26 @@ var _default = (0, _vue.defineComponent)({
|
|
|
357
362
|
step = (0, _shared.toNumber)(props.step);
|
|
358
363
|
}
|
|
359
364
|
|
|
365
|
+
var getPercent = value => {
|
|
366
|
+
var {
|
|
367
|
+
min,
|
|
368
|
+
max
|
|
369
|
+
} = props;
|
|
370
|
+
if (value < (0, _shared.toNumber)(min)) return 0;
|
|
371
|
+
if (value > (0, _shared.toNumber)(max)) return scope.value / step;
|
|
372
|
+
return (value - (0, _shared.toNumber)(min)) / step;
|
|
373
|
+
};
|
|
374
|
+
|
|
360
375
|
if (props.range && (0, _shared.isArray)(modelValue)) {
|
|
361
|
-
thumbsProps[Thumbs.First].percentValue = modelValue[0]
|
|
376
|
+
thumbsProps[Thumbs.First].percentValue = getPercent(modelValue[0]);
|
|
362
377
|
thumbsProps[Thumbs.First].currentLeft = thumbsProps[Thumbs.First].percentValue * unitWidth.value;
|
|
363
|
-
thumbsProps[Thumbs.Second].percentValue = modelValue[1]
|
|
378
|
+
thumbsProps[Thumbs.Second].percentValue = getPercent(modelValue[1]);
|
|
364
379
|
thumbsProps[Thumbs.Second].currentLeft = thumbsProps[Thumbs.Second].percentValue * unitWidth.value;
|
|
365
380
|
} else if ((0, _shared.isNumber)(modelValue)) {
|
|
366
|
-
thumbsProps[Thumbs.First].currentLeft = modelValue
|
|
381
|
+
thumbsProps[Thumbs.First].currentLeft = getPercent(modelValue) * unitWidth.value;
|
|
367
382
|
}
|
|
368
383
|
};
|
|
369
384
|
|
|
370
|
-
(0, _vue.watch)([() => props.modelValue, () => props.step], _ref => {
|
|
371
|
-
var [modelValue, step] = _ref;
|
|
372
|
-
if (!stepValidator() || !valueValidator() || isScroll.value) return;
|
|
373
|
-
setProps(modelValue, (0, _shared.toNumber)(step));
|
|
374
|
-
});
|
|
375
|
-
(0, _vue.watch)(maxWidth, () => setProps());
|
|
376
|
-
(0, _vue.onMounted)(() => {
|
|
377
|
-
if (!stepValidator() || !valueValidator()) return;
|
|
378
|
-
maxWidth.value = sliderEl.value.offsetWidth;
|
|
379
|
-
});
|
|
380
|
-
|
|
381
385
|
var reset = () => {
|
|
382
386
|
var resetValue = props.range ? [0, 0] : 0;
|
|
383
387
|
(0, _components.call)(props['onUpdate:modelValue'], resetValue);
|
|
@@ -390,6 +394,16 @@ var _default = (0, _vue.defineComponent)({
|
|
|
390
394
|
resetValidation
|
|
391
395
|
};
|
|
392
396
|
(0, _components.call)(bindForm, sliderProvider);
|
|
397
|
+
(0, _vue.watch)([() => props.modelValue, () => props.step], _ref => {
|
|
398
|
+
var [modelValue, step] = _ref;
|
|
399
|
+
if (!stepValidator() || !valueValidator() || isScroll.value) return;
|
|
400
|
+
setProps(modelValue, (0, _shared.toNumber)(step));
|
|
401
|
+
});
|
|
402
|
+
(0, _vue.watch)(maxWidth, () => setProps());
|
|
403
|
+
(0, _vue.onMounted)(() => {
|
|
404
|
+
if (!stepValidator() || !valueValidator()) return;
|
|
405
|
+
maxWidth.value = sliderEl.value.offsetWidth;
|
|
406
|
+
});
|
|
393
407
|
return {
|
|
394
408
|
n,
|
|
395
409
|
classes,
|
|
@@ -402,7 +416,6 @@ var _default = (0, _vue.defineComponent)({
|
|
|
402
416
|
thumbList,
|
|
403
417
|
multiplySizeUnit: _elements.multiplySizeUnit,
|
|
404
418
|
toNumber: _shared.toNumber,
|
|
405
|
-
getRippleSize,
|
|
406
419
|
showLabel,
|
|
407
420
|
start,
|
|
408
421
|
move,
|
package/lib/slider/props.js
CHANGED
package/lib/slider/slider.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
:root { --slider-error-color: var(--color-danger); --slider-track-background: #bdbdbd; --slider-track-fill-background: var(--color-primary); --slider-thumb-block-background: var(--color-primary); --slider-thumb-ripple-background: var(--color-primary); --slider-thumb-label-background: var(--color-primary); --slider-thumb-label-font-size: var(--font-size-sm);}.var-slider { -webkit-tap-highlight-color: rgba(0, 0, 0, 0); width: 100%;}.var-slider__block { display: flex; align-items: center; position: relative; flex: 1; user-select: none; height: 36px; margin: 0 6px;}.var-slider--disabled { filter: opacity(0.6);}.var-slider__track { width: 100%; align-items: center; position: relative;}.var-slider__track-background { width: 100%; height: 2px; background: var(--slider-track-background);}.var-slider__track-fill { position: absolute; height: 100%; left: 0; top: 0; background-color: var(--slider-track-fill-background);}.var-slider__thumb { position: absolute;}.var-slider__thumb-block { position: absolute; width: 12px; height: 12px; border-radius: 50%; transform: translate(-50%, -50%); background-color: var(--slider-thumb-block-background);}.var-slider__thumb-ripple { position: absolute; width: 0; z-index: -1; height: 0; left: 50%; top: 50%; transform: translate(-50%, -50%); border-radius: 50%; opacity: 0.3; background: var(--slider-thumb-ripple-background); transition: 0.3s var(--cubic-bezier);}.var-slider__thumb-ripple--active { width: 36px; height: 36px;}.var-slider__thumb-label { height: 24px; width: 24px; background-color: var(--slider-thumb-label-background); display: flex; align-items: center; border: none; justify-content: center; color: #fff; border-radius: 50% 50% 0; bottom: 60%; user-select: none; position: absolute; left: 45%; transition: 0.3s var(--cubic-bezier); font-size: var(--slider-thumb-label-font-size); overflow: hidden; transform: translateY(0) translateY(0) translateX(-50%) rotate(45deg) scale(0);}.var-slider__thumb-label span { transform: rotate(-45deg);}.var-slider__thumb-label--active { transform: translateY(-
|
|
1
|
+
:root { --slider-error-color: var(--color-danger); --slider-track-background: #bdbdbd; --slider-track-fill-background: var(--color-primary); --slider-thumb-block-background: var(--color-primary); --slider-thumb-ripple-background: var(--color-primary); --slider-thumb-label-background: var(--color-primary); --slider-thumb-label-font-size: var(--font-size-sm);}.var-slider { -webkit-tap-highlight-color: rgba(0, 0, 0, 0); width: 100%;}.var-slider__block { display: flex; align-items: center; position: relative; flex: 1; user-select: none; height: 36px; margin: 0 6px;}.var-slider--disabled { filter: opacity(0.6);}.var-slider__track { width: 100%; align-items: center; position: relative;}.var-slider__track-background { width: 100%; height: 2px; background: var(--slider-track-background);}.var-slider__track-fill { position: absolute; height: 100%; left: 0; top: 0; background-color: var(--slider-track-fill-background);}.var-slider__thumb { position: absolute;}.var-slider__thumb-block { position: absolute; width: 12px; height: 12px; border-radius: 50%; transform: translate(-50%, -50%); background-color: var(--slider-thumb-block-background);}.var-slider__thumb-ripple { position: absolute; width: 0; z-index: -1; height: 0; left: 50%; top: 50%; transform: translate(-50%, -50%); border-radius: 50%; opacity: 0.3; background: var(--slider-thumb-ripple-background); transition: 0.3s var(--cubic-bezier);}.var-slider__thumb-ripple--active { width: 36px; height: 36px;}.var-slider__thumb-label { height: 24px; width: 24px; background-color: var(--slider-thumb-label-background); display: flex; align-items: center; border: none; justify-content: center; color: #fff; border-radius: 50% 50% 0; bottom: 60%; user-select: none; position: absolute; left: 45%; transition: 0.3s var(--cubic-bezier); font-size: var(--slider-thumb-label-font-size); overflow: hidden; transform: translateY(0) translateY(0) translateX(-50%) rotate(45deg) scale(0);}.var-slider__thumb-label span { transform: rotate(-45deg);}.var-slider__thumb-label--active { transform: translateY(-20%) translateY(-8px) translateX(-50%) rotate(45deg) scale(1);}.var-slider--error .var-slider__track-background { background-color: var(--slider-error-color) !important; filter: opacity(0.5);}.var-slider--error .var-slider__track-fill { background-color: var(--slider-error-color) !important;}.var-slider--error .var-slider__thumb-block { background-color: var(--slider-error-color) !important;}.var-slider--error .var-slider__thumb-ripple { background-color: var(--slider-error-color) !important;}.var-slider--error .var-slider__thumb-label { background-color: var(--slider-error-color) !important;}.var-slider__form[var-slider-cover] { margin: 0;}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
require('../../styles/common.css')
|
|
2
|
+
require('../SnackbarSfc.css')
|
|
2
3
|
require('../../styles/elevation.css')
|
|
3
4
|
require('../../loading/loading.css')
|
|
4
5
|
require('../../button/button.css')
|
|
5
6
|
require('../../icon/icon.css')
|
|
6
7
|
require('../snackbar.css')
|
|
7
8
|
require('../coreSfc.css')
|
|
8
|
-
require('../SnackbarSfc.css')
|