huiyi-select-table 0.1.18 → 0.1.20

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.
Binary file
@@ -1,160 +1,279 @@
1
- import { defineComponent as j, ref as a, computed as H, resolveComponent as y, openBlock as p, createElementBlock as k, createVNode as C, createBlock as R, Teleport as Q, normalizeStyle as z, withCtx as K, Fragment as N, renderList as U, nextTick as $ } from "vue";
2
- const G = /* @__PURE__ */ j({
1
+ import { defineComponent as q, openBlock as y, createElementBlock as E, createElementVNode as V, ref as i, onMounted as O, computed as Z, onUnmounted as ee, resolveComponent as S, createVNode as T, unref as g, isRef as ne, withCtx as I, normalizeClass as te, createBlock as L, Teleport as F, normalizeStyle as le, Fragment as oe, renderList as ae, createCommentVNode as N } from "vue";
2
+ /*! Element Plus Icons Vue v2.3.2 */
3
+ var re = /* @__PURE__ */ q({
4
+ name: "ArrowDown",
5
+ __name: "arrow-down",
6
+ setup(u) {
7
+ return (f, _) => (y(), E("svg", {
8
+ xmlns: "http://www.w3.org/2000/svg",
9
+ viewBox: "0 0 1024 1024"
10
+ }, [
11
+ V("path", {
12
+ fill: "currentColor",
13
+ d: "M831.872 340.864 512 652.672 192.128 340.864a30.59 30.59 0 0 0-42.752 0 29.12 29.12 0 0 0 0 41.6L489.664 714.24a32 32 0 0 0 44.672 0l340.288-331.712a29.12 29.12 0 0 0 0-41.728 30.59 30.59 0 0 0-42.752 0z"
14
+ })
15
+ ]));
16
+ }
17
+ }), ue = re;
18
+ const se = /* @__PURE__ */ q({
3
19
  name: "InputSelectCompont",
4
20
  __name: "SelectTable",
5
21
  props: {
6
- originalData: Object,
7
- showValue: String,
8
- columnList: Object,
9
- searchQueryInit: String,
10
- labelIndex: String,
11
- isRead: !1,
12
- isRequired: !1,
13
- isIndex: 1
22
+ options: Array,
23
+ readonly: Boolean,
24
+ required: Boolean,
25
+ value: String,
26
+ itemIndex: {
27
+ type: [String, Number, null],
28
+ default: null
29
+ },
30
+ column: Array
14
31
  },
15
- emits: ["slectValue"],
16
- setup(o, { emit: c }) {
17
- const u = o, s = a("");
18
- s.value = u.searchQueryInit;
19
- const r = a(!1), t = a([]), b = a([]), g = a(!1), n = a(-1), v = a(-1), h = a(null), w = a(null), S = ({ row: e, rowIndex: l }) => n.value === l ? "warning-row" : "", V = H(() => {
20
- if (!r.value || !w.value)
21
- return { display: "none" };
22
- const e = w.value.getBoundingClientRect();
23
- return {
24
- position: "fixed",
25
- top: e.bottom + "px",
26
- left: e.left + "px",
27
- width: e.width + 80 + "px",
28
- zIndex: 1e4,
29
- backgroundColor: "#FFF",
30
- height: "230px"
31
- };
32
- }), _ = () => {
33
- r.value = !0, s.value ? (t.value = u.originalData.filter((e) => Object.keys(e).some((l) => String(e[l]).toLowerCase().includes(s.value.toLowerCase()))), console.log(t.value), n.value = -1, v.value = -1) : t.value = u.originalData;
34
- }, D = c, T = (e) => {
35
- b.value = e, console.log(e);
36
- }, x = (e) => {
37
- b.value = e, e && (s.value = e[u.showValue], r.value = !1);
38
- let l = {
39
- val: e,
40
- isIndex: u.isIndex
32
+ emits: ["getInputRef", "handleChangeSelectValue"],
33
+ setup(u, { emit: f }) {
34
+ const _ = f, t = u;
35
+ let d = i(), p = i(""), x = i(), R = i(), r = i(!1), A = i({
36
+ top: "0px",
37
+ left: "0px"
38
+ // width: "0px",
39
+ }), l = i(-1), h = i(!1), D = i(!1);
40
+ watch(
41
+ () => t.value,
42
+ (e) => {
43
+ p.value = e || "";
44
+ },
45
+ { immediate: !0 }
46
+ ), O(() => {
47
+ nextTick(() => {
48
+ _("getInputRef", x.value);
49
+ });
50
+ });
51
+ const b = () => {
52
+ if (!R.value)
53
+ return;
54
+ const e = R.value.getBoundingClientRect(), n = window.pageYOffset || document.documentElement.scrollTop, a = window.pageXOffset || document.documentElement.scrollLeft;
55
+ A.value = {
56
+ top: `${e.bottom + n}px`,
57
+ left: `${e.left + a}px`
58
+ // width: `${rect.width}px`,
41
59
  };
42
- D("slectValue", l);
43
- }, O = () => {
44
- g.value == !1 && setTimeout(() => {
45
- r.value = !1;
46
- }, 150);
47
- }, q = () => {
48
- g.value = !0;
49
- }, B = () => {
50
- g.value = !1;
51
- }, E = (e) => {
52
- if (console.log(e.key, "event.key "), t.value.length !== 0)
53
- if (e.key == "ArrowDown") {
54
- e.preventDefault();
55
- let l = n.value + 1;
56
- l >= t.value.length && (l = 0), console.log(l, "newIndex"), I(l);
57
- } else if (e.key == "ArrowUp") {
58
- e.preventDefault();
59
- let l = n.value - 1;
60
- l < 0 && (l = t.value.length - 1), I(l);
61
- } else
62
- e.key === "Enter" && (e.preventDefault(), r.value == !0 ? F() : _());
63
- }, F = () => {
64
- if (n.value >= 0) {
65
- v.value === n.value ? v.value = -1 : v.value = n.value;
66
- const e = t.value;
67
- console.log(e[n.value], n.value, "hh[currentHighlightIndex]"), x(t.value[n.value]);
60
+ }, C = Z(() => {
61
+ const e = t.column?.map((c) => c.prop) || [
62
+ "name",
63
+ "engname",
64
+ "spell",
65
+ "zjm",
66
+ "infoOrder"
67
+ ], n = t.options || [], a = p.value || "";
68
+ return l.value = -1, nextTick(() => {
69
+ const c = t.options || [], w = c.find((m) => m.name === t.value);
70
+ if (d.value && d.value.setCurrentRow(w), w) {
71
+ const m = P(
72
+ e,
73
+ a,
74
+ c
75
+ );
76
+ l.value = m.findIndex(
77
+ (o) => o.name === w.name
78
+ );
79
+ }
80
+ }), P(e, a, n);
81
+ }), K = (e) => {
82
+ e?.stopPropagation(), !t.readonly && (r.value ? s() : v());
83
+ }, U = () => {
84
+ if (t.readonly) {
85
+ s();
86
+ return;
68
87
  }
69
- }, I = (e) => {
70
- n.value = e, $(() => {
71
- if (h.value && t.value.length > 0 && e >= 0 && e < t.value.length) {
72
- const d = h.value.$el.querySelectorAll(".el-table__row");
73
- console.log(d, "rows"), d.length > 0 && e < d.length && d[e].scrollIntoView({ behavior: "smooth", block: "nearest" }), h.value.setCurrentRow(t.value[n.value]);
88
+ r.value || v(), l.value = -1;
89
+ }, v = () => {
90
+ t.readonly || D.value || (D.value = !0, r.value = !0, nextTick(() => {
91
+ b(), h.value = !1, setTimeout(() => {
92
+ D.value = !1;
93
+ }, 100);
94
+ }));
95
+ }, s = () => {
96
+ r.value = !1, h.value = !1;
97
+ }, M = (e) => {
98
+ p.value = e.name, s(), nextTick(() => {
99
+ x.value?.focus();
100
+ }), _("handleChangeSelectValue", {
101
+ valueCode: e.code,
102
+ value: e.name,
103
+ index: t.itemIndex ? t.itemIndex : ""
104
+ });
105
+ }, Y = (e) => {
106
+ h.value = !0, e.preventDefault();
107
+ }, $ = (e) => {
108
+ e.stopPropagation(), s();
109
+ }, j = async () => {
110
+ if (console.log("handleInput"), t.readonly) {
111
+ s();
112
+ return;
113
+ }
114
+ v(), l.value = -1;
115
+ }, H = () => {
116
+ if (console.log("handleFocus"), t.readonly) {
117
+ s();
118
+ return;
119
+ }
120
+ r.value || v(), l.value = -1;
121
+ }, X = () => {
122
+ console.log("handleBlur", h.value), setTimeout(() => {
123
+ if (h.value) {
124
+ nextTick(() => {
125
+ x.value?.focus();
126
+ });
127
+ return;
74
128
  }
129
+ s();
130
+ }, 150);
131
+ }, G = (e) => {
132
+ C.value.length !== 0 && (e.key === "ArrowDown" ? (e.preventDefault(), r.value || v(), z(1)) : e.key === "ArrowUp" ? (e.preventDefault(), r.value || v(), z(-1)) : e.key === "Enter" ? (e.preventDefault(), r.value ? J() : v()) : (e.key === "Escape" || e.key === "Tab") && s());
133
+ }, z = (e) => {
134
+ const n = C.value;
135
+ if (n.length === 0)
136
+ return;
137
+ l.value === -1 ? e === 1 ? l.value = 0 : l.value = n.length - 1 : (l.value += e, l.value < 0 ? l.value = n.length - 1 : l.value >= n.length && (l.value = 0));
138
+ const a = n[l.value];
139
+ d.value && d.value.setCurrentRow(a), Q();
140
+ }, J = () => {
141
+ const e = C.value;
142
+ if (e.length === 0 || l.value === -1)
143
+ return;
144
+ const n = e[l.value];
145
+ M(n);
146
+ }, Q = () => {
147
+ nextTick(() => {
148
+ const e = d.value;
149
+ if (!e)
150
+ return;
151
+ const n = e.$el.querySelector(".el-table__body-wrapper");
152
+ if (!n)
153
+ return;
154
+ const a = n.querySelector(".current-row");
155
+ a && a.scrollIntoView({
156
+ behavior: "smooth",
157
+ block: "nearest"
158
+ });
75
159
  });
160
+ }, P = (e, n, a) => {
161
+ const c = n.trim().toLowerCase();
162
+ return c ? a.filter(
163
+ (w) => e.some((m) => {
164
+ const o = w[m];
165
+ return o == null && o !== 0 ? !1 : String(o).toLowerCase().includes(c);
166
+ })
167
+ ) : a;
76
168
  };
77
- return (e, l) => {
78
- const d = y("el-input"), L = y("el-table-column"), A = y("el-table");
79
- return p(), k("span", {
80
- class: "huiyi-select-spanInput",
81
- onMouseover: q,
82
- onMouseout: B,
83
- ref_key: "inputContainerRef",
84
- ref: w
169
+ return O(() => {
170
+ window.addEventListener("resize", b), window.addEventListener("scroll", b, !0);
171
+ }), ee(() => {
172
+ window.removeEventListener("resize", b), window.removeEventListener("scroll", b, !0);
173
+ }), (e, n) => {
174
+ const a = S("el-icon"), c = S("el-input"), w = S("el-table-column"), m = S("el-table");
175
+ return y(), E("div", {
176
+ class: "custom-dropdown",
177
+ ref_key: "dropdownRef",
178
+ ref: R
85
179
  }, [
86
- C(d, {
87
- placeholder: "请输入搜索内容",
88
- modelValue: s.value,
89
- "onUpdate:modelValue": l[0] || (l[0] = (i) => s.value = i),
90
- id: "filterInput",
91
- onInput: _,
92
- style: { width: "200px" },
93
- readonly: o.isRead,
94
- required: o.isRequired,
95
- onFocus: _,
96
- onBlur: O,
97
- onKeydown: E
98
- }, null, 8, ["modelValue", "readonly", "required"]),
99
- (p(), R(Q, {
100
- to: "body",
101
- class: "huiyi-select-spanDiv"
180
+ T(c, {
181
+ modelValue: g(p),
182
+ "onUpdate:modelValue": n[0] || (n[0] = (o) => ne(p) ? p.value = o : p = o),
183
+ ref_key: "inputValueRef",
184
+ ref: x,
185
+ readonly: t.readonly,
186
+ onInput: j,
187
+ onKeydown: G,
188
+ onFocus: H,
189
+ onBlur: X,
190
+ onClick: U
191
+ }, {
192
+ suffix: I(() => [
193
+ T(a, {
194
+ class: te(["el-input__icon dropdown-arrow", { "dropdown-arrow--open": g(r) }]),
195
+ onClick: K
196
+ }, {
197
+ default: I(() => [
198
+ T(g(ue))
199
+ ]),
200
+ _: 1
201
+ }, 8, ["class"])
202
+ ]),
203
+ _: 1
204
+ }, 8, ["modelValue", "readonly"]),
205
+ g(r) ? (y(), L(F, {
206
+ key: 0,
207
+ to: "body"
208
+ }, [
209
+ V("div", {
210
+ class: "dropdown-panel",
211
+ style: le(g(A)),
212
+ onMousedown: Y
213
+ }, [
214
+ T(m, {
215
+ border: "",
216
+ data: C.value,
217
+ "highlight-current-row": "",
218
+ ref_key: "tableRef",
219
+ ref: d,
220
+ "max-height": "200px",
221
+ onRowClick: M,
222
+ style: { width: "100%" }
223
+ }, {
224
+ default: I(() => [
225
+ (y(!0), E(oe, null, ae(t.column, (o, W) => (y(), L(w, {
226
+ key: W,
227
+ prop: o.prop,
228
+ label: o.label,
229
+ width: o.width,
230
+ align: o.align,
231
+ type: o.type,
232
+ "header-align": o.headerAlign
233
+ }, null, 8, ["prop", "label", "width", "align", "type", "header-align"]))), 128))
234
+ ]),
235
+ _: 1
236
+ }, 8, ["data"])
237
+ ], 36)
238
+ ])) : N("", !0),
239
+ g(r) ? (y(), L(F, {
240
+ key: 1,
241
+ to: "body"
102
242
  }, [
103
- C(A, {
104
- ref_key: "singleTableRef",
105
- ref: h,
106
- border: "",
107
- class: "huiyi-select-spanInputTable",
108
- "row-class-name": S,
109
- "highlight-current-row": "",
110
- data: t.value,
111
- onCurrentChange: T,
112
- onRowClick: x,
113
- style: z(V.value)
114
- }, {
115
- default: K(() => [
116
- (p(!0), k(N, null, U(o.columnList, (i, M) => (p(), R(L, {
117
- key: M,
118
- prop: i.prop,
119
- align: i.align,
120
- label: i.label,
121
- width: i.width,
122
- "header-align": i.headerAlign,
123
- "show-overflow-tooltip": ""
124
- }, null, 8, ["prop", "align", "label", "width", "header-align"]))), 128))
125
- ]),
126
- _: 1
127
- }, 8, ["data", "style"])
128
- ]))
129
- ], 544);
243
+ V("div", {
244
+ class: "dropdown-mask",
245
+ onMousedown: $
246
+ }, null, 32)
247
+ ])) : N("", !0)
248
+ ], 512);
130
249
  };
131
250
  }
132
251
  });
133
- const J = (o, c) => {
134
- const u = o.__vccOpts || o;
135
- for (const [s, r] of c)
136
- u[s] = r;
137
- return u;
138
- }, f = /* @__PURE__ */ J(G, [["__scopeId", "data-v-f5648f73"]]);
139
- f.install = (o) => {
140
- o.component(f.name, f);
252
+ const ce = (u, f) => {
253
+ const _ = u.__vccOpts || u;
254
+ for (const [t, d] of f)
255
+ _[t] = d;
256
+ return _;
257
+ }, k = /* @__PURE__ */ ce(se, [["__scopeId", "data-v-7fb91764"]]);
258
+ k.install = (u) => {
259
+ u.component(k.name, k);
141
260
  };
142
- const P = [
143
- f
144
- ], m = function(o) {
145
- m.installed || P.forEach((c) => {
146
- o.component(c.name, c);
261
+ const ie = [
262
+ k
263
+ ], B = function(u) {
264
+ B.installed || ie.forEach((f) => {
265
+ u.component(f.name, f);
147
266
  });
148
267
  };
149
- typeof window < "u" && window.Vue && m(window.Vue);
150
- const X = {
268
+ typeof window < "u" && window.Vue && B(window.Vue);
269
+ const fe = {
151
270
  // 导出的对象必须具有 install,才能被 Vue.use() 方法安装
152
- install: m,
271
+ install: B,
153
272
  // 以下是具体的组件列表
154
- SelectTable: f
273
+ SelectTable: k
155
274
  };
156
275
  export {
157
- f as SelectTable,
158
- X as default,
159
- m as install
276
+ k as SelectTable,
277
+ fe as default,
278
+ B as install
160
279
  };
@@ -1 +1 @@
1
- (function(s,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(s=typeof globalThis<"u"?globalThis:s||self,e(s.HuiyiSelectTable={},s.Vue))})(this,function(s,e){"use strict";const L="",x=e.defineComponent({name:"InputSelectCompont",__name:"SelectTable",props:{originalData:Object,showValue:String,columnList:Object,searchQueryInit:String,labelIndex:String,isRead:!1,isRequired:!1,isIndex:1},emits:["slectValue"],setup(a,{emit:d}){const r=a,i=e.ref("");i.value=r.searchQueryInit;const u=e.ref(!1),n=e.ref([]),v=e.ref([]),_=e.ref(!1),o=e.ref(-1),g=e.ref(-1),w=e.ref(null),y=e.ref(null),S=({row:l,rowIndex:t})=>o.value===t?"warning-row":"",R=e.computed(()=>{if(!u.value||!y.value)return{display:"none"};const l=y.value.getBoundingClientRect();return{position:"fixed",top:l.bottom+"px",left:l.left+"px",width:l.width+80+"px",zIndex:1e4,backgroundColor:"#FFF",height:"230px"}}),m=()=>{u.value=!0,i.value?(n.value=r.originalData.filter(l=>Object.keys(l).some(t=>String(l[t]).toLowerCase().includes(i.value.toLowerCase()))),console.log(n.value),o.value=-1,g.value=-1):n.value=r.originalData},T=d,V=l=>{v.value=l,console.log(l)},b=l=>{v.value=l,l&&(i.value=l[r.showValue],u.value=!1);let t={val:l,isIndex:r.isIndex};T("slectValue",t)},D=()=>{_.value==!1&&setTimeout(()=>{u.value=!1},150)},B=()=>{_.value=!0},O=()=>{_.value=!1},q=l=>{if(console.log(l.key,"event.key "),n.value.length!==0)if(l.key=="ArrowDown"){l.preventDefault();let t=o.value+1;t>=n.value.length&&(t=0),console.log(t,"newIndex"),k(t)}else if(l.key=="ArrowUp"){l.preventDefault();let t=o.value-1;t<0&&(t=n.value.length-1),k(t)}else l.key==="Enter"&&(l.preventDefault(),u.value==!0?E():m())},E=()=>{if(o.value>=0){g.value===o.value?g.value=-1:g.value=o.value;const l=n.value;console.log(l[o.value],o.value,"hh[currentHighlightIndex]"),b(n.value[o.value])}},k=l=>{o.value=l,e.nextTick(()=>{if(w.value&&n.value.length>0&&l>=0&&l<n.value.length){const p=w.value.$el.querySelectorAll(".el-table__row");console.log(p,"rows"),p.length>0&&l<p.length&&p[l].scrollIntoView({behavior:"smooth",block:"nearest"}),w.value.setCurrentRow(n.value[o.value])}})};return(l,t)=>{const p=e.resolveComponent("el-input"),M=e.resolveComponent("el-table-column"),j=e.resolveComponent("el-table");return e.openBlock(),e.createElementBlock("span",{class:"huiyi-select-spanInput",onMouseover:B,onMouseout:O,ref_key:"inputContainerRef",ref:y},[e.createVNode(p,{placeholder:"请输入搜索内容",modelValue:i.value,"onUpdate:modelValue":t[0]||(t[0]=c=>i.value=c),id:"filterInput",onInput:m,style:{width:"200px"},readonly:a.isRead,required:a.isRequired,onFocus:m,onBlur:D,onKeydown:q},null,8,["modelValue","readonly","required"]),(e.openBlock(),e.createBlock(e.Teleport,{to:"body",class:"huiyi-select-spanDiv"},[e.createVNode(j,{ref_key:"singleTableRef",ref:w,border:"",class:"huiyi-select-spanInputTable","row-class-name":S,"highlight-current-row":"",data:n.value,onCurrentChange:V,onRowClick:b,style:e.normalizeStyle(R.value)},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.columnList,(c,F)=>(e.openBlock(),e.createBlock(M,{key:F,prop:c.prop,align:c.align,label:c.label,width:c.width,"header-align":c.headerAlign,"show-overflow-tooltip":""},null,8,["prop","align","label","width","header-align"]))),128))]),_:1},8,["data","style"])]))],544)}}}),A="",f=((a,d)=>{const r=a.__vccOpts||a;for(const[i,u]of d)r[i]=u;return r})(x,[["__scopeId","data-v-f5648f73"]]);f.install=a=>{a.component(f.name,f)};const I=[f],h=function(a){h.installed||I.forEach(d=>{a.component(d.name,d)})};typeof window<"u"&&window.Vue&&h(window.Vue);const C={install:h,SelectTable:f};s.SelectTable=f,s.default=C,s.install=h,Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(c,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(c=typeof globalThis<"u"?globalThis:c||self,e(c.HuiyiSelectTable={},c.Vue))})(this,function(c,e){"use strict";const $="";/*! Element Plus Icons Vue v2.3.2 */var D=e.defineComponent({name:"ArrowDown",__name:"arrow-down",setup(i){return(p,g)=>(e.openBlock(),e.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[e.createElementVNode("path",{fill:"currentColor",d:"M831.872 340.864 512 652.672 192.128 340.864a30.59 30.59 0 0 0-42.752 0 29.12 29.12 0 0 0 0 41.6L489.664 714.24a32 32 0 0 0 44.672 0l340.288-331.712a29.12 29.12 0 0 0 0-41.728 30.59 30.59 0 0 0-42.752 0z"})]))}}),I=D;const L=e.defineComponent({name:"InputSelectCompont",__name:"SelectTable",props:{options:Array,readonly:Boolean,required:Boolean,value:String,itemIndex:{type:[String,Number,null],default:null},column:Array},emits:["getInputRef","handleChangeSelectValue"],setup(i,{emit:p}){const g=p,o=i;let f=e.ref(),m=e.ref(""),v=e.ref(),T=e.ref(),s=e.ref(!1),B=e.ref({top:"0px",left:"0px"}),l=e.ref(-1),k=e.ref(!1),S=e.ref(!1);watch(()=>o.value,n=>{m.value=n||""},{immediate:!0}),e.onMounted(()=>{nextTick(()=>{g("getInputRef",v.value)})});const b=()=>{if(!T.value)return;const n=T.value.getBoundingClientRect(),t=window.pageYOffset||document.documentElement.scrollTop,r=window.pageXOffset||document.documentElement.scrollLeft;B.value={top:`${n.bottom+t}px`,left:`${n.left+r}px`}},C=e.computed(()=>{const n=o.column?.map(d=>d.prop)||["name","engname","spell","zjm","infoOrder"],t=o.options||[],r=m.value||"";return l.value=-1,nextTick(()=>{const d=o.options||[],_=d.find(y=>y.name===o.value);if(f.value&&f.value.setCurrentRow(_),_){const y=E(n,r,d);l.value=y.findIndex(a=>a.name===_.name)}}),E(n,r,t)}),A=n=>{n?.stopPropagation(),!o.readonly&&(s.value?u():w())},P=()=>{if(o.readonly){u();return}s.value||w(),l.value=-1},w=()=>{o.readonly||S.value||(S.value=!0,s.value=!0,nextTick(()=>{b(),k.value=!1,setTimeout(()=>{S.value=!1},100)}))},u=()=>{s.value=!1,k.value=!1},R=n=>{m.value=n.name,u(),nextTick(()=>{v.value?.focus()}),g("handleChangeSelectValue",{valueCode:n.code,value:n.name,index:o.itemIndex?o.itemIndex:""})},z=n=>{k.value=!0,n.preventDefault()},O=n=>{n.stopPropagation(),u()},q=async()=>{if(console.log("handleInput"),o.readonly){u();return}w(),l.value=-1},F=()=>{if(console.log("handleFocus"),o.readonly){u();return}s.value||w(),l.value=-1},j=()=>{console.log("handleBlur",k.value),setTimeout(()=>{if(k.value){nextTick(()=>{v.value?.focus()});return}u()},150)},K=n=>{C.value.length!==0&&(n.key==="ArrowDown"?(n.preventDefault(),s.value||w(),V(1)):n.key==="ArrowUp"?(n.preventDefault(),s.value||w(),V(-1)):n.key==="Enter"?(n.preventDefault(),s.value?U():w()):(n.key==="Escape"||n.key==="Tab")&&u())},V=n=>{const t=C.value;if(t.length===0)return;l.value===-1?n===1?l.value=0:l.value=t.length-1:(l.value+=n,l.value<0?l.value=t.length-1:l.value>=t.length&&(l.value=0));const r=t[l.value];f.value&&f.value.setCurrentRow(r),H()},U=()=>{const n=C.value;if(n.length===0||l.value===-1)return;const t=n[l.value];R(t)},H=()=>{nextTick(()=>{const n=f.value;if(!n)return;const t=n.$el.querySelector(".el-table__body-wrapper");if(!t)return;const r=t.querySelector(".current-row");r&&r.scrollIntoView({behavior:"smooth",block:"nearest"})})},E=(n,t,r)=>{const d=t.trim().toLowerCase();return d?r.filter(_=>n.some(y=>{const a=_[y];return a==null&&a!==0?!1:String(a).toLowerCase().includes(d)})):r};return e.onMounted(()=>{window.addEventListener("resize",b),window.addEventListener("scroll",b,!0)}),e.onUnmounted(()=>{window.removeEventListener("resize",b),window.removeEventListener("scroll",b,!0)}),(n,t)=>{const r=e.resolveComponent("el-icon"),d=e.resolveComponent("el-input"),_=e.resolveComponent("el-table-column"),y=e.resolveComponent("el-table");return e.openBlock(),e.createElementBlock("div",{class:"custom-dropdown",ref_key:"dropdownRef",ref:T},[e.createVNode(d,{modelValue:e.unref(m),"onUpdate:modelValue":t[0]||(t[0]=a=>e.isRef(m)?m.value=a:m=a),ref_key:"inputValueRef",ref:v,readonly:o.readonly,onInput:q,onKeydown:K,onFocus:F,onBlur:j,onClick:P},{suffix:e.withCtx(()=>[e.createVNode(r,{class:e.normalizeClass(["el-input__icon dropdown-arrow",{"dropdown-arrow--open":e.unref(s)}]),onClick:A},{default:e.withCtx(()=>[e.createVNode(e.unref(I))]),_:1},8,["class"])]),_:1},8,["modelValue","readonly"]),e.unref(s)?(e.openBlock(),e.createBlock(e.Teleport,{key:0,to:"body"},[e.createElementVNode("div",{class:"dropdown-panel",style:e.normalizeStyle(e.unref(B)),onMousedown:z},[e.createVNode(y,{border:"",data:C.value,"highlight-current-row":"",ref_key:"tableRef",ref:f,"max-height":"200px",onRowClick:R,style:{width:"100%"}},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.column,(a,Y)=>(e.openBlock(),e.createBlock(_,{key:Y,prop:a.prop,label:a.label,width:a.width,align:a.align,type:a.type,"header-align":a.headerAlign},null,8,["prop","label","width","align","type","header-align"]))),128))]),_:1},8,["data"])],36)])):e.createCommentVNode("",!0),e.unref(s)?(e.openBlock(),e.createBlock(e.Teleport,{key:1,to:"body"},[e.createElementVNode("div",{class:"dropdown-mask",onMousedown:O},null,32)])):e.createCommentVNode("",!0)],512)}}}),X="",h=((i,p)=>{const g=i.__vccOpts||i;for(const[o,f]of p)g[o]=f;return g})(L,[["__scopeId","data-v-7fb91764"]]);h.install=i=>{i.component(h.name,h)};const M=[h],x=function(i){x.installed||M.forEach(p=>{i.component(p.name,p)})};typeof window<"u"&&window.Vue&&x(window.Vue);const N={install:x,SelectTable:h};c.SelectTable=h,c.default=N,c.install=x,Object.defineProperties(c,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "huiyi-select-table",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "description": "A Vue.js select table component",
5
5
  "main": "huiyi-select-table.umd.js",
6
6
  "module": "huiyi-select-table.mjs",
package/style.css CHANGED
@@ -1 +1 @@
1
- .el-table .warning-row[data-v-f5648f73]{--el-table-tr-bg-color: #141}.huiyi-select-spanInput[data-v-f5648f73]{display:inline-block;position:relative}
1
+ .custom-dropdown[data-v-7fb91764]{position:relative;width:100%}.dropdown-panel[data-v-7fb91764]{position:fixed;z-index:9999;background:white;border:1px solid #e4e7ed;border-radius:4px;box-shadow:0 2px 12px #0000001a;margin-top:4px;box-sizing:border-box;max-height:200px;overflow:hidden}.dropdown-mask[data-v-7fb91764]{position:fixed;inset:0;z-index:9998;background:transparent}.dropdown-arrow[data-v-7fb91764]{cursor:pointer;transition:transform .3s}.dropdown-arrow--open[data-v-7fb91764]{transform:rotate(180deg)}
Binary file