@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.
Files changed (67) 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 +4 -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 +77 -49
  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/select/Select.mjs +279 -213
  39. package/es/select/select.css +1 -1
  40. package/es/snackbar/style/index.mjs +1 -1
  41. package/es/style.css +1 -1
  42. package/es/switch/Switch.mjs +82 -52
  43. package/es/switch/switch.css +1 -1
  44. package/es/tab/tab.css +1 -1
  45. package/es/themes/dark/link.mjs +2 -1
  46. package/es/themes/dark/paper.mjs +2 -1
  47. package/es/themes/dark/tab.mjs +3 -1
  48. package/es/themes/md3-dark/link.mjs +2 -1
  49. package/es/themes/md3-dark/paper.mjs +2 -1
  50. package/es/themes/md3-dark/tab.mjs +3 -1
  51. package/es/themes/md3-light/link.mjs +2 -1
  52. package/es/themes/md3-light/paper.mjs +2 -1
  53. package/es/themes/md3-light/tab.mjs +3 -1
  54. package/es/tooltip/props.mjs +6 -1
  55. package/es/uploader/Uploader.mjs +70 -44
  56. package/es/uploader/uploader.css +1 -1
  57. package/es/utils/elements.mjs +32 -0
  58. package/es/varlet.esm.js +7721 -7457
  59. package/highlight/web-types.en-US.json +2 -2
  60. package/highlight/web-types.zh-CN.json +3 -3
  61. package/lib/style.css +1 -1
  62. package/lib/varlet.cjs.js +1527 -1084
  63. package/package.json +7 -7
  64. package/types/input.d.ts +1 -1
  65. package/types/select.d.ts +1 -0
  66. package/types/styleVars.d.ts +100 -92
  67. package/umd/varlet.js +6 -6
@@ -6,64 +6,67 @@ import { defineComponent, computed, ref, watch } from "vue";
6
6
  import { useSelect } from "./provide.mjs";
7
7
  import { createNamespace } from "../utils/components.mjs";
8
8
  import { props } from "./props.mjs";
9
+ import { preventDefault } from "@varlet/shared";
10
+ import { useEventListener } from "@varlet/use";
9
11
  const { name, n, classes } = createNamespace("option");
10
- import { normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle, createElementVNode as _createElementVNode, resolveComponent as _resolveComponent, withModifiers as _withModifiers, openBlock as _openBlock, createBlock as _createBlock, createCommentVNode as _createCommentVNode, renderSlot as _renderSlot, toDisplayString as _toDisplayString, createVNode as _createVNode, resolveDirective as _resolveDirective, createElementBlock as _createElementBlock, withDirectives as _withDirectives } from "vue";
12
+ import { normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle, createElementVNode as _createElementVNode, resolveComponent as _resolveComponent, withModifiers as _withModifiers, openBlock as _openBlock, createBlock as _createBlock, createCommentVNode as _createCommentVNode, renderSlot as _renderSlot, toDisplayString as _toDisplayString, createVNode as _createVNode, resolveDirective as _resolveDirective, createElementBlock as _createElementBlock, withDirectives as _withDirectives, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
13
+ const _withScopeId = (n2) => (_pushScopeId(""), n2 = n2(), _popScopeId(), n2);
14
+ const _hoisted_1 = ["tabindex"];
11
15
  function __render__(_ctx, _cache) {
12
16
  const _component_var_checkbox = _resolveComponent("var-checkbox");
13
17
  const _component_var_hover_overlay = _resolveComponent("var-hover-overlay");
14
18
  const _directive_ripple = _resolveDirective("ripple");
15
19
  const _directive_hover = _resolveDirective("hover");
16
- return _withDirectives((_openBlock(), _createElementBlock(
17
- "div",
18
- {
19
- class: _normalizeClass(_ctx.classes(_ctx.n(), _ctx.n("$--box"), [_ctx.optionSelected, _ctx.n("--selected-color")], [_ctx.disabled, _ctx.n("--disabled")])),
20
- style: _normalizeStyle({
21
- color: _ctx.optionSelected ? _ctx.focusColor : void 0
22
- }),
23
- onClick: _cache[2] || (_cache[2] = (...args) => _ctx.handleClick && _ctx.handleClick(...args))
24
- },
25
- [
20
+ return _withDirectives((_openBlock(), _createElementBlock("div", {
21
+ ref: "root",
22
+ class: _normalizeClass(_ctx.classes(_ctx.n(), _ctx.n("$--box"), [_ctx.optionSelected, _ctx.n("--selected-color")], [_ctx.disabled, _ctx.n("--disabled")])),
23
+ style: _normalizeStyle({
24
+ color: _ctx.optionSelected ? _ctx.focusColor : void 0
25
+ }),
26
+ tabindex: _ctx.disabled ? void 0 : "-1",
27
+ onFocus: _cache[2] || (_cache[2] = ($event) => _ctx.isFocusing = true),
28
+ onBlur: _cache[3] || (_cache[3] = ($event) => _ctx.isFocusing = false),
29
+ onClick: _cache[4] || (_cache[4] = (...args) => _ctx.handleClick && _ctx.handleClick(...args))
30
+ }, [
31
+ _createElementVNode(
32
+ "div",
33
+ {
34
+ class: _normalizeClass(_ctx.classes(_ctx.n("cover"), [_ctx.optionSelected, _ctx.n("--selected-background")])),
35
+ style: _normalizeStyle({
36
+ background: _ctx.optionSelected ? _ctx.focusColor : void 0
37
+ })
38
+ },
39
+ null,
40
+ 6
41
+ /* CLASS, STYLE */
42
+ ),
43
+ _ctx.multiple ? (_openBlock(), _createBlock(_component_var_checkbox, {
44
+ key: 0,
45
+ ref: "checkbox",
46
+ modelValue: _ctx.optionSelected,
47
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.optionSelected = $event),
48
+ "checked-color": _ctx.focusColor,
49
+ disabled: _ctx.disabled,
50
+ onClick: _cache[1] || (_cache[1] = _withModifiers(() => {
51
+ }, ["stop"])),
52
+ onChange: _ctx.handleSelect
53
+ }, null, 8, ["modelValue", "checked-color", "disabled", "onChange"])) : _createCommentVNode("v-if", true),
54
+ _renderSlot(_ctx.$slots, "default", {}, () => [
26
55
  _createElementVNode(
27
56
  "div",
28
57
  {
29
- class: _normalizeClass(_ctx.classes(_ctx.n("cover"), [_ctx.optionSelected, _ctx.n("--selected-background")])),
30
- style: _normalizeStyle({
31
- background: _ctx.optionSelected ? _ctx.focusColor : void 0
32
- })
58
+ class: _normalizeClass(_ctx.classes(_ctx.n("text"), _ctx.n("$--ellipsis")))
33
59
  },
34
- null,
35
- 6
36
- /* CLASS, STYLE */
37
- ),
38
- _ctx.multiple ? (_openBlock(), _createBlock(_component_var_checkbox, {
39
- key: 0,
40
- ref: "checkbox",
41
- modelValue: _ctx.optionSelected,
42
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.optionSelected = $event),
43
- "checked-color": _ctx.focusColor,
44
- disabled: _ctx.disabled,
45
- onClick: _cache[1] || (_cache[1] = _withModifiers(() => {
46
- }, ["stop"])),
47
- onChange: _ctx.handleSelect
48
- }, null, 8, ["modelValue", "checked-color", "disabled", "onChange"])) : _createCommentVNode("v-if", true),
49
- _renderSlot(_ctx.$slots, "default", {}, () => [
50
- _createElementVNode(
51
- "div",
52
- {
53
- class: _normalizeClass(_ctx.classes(_ctx.n("text"), _ctx.n("$--ellipsis")))
54
- },
55
- _toDisplayString(_ctx.label),
56
- 3
57
- /* TEXT, CLASS */
58
- )
59
- ]),
60
- _createVNode(_component_var_hover_overlay, {
61
- hovering: _ctx.hovering && !_ctx.disabled
62
- }, null, 8, ["hovering"])
63
- ],
64
- 6
65
- /* CLASS, STYLE */
66
- )), [
60
+ _toDisplayString(_ctx.label),
61
+ 3
62
+ /* TEXT, CLASS */
63
+ )
64
+ ]),
65
+ _createVNode(_component_var_hover_overlay, {
66
+ hovering: _ctx.hovering && !_ctx.disabled,
67
+ focusing: _ctx.isFocusing && !_ctx.disabled
68
+ }, null, 8, ["hovering", "focusing"])
69
+ ], 46, _hoisted_1)), [
67
70
  [_directive_ripple, { disabled: _ctx.disabled }],
68
71
  [_directive_hover, _ctx.handleHovering, "desktop"]
69
72
  ]);
@@ -77,6 +80,8 @@ const __sfc__ = defineComponent({
77
80
  },
78
81
  props,
79
82
  setup(props2) {
83
+ const root = ref();
84
+ const isFocusing = ref(false);
80
85
  const optionSelected = ref(false);
81
86
  const selected = computed(() => optionSelected.value);
82
87
  const label = computed(() => props2.label);
@@ -92,12 +97,34 @@ const __sfc__ = defineComponent({
92
97
  };
93
98
  watch([() => props2.label, () => props2.value], computeLabel);
94
99
  bindSelect(optionProvider);
100
+ useEventListener(() => window, "keydown", handleKeydown);
101
+ useEventListener(() => window, "keyup", handleKeyup);
95
102
  function handleClick() {
96
103
  if (props2.disabled) {
97
104
  return;
98
105
  }
99
106
  handleSelect();
100
107
  }
108
+ function handleKeydown(event) {
109
+ if (!isFocusing.value) {
110
+ return;
111
+ }
112
+ if (event.key === " " || event.key === "Enter") {
113
+ preventDefault(event);
114
+ }
115
+ if (event.key === "Enter") {
116
+ root.value.click();
117
+ }
118
+ }
119
+ function handleKeyup(event) {
120
+ if (!isFocusing.value) {
121
+ return;
122
+ }
123
+ if (event.key === " ") {
124
+ preventDefault(event);
125
+ root.value.click();
126
+ }
127
+ }
101
128
  function handleSelect() {
102
129
  if (multiple.value) {
103
130
  optionSelected.value = !optionSelected.value;
@@ -108,10 +135,12 @@ const __sfc__ = defineComponent({
108
135
  optionSelected.value = checked;
109
136
  }
110
137
  return {
138
+ root,
111
139
  optionSelected,
112
140
  multiple,
113
141
  focusColor,
114
142
  hovering,
143
+ isFocusing,
115
144
  n,
116
145
  classes,
117
146
  handleHovering,
@@ -1 +1 @@
1
- :root { --option-height: 38px; --option-padding: 0 12px; --option-font-size: 16px; --option-selected-background: var(--field-decorator-focus-color); --option-text-color: #555; --option-disabled-color: var(--color-text-disabled);}.var-option { position: relative; display: flex; align-items: center; height: var(--option-height); padding: var(--option-padding); cursor: pointer; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); color: var(--option-text-color);}.var-option__cover { position: absolute; top: 0; left: 0; right: 0; bottom: 0; opacity: 0.2; background: transparent;}.var-option__text { font-size: var(--option-font-size);}.var-option--selected-background { background: var(--option-selected-background);}.var-option--selected-color { color: var(--option-selected-background);}.var-option--disabled { color: var(--option-disabled-color); cursor: not-allowed;}
1
+ :root { --option-height: 38px; --option-padding: 0 12px; --option-font-size: 16px; --option-selected-background: var(--field-decorator-focus-color); --option-text-color: #555; --option-disabled-color: var(--color-text-disabled);}.var-option { position: relative; display: flex; align-items: center; height: var(--option-height); padding: var(--option-padding); cursor: pointer; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); color: var(--option-text-color); outline: none;}.var-option__cover { position: absolute; top: 0; left: 0; right: 0; bottom: 0; opacity: 0.2; background: transparent;}.var-option__text { font-size: var(--option-font-size);}.var-option--selected-background { background: var(--option-selected-background);}.var-option--selected-color { color: var(--option-selected-background);}.var-option--disabled { color: var(--option-disabled-color); cursor: not-allowed;}
@@ -4,9 +4,11 @@ import { props } from "./props.mjs";
4
4
  import { useLock } from "../context/lock.mjs";
5
5
  import { useZIndex } from "../context/zIndex.mjs";
6
6
  import { createNamespace, useTeleport } from "../utils/components.mjs";
7
- import { call } from "@varlet/shared";
7
+ import { call, preventDefault } from "@varlet/shared";
8
8
 
9
9
 
10
+ import { useStack } from "../context/stack.mjs";
11
+ import { useEventListener } from "@varlet/use";
10
12
  const {
11
13
  name,
12
14
  n
@@ -22,10 +24,25 @@ var stdin_default = defineComponent({
22
24
  const {
23
25
  zIndex
24
26
  } = useZIndex(() => props2.show, 1);
27
+ const {
28
+ onStackTop
29
+ } = useStack(() => props2.show, zIndex);
25
30
  const {
26
31
  disabled
27
32
  } = useTeleport();
28
33
  useLock(() => props2.show, () => props2.lockScroll);
34
+ useEventListener(window, "keydown", handleKeydown);
35
+ function handleKeydown(event) {
36
+ if (!onStackTop() || event.key !== "Escape" || !props2.show) {
37
+ return;
38
+ }
39
+ call(props2.onKeyEscape);
40
+ if (!props2.closeOnKeyEscape) {
41
+ return;
42
+ }
43
+ preventDefault(event);
44
+ call(props2["onUpdate:show"], false);
45
+ }
29
46
  function handleClickOverlay() {
30
47
  call(props2.onClick);
31
48
  call(props2["onUpdate:show"], false);
@@ -34,7 +51,7 @@ var stdin_default = defineComponent({
34
51
  return _createVNode("div", _mergeProps({
35
52
  "class": n(),
36
53
  "style": {
37
- zIndex: zIndex.value - 1
54
+ zIndex: zIndex.value
38
55
  }
39
56
  }, attrs, {
40
57
  "onClick": handleClickOverlay
@@ -7,7 +7,13 @@ const props = {
7
7
  },
8
8
  teleport: [String, Object, Boolean],
9
9
  onClick: defineListenerProp(),
10
- "onUpdate:show": defineListenerProp()
10
+ "onUpdate:show": defineListenerProp(),
11
+ // internal for esc
12
+ onKeyEscape: defineListenerProp(),
13
+ closeOnKeyEscape: {
14
+ type: Boolean,
15
+ default: true
16
+ }
11
17
  };
12
18
  export {
13
19
  props
@@ -1 +1 @@
1
- :root { --paper-background: var(--color-surface-container-highest);}.var-paper { background: var(--paper-background); transition: background-color 0.25s; overflow: hidden;}.var-paper--round { border-radius: 50%;}.var-paper--cursor { cursor: pointer;}
1
+ :root { --paper-background: var(--color-surface-container-highest); --paper-border-radius: 0;}.var-paper { background: var(--paper-background); transition: background-color 0.25s; overflow: hidden; border-radius: var(--paper-border-radius);}.var-paper--round { border-radius: 50%;}.var-paper--cursor { cursor: pointer;}
@@ -30,7 +30,9 @@ function __render__(_ctx, _cache) {
30
30
  onClosed: _ctx.onClosed,
31
31
  onClickOverlay: _ctx.onClickOverlay,
32
32
  onRouteChange: _ctx.onRouteChange,
33
+ onKeyEscape: _ctx.onKeyEscape,
33
34
  closeOnClickOverlay: _ctx.closeOnClickOverlay,
35
+ closeOnKeyEscape: _ctx.closeOnKeyEscape,
34
36
  teleport: _ctx.teleport,
35
37
  show: _ctx.show,
36
38
  safeArea: _ctx.safeArea,
@@ -72,7 +72,10 @@ const props = __spreadValues({
72
72
  "onOpened",
73
73
  "onClosed",
74
74
  "onClickOverlay",
75
- "onRouteChange"
75
+ "onRouteChange",
76
+ // internal for esc
77
+ "onKeyEscape",
78
+ "closeOnKeyEscape"
76
79
  ]));
77
80
  export {
78
81
  props
@@ -19,10 +19,11 @@ import { defineComponent, watch, Transition, Teleport, computed } from "vue";
19
19
  import { props } from "./props.mjs";
20
20
  import { useLock } from "../context/lock.mjs";
21
21
  import { useZIndex } from "../context/zIndex.mjs";
22
+ import { useStack } from "../context/stack.mjs";
22
23
  import { useRouteListener, useTeleport, createNamespace } from "../utils/components.mjs";
23
24
  import { usePopupItems } from "./provide.mjs";
24
- import { useInitialized } from "@varlet/use";
25
- import { call } from "@varlet/shared";
25
+ import { useEventListener, useInitialized } from "@varlet/use";
26
+ import { call, preventDefault } from "@varlet/shared";
26
27
 
27
28
 
28
29
  const {
@@ -42,6 +43,9 @@ var stdin_default = defineComponent({
42
43
  const {
43
44
  zIndex
44
45
  } = useZIndex(() => props2.show, 3);
46
+ const {
47
+ onStackTop
48
+ } = useStack(() => props2.show, zIndex);
45
49
  const {
46
50
  disabled
47
51
  } = useTeleport();
@@ -55,6 +59,7 @@ var stdin_default = defineComponent({
55
59
  bindPopupItems({
56
60
  show: computed(() => props2.show)
57
61
  });
62
+ useEventListener(window, "keydown", handleKeydown);
58
63
  useRouteListener(() => call(props2.onRouteChange));
59
64
  function hidePopup() {
60
65
  const {
@@ -106,6 +111,17 @@ var stdin_default = defineComponent({
106
111
  })]), [[_vShow, props2.show]])]
107
112
  });
108
113
  }
114
+ function handleKeydown(event) {
115
+ if (!onStackTop() || event.key !== "Escape" || !props2.show) {
116
+ return;
117
+ }
118
+ call(props2.onKeyEscape);
119
+ if (!props2.closeOnKeyEscape) {
120
+ return;
121
+ }
122
+ preventDefault(event);
123
+ call(props2["onUpdate:show"], false);
124
+ }
109
125
  return () => {
110
126
  const {
111
127
  teleport
@@ -37,7 +37,13 @@ const props = {
37
37
  onClickOverlay: defineListenerProp(),
38
38
  "onUpdate:show": defineListenerProp(),
39
39
  // internal for Dialog
40
- onRouteChange: defineListenerProp()
40
+ onRouteChange: defineListenerProp(),
41
+ // internal for esc
42
+ onKeyEscape: defineListenerProp(),
43
+ closeOnKeyEscape: {
44
+ type: Boolean,
45
+ default: true
46
+ }
41
47
  };
42
48
  export {
43
49
  props