x-next 1.2.0 → 1.3.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.
Files changed (33) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/components/dropdown/Dropdown.vue.d.ts +27 -1
  3. package/dist/components/dropdown/DropdownButton.vue.d.ts +27 -1
  4. package/dist/components/dropdown/DropdownOption.vue.d.ts +2 -0
  5. package/dist/components/dropdown/DropdownSubmenu.vue.d.ts +158 -1
  6. package/dist/components/dropdown/context.d.ts +14 -1
  7. package/dist/components/dropdown/dropdown-panel.vue.d.ts +7 -1
  8. package/dist/components/dropdown/index.d.ts +588 -6
  9. package/dist/components/dropdown/use-keyboard.d.ts +10 -0
  10. package/dist/components/form-select/hooks/use-select.d.ts +2 -1
  11. package/dist/es/_hooks/use-overflow.js +45 -40
  12. package/dist/es/components/_components/select-view/select-view.js +49 -55
  13. package/dist/es/components/dialog/Dialog.js +106 -97
  14. package/dist/es/components/dropdown/Dropdown.vue.js +18 -15
  15. package/dist/es/components/dropdown/Dropdown.vue2.js +52 -31
  16. package/dist/es/components/dropdown/DropdownOption.vue.js +22 -21
  17. package/dist/es/components/dropdown/DropdownOption.vue2.js +23 -19
  18. package/dist/es/components/dropdown/DropdownSubmenu.vue.js +49 -36
  19. package/dist/es/components/dropdown/DropdownSubmenu.vue2.js +45 -24
  20. package/dist/es/components/dropdown/context.js +3 -2
  21. package/dist/es/components/dropdown/dropdown-panel.vue.js +24 -21
  22. package/dist/es/components/dropdown/dropdown-panel.vue2.js +83 -31
  23. package/dist/es/components/dropdown/use-keyboard.js +45 -0
  24. package/dist/es/components/form-checkbox/Checkbox.js +49 -49
  25. package/dist/es/components/form-select/Select.js +25 -24
  26. package/dist/es/components/form-select/hooks/use-select.js +128 -128
  27. package/dist/es/style.css +1 -1
  28. package/dist/index.cjs +4 -4
  29. package/dist/index.d.ts +1 -1
  30. package/dist/index.umd.js +4 -4
  31. package/dist/style/base.css +1 -1
  32. package/dist/style.css +1 -1
  33. package/package.json +1 -1
@@ -1,146 +1,146 @@
1
- import { ref as J, watch as H, nextTick as P, provide as Q, reactive as X } from "vue";
2
- import { getRelativeRect as Z } from "../../../_utils/dom.js";
3
- import { useOptions as $ } from "./use-options.js";
4
- import { getKeyDownHandler as k, KEYBOARD_KEY as s } from "../../../_utils/keyboard.js";
5
- import { selectInjectionKey as b } from "../context.js";
6
- import { isUndefined as r } from "../../../_utils/is.js";
1
+ import { ref as X, watch as U, nextTick as Z, provide as $, reactive as p } from "vue";
2
+ import { getRelativeRect as R } from "../../../_utils/dom.js";
3
+ import { useOptions as F } from "./use-options.js";
4
+ import { KEYBOARD_KEY as a } from "../../../_utils/keyboard.js";
5
+ import { selectInjectionKey as L } from "../context.js";
6
+ import { isUndefined as f } from "../../../_utils/is.js";
7
7
  const le = ({
8
- multiple: W,
9
- options: y,
10
- extraOptions: M,
11
- inputValue: E,
12
- filterOption: O,
13
- showExtraOptions: U,
14
- component: Y,
15
- valueKey: T,
16
- fieldNames: j,
17
- loading: i,
18
- popupVisible: v,
19
- valueKeys: m,
20
- dropdownRef: x,
21
- optionRefs: p,
22
- virtualListRef: a,
23
- onSelect: g,
24
- onPopupVisibleChange: h,
25
- getOptionId: A,
26
- enterToOpen: B = !0,
27
- defaultActiveFirstOption: D
8
+ multiple: B,
9
+ options: H,
10
+ extraOptions: Y,
11
+ inputValue: T,
12
+ filterOption: E,
13
+ showExtraOptions: j,
14
+ component: M,
15
+ valueKey: h,
16
+ fieldNames: q,
17
+ loading: m,
18
+ disabled: y,
19
+ popupVisible: c,
20
+ valueKeys: x,
21
+ dropdownRef: K,
22
+ optionRefs: O,
23
+ virtualListRef: v,
24
+ onSelect: k,
25
+ onPopupVisibleChange: i,
26
+ getOptionId: z,
27
+ enterToOpen: C = !0,
28
+ defaultActiveFirstOption: g
28
29
  }) => {
29
30
  const {
30
- validOptions: C,
31
- optionInfoMap: w,
32
- validOptionInfos: q,
33
- enabledOptionKeys: o,
34
- getNextSlotOptionIndex: z,
35
- addSlotOptionInfo: K,
36
- removeSlotOptionInfo: S
37
- } = $({
38
- options: y,
39
- extraOptions: M,
40
- inputValue: E,
41
- filterOption: O,
42
- showExtraOptions: U,
43
- valueKey: T,
44
- fieldNames: j
45
- }), l = J();
46
- H(o, (e) => {
47
- (r(l.value) || !e.includes(l.value)) && (l.value = e[0]);
31
+ validOptions: G,
32
+ optionInfoMap: D,
33
+ validOptionInfos: J,
34
+ enabledOptionKeys: l,
35
+ getNextSlotOptionIndex: P,
36
+ addSlotOptionInfo: S,
37
+ removeSlotOptionInfo: _
38
+ } = F({
39
+ options: H,
40
+ extraOptions: Y,
41
+ inputValue: T,
42
+ filterOption: E,
43
+ showExtraOptions: j,
44
+ valueKey: h,
45
+ fieldNames: q
46
+ }), t = X();
47
+ let u;
48
+ const w = () => {
49
+ const e = l.value, r = x.value[x.value.length - 1];
50
+ return e.includes(r) ? r : u ? u === "up" ? e[e.length - 1] : e[0] : (g == null ? void 0 : g.value) ?? !0 ? e[0] : void 0;
51
+ };
52
+ U(l, (e) => {
53
+ c.value && u ? t.value = w() : (f(t.value) || !e.includes(t.value)) && (t.value = e[0]);
48
54
  });
49
- const _ = (e) => {
50
- l.value = e;
51
- }, I = (e) => {
52
- const t = o.value.length;
53
- if (t === 0)
55
+ const A = (e) => {
56
+ t.value = e;
57
+ }, N = (e) => {
58
+ const r = l.value.length;
59
+ if (r === 0)
54
60
  return;
55
- if (r(l.value))
56
- return e === "down" ? o.value[0] : o.value[t - 1];
57
- const n = o.value.indexOf(l.value), c = (t + n + (e === "up" ? -1 : 1)) % t;
58
- return o.value[c];
59
- }, u = (e) => {
61
+ if (f(t.value))
62
+ return e === "down" ? l.value[0] : l.value[r - 1];
63
+ const o = l.value.indexOf(t.value), n = (r + o + (e === "up" ? -1 : 1)) % r;
64
+ return l.value[n];
65
+ }, I = (e) => {
60
66
  var d;
61
- a != null && a.value && a.value.scrollTo({ key: e });
62
- const t = w.get(e), n = (d = x == null ? void 0 : x.value) == null ? void 0 : d.wrapperRef, c = (p == null ? void 0 : p.value[e]) ?? (t == null ? void 0 : t.ref);
63
- if (!n || !c || n.scrollHeight === n.offsetHeight)
67
+ v != null && v.value && v.value.scrollTo({ key: e });
68
+ const r = D.get(e), o = (d = K == null ? void 0 : K.value) == null ? void 0 : d.wrapperRef, n = (O == null ? void 0 : O.value[e]) ?? (r == null ? void 0 : r.ref);
69
+ if (!o || !n || o.scrollHeight === o.offsetHeight)
64
70
  return;
65
- const f = Z(c, n), N = n.scrollTop;
66
- f.top < 0 ? n.scrollTo(0, N + f.top) : f.bottom < 0 && n.scrollTo(0, N - f.bottom);
71
+ const s = R(n, o), W = o.scrollTop;
72
+ s.top < 0 ? o.scrollTo(0, W + s.top) : s.bottom < 0 && o.scrollTo(0, W - s.bottom);
67
73
  };
68
- H(
69
- v,
74
+ U(
75
+ c,
70
76
  (e) => {
71
- if (e) {
72
- const t = m.value[m.value.length - 1];
73
- let n = (D == null ? void 0 : D.value) ?? !0 ? o.value[0] : void 0;
74
- o.value.includes(t) && (n = t), n !== l.value && (l.value = n), P(() => {
75
- r(l.value) || u(l.value);
76
- });
77
- }
77
+ e ? (t.value = w(), Z(() => {
78
+ u = void 0, c.value && !f(t.value) && I(t.value);
79
+ })) : u = void 0;
78
80
  },
79
81
  { immediate: !0 }
80
82
  );
81
- const G = k(
82
- /* @__PURE__ */ new Map([
83
- [
84
- s.ENTER,
85
- (e) => {
86
- !(i != null && i.value) && !e.isComposing && (v.value ? r(l.value) || (g(l.value, e), e.preventDefault()) : B && (h(!0), e.preventDefault()));
87
- }
88
- ],
89
- [
90
- s.ESC,
91
- (e) => {
92
- v.value && (h(!1), e.preventDefault());
93
- }
94
- ],
95
- [
96
- s.ARROW_DOWN,
97
- (e) => {
98
- if (v.value) {
99
- const t = I("down");
100
- r(t) || (l.value = t, u(t)), e.preventDefault();
101
- }
102
- }
103
- ],
104
- [
105
- s.ARROW_UP,
106
- (e) => {
107
- if (v.value) {
108
- const t = I("up");
109
- r(t) || (l.value = t, u(t)), e.preventDefault();
110
- }
83
+ const Q = (e) => {
84
+ if (y != null && y.value || e.isComposing || e.keyCode === 229 || e.ctrlKey || e.altKey || e.metaKey)
85
+ return;
86
+ if (e.key === a.TAB) {
87
+ u = void 0, c.value && i(!1);
88
+ return;
89
+ }
90
+ if (e.shiftKey)
91
+ return;
92
+ const r = () => {
93
+ e.stopPropagation(), e.preventDefault();
94
+ };
95
+ if (e.key === a.ESC) {
96
+ u = void 0, c.value && (r(), i(!1));
97
+ return;
98
+ }
99
+ if (!(m != null && m.value)) {
100
+ if (e.key === a.ENTER) {
101
+ c.value ? !f(t.value) && l.value.includes(t.value) && (r(), k(t.value, e)) : C && (u = void 0, r(), i(!0));
102
+ return;
103
+ }
104
+ if (e.key === a.ARROW_DOWN || e.key === a.ARROW_UP) {
105
+ const o = e.key === a.ARROW_UP ? "up" : "down";
106
+ if (r(), !c.value)
107
+ u = o, i(!0);
108
+ else {
109
+ const n = N(o);
110
+ f(n) || (t.value = n, I(n));
111
111
  }
112
- ]
113
- ])
114
- );
115
- return Q(
116
- b,
117
- X({
118
- multiple: W,
119
- valueKey: T,
120
- inputValue: E,
121
- filterOption: O,
122
- component: Y,
123
- valueKeys: m,
124
- activeKey: l,
125
- getOptionId: A,
126
- setActiveKey: _,
127
- onSelect: g,
128
- getNextSlotOptionIndex: z,
129
- addSlotOptionInfo: K,
130
- removeSlotOptionInfo: S
112
+ }
113
+ }
114
+ };
115
+ return $(
116
+ L,
117
+ p({
118
+ multiple: B,
119
+ valueKey: h,
120
+ inputValue: T,
121
+ filterOption: E,
122
+ component: M,
123
+ valueKeys: x,
124
+ activeKey: t,
125
+ getOptionId: z,
126
+ setActiveKey: A,
127
+ onSelect: k,
128
+ getNextSlotOptionIndex: P,
129
+ addSlotOptionInfo: S,
130
+ removeSlotOptionInfo: _
131
131
  })
132
132
  ), {
133
- validOptions: C,
134
- optionInfoMap: w,
135
- validOptionInfos: q,
136
- enabledOptionKeys: o,
137
- activeKey: l,
138
- setActiveKey: _,
139
- addSlotOptionInfo: K,
140
- removeSlotOptionInfo: S,
141
- getNextActiveKey: I,
142
- scrollIntoView: u,
143
- handleKeyDown: G
133
+ validOptions: G,
134
+ optionInfoMap: D,
135
+ validOptionInfos: J,
136
+ enabledOptionKeys: l,
137
+ activeKey: t,
138
+ setActiveKey: A,
139
+ addSlotOptionInfo: S,
140
+ removeSlotOptionInfo: _,
141
+ getNextActiveKey: N,
142
+ scrollIntoView: I,
143
+ handleKeyDown: Q
144
144
  };
145
145
  };
146
146
  export {