@varlet/ui 3.0.6 → 3.1.0-alpha.1709284240068
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 +4 -1
- package/es/action-sheet/style/index.mjs +1 -0
- package/es/button/Button.mjs +6 -6
- package/es/checkbox/Checkbox.mjs +77 -49
- 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/select/Select.mjs +279 -213
- package/es/select/select.css +1 -1
- package/es/snackbar/style/index.mjs +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 +7721 -7457
- package/highlight/web-types.en-US.json +2 -2
- package/highlight/web-types.zh-CN.json +3 -3
- package/lib/style.css +1 -1
- package/lib/varlet.cjs.js +1527 -1084
- package/package.json +7 -7
- package/types/input.d.ts +1 -1
- package/types/select.d.ts +1 -0
- package/types/styleVars.d.ts +100 -92
- package/umd/varlet.js +6 -6
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import Ripple from "../ripple/index.mjs";
|
|
2
|
+
import VarIcon from "../icon/index.mjs";
|
|
3
|
+
import VarHoverOverlay, { useHoverOverlay } from "../hover-overlay/index.mjs";
|
|
4
|
+
import Hover from "../hover/index.mjs";
|
|
5
|
+
import { defineComponent } from "vue";
|
|
6
|
+
import { createNamespace } from "../utils/components.mjs";
|
|
7
|
+
const { name, n, classes } = createNamespace("action-sheet");
|
|
8
|
+
import { resolveComponent as _resolveComponent, normalizeClass as _normalizeClass, openBlock as _openBlock, createBlock as _createBlock, createCommentVNode as _createCommentVNode, toDisplayString as _toDisplayString, createElementVNode as _createElementVNode, createVNode as _createVNode, normalizeStyle as _normalizeStyle, resolveDirective as _resolveDirective, createElementBlock as _createElementBlock, withDirectives as _withDirectives } from "vue";
|
|
9
|
+
function __render__(_ctx, _cache) {
|
|
10
|
+
const _component_var_icon = _resolveComponent("var-icon");
|
|
11
|
+
const _component_var_hover_overlay = _resolveComponent("var-hover-overlay");
|
|
12
|
+
const _directive_ripple = _resolveDirective("ripple");
|
|
13
|
+
const _directive_hover = _resolveDirective("hover");
|
|
14
|
+
return _withDirectives((_openBlock(), _createElementBlock(
|
|
15
|
+
"div",
|
|
16
|
+
{
|
|
17
|
+
class: _normalizeClass(_ctx.classes(_ctx.n("action-item"), _ctx.className, [_ctx.disabled, _ctx.n("--disabled")])),
|
|
18
|
+
style: _normalizeStyle({ color: _ctx.color })
|
|
19
|
+
},
|
|
20
|
+
[
|
|
21
|
+
_ctx.icon ? (_openBlock(), _createBlock(_component_var_icon, {
|
|
22
|
+
key: 0,
|
|
23
|
+
"var-action-sheet-cover": "",
|
|
24
|
+
class: _normalizeClass(_ctx.n("action-icon")),
|
|
25
|
+
namespace: _ctx.namespace,
|
|
26
|
+
name: _ctx.icon,
|
|
27
|
+
size: _ctx.iconSize
|
|
28
|
+
}, null, 8, ["class", "namespace", "name", "size"])) : _createCommentVNode("v-if", true),
|
|
29
|
+
_createElementVNode(
|
|
30
|
+
"div",
|
|
31
|
+
{
|
|
32
|
+
class: _normalizeClass(_ctx.n("action-name"))
|
|
33
|
+
},
|
|
34
|
+
_toDisplayString(_ctx.name),
|
|
35
|
+
3
|
|
36
|
+
/* TEXT, CLASS */
|
|
37
|
+
),
|
|
38
|
+
_createVNode(_component_var_hover_overlay, {
|
|
39
|
+
hovering: _ctx.disabled ? false : _ctx.hovering
|
|
40
|
+
}, null, 8, ["hovering"])
|
|
41
|
+
],
|
|
42
|
+
6
|
|
43
|
+
/* CLASS, STYLE */
|
|
44
|
+
)), [
|
|
45
|
+
[_directive_ripple, { disabled: _ctx.disabled }],
|
|
46
|
+
[_directive_hover, _ctx.handleHovering, "desktop"]
|
|
47
|
+
]);
|
|
48
|
+
}
|
|
49
|
+
const __sfc__ = defineComponent({
|
|
50
|
+
name,
|
|
51
|
+
components: {
|
|
52
|
+
VarHoverOverlay,
|
|
53
|
+
VarIcon
|
|
54
|
+
},
|
|
55
|
+
directives: { Ripple, Hover },
|
|
56
|
+
props: {
|
|
57
|
+
name: String,
|
|
58
|
+
className: String,
|
|
59
|
+
disabled: Boolean,
|
|
60
|
+
color: String,
|
|
61
|
+
namespace: String,
|
|
62
|
+
iconSize: [String, Number],
|
|
63
|
+
icon: String
|
|
64
|
+
},
|
|
65
|
+
setup() {
|
|
66
|
+
const { hovering, handleHovering } = useHoverOverlay();
|
|
67
|
+
return {
|
|
68
|
+
hovering,
|
|
69
|
+
n,
|
|
70
|
+
classes,
|
|
71
|
+
handleHovering
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
__sfc__.render = __render__;
|
|
76
|
+
var stdin_default = __sfc__;
|
|
77
|
+
export {
|
|
78
|
+
stdin_default as default
|
|
79
|
+
};
|
|
File without changes
|
|
@@ -1,39 +1,37 @@
|
|
|
1
1
|
import Ripple from "../ripple/index.mjs";
|
|
2
2
|
import VarPopup from "../popup/index.mjs";
|
|
3
|
-
import
|
|
4
|
-
import { defineComponent
|
|
3
|
+
import VarActionItem from "./ActionItem.mjs";
|
|
4
|
+
import { defineComponent } from "vue";
|
|
5
5
|
import { props } from "./props.mjs";
|
|
6
6
|
import { t } from "../locale/index.mjs";
|
|
7
7
|
import { createNamespace } from "../utils/components.mjs";
|
|
8
8
|
import { call } from "@varlet/shared";
|
|
9
|
+
import { useVModel } from "@varlet/use";
|
|
9
10
|
const { name, n, classes } = createNamespace("action-sheet");
|
|
10
|
-
import { renderSlot as _renderSlot, toDisplayString as _toDisplayString, normalizeClass as _normalizeClass, createElementVNode as _createElementVNode, renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, resolveComponent as _resolveComponent, createBlock as _createBlock,
|
|
11
|
-
const _withScopeId = (n2) => (_pushScopeId(""), n2 = n2(), _popScopeId(), n2);
|
|
12
|
-
const _hoisted_1 = ["onClick"];
|
|
11
|
+
import { renderSlot as _renderSlot, toDisplayString as _toDisplayString, normalizeClass as _normalizeClass, createElementVNode as _createElementVNode, renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, resolveComponent as _resolveComponent, createBlock as _createBlock, mergeProps as _mergeProps, withCtx as _withCtx } from "vue";
|
|
13
12
|
function __render__(_ctx, _cache) {
|
|
14
|
-
const
|
|
13
|
+
const _component_var_action_item = _resolveComponent("var-action-item");
|
|
15
14
|
const _component_var_popup = _resolveComponent("var-popup");
|
|
16
|
-
|
|
17
|
-
return _openBlock(), _createBlock(_component_var_popup, _mergeProps({
|
|
18
|
-
class: _ctx.n("popup-radius"),
|
|
15
|
+
return _openBlock(), _createBlock(_component_var_popup, {
|
|
19
16
|
position: "bottom",
|
|
20
|
-
|
|
17
|
+
class: _normalizeClass(_ctx.n("popup-radius")),
|
|
21
18
|
overlay: _ctx.overlay,
|
|
22
19
|
"overlay-class": _ctx.overlayClass,
|
|
23
20
|
"overlay-style": _ctx.overlayStyle,
|
|
24
21
|
"lock-scroll": _ctx.lockScroll,
|
|
25
22
|
"close-on-click-overlay": _ctx.closeOnClickOverlay,
|
|
23
|
+
"close-on-key-escape": _ctx.closeOnKeyEscape,
|
|
26
24
|
teleport: _ctx.teleport,
|
|
27
|
-
"safe-area": _ctx.safeArea
|
|
28
|
-
|
|
29
|
-
"onUpdate:show": _ctx.
|
|
30
|
-
}, {
|
|
25
|
+
"safe-area": _ctx.safeArea,
|
|
26
|
+
show: _ctx.show,
|
|
27
|
+
"onUpdate:show": _cache[0] || (_cache[0] = ($event) => _ctx.show = $event),
|
|
31
28
|
onOpen: _ctx.onOpen,
|
|
32
29
|
onClose: _ctx.onClose,
|
|
33
30
|
onClosed: _ctx.onClosed,
|
|
34
31
|
onOpened: _ctx.onOpened,
|
|
35
|
-
onRouteChange: _ctx.onRouteChange
|
|
36
|
-
|
|
32
|
+
onRouteChange: _ctx.onRouteChange,
|
|
33
|
+
onKeyEscape: _ctx.onKeyEscape
|
|
34
|
+
}, {
|
|
37
35
|
default: _withCtx(() => [
|
|
38
36
|
_createElementVNode(
|
|
39
37
|
"div",
|
|
@@ -60,32 +58,16 @@ function __render__(_ctx, _cache) {
|
|
|
60
58
|
_Fragment,
|
|
61
59
|
null,
|
|
62
60
|
_renderList(_ctx.actions, (action) => {
|
|
63
|
-
return
|
|
64
|
-
class: _normalizeClass(_ctx.classes(_ctx.n("action-item"), action.className, [action.disabled, _ctx.n("--disabled")])),
|
|
61
|
+
return _openBlock(), _createBlock(_component_var_action_item, {
|
|
65
62
|
key: action.name,
|
|
66
|
-
|
|
63
|
+
name: action.name,
|
|
64
|
+
namespace: action.namespace,
|
|
65
|
+
icon: action.icon,
|
|
66
|
+
"icon-size": action.iconSize,
|
|
67
|
+
"class-name": action.className,
|
|
68
|
+
color: action.color,
|
|
67
69
|
onClick: ($event) => _ctx.handleSelect(action)
|
|
68
|
-
}, [
|
|
69
|
-
action.icon ? (_openBlock(), _createBlock(_component_var_icon, {
|
|
70
|
-
key: 0,
|
|
71
|
-
class: _normalizeClass(_ctx.n("action-icon")),
|
|
72
|
-
"var-action-sheet-cover": "",
|
|
73
|
-
namespace: action.namespace,
|
|
74
|
-
name: action.icon,
|
|
75
|
-
size: action.iconSize
|
|
76
|
-
}, null, 8, ["class", "namespace", "name", "size"])) : _createCommentVNode("v-if", true),
|
|
77
|
-
_createElementVNode(
|
|
78
|
-
"div",
|
|
79
|
-
{
|
|
80
|
-
class: _normalizeClass(_ctx.n("action-name"))
|
|
81
|
-
},
|
|
82
|
-
_toDisplayString(action.name),
|
|
83
|
-
3
|
|
84
|
-
/* TEXT, CLASS */
|
|
85
|
-
)
|
|
86
|
-
], 14, _hoisted_1)), [
|
|
87
|
-
[_directive_ripple, { disabled: action.disabled }]
|
|
88
|
-
]);
|
|
70
|
+
}, null, 8, ["name", "namespace", "icon", "icon-size", "class-name", "color", "onClick"]);
|
|
89
71
|
}),
|
|
90
72
|
128
|
|
91
73
|
/* KEYED_FRAGMENT */
|
|
@@ -98,43 +80,34 @@ function __render__(_ctx, _cache) {
|
|
|
98
80
|
]),
|
|
99
81
|
_: 3
|
|
100
82
|
/* FORWARDED */
|
|
101
|
-
},
|
|
83
|
+
}, 8, ["class", "overlay", "overlay-class", "overlay-style", "lock-scroll", "close-on-click-overlay", "close-on-key-escape", "teleport", "safe-area", "show", "onOpen", "onClose", "onClosed", "onOpened", "onRouteChange", "onKeyEscape"]);
|
|
102
84
|
}
|
|
103
85
|
const __sfc__ = defineComponent({
|
|
104
86
|
name,
|
|
105
87
|
directives: { Ripple },
|
|
106
88
|
components: {
|
|
107
89
|
VarPopup,
|
|
108
|
-
|
|
90
|
+
VarActionItem
|
|
109
91
|
},
|
|
110
92
|
inheritAttrs: false,
|
|
111
93
|
props,
|
|
112
94
|
setup(props2) {
|
|
113
|
-
const
|
|
114
|
-
watch(
|
|
115
|
-
() => props2.show,
|
|
116
|
-
(newValue) => {
|
|
117
|
-
popupShow.value = newValue;
|
|
118
|
-
},
|
|
119
|
-
{ immediate: true }
|
|
120
|
-
);
|
|
95
|
+
const show = useVModel(props2, "show");
|
|
121
96
|
function handleSelect(action) {
|
|
122
97
|
if (action.disabled) {
|
|
123
98
|
return;
|
|
124
99
|
}
|
|
125
100
|
const { closeOnClickAction, onSelect } = props2;
|
|
126
101
|
call(onSelect, action);
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
call(props2["onUpdate:show"], value);
|
|
102
|
+
if (closeOnClickAction) {
|
|
103
|
+
show.value = false;
|
|
104
|
+
}
|
|
131
105
|
}
|
|
132
106
|
return {
|
|
133
|
-
|
|
107
|
+
show,
|
|
134
108
|
t,
|
|
135
109
|
n,
|
|
136
110
|
classes,
|
|
137
|
-
handlePopupUpdateShow,
|
|
138
111
|
handleSelect
|
|
139
112
|
};
|
|
140
113
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
:root { --action-sheet-border-radius: 2px; --action-sheet-border-top: none; --action-sheet-title-color: #888; --action-sheet-title-padding: 10px 16px; --action-sheet-title-font-size: 14px; --action-sheet-action-item-height: 48px; --action-sheet-action-item-padding: 0 18px; --action-sheet-action-item-color: #333; --action-sheet-action-item-disabled-color: var(--color-text-disabled); --action-sheet-icon-margin: 0 20px 0 0; --action-sheet-icon-size: 24px; --action-sheet-background: #fff;}.var-action-sheet { padding: 10px 0; background: var(--action-sheet-background); transition: background-color 0.25s;}.var-action-sheet__popup-radius { border-radius: var(--action-sheet-border-radius); border-top: var(--action-sheet-border-top);}.var-action-sheet__title { padding: var(--action-sheet-title-padding); color: var(--action-sheet-title-color); font-size: var(--action-sheet-title-font-size);}.var-action-sheet__action-item { display: flex; align-items: center; height: var(--action-sheet-action-item-height); padding: var(--action-sheet-action-item-padding); color: var(--action-sheet-action-item-color); cursor: pointer;}.var-action-sheet__action-name { overflow: auto; max-height: var(--action-sheet-action-item-height);}.var-action-sheet__action-icon[var-action-sheet-cover] { margin: var(--action-sheet-icon-margin); width: var(--action-sheet-icon-size); height: var(--action-sheet-icon-size); font-size: var(--action-sheet-icon-size);}.var-action-sheet--disabled { color: var(--action-sheet-action-item-disabled-color) !important; cursor: not-allowed;}
|
|
1
|
+
:root { --action-sheet-border-radius: 2px; --action-sheet-border-top: none; --action-sheet-title-color: #888; --action-sheet-title-padding: 10px 16px; --action-sheet-title-font-size: 14px; --action-sheet-action-item-height: 48px; --action-sheet-action-item-padding: 0 18px; --action-sheet-action-item-color: #333; --action-sheet-action-item-disabled-color: var(--color-text-disabled); --action-sheet-icon-margin: 0 20px 0 0; --action-sheet-icon-size: 24px; --action-sheet-background: #fff;}.var-action-sheet { padding: 10px 0; background: var(--action-sheet-background); transition: background-color 0.25s;}.var-action-sheet__popup-radius { border-radius: var(--action-sheet-border-radius); border-top: var(--action-sheet-border-top);}.var-action-sheet__title { padding: var(--action-sheet-title-padding); color: var(--action-sheet-title-color); font-size: var(--action-sheet-title-font-size);}.var-action-sheet__action-item { display: flex; align-items: center; height: var(--action-sheet-action-item-height); padding: var(--action-sheet-action-item-padding); color: var(--action-sheet-action-item-color); cursor: pointer; position: relative;}.var-action-sheet__action-name { overflow: auto; max-height: var(--action-sheet-action-item-height);}.var-action-sheet__action-icon[var-action-sheet-cover] { margin: var(--action-sheet-icon-margin); width: var(--action-sheet-icon-size); height: var(--action-sheet-icon-size); font-size: var(--action-sheet-icon-size);}.var-action-sheet--disabled { color: var(--action-sheet-action-item-disabled-color) !important; cursor: not-allowed;}
|
package/es/button/Button.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { computed, defineComponent, ref } from "vue";
|
|
|
6
6
|
import { props } from "./props.mjs";
|
|
7
7
|
import { createNamespace, formatElevation } from "../utils/components.mjs";
|
|
8
8
|
import { useButtonGroup } from "./provide.mjs";
|
|
9
|
-
import { isArray, call
|
|
9
|
+
import { isArray, call } from "@varlet/shared";
|
|
10
10
|
const { name, n, classes } = createNamespace("button");
|
|
11
11
|
import { resolveComponent as _resolveComponent, normalizeClass as _normalizeClass, openBlock as _openBlock, createBlock as _createBlock, createCommentVNode as _createCommentVNode, renderSlot as _renderSlot, createElementVNode as _createElementVNode, createVNode as _createVNode, normalizeStyle as _normalizeStyle, resolveDirective as _resolveDirective, createElementBlock as _createElementBlock, withDirectives as _withDirectives, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
|
|
12
12
|
const _withScopeId = (n2) => (_pushScopeId(""), n2 = n2(), _popScopeId(), n2);
|
|
@@ -42,8 +42,8 @@ function __render__(_ctx, _cache) {
|
|
|
42
42
|
disabled: _ctx.disabled,
|
|
43
43
|
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.handleClick && _ctx.handleClick(...args)),
|
|
44
44
|
onTouchstart: _cache[1] || (_cache[1] = (...args) => _ctx.handleTouchstart && _ctx.handleTouchstart(...args)),
|
|
45
|
-
onFocus: _cache[2] || (_cache[2] = ($event) => _ctx.
|
|
46
|
-
onBlur: _cache[3] || (_cache[3] = ($event) => _ctx.
|
|
45
|
+
onFocus: _cache[2] || (_cache[2] = ($event) => _ctx.isFocusing = true),
|
|
46
|
+
onBlur: _cache[3] || (_cache[3] = ($event) => _ctx.isFocusing = false)
|
|
47
47
|
}, [
|
|
48
48
|
_ctx.loading || _ctx.pending ? (_openBlock(), _createBlock(_component_var_loading, {
|
|
49
49
|
key: 0,
|
|
@@ -67,7 +67,7 @@ function __render__(_ctx, _cache) {
|
|
|
67
67
|
),
|
|
68
68
|
_createVNode(_component_var_hover_overlay, {
|
|
69
69
|
hovering: _ctx.disabled || _ctx.loading || _ctx.pending ? false : _ctx.hovering,
|
|
70
|
-
focusing: _ctx.disabled || _ctx.loading || _ctx.pending ? false : _ctx.
|
|
70
|
+
focusing: _ctx.disabled || _ctx.loading || _ctx.pending ? false : _ctx.isFocusing
|
|
71
71
|
}, null, 8, ["hovering", "focusing"])
|
|
72
72
|
], 46, _hoisted_1)), [
|
|
73
73
|
[_directive_ripple, { disabled: _ctx.disabled || !_ctx.ripple || _ctx.loading || _ctx.pending }],
|
|
@@ -83,7 +83,7 @@ const __sfc__ = defineComponent({
|
|
|
83
83
|
directives: { Ripple, Hover },
|
|
84
84
|
props,
|
|
85
85
|
setup(props2) {
|
|
86
|
-
const
|
|
86
|
+
const isFocusing = ref(false);
|
|
87
87
|
const pending = ref(false);
|
|
88
88
|
const { buttonGroup } = useButtonGroup();
|
|
89
89
|
const { hovering, handleHovering } = useHoverOverlay();
|
|
@@ -146,7 +146,7 @@ const __sfc__ = defineComponent({
|
|
|
146
146
|
handleHovering,
|
|
147
147
|
handleClick,
|
|
148
148
|
handleTouchstart,
|
|
149
|
-
|
|
149
|
+
isFocusing
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
152
|
});
|
package/es/checkbox/Checkbox.mjs
CHANGED
|
@@ -8,10 +8,12 @@ import { props } from "./props.mjs";
|
|
|
8
8
|
import { useValidation, createNamespace } from "../utils/components.mjs";
|
|
9
9
|
import { useCheckboxGroup } from "./provide.mjs";
|
|
10
10
|
import { useForm } from "../form/provide.mjs";
|
|
11
|
-
import { call } from "@varlet/shared";
|
|
12
|
-
import { useVModel } from "@varlet/use";
|
|
11
|
+
import { call, preventDefault } from "@varlet/shared";
|
|
12
|
+
import { useEventListener, useVModel } from "@varlet/use";
|
|
13
13
|
const { name, n, classes } = createNamespace("checkbox");
|
|
14
|
-
import { renderSlot as _renderSlot, resolveComponent as _resolveComponent, normalizeClass as _normalizeClass, createVNode as _createVNode, createCommentVNode as _createCommentVNode, normalizeStyle as _normalizeStyle, resolveDirective as _resolveDirective, openBlock as _openBlock, createElementBlock as _createElementBlock, withDirectives as _withDirectives, createElementVNode as _createElementVNode } from "vue";
|
|
14
|
+
import { renderSlot as _renderSlot, resolveComponent as _resolveComponent, normalizeClass as _normalizeClass, createVNode as _createVNode, createCommentVNode as _createCommentVNode, normalizeStyle as _normalizeStyle, resolveDirective as _resolveDirective, openBlock as _openBlock, createElementBlock as _createElementBlock, withDirectives as _withDirectives, createElementVNode as _createElementVNode, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
|
|
15
|
+
const _withScopeId = (n2) => (_pushScopeId(""), n2 = n2(), _popScopeId(), n2);
|
|
16
|
+
const _hoisted_1 = ["tabindex"];
|
|
15
17
|
function __render__(_ctx, _cache) {
|
|
16
18
|
const _component_var_icon = _resolveComponent("var-icon");
|
|
17
19
|
const _component_var_hover_overlay = _resolveComponent("var-hover-overlay");
|
|
@@ -22,7 +24,7 @@ function __render__(_ctx, _cache) {
|
|
|
22
24
|
"div",
|
|
23
25
|
{
|
|
24
26
|
class: _normalizeClass(_ctx.n("wrap")),
|
|
25
|
-
onClick: _cache[
|
|
27
|
+
onClick: _cache[2] || (_cache[2] = (...args) => _ctx.handleClick && _ctx.handleClick(...args))
|
|
26
28
|
},
|
|
27
29
|
[
|
|
28
30
|
_createElementVNode(
|
|
@@ -31,51 +33,50 @@ function __render__(_ctx, _cache) {
|
|
|
31
33
|
class: _normalizeClass(_ctx.n())
|
|
32
34
|
},
|
|
33
35
|
[
|
|
34
|
-
_withDirectives((_openBlock(), _createElementBlock(
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
_ctx.
|
|
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
|
-
)), [
|
|
36
|
+
_withDirectives((_openBlock(), _createElementBlock("div", {
|
|
37
|
+
ref: "action",
|
|
38
|
+
class: _normalizeClass(
|
|
39
|
+
_ctx.classes(
|
|
40
|
+
_ctx.n("action"),
|
|
41
|
+
[_ctx.checked || _ctx.isIndeterminate, _ctx.n("--checked"), _ctx.n("--unchecked")],
|
|
42
|
+
[_ctx.errorMessage || _ctx.checkboxGroupErrorMessage, _ctx.n("--error")],
|
|
43
|
+
[_ctx.formDisabled || _ctx.disabled, _ctx.n("--disabled")]
|
|
44
|
+
)
|
|
45
|
+
),
|
|
46
|
+
style: _normalizeStyle({ color: _ctx.checked || _ctx.isIndeterminate ? _ctx.checkedColor : _ctx.uncheckedColor }),
|
|
47
|
+
tabindex: _ctx.disabled || _ctx.formDisabled ? void 0 : "0",
|
|
48
|
+
onFocus: _cache[0] || (_cache[0] = ($event) => _ctx.isFocusing = true),
|
|
49
|
+
onBlur: _cache[1] || (_cache[1] = ($event) => _ctx.isFocusing = false)
|
|
50
|
+
}, [
|
|
51
|
+
_ctx.isIndeterminate ? _renderSlot(_ctx.$slots, "indeterminate-icon", { key: 0 }, () => [
|
|
52
|
+
_createVNode(_component_var_icon, {
|
|
53
|
+
class: _normalizeClass(_ctx.classes(_ctx.n("icon"), [_ctx.withAnimation, _ctx.n("--with-animation")])),
|
|
54
|
+
name: "minus-box",
|
|
55
|
+
size: _ctx.iconSize,
|
|
56
|
+
"var-checkbox-cover": ""
|
|
57
|
+
}, null, 8, ["class", "size"])
|
|
58
|
+
]) : _createCommentVNode("v-if", true),
|
|
59
|
+
_ctx.checked && !_ctx.isIndeterminate ? _renderSlot(_ctx.$slots, "checked-icon", { key: 1 }, () => [
|
|
60
|
+
_createVNode(_component_var_icon, {
|
|
61
|
+
class: _normalizeClass(_ctx.classes(_ctx.n("icon"), [_ctx.withAnimation, _ctx.n("--with-animation")])),
|
|
62
|
+
name: "checkbox-marked",
|
|
63
|
+
size: _ctx.iconSize,
|
|
64
|
+
"var-checkbox-cover": ""
|
|
65
|
+
}, null, 8, ["class", "size"])
|
|
66
|
+
]) : _createCommentVNode("v-if", true),
|
|
67
|
+
!_ctx.checked && !_ctx.isIndeterminate ? _renderSlot(_ctx.$slots, "unchecked-icon", { key: 2 }, () => [
|
|
68
|
+
_createVNode(_component_var_icon, {
|
|
69
|
+
class: _normalizeClass(_ctx.classes(_ctx.n("icon"), [_ctx.withAnimation, _ctx.n("--with-animation")])),
|
|
70
|
+
name: "checkbox-blank-outline",
|
|
71
|
+
size: _ctx.iconSize,
|
|
72
|
+
"var-checkbox-cover": ""
|
|
73
|
+
}, null, 8, ["class", "size"])
|
|
74
|
+
]) : _createCommentVNode("v-if", true),
|
|
75
|
+
_createVNode(_component_var_hover_overlay, {
|
|
76
|
+
hovering: !_ctx.disabled && !_ctx.formDisabled && _ctx.hovering,
|
|
77
|
+
focusing: !_ctx.disabled && !_ctx.formDisabled && _ctx.isFocusing
|
|
78
|
+
}, null, 8, ["hovering", "focusing"])
|
|
79
|
+
], 46, _hoisted_1)), [
|
|
79
80
|
[_directive_hover, _ctx.handleHovering, "desktop"],
|
|
80
81
|
[_directive_ripple, { disabled: _ctx.formReadonly || _ctx.readonly || _ctx.formDisabled || _ctx.disabled || !_ctx.ripple }]
|
|
81
82
|
]),
|
|
@@ -117,6 +118,8 @@ const __sfc__ = defineComponent({
|
|
|
117
118
|
},
|
|
118
119
|
props,
|
|
119
120
|
setup(props2) {
|
|
121
|
+
const action = ref(null);
|
|
122
|
+
const isFocusing = ref(false);
|
|
120
123
|
const value = useVModel(props2, "modelValue");
|
|
121
124
|
const isIndeterminate = useVModel(props2, "indeterminate");
|
|
122
125
|
const checked = computed(() => value.value === props2.checkedValue);
|
|
@@ -192,10 +195,35 @@ const __sfc__ = defineComponent({
|
|
|
192
195
|
}
|
|
193
196
|
change(changedValue);
|
|
194
197
|
}
|
|
198
|
+
useEventListener(() => window, "keydown", handleKeydown);
|
|
199
|
+
useEventListener(() => window, "keyup", handleKeyup);
|
|
200
|
+
function handleKeydown(event) {
|
|
201
|
+
if (!isFocusing.value) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
const { key } = event;
|
|
205
|
+
if (key === "Enter" || key === " ") {
|
|
206
|
+
preventDefault(event);
|
|
207
|
+
}
|
|
208
|
+
if (key === "Enter") {
|
|
209
|
+
action.value.click();
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
function handleKeyup(event) {
|
|
213
|
+
if (!isFocusing.value) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
if (event.key === " ") {
|
|
217
|
+
preventDefault(event);
|
|
218
|
+
action.value.click();
|
|
219
|
+
}
|
|
220
|
+
}
|
|
195
221
|
function validate() {
|
|
196
222
|
return v(props2.rules, props2.modelValue);
|
|
197
223
|
}
|
|
198
224
|
return {
|
|
225
|
+
action,
|
|
226
|
+
isFocusing,
|
|
199
227
|
isIndeterminate,
|
|
200
228
|
withAnimation,
|
|
201
229
|
checked,
|
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;}@keyframes var-vibrate-animation { 0% { opacity: 1; transform: scale(1); } 50% { opacity: 0.8; transform: scale(0.8); } 100% { opacity: 1; transform: scale(1); }}.var-checkbox { display: flex; align-items: center; transform: translateX(calc(-1 * var(--checkbox-action-padding))); cursor: pointer; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);}.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;}.var-checkbox__icon[var-checkbox-cover] { display: block; font-size: var(--checkbox-icon-size);}.var-checkbox__text { color: var(--checkbox-text-color);}.var-checkbox--with-animation { animation: var-vibrate-animation 0.25s;}.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);}
|
|
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;}@keyframes var-vibrate-animation { 0% { opacity: 1; transform: scale(1); } 50% { opacity: 0.8; transform: scale(0.8); } 100% { opacity: 1; transform: scale(1); }}.var-checkbox { display: flex; align-items: center; transform: translateX(calc(-1 * var(--checkbox-action-padding))); cursor: pointer; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);}.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--with-animation { animation: var-vibrate-animation 0.25s;}.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);}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { getCurrentInstance, watch } from "vue";
|
|
2
|
+
import { removeItem } from "@varlet/shared";
|
|
3
|
+
import { onSmartUnmounted, onSmartMounted } from "@varlet/use";
|
|
4
|
+
const stack = [];
|
|
5
|
+
function useStack(activeGetter, zIndex) {
|
|
6
|
+
const { uid } = getCurrentInstance();
|
|
7
|
+
watch(activeGetter, (isActive) => {
|
|
8
|
+
if (isActive && !getStackItem(uid)) {
|
|
9
|
+
pushStackItem();
|
|
10
|
+
} else {
|
|
11
|
+
setTimeout(() => {
|
|
12
|
+
removeItem(stack, getStackItem(uid));
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
onSmartMounted(() => {
|
|
17
|
+
if (activeGetter()) {
|
|
18
|
+
pushStackItem();
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
onSmartUnmounted(() => {
|
|
22
|
+
removeItem(stack, getStackItem(uid));
|
|
23
|
+
});
|
|
24
|
+
function onStackTop() {
|
|
25
|
+
if (stack.length === 0) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
stack.sort((a, b) => a.zIndex.value - b.zIndex.value);
|
|
29
|
+
return stack[stack.length - 1].uid === uid;
|
|
30
|
+
}
|
|
31
|
+
function pushStackItem() {
|
|
32
|
+
if (getStackItem(uid)) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
stack.push({ uid, zIndex });
|
|
36
|
+
}
|
|
37
|
+
function getStackItem(uid2) {
|
|
38
|
+
return stack.find((item) => item.uid === uid2);
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
onStackTop
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
useStack
|
|
46
|
+
};
|
package/es/dialog/Dialog.mjs
CHANGED
|
@@ -36,11 +36,13 @@ function __render__(_ctx, _cache) {
|
|
|
36
36
|
"overlay-style": _ctx.overlayStyle,
|
|
37
37
|
"lock-scroll": _ctx.lockScroll,
|
|
38
38
|
"close-on-click-overlay": _ctx.popupCloseOnClickOverlay,
|
|
39
|
+
"close-on-key-escape": false,
|
|
39
40
|
teleport: _ctx.teleport,
|
|
40
41
|
onOpen: _ctx.onOpen,
|
|
41
42
|
onClose: _ctx.onClose,
|
|
42
43
|
onClosed: _ctx.onClosed,
|
|
43
44
|
onOpened: _ctx.onOpened,
|
|
45
|
+
onKeyEscape: _ctx.handleKeyEscape,
|
|
44
46
|
onRouteChange: _ctx.onRouteChange,
|
|
45
47
|
onClickOverlay: _ctx.handleClickOverlay
|
|
46
48
|
}, {
|
|
@@ -151,7 +153,7 @@ function __render__(_ctx, _cache) {
|
|
|
151
153
|
]),
|
|
152
154
|
_: 3
|
|
153
155
|
/* FORWARDED */
|
|
154
|
-
}, 8, ["class", "show", "overlay", "overlay-class", "overlay-style", "lock-scroll", "close-on-click-overlay", "teleport", "onOpen", "onClose", "onClosed", "onOpened", "onRouteChange", "onClickOverlay"]);
|
|
156
|
+
}, 8, ["class", "show", "overlay", "overlay-class", "overlay-style", "lock-scroll", "close-on-click-overlay", "teleport", "onOpen", "onClose", "onClosed", "onOpened", "onKeyEscape", "onRouteChange", "onClickOverlay"]);
|
|
155
157
|
}
|
|
156
158
|
const __sfc__ = defineComponent({
|
|
157
159
|
name,
|
|
@@ -215,6 +217,13 @@ const __sfc__ = defineComponent({
|
|
|
215
217
|
}
|
|
216
218
|
call(props2["onUpdate:show"], false);
|
|
217
219
|
}
|
|
220
|
+
function handleKeyEscape() {
|
|
221
|
+
call(props2.onKeyEscape);
|
|
222
|
+
if (!props2.closeOnKeyEscape) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
cancel();
|
|
226
|
+
}
|
|
218
227
|
return {
|
|
219
228
|
t,
|
|
220
229
|
popupShow,
|
|
@@ -224,7 +233,8 @@ const __sfc__ = defineComponent({
|
|
|
224
233
|
handleClickOverlay,
|
|
225
234
|
confirm,
|
|
226
235
|
cancel,
|
|
227
|
-
toSizeUnit
|
|
236
|
+
toSizeUnit,
|
|
237
|
+
handleKeyEscape
|
|
228
238
|
};
|
|
229
239
|
}
|
|
230
240
|
});
|
package/es/dialog/props.mjs
CHANGED
|
@@ -23,7 +23,7 @@ function __render__(_ctx, _cache) {
|
|
|
23
23
|
class: _normalizeClass(
|
|
24
24
|
_ctx.classes(
|
|
25
25
|
_ctx.n("controller"),
|
|
26
|
-
[_ctx.
|
|
26
|
+
[_ctx.isFocusing, _ctx.n("--focus")],
|
|
27
27
|
[_ctx.errorMessage, _ctx.n("--error")],
|
|
28
28
|
[_ctx.formDisabled || _ctx.disabled, _ctx.n("--disabled")]
|
|
29
29
|
)
|
|
@@ -67,7 +67,7 @@ function __render__(_ctx, _cache) {
|
|
|
67
67
|
_ctx.classes(
|
|
68
68
|
_ctx.n("placeholder"),
|
|
69
69
|
_ctx.n("$--ellipsis"),
|
|
70
|
-
[_ctx.
|
|
70
|
+
[_ctx.isFocusing, _ctx.n("--focus")],
|
|
71
71
|
[_ctx.hintCenter, _ctx.n("--hint-center")],
|
|
72
72
|
[_ctx.formDisabled || _ctx.disabled, _ctx.n("--disabled")],
|
|
73
73
|
[_ctx.errorMessage, _ctx.n("--error")],
|
|
@@ -94,7 +94,10 @@ function __render__(_ctx, _cache) {
|
|
|
94
94
|
class: _normalizeClass(_ctx.classes(_ctx.n("icon"), [!_ctx.hint, _ctx.n("--icon-non-hint")]))
|
|
95
95
|
},
|
|
96
96
|
[
|
|
97
|
-
_ctx.clearable && !_ctx.isEmpty(_ctx.value) ? _renderSlot(_ctx.$slots, "clear-icon", {
|
|
97
|
+
_ctx.clearable && !_ctx.isEmpty(_ctx.value) ? _renderSlot(_ctx.$slots, "clear-icon", {
|
|
98
|
+
key: 0,
|
|
99
|
+
clear: _ctx.handleClear
|
|
100
|
+
}, () => [
|
|
98
101
|
_createVNode(_component_var_icon, {
|
|
99
102
|
class: _normalizeClass(_ctx.n("clear-icon")),
|
|
100
103
|
"var-field-decorator-cover": "",
|
|
@@ -122,7 +125,7 @@ function __render__(_ctx, _cache) {
|
|
|
122
125
|
class: _normalizeClass(
|
|
123
126
|
_ctx.classes(
|
|
124
127
|
_ctx.n("line"),
|
|
125
|
-
[_ctx.
|
|
128
|
+
[_ctx.isFocusing, _ctx.n("--line-focus")],
|
|
126
129
|
[_ctx.errorMessage, _ctx.n("--line-error")],
|
|
127
130
|
[_ctx.formDisabled || _ctx.disabled, _ctx.n("--line-disabled")]
|
|
128
131
|
)
|
|
@@ -175,7 +178,7 @@ function __render__(_ctx, _cache) {
|
|
|
175
178
|
class: _normalizeClass(
|
|
176
179
|
_ctx.classes(
|
|
177
180
|
_ctx.n("dot"),
|
|
178
|
-
[_ctx.
|
|
181
|
+
[_ctx.isFocusing, _ctx.n("--line-focus")],
|
|
179
182
|
[_ctx.formDisabled || _ctx.disabled, _ctx.n("--line-disabled")],
|
|
180
183
|
[_ctx.errorMessage, _ctx.n("--line-error")]
|
|
181
184
|
)
|
|
@@ -211,9 +214,9 @@ const __sfc__ = defineComponent({
|
|
|
211
214
|
const middleOffsetWidth = ref("0px");
|
|
212
215
|
const middleOffsetHeight = ref("0px");
|
|
213
216
|
const transitionDisabled = ref(true);
|
|
214
|
-
const isFloating = computed(() => props2.hint && (!isEmpty(props2.value) || props2.
|
|
217
|
+
const isFloating = computed(() => props2.hint && (!isEmpty(props2.value) || props2.isFocusing));
|
|
215
218
|
const color = computed(
|
|
216
|
-
() => !props2.errorMessage ? props2.
|
|
219
|
+
() => !props2.errorMessage ? props2.isFocusing ? props2.focusColor : props2.blurColor : void 0
|
|
217
220
|
);
|
|
218
221
|
onWindowResize(resize);
|
|
219
222
|
onSmartMounted(() => {
|