huiyi-select-table 0.1.23 → 0.1.24

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