@varlet/ui 3.7.4 → 3.8.0
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/style/index.mjs +1 -1
- package/es/checkbox/Checkbox.mjs +11 -13
- package/es/checkbox/checkbox.css +1 -1
- package/es/checkbox-group/CheckboxGroup.mjs +0 -5
- package/es/index.bundle.mjs +1 -1
- package/es/index.mjs +1 -1
- package/es/menu/Menu.mjs +5 -0
- package/es/menu/menu.css +1 -1
- package/es/menu/props.mjs +4 -1
- package/es/menu/usePopover.mjs +11 -0
- package/es/menu-option/MenuOption.mjs +104 -21
- package/es/menu-option/menuOption.css +1 -1
- package/es/menu-option/props.mjs +7 -2
- package/es/menu-option/style/index.mjs +1 -0
- package/es/menu-select/MenuChildren.mjs +237 -0
- package/es/menu-select/MenuSelect.mjs +200 -20
- package/es/menu-select/menuSelect.css +1 -1
- package/es/menu-select/props.mjs +6 -1
- package/es/option/Option.mjs +9 -5
- package/es/option/props.mjs +4 -0
- package/es/radio/Radio.mjs +2 -5
- package/es/radio/radio.css +1 -1
- package/es/select/Select.mjs +3 -2
- package/es/select/useSelectController.mjs +12 -5
- package/es/snackbar/style/index.mjs +1 -1
- package/es/style.css +1 -1
- package/es/uploader/Uploader.mjs +17 -11
- package/es/utils/elements.mjs +14 -1
- package/es/varlet.esm.js +7264 -6858
- package/highlight/web-types.en-US.json +27 -1
- package/highlight/web-types.zh-CN.json +27 -1
- package/lib/style.css +1 -1
- package/lib/varlet.cjs.js +1149 -610
- package/package.json +7 -7
- package/types/checkbox.d.ts +1 -1
- package/types/checkboxGroup.d.ts +2 -2
- package/types/menuSelect.d.ts +9 -1
- package/types/radioGroup.d.ts +2 -2
- package/types/select.d.ts +1 -1
- package/types/uploader.d.ts +1 -0
- package/umd/varlet.js +8 -8
package/es/checkbox/Checkbox.mjs
CHANGED
|
@@ -49,7 +49,7 @@ function __render__(_ctx, _cache) {
|
|
|
49
49
|
}, [
|
|
50
50
|
_ctx.isIndeterminate ? _renderSlot(_ctx.$slots, "indeterminate-icon", { key: 0 }, () => [
|
|
51
51
|
_createVNode(_component_var_icon, {
|
|
52
|
-
class: _normalizeClass(_ctx.
|
|
52
|
+
class: _normalizeClass(_ctx.n("icon")),
|
|
53
53
|
name: "minus-box",
|
|
54
54
|
size: _ctx.iconSize,
|
|
55
55
|
"var-checkbox-cover": ""
|
|
@@ -57,7 +57,7 @@ function __render__(_ctx, _cache) {
|
|
|
57
57
|
]) : _createCommentVNode("v-if", true),
|
|
58
58
|
_ctx.checked && !_ctx.isIndeterminate ? _renderSlot(_ctx.$slots, "checked-icon", { key: 1 }, () => [
|
|
59
59
|
_createVNode(_component_var_icon, {
|
|
60
|
-
class: _normalizeClass(_ctx.
|
|
60
|
+
class: _normalizeClass(_ctx.n("icon")),
|
|
61
61
|
name: "checkbox-marked",
|
|
62
62
|
size: _ctx.iconSize,
|
|
63
63
|
"var-checkbox-cover": ""
|
|
@@ -65,7 +65,7 @@ function __render__(_ctx, _cache) {
|
|
|
65
65
|
]) : _createCommentVNode("v-if", true),
|
|
66
66
|
!_ctx.checked && !_ctx.isIndeterminate ? _renderSlot(_ctx.$slots, "unchecked-icon", { key: 2 }, () => [
|
|
67
67
|
_createVNode(_component_var_icon, {
|
|
68
|
-
class: _normalizeClass(_ctx.
|
|
68
|
+
class: _normalizeClass(_ctx.n("icon")),
|
|
69
69
|
name: "checkbox-blank-outline",
|
|
70
70
|
size: _ctx.iconSize,
|
|
71
71
|
"var-checkbox-cover": ""
|
|
@@ -124,7 +124,6 @@ const __sfc__ = defineComponent({
|
|
|
124
124
|
const isIndeterminate = useVModel(props2, "indeterminate");
|
|
125
125
|
const checked = computed(() => value.value === props2.checkedValue);
|
|
126
126
|
const checkedValue = computed(() => props2.checkedValue);
|
|
127
|
-
const withAnimation = ref(false);
|
|
128
127
|
const { checkboxGroup, bindCheckboxGroup } = useCheckboxGroup();
|
|
129
128
|
const { hovering, handleHovering } = useHoverOverlay();
|
|
130
129
|
const { form, bindForm } = useForm();
|
|
@@ -141,8 +140,7 @@ const __sfc__ = defineComponent({
|
|
|
141
140
|
sync,
|
|
142
141
|
validate,
|
|
143
142
|
resetValidation,
|
|
144
|
-
reset
|
|
145
|
-
resetWithAnimation
|
|
143
|
+
reset
|
|
146
144
|
};
|
|
147
145
|
call(bindCheckboxGroup, checkboxProvider);
|
|
148
146
|
call(bindForm, checkboxProvider);
|
|
@@ -157,8 +155,7 @@ const __sfc__ = defineComponent({
|
|
|
157
155
|
function change(changedValue) {
|
|
158
156
|
const { checkedValue: checkedValue2, onChange } = props2;
|
|
159
157
|
value.value = changedValue;
|
|
160
|
-
isIndeterminate.value
|
|
161
|
-
call(onChange, value.value);
|
|
158
|
+
call(onChange, value.value, isIndeterminate.value);
|
|
162
159
|
validateWithTrigger("onChange");
|
|
163
160
|
changedValue === checkedValue2 ? checkboxGroup == null ? void 0 : checkboxGroup.onChecked(checkedValue2) : checkboxGroup == null ? void 0 : checkboxGroup.onUnchecked(checkedValue2);
|
|
164
161
|
}
|
|
@@ -171,7 +168,12 @@ const __sfc__ = defineComponent({
|
|
|
171
168
|
if ((form == null ? void 0 : form.readonly.value) || readonly) {
|
|
172
169
|
return;
|
|
173
170
|
}
|
|
174
|
-
|
|
171
|
+
if (isIndeterminate.value === true) {
|
|
172
|
+
isIndeterminate.value = false;
|
|
173
|
+
call(props2.onChange, value.value, isIndeterminate.value);
|
|
174
|
+
validateWithTrigger("onChange");
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
175
177
|
const maximum = checkboxGroup ? checkboxGroup.checkedCount.value >= Number(checkboxGroup.max.value) : false;
|
|
176
178
|
if (!checked.value && maximum) {
|
|
177
179
|
return;
|
|
@@ -185,9 +187,6 @@ const __sfc__ = defineComponent({
|
|
|
185
187
|
const { checkedValue: checkedValue2, uncheckedValue } = props2;
|
|
186
188
|
value.value = values.includes(checkedValue2) ? checkedValue2 : uncheckedValue;
|
|
187
189
|
}
|
|
188
|
-
function resetWithAnimation() {
|
|
189
|
-
withAnimation.value = false;
|
|
190
|
-
}
|
|
191
190
|
function reset() {
|
|
192
191
|
value.value = props2.uncheckedValue;
|
|
193
192
|
resetValidation();
|
|
@@ -228,7 +227,6 @@ const __sfc__ = defineComponent({
|
|
|
228
227
|
action,
|
|
229
228
|
isFocusing,
|
|
230
229
|
isIndeterminate,
|
|
231
|
-
withAnimation,
|
|
232
230
|
checked,
|
|
233
231
|
errorMessage,
|
|
234
232
|
checkboxGroupErrorMessage: checkboxGroup == null ? void 0 : checkboxGroup.errorMessage,
|
package/es/checkbox/checkbox.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
:root { --checkbox-checked-color: var(--color-primary); --checkbox-unchecked-color: #555; --checkbox-disabled-color: var(--color-text-disabled); --checkbox-error-color: var(--color-danger); --checkbox-action-padding: 6px; --checkbox-text-color: #555; --checkbox-icon-size: 24px;}
|
|
1
|
+
:root { --checkbox-checked-color: var(--color-primary); --checkbox-unchecked-color: #555; --checkbox-disabled-color: var(--color-text-disabled); --checkbox-error-color: var(--color-danger); --checkbox-action-padding: 6px; --checkbox-text-color: #555; --checkbox-icon-size: 24px;}.var-checkbox { display: flex; align-items: center; transform: translateX(calc(-1 * var(--checkbox-action-padding))); cursor: pointer; -webkit-tap-highlight-color: transparent;}.var-checkbox__wrap { display: inline-flex; flex-direction: column;}.var-checkbox__action { position: relative; display: flex; justify-content: center; align-items: center; flex-shrink: 0; padding: var(--checkbox-action-padding); border-radius: 50%; transition: background-color 0.25s, color 0.25s; outline: none;}.var-checkbox__icon[var-checkbox-cover] { display: block; font-size: var(--checkbox-icon-size);}.var-checkbox__text { color: var(--checkbox-text-color);}.var-checkbox--checked { color: var(--checkbox-checked-color);}.var-checkbox--unchecked { color: var(--checkbox-unchecked-color);}.var-checkbox--disabled { color: var(--checkbox-disabled-color); cursor: not-allowed;}.var-checkbox--error { color: var(--checkbox-error-color);}
|
|
@@ -114,20 +114,15 @@ const __sfc__ = defineComponent({
|
|
|
114
114
|
function syncCheckboxes() {
|
|
115
115
|
checkboxes.forEach(({ sync }) => sync(props2.modelValue));
|
|
116
116
|
}
|
|
117
|
-
function resetWithAnimation() {
|
|
118
|
-
checkboxes.forEach((checkbox) => checkbox.resetWithAnimation());
|
|
119
|
-
}
|
|
120
117
|
function checkAll() {
|
|
121
118
|
const checkedValues = checkboxes.map(({ checkedValue }) => checkedValue.value);
|
|
122
119
|
const changedModelValue = uniq(checkedValues);
|
|
123
|
-
resetWithAnimation();
|
|
124
120
|
call(props2["onUpdate:modelValue"], changedModelValue);
|
|
125
121
|
return changedModelValue;
|
|
126
122
|
}
|
|
127
123
|
function inverseAll() {
|
|
128
124
|
const checkedValues = checkboxes.filter(({ checked }) => !checked.value).map(({ checkedValue }) => checkedValue.value);
|
|
129
125
|
const changedModelValue = uniq(checkedValues);
|
|
130
|
-
resetWithAnimation();
|
|
131
126
|
call(props2["onUpdate:modelValue"], changedModelValue);
|
|
132
127
|
return changedModelValue;
|
|
133
128
|
}
|
package/es/index.bundle.mjs
CHANGED
|
@@ -280,7 +280,7 @@ import './tooltip/style/index.mjs'
|
|
|
280
280
|
import './uploader/style/index.mjs'
|
|
281
281
|
import './watermark/style/index.mjs'
|
|
282
282
|
|
|
283
|
-
const version = '3.
|
|
283
|
+
const version = '3.8.0'
|
|
284
284
|
|
|
285
285
|
function install(app) {
|
|
286
286
|
ActionSheet.install && app.use(ActionSheet)
|
package/es/index.mjs
CHANGED
|
@@ -186,7 +186,7 @@ export * from './tooltip/index.mjs'
|
|
|
186
186
|
export * from './uploader/index.mjs'
|
|
187
187
|
export * from './watermark/index.mjs'
|
|
188
188
|
|
|
189
|
-
const version = '3.
|
|
189
|
+
const version = '3.8.0'
|
|
190
190
|
|
|
191
191
|
function install(app) {
|
|
192
192
|
ActionSheet.install && app.use(ActionSheet)
|
package/es/menu/Menu.mjs
CHANGED
|
@@ -80,6 +80,7 @@ const __sfc__ = defineComponent({
|
|
|
80
80
|
handlePopoverMouseleave,
|
|
81
81
|
handlePopoverClose,
|
|
82
82
|
handleClosed,
|
|
83
|
+
setAllowClose,
|
|
83
84
|
// expose
|
|
84
85
|
open,
|
|
85
86
|
// expose
|
|
@@ -89,6 +90,9 @@ const __sfc__ = defineComponent({
|
|
|
89
90
|
// expose
|
|
90
91
|
setReference
|
|
91
92
|
} = usePopover(props2);
|
|
93
|
+
function allowClose() {
|
|
94
|
+
setAllowClose(true);
|
|
95
|
+
}
|
|
92
96
|
return {
|
|
93
97
|
popover,
|
|
94
98
|
host,
|
|
@@ -96,6 +100,7 @@ const __sfc__ = defineComponent({
|
|
|
96
100
|
show,
|
|
97
101
|
zIndex,
|
|
98
102
|
teleportDisabled,
|
|
103
|
+
allowClose,
|
|
99
104
|
formatElevation,
|
|
100
105
|
toSizeUnit,
|
|
101
106
|
n,
|
package/es/menu/menu.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
:root { --menu-background-color: var(--color-surface-container-high); --menu-border-radius: 2px;}.var-menu { display: inline-
|
|
1
|
+
:root { --menu-background-color: var(--color-surface-container-high); --menu-border-radius: 2px;}.var-menu { display: inline-flex; outline: none;}.var-menu__menu { border-radius: var(--menu-border-radius);}.var-menu-enter-from,.var-menu-leave-to { opacity: 0; transform: scale(0.8);}.var-menu-enter-active,.var-menu-leave-active { transition-property: opacity, transform; transition-duration: 0.2s;}.var-menu--menu-background-color { background: var(--menu-background-color);}
|
package/es/menu/props.mjs
CHANGED
|
@@ -47,7 +47,10 @@ const props = {
|
|
|
47
47
|
onClose: defineListenerProp(),
|
|
48
48
|
onClosed: defineListenerProp(),
|
|
49
49
|
onClickOutside: defineListenerProp(),
|
|
50
|
-
"onUpdate:show": defineListenerProp()
|
|
50
|
+
"onUpdate:show": defineListenerProp(),
|
|
51
|
+
// internal start
|
|
52
|
+
cascadeOptimization: Boolean
|
|
53
|
+
// internal end
|
|
51
54
|
};
|
|
52
55
|
export {
|
|
53
56
|
props
|
package/es/menu/usePopover.mjs
CHANGED
|
@@ -68,6 +68,7 @@ function usePopover(options) {
|
|
|
68
68
|
let reference = void 0;
|
|
69
69
|
let enterPopover = false;
|
|
70
70
|
let enterReference = false;
|
|
71
|
+
let allowClose = true;
|
|
71
72
|
useEventListener(() => window, "keydown", handleKeydown);
|
|
72
73
|
watch(() => [options.offsetX, options.offsetY, options.placement, options.strategy], resize);
|
|
73
74
|
watch(() => options.disabled, close);
|
|
@@ -168,6 +169,9 @@ function usePopover(options) {
|
|
|
168
169
|
return;
|
|
169
170
|
}
|
|
170
171
|
enterPopover = true;
|
|
172
|
+
if (options.cascadeOptimization) {
|
|
173
|
+
allowClose = false;
|
|
174
|
+
}
|
|
171
175
|
}
|
|
172
176
|
function handlePopoverMouseleave() {
|
|
173
177
|
return __async(this, null, function* () {
|
|
@@ -340,6 +344,9 @@ function usePopover(options) {
|
|
|
340
344
|
}
|
|
341
345
|
return targetReference;
|
|
342
346
|
}
|
|
347
|
+
function setAllowClose(value) {
|
|
348
|
+
allowClose = value;
|
|
349
|
+
}
|
|
343
350
|
function setReference(newReference) {
|
|
344
351
|
destroyPopperInstance();
|
|
345
352
|
reference = newReference;
|
|
@@ -363,6 +370,9 @@ function usePopover(options) {
|
|
|
363
370
|
call(options["onUpdate:show"], true);
|
|
364
371
|
}
|
|
365
372
|
function close() {
|
|
373
|
+
if (!allowClose) {
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
366
376
|
show.value = false;
|
|
367
377
|
call(options["onUpdate:show"], false);
|
|
368
378
|
}
|
|
@@ -377,6 +387,7 @@ function usePopover(options) {
|
|
|
377
387
|
handlePopoverMouseleave,
|
|
378
388
|
handleClosed,
|
|
379
389
|
setReference,
|
|
390
|
+
setAllowClose,
|
|
380
391
|
resize,
|
|
381
392
|
open,
|
|
382
393
|
close
|
|
@@ -1,31 +1,60 @@
|
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
1
21
|
import VarCheckbox from "../checkbox/index.mjs";
|
|
22
|
+
import VarIcon from "../icon/index.mjs";
|
|
23
|
+
import VarHoverOverlay, { useHoverOverlay } from "../hover-overlay/index.mjs";
|
|
2
24
|
import Ripple from "../ripple/index.mjs";
|
|
3
25
|
import Hover from "../hover/index.mjs";
|
|
4
|
-
import
|
|
5
|
-
import { defineComponent, computed, ref, watch } from "vue";
|
|
26
|
+
import { defineComponent, computed, ref, watch, nextTick } from "vue";
|
|
6
27
|
import { useMenuSelect } from "./provide.mjs";
|
|
7
28
|
import { createNamespace, MaybeVNode } from "../utils/components.mjs";
|
|
8
29
|
import { props } from "./props.mjs";
|
|
9
|
-
import { preventDefault, isFunction } from "@varlet/shared";
|
|
30
|
+
import { preventDefault, isFunction, isBoolean, call } from "@varlet/shared";
|
|
10
31
|
import { useEventListener } from "@varlet/use";
|
|
11
32
|
const { name, n, classes } = createNamespace("menu-option");
|
|
12
|
-
import { normalizeClass as _normalizeClass, createElementVNode as _createElementVNode, resolveComponent as _resolveComponent, withModifiers as _withModifiers, openBlock as _openBlock, createBlock as _createBlock, createCommentVNode as _createCommentVNode, renderSlot as _renderSlot, createVNode as _createVNode,
|
|
33
|
+
import { normalizeClass as _normalizeClass, createElementVNode as _createElementVNode, resolveComponent as _resolveComponent, withModifiers as _withModifiers, openBlock as _openBlock, createBlock as _createBlock, createCommentVNode as _createCommentVNode, renderSlot as _renderSlot, createVNode as _createVNode, createElementBlock as _createElementBlock, resolveDirective as _resolveDirective, withDirectives as _withDirectives } from "vue";
|
|
13
34
|
const _hoisted_1 = ["tabindex"];
|
|
14
35
|
function __render__(_ctx, _cache) {
|
|
15
36
|
const _component_var_checkbox = _resolveComponent("var-checkbox");
|
|
16
37
|
const _component_maybe_v_node = _resolveComponent("maybe-v-node");
|
|
38
|
+
const _component_var_icon = _resolveComponent("var-icon");
|
|
17
39
|
const _component_var_hover_overlay = _resolveComponent("var-hover-overlay");
|
|
18
40
|
const _directive_ripple = _resolveDirective("ripple");
|
|
19
41
|
const _directive_hover = _resolveDirective("hover");
|
|
20
42
|
return _withDirectives((_openBlock(), _createElementBlock("div", {
|
|
21
43
|
ref: "root",
|
|
22
44
|
class: _normalizeClass(
|
|
23
|
-
_ctx.classes(
|
|
45
|
+
_ctx.classes(
|
|
46
|
+
_ctx.n(),
|
|
47
|
+
_ctx.n("$--box"),
|
|
48
|
+
_ctx.n(`--${_ctx.size}`),
|
|
49
|
+
[_ctx.optionSelected, _ctx.n("--selected-color")],
|
|
50
|
+
[_ctx.disabled, _ctx.n("--disabled")],
|
|
51
|
+
[_ctx.childrenTrigger, _ctx.n("--children-trigger")]
|
|
52
|
+
)
|
|
24
53
|
),
|
|
25
54
|
tabindex: _ctx.disabled ? void 0 : "-1",
|
|
26
|
-
onClick: _cache[
|
|
27
|
-
onFocus: _cache[
|
|
28
|
-
onBlur: _cache[
|
|
55
|
+
onClick: _cache[3] || (_cache[3] = (...args) => _ctx.handleClick && _ctx.handleClick(...args)),
|
|
56
|
+
onFocus: _cache[4] || (_cache[4] = ($event) => _ctx.isFocusing = true),
|
|
57
|
+
onBlur: _cache[5] || (_cache[5] = ($event) => _ctx.isFocusing = false)
|
|
29
58
|
}, [
|
|
30
59
|
_createElementVNode(
|
|
31
60
|
"div",
|
|
@@ -41,11 +70,13 @@ function __render__(_ctx, _cache) {
|
|
|
41
70
|
ref: "checkbox",
|
|
42
71
|
modelValue: _ctx.optionSelected,
|
|
43
72
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.optionSelected = $event),
|
|
73
|
+
indeterminate: _ctx.optionIndeterminate,
|
|
74
|
+
"onUpdate:indeterminate": _cache[1] || (_cache[1] = ($event) => _ctx.optionIndeterminate = $event),
|
|
44
75
|
disabled: _ctx.disabled,
|
|
45
|
-
onClick: _cache[
|
|
76
|
+
onClick: _cache[2] || (_cache[2] = _withModifiers(() => {
|
|
46
77
|
}, ["stop"])),
|
|
47
78
|
onChange: _ctx.handleSelect
|
|
48
|
-
}, null, 8, ["modelValue", "disabled", "onChange"])) : _createCommentVNode("v-if", true),
|
|
79
|
+
}, null, 8, ["modelValue", "indeterminate", "disabled", "onChange"])) : _createCommentVNode("v-if", true),
|
|
49
80
|
_renderSlot(_ctx.$slots, "default", {}, () => [
|
|
50
81
|
_createElementVNode(
|
|
51
82
|
"div",
|
|
@@ -62,8 +93,24 @@ function __render__(_ctx, _cache) {
|
|
|
62
93
|
/* CLASS */
|
|
63
94
|
)
|
|
64
95
|
]),
|
|
96
|
+
_ctx.childrenTrigger ? (_openBlock(), _createElementBlock(
|
|
97
|
+
"div",
|
|
98
|
+
{
|
|
99
|
+
key: 1,
|
|
100
|
+
class: _normalizeClass(_ctx.n("arrow"))
|
|
101
|
+
},
|
|
102
|
+
[
|
|
103
|
+
_createVNode(_component_var_icon, {
|
|
104
|
+
"var-menu-option-cover": "",
|
|
105
|
+
class: _normalizeClass(_ctx.n("arrow-icon")),
|
|
106
|
+
name: "chevron-right"
|
|
107
|
+
}, null, 8, ["class"])
|
|
108
|
+
],
|
|
109
|
+
2
|
|
110
|
+
/* CLASS */
|
|
111
|
+
)) : _createCommentVNode("v-if", true),
|
|
65
112
|
_createVNode(_component_var_hover_overlay, {
|
|
66
|
-
hovering: _ctx.hovering && !_ctx.disabled,
|
|
113
|
+
hovering: (_ctx.hovering || _ctx.highlight) && !_ctx.disabled,
|
|
67
114
|
focusing: _ctx.isFocusing && !_ctx.disabled
|
|
68
115
|
}, null, 8, ["hovering", "focusing"])
|
|
69
116
|
], 42, _hoisted_1)), [
|
|
@@ -77,14 +124,24 @@ const __sfc__ = defineComponent({
|
|
|
77
124
|
components: {
|
|
78
125
|
VarCheckbox,
|
|
79
126
|
VarHoverOverlay,
|
|
127
|
+
VarIcon,
|
|
80
128
|
MaybeVNode
|
|
81
129
|
},
|
|
82
130
|
props,
|
|
83
131
|
setup(props2) {
|
|
84
132
|
const root = ref();
|
|
133
|
+
const checkbox = ref();
|
|
85
134
|
const isFocusing = ref(false);
|
|
86
135
|
const optionSelected = ref(false);
|
|
136
|
+
const optionIndeterminate = ref(false);
|
|
87
137
|
const selected = computed(() => optionSelected.value);
|
|
138
|
+
const indeterminate = computed(() => optionIndeterminate.value);
|
|
139
|
+
const value = computed(() => props2.value);
|
|
140
|
+
const disabled = computed(() => props2.disabled);
|
|
141
|
+
const ripple = computed(() => props2.ripple);
|
|
142
|
+
const { menuSelect, bindMenuSelect } = useMenuSelect();
|
|
143
|
+
const { size, multiple, onSelect, computeLabel } = menuSelect;
|
|
144
|
+
const { hovering, handleHovering } = useHoverOverlay();
|
|
88
145
|
const labelVNode = computed(
|
|
89
146
|
() => {
|
|
90
147
|
var _a;
|
|
@@ -99,14 +156,13 @@ const __sfc__ = defineComponent({
|
|
|
99
156
|
) : props2.label;
|
|
100
157
|
}
|
|
101
158
|
);
|
|
102
|
-
const value = computed(() => props2.value);
|
|
103
|
-
const { menuSelect, bindMenuSelect } = useMenuSelect();
|
|
104
|
-
const { size, multiple, onSelect, computeLabel } = menuSelect;
|
|
105
|
-
const { hovering, handleHovering } = useHoverOverlay();
|
|
106
159
|
const menuOptionProvider = {
|
|
107
160
|
label: labelVNode,
|
|
108
161
|
value,
|
|
109
162
|
selected,
|
|
163
|
+
disabled,
|
|
164
|
+
ripple,
|
|
165
|
+
indeterminate,
|
|
110
166
|
sync
|
|
111
167
|
};
|
|
112
168
|
watch([() => props2.label, () => props2.value], computeLabel);
|
|
@@ -117,9 +173,31 @@ const __sfc__ = defineComponent({
|
|
|
117
173
|
if (props2.disabled) {
|
|
118
174
|
return;
|
|
119
175
|
}
|
|
120
|
-
|
|
176
|
+
if (!multiple.value && props2.childrenTrigger) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
if (multiple.value && optionIndeterminate.value) {
|
|
180
|
+
optionIndeterminate.value = false;
|
|
181
|
+
optionSelected.value = false;
|
|
182
|
+
onSelect(menuOptionProvider);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (multiple.value && !optionIndeterminate.value) {
|
|
186
|
+
optionSelected.value = !optionSelected.value;
|
|
187
|
+
}
|
|
188
|
+
onSelect(menuOptionProvider);
|
|
121
189
|
}
|
|
122
190
|
function handleKeydown(event) {
|
|
191
|
+
var _a;
|
|
192
|
+
if (!isFocusing.value && !((_a = checkbox.value) == null ? void 0 : _a.isFocusing)) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if (event.key === "ArrowRight") {
|
|
196
|
+
call(props2.onKeyArrowX, event.key);
|
|
197
|
+
}
|
|
198
|
+
if (event.key === "ArrowLeft") {
|
|
199
|
+
call(props2.onKeyArrowX, event.key);
|
|
200
|
+
}
|
|
123
201
|
if (!isFocusing.value) {
|
|
124
202
|
return;
|
|
125
203
|
}
|
|
@@ -140,17 +218,22 @@ const __sfc__ = defineComponent({
|
|
|
140
218
|
}
|
|
141
219
|
}
|
|
142
220
|
function handleSelect() {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
221
|
+
return __async(this, null, function* () {
|
|
222
|
+
yield nextTick();
|
|
223
|
+
onSelect(menuOptionProvider);
|
|
224
|
+
});
|
|
147
225
|
}
|
|
148
|
-
function sync(checked) {
|
|
226
|
+
function sync(checked, indeterminate2) {
|
|
149
227
|
optionSelected.value = checked;
|
|
228
|
+
if (isBoolean(indeterminate2)) {
|
|
229
|
+
optionIndeterminate.value = indeterminate2;
|
|
230
|
+
}
|
|
150
231
|
}
|
|
151
232
|
return {
|
|
152
233
|
root,
|
|
234
|
+
checkbox,
|
|
153
235
|
optionSelected,
|
|
236
|
+
optionIndeterminate,
|
|
154
237
|
size,
|
|
155
238
|
multiple,
|
|
156
239
|
hovering,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
:root { --menu-option-normal-height: 38px; --menu-option-small-height: 30px; --menu-option-mini-height: 24px; --menu-option-large-height: 46px; --menu-option-padding: 0 12px; --menu-option-normal-font-size: var(--font-size-md); --menu-option-small-font-size: var(--font-size-sm); --menu-option-mini-font-size: var(--font-size-xs); --menu-option-large-font-size: var(--font-size-lg); --menu-option-selected-background: var(--color-primary); --menu-option-text-color: #555; --menu-option-disabled-color: var(--color-text-disabled);}.var-menu-option { position: relative; display: flex; align-items: center; padding: var(--menu-option-padding); cursor: pointer; -webkit-tap-highlight-color: transparent; color: var(--menu-option-text-color); outline: none;}.var-menu-option__cover { position: absolute; top: 0; left: 0; right: 0; bottom: 0; opacity: 0.2; background: transparent;}.var-menu-option__text { display: flex; align-items: center; overflow-x: hidden;}.var-menu-option--normal { height: var(--menu-option-normal-height); font-size: var(--menu-option-normal-font-size);}.var-menu-option--large { height: var(--menu-option-large-height); font-size: var(--menu-option-large-font-size);}.var-menu-option--small { height: var(--menu-option-small-height); font-size: var(--menu-option-small-font-size);}.var-menu-option--mini { height: var(--menu-option-mini-height); font-size: var(--menu-option-mini-font-size);}.var-menu-option--selected-background { background: var(--menu-option-selected-background);}.var-menu-option--selected-color { color: var(--menu-option-selected-background);}.var-menu-option--disabled { color: var(--menu-option-disabled-color); cursor: not-allowed;}
|
|
1
|
+
:root { --menu-option-normal-height: 38px; --menu-option-small-height: 30px; --menu-option-mini-height: 24px; --menu-option-large-height: 46px; --menu-option-padding: 0 12px; --menu-option-normal-font-size: var(--font-size-md); --menu-option-small-font-size: var(--font-size-sm); --menu-option-mini-font-size: var(--font-size-xs); --menu-option-large-font-size: var(--font-size-lg); --menu-option-selected-background: var(--color-primary); --menu-option-text-color: #555; --menu-option-disabled-color: var(--color-text-disabled); --menu-option-arrow-padding: 0 6px 0 8px; --menu-option-arrow-icon-size: 18px;}.var-menu-option { position: relative; display: flex; align-items: center; padding: var(--menu-option-padding); cursor: pointer; -webkit-tap-highlight-color: transparent; color: var(--menu-option-text-color); outline: none;}.var-menu-option__cover { position: absolute; top: 0; left: 0; right: 0; bottom: 0; opacity: 0.2; background: transparent;}.var-menu-option__text { display: flex; align-items: center; overflow-x: hidden;}.var-menu-option__arrow { padding: var(--menu-option-arrow-padding);}.var-menu-option__arrow-icon[var-menu-option-cover] { font-size: var(--menu-option-arrow-icon-size);}.var-menu-option--children-trigger { padding-right: 0;}.var-menu-option--normal { height: var(--menu-option-normal-height); font-size: var(--menu-option-normal-font-size);}.var-menu-option--large { height: var(--menu-option-large-height); font-size: var(--menu-option-large-font-size);}.var-menu-option--small { height: var(--menu-option-small-height); font-size: var(--menu-option-small-font-size);}.var-menu-option--mini { height: var(--menu-option-mini-height); font-size: var(--menu-option-mini-font-size);}.var-menu-option--selected-background { background: var(--menu-option-selected-background);}.var-menu-option--selected-color { color: var(--menu-option-selected-background);}.var-menu-option--disabled { color: var(--menu-option-disabled-color); cursor: not-allowed;}
|
package/es/menu-option/props.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { defineListenerProp } from "../utils/components.mjs";
|
|
1
2
|
const props = {
|
|
2
3
|
label: {},
|
|
3
4
|
value: {},
|
|
@@ -6,8 +7,12 @@ const props = {
|
|
|
6
7
|
type: Boolean,
|
|
7
8
|
default: true
|
|
8
9
|
},
|
|
9
|
-
// internal
|
|
10
|
-
option: Object
|
|
10
|
+
// internal start
|
|
11
|
+
option: Object,
|
|
12
|
+
childrenTrigger: Boolean,
|
|
13
|
+
highlight: Boolean,
|
|
14
|
+
onKeyArrowX: defineListenerProp()
|
|
15
|
+
// internal end
|
|
11
16
|
};
|
|
12
17
|
export {
|
|
13
18
|
props
|