huiyi-select-table 0.1.22 → 0.1.23

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.
@@ -1,21 +1,24 @@
1
- import { defineComponent as K, openBlock as h, createElementBlock as V, createElementVNode as B, ref as i, watch as ee, onMounted as F, nextTick as g, computed as ne, onUnmounted as le, resolveComponent as R, createVNode as T, unref as y, isRef as te, withCtx as L, normalizeClass as oe, createBlock as E, Teleport as N, normalizeStyle as ae, Fragment as re, renderList as ue, createCommentVNode as q } from "vue";
1
+ import { defineComponent as F, openBlock as x, createElementBlock as D, createElementVNode as V, ref as i, watch as J, onMounted as O, nextTick as g, computed as Q, onUnmounted as Z, resolveComponent as R, createVNode as T, unref as b, isRef as ee, withCtx as E, normalizeClass as ne, normalizeStyle as le, Fragment as te, renderList as oe, createBlock as ae, createCommentVNode as re } from "vue";
2
2
  /*! Element Plus Icons Vue v2.3.2 */
3
- var se = /* @__PURE__ */ K({
3
+ var ue = /* @__PURE__ */ F({
4
4
  name: "ArrowDown",
5
5
  __name: "arrow-down",
6
6
  setup(u) {
7
- return (f, _) => (h(), V("svg", {
7
+ return (f, _) => (x(), D("svg", {
8
8
  xmlns: "http://www.w3.org/2000/svg",
9
9
  viewBox: "0 0 1024 1024"
10
10
  }, [
11
- B("path", {
11
+ V("path", {
12
12
  fill: "currentColor",
13
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
14
  })
15
15
  ]));
16
16
  }
17
- }), ce = se;
18
- const ie = /* @__PURE__ */ K({
17
+ }), se = ue;
18
+ const ce = {
19
+ key: 0,
20
+ class: "dropdown-overlay"
21
+ }, ie = /* @__PURE__ */ F({
19
22
  name: "InputSelectCompont",
20
23
  __name: "SelectTable",
21
24
  props: {
@@ -32,32 +35,32 @@ const ie = /* @__PURE__ */ K({
32
35
  emits: ["getInputRef", "handleChangeSelectValue"],
33
36
  setup(u, { emit: f }) {
34
37
  const _ = f, l = u;
35
- let d = i(), p = i(""), C = i(), D = i(), r = i(!1), M = i({
38
+ let d = i(), p = i(""), C = i(), I = i(), r = i(!1), A = i({
36
39
  top: "0px",
37
- left: "0px"
38
- // width: "0px",
39
- }), t = i(-1), b = i(!1), I = i(!1);
40
- ee(
40
+ left: "0px",
41
+ minWidth: "100%"
42
+ }), t = i(-1), h = i(!1), L = i(!1);
43
+ J(
41
44
  () => l.value,
42
45
  (e) => {
43
46
  p.value = e || "";
44
47
  },
45
48
  { immediate: !0 }
46
- ), F(() => {
49
+ ), O(() => {
47
50
  g(() => {
48
51
  _("getInputRef", C.value);
49
52
  });
50
53
  });
51
- const k = () => {
52
- if (!D.value)
54
+ const y = () => {
55
+ if (!I.value)
53
56
  return;
54
- const e = D.value.getBoundingClientRect(), n = window.pageYOffset || document.documentElement.scrollTop, a = window.pageXOffset || document.documentElement.scrollLeft;
55
- M.value = {
57
+ const e = I.value.getBoundingClientRect(), n = window.pageYOffset || document.documentElement.scrollTop, a = window.pageXOffset || document.documentElement.scrollLeft;
58
+ A.value = {
56
59
  top: `${e.bottom + n}px`,
57
60
  left: `${e.left + a}px`
58
61
  // width: `${rect.width}px`,
59
62
  };
60
- }, S = ne(() => {
63
+ }, S = Q(() => {
61
64
  const e = l.column?.map((c) => c.prop) || [
62
65
  "name",
63
66
  "engname",
@@ -68,7 +71,7 @@ const ie = /* @__PURE__ */ K({
68
71
  return t.value = -1, g(() => {
69
72
  const c = l.options || [], w = c.find((m) => m.name === l.value);
70
73
  if (d.value && d.value.setCurrentRow(w), w) {
71
- const m = O(
74
+ const m = P(
72
75
  e,
73
76
  a,
74
77
  c
@@ -77,24 +80,24 @@ const ie = /* @__PURE__ */ K({
77
80
  (o) => o.name === w.name
78
81
  );
79
82
  }
80
- }), O(e, a, n);
81
- }), U = (e) => {
83
+ }), P(e, a, n);
84
+ }), N = (e) => {
82
85
  e?.stopPropagation(), !l.readonly && (r.value ? s() : v());
83
- }, Y = () => {
86
+ }, q = () => {
84
87
  if (l.readonly) {
85
88
  s();
86
89
  return;
87
90
  }
88
91
  r.value || v(), t.value = -1;
89
92
  }, v = () => {
90
- l.readonly || I.value || (I.value = !0, r.value = !0, g(() => {
91
- k(), b.value = !1, setTimeout(() => {
92
- I.value = !1;
93
+ l.readonly || L.value || (L.value = !0, r.value = !0, g(() => {
94
+ y(), h.value = !1, setTimeout(() => {
95
+ L.value = !1;
93
96
  }, 100);
94
97
  }));
95
98
  }, s = () => {
96
- r.value = !1, b.value = !1;
97
- }, z = (e) => {
99
+ r.value = !1, h.value = !1;
100
+ }, M = (e) => {
98
101
  p.value = e.name, s(), g(() => {
99
102
  C.value?.focus();
100
103
  }), _("handleChangeSelectValue", {
@@ -102,25 +105,25 @@ const ie = /* @__PURE__ */ K({
102
105
  value: e.name,
103
106
  index: l.itemIndex ? l.itemIndex : ""
104
107
  });
105
- }, $ = (e) => {
106
- b.value = !0, e.preventDefault();
107
- }, j = (e) => {
108
+ }, K = (e) => {
109
+ h.value = !0, e.preventDefault();
110
+ }, U = (e) => {
108
111
  e.stopPropagation(), s();
109
- }, H = async () => {
112
+ }, Y = async () => {
110
113
  if (console.log("handleInput"), l.readonly) {
111
114
  s();
112
115
  return;
113
116
  }
114
117
  v(), t.value = -1;
115
- }, X = () => {
118
+ }, $ = () => {
116
119
  if (console.log("handleFocus"), l.readonly) {
117
120
  s();
118
121
  return;
119
122
  }
120
123
  r.value || v(), t.value = -1;
121
- }, G = () => {
122
- console.log("handleBlur", b.value), setTimeout(() => {
123
- if (b.value) {
124
+ }, j = () => {
125
+ console.log("handleBlur", h.value), setTimeout(() => {
126
+ if (h.value) {
124
127
  g(() => {
125
128
  C.value?.focus();
126
129
  });
@@ -128,22 +131,22 @@ const ie = /* @__PURE__ */ K({
128
131
  }
129
132
  s();
130
133
  }, 150);
131
- }, J = (e) => {
132
- S.value.length !== 0 && (e.key === "ArrowDown" ? (e.preventDefault(), r.value || v(), P(1)) : e.key === "ArrowUp" ? (e.preventDefault(), r.value || v(), P(-1)) : e.key === "Enter" ? (e.preventDefault(), r.value ? Q() : v()) : (e.key === "Escape" || e.key === "Tab") && s());
133
- }, P = (e) => {
134
+ }, H = (e) => {
135
+ S.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 ? W() : v()) : (e.key === "Escape" || e.key === "Tab") && s());
136
+ }, z = (e) => {
134
137
  const n = S.value;
135
138
  if (n.length === 0)
136
139
  return;
137
140
  t.value === -1 ? e === 1 ? t.value = 0 : t.value = n.length - 1 : (t.value += e, t.value < 0 ? t.value = n.length - 1 : t.value >= n.length && (t.value = 0));
138
141
  const a = n[t.value];
139
- d.value && d.value.setCurrentRow(a), W();
140
- }, Q = () => {
142
+ d.value && d.value.setCurrentRow(a), X();
143
+ }, W = () => {
141
144
  const e = S.value;
142
145
  if (e.length === 0 || t.value === -1)
143
146
  return;
144
147
  const n = e[t.value];
145
- z(n);
146
- }, W = () => {
148
+ M(n);
149
+ }, X = () => {
147
150
  g(() => {
148
151
  const e = d.value;
149
152
  if (!e)
@@ -157,7 +160,7 @@ const ie = /* @__PURE__ */ K({
157
160
  block: "nearest"
158
161
  });
159
162
  });
160
- }, O = (e, n, a) => {
163
+ }, P = (e, n, a) => {
161
164
  const c = n.trim().toLowerCase();
162
165
  return c ? a.filter(
163
166
  (w) => e.some((m) => {
@@ -166,50 +169,47 @@ const ie = /* @__PURE__ */ K({
166
169
  })
167
170
  ) : a;
168
171
  };
169
- return F(() => {
170
- window.addEventListener("resize", k), window.addEventListener("scroll", k, !0);
171
- }), le(() => {
172
- window.removeEventListener("resize", k), window.removeEventListener("scroll", k, !0);
172
+ return O(() => {
173
+ window.addEventListener("resize", y), window.addEventListener("scroll", y, !0);
174
+ }), Z(() => {
175
+ window.removeEventListener("resize", y), window.removeEventListener("scroll", y, !0);
173
176
  }), (e, n) => {
174
177
  const a = R("el-icon"), c = R("el-input"), w = R("el-table-column"), m = R("el-table");
175
- return h(), V("div", {
178
+ return x(), D("div", {
176
179
  class: "custom-dropdown",
177
180
  ref_key: "dropdownRef",
178
- ref: D
181
+ ref: I
179
182
  }, [
180
183
  T(c, {
181
- modelValue: y(p),
182
- "onUpdate:modelValue": n[0] || (n[0] = (o) => te(p) ? p.value = o : p = o),
184
+ modelValue: b(p),
185
+ "onUpdate:modelValue": n[0] || (n[0] = (o) => ee(p) ? p.value = o : p = o),
183
186
  ref_key: "inputValueRef",
184
187
  ref: C,
185
188
  readonly: l.readonly,
186
- onInput: H,
187
- onKeydown: J,
188
- onFocus: X,
189
- onBlur: G,
190
- onClick: Y
189
+ onInput: Y,
190
+ onKeydown: H,
191
+ onFocus: $,
192
+ onBlur: j,
193
+ onClick: q
191
194
  }, {
192
- suffix: L(() => [
195
+ suffix: E(() => [
193
196
  T(a, {
194
- class: oe(["el-input__icon dropdown-arrow", { "dropdown-arrow--open": y(r) }]),
195
- onClick: U
197
+ class: ne(["el-input__icon dropdown-arrow", { "dropdown-arrow--open": b(r) }]),
198
+ onClick: N
196
199
  }, {
197
- default: L(() => [
198
- T(y(ce))
200
+ default: E(() => [
201
+ T(b(se))
199
202
  ]),
200
203
  _: 1
201
204
  }, 8, ["class"])
202
205
  ]),
203
206
  _: 1
204
207
  }, 8, ["modelValue", "readonly"]),
205
- y(r) ? (h(), E(N, {
206
- key: 0,
207
- to: "body"
208
- }, [
209
- B("div", {
208
+ b(r) ? (x(), D("div", ce, [
209
+ V("div", {
210
210
  class: "dropdown-panel",
211
- style: ae(y(M)),
212
- onMousedown: $
211
+ style: le(b(A)),
212
+ onMousedown: K
213
213
  }, [
214
214
  T(m, {
215
215
  border: "",
@@ -218,12 +218,12 @@ const ie = /* @__PURE__ */ K({
218
218
  ref_key: "tableRef",
219
219
  ref: d,
220
220
  "max-height": "200px",
221
- onRowClick: z,
221
+ onRowClick: M,
222
222
  style: { width: "100%" }
223
223
  }, {
224
- default: L(() => [
225
- (h(!0), V(re, null, ue(l.column, (o, Z) => (h(), E(w, {
226
- key: Z,
224
+ default: E(() => [
225
+ (x(!0), D(te, null, oe(l.column, (o, G) => (x(), ae(w, {
226
+ key: G,
227
227
  prop: o.prop,
228
228
  label: o.label,
229
229
  width: o.width,
@@ -234,17 +234,12 @@ const ie = /* @__PURE__ */ K({
234
234
  ]),
235
235
  _: 1
236
236
  }, 8, ["data"])
237
- ], 36)
238
- ])) : q("", !0),
239
- y(r) ? (h(), E(N, {
240
- key: 1,
241
- to: "body"
242
- }, [
243
- B("div", {
237
+ ], 36),
238
+ V("div", {
244
239
  class: "dropdown-mask",
245
- onMousedown: j
240
+ onMousedown: U
246
241
  }, null, 32)
247
- ])) : q("", !0)
242
+ ])) : re("", !0)
248
243
  ], 512);
249
244
  };
250
245
  }
@@ -254,26 +249,26 @@ const de = (u, f) => {
254
249
  for (const [l, d] of f)
255
250
  _[l] = d;
256
251
  return _;
257
- }, x = /* @__PURE__ */ de(ie, [["__scopeId", "data-v-2301dea2"]]);
258
- x.install = (u) => {
259
- u.component(x.name, x);
252
+ }, k = /* @__PURE__ */ de(ie, [["__scopeId", "data-v-40f4afb7"]]);
253
+ k.install = (u) => {
254
+ u.component(k.name, k);
260
255
  };
261
256
  const fe = [
262
- x
263
- ], A = function(u) {
264
- A.installed || fe.forEach((f) => {
257
+ k
258
+ ], B = function(u) {
259
+ B.installed || fe.forEach((f) => {
265
260
  u.component(f.name, f);
266
261
  });
267
262
  };
268
- typeof window < "u" && window.Vue && A(window.Vue);
263
+ typeof window < "u" && window.Vue && B(window.Vue);
269
264
  const ve = {
270
265
  // 导出的对象必须具有 install,才能被 Vue.use() 方法安装
271
- install: A,
266
+ install: B,
272
267
  // 以下是具体的组件列表
273
- SelectTable: x
268
+ SelectTable: k
274
269
  };
275
270
  export {
276
- x as SelectTable,
271
+ k as SelectTable,
277
272
  ve as default,
278
- A as install
273
+ B as install
279
274
  };
@@ -1 +1 @@
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(""),C=e.ref(),S=e.ref(),s=e.ref(!1),B=e.ref({top:"0px",left:"0px"}),l=e.ref(-1),k=e.ref(!1),v=e.ref(!1);e.watch(()=>o.value,n=>{m.value=n||""},{immediate:!0}),e.onMounted(()=>{e.nextTick(()=>{g("getInputRef",C.value)})});const b=()=>{if(!S.value)return;const n=S.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`}},T=e.computed(()=>{const n=o.column?.map(u=>u.prop)||["name","engname","spell","zjm","infoOrder"],t=o.options||[],r=m.value||"";return l.value=-1,e.nextTick(()=>{const u=o.options||[],_=u.find(y=>y.name===o.value);if(f.value&&f.value.setCurrentRow(_),_){const y=E(n,r,u);l.value=y.findIndex(a=>a.name===_.name)}}),E(n,r,t)}),A=n=>{n?.stopPropagation(),!o.readonly&&(s.value?d():w())},P=()=>{if(o.readonly){d();return}s.value||w(),l.value=-1},w=()=>{o.readonly||v.value||(v.value=!0,s.value=!0,e.nextTick(()=>{b(),k.value=!1,setTimeout(()=>{v.value=!1},100)}))},d=()=>{s.value=!1,k.value=!1},R=n=>{m.value=n.name,d(),e.nextTick(()=>{C.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(),d()},q=async()=>{if(console.log("handleInput"),o.readonly){d();return}w(),l.value=-1},F=()=>{if(console.log("handleFocus"),o.readonly){d();return}s.value||w(),l.value=-1},j=()=>{console.log("handleBlur",k.value),setTimeout(()=>{if(k.value){e.nextTick(()=>{C.value?.focus()});return}d()},150)},K=n=>{T.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")&&d())},V=n=>{const t=T.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=T.value;if(n.length===0||l.value===-1)return;const t=n[l.value];R(t)},H=()=>{e.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 u=t.trim().toLowerCase();return u?r.filter(_=>n.some(y=>{const a=_[y];return a==null&&a!==0?!1:String(a).toLowerCase().includes(u)})):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"),u=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:S},[e.createVNode(u,{modelValue:e.unref(m),"onUpdate:modelValue":t[0]||(t[0]=a=>e.isRef(m)?m.value=a:m=a),ref_key:"inputValueRef",ref:C,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:T.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-2301dea2"]]);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"}})});
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 W="";/*! 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={key:0,class:"dropdown-overlay"},M=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,l=i;let f=e.ref(),m=e.ref(""),v=e.ref(),S=e.ref(),s=e.ref(!1),R=e.ref({top:"0px",left:"0px",minWidth:"100%"}),o=e.ref(-1),k=e.ref(!1),T=e.ref(!1);e.watch(()=>l.value,n=>{m.value=n||""},{immediate:!0}),e.onMounted(()=>{e.nextTick(()=>{g("getInputRef",v.value)})});const b=()=>{if(!S.value)return;const n=S.value.getBoundingClientRect(),t=window.pageYOffset||document.documentElement.scrollTop,r=window.pageXOffset||document.documentElement.scrollLeft;R.value={top:`${n.bottom+t}px`,left:`${n.left+r}px`}},C=e.computed(()=>{const n=l.column?.map(u=>u.prop)||["name","engname","spell","zjm","infoOrder"],t=l.options||[],r=m.value||"";return o.value=-1,e.nextTick(()=>{const u=l.options||[],_=u.find(h=>h.name===l.value);if(f.value&&f.value.setCurrentRow(_),_){const h=E(n,r,u);o.value=h.findIndex(a=>a.name===_.name)}}),E(n,r,t)}),P=n=>{n?.stopPropagation(),!l.readonly&&(s.value?d():w())},z=()=>{if(l.readonly){d();return}s.value||w(),o.value=-1},w=()=>{l.readonly||T.value||(T.value=!0,s.value=!0,e.nextTick(()=>{b(),k.value=!1,setTimeout(()=>{T.value=!1},100)}))},d=()=>{s.value=!1,k.value=!1},V=n=>{m.value=n.name,d(),e.nextTick(()=>{v.value?.focus()}),g("handleChangeSelectValue",{valueCode:n.code,value:n.name,index:l.itemIndex?l.itemIndex:""})},O=n=>{k.value=!0,n.preventDefault()},q=n=>{n.stopPropagation(),d()},F=async()=>{if(console.log("handleInput"),l.readonly){d();return}w(),o.value=-1},j=()=>{if(console.log("handleFocus"),l.readonly){d();return}s.value||w(),o.value=-1},K=()=>{console.log("handleBlur",k.value),setTimeout(()=>{if(k.value){e.nextTick(()=>{v.value?.focus()});return}d()},150)},U=n=>{C.value.length!==0&&(n.key==="ArrowDown"?(n.preventDefault(),s.value||w(),B(1)):n.key==="ArrowUp"?(n.preventDefault(),s.value||w(),B(-1)):n.key==="Enter"?(n.preventDefault(),s.value?H():w()):(n.key==="Escape"||n.key==="Tab")&&d())},B=n=>{const t=C.value;if(t.length===0)return;o.value===-1?n===1?o.value=0:o.value=t.length-1:(o.value+=n,o.value<0?o.value=t.length-1:o.value>=t.length&&(o.value=0));const r=t[o.value];f.value&&f.value.setCurrentRow(r),Y()},H=()=>{const n=C.value;if(n.length===0||o.value===-1)return;const t=n[o.value];V(t)},Y=()=>{e.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 u=t.trim().toLowerCase();return u?r.filter(_=>n.some(h=>{const a=_[h];return a==null&&a!==0?!1:String(a).toLowerCase().includes(u)})):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"),u=e.resolveComponent("el-input"),_=e.resolveComponent("el-table-column"),h=e.resolveComponent("el-table");return e.openBlock(),e.createElementBlock("div",{class:"custom-dropdown",ref_key:"dropdownRef",ref:S},[e.createVNode(u,{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:l.readonly,onInput:F,onKeydown:U,onFocus:j,onBlur:K,onClick:z},{suffix:e.withCtx(()=>[e.createVNode(r,{class:e.normalizeClass(["el-input__icon dropdown-arrow",{"dropdown-arrow--open":e.unref(s)}]),onClick:P},{default:e.withCtx(()=>[e.createVNode(e.unref(I))]),_:1},8,["class"])]),_:1},8,["modelValue","readonly"]),e.unref(s)?(e.openBlock(),e.createElementBlock("div",L,[e.createElementVNode("div",{class:"dropdown-panel",style:e.normalizeStyle(e.unref(R)),onMousedown:O},[e.createVNode(h,{border:"",data:C.value,"highlight-current-row":"",ref_key:"tableRef",ref:f,"max-height":"200px",onRowClick:V,style:{width:"100%"}},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.column,(a,$)=>(e.openBlock(),e.createBlock(_,{key:$,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.createElementVNode("div",{class:"dropdown-mask",onMousedown:q},null,32)])):e.createCommentVNode("",!0)],512)}}}),X="",y=((i,p)=>{const g=i.__vccOpts||i;for(const[l,f]of p)g[l]=f;return g})(M,[["__scopeId","data-v-40f4afb7"]]);y.install=i=>{i.component(y.name,y)};const N=[y],x=function(i){x.installed||N.forEach(p=>{i.component(p.name,p)})};typeof window<"u"&&window.Vue&&x(window.Vue);const A={install:x,SelectTable:y};c.SelectTable=y,c.default=A,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.22",
3
+ "version": "0.1.23",
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
- .custom-dropdown[data-v-2301dea2]{position:relative;width:100%}.dropdown-panel[data-v-2301dea2]{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-2301dea2]{position:fixed;inset:0;z-index:9998;background:transparent}.dropdown-arrow[data-v-2301dea2]{cursor:pointer;transition:transform .3s}.dropdown-arrow--open[data-v-2301dea2]{transform:rotate(180deg)}
1
+ .custom-dropdown[data-v-40f4afb7]{position:relative;width:100%}.dropdown-overlay[data-v-40f4afb7]{position:fixed;top:0;left:0;width:100%;height:100%;z-index:9998;pointer-events:none}.dropdown-panel[data-v-40f4afb7]{position:absolute;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;pointer-events:auto}.dropdown-mask[data-v-40f4afb7]{position:absolute;inset:0;z-index:9998;background:transparent;pointer-events:auto}.dropdown-arrow[data-v-40f4afb7]{cursor:pointer;transition:transform .3s}.dropdown-arrow--open[data-v-40f4afb7]{transform:rotate(180deg)}
Binary file