@scvzerng/element-plus-search-vue2 0.0.4 → 0.0.6

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,16 +1,16 @@
1
- import { isFunction as V, keyBy as M, isNumber as z, isBoolean as P, isEmpty as U, chain as G, sum as W, isPlainObject as X } from "lodash-unified";
2
- import { defineComponent as D, ref as y, resolveComponent as g, createElementBlock as A, openBlock as f, createVNode as o, createElementVNode as b, withCtx as c, unref as u, Fragment as N, renderList as B, createBlock as w, createTextVNode as L, toDisplayString as F, reactive as H, shallowRef as J, isRef as Q, computed as j, normalizeStyle as Y, normalizeClass as Z, withDirectives as ee, vShow as te, createCommentVNode as q } from "vue";
3
- import { ArrowLeft as se, ArrowRight as ie, ArrowDown as re, ArrowUp as ne } from "@element-plus/icons-vue";
4
- import { Setting as le } from "@scvzerng/icons";
5
- import { watchDebounced as ae } from "@vueuse/core";
6
- const oe = { class: "tags-scroll-container" }, ce = ["innerHTML"], ue = /* @__PURE__ */ D({
1
+ import { isFunction as q, keyBy as P, isNumber as U, isBoolean as G, isEmpty as W, chain as X, sum as J, isPlainObject as Q } from "lodash-unified";
2
+ import { defineComponent as T, ref as v, resolveComponent as g, createElementBlock as C, openBlock as h, createVNode as o, createElementVNode as y, withCtx as c, unref as u, Fragment as H, renderList as K, createBlock as b, createTextVNode as x, toDisplayString as I, reactive as M, shallowRef as Y, isRef as Z, computed as R, normalizeStyle as ee, normalizeClass as te, withDirectives as se, vShow as ie, createCommentVNode as N } from "vue";
3
+ import { ArrowLeft as re, ArrowRight as ne, ArrowDown as ae, ArrowUp as le } from "@element-plus/icons-vue";
4
+ import { Setting as oe } from "@scvzerng/icons";
5
+ import { watchDebounced as ce } from "@vueuse/core";
6
+ const ue = { class: "tags-scroll-container" }, de = ["innerHTML"], he = /* @__PURE__ */ T({
7
7
  name: "SearchTags",
8
8
  __name: "SearchTagsRender",
9
9
  props: {
10
10
  tags: {}
11
11
  },
12
12
  setup(s) {
13
- const e = y(), t = () => {
13
+ const e = v(), t = () => {
14
14
  e.value.scrollBy({ left: -200, behavior: "smooth" });
15
15
  }, r = () => {
16
16
  e.value.scrollBy({
@@ -18,43 +18,43 @@ const oe = { class: "tags-scroll-container" }, ce = ["innerHTML"], ue = /* @__PU
18
18
  behavior: "smooth"
19
19
  });
20
20
  };
21
- return (i, n) => {
22
- const p = g("el-icon"), d = g("el-tag");
23
- return f(), A("div", oe, [
21
+ return (i, a) => {
22
+ const f = g("el-icon"), d = g("el-tag");
23
+ return h(), C("div", ue, [
24
24
  o(d, {
25
25
  type: "info",
26
26
  class: "scroll-left-bar",
27
27
  onClick: t
28
28
  }, {
29
29
  default: c(() => [
30
- o(p, null, {
30
+ o(f, null, {
31
31
  default: c(() => [
32
- o(u(se))
32
+ o(u(re))
33
33
  ]),
34
34
  _: 1
35
35
  }),
36
- n[0] || (n[0] = b("i", { class: "el-icon-arrow-left" }, null, -1))
36
+ a[0] || (a[0] = y("i", { class: "el-icon-arrow-left" }, null, -1))
37
37
  ]),
38
38
  _: 1
39
39
  }),
40
- b("div", {
40
+ y("div", {
41
41
  ref_key: "scrollContainer",
42
42
  ref: e,
43
43
  class: "search-tags"
44
44
  }, [
45
- (f(!0), A(N, null, B(s.tags, (m) => (f(), w(d, {
45
+ (h(!0), C(H, null, K(s.tags, (p) => (h(), b(d, {
46
46
  class: "search-tag",
47
- onClose: () => m.clean(),
48
- closable: !m.required,
49
- type: m.required ? "primary" : "info",
50
- key: m.field
47
+ onClose: () => p.clean(),
48
+ closable: !p.required,
49
+ type: p.required ? "primary" : "info",
50
+ key: p.field
51
51
  }, {
52
52
  default: c(() => [
53
- b("span", null, F(m.label), 1),
54
- n[1] || (n[1] = L(": ", -1)),
55
- b("span", {
56
- innerHTML: m.valueText
57
- }, null, 8, ce)
53
+ y("span", null, I(p.label), 1),
54
+ a[1] || (a[1] = x(": ", -1)),
55
+ y("span", {
56
+ innerHTML: p.valueText
57
+ }, null, 8, de)
58
58
  ]),
59
59
  _: 2
60
60
  }, 1032, ["onClose", "closable", "type"]))), 128))
@@ -65,9 +65,9 @@ const oe = { class: "tags-scroll-container" }, ce = ["innerHTML"], ue = /* @__PU
65
65
  onClick: r
66
66
  }, {
67
67
  default: c(() => [
68
- o(p, null, {
68
+ o(f, null, {
69
69
  default: c(() => [
70
- o(u(ie))
70
+ o(u(ne))
71
71
  ]),
72
72
  _: 1
73
73
  })
@@ -77,8 +77,8 @@ const oe = { class: "tags-scroll-container" }, ce = ["innerHTML"], ue = /* @__PU
77
77
  ]);
78
78
  };
79
79
  }
80
- }), K = 6;
81
- class de {
80
+ }), z = 6;
81
+ class fe {
82
82
  field;
83
83
  label;
84
84
  value;
@@ -93,7 +93,7 @@ class de {
93
93
  render;
94
94
  transform;
95
95
  constructor(e, t) {
96
- this.field = e.field, this.label = e.label, this.value = e.initValue, this.required = e.required, this.initValue = e.initValue, this.index = t, this.visible = e.visible ?? !0, this.span = e.span ?? K, this.render = e.render, this.tagFilter = e.tagFilter, this.transform = e.transform, this.enable = e.enable ?? !0, this.disabled = e.disabled ?? !1;
96
+ this.field = e.field, this.label = e.label, this.value = e.initValue, this.required = e.required, this.initValue = e.initValue, this.index = t, this.visible = e.visible ?? !0, this.span = e.span ?? z, this.render = e.render, this.tagFilter = e.tagFilter, this.transform = e.transform, this.enable = e.enable ?? !0, this.disabled = e.disabled ?? !1;
97
97
  }
98
98
  clean() {
99
99
  Array.isArray(this.value) ? this.value = [] : this.value = void 0;
@@ -102,13 +102,13 @@ class de {
102
102
  this.value = this.initValue;
103
103
  }
104
104
  isEnable(e) {
105
- return V(this.enable) ? this.enable(e.getSearchObject()) : this.enable;
105
+ return q(this.enable) ? this.enable(e.getSearchObject()) : this.enable;
106
106
  }
107
107
  isDisabled(e) {
108
- return V(this.disabled) ? this.disabled(e.getSearchObject()) : this.disabled;
108
+ return q(this.disabled) ? this.disabled(e.getSearchObject()) : this.disabled;
109
109
  }
110
110
  }
111
- class x {
111
+ class S {
112
112
  field;
113
113
  span;
114
114
  index;
@@ -117,7 +117,7 @@ class x {
117
117
  this.field = e, this.span = t, this.index = r, this.visible = i;
118
118
  }
119
119
  static fromSearchItem(e, t) {
120
- return new x(
120
+ return new S(
121
121
  e.field,
122
122
  e.span,
123
123
  t ?? e.index,
@@ -125,16 +125,16 @@ class x {
125
125
  );
126
126
  }
127
127
  static formSearchConfig(e, t) {
128
- return new x(
128
+ return new S(
129
129
  e.field,
130
- e.span ?? K,
130
+ e.span ?? z,
131
131
  t ?? e,
132
132
  e.visible ?? !0
133
133
  );
134
134
  }
135
135
  static fromString(e) {
136
- const [t, r, i, n] = e.split("_");
137
- return new x(r, Number(i), Number(t), n === "true");
136
+ const [t, r, i, a] = e.split("_");
137
+ return new S(r, Number(i), Number(t), a === "true");
138
138
  }
139
139
  toString() {
140
140
  return `${this.index}_${this.field}_${this.span}_${this.visible}`;
@@ -143,23 +143,23 @@ class x {
143
143
  this.span = e.span, this.index = e.index, this.visible = e.visible;
144
144
  }
145
145
  }
146
- const O = (s) => `searches_layouts_${s}`;
147
- class he {
146
+ const B = (s) => `searches_layouts_${s}`;
147
+ class pe {
148
148
  id;
149
149
  state;
150
150
  itemLayouts;
151
151
  initialLayouts;
152
152
  constructor(e, t) {
153
- this.id = e.id, this.initialLayouts = t, this.state = e, this.itemLayouts = M(e.items.map(x.fromSearchItem), (r) => r.field), this.restoreCachedLayouts();
153
+ this.id = e.id, this.initialLayouts = t, this.state = e, this.itemLayouts = P(e.items.map(S.fromSearchItem), (r) => r.field), this.restoreCachedLayouts();
154
154
  }
155
155
  /**
156
156
  * 恢复自缓存中的布局信息
157
157
  * @private
158
158
  */
159
159
  restoreCachedLayouts() {
160
- const e = localStorage.getItem(O(this.id));
160
+ const e = localStorage.getItem(B(this.id));
161
161
  e && e.split(",").forEach((t) => {
162
- const r = x.fromString(t), i = this.itemLayouts[r.field];
162
+ const r = S.fromString(t), i = this.itemLayouts[r.field];
163
163
  i && i.merge(r);
164
164
  });
165
165
  }
@@ -167,13 +167,13 @@ class he {
167
167
  if (e.length !== Object.keys(this.itemLayouts).length)
168
168
  throw new Error("同步布局字段数量不一致");
169
169
  e.forEach((r, i) => {
170
- const n = this.itemLayouts[r];
171
- n.index = i, n.visible = t.has(r);
170
+ const a = this.itemLayouts[r];
171
+ a.index = i, a.visible = t.has(r);
172
172
  });
173
173
  }
174
174
  persistent() {
175
175
  localStorage.setItem(
176
- O(this.id),
176
+ B(this.id),
177
177
  Object.values(this.itemLayouts).map((e) => e.toString()).join(",")
178
178
  ), this.state.updateTags();
179
179
  }
@@ -184,7 +184,7 @@ class he {
184
184
  });
185
185
  }
186
186
  }
187
- const fe = [
187
+ const ge = [
188
188
  {
189
189
  isApply(s) {
190
190
  return s.contains("el-radio-group");
@@ -260,7 +260,7 @@ const fe = [
260
260
  }
261
261
  }
262
262
  ];
263
- class R {
263
+ class F {
264
264
  id;
265
265
  field;
266
266
  value;
@@ -273,25 +273,25 @@ class R {
273
273
  this.id = `#${e.id}-${t.field}`, this.state = e, this.field = t.field, this.value = t.value, this.label = t.label, this.item = t, this.required = t.required ?? !1, this.updateValueText();
274
274
  }
275
275
  static hasValue(e) {
276
- return z(e.value) || P(e.value) ? !0 : !U(e.value);
276
+ return U(e.value) || G(e.value) ? !0 : !W(e.value);
277
277
  }
278
278
  updateValueText() {
279
279
  const e = document.querySelector(this.id);
280
280
  if (e.children.length !== 1)
281
281
  throw new Error("holder children length is not 1");
282
- const t = e.children[0], r = fe.find((i) => i.isApply(t.classList));
282
+ const t = e.children[0], r = ge.find((i) => i.isApply(t.classList));
283
283
  r && (this.valueText = r.getText(t, this));
284
284
  }
285
285
  async clean() {
286
286
  this.item.clean(), await this.state.doSearch();
287
287
  }
288
288
  }
289
- class pe {
289
+ class me {
290
290
  constructor(e, t, r) {
291
- this.id = e, this.id = e, this.items = t.map((i, n) => new de(i, n)), this.config = H(
292
- new he(
291
+ this.id = e, this.id = e, this.items = t.map((i, a) => new fe(i, a)), this.config = M(
292
+ new pe(
293
293
  this,
294
- t.map((i, n) => x.formSearchConfig(i, n))
294
+ t.map((i, a) => S.formSearchConfig(i, a))
295
295
  )
296
296
  ), this.sourceSearchable = t, this.searching = !1, this.searchCallback = r, this.tags = [];
297
297
  }
@@ -303,7 +303,7 @@ class pe {
303
303
  sourceSearchable;
304
304
  _lastSearchObject = { time: 0, data: null };
305
305
  updateTags() {
306
- this.tags = this.items.filter((e) => e.tagFilter ? e.tagFilter(e.value) : R.hasValue(e)).map((e) => new R(this, e)).sort(
306
+ this.tags = this.items.filter((e) => e.tagFilter ? e.tagFilter(e.value) : F.hasValue(e)).map((e) => new F(this, e)).sort(
307
307
  (e, t) => this.config.itemLayouts[e.field].index - this.config.itemLayouts[t.field].index
308
308
  );
309
309
  }
@@ -327,38 +327,38 @@ class pe {
327
327
  r && (r.value = t);
328
328
  }
329
329
  }
330
- const me = ({ search: s, api: e }) => {
330
+ const ve = ({ search: s, api: e }) => {
331
331
  const t = s.render(s);
332
332
  return t.props || (t.props = {}), s.isDisabled(e) && (t.props.disabled = !0), t;
333
- }, ge = () => {
334
- const s = J(), e = y(), t = y([]), r = y(!1), i = y(), n = y([]), p = y(300), d = (a) => {
335
- s.value = a, t.value = [
333
+ }, ye = () => {
334
+ const s = Y(), e = v(), t = v([]), r = v(!1), i = v(), a = v([]), f = v(300), d = (l) => {
335
+ s.value = l, t.value = [
336
336
  {
337
337
  label: "全部",
338
338
  id: "all",
339
339
  children: s.value.items.sort(
340
- (h, v) => a.config.itemLayouts[h.field].index - a.config.itemLayouts[v.field].index
341
- ).map((h) => ({
342
- label: h.label,
343
- id: h.field,
344
- disabled: !h.isEnable(a)
340
+ (n, m) => l.config.itemLayouts[n.field].index - l.config.itemLayouts[m.field].index
341
+ ).map((n) => ({
342
+ label: n.label,
343
+ id: n.field,
344
+ disabled: !n.isEnable(l)
345
345
  }))
346
346
  }
347
- ], i.value = G(a.config.itemLayouts).pickBy((h) => h.visible).keys().value();
347
+ ], i.value = X(l.config.itemLayouts).pickBy((n) => n.visible).keys().value();
348
348
  };
349
349
  return {
350
350
  treeRef: e,
351
351
  visible: r,
352
352
  snapshot: t,
353
353
  defaultCheckedKeys: i,
354
- drawerWidth: p,
354
+ drawerWidth: f,
355
355
  updateSnapshot: d,
356
- show: (a) => {
357
- d(a), r.value = !0;
356
+ show: (l) => {
357
+ d(l), r.value = !0;
358
358
  },
359
359
  save: () => {
360
360
  s.value.config.sync(
361
- t.value[0].children.map((a) => a.id),
361
+ t.value[0].children.map((l) => l.id),
362
362
  new Set(e.value.getCheckedKeys())
363
363
  ), s.value.config.persistent();
364
364
  },
@@ -366,103 +366,103 @@ const me = ({ search: s, api: e }) => {
366
366
  s.value.config.reset(), d(s.value);
367
367
  },
368
368
  keepSelection: () => {
369
- n.value = e.value.getCheckedKeys();
369
+ a.value = e.value.getCheckedKeys();
370
370
  },
371
371
  restoreSelection: () => {
372
- e.value.setCheckedKeys(n.value), n.value = [];
372
+ e.value.setCheckedKeys(a.value), a.value = [];
373
373
  },
374
- allowDrop: (a, h, v) => v !== "inner",
375
- allowDrag: (a) => !a.disabled
374
+ allowDrop: (l, n, m) => m !== "inner",
375
+ allowDrag: (l) => !l.disabled
376
376
  };
377
- }, ve = /* @__PURE__ */ D({
377
+ }, be = /* @__PURE__ */ T({
378
378
  __name: "SearchSettingsDrawer",
379
379
  setup(s, { expose: e }) {
380
380
  const {
381
381
  treeRef: t,
382
382
  visible: r,
383
383
  snapshot: i,
384
- drawerWidth: n,
385
- defaultCheckedKeys: p,
384
+ drawerWidth: a,
385
+ defaultCheckedKeys: f,
386
386
  show: d,
387
- allowDrop: m,
388
- allowDrag: T,
389
- keepSelection: k,
390
- restoreSelection: $,
391
- save: S,
392
- reset: l
393
- } = ge();
387
+ allowDrop: p,
388
+ allowDrag: k,
389
+ keepSelection: w,
390
+ restoreSelection: L,
391
+ save: A,
392
+ reset: j
393
+ } = ye();
394
394
  return e({
395
395
  show: d
396
- }), (C, a) => {
397
- const h = g("el-tree"), v = g("el-button"), _ = g("el-drawer");
398
- return f(), w(_, {
396
+ }), (V, l) => {
397
+ const n = g("el-tree"), m = g("el-button"), D = g("el-drawer");
398
+ return h(), b(D, {
399
399
  class: "search-setting",
400
- size: u(n),
400
+ size: u(a),
401
401
  title: "搜索项配置",
402
402
  modelValue: u(r),
403
- "onUpdate:modelValue": a[0] || (a[0] = (I) => Q(r) ? r.value = I : null)
403
+ "onUpdate:modelValue": l[0] || (l[0] = (O) => Z(r) ? r.value = O : null)
404
404
  }, {
405
405
  footer: c(() => [
406
- o(v, { onClick: u(l) }, {
407
- default: c(() => [...a[1] || (a[1] = [
408
- L("重置", -1)
406
+ o(m, { onClick: u(j) }, {
407
+ default: c(() => [...l[1] || (l[1] = [
408
+ x("重置", -1)
409
409
  ])]),
410
410
  _: 1
411
411
  }, 8, ["onClick"]),
412
- o(v, {
412
+ o(m, {
413
413
  type: "primary",
414
- onClick: u(S)
414
+ onClick: u(A)
415
415
  }, {
416
- default: c(() => [...a[2] || (a[2] = [
417
- L("保存", -1)
416
+ default: c(() => [...l[2] || (l[2] = [
417
+ x("保存", -1)
418
418
  ])]),
419
419
  _: 1
420
420
  }, 8, ["onClick"])
421
421
  ]),
422
422
  default: c(() => [
423
- o(h, {
423
+ o(n, {
424
424
  class: "tree",
425
425
  "default-expand-all": "",
426
- "default-checked-keys": u(p),
426
+ "default-checked-keys": u(f),
427
427
  "node-key": "id",
428
428
  ref_key: "treeRef",
429
429
  ref: t,
430
430
  draggable: "",
431
431
  "show-checkbox": "",
432
432
  data: u(i),
433
- onNodeDragStart: u(k),
434
- onNodeDragEnd: u($),
435
- "allow-drop": u(m),
436
- "allow-drag": u(T)
433
+ onNodeDragStart: u(w),
434
+ onNodeDragEnd: u(L),
435
+ "allow-drop": u(p),
436
+ "allow-drag": u(k)
437
437
  }, null, 8, ["default-checked-keys", "data", "onNodeDragStart", "onNodeDragEnd", "allow-drop", "allow-drag"])
438
438
  ]),
439
439
  _: 1
440
440
  }, 8, ["size", "modelValue"]);
441
441
  };
442
442
  }
443
- }), ye = /* @__PURE__ */ D({
443
+ }), _e = /* @__PURE__ */ T({
444
444
  __name: "SettingButton",
445
445
  props: {
446
446
  state: {}
447
447
  },
448
448
  setup(s) {
449
- const e = s, t = y(), r = () => {
449
+ const e = s, t = v(), r = () => {
450
450
  t.value.show(e.state);
451
451
  };
452
- return (i, n) => {
453
- const p = g("el-icon"), d = g("el-button");
454
- return f(), w(d, {
452
+ return (i, a) => {
453
+ const f = g("el-icon"), d = g("el-button");
454
+ return h(), b(d, {
455
455
  class: "icon-button",
456
456
  onClick: r
457
457
  }, {
458
458
  default: c(() => [
459
- o(p, null, {
459
+ o(f, null, {
460
460
  default: c(() => [
461
- o(u(le))
461
+ o(u(oe))
462
462
  ]),
463
463
  _: 1
464
464
  }),
465
- o(ve, {
465
+ o(be, {
466
466
  ref_key: "searchSettingDialogRef",
467
467
  ref: t
468
468
  }, null, 512)
@@ -471,7 +471,7 @@ const me = ({ search: s, api: e }) => {
471
471
  });
472
472
  };
473
473
  }
474
- }), _e = { class: "search-bar-container" }, be = { class: "search-item" }, Se = { class: "search-item-title" }, we = ["id"], xe = { class: "search-bottom" }, ke = { class: "actions" }, $e = /* @__PURE__ */ D({
474
+ }), Se = { class: "search-bar-container" }, we = { class: "search-item" }, xe = { class: "search-item-title" }, ke = ["id"], Ce = { class: "search-bottom" }, Te = { class: "actions" }, $e = /* @__PURE__ */ T({
475
475
  __name: "SearchBar",
476
476
  props: {
477
477
  searches: {},
@@ -484,89 +484,96 @@ const me = ({ search: s, api: e }) => {
484
484
  },
485
485
  emits: ["change"],
486
486
  setup(s, { expose: e, emit: t }) {
487
- const r = s, i = H(new pe(r.id, r.searches, r.onSearch)), n = y(!1), p = j(() => W(Array.from(Object.values(i.config.itemLayouts)).filter((l) => l.visible).map((l) => l.span)) / 24 > r.maxRows), d = y([]), m = t;
488
- ae(() => i.items, () => {
489
- const S = [...i.items];
490
- d.value = S.sort((l, C) => i.config.itemLayouts[l.field].index - i.config.itemLayouts[C.field].index).filter((l) => i.config.itemLayouts[l.field].visible).filter((l) => l.isEnable(i)), m("change", i.getSearchObject(), i);
487
+ const r = s, i = M(new me(r.id, r.searches, r.onSearch)), a = v(!1), f = R(() => J(Array.from(Object.values(i.config.itemLayouts)).filter((n) => n.visible).map((n) => n.span)) / 24 > r.maxRows), d = v([]), p = t;
488
+ ce(() => i.items, () => {
489
+ const l = [...i.items];
490
+ d.value = l.sort((n, m) => i.config.itemLayouts[n.field].index - i.config.itemLayouts[m.field].index).filter((n) => i.config.itemLayouts[n.field].visible).filter((n) => n.isEnable(i)), p("change", i.getSearchObject(), i);
491
491
  }, { debounce: 100, immediate: !0, deep: !0 });
492
- const T = j(() => ({
492
+ const k = R(() => ({
493
493
  height: `${r.itemHeight * r.maxRows}px`,
494
494
  overflow: "hidden"
495
- })), k = (S) => i.config.itemLayouts[S.field];
495
+ })), w = (l) => i.config.itemLayouts[l.field];
496
496
  return e({
497
- getSearchItems: () => i.items
498
- }), (S, l) => {
499
- const C = g("el-col"), a = g("el-row"), h = g("el-icon"), v = g("el-button");
500
- return f(), A("div", _e, [
501
- o(a, {
502
- class: Z("search"),
503
- style: Y(p.value && !n.value ? T.value : {}),
497
+ getSearchItems: () => i.items,
498
+ getSearchObject: () => i.getSearchObject(),
499
+ updateSearching: (l) => {
500
+ i.searching = l;
501
+ },
502
+ updateTags: () => {
503
+ i.updateTags();
504
+ }
505
+ }), (l, n) => {
506
+ const m = g("el-col"), D = g("el-row"), O = g("el-icon"), $ = g("el-button");
507
+ return h(), C("div", Se, [
508
+ o(D, {
509
+ class: te("search"),
510
+ style: ee(f.value && !a.value ? k.value : {}),
504
511
  gutter: 16
505
512
  }, {
506
513
  default: c(() => [
507
- (f(!0), A(N, null, B(d.value, (_) => ee((f(), w(C, {
508
- span: k(_).span,
514
+ (h(!0), C(H, null, K(d.value, (_) => se((h(), b(m, {
515
+ span: w(_).span,
509
516
  key: _.field
510
517
  }, {
511
518
  default: c(() => [
512
- b("div", be, [
513
- b("div", Se, F(_.label), 1),
514
- b("div", {
519
+ y("div", we, [
520
+ y("div", xe, I(_.label), 1),
521
+ y("div", {
515
522
  id: `${s.id}-${_.field}`,
516
523
  class: "search-item-content"
517
524
  }, [
518
- o(u(me), {
525
+ o(u(ve), {
519
526
  search: _,
520
527
  api: i
521
528
  }, null, 8, ["search", "api"])
522
- ], 8, we)
529
+ ], 8, ke)
523
530
  ])
524
531
  ]),
525
532
  _: 2
526
533
  }, 1032, ["span"])), [
527
- [te, k(_).visible]
534
+ [ie, w(_).visible]
528
535
  ])), 128))
529
536
  ]),
530
537
  _: 1
531
538
  }, 8, ["style"]),
532
- b("div", xe, [
533
- i.tags.length > 0 ? (f(), w(ue, {
539
+ y("div", Ce, [
540
+ i.tags.length > 0 ? (h(), b(he, {
534
541
  key: 0,
535
542
  tags: i.tags
536
- }, null, 8, ["tags"])) : q("", !0),
537
- b("div", ke, [
538
- p.value ? (f(), w(v, {
543
+ }, null, 8, ["tags"])) : N("", !0),
544
+ y("div", Te, [
545
+ f.value ? (h(), b($, {
539
546
  key: 0,
540
547
  class: "icon-button",
541
- onClick: l[0] || (l[0] = (_) => n.value = !n.value)
548
+ onClick: n[0] || (n[0] = (_) => a.value = !a.value)
542
549
  }, {
543
550
  default: c(() => [
544
- o(h, null, {
551
+ o(O, null, {
545
552
  default: c(() => [
546
- n.value ? (f(), w(u(ne), { key: 1 })) : (f(), w(u(re), { key: 0 }))
553
+ a.value ? (h(), b(u(le), { key: 1 })) : (h(), b(u(ae), { key: 0 }))
547
554
  ]),
548
555
  _: 1
549
556
  })
550
557
  ]),
551
558
  _: 1
552
- })) : q("", !0),
553
- o(ye, { state: i }, null, 8, ["state"]),
554
- o(v, {
555
- onClick: l[1] || (l[1] = () => i.reset(s.resetAutoSearch))
559
+ })) : N("", !0),
560
+ o(_e, { state: i }, null, 8, ["state"]),
561
+ o($, {
562
+ onClick: n[1] || (n[1] = () => i.reset(s.resetAutoSearch))
556
563
  }, {
557
- default: c(() => [...l[3] || (l[3] = [
558
- L("重 置", -1)
564
+ default: c(() => [...n[3] || (n[3] = [
565
+ x("重 置", -1)
559
566
  ])]),
560
567
  _: 1
561
568
  }),
562
- o(v, {
569
+ o($, {
563
570
  type: "primary",
564
571
  loading: i.searching,
565
572
  disabled: i.searching,
566
- onClick: l[2] || (l[2] = () => i.doSearch())
573
+ onClick: n[2] || (n[2] = () => i.doSearch())
567
574
  }, {
568
- default: c(() => [...l[4] || (l[4] = [
569
- L("搜 索", -1)
575
+ default: c(() => [...n[4] || (n[4] = [
576
+ x("搜 索", -1)
570
577
  ])]),
571
578
  _: 1
572
579
  }, 8, ["loading", "disabled"])
@@ -575,6 +582,30 @@ const me = ({ search: s, api: e }) => {
575
582
  ]);
576
583
  };
577
584
  }
585
+ }), Ee = (s, e, t) => ({
586
+ /**
587
+ * 数据刷新回调代理
588
+ *
589
+ * 填充数据拉取接口的搜索参数
590
+ * @param param
591
+ */
592
+ refreshCallback: async (r) => {
593
+ const i = e.value.getSearchObject();
594
+ try {
595
+ return e.value.updateSearching(!0), await s(i, r);
596
+ } finally {
597
+ e.value.updateSearching(!1), e.value.updateTags();
598
+ }
599
+ },
600
+ /**
601
+ * 搜索项搜索按钮点击时触发
602
+ *
603
+ * 回调所有的可刷新组件
604
+ */
605
+ searchCallback: async () => {
606
+ for (const r of t)
607
+ await r.value?.refresh();
608
+ }
578
609
  });
579
610
  class E {
580
611
  record;
@@ -584,10 +615,10 @@ class E {
584
615
  static from(e) {
585
616
  const t = e.filter((r) => r.value === void 0 ? !1 : Array.isArray(r.value) ? r.value.length > 0 : !0).reduce(
586
617
  (r, i) => {
587
- const n = i.transform ? i.transform(i.value) : i.value;
618
+ const a = i.transform ? i.transform(i.value) : i.value;
588
619
  return {
589
620
  ...r,
590
- ...X(n) ? n : { [i.field]: n }
621
+ ...Q(a) ? a : { [i.field]: a }
591
622
  };
592
623
  },
593
624
  {}
@@ -604,5 +635,6 @@ class E {
604
635
  }
605
636
  export {
606
637
  $e as SearchBar,
607
- E as Searches
638
+ E as Searches,
639
+ Ee as useSearchProxy
608
640
  };
@@ -1 +1 @@
1
- (function(h,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("lodash-unified"),require("vue"),require("@element-plus/icons-vue"),require("@scvzerng/icons"),require("@vueuse/core")):typeof define=="function"&&define.amd?define(["exports","lodash-unified","vue","@element-plus/icons-vue","@scvzerng/icons","@vueuse/core"],d):(h=typeof globalThis<"u"?globalThis:h||self,d(h.ElementPlusSearch={},h.lodashUnified,h.vue,h.iconsVue,h.icons,h.core))})(this,(function(h,d,e,w,L,B){"use strict";const E={class:"tags-scroll-container"},A=["innerHTML"],D=e.defineComponent({name:"SearchTags",__name:"SearchTagsRender",props:{tags:{}},setup(n){const t=e.ref(),r=()=>{t.value.scrollBy({left:-200,behavior:"smooth"})},i=()=>{t.value.scrollBy({left:200,behavior:"smooth"})};return(s,o)=>{const f=e.resolveComponent("el-icon"),c=e.resolveComponent("el-tag");return e.openBlock(),e.createElementBlock("div",E,[e.createVNode(c,{type:"info",class:"scroll-left-bar",onClick:r},{default:e.withCtx(()=>[e.createVNode(f,null,{default:e.withCtx(()=>[e.createVNode(e.unref(w.ArrowLeft))]),_:1}),o[0]||(o[0]=e.createElementVNode("i",{class:"el-icon-arrow-left"},null,-1))]),_:1}),e.createElementVNode("div",{ref_key:"scrollContainer",ref:t,class:"search-tags"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.tags,p=>(e.openBlock(),e.createBlock(c,{class:"search-tag",onClose:()=>p.clean(),closable:!p.required,type:p.required?"primary":"info",key:p.field},{default:e.withCtx(()=>[e.createElementVNode("span",null,e.toDisplayString(p.label),1),o[1]||(o[1]=e.createTextVNode(": ",-1)),e.createElementVNode("span",{innerHTML:p.valueText},null,8,A)]),_:2},1032,["onClose","closable","type"]))),128))],512),e.createVNode(c,{type:"info",class:"scroll-right-bar",onClick:i},{default:e.withCtx(()=>[e.createVNode(f,null,{default:e.withCtx(()=>[e.createVNode(e.unref(w.ArrowRight))]),_:1})]),_:1})])}}}),V=6;class q{field;label;value;required;index;visible;disabled;span;initValue;enable;tagFilter;render;transform;constructor(t,r){this.field=t.field,this.label=t.label,this.value=t.initValue,this.required=t.required,this.initValue=t.initValue,this.index=r,this.visible=t.visible??!0,this.span=t.span??V,this.render=t.render,this.tagFilter=t.tagFilter,this.transform=t.transform,this.enable=t.enable??!0,this.disabled=t.disabled??!1}clean(){Array.isArray(this.value)?this.value=[]:this.value=void 0}reset(){this.value=this.initValue}isEnable(t){return d.isFunction(this.enable)?this.enable(t.getSearchObject()):this.enable}isDisabled(t){return d.isFunction(this.disabled)?this.disabled(t.getSearchObject()):this.disabled}}class _{field;span;index;visible;constructor(t,r,i,s){this.field=t,this.span=r,this.index=i,this.visible=s}static fromSearchItem(t,r){return new _(t.field,t.span,r??t.index,t.visible)}static formSearchConfig(t,r){return new _(t.field,t.span??V,r??t,t.visible??!0)}static fromString(t){const[r,i,s,o]=t.split("_");return new _(i,Number(s),Number(r),o==="true")}toString(){return`${this.index}_${this.field}_${this.span}_${this.visible}`}merge(t){this.span=t.span,this.index=t.index,this.visible=t.visible}}const N=n=>`searches_layouts_${n}`;class ${id;state;itemLayouts;initialLayouts;constructor(t,r){this.id=t.id,this.initialLayouts=r,this.state=t,this.itemLayouts=d.keyBy(t.items.map(_.fromSearchItem),i=>i.field),this.restoreCachedLayouts()}restoreCachedLayouts(){const t=localStorage.getItem(N(this.id));t&&t.split(",").forEach(r=>{const i=_.fromString(r),s=this.itemLayouts[i.field];s&&s.merge(i)})}sync(t,r){if(t.length!==Object.keys(this.itemLayouts).length)throw new Error("同步布局字段数量不一致");t.forEach((i,s)=>{const o=this.itemLayouts[i];o.index=s,o.visible=r.has(i)})}persistent(){localStorage.setItem(N(this.id),Object.values(this.itemLayouts).map(t=>t.toString()).join(",")),this.state.updateTags()}reset(){this.initialLayouts.forEach(t=>{const r=this.itemLayouts[t.field];r&&r.merge(t)})}}const j=[{isApply(n){return n.contains("el-radio-group")},getText(n){return n.querySelector(".is-active")?.querySelector("input")?.value}},{isApply(n){return n.contains("el-checkbox-group")},getText(n){const t=Array.from(n.querySelectorAll(".el-checkbox__input.is-checked")??[]).map(r=>r.querySelector("input")?.value).filter(r=>r);return t.length===1?t[0]:`${t[0]} 等${t.length}条`}},{isApply(n){return n.contains("el-input")},getText(n,t){return t.value}},{isApply(n){return n.contains("el-input-number")},getText(n,t){return t.value}},{isApply(n){return n.contains("el-select")},getText(n,t){const r=n.querySelectorAll(".el-select__tags-text");return r.length>0?t.value.length>1?`${r[0].textContent} 等${t.value.length}条`:r[0].textContent:n.querySelector(".el-select__placeholder")?.innerHTML}},{isApply(n){return n.contains("el-cascader")},getText(n){return n.querySelector("input")?.value}},{isApply(n){return n.contains("el-switch")},getText(n){return n.querySelector(".is-active").innerHTML}},{isApply(n){return n.contains("el-slider")},getText(n,t){return t.value}},{isApply(n){return n.contains("el-date-editor")},getText(n,t){return t.value?t.value.join(" ~ "):t.value}}];class T{id;field;value;label;valueText;required;item;state;constructor(t,r){this.id=`#${t.id}-${r.field}`,this.state=t,this.field=r.field,this.value=r.value,this.label=r.label,this.item=r,this.required=r.required??!1,this.updateValueText()}static hasValue(t){return d.isNumber(t.value)||d.isBoolean(t.value)?!0:!d.isEmpty(t.value)}updateValueText(){const t=document.querySelector(this.id);if(t.children.length!==1)throw new Error("holder children length is not 1");const r=t.children[0],i=j.find(s=>s.isApply(r.classList));i&&(this.valueText=i.getText(r,this))}async clean(){this.item.clean(),await this.state.doSearch()}}class O{constructor(t,r,i){this.id=t,this.id=t,this.items=r.map((s,o)=>new q(s,o)),this.config=e.reactive(new $(this,r.map((s,o)=>_.formSearchConfig(s,o)))),this.sourceSearchable=r,this.searching=!1,this.searchCallback=i,this.tags=[]}items;config;searching;tags;searchCallback;sourceSearchable;_lastSearchObject={time:0,data:null};updateTags(){this.tags=this.items.filter(t=>t.tagFilter?t.tagFilter(t.value):T.hasValue(t)).map(t=>new T(this,t)).sort((t,r)=>this.config.itemLayouts[t.field].index-this.config.itemLayouts[r.field].index)}getSearchObject(t){const r=Date.now();return this._lastSearchObject.data&&r-this._lastSearchObject.time<50?this._lastSearchObject.data:(this._lastSearchObject={time:r,data:x.from(this.items).toCondition(t)},this._lastSearchObject.data)}async doSearch(){if(!this.searching)try{this.searching=!0,await this.searchCallback(this.getSearchObject()),this.updateTags()}finally{this.searching=!1}}async reset(t){this.items.forEach(r=>r.reset()),t&&await this.doSearch()}setSearchValue(t,r){const i=this.items.find(s=>s.field===t);i&&(i.value=r)}}const R=({search:n,api:t})=>{const r=n.render(n);return r.props||(r.props={}),n.isDisabled(t)&&(r.props.disabled=!0),r},F=()=>{const n=e.shallowRef(),t=e.ref(),r=e.ref([]),i=e.ref(!1),s=e.ref(),o=e.ref([]),f=e.ref(300),c=a=>{n.value=a,r.value=[{label:"全部",id:"all",children:n.value.items.sort((u,m)=>a.config.itemLayouts[u.field].index-a.config.itemLayouts[m.field].index).map(u=>({label:u.label,id:u.field,disabled:!u.isEnable(a)}))}],s.value=d.chain(a.config.itemLayouts).pickBy(u=>u.visible).keys().value()};return{treeRef:t,visible:i,snapshot:r,defaultCheckedKeys:s,drawerWidth:f,updateSnapshot:c,show:a=>{c(a),i.value=!0},save:()=>{n.value.config.sync(r.value[0].children.map(a=>a.id),new Set(t.value.getCheckedKeys())),n.value.config.persistent()},reset:()=>{n.value.config.reset(),c(n.value)},keepSelection:()=>{o.value=t.value.getCheckedKeys()},restoreSelection:()=>{t.value.setCheckedKeys(o.value),o.value=[]},allowDrop:(a,u,m)=>m!=="inner",allowDrag:a=>!a.disabled}},H=e.defineComponent({__name:"SearchSettingsDrawer",setup(n,{expose:t}){const{treeRef:r,visible:i,snapshot:s,drawerWidth:o,defaultCheckedKeys:f,show:c,allowDrop:p,allowDrag:C,keepSelection:S,restoreSelection:k,save:y,reset:l}=F();return t({show:c}),(b,a)=>{const u=e.resolveComponent("el-tree"),m=e.resolveComponent("el-button"),g=e.resolveComponent("el-drawer");return e.openBlock(),e.createBlock(g,{class:"search-setting",size:e.unref(o),title:"搜索项配置",modelValue:e.unref(i),"onUpdate:modelValue":a[0]||(a[0]=v=>e.isRef(i)?i.value=v:null)},{footer:e.withCtx(()=>[e.createVNode(m,{onClick:e.unref(l)},{default:e.withCtx(()=>[...a[1]||(a[1]=[e.createTextVNode("重置",-1)])]),_:1},8,["onClick"]),e.createVNode(m,{type:"primary",onClick:e.unref(y)},{default:e.withCtx(()=>[...a[2]||(a[2]=[e.createTextVNode("保存",-1)])]),_:1},8,["onClick"])]),default:e.withCtx(()=>[e.createVNode(u,{class:"tree","default-expand-all":"","default-checked-keys":e.unref(f),"node-key":"id",ref_key:"treeRef",ref:r,draggable:"","show-checkbox":"",data:e.unref(s),onNodeDragStart:e.unref(S),onNodeDragEnd:e.unref(k),"allow-drop":e.unref(p),"allow-drag":e.unref(C)},null,8,["default-checked-keys","data","onNodeDragStart","onNodeDragEnd","allow-drop","allow-drag"])]),_:1},8,["size","modelValue"])}}}),K=e.defineComponent({__name:"SettingButton",props:{state:{}},setup(n){const t=n,r=e.ref(),i=()=>{r.value.show(t.state)};return(s,o)=>{const f=e.resolveComponent("el-icon"),c=e.resolveComponent("el-button");return e.openBlock(),e.createBlock(c,{class:"icon-button",onClick:i},{default:e.withCtx(()=>[e.createVNode(f,null,{default:e.withCtx(()=>[e.createVNode(e.unref(L.Setting))]),_:1}),e.createVNode(H,{ref_key:"searchSettingDialogRef",ref:r},null,512)]),_:1})}}}),z={class:"search-bar-container"},M={class:"search-item"},I={class:"search-item-title"},P=["id"],G={class:"search-bottom"},W={class:"actions"},X=e.defineComponent({__name:"SearchBar",props:{searches:{},id:{},onSearch:{},defaultSpan:{default:6},maxRows:{default:2},itemHeight:{default:67},resetAutoSearch:{type:Boolean,default:!0}},emits:["change"],setup(n,{expose:t,emit:r}){const i=n,s=e.reactive(new O(i.id,i.searches,i.onSearch)),o=e.ref(!1),f=e.computed(()=>d.sum(Array.from(Object.values(s.config.itemLayouts)).filter(l=>l.visible).map(l=>l.span))/24>i.maxRows),c=e.ref([]),p=r;B.watchDebounced(()=>s.items,()=>{const y=[...s.items];c.value=y.sort((l,b)=>s.config.itemLayouts[l.field].index-s.config.itemLayouts[b.field].index).filter(l=>s.config.itemLayouts[l.field].visible).filter(l=>l.isEnable(s)),p("change",s.getSearchObject(),s)},{debounce:100,immediate:!0,deep:!0});const C=e.computed(()=>({height:`${i.itemHeight*i.maxRows}px`,overflow:"hidden"})),S=y=>s.config.itemLayouts[y.field];return t({getSearchItems:()=>s.items}),(y,l)=>{const b=e.resolveComponent("el-col"),a=e.resolveComponent("el-row"),u=e.resolveComponent("el-icon"),m=e.resolveComponent("el-button");return e.openBlock(),e.createElementBlock("div",z,[e.createVNode(a,{class:e.normalizeClass("search"),style:e.normalizeStyle(f.value&&!o.value?C.value:{}),gutter:16},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,g=>e.withDirectives((e.openBlock(),e.createBlock(b,{span:S(g).span,key:g.field},{default:e.withCtx(()=>[e.createElementVNode("div",M,[e.createElementVNode("div",I,e.toDisplayString(g.label),1),e.createElementVNode("div",{id:`${n.id}-${g.field}`,class:"search-item-content"},[e.createVNode(e.unref(R),{search:g,api:s},null,8,["search","api"])],8,P)])]),_:2},1032,["span"])),[[e.vShow,S(g).visible]])),128))]),_:1},8,["style"]),e.createElementVNode("div",G,[s.tags.length>0?(e.openBlock(),e.createBlock(D,{key:0,tags:s.tags},null,8,["tags"])):e.createCommentVNode("",!0),e.createElementVNode("div",W,[f.value?(e.openBlock(),e.createBlock(m,{key:0,class:"icon-button",onClick:l[0]||(l[0]=g=>o.value=!o.value)},{default:e.withCtx(()=>[e.createVNode(u,null,{default:e.withCtx(()=>[o.value?(e.openBlock(),e.createBlock(e.unref(w.ArrowUp),{key:1})):(e.openBlock(),e.createBlock(e.unref(w.ArrowDown),{key:0}))]),_:1})]),_:1})):e.createCommentVNode("",!0),e.createVNode(K,{state:s},null,8,["state"]),e.createVNode(m,{onClick:l[1]||(l[1]=()=>s.reset(n.resetAutoSearch))},{default:e.withCtx(()=>[...l[3]||(l[3]=[e.createTextVNode("重 置",-1)])]),_:1}),e.createVNode(m,{type:"primary",loading:s.searching,disabled:s.searching,onClick:l[2]||(l[2]=()=>s.doSearch())},{default:e.withCtx(()=>[...l[4]||(l[4]=[e.createTextVNode("搜 索",-1)])]),_:1},8,["loading","disabled"])])])])}}});class x{record;constructor(t){this.record=t}static from(t){const r=t.filter(i=>i.value===void 0?!1:Array.isArray(i.value)?i.value.length>0:!0).reduce((i,s)=>{const o=s.transform?s.transform(s.value):s.value;return{...i,...d.isPlainObject(o)?o:{[s.field]:o}}},{});return new x(r)}transform(t,r){const i=this.record[t],s=r(i);return delete this.record[t],this.record={...this.record,...s},this}toCondition(t){return{...this.record,...t}}}h.SearchBar=X,h.Searches=x,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(d,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("lodash-unified"),require("vue"),require("@element-plus/icons-vue"),require("@scvzerng/icons"),require("@vueuse/core")):typeof define=="function"&&define.amd?define(["exports","lodash-unified","vue","@element-plus/icons-vue","@scvzerng/icons","@vueuse/core"],h):(d=typeof globalThis<"u"?globalThis:d||self,h(d.ElementPlusSearch={},d.lodashUnified,d.vue,d.iconsVue,d.icons,d.core))})(this,(function(d,h,e,S,A,j){"use strict";const D={class:"tags-scroll-container"},O=["innerHTML"],q=e.defineComponent({name:"SearchTags",__name:"SearchTagsRender",props:{tags:{}},setup(n){const t=e.ref(),r=()=>{t.value.scrollBy({left:-200,behavior:"smooth"})},i=()=>{t.value.scrollBy({left:200,behavior:"smooth"})};return(s,a)=>{const u=e.resolveComponent("el-icon"),c=e.resolveComponent("el-tag");return e.openBlock(),e.createElementBlock("div",D,[e.createVNode(c,{type:"info",class:"scroll-left-bar",onClick:r},{default:e.withCtx(()=>[e.createVNode(u,null,{default:e.withCtx(()=>[e.createVNode(e.unref(S.ArrowLeft))]),_:1}),a[0]||(a[0]=e.createElementVNode("i",{class:"el-icon-arrow-left"},null,-1))]),_:1}),e.createElementVNode("div",{ref_key:"scrollContainer",ref:t,class:"search-tags"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.tags,f=>(e.openBlock(),e.createBlock(c,{class:"search-tag",onClose:()=>f.clean(),closable:!f.required,type:f.required?"primary":"info",key:f.field},{default:e.withCtx(()=>[e.createElementVNode("span",null,e.toDisplayString(f.label),1),a[1]||(a[1]=e.createTextVNode(": ",-1)),e.createElementVNode("span",{innerHTML:f.valueText},null,8,O)]),_:2},1032,["onClose","closable","type"]))),128))],512),e.createVNode(c,{type:"info",class:"scroll-right-bar",onClick:i},{default:e.withCtx(()=>[e.createVNode(u,null,{default:e.withCtx(()=>[e.createVNode(e.unref(S.ArrowRight))]),_:1})]),_:1})])}}}),T=6;class ${field;label;value;required;index;visible;disabled;span;initValue;enable;tagFilter;render;transform;constructor(t,r){this.field=t.field,this.label=t.label,this.value=t.initValue,this.required=t.required,this.initValue=t.initValue,this.index=r,this.visible=t.visible??!0,this.span=t.span??T,this.render=t.render,this.tagFilter=t.tagFilter,this.transform=t.transform,this.enable=t.enable??!0,this.disabled=t.disabled??!1}clean(){Array.isArray(this.value)?this.value=[]:this.value=void 0}reset(){this.value=this.initValue}isEnable(t){return h.isFunction(this.enable)?this.enable(t.getSearchObject()):this.enable}isDisabled(t){return h.isFunction(this.disabled)?this.disabled(t.getSearchObject()):this.disabled}}class m{field;span;index;visible;constructor(t,r,i,s){this.field=t,this.span=r,this.index=i,this.visible=s}static fromSearchItem(t,r){return new m(t.field,t.span,r??t.index,t.visible)}static formSearchConfig(t,r){return new m(t.field,t.span??T,r??t,t.visible??!0)}static fromString(t){const[r,i,s,a]=t.split("_");return new m(i,Number(s),Number(r),a==="true")}toString(){return`${this.index}_${this.field}_${this.span}_${this.visible}`}merge(t){this.span=t.span,this.index=t.index,this.visible=t.visible}}const L=n=>`searches_layouts_${n}`;class R{id;state;itemLayouts;initialLayouts;constructor(t,r){this.id=t.id,this.initialLayouts=r,this.state=t,this.itemLayouts=h.keyBy(t.items.map(m.fromSearchItem),i=>i.field),this.restoreCachedLayouts()}restoreCachedLayouts(){const t=localStorage.getItem(L(this.id));t&&t.split(",").forEach(r=>{const i=m.fromString(r),s=this.itemLayouts[i.field];s&&s.merge(i)})}sync(t,r){if(t.length!==Object.keys(this.itemLayouts).length)throw new Error("同步布局字段数量不一致");t.forEach((i,s)=>{const a=this.itemLayouts[i];a.index=s,a.visible=r.has(i)})}persistent(){localStorage.setItem(L(this.id),Object.values(this.itemLayouts).map(t=>t.toString()).join(",")),this.state.updateTags()}reset(){this.initialLayouts.forEach(t=>{const r=this.itemLayouts[t.field];r&&r.merge(t)})}}const F=[{isApply(n){return n.contains("el-radio-group")},getText(n){return n.querySelector(".is-active")?.querySelector("input")?.value}},{isApply(n){return n.contains("el-checkbox-group")},getText(n){const t=Array.from(n.querySelectorAll(".el-checkbox__input.is-checked")??[]).map(r=>r.querySelector("input")?.value).filter(r=>r);return t.length===1?t[0]:`${t[0]} 等${t.length}条`}},{isApply(n){return n.contains("el-input")},getText(n,t){return t.value}},{isApply(n){return n.contains("el-input-number")},getText(n,t){return t.value}},{isApply(n){return n.contains("el-select")},getText(n,t){const r=n.querySelectorAll(".el-select__tags-text");return r.length>0?t.value.length>1?`${r[0].textContent} 等${t.value.length}条`:r[0].textContent:n.querySelector(".el-select__placeholder")?.innerHTML}},{isApply(n){return n.contains("el-cascader")},getText(n){return n.querySelector("input")?.value}},{isApply(n){return n.contains("el-switch")},getText(n){return n.querySelector(".is-active").innerHTML}},{isApply(n){return n.contains("el-slider")},getText(n,t){return t.value}},{isApply(n){return n.contains("el-date-editor")},getText(n,t){return t.value?t.value.join(" ~ "):t.value}}];class B{id;field;value;label;valueText;required;item;state;constructor(t,r){this.id=`#${t.id}-${r.field}`,this.state=t,this.field=r.field,this.value=r.value,this.label=r.label,this.item=r,this.required=r.required??!1,this.updateValueText()}static hasValue(t){return h.isNumber(t.value)||h.isBoolean(t.value)?!0:!h.isEmpty(t.value)}updateValueText(){const t=document.querySelector(this.id);if(t.children.length!==1)throw new Error("holder children length is not 1");const r=t.children[0],i=F.find(s=>s.isApply(r.classList));i&&(this.valueText=i.getText(r,this))}async clean(){this.item.clean(),await this.state.doSearch()}}class H{constructor(t,r,i){this.id=t,this.id=t,this.items=r.map((s,a)=>new $(s,a)),this.config=e.reactive(new R(this,r.map((s,a)=>m.formSearchConfig(s,a)))),this.sourceSearchable=r,this.searching=!1,this.searchCallback=i,this.tags=[]}items;config;searching;tags;searchCallback;sourceSearchable;_lastSearchObject={time:0,data:null};updateTags(){this.tags=this.items.filter(t=>t.tagFilter?t.tagFilter(t.value):B.hasValue(t)).map(t=>new B(this,t)).sort((t,r)=>this.config.itemLayouts[t.field].index-this.config.itemLayouts[r.field].index)}getSearchObject(t){const r=Date.now();return this._lastSearchObject.data&&r-this._lastSearchObject.time<50?this._lastSearchObject.data:(this._lastSearchObject={time:r,data:_.from(this.items).toCondition(t)},this._lastSearchObject.data)}async doSearch(){if(!this.searching)try{this.searching=!0,await this.searchCallback(this.getSearchObject()),this.updateTags()}finally{this.searching=!1}}async reset(t){this.items.forEach(r=>r.reset()),t&&await this.doSearch()}setSearchValue(t,r){const i=this.items.find(s=>s.field===t);i&&(i.value=r)}}const K=({search:n,api:t})=>{const r=n.render(n);return r.props||(r.props={}),n.isDisabled(t)&&(r.props.disabled=!0),r},P=()=>{const n=e.shallowRef(),t=e.ref(),r=e.ref([]),i=e.ref(!1),s=e.ref(),a=e.ref([]),u=e.ref(300),c=l=>{n.value=l,r.value=[{label:"全部",id:"all",children:n.value.items.sort((o,p)=>l.config.itemLayouts[o.field].index-l.config.itemLayouts[p.field].index).map(o=>({label:o.label,id:o.field,disabled:!o.isEnable(l)}))}],s.value=h.chain(l.config.itemLayouts).pickBy(o=>o.visible).keys().value()};return{treeRef:t,visible:i,snapshot:r,defaultCheckedKeys:s,drawerWidth:u,updateSnapshot:c,show:l=>{c(l),i.value=!0},save:()=>{n.value.config.sync(r.value[0].children.map(l=>l.id),new Set(t.value.getCheckedKeys())),n.value.config.persistent()},reset:()=>{n.value.config.reset(),c(n.value)},keepSelection:()=>{a.value=t.value.getCheckedKeys()},restoreSelection:()=>{t.value.setCheckedKeys(a.value),a.value=[]},allowDrop:(l,o,p)=>p!=="inner",allowDrag:l=>!l.disabled}},z=e.defineComponent({__name:"SearchSettingsDrawer",setup(n,{expose:t}){const{treeRef:r,visible:i,snapshot:s,drawerWidth:a,defaultCheckedKeys:u,show:c,allowDrop:f,allowDrag:b,keepSelection:y,restoreSelection:w,save:x,reset:C}=P();return t({show:c}),(E,l)=>{const o=e.resolveComponent("el-tree"),p=e.resolveComponent("el-button"),k=e.resolveComponent("el-drawer");return e.openBlock(),e.createBlock(k,{class:"search-setting",size:e.unref(a),title:"搜索项配置",modelValue:e.unref(i),"onUpdate:modelValue":l[0]||(l[0]=V=>e.isRef(i)?i.value=V:null)},{footer:e.withCtx(()=>[e.createVNode(p,{onClick:e.unref(C)},{default:e.withCtx(()=>[...l[1]||(l[1]=[e.createTextVNode("重置",-1)])]),_:1},8,["onClick"]),e.createVNode(p,{type:"primary",onClick:e.unref(x)},{default:e.withCtx(()=>[...l[2]||(l[2]=[e.createTextVNode("保存",-1)])]),_:1},8,["onClick"])]),default:e.withCtx(()=>[e.createVNode(o,{class:"tree","default-expand-all":"","default-checked-keys":e.unref(u),"node-key":"id",ref_key:"treeRef",ref:r,draggable:"","show-checkbox":"",data:e.unref(s),onNodeDragStart:e.unref(y),onNodeDragEnd:e.unref(w),"allow-drop":e.unref(f),"allow-drag":e.unref(b)},null,8,["default-checked-keys","data","onNodeDragStart","onNodeDragEnd","allow-drop","allow-drag"])]),_:1},8,["size","modelValue"])}}}),M=e.defineComponent({__name:"SettingButton",props:{state:{}},setup(n){const t=n,r=e.ref(),i=()=>{r.value.show(t.state)};return(s,a)=>{const u=e.resolveComponent("el-icon"),c=e.resolveComponent("el-button");return e.openBlock(),e.createBlock(c,{class:"icon-button",onClick:i},{default:e.withCtx(()=>[e.createVNode(u,null,{default:e.withCtx(()=>[e.createVNode(e.unref(A.Setting))]),_:1}),e.createVNode(z,{ref_key:"searchSettingDialogRef",ref:r},null,512)]),_:1})}}}),v={class:"search-bar-container"},I={class:"search-item"},G={class:"search-item-title"},W=["id"],X={class:"search-bottom"},J={class:"actions"},Q=e.defineComponent({__name:"SearchBar",props:{searches:{},id:{},onSearch:{},defaultSpan:{default:6},maxRows:{default:2},itemHeight:{default:67},resetAutoSearch:{type:Boolean,default:!0}},emits:["change"],setup(n,{expose:t,emit:r}){const i=n,s=e.reactive(new H(i.id,i.searches,i.onSearch)),a=e.ref(!1),u=e.computed(()=>h.sum(Array.from(Object.values(s.config.itemLayouts)).filter(o=>o.visible).map(o=>o.span))/24>i.maxRows),c=e.ref([]),f=r;j.watchDebounced(()=>s.items,()=>{const l=[...s.items];c.value=l.sort((o,p)=>s.config.itemLayouts[o.field].index-s.config.itemLayouts[p.field].index).filter(o=>s.config.itemLayouts[o.field].visible).filter(o=>o.isEnable(s)),f("change",s.getSearchObject(),s)},{debounce:100,immediate:!0,deep:!0});const b=e.computed(()=>({height:`${i.itemHeight*i.maxRows}px`,overflow:"hidden"})),y=l=>s.config.itemLayouts[l.field];return t({getSearchItems:()=>s.items,getSearchObject:()=>s.getSearchObject(),updateSearching:l=>{s.searching=l},updateTags:()=>{s.updateTags()}}),(l,o)=>{const p=e.resolveComponent("el-col"),k=e.resolveComponent("el-row"),V=e.resolveComponent("el-icon"),N=e.resolveComponent("el-button");return e.openBlock(),e.createElementBlock("div",v,[e.createVNode(k,{class:e.normalizeClass("search"),style:e.normalizeStyle(u.value&&!a.value?b.value:{}),gutter:16},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,g=>e.withDirectives((e.openBlock(),e.createBlock(p,{span:y(g).span,key:g.field},{default:e.withCtx(()=>[e.createElementVNode("div",I,[e.createElementVNode("div",G,e.toDisplayString(g.label),1),e.createElementVNode("div",{id:`${n.id}-${g.field}`,class:"search-item-content"},[e.createVNode(e.unref(K),{search:g,api:s},null,8,["search","api"])],8,W)])]),_:2},1032,["span"])),[[e.vShow,y(g).visible]])),128))]),_:1},8,["style"]),e.createElementVNode("div",X,[s.tags.length>0?(e.openBlock(),e.createBlock(q,{key:0,tags:s.tags},null,8,["tags"])):e.createCommentVNode("",!0),e.createElementVNode("div",J,[u.value?(e.openBlock(),e.createBlock(N,{key:0,class:"icon-button",onClick:o[0]||(o[0]=g=>a.value=!a.value)},{default:e.withCtx(()=>[e.createVNode(V,null,{default:e.withCtx(()=>[a.value?(e.openBlock(),e.createBlock(e.unref(S.ArrowUp),{key:1})):(e.openBlock(),e.createBlock(e.unref(S.ArrowDown),{key:0}))]),_:1})]),_:1})):e.createCommentVNode("",!0),e.createVNode(M,{state:s},null,8,["state"]),e.createVNode(N,{onClick:o[1]||(o[1]=()=>s.reset(n.resetAutoSearch))},{default:e.withCtx(()=>[...o[3]||(o[3]=[e.createTextVNode("重 置",-1)])]),_:1}),e.createVNode(N,{type:"primary",loading:s.searching,disabled:s.searching,onClick:o[2]||(o[2]=()=>s.doSearch())},{default:e.withCtx(()=>[...o[4]||(o[4]=[e.createTextVNode("搜 索",-1)])]),_:1},8,["loading","disabled"])])])])}}}),Y=(n,t,r)=>({refreshCallback:async i=>{const s=t.value.getSearchObject();try{return t.value.updateSearching(!0),await n(s,i)}finally{t.value.updateSearching(!1),t.value.updateTags()}},searchCallback:async()=>{for(const i of r)await i.value?.refresh()}});class _{record;constructor(t){this.record=t}static from(t){const r=t.filter(i=>i.value===void 0?!1:Array.isArray(i.value)?i.value.length>0:!0).reduce((i,s)=>{const a=s.transform?s.transform(s.value):s.value;return{...i,...h.isPlainObject(a)?a:{[s.field]:a}}},{});return new _(r)}transform(t,r){const i=this.record[t],s=r(i);return delete this.record[t],this.record={...this.record,...s},this}toCondition(t){return{...this.record,...t}}}d.SearchBar=Q,d.Searches=_,d.useSearchProxy=Y,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})}));
package/dist/stats.html CHANGED
@@ -4929,7 +4929,7 @@ var drawChart = (function (exports) {
4929
4929
  </script>
4930
4930
  <script>
4931
4931
  /*<!--*/
4932
- const data = {"version":2,"tree":{"name":"root","children":[{"name":"ElementPlusSearch.umd.js","children":[{"name":"D:/gitee/element-plus-search/src","children":[{"uid":"f8a336ce-1","name":"SearchTagsRender.vue?vue&type=script&setup=true&lang.ts"},{"uid":"f8a336ce-3","name":"SearchTagsRender.vue?vue&type=style&index=0&lang.scss"},{"uid":"f8a336ce-5","name":"SearchTagsRender.vue"},{"name":"model","children":[{"uid":"f8a336ce-7","name":"SearchItem.ts"},{"uid":"f8a336ce-9","name":"SearchConfig.ts"},{"uid":"f8a336ce-11","name":"SearchTag.ts"}]},{"uid":"f8a336ce-13","name":"SearchBarState.ts"},{"uid":"f8a336ce-15","name":"SearchItemRender.ts"},{"name":"setting","children":[{"uid":"f8a336ce-17","name":"use-setting.ts"},{"uid":"f8a336ce-19","name":"SearchSettingsDrawer.vue?vue&type=script&setup=true&lang.ts"},{"uid":"f8a336ce-21","name":"SearchSettingsDrawer.vue?vue&type=style&index=0&lang.scss"},{"uid":"f8a336ce-23","name":"SearchSettingsDrawer.vue"},{"uid":"f8a336ce-25","name":"SettingButton.vue?vue&type=script&setup=true&lang.ts"},{"uid":"f8a336ce-27","name":"SettingButton.vue"}]},{"uid":"f8a336ce-29","name":"SearchBar.vue?vue&type=script&setup=true&lang.ts"},{"uid":"f8a336ce-31","name":"SearchBar.vue?vue&type=style&index=0&lang.scss"},{"uid":"f8a336ce-33","name":"SearchBar.vue"},{"uid":"f8a336ce-35","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"f8a336ce-1":{"renderedLength":3005,"gzipLength":0,"brotliLength":0,"metaUid":"f8a336ce-0"},"f8a336ce-3":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"f8a336ce-2"},"f8a336ce-5":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"f8a336ce-4"},"f8a336ce-7":{"renderedLength":1359,"gzipLength":0,"brotliLength":0,"metaUid":"f8a336ce-6"},"f8a336ce-9":{"renderedLength":2807,"gzipLength":0,"brotliLength":0,"metaUid":"f8a336ce-8"},"f8a336ce-11":{"renderedLength":3377,"gzipLength":0,"brotliLength":0,"metaUid":"f8a336ce-10"},"f8a336ce-13":{"renderedLength":1977,"gzipLength":0,"brotliLength":0,"metaUid":"f8a336ce-12"},"f8a336ce-15":{"renderedLength":242,"gzipLength":0,"brotliLength":0,"metaUid":"f8a336ce-14"},"f8a336ce-17":{"renderedLength":1981,"gzipLength":0,"brotliLength":0,"metaUid":"f8a336ce-16"},"f8a336ce-19":{"renderedLength":2564,"gzipLength":0,"brotliLength":0,"metaUid":"f8a336ce-18"},"f8a336ce-21":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"f8a336ce-20"},"f8a336ce-23":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"f8a336ce-22"},"f8a336ce-25":{"renderedLength":1135,"gzipLength":0,"brotliLength":0,"metaUid":"f8a336ce-24"},"f8a336ce-27":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"f8a336ce-26"},"f8a336ce-29":{"renderedLength":6019,"gzipLength":0,"brotliLength":0,"metaUid":"f8a336ce-28"},"f8a336ce-31":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"f8a336ce-30"},"f8a336ce-33":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"f8a336ce-32"},"f8a336ce-35":{"renderedLength":1004,"gzipLength":0,"brotliLength":0,"metaUid":"f8a336ce-34"}},"nodeMetas":{"f8a336ce-0":{"id":"D:/gitee/element-plus-search/src/SearchTagsRender.vue?vue&type=script&setup=true&lang.ts","moduleParts":{"ElementPlusSearch.umd.js":"f8a336ce-1"},"imported":[{"uid":"f8a336ce-38"},{"uid":"f8a336ce-39"}],"importedBy":[{"uid":"f8a336ce-4"}]},"f8a336ce-2":{"id":"D:/gitee/element-plus-search/src/SearchTagsRender.vue?vue&type=style&index=0&lang.scss","moduleParts":{"ElementPlusSearch.umd.js":"f8a336ce-3"},"imported":[],"importedBy":[{"uid":"f8a336ce-4"}]},"f8a336ce-4":{"id":"D:/gitee/element-plus-search/src/SearchTagsRender.vue","moduleParts":{"ElementPlusSearch.umd.js":"f8a336ce-5"},"imported":[{"uid":"f8a336ce-0"},{"uid":"f8a336ce-2"}],"importedBy":[{"uid":"f8a336ce-28"}]},"f8a336ce-6":{"id":"D:/gitee/element-plus-search/src/model/SearchItem.ts","moduleParts":{"ElementPlusSearch.umd.js":"f8a336ce-7"},"imported":[{"uid":"f8a336ce-36"}],"importedBy":[{"uid":"f8a336ce-12"},{"uid":"f8a336ce-8"}]},"f8a336ce-8":{"id":"D:/gitee/element-plus-search/src/model/SearchConfig.ts","moduleParts":{"ElementPlusSearch.umd.js":"f8a336ce-9"},"imported":[{"uid":"f8a336ce-6"},{"uid":"f8a336ce-36"}],"importedBy":[{"uid":"f8a336ce-12"}]},"f8a336ce-10":{"id":"D:/gitee/element-plus-search/src/model/SearchTag.ts","moduleParts":{"ElementPlusSearch.umd.js":"f8a336ce-11"},"imported":[{"uid":"f8a336ce-36"}],"importedBy":[{"uid":"f8a336ce-12"}]},"f8a336ce-12":{"id":"D:/gitee/element-plus-search/src/SearchBarState.ts","moduleParts":{"ElementPlusSearch.umd.js":"f8a336ce-13"},"imported":[{"uid":"f8a336ce-6"},{"uid":"f8a336ce-8"},{"uid":"f8a336ce-10"},{"uid":"f8a336ce-38"},{"uid":"f8a336ce-34"}],"importedBy":[{"uid":"f8a336ce-28"}]},"f8a336ce-14":{"id":"D:/gitee/element-plus-search/src/SearchItemRender.ts","moduleParts":{"ElementPlusSearch.umd.js":"f8a336ce-15"},"imported":[],"importedBy":[{"uid":"f8a336ce-28"}]},"f8a336ce-16":{"id":"D:/gitee/element-plus-search/src/setting/use-setting.ts","moduleParts":{"ElementPlusSearch.umd.js":"f8a336ce-17"},"imported":[{"uid":"f8a336ce-38"},{"uid":"f8a336ce-36"}],"importedBy":[{"uid":"f8a336ce-18"}]},"f8a336ce-18":{"id":"D:/gitee/element-plus-search/src/setting/SearchSettingsDrawer.vue?vue&type=script&setup=true&lang.ts","moduleParts":{"ElementPlusSearch.umd.js":"f8a336ce-19"},"imported":[{"uid":"f8a336ce-38"},{"uid":"f8a336ce-16"}],"importedBy":[{"uid":"f8a336ce-22"}]},"f8a336ce-20":{"id":"D:/gitee/element-plus-search/src/setting/SearchSettingsDrawer.vue?vue&type=style&index=0&lang.scss","moduleParts":{"ElementPlusSearch.umd.js":"f8a336ce-21"},"imported":[],"importedBy":[{"uid":"f8a336ce-22"}]},"f8a336ce-22":{"id":"D:/gitee/element-plus-search/src/setting/SearchSettingsDrawer.vue","moduleParts":{"ElementPlusSearch.umd.js":"f8a336ce-23"},"imported":[{"uid":"f8a336ce-18"},{"uid":"f8a336ce-20"}],"importedBy":[{"uid":"f8a336ce-24"}]},"f8a336ce-24":{"id":"D:/gitee/element-plus-search/src/setting/SettingButton.vue?vue&type=script&setup=true&lang.ts","moduleParts":{"ElementPlusSearch.umd.js":"f8a336ce-25"},"imported":[{"uid":"f8a336ce-38"},{"uid":"f8a336ce-41"},{"uid":"f8a336ce-22"}],"importedBy":[{"uid":"f8a336ce-26"}]},"f8a336ce-26":{"id":"D:/gitee/element-plus-search/src/setting/SettingButton.vue","moduleParts":{"ElementPlusSearch.umd.js":"f8a336ce-27"},"imported":[{"uid":"f8a336ce-24"}],"importedBy":[{"uid":"f8a336ce-28"}]},"f8a336ce-28":{"id":"D:/gitee/element-plus-search/src/SearchBar.vue?vue&type=script&setup=true&lang.ts","moduleParts":{"ElementPlusSearch.umd.js":"f8a336ce-29"},"imported":[{"uid":"f8a336ce-38"},{"uid":"f8a336ce-36"},{"uid":"f8a336ce-4"},{"uid":"f8a336ce-12"},{"uid":"f8a336ce-14"},{"uid":"f8a336ce-39"},{"uid":"f8a336ce-26"},{"uid":"f8a336ce-40"}],"importedBy":[{"uid":"f8a336ce-32"}]},"f8a336ce-30":{"id":"D:/gitee/element-plus-search/src/SearchBar.vue?vue&type=style&index=0&lang.scss","moduleParts":{"ElementPlusSearch.umd.js":"f8a336ce-31"},"imported":[],"importedBy":[{"uid":"f8a336ce-32"}]},"f8a336ce-32":{"id":"D:/gitee/element-plus-search/src/SearchBar.vue","moduleParts":{"ElementPlusSearch.umd.js":"f8a336ce-33"},"imported":[{"uid":"f8a336ce-28"},{"uid":"f8a336ce-30"}],"importedBy":[{"uid":"f8a336ce-34"}]},"f8a336ce-34":{"id":"D:/gitee/element-plus-search/src/index.ts","moduleParts":{"ElementPlusSearch.umd.js":"f8a336ce-35"},"imported":[{"uid":"f8a336ce-36"},{"uid":"f8a336ce-37"},{"uid":"f8a336ce-32"}],"importedBy":[{"uid":"f8a336ce-12"}],"isEntry":true},"f8a336ce-36":{"id":"lodash-unified","moduleParts":{},"imported":[],"importedBy":[{"uid":"f8a336ce-34"},{"uid":"f8a336ce-28"},{"uid":"f8a336ce-6"},{"uid":"f8a336ce-8"},{"uid":"f8a336ce-10"},{"uid":"f8a336ce-16"}],"isExternal":true},"f8a336ce-37":{"id":"D:/gitee/element-plus-search/src/types/Searchable.ts","moduleParts":{},"imported":[],"importedBy":[{"uid":"f8a336ce-34"}]},"f8a336ce-38":{"id":"vue","moduleParts":{},"imported":[],"importedBy":[{"uid":"f8a336ce-28"},{"uid":"f8a336ce-12"},{"uid":"f8a336ce-0"},{"uid":"f8a336ce-24"},{"uid":"f8a336ce-18"},{"uid":"f8a336ce-16"}],"isExternal":true},"f8a336ce-39":{"id":"@element-plus/icons-vue","moduleParts":{},"imported":[],"importedBy":[{"uid":"f8a336ce-28"},{"uid":"f8a336ce-0"}],"isExternal":true},"f8a336ce-40":{"id":"@vueuse/core","moduleParts":{},"imported":[],"importedBy":[{"uid":"f8a336ce-28"}],"isExternal":true},"f8a336ce-41":{"id":"@scvzerng/icons","moduleParts":{},"imported":[],"importedBy":[{"uid":"f8a336ce-24"}],"isExternal":true}},"env":{"rollup":"4.52.4"},"options":{"gzip":false,"brotli":false,"sourcemap":false}};
4932
+ const data = {"version":2,"tree":{"name":"root","children":[{"name":"ElementPlusSearch.umd.js","children":[{"name":"D:/gitee/element-plus-search/src","children":[{"uid":"6135bd6f-1","name":"SearchTagsRender.vue?vue&type=script&setup=true&lang.ts"},{"uid":"6135bd6f-3","name":"SearchTagsRender.vue?vue&type=style&index=0&lang.scss"},{"uid":"6135bd6f-5","name":"SearchTagsRender.vue"},{"name":"model","children":[{"uid":"6135bd6f-7","name":"SearchItem.ts"},{"uid":"6135bd6f-9","name":"SearchConfig.ts"},{"uid":"6135bd6f-11","name":"SearchTag.ts"}]},{"uid":"6135bd6f-13","name":"SearchBarState.ts"},{"uid":"6135bd6f-15","name":"SearchItemRender.ts"},{"name":"setting","children":[{"uid":"6135bd6f-17","name":"use-setting.ts"},{"uid":"6135bd6f-19","name":"SearchSettingsDrawer.vue?vue&type=script&setup=true&lang.ts"},{"uid":"6135bd6f-21","name":"SearchSettingsDrawer.vue?vue&type=style&index=0&lang.scss"},{"uid":"6135bd6f-23","name":"SearchSettingsDrawer.vue"},{"uid":"6135bd6f-25","name":"SettingButton.vue?vue&type=script&setup=true&lang.ts"},{"uid":"6135bd6f-27","name":"SettingButton.vue"}]},{"uid":"6135bd6f-29","name":"SearchBar.vue?vue&type=script&setup=true&lang.ts"},{"uid":"6135bd6f-31","name":"SearchBar.vue?vue&type=style&index=0&lang.scss"},{"uid":"6135bd6f-33","name":"SearchBar.vue"},{"uid":"6135bd6f-35","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"6135bd6f-1":{"renderedLength":3005,"gzipLength":0,"brotliLength":0,"metaUid":"6135bd6f-0"},"6135bd6f-3":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"6135bd6f-2"},"6135bd6f-5":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"6135bd6f-4"},"6135bd6f-7":{"renderedLength":1359,"gzipLength":0,"brotliLength":0,"metaUid":"6135bd6f-6"},"6135bd6f-9":{"renderedLength":2807,"gzipLength":0,"brotliLength":0,"metaUid":"6135bd6f-8"},"6135bd6f-11":{"renderedLength":3377,"gzipLength":0,"brotliLength":0,"metaUid":"6135bd6f-10"},"6135bd6f-13":{"renderedLength":1977,"gzipLength":0,"brotliLength":0,"metaUid":"6135bd6f-12"},"6135bd6f-15":{"renderedLength":242,"gzipLength":0,"brotliLength":0,"metaUid":"6135bd6f-14"},"6135bd6f-17":{"renderedLength":1981,"gzipLength":0,"brotliLength":0,"metaUid":"6135bd6f-16"},"6135bd6f-19":{"renderedLength":2564,"gzipLength":0,"brotliLength":0,"metaUid":"6135bd6f-18"},"6135bd6f-21":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"6135bd6f-20"},"6135bd6f-23":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"6135bd6f-22"},"6135bd6f-25":{"renderedLength":1135,"gzipLength":0,"brotliLength":0,"metaUid":"6135bd6f-24"},"6135bd6f-27":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"6135bd6f-26"},"6135bd6f-29":{"renderedLength":6339,"gzipLength":0,"brotliLength":0,"metaUid":"6135bd6f-28"},"6135bd6f-31":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"6135bd6f-30"},"6135bd6f-33":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"6135bd6f-32"},"6135bd6f-35":{"renderedLength":1844,"gzipLength":0,"brotliLength":0,"metaUid":"6135bd6f-34"}},"nodeMetas":{"6135bd6f-0":{"id":"D:/gitee/element-plus-search/src/SearchTagsRender.vue?vue&type=script&setup=true&lang.ts","moduleParts":{"ElementPlusSearch.umd.js":"6135bd6f-1"},"imported":[{"uid":"6135bd6f-38"},{"uid":"6135bd6f-39"}],"importedBy":[{"uid":"6135bd6f-4"}]},"6135bd6f-2":{"id":"D:/gitee/element-plus-search/src/SearchTagsRender.vue?vue&type=style&index=0&lang.scss","moduleParts":{"ElementPlusSearch.umd.js":"6135bd6f-3"},"imported":[],"importedBy":[{"uid":"6135bd6f-4"}]},"6135bd6f-4":{"id":"D:/gitee/element-plus-search/src/SearchTagsRender.vue","moduleParts":{"ElementPlusSearch.umd.js":"6135bd6f-5"},"imported":[{"uid":"6135bd6f-0"},{"uid":"6135bd6f-2"}],"importedBy":[{"uid":"6135bd6f-28"}]},"6135bd6f-6":{"id":"D:/gitee/element-plus-search/src/model/SearchItem.ts","moduleParts":{"ElementPlusSearch.umd.js":"6135bd6f-7"},"imported":[{"uid":"6135bd6f-36"}],"importedBy":[{"uid":"6135bd6f-12"},{"uid":"6135bd6f-8"}]},"6135bd6f-8":{"id":"D:/gitee/element-plus-search/src/model/SearchConfig.ts","moduleParts":{"ElementPlusSearch.umd.js":"6135bd6f-9"},"imported":[{"uid":"6135bd6f-6"},{"uid":"6135bd6f-36"}],"importedBy":[{"uid":"6135bd6f-12"}]},"6135bd6f-10":{"id":"D:/gitee/element-plus-search/src/model/SearchTag.ts","moduleParts":{"ElementPlusSearch.umd.js":"6135bd6f-11"},"imported":[{"uid":"6135bd6f-36"}],"importedBy":[{"uid":"6135bd6f-12"}]},"6135bd6f-12":{"id":"D:/gitee/element-plus-search/src/SearchBarState.ts","moduleParts":{"ElementPlusSearch.umd.js":"6135bd6f-13"},"imported":[{"uid":"6135bd6f-6"},{"uid":"6135bd6f-8"},{"uid":"6135bd6f-10"},{"uid":"6135bd6f-38"},{"uid":"6135bd6f-34"}],"importedBy":[{"uid":"6135bd6f-28"}]},"6135bd6f-14":{"id":"D:/gitee/element-plus-search/src/SearchItemRender.ts","moduleParts":{"ElementPlusSearch.umd.js":"6135bd6f-15"},"imported":[],"importedBy":[{"uid":"6135bd6f-28"}]},"6135bd6f-16":{"id":"D:/gitee/element-plus-search/src/setting/use-setting.ts","moduleParts":{"ElementPlusSearch.umd.js":"6135bd6f-17"},"imported":[{"uid":"6135bd6f-38"},{"uid":"6135bd6f-36"}],"importedBy":[{"uid":"6135bd6f-18"}]},"6135bd6f-18":{"id":"D:/gitee/element-plus-search/src/setting/SearchSettingsDrawer.vue?vue&type=script&setup=true&lang.ts","moduleParts":{"ElementPlusSearch.umd.js":"6135bd6f-19"},"imported":[{"uid":"6135bd6f-38"},{"uid":"6135bd6f-16"}],"importedBy":[{"uid":"6135bd6f-22"}]},"6135bd6f-20":{"id":"D:/gitee/element-plus-search/src/setting/SearchSettingsDrawer.vue?vue&type=style&index=0&lang.scss","moduleParts":{"ElementPlusSearch.umd.js":"6135bd6f-21"},"imported":[],"importedBy":[{"uid":"6135bd6f-22"}]},"6135bd6f-22":{"id":"D:/gitee/element-plus-search/src/setting/SearchSettingsDrawer.vue","moduleParts":{"ElementPlusSearch.umd.js":"6135bd6f-23"},"imported":[{"uid":"6135bd6f-18"},{"uid":"6135bd6f-20"}],"importedBy":[{"uid":"6135bd6f-24"}]},"6135bd6f-24":{"id":"D:/gitee/element-plus-search/src/setting/SettingButton.vue?vue&type=script&setup=true&lang.ts","moduleParts":{"ElementPlusSearch.umd.js":"6135bd6f-25"},"imported":[{"uid":"6135bd6f-38"},{"uid":"6135bd6f-41"},{"uid":"6135bd6f-22"}],"importedBy":[{"uid":"6135bd6f-26"}]},"6135bd6f-26":{"id":"D:/gitee/element-plus-search/src/setting/SettingButton.vue","moduleParts":{"ElementPlusSearch.umd.js":"6135bd6f-27"},"imported":[{"uid":"6135bd6f-24"}],"importedBy":[{"uid":"6135bd6f-28"}]},"6135bd6f-28":{"id":"D:/gitee/element-plus-search/src/SearchBar.vue?vue&type=script&setup=true&lang.ts","moduleParts":{"ElementPlusSearch.umd.js":"6135bd6f-29"},"imported":[{"uid":"6135bd6f-38"},{"uid":"6135bd6f-36"},{"uid":"6135bd6f-4"},{"uid":"6135bd6f-12"},{"uid":"6135bd6f-14"},{"uid":"6135bd6f-39"},{"uid":"6135bd6f-26"},{"uid":"6135bd6f-40"}],"importedBy":[{"uid":"6135bd6f-32"}]},"6135bd6f-30":{"id":"D:/gitee/element-plus-search/src/SearchBar.vue?vue&type=style&index=0&lang.scss","moduleParts":{"ElementPlusSearch.umd.js":"6135bd6f-31"},"imported":[],"importedBy":[{"uid":"6135bd6f-32"}]},"6135bd6f-32":{"id":"D:/gitee/element-plus-search/src/SearchBar.vue","moduleParts":{"ElementPlusSearch.umd.js":"6135bd6f-33"},"imported":[{"uid":"6135bd6f-28"},{"uid":"6135bd6f-30"}],"importedBy":[{"uid":"6135bd6f-34"}]},"6135bd6f-34":{"id":"D:/gitee/element-plus-search/src/index.ts","moduleParts":{"ElementPlusSearch.umd.js":"6135bd6f-35"},"imported":[{"uid":"6135bd6f-36"},{"uid":"6135bd6f-37"},{"uid":"6135bd6f-32"}],"importedBy":[{"uid":"6135bd6f-12"}],"isEntry":true},"6135bd6f-36":{"id":"lodash-unified","moduleParts":{},"imported":[],"importedBy":[{"uid":"6135bd6f-34"},{"uid":"6135bd6f-28"},{"uid":"6135bd6f-6"},{"uid":"6135bd6f-8"},{"uid":"6135bd6f-10"},{"uid":"6135bd6f-16"}],"isExternal":true},"6135bd6f-37":{"id":"D:/gitee/element-plus-search/src/types/Searchable.ts","moduleParts":{},"imported":[],"importedBy":[{"uid":"6135bd6f-34"}]},"6135bd6f-38":{"id":"vue","moduleParts":{},"imported":[],"importedBy":[{"uid":"6135bd6f-28"},{"uid":"6135bd6f-12"},{"uid":"6135bd6f-0"},{"uid":"6135bd6f-24"},{"uid":"6135bd6f-18"},{"uid":"6135bd6f-16"}],"isExternal":true},"6135bd6f-39":{"id":"@element-plus/icons-vue","moduleParts":{},"imported":[],"importedBy":[{"uid":"6135bd6f-28"},{"uid":"6135bd6f-0"}],"isExternal":true},"6135bd6f-40":{"id":"@vueuse/core","moduleParts":{},"imported":[],"importedBy":[{"uid":"6135bd6f-28"}],"isExternal":true},"6135bd6f-41":{"id":"@scvzerng/icons","moduleParts":{},"imported":[],"importedBy":[{"uid":"6135bd6f-24"}],"isExternal":true}},"env":{"rollup":"4.52.4"},"options":{"gzip":false,"brotli":false,"sourcemap":false}};
4933
4933
 
4934
4934
  const run = () => {
4935
4935
  const width = window.innerWidth;
@@ -29,6 +29,9 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
29
29
  isEnable: (state: SearchBarState) => boolean;
30
30
  isDisabled: (state: SearchBarState) => boolean;
31
31
  }[];
32
+ getSearchObject: () => any;
33
+ updateSearching: (searching: boolean) => void;
34
+ updateTags: () => void;
32
35
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
33
36
  change: (...args: any[]) => void;
34
37
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
@@ -1,9 +1,31 @@
1
1
  import { TransformCallback } from './types/Searchable';
2
2
  import { SearchValueLike } from './types/SearchValueLike';
3
- export * from "./types/Searchable";
3
+ import { Ref } from 'vue';
4
+ export * from './types/Searchable';
4
5
  export { default as SearchBar } from './SearchBar.vue';
5
- export type SearchBarInstance = {
6
+ export interface RefreshInstance<SEARCH_OBJECT> {
7
+ refresh: (searchObject?: SEARCH_OBJECT) => void | Promise<void>;
8
+ }
9
+ export declare const useSearchProxy: <C_PARAM, SEARCH_OBJECT, VALUE>(callback: (searchObject: SEARCH_OBJECT, params: C_PARAM) => VALUE, instance: Ref<SearchBarInstance<SEARCH_OBJECT>>, refreshInstance: Ref<RefreshInstance<SEARCH_OBJECT>>[]) => {
10
+ /**
11
+ * 数据刷新回调代理
12
+ *
13
+ * 填充数据拉取接口的搜索参数
14
+ * @param param
15
+ */
16
+ refreshCallback: (param: C_PARAM) => Promise<VALUE>;
17
+ /**
18
+ * 搜索项搜索按钮点击时触发
19
+ *
20
+ * 回调所有的可刷新组件
21
+ */
22
+ searchCallback: () => Promise<void>;
23
+ };
24
+ export type SearchBarInstance<T> = {
6
25
  getSearchItems(): SearchValueLike[];
26
+ getSearchObject(): T;
27
+ updateSearching(searching: boolean): void;
28
+ updateTags(): void;
7
29
  };
8
30
  export declare class Searches {
9
31
  record: Record<string, any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scvzerng/element-plus-search-vue2",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "scripts": {