@varlet/ui 2.9.0 → 2.9.1-alpha.1678874318012
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/button/Button.mjs +17 -14
- package/es/button/button.css +1 -1
- package/es/button/style/index.mjs +1 -0
- package/es/counter/Counter.mjs +36 -22
- package/es/counter/counter.css +1 -1
- package/es/counter/style/index.mjs +2 -0
- package/es/hover-overlay/HoverOverlay.mjs +32 -0
- package/es/hover-overlay/HoverOverlaySfc.css +0 -0
- package/es/hover-overlay/hoverOverlay.css +1 -0
- package/es/hover-overlay/index.mjs +21 -0
- package/es/hover-overlay/props.mjs +6 -0
- package/es/hover-overlay/style/index.mjs +2 -0
- package/es/image-preview/index.mjs +32 -5
- package/es/index.bundle.mjs +7 -1
- package/es/index.mjs +6 -1
- package/es/input/Input.mjs +1 -3
- package/es/slider/Slider.mjs +54 -12
- package/es/slider/slider.css +1 -1
- package/es/slider/style/index.mjs +1 -0
- package/es/snackbar/style/index.mjs +1 -1
- package/es/style.css +1 -1
- package/es/style.mjs +1 -0
- package/es/switch/Switch.mjs +29 -6
- package/es/switch/style/index.mjs +1 -0
- package/es/varlet.esm.js +5860 -5736
- package/highlight/web-types.en-US.json +1 -1
- package/highlight/web-types.zh-CN.json +1 -1
- package/lib/style.css +1 -1
- package/lib/varlet.cjs.js +399 -240
- package/package.json +6 -6
- package/types/hoverOverlay.d.ts +13 -0
- package/types/imagePreview.d.ts +5 -1
- package/types/index.d.ts +2 -0
- package/umd/varlet.js +5 -5
package/es/slider/Slider.mjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import VarFormDetails from '../form-details/index.mjs';
|
|
2
|
-
import { defineComponent, ref, computed, reactive, nextTick, watch } from 'vue';
|
|
2
|
+
import { defineComponent, ref, computed, reactive, nextTick, watch, unref } from 'vue';
|
|
3
3
|
import { useValidation, createNamespace, call } from '../utils/components.mjs';
|
|
4
4
|
import { useForm } from '../form/provide.mjs';
|
|
5
|
+
import VarHoverOverlay, { useHoverOverlay } from '../hover-overlay/index.mjs';
|
|
6
|
+
import Hover from '../hover/index.mjs';
|
|
5
7
|
import { getLeft, multiplySizeUnit } from '../utils/elements.mjs';
|
|
6
8
|
import { isArray, isNumber, toNumber } from '@varlet/shared';
|
|
7
9
|
import { props, Thumbs } from './props.mjs';
|
|
@@ -10,15 +12,19 @@ var {
|
|
|
10
12
|
n,
|
|
11
13
|
classes
|
|
12
14
|
} = createNamespace('slider');
|
|
13
|
-
import { normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle, createElementVNode as _createElementVNode, renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, renderSlot as _renderSlot,
|
|
15
|
+
import { normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle, createElementVNode as _createElementVNode, renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, renderSlot as _renderSlot, resolveDirective as _resolveDirective, withDirectives as _withDirectives, resolveComponent as _resolveComponent, createVNode as _createVNode, toDisplayString as _toDisplayString, withModifiers as _withModifiers, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
|
|
14
16
|
|
|
15
17
|
var _withScopeId = n => (_pushScopeId(""), n = n(), _popScopeId(), n);
|
|
16
18
|
|
|
17
19
|
var _hoisted_1 = ["onTouchstart", "onTouchmove", "onTouchend", "onTouchcancel"];
|
|
18
20
|
|
|
19
21
|
function __render__(_ctx, _cache) {
|
|
22
|
+
var _component_var_hover_overlay = _resolveComponent("var-hover-overlay");
|
|
23
|
+
|
|
20
24
|
var _component_var_form_details = _resolveComponent("var-form-details");
|
|
21
25
|
|
|
26
|
+
var _directive_hover = _resolveDirective("hover");
|
|
27
|
+
|
|
22
28
|
return _openBlock(), _createElementBlock("div", {
|
|
23
29
|
class: _normalizeClass(_ctx.n())
|
|
24
30
|
}, [_createElementVNode("div", {
|
|
@@ -58,19 +64,23 @@ function __render__(_ctx, _cache) {
|
|
|
58
64
|
onTouchcancel: $event => _ctx.end(item.enumValue)
|
|
59
65
|
}, [_renderSlot(_ctx.$slots, "button", {
|
|
60
66
|
currentValue: item.text
|
|
61
|
-
}, () => [_createElementVNode("div", {
|
|
67
|
+
}, () => [_withDirectives(_createElementVNode("div", {
|
|
62
68
|
class: _normalizeClass(_ctx.n('thumb-block')),
|
|
63
69
|
style: _normalizeStyle({
|
|
64
70
|
background: _ctx.thumbColor
|
|
65
71
|
})
|
|
66
72
|
}, null, 6
|
|
67
73
|
/* CLASS, STYLE */
|
|
68
|
-
), _createElementVNode("div", {
|
|
74
|
+
), [[_directive_hover, value => _ctx.hover(value, item), "desktop"]]), _createElementVNode("div", {
|
|
69
75
|
class: _normalizeClass(_ctx.classes(_ctx.n('thumb-ripple'), [_ctx.thumbsProps[item.enumValue].active, _ctx.n('thumb-ripple--active')])),
|
|
70
76
|
style: _normalizeStyle({
|
|
71
|
-
background: _ctx.thumbColor
|
|
77
|
+
background: _ctx.thumbsProps[item.enumValue].active ? _ctx.thumbColor : undefined
|
|
72
78
|
})
|
|
73
|
-
},
|
|
79
|
+
}, [_createVNode(_component_var_hover_overlay, {
|
|
80
|
+
hovering: item.hovering
|
|
81
|
+
}, null, 8
|
|
82
|
+
/* PROPS */
|
|
83
|
+
, ["hovering"])], 6
|
|
74
84
|
/* CLASS, STYLE */
|
|
75
85
|
), _createElementVNode("div", {
|
|
76
86
|
class: _normalizeClass(_ctx.classes(_ctx.n('thumb-label'), [_ctx.showLabel(item.enumValue), _ctx.n('thumb-label--active')])),
|
|
@@ -105,7 +115,11 @@ function __render__(_ctx, _cache) {
|
|
|
105
115
|
var __sfc__ = defineComponent({
|
|
106
116
|
name: 'VarSlider',
|
|
107
117
|
components: {
|
|
108
|
-
VarFormDetails
|
|
118
|
+
VarFormDetails,
|
|
119
|
+
VarHoverOverlay
|
|
120
|
+
},
|
|
121
|
+
directives: {
|
|
122
|
+
Hover
|
|
109
123
|
},
|
|
110
124
|
props,
|
|
111
125
|
|
|
@@ -120,6 +134,14 @@ var __sfc__ = defineComponent({
|
|
|
120
134
|
validate: v,
|
|
121
135
|
resetValidation
|
|
122
136
|
} = useValidation();
|
|
137
|
+
var {
|
|
138
|
+
hovering: hoveringFirst,
|
|
139
|
+
handleHovering: handleHoveringFirst
|
|
140
|
+
} = useHoverOverlay();
|
|
141
|
+
var {
|
|
142
|
+
hovering: hoveringSecond,
|
|
143
|
+
handleHovering: handleHoveringSecond
|
|
144
|
+
} = useHoverOverlay();
|
|
123
145
|
|
|
124
146
|
var validate = () => v(props.rules, props.modelValue);
|
|
125
147
|
|
|
@@ -152,17 +174,23 @@ var __sfc__ = defineComponent({
|
|
|
152
174
|
list = [{
|
|
153
175
|
value: getValue(modelValue[0]),
|
|
154
176
|
enumValue: Thumbs.First,
|
|
155
|
-
text: toPrecision(modelValue[0])
|
|
177
|
+
text: toPrecision(modelValue[0]),
|
|
178
|
+
hovering: unref(hoveringFirst),
|
|
179
|
+
handleHovering: handleHoveringFirst
|
|
156
180
|
}, {
|
|
157
181
|
value: getValue(modelValue[1]),
|
|
158
182
|
enumValue: Thumbs.Second,
|
|
159
|
-
text: toPrecision(modelValue[1])
|
|
183
|
+
text: toPrecision(modelValue[1]),
|
|
184
|
+
hovering: unref(hoveringSecond),
|
|
185
|
+
handleHovering: handleHoveringSecond
|
|
160
186
|
}];
|
|
161
187
|
} else if (isNumber(modelValue)) {
|
|
162
188
|
list = [{
|
|
163
189
|
value: getValue(modelValue),
|
|
164
190
|
enumValue: Thumbs.First,
|
|
165
|
-
text: toPrecision(modelValue)
|
|
191
|
+
text: toPrecision(modelValue),
|
|
192
|
+
hovering: unref(hoveringFirst),
|
|
193
|
+
handleHovering: handleHoveringFirst
|
|
166
194
|
}];
|
|
167
195
|
}
|
|
168
196
|
|
|
@@ -210,6 +238,11 @@ var __sfc__ = defineComponent({
|
|
|
210
238
|
return isInteger ? num : toNumber(num.toPrecision(5));
|
|
211
239
|
};
|
|
212
240
|
|
|
241
|
+
var hover = (value, item) => {
|
|
242
|
+
if (isDisabled.value) return;
|
|
243
|
+
item.handleHovering(value);
|
|
244
|
+
};
|
|
245
|
+
|
|
213
246
|
var setPercent = (moveDistance, type) => {
|
|
214
247
|
var rangeValue = [];
|
|
215
248
|
var {
|
|
@@ -248,6 +281,11 @@ var __sfc__ = defineComponent({
|
|
|
248
281
|
|
|
249
282
|
var start = (event, type) => {
|
|
250
283
|
if (!maxWidth.value) maxWidth.value = sliderEl.value.offsetWidth;
|
|
284
|
+
|
|
285
|
+
if (!isDisabled.value) {
|
|
286
|
+
thumbsProps[type].active = true;
|
|
287
|
+
}
|
|
288
|
+
|
|
251
289
|
if (isDisabled.value || isReadonly.value) return;
|
|
252
290
|
call(props.onStart);
|
|
253
291
|
isScroll.value = true;
|
|
@@ -257,7 +295,6 @@ var __sfc__ = defineComponent({
|
|
|
257
295
|
var move = (event, type) => {
|
|
258
296
|
if (isDisabled.value || isReadonly.value || !isScroll.value) return;
|
|
259
297
|
var moveDistance = event.touches[0].clientX - thumbsProps[type].startPosition + thumbsProps[type].currentLeft;
|
|
260
|
-
thumbsProps[type].active = true;
|
|
261
298
|
if (moveDistance <= 0) moveDistance = 0;else if (moveDistance >= maxWidth.value) moveDistance = maxWidth.value;
|
|
262
299
|
setPercent(moveDistance, type);
|
|
263
300
|
};
|
|
@@ -270,10 +307,14 @@ var __sfc__ = defineComponent({
|
|
|
270
307
|
step,
|
|
271
308
|
min
|
|
272
309
|
} = props;
|
|
310
|
+
|
|
311
|
+
if (!isDisabled.value) {
|
|
312
|
+
thumbsProps[type].active = false;
|
|
313
|
+
}
|
|
314
|
+
|
|
273
315
|
if (isDisabled.value || isReadonly.value) return;
|
|
274
316
|
var rangeValue = [];
|
|
275
317
|
thumbsProps[type].currentLeft = thumbsProps[type].percentValue * unitWidth.value;
|
|
276
|
-
thumbsProps[type].active = false;
|
|
277
318
|
var curValue = thumbsProps[type].percentValue * toNumber(step) + toNumber(min);
|
|
278
319
|
|
|
279
320
|
if (range && isArray(modelValue)) {
|
|
@@ -394,6 +435,7 @@ var __sfc__ = defineComponent({
|
|
|
394
435
|
errorMessage,
|
|
395
436
|
thumbsProps,
|
|
396
437
|
thumbList,
|
|
438
|
+
hover,
|
|
397
439
|
multiplySizeUnit,
|
|
398
440
|
toNumber,
|
|
399
441
|
showLabel,
|
package/es/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); --slider-disabled-opacity: var(--opacity-disabled);}.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; transition: filter 0.25s;}.var-slider--disabled { filter: opacity(var(--slider-disabled-opacity)); cursor: not-allowed;}.var-slider__track { width: 100%; align-items: center; position: relative;}.var-slider__track-background { width: 100%; height: 2px; background: var(--slider-track-background); transition: filter, background-color, 0.25s;}.var-slider__track-fill { position: absolute; height: 100%; left: 0; top: 0; transition: background-color 0.25s; 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%); transition: background-color 0.25s; background-color: var(--slider-thumb-block-background);}.var-slider__thumb-ripple { position: absolute; width:
|
|
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); --slider-disabled-opacity: var(--opacity-disabled);}.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; transition: filter 0.25s;}.var-slider--disabled { filter: opacity(var(--slider-disabled-opacity)); cursor: not-allowed;}.var-slider__track { width: 100%; align-items: center; position: relative;}.var-slider__track-background { width: 100%; height: 2px; background: var(--slider-track-background); transition: filter, background-color, 0.25s;}.var-slider__track-fill { position: absolute; height: 100%; left: 0; top: 0; transition: background-color 0.25s; background-color: var(--slider-track-fill-background);}.var-slider__thumb { position: absolute; cursor: pointer;}.var-slider__thumb-block { position: absolute; width: 12px; height: 12px; border-radius: 50%; transform: translate(-50%, -50%); transition: background-color 0.25s; z-index: 1; background-color: var(--slider-thumb-block-background);}.var-slider__thumb-ripple { position: absolute; width: 36px; height: 36px; left: 50%; top: 50%; transform: translate(-50%, -50%); border-radius: 50%; opacity: 0.3; background: transparent; transition: 0.3s var(--cubic-bezier);}.var-slider__thumb-ripple--active { background: var(--slider-thumb-ripple-background);}.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.6);}.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--active { 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
|
import '../../styles/common.css'
|
|
2
|
-
import '../SnackbarSfc.css'
|
|
3
2
|
import '../../styles/elevation.css'
|
|
4
3
|
import '../../loading/loading.css'
|
|
5
4
|
import '../../button/button.css'
|
|
6
5
|
import '../../icon/icon.css'
|
|
7
6
|
import '../snackbar.css'
|
|
8
7
|
import '../coreSfc.css'
|
|
8
|
+
import '../SnackbarSfc.css'
|