@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.
Files changed (70) hide show
  1. package/es/action-sheet/ActionItem.mjs +79 -0
  2. package/es/action-sheet/ActionItemSfc.css +0 -0
  3. package/es/action-sheet/ActionSheet.mjs +29 -56
  4. package/es/action-sheet/actionSheet.css +1 -1
  5. package/es/action-sheet/props.mjs +3 -1
  6. package/es/action-sheet/style/index.mjs +1 -0
  7. package/es/button/Button.mjs +6 -6
  8. package/es/checkbox/Checkbox.mjs +83 -50
  9. package/es/checkbox/checkbox.css +1 -1
  10. package/es/context/stack.mjs +46 -0
  11. package/es/dialog/Dialog.mjs +12 -2
  12. package/es/dialog/props.mjs +4 -1
  13. package/es/field-decorator/FieldDecorator.mjs +10 -7
  14. package/es/field-decorator/props.mjs +1 -1
  15. package/es/hover-overlay/HoverOverlay.mjs +4 -2
  16. package/es/image-preview/ImagePreview.mjs +12 -16
  17. package/es/image-preview/props.mjs +4 -1
  18. package/es/index.bundle.mjs +1 -1
  19. package/es/index.mjs +1 -1
  20. package/es/input/Input.mjs +8 -8
  21. package/es/link/Link.mjs +10 -4
  22. package/es/link/link.css +1 -1
  23. package/es/menu/menu.css +1 -1
  24. package/es/menu/props.mjs +6 -1
  25. package/es/menu/usePopover.mjs +12 -2
  26. package/es/menu-option/MenuOption.mjs +72 -43
  27. package/es/menu-option/menuOption.css +1 -1
  28. package/es/menu-select/MenuSelect.mjs +28 -3
  29. package/es/option/Option.mjs +77 -48
  30. package/es/option/option.css +1 -1
  31. package/es/overlay/Overlay.mjs +19 -2
  32. package/es/overlay/props.mjs +7 -1
  33. package/es/paper/paper.css +1 -1
  34. package/es/picker/Picker.mjs +2 -0
  35. package/es/picker/props.mjs +4 -1
  36. package/es/popup/Popup.mjs +18 -2
  37. package/es/popup/props.mjs +7 -1
  38. package/es/radio/Radio.mjs +84 -42
  39. package/es/radio/radio.css +1 -1
  40. package/es/radio-group/RadioGroup.mjs +43 -1
  41. package/es/select/Select.mjs +279 -213
  42. package/es/select/select.css +1 -1
  43. package/es/style.css +1 -1
  44. package/es/switch/Switch.mjs +82 -52
  45. package/es/switch/switch.css +1 -1
  46. package/es/tab/tab.css +1 -1
  47. package/es/themes/dark/link.mjs +2 -1
  48. package/es/themes/dark/paper.mjs +2 -1
  49. package/es/themes/dark/tab.mjs +3 -1
  50. package/es/themes/md3-dark/link.mjs +2 -1
  51. package/es/themes/md3-dark/paper.mjs +2 -1
  52. package/es/themes/md3-dark/tab.mjs +3 -1
  53. package/es/themes/md3-light/link.mjs +2 -1
  54. package/es/themes/md3-light/paper.mjs +2 -1
  55. package/es/themes/md3-light/tab.mjs +3 -1
  56. package/es/tooltip/props.mjs +6 -1
  57. package/es/uploader/Uploader.mjs +70 -44
  58. package/es/uploader/uploader.css +1 -1
  59. package/es/utils/elements.mjs +32 -0
  60. package/es/varlet.esm.js +8014 -7704
  61. package/highlight/web-types.en-US.json +15 -2
  62. package/lib/style.css +1 -1
  63. package/lib/varlet.cjs.js +1753 -1224
  64. package/package.json +7 -7
  65. package/types/actionSheet.d.ts +4 -0
  66. package/types/input.d.ts +5 -1
  67. package/types/select.d.ts +6 -1
  68. package/types/styleVars.d.ts +100 -92
  69. package/umd/varlet.js +6 -6
  70. package/highlight/web-types.zh-CN.json +0 -8045
@@ -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 VarIcon from "../icon/index.mjs";
4
- import { defineComponent, ref, watch } from "vue";
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, createCommentVNode as _createCommentVNode, normalizeStyle as _normalizeStyle, resolveDirective as _resolveDirective, withDirectives as _withDirectives, mergeProps as _mergeProps, withCtx as _withCtx, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
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 _component_var_icon = _resolveComponent("var-icon");
13
+ const _component_var_action_item = _resolveComponent("var-action-item");
15
14
  const _component_var_popup = _resolveComponent("var-popup");
16
- const _directive_ripple = _resolveDirective("ripple");
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
- show: _ctx.popupShow,
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.handlePopupUpdateShow
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 _withDirectives((_openBlock(), _createElementBlock("div", {
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
- style: _normalizeStyle({ color: action.color }),
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
- }, 16, ["class", "show", "overlay", "overlay-class", "overlay-style", "lock-scroll", "close-on-click-overlay", "teleport", "safe-area", "onOpen", "onClose", "onClosed", "onOpened", "onRouteChange"]);
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
- VarIcon
90
+ VarActionItem
109
91
  },
110
92
  inheritAttrs: false,
111
93
  props,
112
94
  setup(props2) {
113
- const popupShow = ref(false);
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
- closeOnClickAction && call(props2["onUpdate:show"], false);
128
- }
129
- function handlePopupUpdateShow(value) {
130
- call(props2["onUpdate:show"], value);
102
+ if (closeOnClickAction) {
103
+ show.value = false;
104
+ }
131
105
  }
132
106
  return {
133
- popupShow,
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;}
@@ -35,6 +35,7 @@ const props = __spreadValues({
35
35
  "overlayStyle",
36
36
  "lockScroll",
37
37
  "closeOnClickOverlay",
38
+ "closeOnKeyEscape",
38
39
  "safeArea",
39
40
  "teleport",
40
41
  "onOpen",
@@ -43,7 +44,8 @@ const props = __spreadValues({
43
44
  "onClosed",
44
45
  "onClickOverlay",
45
46
  // internal for function call closes the dialog
46
- "onRouteChange"
47
+ "onRouteChange",
48
+ "onKeyEscape"
47
49
  ]));
48
50
  export {
49
51
  props
@@ -4,3 +4,4 @@ import '../../ripple/ripple.css'
4
4
  import '../../popup/popup.css'
5
5
  import '../actionSheet.css'
6
6
  import '../ActionSheetSfc.css'
7
+ import '../ActionItemSfc.css'
@@ -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, inMobile } from "@varlet/shared";
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.isEffectFocusing = true),
46
- onBlur: _cache[3] || (_cache[3] = ($event) => _ctx.isEffectFocusing = false)
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.isEffectFocusing
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 isEffectFocusing = inMobile() ? computed(() => false) : ref(false);
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
- isEffectFocusing
149
+ isFocusing
150
150
  };
151
151
  }
152
152
  });
@@ -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[0] || (_cache[0] = (...args) => _ctx.handleClick && _ctx.handleClick(...args))
27
+ onClick: _cache[3] || (_cache[3] = (...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
- "div",
36
- {
37
- class: _normalizeClass(
38
- _ctx.classes(
39
- _ctx.n("action"),
40
- [_ctx.checked || _ctx.isIndeterminate, _ctx.n("--checked"), _ctx.n("--unchecked")],
41
- [_ctx.errorMessage || _ctx.checkboxGroupErrorMessage, _ctx.n("--error")],
42
- [_ctx.formDisabled || _ctx.disabled, _ctx.n("--disabled")]
43
- )
44
- ),
45
- style: _normalizeStyle({ color: _ctx.checked || _ctx.isIndeterminate ? _ctx.checkedColor : _ctx.uncheckedColor })
46
- },
47
- [
48
- _ctx.isIndeterminate ? _renderSlot(_ctx.$slots, "indeterminate-icon", { key: 0 }, () => [
49
- _createVNode(_component_var_icon, {
50
- class: _normalizeClass(_ctx.classes(_ctx.n("icon"), [_ctx.withAnimation, _ctx.n("--with-animation")])),
51
- name: "minus-box",
52
- size: _ctx.iconSize,
53
- "var-checkbox-cover": ""
54
- }, null, 8, ["class", "size"])
55
- ]) : _createCommentVNode("v-if", true),
56
- _ctx.checked && !_ctx.isIndeterminate ? _renderSlot(_ctx.$slots, "checked-icon", { key: 1 }, () => [
57
- _createVNode(_component_var_icon, {
58
- class: _normalizeClass(_ctx.classes(_ctx.n("icon"), [_ctx.withAnimation, _ctx.n("--with-animation")])),
59
- name: "checkbox-marked",
60
- size: _ctx.iconSize,
61
- "var-checkbox-cover": ""
62
- }, null, 8, ["class", "size"])
63
- ]) : _createCommentVNode("v-if", true),
64
- !_ctx.checked && !_ctx.isIndeterminate ? _renderSlot(_ctx.$slots, "unchecked-icon", { key: 2 }, () => [
65
- _createVNode(_component_var_icon, {
66
- class: _normalizeClass(_ctx.classes(_ctx.n("icon"), [_ctx.withAnimation, _ctx.n("--with-animation")])),
67
- name: "checkbox-blank-outline",
68
- size: _ctx.iconSize,
69
- "var-checkbox-cover": ""
70
- }, null, 8, ["class", "size"])
71
- ]) : _createCommentVNode("v-if", true),
72
- _createVNode(_component_var_hover_overlay, {
73
- hovering: !_ctx.disabled && !_ctx.formDisabled && _ctx.hovering
74
- }, null, 8, ["hovering"])
75
- ],
76
- 6
77
- /* CLASS, STYLE */
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
  ]),
@@ -89,7 +90,8 @@ function __render__(_ctx, _cache) {
89
90
  [_ctx.errorMessage || _ctx.checkboxGroupErrorMessage, _ctx.n("--error")],
90
91
  [_ctx.formDisabled || _ctx.disabled, _ctx.n("--disabled")]
91
92
  )
92
- )
93
+ ),
94
+ onClick: _cache[2] || (_cache[2] = (...args) => _ctx.handleTextClick && _ctx.handleTextClick(...args))
93
95
  },
94
96
  [
95
97
  _renderSlot(_ctx.$slots, "default")
@@ -117,6 +119,8 @@ const __sfc__ = defineComponent({
117
119
  },
118
120
  props,
119
121
  setup(props2) {
122
+ const action = ref(null);
123
+ const isFocusing = ref(false);
120
124
  const value = useVModel(props2, "modelValue");
121
125
  const isIndeterminate = useVModel(props2, "indeterminate");
122
126
  const checked = computed(() => value.value === props2.checkedValue);
@@ -143,6 +147,8 @@ const __sfc__ = defineComponent({
143
147
  };
144
148
  call(bindCheckboxGroup, checkboxProvider);
145
149
  call(bindForm, checkboxProvider);
150
+ useEventListener(() => window, "keydown", handleKeydown);
151
+ useEventListener(() => window, "keyup", handleKeyup);
146
152
  function validateWithTrigger(trigger) {
147
153
  nextTick(() => {
148
154
  const { validateTrigger, rules, modelValue } = props2;
@@ -173,6 +179,9 @@ const __sfc__ = defineComponent({
173
179
  }
174
180
  change(checked.value ? uncheckedValue : checkedValue2);
175
181
  }
182
+ function handleTextClick() {
183
+ action.value.focus();
184
+ }
176
185
  function sync(values) {
177
186
  const { checkedValue: checkedValue2, uncheckedValue } = props2;
178
187
  value.value = values.includes(checkedValue2) ? checkedValue2 : uncheckedValue;
@@ -192,10 +201,33 @@ const __sfc__ = defineComponent({
192
201
  }
193
202
  change(changedValue);
194
203
  }
204
+ function handleKeydown(event) {
205
+ if (!isFocusing.value) {
206
+ return;
207
+ }
208
+ const { key } = event;
209
+ if (key === "Enter" || key === " ") {
210
+ preventDefault(event);
211
+ }
212
+ if (key === "Enter") {
213
+ action.value.click();
214
+ }
215
+ }
216
+ function handleKeyup(event) {
217
+ if (!isFocusing.value) {
218
+ return;
219
+ }
220
+ if (event.key === " ") {
221
+ preventDefault(event);
222
+ action.value.click();
223
+ }
224
+ }
195
225
  function validate() {
196
226
  return v(props2.rules, props2.modelValue);
197
227
  }
198
228
  return {
229
+ action,
230
+ isFocusing,
199
231
  isIndeterminate,
200
232
  withAnimation,
201
233
  checked,
@@ -208,6 +240,7 @@ const __sfc__ = defineComponent({
208
240
  classes,
209
241
  handleHovering,
210
242
  handleClick,
243
+ handleTextClick,
211
244
  toggle,
212
245
  reset,
213
246
  validate,
@@ -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
+ };
@@ -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
  });
@@ -58,7 +58,10 @@ const props = __spreadValues({
58
58
  "onClosed",
59
59
  "onClickOverlay",
60
60
  // internal for function call closes the dialog
61
- "onRouteChange"
61
+ "onRouteChange",
62
+ // internal for esc
63
+ "closeOnKeyEscape",
64
+ "onKeyEscape"
62
65
  ]));
63
66
  export {
64
67
  props