@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.
@@ -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.modelValue === _ctx.activeValue, _ctx.n("ripple--active")])),
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.modelValue === _ctx.activeValue, _ctx.n("handle--active")],
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, modelValue, color, closeColor, loadingColor, activeValue } = props2;
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: modelValue === activeValue ? color : closeColor,
145
+ backgroundColor: isActive.value ? color : closeColor,
146
146
  color: loadingColor
147
147
  },
148
148
  ripple: {
149
- left: modelValue === activeValue ? multiplySizeUnit(size, 0.5) : `-${multiplySizeUnit(size, 0.5)}`,
150
- color: modelValue === activeValue ? color : closeColor || "currentColor",
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
- height: multiplySizeUnit(size, 0.72),
156
- width: multiplySizeUnit(size, 1.9),
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: modelValue === activeValue || (errorMessage == null ? void 0 : errorMessage.value) ? void 0 : "brightness(.6)",
159
- backgroundColor: modelValue === activeValue ? color : closeColor
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
- height: multiplySizeUnit(size, 1.2),
163
- width: multiplySizeUnit(size, 2)
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 = modelValue === activeValue ? inactiveValue : activeValue;
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,
@@ -17,6 +17,7 @@ const props = {
17
17
  loadingColor: String,
18
18
  closeColor: String,
19
19
  size: [String, Number],
20
+ variant: Boolean,
20
21
  rules: Array,
21
22
  ripple: {
22
23
  type: Boolean,
@@ -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); --switch-disabled-opacity: var(--opacity-disabled);}.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;}.var-switch__handle--active { background-color: var(--switch-handle-active-background);}.var-switch__handle--error { background-color: var(--switch-handle-error-background) !important;}.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; }}
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": "#fff",
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
@@ -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
- function toViewport(theme, options = {}) {
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-on-primary)",
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": "#fff",
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,3 @@
1
+ import { Themes } from '../../types'
2
+
3
+ declare const toViewport: Themes['toViewport']
@@ -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
+ };
@@ -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,