@varlet/ui 3.0.7 → 3.1.0-alpha.1709537939980
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/ActionItem.mjs +79 -0
- package/es/action-sheet/ActionItemSfc.css +0 -0
- package/es/action-sheet/ActionSheet.mjs +29 -56
- package/es/action-sheet/actionSheet.css +1 -1
- package/es/action-sheet/props.mjs +3 -1
- package/es/action-sheet/style/index.mjs +1 -0
- package/es/button/Button.mjs +6 -6
- package/es/checkbox/Checkbox.mjs +83 -50
- package/es/checkbox/checkbox.css +1 -1
- package/es/context/stack.mjs +46 -0
- package/es/dialog/Dialog.mjs +12 -2
- package/es/dialog/props.mjs +4 -1
- package/es/field-decorator/FieldDecorator.mjs +10 -7
- package/es/field-decorator/props.mjs +1 -1
- package/es/hover-overlay/HoverOverlay.mjs +4 -2
- package/es/image-preview/ImagePreview.mjs +12 -16
- package/es/image-preview/props.mjs +4 -1
- package/es/index.bundle.mjs +1 -1
- package/es/index.mjs +1 -1
- package/es/input/Input.mjs +8 -8
- package/es/link/Link.mjs +10 -4
- package/es/link/link.css +1 -1
- package/es/menu/menu.css +1 -1
- package/es/menu/props.mjs +6 -1
- package/es/menu/usePopover.mjs +12 -2
- package/es/menu-option/MenuOption.mjs +72 -43
- package/es/menu-option/menuOption.css +1 -1
- package/es/menu-select/MenuSelect.mjs +28 -3
- package/es/option/Option.mjs +77 -48
- package/es/option/option.css +1 -1
- package/es/overlay/Overlay.mjs +19 -2
- package/es/overlay/props.mjs +7 -1
- package/es/paper/paper.css +1 -1
- package/es/picker/Picker.mjs +2 -0
- package/es/picker/props.mjs +4 -1
- package/es/popup/Popup.mjs +18 -2
- package/es/popup/props.mjs +7 -1
- package/es/radio/Radio.mjs +84 -42
- package/es/radio/radio.css +1 -1
- package/es/radio-group/RadioGroup.mjs +43 -1
- package/es/select/Select.mjs +279 -213
- package/es/select/select.css +1 -1
- package/es/style.css +1 -1
- package/es/switch/Switch.mjs +82 -52
- package/es/switch/switch.css +1 -1
- package/es/tab/tab.css +1 -1
- package/es/themes/dark/link.mjs +2 -1
- package/es/themes/dark/paper.mjs +2 -1
- package/es/themes/dark/tab.mjs +3 -1
- package/es/themes/md3-dark/link.mjs +2 -1
- package/es/themes/md3-dark/paper.mjs +2 -1
- package/es/themes/md3-dark/tab.mjs +3 -1
- package/es/themes/md3-light/link.mjs +2 -1
- package/es/themes/md3-light/paper.mjs +2 -1
- package/es/themes/md3-light/tab.mjs +3 -1
- package/es/tooltip/props.mjs +6 -1
- package/es/uploader/Uploader.mjs +70 -44
- package/es/uploader/uploader.css +1 -1
- package/es/utils/elements.mjs +32 -0
- package/es/varlet.esm.js +8014 -7704
- package/highlight/web-types.en-US.json +15 -2
- package/lib/style.css +1 -1
- package/lib/varlet.cjs.js +1753 -1224
- package/package.json +7 -7
- package/types/actionSheet.d.ts +4 -0
- package/types/input.d.ts +5 -1
- package/types/select.d.ts +6 -1
- package/types/styleVars.d.ts +100 -92
- package/umd/varlet.js +6 -6
- package/highlight/web-types.zh-CN.json +0 -8045
package/es/select/Select.mjs
CHANGED
|
@@ -4,227 +4,230 @@ import VarChip from "../chip/index.mjs";
|
|
|
4
4
|
import VarFieldDecorator from "../field-decorator/index.mjs";
|
|
5
5
|
import VarFormDetails from "../form-details/index.mjs";
|
|
6
6
|
import { computed, defineComponent, ref, watch, nextTick } from "vue";
|
|
7
|
-
import { isArray, isEmpty, call } from "@varlet/shared";
|
|
7
|
+
import { isArray, isEmpty, call, preventDefault, doubleRaf } from "@varlet/shared";
|
|
8
8
|
import { props } from "./props.mjs";
|
|
9
9
|
import { useValidation, createNamespace } from "../utils/components.mjs";
|
|
10
10
|
import { useOptions } from "./provide.mjs";
|
|
11
11
|
import { useForm } from "../form/provide.mjs";
|
|
12
|
-
import { toPxNum } from "../utils/elements.mjs";
|
|
12
|
+
import { focusChildElementByKey, toPxNum } from "../utils/elements.mjs";
|
|
13
13
|
import { error } from "../utils/logger.mjs";
|
|
14
14
|
import { useSelectController } from "./useSelectController.mjs";
|
|
15
|
+
import { useEventListener } from "@varlet/use";
|
|
15
16
|
const { name, n, classes } = createNamespace("select");
|
|
16
17
|
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";
|
|
17
18
|
const _withScopeId = (n2) => (_pushScopeId(""), n2 = n2(), _popScopeId(), n2);
|
|
18
|
-
const _hoisted_1 =
|
|
19
|
+
const _hoisted_1 = ["tabindex"];
|
|
20
|
+
const _hoisted_2 = { key: 1 };
|
|
19
21
|
function __render__(_ctx, _cache) {
|
|
20
22
|
const _component_var_chip = _resolveComponent("var-chip");
|
|
21
23
|
const _component_var_icon = _resolveComponent("var-icon");
|
|
22
24
|
const _component_var_field_decorator = _resolveComponent("var-field-decorator");
|
|
23
25
|
const _component_var_menu = _resolveComponent("var-menu");
|
|
24
26
|
const _component_var_form_details = _resolveComponent("var-form-details");
|
|
25
|
-
return _openBlock(), _createElementBlock(
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
default: _withCtx(() => [
|
|
90
|
-
_createElementVNode(
|
|
91
|
-
"div",
|
|
92
|
-
{
|
|
93
|
-
class: _normalizeClass(_ctx.classes(_ctx.n("select"), [_ctx.errorMessage, _ctx.n("--error")], [_ctx.formDisabled || _ctx.disabled, _ctx.n("--disabled")])),
|
|
94
|
-
style: _normalizeStyle({
|
|
95
|
-
textAlign: _ctx.textAlign,
|
|
96
|
-
color: _ctx.textColor
|
|
97
|
-
})
|
|
98
|
-
},
|
|
99
|
-
[
|
|
100
|
-
_createElementVNode(
|
|
101
|
-
"div",
|
|
102
|
-
{
|
|
103
|
-
class: _normalizeClass(_ctx.n("label"))
|
|
104
|
-
},
|
|
105
|
-
[
|
|
106
|
-
!_ctx.isEmptyModelValue ? _renderSlot(_ctx.$slots, "selected", { key: 0 }, () => [
|
|
107
|
-
_ctx.multiple ? (_openBlock(), _createElementBlock(
|
|
108
|
-
_Fragment,
|
|
109
|
-
{ key: 0 },
|
|
110
|
-
[
|
|
111
|
-
_ctx.chip ? (_openBlock(), _createElementBlock(
|
|
112
|
-
"div",
|
|
113
|
-
{
|
|
114
|
-
key: 0,
|
|
115
|
-
class: _normalizeClass(_ctx.n("chips"))
|
|
116
|
-
},
|
|
117
|
-
[
|
|
118
|
-
(_openBlock(true), _createElementBlock(
|
|
119
|
-
_Fragment,
|
|
120
|
-
null,
|
|
121
|
-
_renderList(_ctx.labels, (l) => {
|
|
122
|
-
return _openBlock(), _createBlock(_component_var_chip, {
|
|
123
|
-
class: _normalizeClass(_ctx.n("chip")),
|
|
124
|
-
"var-select-cover": "",
|
|
125
|
-
closeable: "",
|
|
126
|
-
size: "small",
|
|
127
|
-
type: _ctx.errorMessage ? "danger" : void 0,
|
|
128
|
-
key: l,
|
|
129
|
-
onClick: _cache[0] || (_cache[0] = _withModifiers(() => {
|
|
130
|
-
}, ["stop"])),
|
|
131
|
-
onClose: () => _ctx.handleClose(l)
|
|
132
|
-
}, {
|
|
133
|
-
default: _withCtx(() => [
|
|
134
|
-
_createTextVNode(
|
|
135
|
-
_toDisplayString(l),
|
|
136
|
-
1
|
|
137
|
-
/* TEXT */
|
|
138
|
-
)
|
|
139
|
-
]),
|
|
140
|
-
_: 2
|
|
141
|
-
/* DYNAMIC */
|
|
142
|
-
}, 1032, ["class", "type", "onClose"]);
|
|
143
|
-
}),
|
|
144
|
-
128
|
|
145
|
-
/* KEYED_FRAGMENT */
|
|
146
|
-
))
|
|
147
|
-
],
|
|
148
|
-
2
|
|
149
|
-
/* CLASS */
|
|
150
|
-
)) : (_openBlock(), _createElementBlock(
|
|
151
|
-
"div",
|
|
152
|
-
{
|
|
153
|
-
key: 1,
|
|
154
|
-
class: _normalizeClass(_ctx.n("values"))
|
|
155
|
-
},
|
|
156
|
-
_toDisplayString(_ctx.labels.join(_ctx.separator)),
|
|
157
|
-
3
|
|
158
|
-
/* TEXT, CLASS */
|
|
159
|
-
))
|
|
160
|
-
],
|
|
161
|
-
64
|
|
162
|
-
/* STABLE_FRAGMENT */
|
|
163
|
-
)) : (_openBlock(), _createElementBlock(
|
|
164
|
-
"span",
|
|
165
|
-
_hoisted_1,
|
|
166
|
-
_toDisplayString(_ctx.label),
|
|
167
|
-
1
|
|
168
|
-
/* TEXT */
|
|
169
|
-
))
|
|
170
|
-
]) : _createCommentVNode("v-if", true)
|
|
171
|
-
],
|
|
172
|
-
2
|
|
173
|
-
/* CLASS */
|
|
174
|
-
),
|
|
175
|
-
_ctx.enableCustomPlaceholder ? (_openBlock(), _createElementBlock(
|
|
176
|
-
"span",
|
|
177
|
-
{
|
|
178
|
-
key: 0,
|
|
179
|
-
class: _normalizeClass(_ctx.classes(_ctx.n("placeholder"), _ctx.n("$--ellipsis"))),
|
|
180
|
-
style: _normalizeStyle({
|
|
181
|
-
color: _ctx.placeholderColor
|
|
182
|
-
})
|
|
183
|
-
},
|
|
184
|
-
_toDisplayString(_ctx.placeholder),
|
|
185
|
-
7
|
|
186
|
-
/* TEXT, CLASS, STYLE */
|
|
187
|
-
)) : _createCommentVNode("v-if", true),
|
|
188
|
-
_renderSlot(_ctx.$slots, "arrow-icon", { focus: _ctx.showMenu }, () => [
|
|
189
|
-
_createVNode(_component_var_icon, {
|
|
190
|
-
class: _normalizeClass(_ctx.classes(_ctx.n("arrow"), [_ctx.showMenu, _ctx.n("--arrow-rotate")])),
|
|
191
|
-
"var-select-cover": "",
|
|
192
|
-
name: "menu-down",
|
|
193
|
-
transition: 300
|
|
194
|
-
}, null, 8, ["class"])
|
|
195
|
-
])
|
|
196
|
-
],
|
|
197
|
-
6
|
|
198
|
-
/* CLASS, STYLE */
|
|
199
|
-
)
|
|
200
|
-
]),
|
|
201
|
-
_: 2
|
|
202
|
-
/* DYNAMIC */
|
|
203
|
-
}, [
|
|
204
|
-
_ctx.$slots["prepend-icon"] ? {
|
|
205
|
-
name: "prepend-icon",
|
|
206
|
-
fn: _withCtx(() => [
|
|
207
|
-
_renderSlot(_ctx.$slots, "prepend-icon")
|
|
208
|
-
]),
|
|
209
|
-
key: "0"
|
|
210
|
-
} : void 0
|
|
27
|
+
return _openBlock(), _createElementBlock("div", {
|
|
28
|
+
ref: "root",
|
|
29
|
+
class: _normalizeClass(_ctx.n()),
|
|
30
|
+
tabindex: _ctx.disabled || _ctx.formDisabled ? void 0 : "0",
|
|
31
|
+
onFocus: _cache[3] || (_cache[3] = (...args) => _ctx.handleFocus && _ctx.handleFocus(...args)),
|
|
32
|
+
onBlur: _cache[4] || (_cache[4] = (...args) => _ctx.handleRootBlur && _ctx.handleRootBlur(...args))
|
|
33
|
+
}, [
|
|
34
|
+
_createVNode(_component_var_menu, {
|
|
35
|
+
"var-select-cover": "",
|
|
36
|
+
"same-width": "",
|
|
37
|
+
"close-on-click-reference": "",
|
|
38
|
+
"close-on-key-escape": false,
|
|
39
|
+
class: _normalizeClass(_ctx.n("menu")),
|
|
40
|
+
"popover-class": _ctx.variant === "standard" && _ctx.hint ? _ctx.n("--standard-menu-margin") : void 0,
|
|
41
|
+
"offset-y": _ctx.offsetY,
|
|
42
|
+
disabled: _ctx.formReadonly || _ctx.readonly || _ctx.formDisabled || _ctx.disabled,
|
|
43
|
+
placement: _ctx.placement,
|
|
44
|
+
"default-style": false,
|
|
45
|
+
show: _ctx.showMenu,
|
|
46
|
+
"onUpdate:show": _cache[1] || (_cache[1] = ($event) => _ctx.showMenu = $event),
|
|
47
|
+
onClickOutside: _ctx.handleClickOutside
|
|
48
|
+
}, {
|
|
49
|
+
menu: _withCtx(() => [
|
|
50
|
+
_createElementVNode(
|
|
51
|
+
"div",
|
|
52
|
+
{
|
|
53
|
+
ref: "menuEl",
|
|
54
|
+
class: _normalizeClass(_ctx.classes(_ctx.n("scroller"), _ctx.n("$-elevation--3")))
|
|
55
|
+
},
|
|
56
|
+
[
|
|
57
|
+
_renderSlot(_ctx.$slots, "default")
|
|
58
|
+
],
|
|
59
|
+
2
|
|
60
|
+
/* CLASS */
|
|
61
|
+
)
|
|
62
|
+
]),
|
|
63
|
+
default: _withCtx(() => [
|
|
64
|
+
_createVNode(
|
|
65
|
+
_component_var_field_decorator,
|
|
66
|
+
_normalizeProps(_guardReactiveProps({
|
|
67
|
+
value: _ctx.modelValue,
|
|
68
|
+
size: _ctx.size,
|
|
69
|
+
variant: _ctx.variant,
|
|
70
|
+
placeholder: _ctx.placeholder,
|
|
71
|
+
line: _ctx.line,
|
|
72
|
+
hint: _ctx.hint,
|
|
73
|
+
textColor: _ctx.textColor,
|
|
74
|
+
focusColor: _ctx.focusColor,
|
|
75
|
+
blurColor: _ctx.blurColor,
|
|
76
|
+
isFocusing: _ctx.isFocusing,
|
|
77
|
+
errorMessage: _ctx.errorMessage,
|
|
78
|
+
formDisabled: _ctx.formDisabled,
|
|
79
|
+
disabled: _ctx.disabled,
|
|
80
|
+
clearable: _ctx.clearable,
|
|
81
|
+
cursor: _ctx.cursor,
|
|
82
|
+
onClick: _ctx.handleClick,
|
|
83
|
+
onClear: _ctx.handleClear
|
|
84
|
+
})),
|
|
85
|
+
_createSlots({
|
|
86
|
+
"clear-icon": _withCtx(({ clear }) => [
|
|
87
|
+
_renderSlot(_ctx.$slots, "clear-icon", { clear })
|
|
88
|
+
]),
|
|
89
|
+
"append-icon": _withCtx(() => [
|
|
90
|
+
_renderSlot(_ctx.$slots, "append-icon")
|
|
211
91
|
]),
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
92
|
+
default: _withCtx(() => [
|
|
93
|
+
_createElementVNode(
|
|
94
|
+
"div",
|
|
95
|
+
{
|
|
96
|
+
class: _normalizeClass(_ctx.classes(_ctx.n("select"), [_ctx.errorMessage, _ctx.n("--error")], [_ctx.formDisabled || _ctx.disabled, _ctx.n("--disabled")])),
|
|
97
|
+
style: _normalizeStyle({
|
|
98
|
+
textAlign: _ctx.textAlign,
|
|
99
|
+
color: _ctx.textColor
|
|
100
|
+
})
|
|
101
|
+
},
|
|
102
|
+
[
|
|
103
|
+
_createElementVNode(
|
|
104
|
+
"div",
|
|
105
|
+
{
|
|
106
|
+
class: _normalizeClass(_ctx.n("label"))
|
|
107
|
+
},
|
|
108
|
+
[
|
|
109
|
+
!_ctx.isEmptyModelValue ? _renderSlot(_ctx.$slots, "selected", { key: 0 }, () => [
|
|
110
|
+
_ctx.multiple ? (_openBlock(), _createElementBlock(
|
|
111
|
+
_Fragment,
|
|
112
|
+
{ key: 0 },
|
|
113
|
+
[
|
|
114
|
+
_ctx.chip ? (_openBlock(), _createElementBlock(
|
|
115
|
+
"div",
|
|
116
|
+
{
|
|
117
|
+
key: 0,
|
|
118
|
+
class: _normalizeClass(_ctx.n("chips"))
|
|
119
|
+
},
|
|
120
|
+
[
|
|
121
|
+
(_openBlock(true), _createElementBlock(
|
|
122
|
+
_Fragment,
|
|
123
|
+
null,
|
|
124
|
+
_renderList(_ctx.labels, (l) => {
|
|
125
|
+
return _openBlock(), _createBlock(_component_var_chip, {
|
|
126
|
+
class: _normalizeClass(_ctx.n("chip")),
|
|
127
|
+
"var-select-cover": "",
|
|
128
|
+
closeable: "",
|
|
129
|
+
size: "small",
|
|
130
|
+
type: _ctx.errorMessage ? "danger" : void 0,
|
|
131
|
+
key: l,
|
|
132
|
+
onClick: _cache[0] || (_cache[0] = _withModifiers(() => {
|
|
133
|
+
}, ["stop"])),
|
|
134
|
+
onClose: () => _ctx.handleClose(l)
|
|
135
|
+
}, {
|
|
136
|
+
default: _withCtx(() => [
|
|
137
|
+
_createTextVNode(
|
|
138
|
+
_toDisplayString(l),
|
|
139
|
+
1
|
|
140
|
+
/* TEXT */
|
|
141
|
+
)
|
|
142
|
+
]),
|
|
143
|
+
_: 2
|
|
144
|
+
/* DYNAMIC */
|
|
145
|
+
}, 1032, ["class", "type", "onClose"]);
|
|
146
|
+
}),
|
|
147
|
+
128
|
|
148
|
+
/* KEYED_FRAGMENT */
|
|
149
|
+
))
|
|
150
|
+
],
|
|
151
|
+
2
|
|
152
|
+
/* CLASS */
|
|
153
|
+
)) : (_openBlock(), _createElementBlock(
|
|
154
|
+
"div",
|
|
155
|
+
{
|
|
156
|
+
key: 1,
|
|
157
|
+
class: _normalizeClass(_ctx.n("values"))
|
|
158
|
+
},
|
|
159
|
+
_toDisplayString(_ctx.labels.join(_ctx.separator)),
|
|
160
|
+
3
|
|
161
|
+
/* TEXT, CLASS */
|
|
162
|
+
))
|
|
163
|
+
],
|
|
164
|
+
64
|
|
165
|
+
/* STABLE_FRAGMENT */
|
|
166
|
+
)) : (_openBlock(), _createElementBlock(
|
|
167
|
+
"span",
|
|
168
|
+
_hoisted_2,
|
|
169
|
+
_toDisplayString(_ctx.label),
|
|
170
|
+
1
|
|
171
|
+
/* TEXT */
|
|
172
|
+
))
|
|
173
|
+
]) : _createCommentVNode("v-if", true)
|
|
174
|
+
],
|
|
175
|
+
2
|
|
176
|
+
/* CLASS */
|
|
177
|
+
),
|
|
178
|
+
_ctx.enableCustomPlaceholder ? (_openBlock(), _createElementBlock(
|
|
179
|
+
"span",
|
|
180
|
+
{
|
|
181
|
+
key: 0,
|
|
182
|
+
class: _normalizeClass(_ctx.classes(_ctx.n("placeholder"), _ctx.n("$--ellipsis"))),
|
|
183
|
+
style: _normalizeStyle({
|
|
184
|
+
color: _ctx.placeholderColor
|
|
185
|
+
})
|
|
186
|
+
},
|
|
187
|
+
_toDisplayString(_ctx.placeholder),
|
|
188
|
+
7
|
|
189
|
+
/* TEXT, CLASS, STYLE */
|
|
190
|
+
)) : _createCommentVNode("v-if", true),
|
|
191
|
+
_renderSlot(_ctx.$slots, "arrow-icon", {
|
|
192
|
+
focus: _ctx.isFocusing,
|
|
193
|
+
menuOpen: _ctx.showMenu
|
|
194
|
+
}, () => [
|
|
195
|
+
_createVNode(_component_var_icon, {
|
|
196
|
+
class: _normalizeClass(_ctx.classes(_ctx.n("arrow"), [_ctx.showMenu, _ctx.n("--arrow-rotate")])),
|
|
197
|
+
"var-select-cover": "",
|
|
198
|
+
name: "menu-down",
|
|
199
|
+
transition: 300
|
|
200
|
+
}, null, 8, ["class"])
|
|
201
|
+
])
|
|
202
|
+
],
|
|
203
|
+
6
|
|
204
|
+
/* CLASS, STYLE */
|
|
205
|
+
)
|
|
206
|
+
]),
|
|
207
|
+
_: 2
|
|
208
|
+
/* DYNAMIC */
|
|
209
|
+
}, [
|
|
210
|
+
_ctx.$slots["prepend-icon"] ? {
|
|
211
|
+
name: "prepend-icon",
|
|
212
|
+
fn: _withCtx(() => [
|
|
213
|
+
_renderSlot(_ctx.$slots, "prepend-icon")
|
|
214
|
+
]),
|
|
215
|
+
key: "0"
|
|
216
|
+
} : void 0
|
|
217
|
+
]),
|
|
218
|
+
1040
|
|
219
|
+
/* FULL_PROPS, DYNAMIC_SLOTS */
|
|
220
|
+
)
|
|
221
|
+
]),
|
|
222
|
+
_: 3
|
|
223
|
+
/* FORWARDED */
|
|
224
|
+
}, 8, ["class", "popover-class", "offset-y", "disabled", "placement", "show", "onClickOutside"]),
|
|
225
|
+
_createVNode(_component_var_form_details, {
|
|
226
|
+
"error-message": _ctx.errorMessage,
|
|
227
|
+
onClick: _cache[2] || (_cache[2] = _withModifiers(() => {
|
|
228
|
+
}, ["stop"]))
|
|
229
|
+
}, null, 8, ["error-message"])
|
|
230
|
+
], 42, _hoisted_1);
|
|
228
231
|
}
|
|
229
232
|
const __sfc__ = defineComponent({
|
|
230
233
|
name,
|
|
@@ -237,8 +240,9 @@ const __sfc__ = defineComponent({
|
|
|
237
240
|
},
|
|
238
241
|
props,
|
|
239
242
|
setup(props2) {
|
|
240
|
-
const
|
|
243
|
+
const isFocusing = ref(false);
|
|
241
244
|
const showMenu = ref(false);
|
|
245
|
+
const root = ref(null);
|
|
242
246
|
const multiple = computed(() => props2.multiple);
|
|
243
247
|
const focusColor = computed(() => props2.focusColor);
|
|
244
248
|
const isEmptyModelValue = computed(() => isEmpty(props2.modelValue));
|
|
@@ -269,7 +273,7 @@ const __sfc__ = defineComponent({
|
|
|
269
273
|
if (errorMessage.value) {
|
|
270
274
|
return "var(--field-decorator-error-color)";
|
|
271
275
|
}
|
|
272
|
-
if (
|
|
276
|
+
if (isFocusing.value) {
|
|
273
277
|
return focusColor2 || "var(--field-decorator-focus-color)";
|
|
274
278
|
}
|
|
275
279
|
return blurColor || "var(--field-decorator-placeholder-color, var(--field-decorator-blur-color))";
|
|
@@ -294,7 +298,52 @@ const __sfc__ = defineComponent({
|
|
|
294
298
|
}
|
|
295
299
|
);
|
|
296
300
|
bindOptions(selectProvider);
|
|
301
|
+
useEventListener(() => window, "keydown", handleKeydown);
|
|
302
|
+
useEventListener(() => window, "keyup", handleKeyup);
|
|
297
303
|
call(bindForm, selectProvider);
|
|
304
|
+
function handleKeydown(event) {
|
|
305
|
+
const { disabled, readonly } = props2;
|
|
306
|
+
if ((form == null ? void 0 : form.disabled.value) || (form == null ? void 0 : form.readonly.value) || disabled || readonly || !isFocusing.value) {
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
const { key } = event;
|
|
310
|
+
if (key === " " && !showMenu.value) {
|
|
311
|
+
preventDefault(event);
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
if (key === "Escape" && showMenu.value) {
|
|
315
|
+
root.value.focus();
|
|
316
|
+
preventDefault(event);
|
|
317
|
+
showMenu.value = false;
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
if (key === "Tab" && showMenu.value) {
|
|
321
|
+
root.value.focus();
|
|
322
|
+
preventDefault(event);
|
|
323
|
+
handleBlur();
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
if (key === "Enter" && !showMenu.value) {
|
|
327
|
+
preventDefault(event);
|
|
328
|
+
showMenu.value = true;
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
if ((key === "ArrowDown" || key === "ArrowUp") && showMenu.value) {
|
|
332
|
+
preventDefault(event);
|
|
333
|
+
focusChildElementByKey(root.value, menuEl.value, key);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
function handleKeyup(event) {
|
|
337
|
+
const { disabled, readonly } = props2;
|
|
338
|
+
if ((form == null ? void 0 : form.disabled.value) || (form == null ? void 0 : form.readonly.value) || disabled || readonly || showMenu.value || !isFocusing.value) {
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
const { key } = event;
|
|
342
|
+
if (key === " " && !showMenu.value) {
|
|
343
|
+
preventDefault(event);
|
|
344
|
+
showMenu.value = true;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
298
347
|
function validateWithTrigger(trigger) {
|
|
299
348
|
nextTick(() => {
|
|
300
349
|
const { validateTrigger, rules, modelValue } = props2;
|
|
@@ -307,7 +356,7 @@ const __sfc__ = defineComponent({
|
|
|
307
356
|
return;
|
|
308
357
|
}
|
|
309
358
|
offsetY.value = toPxNum(props2.offsetY);
|
|
310
|
-
|
|
359
|
+
focus();
|
|
311
360
|
call(onFocus);
|
|
312
361
|
validateWithTrigger("onFocus");
|
|
313
362
|
}
|
|
@@ -320,6 +369,18 @@ const __sfc__ = defineComponent({
|
|
|
320
369
|
call(onBlur);
|
|
321
370
|
validateWithTrigger("onBlur");
|
|
322
371
|
}
|
|
372
|
+
function handleRootBlur() {
|
|
373
|
+
if (showMenu.value) {
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
handleBlur();
|
|
377
|
+
}
|
|
378
|
+
function handleClickOutside() {
|
|
379
|
+
if (!isFocusing.value) {
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
handleBlur();
|
|
383
|
+
}
|
|
323
384
|
function onSelect(option) {
|
|
324
385
|
const { disabled, readonly, multiple: multiple2, onChange } = props2;
|
|
325
386
|
if ((form == null ? void 0 : form.disabled.value) || (form == null ? void 0 : form.readonly.value) || disabled || readonly) {
|
|
@@ -330,7 +391,10 @@ const __sfc__ = defineComponent({
|
|
|
330
391
|
call(onChange, selectedValue);
|
|
331
392
|
validateWithTrigger("onChange");
|
|
332
393
|
if (!multiple2) {
|
|
333
|
-
|
|
394
|
+
root.value.focus();
|
|
395
|
+
doubleRaf().then(() => {
|
|
396
|
+
showMenu.value = false;
|
|
397
|
+
});
|
|
334
398
|
}
|
|
335
399
|
}
|
|
336
400
|
function handleClear() {
|
|
@@ -369,11 +433,10 @@ const __sfc__ = defineComponent({
|
|
|
369
433
|
}
|
|
370
434
|
function focus() {
|
|
371
435
|
offsetY.value = toPxNum(props2.offsetY);
|
|
372
|
-
|
|
373
|
-
showMenu.value = true;
|
|
436
|
+
isFocusing.value = true;
|
|
374
437
|
}
|
|
375
438
|
function blur() {
|
|
376
|
-
|
|
439
|
+
isFocusing.value = false;
|
|
377
440
|
showMenu.value = false;
|
|
378
441
|
}
|
|
379
442
|
function validate() {
|
|
@@ -384,8 +447,9 @@ const __sfc__ = defineComponent({
|
|
|
384
447
|
resetValidation();
|
|
385
448
|
}
|
|
386
449
|
return {
|
|
450
|
+
root,
|
|
387
451
|
offsetY,
|
|
388
|
-
|
|
452
|
+
isFocusing,
|
|
389
453
|
showMenu,
|
|
390
454
|
errorMessage,
|
|
391
455
|
formDisabled: form == null ? void 0 : form.disabled,
|
|
@@ -402,9 +466,11 @@ const __sfc__ = defineComponent({
|
|
|
402
466
|
classes,
|
|
403
467
|
handleFocus,
|
|
404
468
|
handleBlur,
|
|
469
|
+
handleClickOutside,
|
|
405
470
|
handleClear,
|
|
406
471
|
handleClick,
|
|
407
472
|
handleClose,
|
|
473
|
+
handleRootBlur,
|
|
408
474
|
reset,
|
|
409
475
|
validate,
|
|
410
476
|
resetValidation,
|
package/es/select/select.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
:root { --select-scroller-background: var(--color-surface-container-high); --select-scroller-padding: 6px 0; --select-scroller-max-height: 278px; --select-scroller-border-radius: 2px; --select-chip-margin: 5px 5px 0; --select-arrow-size: 20px; --select-standard-menu-margin: calc(var(--field-decorator-placeholder-size) * 0.75 + 12px) 0 0 0; --select-label-font-size: 16px;}.var-select { text-align: left;}.var-select__menu[var-select-cover] { width: 100%; background: transparent; display: block;}.var-select__chip[var-select-cover] { margin: var(--select-chip-margin);}.var-select__scroller { max-height: var(--select-scroller-max-height); background: var(--select-scroller-background); padding: var(--select-scroller-padding); overflow-y: auto; transition: background-color 0.25s; border-radius: var(--select-scroller-border-radius);}.var-select__wrap { position: relative; display: flex; flex-direction: column; width: 100%;}.var-select__select { display: flex; justify-content: space-between; align-items: center; width: 100%; min-height: 24px; outline: none; border: none; font-size: inherit; color: var(--field-decorator-text-color); word-break: break-all; overflow: hidden; transition: color 0.25s;}.var-select__label { display: flex; align-items: center; font-size: var(--select-label-font-size);}.var-select__placeholder { max-width: 100%; position: absolute; top: 50%; left: 0; transform: translateY(-50%); font-size: var(--field-decorator-placeholder-size); line-height: 1.5em; color: var(--field-decorator-blur-color); pointer-events: none; cursor: inherit;}.var-select__arrow[var-select-cover] { flex-shrink: 0; font-size: var(--select-arrow-size);}.var-select--standard-menu-margin { margin: var(--select-standard-menu-margin) !important;}.var-select--disabled { color: var(--field-decorator-disabled-color); cursor: not-allowed;}.var-select--error { color: var(--field-decorator-error-color);}.var-select--arrow-rotate { transform: rotate(180deg);}
|
|
1
|
+
:root { --select-scroller-background: var(--color-surface-container-high); --select-scroller-padding: 6px 0; --select-scroller-max-height: 278px; --select-scroller-border-radius: 2px; --select-chip-margin: 5px 5px 0; --select-arrow-size: 20px; --select-standard-menu-margin: calc(var(--field-decorator-placeholder-size) * 0.75 + 12px) 0 0 0; --select-label-font-size: 16px;}.var-select { text-align: left; outline: none;}.var-select__menu[var-select-cover] { width: 100%; background: transparent; display: block;}.var-select__chip[var-select-cover] { margin: var(--select-chip-margin);}.var-select__scroller { max-height: var(--select-scroller-max-height); background: var(--select-scroller-background); padding: var(--select-scroller-padding); overflow-y: auto; transition: background-color 0.25s; border-radius: var(--select-scroller-border-radius);}.var-select__wrap { position: relative; display: flex; flex-direction: column; width: 100%;}.var-select__select { display: flex; justify-content: space-between; align-items: center; width: 100%; min-height: 24px; outline: none; border: none; font-size: inherit; color: var(--field-decorator-text-color); word-break: break-all; overflow: hidden; transition: color 0.25s;}.var-select__label { display: flex; align-items: center; font-size: var(--select-label-font-size);}.var-select__placeholder { max-width: 100%; position: absolute; top: 50%; left: 0; transform: translateY(-50%); font-size: var(--field-decorator-placeholder-size); line-height: 1.5em; color: var(--field-decorator-blur-color); pointer-events: none; cursor: inherit;}.var-select__arrow[var-select-cover] { flex-shrink: 0; font-size: var(--select-arrow-size);}.var-select--standard-menu-margin { margin: var(--select-standard-menu-margin) !important;}.var-select--disabled { color: var(--field-decorator-disabled-color); cursor: not-allowed;}.var-select--error { color: var(--field-decorator-error-color);}.var-select--arrow-rotate { transform: rotate(180deg);}
|