@varlet/ui 2.17.0 → 2.18.0-alpha.1697472019506
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/action-sheet/actionSheet.css +1 -1
- package/es/dialog/dialog.css +1 -1
- package/es/drag/Drag.mjs +2 -2
- package/es/form/Form.mjs +3 -3
- package/es/image-preview/ImagePreview.mjs +2 -2
- package/es/index-bar/indexBar.css +1 -1
- package/es/index.bundle.mjs +13 -1
- package/es/index.mjs +11 -1
- package/es/input/Input.mjs +2 -2
- package/es/menu/style/index.mjs +1 -1
- package/es/menu-option/MenuOption.mjs +122 -0
- package/es/menu-option/MenuOptionSfc.css +0 -0
- package/es/menu-option/index.mjs +11 -0
- package/es/menu-option/menuOption.css +1 -0
- package/es/menu-option/props.mjs +8 -0
- package/es/menu-option/provide.mjs +19 -0
- package/es/menu-option/style/index.mjs +5 -0
- package/es/menu-select/MenuSelect.mjs +110 -0
- package/es/menu-select/MenuSelectSfc.css +0 -0
- package/es/menu-select/index.mjs +9 -0
- package/es/menu-select/menuSelect.css +1 -0
- package/es/menu-select/props.mjs +58 -0
- package/es/menu-select/provide.mjs +16 -0
- package/es/menu-select/style/index.mjs +5 -0
- package/es/option/Option.mjs +28 -28
- package/es/option/option.css +1 -1
- package/es/option/props.mjs +2 -1
- package/es/popup/popup.css +1 -1
- package/es/pull-refresh/PullRefresh.mjs +2 -2
- package/es/ripple/index.mjs +2 -0
- package/es/select/Select.mjs +14 -47
- package/es/select/useSelectController.mjs +67 -0
- package/es/slider/Slider.mjs +2 -2
- package/es/style.css +1 -1
- package/es/style.mjs +2 -0
- package/es/swipe/Swipe.mjs +13 -13
- package/es/themes/dark/index.mjs +3 -2
- package/es/themes/dark/menuOption.mjs +6 -0
- package/es/themes/dark/option.mjs +1 -1
- package/es/time-picker/TimePicker.mjs +2 -2
- package/es/uploader/Uploader.mjs +8 -4
- package/es/uploader/props.mjs +2 -0
- package/es/utils/shared.mjs +4 -4
- package/es/varlet.esm.js +5429 -5139
- package/highlight/web-types.en-US.json +359 -90
- package/highlight/web-types.zh-CN.json +271 -2
- package/lib/style.css +1 -1
- package/lib/varlet.cjs.js +2101 -1744
- package/package.json +7 -7
- package/types/index.d.ts +4 -0
- package/types/menuOption.d.ts +20 -0
- package/types/menuSelect.d.ts +70 -0
- package/types/option.d.ts +1 -0
- package/types/uploader.d.ts +2 -0
- package/umd/varlet.js +6 -6
package/es/option/Option.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { useSelect } from "./provide.mjs";
|
|
|
7
7
|
import { createNamespace } from "../utils/components.mjs";
|
|
8
8
|
import { props } from "./props.mjs";
|
|
9
9
|
const { name, n, classes } = createNamespace("option");
|
|
10
|
-
import { normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle, createElementVNode as _createElementVNode, resolveComponent as _resolveComponent, withModifiers as _withModifiers, openBlock as _openBlock, createBlock as _createBlock, createCommentVNode as _createCommentVNode, renderSlot as _renderSlot, toDisplayString as _toDisplayString,
|
|
10
|
+
import { normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle, createElementVNode as _createElementVNode, resolveComponent as _resolveComponent, withModifiers as _withModifiers, openBlock as _openBlock, createBlock as _createBlock, createCommentVNode as _createCommentVNode, renderSlot as _renderSlot, toDisplayString as _toDisplayString, createVNode as _createVNode, resolveDirective as _resolveDirective, createElementBlock as _createElementBlock, withDirectives as _withDirectives } from "vue";
|
|
11
11
|
function __render__(_ctx, _cache) {
|
|
12
12
|
const _component_var_checkbox = _resolveComponent("var-checkbox");
|
|
13
13
|
const _component_var_hover_overlay = _resolveComponent("var-hover-overlay");
|
|
@@ -16,7 +16,7 @@ function __render__(_ctx, _cache) {
|
|
|
16
16
|
return _withDirectives((_openBlock(), _createElementBlock(
|
|
17
17
|
"div",
|
|
18
18
|
{
|
|
19
|
-
class: _normalizeClass(_ctx.classes(_ctx.n(), _ctx.n("$--box"), [_ctx.optionSelected, _ctx.n("--selected-color")])),
|
|
19
|
+
class: _normalizeClass(_ctx.classes(_ctx.n(), _ctx.n("$--box"), [_ctx.optionSelected, _ctx.n("--selected-color")], [_ctx.disabled, _ctx.n("--disabled")])),
|
|
20
20
|
style: _normalizeStyle({
|
|
21
21
|
color: _ctx.optionSelected ? _ctx.focusColor : void 0
|
|
22
22
|
}),
|
|
@@ -38,36 +38,33 @@ function __render__(_ctx, _cache) {
|
|
|
38
38
|
_ctx.multiple ? (_openBlock(), _createBlock(_component_var_checkbox, {
|
|
39
39
|
key: 0,
|
|
40
40
|
ref: "checkbox",
|
|
41
|
-
"checked-color": _ctx.focusColor,
|
|
42
41
|
modelValue: _ctx.optionSelected,
|
|
43
42
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.optionSelected = $event),
|
|
43
|
+
"checked-color": _ctx.focusColor,
|
|
44
|
+
disabled: _ctx.disabled,
|
|
44
45
|
onClick: _cache[1] || (_cache[1] = _withModifiers(() => {
|
|
45
46
|
}, ["stop"])),
|
|
46
47
|
onChange: _ctx.handleSelect
|
|
47
|
-
}, null, 8, ["checked-color", "
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
2
|
|
63
|
-
/* CLASS */
|
|
64
|
-
),
|
|
65
|
-
_createVNode(_component_var_hover_overlay, { hovering: _ctx.hovering }, null, 8, ["hovering"])
|
|
48
|
+
}, null, 8, ["modelValue", "checked-color", "disabled", "onChange"])) : _createCommentVNode("v-if", true),
|
|
49
|
+
_renderSlot(_ctx.$slots, "default", {}, () => [
|
|
50
|
+
_createElementVNode(
|
|
51
|
+
"div",
|
|
52
|
+
{
|
|
53
|
+
class: _normalizeClass(_ctx.classes(_ctx.n("text"), _ctx.n("$--ellipsis")))
|
|
54
|
+
},
|
|
55
|
+
_toDisplayString(_ctx.label),
|
|
56
|
+
3
|
|
57
|
+
/* TEXT, CLASS */
|
|
58
|
+
)
|
|
59
|
+
]),
|
|
60
|
+
_createVNode(_component_var_hover_overlay, {
|
|
61
|
+
hovering: _ctx.hovering && !_ctx.disabled
|
|
62
|
+
}, null, 8, ["hovering"])
|
|
66
63
|
],
|
|
67
64
|
6
|
|
68
65
|
/* CLASS, STYLE */
|
|
69
66
|
)), [
|
|
70
|
-
[_directive_ripple],
|
|
67
|
+
[_directive_ripple, { disabled: _ctx.disabled }],
|
|
71
68
|
[_directive_hover, _ctx.handleHovering, "desktop"]
|
|
72
69
|
]);
|
|
73
70
|
}
|
|
@@ -96,24 +93,27 @@ const __sfc__ = defineComponent({
|
|
|
96
93
|
watch([() => props2.label, () => props2.value], computeLabel);
|
|
97
94
|
bindSelect(optionProvider);
|
|
98
95
|
function handleClick() {
|
|
96
|
+
if (props2.disabled) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
handleSelect();
|
|
100
|
+
}
|
|
101
|
+
function handleSelect() {
|
|
99
102
|
if (multiple.value) {
|
|
100
103
|
optionSelected.value = !optionSelected.value;
|
|
101
104
|
}
|
|
102
105
|
onSelect(optionProvider);
|
|
103
106
|
}
|
|
104
|
-
function handleSelect() {
|
|
105
|
-
return onSelect(optionProvider);
|
|
106
|
-
}
|
|
107
107
|
function sync(checked) {
|
|
108
108
|
optionSelected.value = checked;
|
|
109
109
|
}
|
|
110
110
|
return {
|
|
111
|
-
n,
|
|
112
|
-
classes,
|
|
113
111
|
optionSelected,
|
|
114
112
|
multiple,
|
|
115
113
|
focusColor,
|
|
116
114
|
hovering,
|
|
115
|
+
n,
|
|
116
|
+
classes,
|
|
117
117
|
handleHovering,
|
|
118
118
|
handleClick,
|
|
119
119
|
handleSelect
|
package/es/option/option.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
:root { --option-height: 38px; --option-padding: 0 12px; --option-font-size: 16px; --option-selected-background: var(--field-decorator-focus-color); --
|
|
1
|
+
:root { --option-height: 38px; --option-padding: 0 12px; --option-font-size: 16px; --option-selected-background: var(--field-decorator-focus-color); --option-text-color: #555; --option-disabled-color: var(--color-text-disabled);}.var-option { position: relative; display: flex; align-items: center; height: var(--option-height); padding: var(--option-padding); cursor: pointer; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); color: var(--option-text-color);}.var-option__cover { position: absolute; top: 0; left: 0; right: 0; bottom: 0; opacity: 0.2; background: transparent;}.var-option__text { display: flex; align-items: center; font-size: var(--option-font-size);}.var-option--selected-background { background: var(--option-selected-background);}.var-option--selected-color { color: var(--option-selected-background);}.var-option--disabled { color: var(--option-disabled-color); cursor: not-allowed;}
|
package/es/option/props.mjs
CHANGED
package/es/popup/popup.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
:root { --popup-content-background-color: #fff; --popup-overlay-background-color: rgba(0, 0, 0, 0.6);}.var-fade-enter-from,.var-fade-leave-to { opacity: 0;}.var-fade-enter-active,.var-fade-leave-active { transition: opacity 0.25s;}.var-pop-center-enter-from,.var-pop-center-leave-to { transform: scale(0.3);}.var-pop-center-enter-active,.var-pop-center-leave-active { transition: all 0.25s;}.var-pop-bottom-enter-from,.var-pop-bottom-leave-to { transform: translateY(100%);}.var-pop-bottom-enter-active,.var-pop-bottom-leave-active { transition: all 0.25s;}.var-pop-top-enter-from,.var-pop-top-leave-to { transform: translateY(-100%);}.var-pop-top-enter-active,.var-pop-top-leave-active { transition: all 0.25s;}.var-pop-left-enter-from,.var-pop-left-leave-to { transform: translateX(-100%);}.var-pop-left-enter-active,.var-pop-left-leave-active { transition: all 0.25s;}.var-pop-right-enter-from,.var-pop-right-leave-to { transform: translateX(100%);}.var-pop-right-enter-active,.var-pop-right-leave-active { transition: all 0.25s;}.var-popup { display: flex; justify-content: center; align-items: center; position: fixed; top: 0; right: 0; bottom: 0; left: 0; overflow: auto;}.var-popup__overlay { display: flex; justify-content: center; align-items: center; position: fixed; top: 0; right: 0; bottom: 0; left: 0; background-color: var(--popup-overlay-background-color); transition: all 0.25s;}.var-popup__content { overflow: auto; transition: all 0.25s;}.var-popup--content-background-color { background-color: var(--popup-content-background-color);}.var-popup--center { position: relative;}.var-popup--bottom {
|
|
1
|
+
:root { --popup-content-background-color: #fff; --popup-overlay-background-color: rgba(0, 0, 0, 0.6);}.var-fade-enter-from,.var-fade-leave-to { opacity: 0;}.var-fade-enter-active,.var-fade-leave-active { transition: opacity 0.25s;}.var-pop-center-enter-from,.var-pop-center-leave-to { transform: scale(0.3);}.var-pop-center-enter-active,.var-pop-center-leave-active { transition: all 0.25s;}.var-pop-bottom-enter-from,.var-pop-bottom-leave-to { transform: translateY(100%);}.var-pop-bottom-enter-active,.var-pop-bottom-leave-active { transition: all 0.25s;}.var-pop-top-enter-from,.var-pop-top-leave-to { transform: translateY(-100%);}.var-pop-top-enter-active,.var-pop-top-leave-active { transition: all 0.25s;}.var-pop-left-enter-from,.var-pop-left-leave-to { transform: translateX(-100%);}.var-pop-left-enter-active,.var-pop-left-leave-active { transition: all 0.25s;}.var-pop-right-enter-from,.var-pop-right-leave-to { transform: translateX(100%);}.var-pop-right-enter-active,.var-pop-right-leave-active { transition: all 0.25s;}.var-popup { display: flex; justify-content: center; align-items: center; position: fixed; top: 0; right: 0; bottom: 0; left: 0; overflow: auto;}.var-popup__overlay { display: flex; justify-content: center; align-items: center; position: fixed; top: 0; right: 0; bottom: 0; left: 0; background-color: var(--popup-overlay-background-color); transition: all 0.25s;}.var-popup__content { overflow: auto; transition: all 0.25s;}.var-popup--content-background-color { background-color: var(--popup-content-background-color);}.var-popup--center { position: relative;}.var-popup--bottom { width: 100%; position: absolute; left: 0; bottom: 0;}.var-popup--top { width: 100%; position: absolute; left: 0; top: 0;}.var-popup--left { height: 100%; position: absolute; left: 0; top: 0;}.var-popup--right { height: 100%; position: absolute; right: 0; top: 0;}.var-popup--safe-area { padding-bottom: constant(safe-area-inset-bottom); padding-bottom: env(safe-area-inset-bottom);}.var-popup--safe-area-top { padding-top: constant(safe-area-inset-top); padding-top: env(safe-area-inset-top);}
|
|
@@ -22,7 +22,7 @@ import VarIcon from "../icon/index.mjs";
|
|
|
22
22
|
import { defineComponent, ref, computed, watch, nextTick } from "vue";
|
|
23
23
|
import { getParentScroller, getScrollTop, getTarget } from "../utils/elements.mjs";
|
|
24
24
|
import { props } from "./props.mjs";
|
|
25
|
-
import { isNumber, isString, toNumber, getRect } from "@varlet/shared";
|
|
25
|
+
import { isNumber, isString, toNumber, getRect, preventDefault } from "@varlet/shared";
|
|
26
26
|
import { call, createNamespace } from "../utils/components.mjs";
|
|
27
27
|
import { useEventListener, onSmartMounted } from "@varlet/use";
|
|
28
28
|
const { name, n, classes } = createNamespace("pull-refresh");
|
|
@@ -147,7 +147,7 @@ const __sfc__ = defineComponent({
|
|
|
147
147
|
const touch = event.touches[0];
|
|
148
148
|
deltaY = touch.clientY - startY;
|
|
149
149
|
if (isReachTop && deltaY >= 0) {
|
|
150
|
-
|
|
150
|
+
preventDefault(event);
|
|
151
151
|
}
|
|
152
152
|
if (refreshStatus.value !== "pulling") {
|
|
153
153
|
refreshStatus.value = "pulling";
|
package/es/ripple/index.mjs
CHANGED
|
@@ -110,6 +110,7 @@ function mounted(el, binding) {
|
|
|
110
110
|
el.addEventListener("dragstart", removeRipple, { passive: true });
|
|
111
111
|
document.addEventListener("touchend", el._ripple.removeRipple, { passive: true });
|
|
112
112
|
document.addEventListener("touchcancel", el._ripple.removeRipple, { passive: true });
|
|
113
|
+
document.addEventListener("dragend", el._ripple.removeRipple, { passive: true });
|
|
113
114
|
}
|
|
114
115
|
function unmounted(el) {
|
|
115
116
|
el.removeEventListener("touchstart", createRipple);
|
|
@@ -117,6 +118,7 @@ function unmounted(el) {
|
|
|
117
118
|
el.removeEventListener("dragstart", removeRipple);
|
|
118
119
|
document.removeEventListener("touchend", el._ripple.removeRipple);
|
|
119
120
|
document.removeEventListener("touchcancel", el._ripple.removeRipple);
|
|
121
|
+
document.removeEventListener("dragend", el._ripple.removeRipple);
|
|
120
122
|
}
|
|
121
123
|
function updated(el, binding) {
|
|
122
124
|
var _a, _b, _c, _d, _e, _f;
|
package/es/select/Select.mjs
CHANGED
|
@@ -11,6 +11,7 @@ import { useOptions } from "./provide.mjs";
|
|
|
11
11
|
import { useForm } from "../form/provide.mjs";
|
|
12
12
|
import { toPxNum } from "../utils/elements.mjs";
|
|
13
13
|
import { error } from "../utils/logger.mjs";
|
|
14
|
+
import { useSelectController } from "./useSelectController.mjs";
|
|
14
15
|
const { name, n, classes } = createNamespace("select");
|
|
15
16
|
import { renderSlot as _renderSlot, renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, resolveComponent as _resolveComponent, withModifiers as _withModifiers, normalizeClass as _normalizeClass, withCtx as _withCtx, createBlock as _createBlock, createCommentVNode as _createCommentVNode, createElementVNode as _createElementVNode, normalizeStyle as _normalizeStyle, createVNode as _createVNode, normalizeProps as _normalizeProps, guardReactiveProps as _guardReactiveProps, createSlots as _createSlots, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
|
|
16
17
|
const _withScopeId = (n2) => (_pushScopeId(""), n2 = n2(), _popScopeId(), n2);
|
|
@@ -237,13 +238,17 @@ const __sfc__ = defineComponent({
|
|
|
237
238
|
const showMenu = ref(false);
|
|
238
239
|
const multiple = computed(() => props2.multiple);
|
|
239
240
|
const focusColor = computed(() => props2.focusColor);
|
|
240
|
-
const label = ref("");
|
|
241
|
-
const labels = ref([]);
|
|
242
241
|
const isEmptyModelValue = computed(() => isEmpty(props2.modelValue));
|
|
243
242
|
const cursor = computed(() => props2.disabled || props2.readonly ? "" : "pointer");
|
|
244
243
|
const offsetY = ref(0);
|
|
245
244
|
const { bindForm, form } = useForm();
|
|
246
245
|
const { length, options, bindOptions } = useOptions();
|
|
246
|
+
const { label, labels, computeLabel, getSelectedValue } = useSelectController({
|
|
247
|
+
modelValue: () => props2.modelValue,
|
|
248
|
+
multiple: () => props2.multiple,
|
|
249
|
+
optionProviders: () => options,
|
|
250
|
+
optionProvidersLength: () => length.value
|
|
251
|
+
});
|
|
247
252
|
const {
|
|
248
253
|
errorMessage,
|
|
249
254
|
validateWithTrigger: vt,
|
|
@@ -285,43 +290,14 @@ const __sfc__ = defineComponent({
|
|
|
285
290
|
}
|
|
286
291
|
}
|
|
287
292
|
);
|
|
288
|
-
watch(() => props2.modelValue, syncOptions, { deep: true });
|
|
289
|
-
watch(() => length.value, syncOptions);
|
|
290
293
|
bindOptions(selectProvider);
|
|
291
294
|
call(bindForm, selectProvider);
|
|
292
|
-
function computeLabel() {
|
|
293
|
-
const { multiple: multiple2, modelValue } = props2;
|
|
294
|
-
if (multiple2) {
|
|
295
|
-
const rawModelValue = modelValue;
|
|
296
|
-
labels.value = rawModelValue.map(findLabel);
|
|
297
|
-
}
|
|
298
|
-
if (!multiple2 && !isEmpty(modelValue)) {
|
|
299
|
-
label.value = findLabel(modelValue);
|
|
300
|
-
}
|
|
301
|
-
if (!multiple2 && isEmpty(modelValue)) {
|
|
302
|
-
label.value = "";
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
295
|
function validateWithTrigger(trigger) {
|
|
306
296
|
nextTick(() => {
|
|
307
297
|
const { validateTrigger, rules, modelValue } = props2;
|
|
308
298
|
vt(validateTrigger, trigger, rules, modelValue);
|
|
309
299
|
});
|
|
310
300
|
}
|
|
311
|
-
function findValueOrLabel({ value, label: label2 }) {
|
|
312
|
-
if (value.value != null) {
|
|
313
|
-
return value.value;
|
|
314
|
-
}
|
|
315
|
-
return label2.value;
|
|
316
|
-
}
|
|
317
|
-
function findLabel(modelValue) {
|
|
318
|
-
var _a;
|
|
319
|
-
let option = options.find(({ value }) => value.value === modelValue);
|
|
320
|
-
if (!option) {
|
|
321
|
-
option = options.find(({ label: label2 }) => label2.value === modelValue);
|
|
322
|
-
}
|
|
323
|
-
return (_a = option == null ? void 0 : option.label.value) != null ? _a : "";
|
|
324
|
-
}
|
|
325
301
|
function handleFocus() {
|
|
326
302
|
const { disabled, readonly, onFocus } = props2;
|
|
327
303
|
if ((form == null ? void 0 : form.disabled.value) || (form == null ? void 0 : form.readonly.value) || disabled || readonly) {
|
|
@@ -346,7 +322,7 @@ const __sfc__ = defineComponent({
|
|
|
346
322
|
if ((form == null ? void 0 : form.disabled.value) || (form == null ? void 0 : form.readonly.value) || disabled || readonly) {
|
|
347
323
|
return;
|
|
348
324
|
}
|
|
349
|
-
const selectedValue =
|
|
325
|
+
const selectedValue = getSelectedValue(option);
|
|
350
326
|
call(props2["onUpdate:modelValue"], selectedValue);
|
|
351
327
|
call(onChange, selectedValue);
|
|
352
328
|
validateWithTrigger("onChange");
|
|
@@ -377,26 +353,17 @@ const __sfc__ = defineComponent({
|
|
|
377
353
|
if ((form == null ? void 0 : form.disabled.value) || (form == null ? void 0 : form.readonly.value) || disabled || readonly) {
|
|
378
354
|
return;
|
|
379
355
|
}
|
|
380
|
-
const rawModelValue = modelValue;
|
|
381
356
|
const option = options.find(({ label: label2 }) => label2.value === text);
|
|
382
|
-
const currentModelValue =
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
357
|
+
const currentModelValue = modelValue.filter(
|
|
358
|
+
(value) => {
|
|
359
|
+
var _a;
|
|
360
|
+
return value !== ((_a = option.value.value) != null ? _a : option.label.value);
|
|
361
|
+
}
|
|
362
|
+
);
|
|
386
363
|
call(props2["onUpdate:modelValue"], currentModelValue);
|
|
387
364
|
call(onClose, currentModelValue);
|
|
388
365
|
validateWithTrigger("onClose");
|
|
389
366
|
}
|
|
390
|
-
function syncOptions() {
|
|
391
|
-
const { multiple: multiple2, modelValue } = props2;
|
|
392
|
-
if (multiple2) {
|
|
393
|
-
const rawModelValue = modelValue;
|
|
394
|
-
options.forEach((option) => option.sync(rawModelValue.includes(findValueOrLabel(option))));
|
|
395
|
-
} else {
|
|
396
|
-
options.forEach((option) => option.sync(modelValue === findValueOrLabel(option)));
|
|
397
|
-
}
|
|
398
|
-
computeLabel();
|
|
399
|
-
}
|
|
400
367
|
function focus() {
|
|
401
368
|
offsetY.value = toPxNum(props2.offsetY);
|
|
402
369
|
isFocus.value = true;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ref, watch } from "vue";
|
|
2
|
+
import { isEmpty } from "@varlet/shared";
|
|
3
|
+
function useSelectController(options) {
|
|
4
|
+
const {
|
|
5
|
+
multiple: multipleGetter,
|
|
6
|
+
modelValue: modelValueGetter,
|
|
7
|
+
optionProviders: optionProvidersGetter,
|
|
8
|
+
optionProvidersLength: optionProvidersLengthGetter
|
|
9
|
+
} = options;
|
|
10
|
+
const label = ref("");
|
|
11
|
+
const labels = ref([]);
|
|
12
|
+
watch(modelValueGetter, syncOptions, { deep: true });
|
|
13
|
+
watch(optionProvidersLengthGetter, syncOptions);
|
|
14
|
+
function computeLabel() {
|
|
15
|
+
const multiple = multipleGetter();
|
|
16
|
+
const modelValue = modelValueGetter();
|
|
17
|
+
if (multiple) {
|
|
18
|
+
labels.value = modelValue.map(findLabel);
|
|
19
|
+
}
|
|
20
|
+
if (!multiple && !isEmpty(modelValue)) {
|
|
21
|
+
label.value = findLabel(modelValue);
|
|
22
|
+
}
|
|
23
|
+
if (!multiple && isEmpty(modelValue)) {
|
|
24
|
+
label.value = "";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function findLabel(targetValue) {
|
|
28
|
+
var _a;
|
|
29
|
+
const options2 = optionProvidersGetter();
|
|
30
|
+
let option = options2.find(({ value }) => value.value === targetValue);
|
|
31
|
+
if (!option) {
|
|
32
|
+
option = options2.find(({ label: label2 }) => label2.value === targetValue);
|
|
33
|
+
}
|
|
34
|
+
return (_a = option == null ? void 0 : option.label.value) != null ? _a : "";
|
|
35
|
+
}
|
|
36
|
+
function findValueOrLabel({ value, label: label2 }) {
|
|
37
|
+
if (value.value != null) {
|
|
38
|
+
return value.value;
|
|
39
|
+
}
|
|
40
|
+
return label2.value;
|
|
41
|
+
}
|
|
42
|
+
function getSelectedValue(option) {
|
|
43
|
+
const multiple = multipleGetter();
|
|
44
|
+
const options2 = optionProvidersGetter();
|
|
45
|
+
return multiple ? options2.filter(({ selected }) => selected.value).map(findValueOrLabel) : findValueOrLabel(option);
|
|
46
|
+
}
|
|
47
|
+
function syncOptions() {
|
|
48
|
+
const multiple = multipleGetter();
|
|
49
|
+
const modelValue = modelValueGetter();
|
|
50
|
+
const options2 = optionProvidersGetter();
|
|
51
|
+
if (multiple) {
|
|
52
|
+
options2.forEach((option) => option.sync(modelValue.includes(findValueOrLabel(option))));
|
|
53
|
+
} else {
|
|
54
|
+
options2.forEach((option) => option.sync(modelValue === findValueOrLabel(option)));
|
|
55
|
+
}
|
|
56
|
+
computeLabel();
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
label,
|
|
60
|
+
labels,
|
|
61
|
+
computeLabel,
|
|
62
|
+
getSelectedValue
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
useSelectController
|
|
67
|
+
};
|
package/es/slider/Slider.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { useValidation, createNamespace, call } from "../utils/components.mjs";
|
|
|
6
6
|
import { useForm } from "../form/provide.mjs";
|
|
7
7
|
import { getLeft, multiplySizeUnit } from "../utils/elements.mjs";
|
|
8
8
|
import { warn } from "../utils/logger.mjs";
|
|
9
|
-
import { isArray, isNumber, toNumber, getRect } from "@varlet/shared";
|
|
9
|
+
import { isArray, isNumber, toNumber, getRect, preventDefault } from "@varlet/shared";
|
|
10
10
|
import { props, Thumbs } from "./props.mjs";
|
|
11
11
|
import { onSmartMounted } from "@varlet/use";
|
|
12
12
|
const { name, n, classes } = createNamespace("slider");
|
|
@@ -367,7 +367,7 @@ const __sfc__ = defineComponent({
|
|
|
367
367
|
thumbsProps[type].startPosition = isVertical.value ? clientY : clientX;
|
|
368
368
|
}
|
|
369
369
|
function move(event) {
|
|
370
|
-
|
|
370
|
+
preventDefault(event);
|
|
371
371
|
if (isDisabled.value || isReadonly.value || !isScroll.value)
|
|
372
372
|
return;
|
|
373
373
|
const { startPosition, currentOffset } = thumbsProps[activeThumb];
|