@varlet/ui 3.2.2 → 3.2.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 +1 -2
- package/README.zh-CN.md +1 -2
- package/es/action-sheet/style/index.mjs +1 -1
- package/es/avatar-group/AvatarGroup.mjs +1 -2
- package/es/date-picker/src/year-picker-panel.mjs +10 -18
- package/es/divider/Divider.mjs +2 -1
- package/es/image/Image.mjs +2 -2
- package/es/image/props.mjs +4 -0
- package/es/index.bundle.mjs +1 -1
- package/es/index.mjs +1 -1
- package/es/menu/usePopover.mjs +10 -4
- package/es/result/Result.mjs +8 -14
- package/es/result/Success.mjs +4 -6
- package/es/snackbar/style/index.mjs +1 -1
- package/es/style.css +1 -1
- package/es/switch/Switch.mjs +21 -20
- package/es/switch/props.mjs +1 -0
- package/es/switch/switch.css +1 -1
- package/es/themes/dark/switch.mjs +13 -2
- package/es/themes/index.mjs +1 -10
- package/es/themes/md3-dark/switch.mjs +13 -2
- package/es/themes/md3-light/switch.mjs +13 -2
- package/es/themes/toViewport.d.ts +3 -0
- package/es/themes/toViewport.mjs +13 -0
- package/es/time-picker/clock.mjs +3 -5
- package/es/varlet.esm.js +1892 -1860
- package/highlight/web-types.en-US.json +22 -4
- package/highlight/web-types.zh-CN.json +23 -5
- package/lib/style.css +1 -1
- package/lib/varlet.cjs.js +113 -76
- package/package.json +7 -7
- package/types/image.d.ts +1 -0
- package/types/styleVars.d.ts +22 -0
- package/types/switch.d.ts +1 -0
- package/umd/varlet.js +6 -6
package/es/switch/Switch.mjs
CHANGED
|
@@ -38,14 +38,14 @@ function __render__(_ctx, _cache) {
|
|
|
38
38
|
return _withDirectives((_openBlock(), _createElementBlock(
|
|
39
39
|
"div",
|
|
40
40
|
{
|
|
41
|
-
class: _normalizeClass(_ctx.n())
|
|
41
|
+
class: _normalizeClass(_ctx.classes(_ctx.n(), [_ctx.variant, _ctx.n("--variant")]))
|
|
42
42
|
},
|
|
43
43
|
[
|
|
44
44
|
_createElementVNode(
|
|
45
45
|
"div",
|
|
46
46
|
{
|
|
47
47
|
ref: "switchRef",
|
|
48
|
-
class: _normalizeClass(_ctx.classes(_ctx.n("block"), [_ctx.disabled || _ctx.formDisabled, _ctx.n("--disabled")])),
|
|
48
|
+
class: _normalizeClass(_ctx.classes(_ctx.n("block"), [_ctx.disabled || _ctx.formDisabled, _ctx.n("--disabled")], [_ctx.isActive, _ctx.n("block--active")])),
|
|
49
49
|
style: _normalizeStyle(_ctx.styleComputed.switch),
|
|
50
50
|
onClick: _cache[2] || (_cache[2] = (...args) => _ctx.switchActive && _ctx.switchActive(...args))
|
|
51
51
|
},
|
|
@@ -54,16 +54,14 @@ function __render__(_ctx, _cache) {
|
|
|
54
54
|
"div",
|
|
55
55
|
{
|
|
56
56
|
style: _normalizeStyle(_ctx.styleComputed.track),
|
|
57
|
-
class: _normalizeClass(
|
|
58
|
-
_ctx.classes(_ctx.n("track"), [_ctx.modelValue === _ctx.activeValue, _ctx.n("track--active")], [_ctx.errorMessage, _ctx.n("track--error")])
|
|
59
|
-
)
|
|
57
|
+
class: _normalizeClass(_ctx.classes(_ctx.n("track"), [_ctx.isActive, _ctx.n("track--active")], [_ctx.errorMessage && !_ctx.variant, _ctx.n("track--error")]))
|
|
60
58
|
},
|
|
61
59
|
null,
|
|
62
60
|
6
|
|
63
61
|
/* CLASS, STYLE */
|
|
64
62
|
),
|
|
65
63
|
_withDirectives((_openBlock(), _createElementBlock("div", {
|
|
66
|
-
class: _normalizeClass(_ctx.classes(_ctx.n("ripple"), [_ctx.
|
|
64
|
+
class: _normalizeClass(_ctx.classes(_ctx.n("ripple"), [_ctx.isActive, _ctx.n("ripple--active")])),
|
|
67
65
|
style: _normalizeStyle(_ctx.styleComputed.ripple),
|
|
68
66
|
tabindex: _ctx.disabled || _ctx.formDisabled ? void 0 : "0",
|
|
69
67
|
onFocus: _cache[0] || (_cache[0] = ($event) => _ctx.isFocusing = true),
|
|
@@ -77,8 +75,9 @@ function __render__(_ctx, _cache) {
|
|
|
77
75
|
_ctx.classes(
|
|
78
76
|
_ctx.n("handle"),
|
|
79
77
|
_ctx.n("$-elevation--2"),
|
|
80
|
-
[_ctx.
|
|
81
|
-
[_ctx.errorMessage, _ctx.n("handle--error")]
|
|
78
|
+
[_ctx.isActive, _ctx.n("handle--active")],
|
|
79
|
+
[_ctx.errorMessage && !_ctx.variant, _ctx.n("handle--error")],
|
|
80
|
+
[_ctx.hovering, _ctx.n("handle--hover")]
|
|
82
81
|
)
|
|
83
82
|
)
|
|
84
83
|
},
|
|
@@ -136,31 +135,33 @@ const __sfc__ = defineComponent({
|
|
|
136
135
|
const { bindForm, form } = useForm();
|
|
137
136
|
const { errorMessage, validateWithTrigger: vt, validate: v, resetValidation } = useValidation();
|
|
138
137
|
const { hovering, handleHovering } = useHoverOverlay();
|
|
138
|
+
const isActive = computed(() => props2.modelValue === props2.activeValue);
|
|
139
139
|
const styleComputed = computed(() => {
|
|
140
|
-
const { size,
|
|
140
|
+
const { size, color, closeColor, loadingColor, variant } = props2;
|
|
141
141
|
return {
|
|
142
142
|
handle: {
|
|
143
143
|
width: multiplySizeUnit(size),
|
|
144
144
|
height: multiplySizeUnit(size),
|
|
145
|
-
backgroundColor:
|
|
145
|
+
backgroundColor: isActive.value ? color : closeColor,
|
|
146
146
|
color: loadingColor
|
|
147
147
|
},
|
|
148
148
|
ripple: {
|
|
149
|
-
left:
|
|
150
|
-
color:
|
|
149
|
+
left: isActive.value ? multiplySizeUnit(size, 0.5) : `-${multiplySizeUnit(size, variant ? 1 / 3 : 0.5)}`,
|
|
150
|
+
color: isActive.value ? color : closeColor || "currentColor",
|
|
151
151
|
width: multiplySizeUnit(size, 2),
|
|
152
152
|
height: multiplySizeUnit(size, 2)
|
|
153
153
|
},
|
|
154
154
|
track: {
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
width: multiplySizeUnit(size, variant ? 13 / 6 : 1.9),
|
|
156
|
+
height: multiplySizeUnit(size, variant ? 4 / 3 : 0.72),
|
|
157
157
|
borderRadius: multiplySizeUnit(size, 2 / 3),
|
|
158
|
-
filter:
|
|
159
|
-
backgroundColor:
|
|
158
|
+
filter: isActive.value || (errorMessage == null ? void 0 : errorMessage.value) ? void 0 : `brightness(${variant ? 1 : 0.6})`,
|
|
159
|
+
backgroundColor: isActive.value ? color : closeColor,
|
|
160
|
+
borderWidth: variant && !isActive.value ? multiplySizeUnit(size, 1 / 12) : void 0
|
|
160
161
|
},
|
|
161
162
|
switch: {
|
|
162
|
-
|
|
163
|
-
|
|
163
|
+
width: multiplySizeUnit(size, variant ? 13 / 6 : 2),
|
|
164
|
+
height: multiplySizeUnit(size, variant ? 4 / 3 : 1.2)
|
|
164
165
|
}
|
|
165
166
|
};
|
|
166
167
|
});
|
|
@@ -207,7 +208,6 @@ const __sfc__ = defineComponent({
|
|
|
207
208
|
disabled,
|
|
208
209
|
loading,
|
|
209
210
|
readonly,
|
|
210
|
-
modelValue,
|
|
211
211
|
activeValue,
|
|
212
212
|
inactiveValue,
|
|
213
213
|
lazyChange,
|
|
@@ -221,7 +221,7 @@ const __sfc__ = defineComponent({
|
|
|
221
221
|
if (loading || readonly || (form == null ? void 0 : form.readonly.value)) {
|
|
222
222
|
return;
|
|
223
223
|
}
|
|
224
|
-
const newValue =
|
|
224
|
+
const newValue = isActive.value ? inactiveValue : activeValue;
|
|
225
225
|
if (lazyChange) {
|
|
226
226
|
call(onBeforeChange, newValue, (value) => {
|
|
227
227
|
call(updateModelValue, value);
|
|
@@ -244,6 +244,7 @@ const __sfc__ = defineComponent({
|
|
|
244
244
|
resetValidation();
|
|
245
245
|
}
|
|
246
246
|
return {
|
|
247
|
+
isActive,
|
|
247
248
|
switchRef,
|
|
248
249
|
hovering,
|
|
249
250
|
isFocusing,
|
package/es/switch/props.mjs
CHANGED
package/es/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:
|
|
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: var(--color-on-primary); --switch-handle-color: var(--color-primary); --switch-handle-active-color: var(--color-on-primary); --switch-handle-active-background: var(--color-primary); --switch-handle-error-background: var(--color-danger); --switch-disabled-opacity: var(--opacity-disabled); --switch-variant-width: 52px; --switch-variant-height: 32px; --switch-variant-track-border-color: #888; --switch-variant-track-background: var(--color-surface-container-highest); --switch-variant-handle-width: 24px; --switch-variant-handle-height: 24px; --switch-variant-handle-color: var(--color-on-primary); --switch-variant-handle-active-color: var(--color-primary); --switch-variant-handle-background: #888; --switch-variant-handle-active-background: var(--color-on-primary);}.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; transition: filter 0.25s;}.var-switch--disabled { filter: opacity(var(--switch-disabled-opacity)); cursor: not-allowed;}.var-switch__track { background-color: var(--switch-track-background); transition: background-color 0.25s; filter: opacity(var(--switch-disabled-opacity)); 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; outline: none; 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; outline: none;}.var-switch__handle--active { background-color: var(--switch-handle-active-background); color: var(--switch-handle-active-color);}.var-switch__handle--error { background-color: var(--switch-handle-error-background) !important;}.var-switch--variant .var-switch__block { width: var(--switch-variant-width); height: var(--switch-variant-height);}.var-switch--variant .var-switch__block:active .var-switch__handle { transform: scale(1.16666667);}.var-switch--variant .var-switch__track { width: 100%; height: 100%; border-radius: calc(var(--switch-variant-height) / 2); background-color: var(--switch-variant-track-background); border: 2px solid var(--switch-variant-track-border-color); filter: none;}.var-switch--variant .var-switch__track--active { background-color: var(--switch-track-active-background); border: none;}.var-switch--variant .var-switch__ripple { left: -4px;}.var-switch--variant .var-switch__ripple--active { left: 16px;}.var-switch--variant .var-switch__handle { width: var(--switch-variant-handle-width); height: var(--switch-variant-handle-height); color: var(--switch-variant-handle-color); transform: scale(0.66666667); background-color: var(--switch-variant-handle-background); transition: transform 0.2s;}.var-switch--variant .var-switch__handle--active { color: var(--switch-variant-handle-active-color); background-color: var(--switch-variant-handle-active-background); transform: none;}.var-switch--variant .var-switch--disabled:active .var-switch__handle { transform: none;}.var-switch__loading { display: inline-block; width: 16px; height: 16px; animation: circle 1.8s linear infinite;}.var-switch__loading svg { display: block; width: 100%; height: 100%;}.var-switch__loading svg circle { animation: circular 1.5s ease-in-out infinite; stroke: currentColor; stroke-width: 3; stroke-linecap: round;}@keyframes circle { from { transform: rotate(0deg); } to { transform: rotate(360deg); }}@keyframes circular { 0% { stroke-dasharray: 1, 200; stroke-dashoffset: 0; } 50% { stroke-dasharray: 90, 150; stroke-dashoffset: -40; } 100% { stroke-dasharray: 90, 150; stroke-dashoffset: -120; }}
|
|
@@ -4,10 +4,21 @@ var stdin_default = {
|
|
|
4
4
|
"--switch-track-active-background": "var(--color-primary)",
|
|
5
5
|
"--switch-track-error-background": "var(--color-danger)",
|
|
6
6
|
"--switch-ripple-color": "var(--color-primary)",
|
|
7
|
-
"--switch-handle-color": "
|
|
7
|
+
"--switch-handle-color": "var(--color-on-primary)",
|
|
8
|
+
"--switch-handle-active-color": "var(--color-on-primary)",
|
|
8
9
|
"--switch-handle-active-background": "var(--color-primary)",
|
|
9
10
|
"--switch-handle-error-background": "var(--color-danger)",
|
|
10
|
-
"--switch-disabled-opacity": "var(--opacity-disabled)"
|
|
11
|
+
"--switch-disabled-opacity": "var(--opacity-disabled)",
|
|
12
|
+
"--switch-variant-width": "52px",
|
|
13
|
+
"--switch-variant-height": "32px",
|
|
14
|
+
"--switch-variant-track-background": "var(--color-surface-container-highest)",
|
|
15
|
+
"--switch-variant-handle-width": "24px",
|
|
16
|
+
"--switch-variant-handle-height": "24px",
|
|
17
|
+
"--switch-variant-track-border-color": "rgb(255, 255, 255, .7)",
|
|
18
|
+
"--switch-variant-handle-background": "rgb(255, 255, 255, .7)",
|
|
19
|
+
"--switch-variant-handle-color": "var(--color-primary)",
|
|
20
|
+
"--switch-variant-handle-active-color": "var(--color-primary)",
|
|
21
|
+
"--switch-variant-handle-active-background": "var(--color-on-primary)"
|
|
11
22
|
};
|
|
12
23
|
export {
|
|
13
24
|
stdin_default as default
|
package/es/themes/index.mjs
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
import dark from "./dark/index.mjs";
|
|
2
2
|
import md3Light from "./md3-light/index.mjs";
|
|
3
3
|
import md3Dark from "./md3-dark/index.mjs";
|
|
4
|
-
|
|
5
|
-
const { viewportWidth = 375, viewportUnit = "vmin", unitPrecision = 6 } = options;
|
|
6
|
-
return Object.entries(theme).reduce((target, [key, value]) => {
|
|
7
|
-
target[key] = value.includes("px") ? value.replace(
|
|
8
|
-
/(\d+(\.\d+)?)px/g,
|
|
9
|
-
(_, p1) => `${Number((p1 / viewportWidth * 100).toFixed(unitPrecision))}${viewportUnit}`
|
|
10
|
-
) : value;
|
|
11
|
-
return target;
|
|
12
|
-
}, {});
|
|
13
|
-
}
|
|
4
|
+
import { toViewport } from "./toViewport.mjs";
|
|
14
5
|
const Themes = { dark, md3Light, md3Dark, toViewport };
|
|
15
6
|
const _ThemesComponent = null;
|
|
16
7
|
var stdin_default = Themes;
|
|
@@ -4,10 +4,21 @@ var stdin_default = {
|
|
|
4
4
|
"--switch-track-active-background": "var(--color-primary)",
|
|
5
5
|
"--switch-track-error-background": "var(--color-danger)",
|
|
6
6
|
"--switch-ripple-color": "var(--color-primary)",
|
|
7
|
-
"--switch-handle-color": "var(--color-
|
|
7
|
+
"--switch-handle-color": "var(--color-primary)",
|
|
8
|
+
"--switch-handle-active-color": "var(--color-on-primary)",
|
|
8
9
|
"--switch-handle-active-background": "var(--color-primary)",
|
|
9
10
|
"--switch-handle-error-background": "var(--color-danger)",
|
|
10
|
-
"--switch-disabled-opacity": "var(--opacity-disabled)"
|
|
11
|
+
"--switch-disabled-opacity": "var(--opacity-disabled)",
|
|
12
|
+
"--switch-variant-width": "52px",
|
|
13
|
+
"--switch-variant-height": "32px",
|
|
14
|
+
"--switch-variant-track-background": "var(--color-surface-container-highest)",
|
|
15
|
+
"--switch-variant-handle-width": "24px",
|
|
16
|
+
"--switch-variant-handle-height": "24px",
|
|
17
|
+
"--switch-variant-track-border-color": "#938F99",
|
|
18
|
+
"--switch-variant-handle-color": "var(--color-on-primary)",
|
|
19
|
+
"--switch-variant-handle-active-color": "var(--color-primary)",
|
|
20
|
+
"--switch-variant-handle-background": "#938F99",
|
|
21
|
+
"--switch-variant-handle-active-background": "var(--color-on-primary)"
|
|
11
22
|
};
|
|
12
23
|
export {
|
|
13
24
|
stdin_default as default
|
|
@@ -4,10 +4,21 @@ var stdin_default = {
|
|
|
4
4
|
"--switch-track-active-background": "var(--color-primary)",
|
|
5
5
|
"--switch-track-error-background": "var(--color-danger)",
|
|
6
6
|
"--switch-ripple-color": "var(--color-primary)",
|
|
7
|
-
"--switch-handle-color": "
|
|
7
|
+
"--switch-handle-color": "var(--color-primary)",
|
|
8
|
+
"--switch-handle-active-color": "var(--color-on-primary)",
|
|
8
9
|
"--switch-handle-active-background": "var(--color-primary)",
|
|
9
10
|
"--switch-handle-error-background": "var(--color-danger)",
|
|
10
|
-
"--switch-disabled-opacity": "var(--opacity-disabled)"
|
|
11
|
+
"--switch-disabled-opacity": "var(--opacity-disabled)",
|
|
12
|
+
"--switch-variant-width": "52px",
|
|
13
|
+
"--switch-variant-height": "32px",
|
|
14
|
+
"--switch-variant-track-background": "var(--color-surface-container-highest)",
|
|
15
|
+
"--switch-variant-handle-width": "24px",
|
|
16
|
+
"--switch-variant-handle-height": "24px",
|
|
17
|
+
"--switch-variant-track-border-color": "#79747E",
|
|
18
|
+
"--switch-variant-handle-color": "var(--color-on-primary)",
|
|
19
|
+
"--switch-variant-handle-active-color": "var(--color-primary)",
|
|
20
|
+
"--switch-variant-handle-background": "#79747E",
|
|
21
|
+
"--switch-variant-handle-active-background": "var(--color-on-primary)"
|
|
11
22
|
};
|
|
12
23
|
export {
|
|
13
24
|
stdin_default as default
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
function toViewport(theme, options = {}) {
|
|
2
|
+
const { viewportWidth = 375, viewportUnit = "vmin", unitPrecision = 6 } = options;
|
|
3
|
+
return Object.entries(theme).reduce((target, [key, value]) => {
|
|
4
|
+
target[key] = value.includes("px") ? value.replace(
|
|
5
|
+
/(\d+(\.\d+)?)px/g,
|
|
6
|
+
(_, p1) => `${Number((p1 / viewportWidth * 100).toFixed(unitPrecision))}${viewportUnit}`
|
|
7
|
+
) : value;
|
|
8
|
+
return target;
|
|
9
|
+
}, {});
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
toViewport
|
|
13
|
+
};
|
package/es/time-picker/clock.mjs
CHANGED
|
@@ -113,12 +113,10 @@ const __sfc__ = defineComponent({
|
|
|
113
113
|
required: true
|
|
114
114
|
},
|
|
115
115
|
useSeconds: {
|
|
116
|
-
type: Boolean
|
|
117
|
-
default: false
|
|
116
|
+
type: Boolean
|
|
118
117
|
},
|
|
119
118
|
preventNextUpdate: {
|
|
120
|
-
type: Boolean
|
|
121
|
-
default: false
|
|
119
|
+
type: Boolean
|
|
122
120
|
},
|
|
123
121
|
type: {
|
|
124
122
|
type: String,
|
|
@@ -310,7 +308,7 @@ const __sfc__ = defineComponent({
|
|
|
310
308
|
}
|
|
311
309
|
disable24HourIndex.value = disableHour.value.map((hour) => hours24.findIndex((hour24) => hour === hour24)).filter((hour) => hour >= 0);
|
|
312
310
|
},
|
|
313
|
-
{ immediate: true }
|
|
311
|
+
{ immediate: true, deep: true }
|
|
314
312
|
);
|
|
315
313
|
return {
|
|
316
314
|
n,
|