@mywzzz/mineadmin-search-panel 1.0.7 → 1.0.9
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.
- package/dist/index.js +106 -100
- package/dist/index.umd.cjs +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { isVNode as j, defineComponent as
|
|
2
|
-
import { ElInputNumber as
|
|
1
|
+
import { isVNode as j, defineComponent as ne, computed as f, ref as S, watch as z, onMounted as te, onBeforeUnmount as le, openBlock as a, createElementBlock as y, createElementVNode as v, toDisplayString as b, createCommentVNode as m, renderSlot as F, createVNode as g, unref as s, withModifiers as R, withCtx as c, normalizeStyle as E, Fragment as U, renderList as D, withDirectives as oe, createBlock as h, resolveDynamicComponent as N, mergeProps as I, withKeys as re, vShow as ae, createTextVNode as T } from "vue";
|
|
2
|
+
import { ElInputNumber as ue, ElDatePicker as se, ElSelect as ie, ElInput as de, ElForm as ce, ElFormItem as pe, ElOption as fe, ElButton as K, ElLink as ye } from "element-plus";
|
|
3
3
|
import { Icon as O } from "@iconify/vue";
|
|
4
|
-
const
|
|
5
|
-
input:
|
|
6
|
-
select:
|
|
7
|
-
"date-picker":
|
|
8
|
-
"input-number":
|
|
4
|
+
const ve = {
|
|
5
|
+
input: de,
|
|
6
|
+
select: ie,
|
|
7
|
+
"date-picker": se,
|
|
8
|
+
"input-number": ue
|
|
9
9
|
};
|
|
10
|
-
function
|
|
11
|
-
return
|
|
10
|
+
function me(e) {
|
|
11
|
+
return ve[e];
|
|
12
12
|
}
|
|
13
|
-
function
|
|
13
|
+
function he(e) {
|
|
14
14
|
if (e.fullWidth !== !1)
|
|
15
15
|
return { width: "100%" };
|
|
16
16
|
}
|
|
@@ -21,18 +21,18 @@ const w = {
|
|
|
21
21
|
inputNumber: "input-number",
|
|
22
22
|
"input-number": "input-number"
|
|
23
23
|
};
|
|
24
|
-
function
|
|
24
|
+
function ke(e) {
|
|
25
25
|
return typeof e == "function" ? e() : e ?? "";
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function be(e) {
|
|
28
28
|
return typeof e == "function" ? e() : e ?? "";
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function ge(e) {
|
|
31
31
|
return typeof e == "string" && e in w;
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
const r =
|
|
35
|
-
if (
|
|
33
|
+
function _e(e) {
|
|
34
|
+
const r = be(e.prop), o = e.label ?? r;
|
|
35
|
+
if (ge(e.render))
|
|
36
36
|
return {
|
|
37
37
|
key: r,
|
|
38
38
|
label: o,
|
|
@@ -42,15 +42,15 @@ function he(e) {
|
|
|
42
42
|
componentProps: e.renderProps
|
|
43
43
|
};
|
|
44
44
|
if (typeof e.render == "function") {
|
|
45
|
-
const k = e.render,
|
|
46
|
-
return typeof
|
|
45
|
+
const k = e.render, u = k();
|
|
46
|
+
return typeof u == "string" && u in w ? {
|
|
47
47
|
key: r,
|
|
48
48
|
label: o,
|
|
49
49
|
span: e.span,
|
|
50
|
-
type: w[
|
|
50
|
+
type: w[u],
|
|
51
51
|
options: e.renderProps?.options,
|
|
52
52
|
componentProps: e.renderProps
|
|
53
|
-
} : j(
|
|
53
|
+
} : j(u) ? {
|
|
54
54
|
key: r,
|
|
55
55
|
label: o,
|
|
56
56
|
span: e.span,
|
|
@@ -61,7 +61,7 @@ function he(e) {
|
|
|
61
61
|
label: o,
|
|
62
62
|
span: e.span,
|
|
63
63
|
type: "component",
|
|
64
|
-
component:
|
|
64
|
+
component: u,
|
|
65
65
|
componentProps: e.renderProps
|
|
66
66
|
};
|
|
67
67
|
}
|
|
@@ -80,25 +80,25 @@ function he(e) {
|
|
|
80
80
|
componentProps: e.renderProps
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
function
|
|
84
|
-
return e.map((r) => "type" in r && "key" in r ? r :
|
|
83
|
+
function we(e) {
|
|
84
|
+
return e.map((r) => "type" in r && "key" in r ? r : _e(r));
|
|
85
85
|
}
|
|
86
|
-
function
|
|
86
|
+
function Ve(e) {
|
|
87
87
|
if ("type" in e && "key" in e || typeof e.render != "function")
|
|
88
88
|
return null;
|
|
89
89
|
const r = e.render, o = r();
|
|
90
90
|
return j(o) ? o : null;
|
|
91
91
|
}
|
|
92
|
-
const
|
|
92
|
+
const Pe = { class: "ma-search-panel" }, xe = {
|
|
93
93
|
key: 0,
|
|
94
94
|
class: "ma-search-panel__card ma-search-panel__header"
|
|
95
|
-
},
|
|
95
|
+
}, Ce = { class: "ma-search-panel__title-wrap" }, Se = {
|
|
96
96
|
key: 0,
|
|
97
97
|
class: "ma-search-panel__title"
|
|
98
|
-
},
|
|
98
|
+
}, Ee = {
|
|
99
99
|
key: 1,
|
|
100
100
|
class: "ma-search-panel__subtitle"
|
|
101
|
-
},
|
|
101
|
+
}, Ne = { class: "ma-search-panel__card" }, Te = { class: "ma-search-panel__field ma-search-panel__field--full" }, Be = { class: "ma-search-panel__actions" }, We = /* @__PURE__ */ ne({
|
|
102
102
|
__name: "SearchPanel",
|
|
103
103
|
props: {
|
|
104
104
|
items: {},
|
|
@@ -107,7 +107,7 @@ const _e = { class: "ma-search-panel" }, ge = {
|
|
|
107
107
|
title: {},
|
|
108
108
|
subtitle: {},
|
|
109
109
|
labelWidth: { default: "90px" },
|
|
110
|
-
cols: { default:
|
|
110
|
+
cols: { default: () => ({ xl: 4, lg: 4, md: 2, sm: 2, xs: 1 }) },
|
|
111
111
|
fold: { type: Boolean, default: !1 },
|
|
112
112
|
foldRows: { default: 1 },
|
|
113
113
|
searchText: { default: "搜索" },
|
|
@@ -117,66 +117,66 @@ const _e = { class: "ma-search-panel" }, ge = {
|
|
|
117
117
|
},
|
|
118
118
|
emits: ["update:modelValue", "search", "reset"],
|
|
119
119
|
setup(e, { emit: r }) {
|
|
120
|
-
const o = e, k = r;
|
|
121
|
-
function
|
|
120
|
+
const o = e, k = r, u = f(() => we(o.items));
|
|
121
|
+
function V() {
|
|
122
122
|
const n = {};
|
|
123
|
-
return
|
|
124
|
-
n[
|
|
123
|
+
return u.value.forEach((t) => {
|
|
124
|
+
n[t.key] = o.defaultValue?.[t.key];
|
|
125
125
|
}), n;
|
|
126
126
|
}
|
|
127
|
-
const d =
|
|
128
|
-
...
|
|
127
|
+
const d = S({
|
|
128
|
+
...V(),
|
|
129
129
|
...o.modelValue
|
|
130
130
|
});
|
|
131
131
|
z(
|
|
132
132
|
() => [o.items, o.defaultValue, o.modelValue],
|
|
133
133
|
() => {
|
|
134
134
|
d.value = {
|
|
135
|
-
...
|
|
135
|
+
...V(),
|
|
136
136
|
...o.modelValue
|
|
137
137
|
};
|
|
138
138
|
},
|
|
139
139
|
{ deep: !0 }
|
|
140
140
|
);
|
|
141
|
-
function
|
|
141
|
+
function B(n) {
|
|
142
142
|
d.value = n, k("update:modelValue", n);
|
|
143
143
|
}
|
|
144
|
-
const
|
|
144
|
+
const L = S(typeof window > "u" ? 1440 : window.innerWidth);
|
|
145
145
|
function A(n) {
|
|
146
146
|
if (typeof n == "number")
|
|
147
147
|
return n;
|
|
148
|
-
const
|
|
149
|
-
return
|
|
148
|
+
const t = L.value;
|
|
149
|
+
return t >= 1920 ? n.xl ?? 4 : t >= 1200 ? n.lg ?? 3 : t >= 992 ? n.md ?? 2 : t >= 768 ? n.sm ?? 2 : n.xs ?? 1;
|
|
150
150
|
}
|
|
151
151
|
function P() {
|
|
152
|
-
typeof window < "u" && (
|
|
152
|
+
typeof window < "u" && (L.value = window.innerWidth);
|
|
153
153
|
}
|
|
154
|
-
|
|
154
|
+
te(() => {
|
|
155
155
|
P(), typeof window < "u" && window.addEventListener("resize", P);
|
|
156
|
-
}),
|
|
156
|
+
}), le(() => {
|
|
157
157
|
typeof window < "u" && window.removeEventListener("resize", P);
|
|
158
158
|
});
|
|
159
|
-
const
|
|
159
|
+
const _ = f(() => Math.max(A(o.cols), 1)), M = f(() => Math.max(_.value * o.foldRows - 1, 0)), p = S(o.fold);
|
|
160
160
|
z(
|
|
161
161
|
() => o.fold,
|
|
162
162
|
(n) => {
|
|
163
163
|
p.value = n;
|
|
164
164
|
}
|
|
165
165
|
);
|
|
166
|
-
const
|
|
167
|
-
gridTemplateColumns: `repeat(${
|
|
166
|
+
const $ = f(() => u.value.length > M.value), q = f(() => p.value && $.value ? Math.min(u.value.length, M.value) : u.value.length), G = f(() => ({
|
|
167
|
+
gridTemplateColumns: `repeat(${_.value}, minmax(0, 1fr))`
|
|
168
168
|
}));
|
|
169
|
-
function
|
|
170
|
-
|
|
169
|
+
function x(n, t) {
|
|
170
|
+
B({ ...d.value, [n]: t });
|
|
171
171
|
}
|
|
172
172
|
function H() {
|
|
173
|
-
const n =
|
|
174
|
-
|
|
173
|
+
const n = V();
|
|
174
|
+
B(n), k("reset", n);
|
|
175
175
|
}
|
|
176
|
-
function
|
|
176
|
+
function C() {
|
|
177
177
|
const n = {};
|
|
178
|
-
Object.entries(d.value).forEach(([
|
|
179
|
-
|
|
178
|
+
Object.entries(d.value).forEach(([t, l]) => {
|
|
179
|
+
l !== "" && l !== void 0 && l !== null && (n[t] = l);
|
|
180
180
|
}), k("search", n);
|
|
181
181
|
}
|
|
182
182
|
function J(n) {
|
|
@@ -186,109 +186,115 @@ const _e = { class: "ma-search-panel" }, ge = {
|
|
|
186
186
|
return n.type === "component";
|
|
187
187
|
}
|
|
188
188
|
function X(n) {
|
|
189
|
-
|
|
189
|
+
const t = { ...n.componentProps ?? {} };
|
|
190
|
+
return (n.type === "input" || n.type === "select") && (t.clearable = t.clearable ?? !0), t;
|
|
190
191
|
}
|
|
191
192
|
function Y(n) {
|
|
193
|
+
return o.items.find((t) => "type" in t && "key" in t ? t.key === n.key : n.key === (typeof t.prop == "function" ? t.prop() : t.prop));
|
|
194
|
+
}
|
|
195
|
+
function Z(n) {
|
|
192
196
|
return n.type === "slot" ? n.slotName : `legacy:${n.key}`;
|
|
193
197
|
}
|
|
194
198
|
function W(n) {
|
|
195
|
-
const
|
|
196
|
-
return
|
|
199
|
+
const t = Y(n);
|
|
200
|
+
return t ? Ve(t) : null;
|
|
197
201
|
}
|
|
198
|
-
return (n,
|
|
199
|
-
e.title || e.subtitle || n.$slots.actions ? (a(), y("div",
|
|
200
|
-
v("div",
|
|
201
|
-
e.title ? (a(), y("div",
|
|
202
|
-
e.subtitle ? (a(), y("div",
|
|
202
|
+
return (n, t) => (a(), y("div", Pe, [
|
|
203
|
+
e.title || e.subtitle || n.$slots.actions ? (a(), y("div", xe, [
|
|
204
|
+
v("div", Ce, [
|
|
205
|
+
e.title ? (a(), y("div", Se, b(e.title), 1)) : m("", !0),
|
|
206
|
+
e.subtitle ? (a(), y("div", Ee, b(e.subtitle), 1)) : m("", !0)
|
|
203
207
|
]),
|
|
204
208
|
F(n.$slots, "actions")
|
|
205
209
|
])) : m("", !0),
|
|
206
|
-
v("div",
|
|
207
|
-
|
|
210
|
+
v("div", Ne, [
|
|
211
|
+
g(s(ce), {
|
|
208
212
|
model: d.value,
|
|
209
213
|
"label-width": e.labelWidth,
|
|
210
|
-
onSubmit: R(
|
|
214
|
+
onSubmit: R(C, ["prevent"])
|
|
211
215
|
}, {
|
|
212
216
|
default: c(() => [
|
|
213
217
|
v("div", {
|
|
214
218
|
class: "ma-search-panel__grid",
|
|
215
219
|
style: E(G.value)
|
|
216
220
|
}, [
|
|
217
|
-
(a(!0), y(
|
|
218
|
-
key:
|
|
221
|
+
(a(!0), y(U, null, D(u.value, (l, ee) => oe((a(), h(s(pe), {
|
|
222
|
+
key: l.key,
|
|
219
223
|
class: "ma-search-panel__item",
|
|
220
|
-
label:
|
|
221
|
-
style: E(
|
|
224
|
+
label: s(ke)(l.label),
|
|
225
|
+
style: E(l.span ? { gridColumn: `span ${l.span}` } : void 0)
|
|
222
226
|
}, {
|
|
223
227
|
default: c(() => [
|
|
224
|
-
v("div",
|
|
225
|
-
J(
|
|
228
|
+
v("div", Te, [
|
|
229
|
+
J(l) ? (a(), h(N(s(me)(l.type)), I({
|
|
226
230
|
key: 0,
|
|
227
|
-
"model-value": d.value[
|
|
228
|
-
}, { ref_for: !0 },
|
|
231
|
+
"model-value": d.value[l.key]
|
|
232
|
+
}, { ref_for: !0 }, X(l), {
|
|
229
233
|
class: "ma-search-panel__field--full",
|
|
230
|
-
onKeyup:
|
|
231
|
-
"onUpdate:modelValue": (i) =>
|
|
234
|
+
onKeyup: re(C, ["enter"]),
|
|
235
|
+
"onUpdate:modelValue": (i) => x(l.key, i)
|
|
232
236
|
}), {
|
|
233
237
|
default: c(() => [
|
|
234
|
-
|
|
238
|
+
l.type === "select" ? (a(!0), y(U, { key: 0 }, D(l.options ?? [], (i) => (a(), h(s(fe), {
|
|
235
239
|
key: String(i.value),
|
|
236
240
|
label: i.label,
|
|
237
241
|
value: i.value
|
|
238
242
|
}, null, 8, ["label", "value"]))), 128)) : m("", !0)
|
|
239
243
|
]),
|
|
240
244
|
_: 2
|
|
241
|
-
}, 1040, ["model-value", "onUpdate:modelValue"])) : Q(
|
|
245
|
+
}, 1040, ["model-value", "onUpdate:modelValue"])) : Q(l) ? (a(), h(N(l.component), I({
|
|
242
246
|
key: 1,
|
|
243
|
-
"model-value": d.value[
|
|
244
|
-
}, { ref_for: !0 },
|
|
245
|
-
style:
|
|
247
|
+
"model-value": d.value[l.key]
|
|
248
|
+
}, { ref_for: !0 }, l.componentProps, {
|
|
249
|
+
style: s(he)(l),
|
|
246
250
|
class: "ma-search-panel__field--full",
|
|
247
|
-
"onUpdate:modelValue": (i) =>
|
|
248
|
-
}), null, 16, ["model-value", "style", "onUpdate:modelValue"])) : F(n.$slots,
|
|
251
|
+
"onUpdate:modelValue": (i) => x(l.key, i)
|
|
252
|
+
}), null, 16, ["model-value", "style", "onUpdate:modelValue"])) : F(n.$slots, Z(l), {
|
|
249
253
|
key: 2,
|
|
250
|
-
item:
|
|
254
|
+
item: l,
|
|
251
255
|
model: d.value,
|
|
252
|
-
update: (i) =>
|
|
256
|
+
update: (i) => x(l.key, i)
|
|
253
257
|
}, () => [
|
|
254
|
-
W(
|
|
258
|
+
W(l) ? (a(), h(N(W(l)), { key: 0 })) : m("", !0)
|
|
255
259
|
])
|
|
256
260
|
])
|
|
257
261
|
]),
|
|
258
262
|
_: 2
|
|
259
|
-
}, 1032, ["label", "style"]))
|
|
263
|
+
}, 1032, ["label", "style"])), [
|
|
264
|
+
[ae, ee < q.value]
|
|
265
|
+
])), 128)),
|
|
260
266
|
v("div", {
|
|
261
267
|
class: "ma-search-panel__actions-wrap",
|
|
262
|
-
style: E({ gridColumn: `${
|
|
268
|
+
style: E({ gridColumn: `${_.value} / ${_.value + 1}` })
|
|
263
269
|
}, [
|
|
264
|
-
v("div",
|
|
265
|
-
|
|
270
|
+
v("div", Be, [
|
|
271
|
+
g(s(K), {
|
|
266
272
|
type: "primary",
|
|
267
|
-
onClick:
|
|
273
|
+
onClick: C
|
|
268
274
|
}, {
|
|
269
275
|
icon: c(() => [
|
|
270
|
-
|
|
276
|
+
g(s(O), { icon: "heroicons:magnifying-glass" })
|
|
271
277
|
]),
|
|
272
278
|
default: c(() => [
|
|
273
279
|
T(" " + b(e.searchText), 1)
|
|
274
280
|
]),
|
|
275
281
|
_: 1
|
|
276
282
|
}),
|
|
277
|
-
|
|
283
|
+
g(s(K), { onClick: H }, {
|
|
278
284
|
default: c(() => [
|
|
279
285
|
T(b(e.resetText), 1)
|
|
280
286
|
]),
|
|
281
287
|
_: 1
|
|
282
288
|
}),
|
|
283
|
-
|
|
289
|
+
$.value ? (a(), h(s(ye), {
|
|
284
290
|
key: 0,
|
|
285
291
|
type: "primary",
|
|
286
292
|
underline: "never",
|
|
287
293
|
class: "ma-search-panel__fold-toggle",
|
|
288
|
-
onClick:
|
|
294
|
+
onClick: t[0] || (t[0] = R((l) => p.value = !p.value, ["prevent"]))
|
|
289
295
|
}, {
|
|
290
296
|
icon: c(() => [
|
|
291
|
-
|
|
297
|
+
g(s(O), {
|
|
292
298
|
icon: p.value ? "material-symbols:keyboard-arrow-down" : "material-symbols:keyboard-arrow-up"
|
|
293
299
|
}, null, 8, ["icon"])
|
|
294
300
|
]),
|
|
@@ -308,10 +314,10 @@ const _e = { class: "ma-search-panel" }, ge = {
|
|
|
308
314
|
}
|
|
309
315
|
});
|
|
310
316
|
export {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
+
We as SearchPanel,
|
|
318
|
+
We as default,
|
|
319
|
+
we as normalizeSearchPanelItems,
|
|
320
|
+
ke as resolveLabelValue,
|
|
321
|
+
Ve as resolveLegacyVNode,
|
|
322
|
+
be as resolvePropValue
|
|
317
323
|
};
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(c,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("element-plus"),require("@iconify/vue")):typeof define=="function"&&define.amd?define(["exports","vue","element-plus","@iconify/vue"],e):(c=typeof globalThis<"u"?globalThis:c||self,e(c.MaSearchPanel={},c.Vue,c.ElementPlus,c.IconifyVue))})(this,(function(c,e,
|
|
1
|
+
(function(c,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("element-plus"),require("@iconify/vue")):typeof define=="function"&&define.amd?define(["exports","vue","element-plus","@iconify/vue"],e):(c=typeof globalThis<"u"?globalThis:c||self,e(c.MaSearchPanel={},c.Vue,c.ElementPlus,c.IconifyVue))})(this,(function(c,e,s,b){"use strict";const M={input:s.ElInput,select:s.ElSelect,"date-picker":s.ElDatePicker,"input-number":s.ElInputNumber};function L(n){return M[n]}function D(n){if(n.fullWidth!==!1)return{width:"100%"}}const y={input:"input",select:"select","date-picker":"date-picker",inputNumber:"input-number","input-number":"input-number"};function w(n){return typeof n=="function"?n():n??""}function _(n){return typeof n=="function"?n():n??""}function z(n){return typeof n=="string"&&n in y}function $(n){const a=_(n.prop),r=n.label??a;if(z(n.render))return{key:a,label:r,span:n.span,type:y[n.render],options:n.renderProps?.options,componentProps:n.renderProps};if(typeof n.render=="function"){const f=n.render,i=f();return typeof i=="string"&&i in y?{key:a,label:r,span:n.span,type:y[i],options:n.renderProps?.options,componentProps:n.renderProps}:e.isVNode(i)?{key:a,label:r,span:n.span,type:"slot",slotName:`legacy:${a}`}:{key:a,label:r,span:n.span,type:"component",component:i,componentProps:n.renderProps}}return n.render?{key:a,label:r,span:n.span,type:"component",component:n.render,componentProps:n.renderProps}:{key:a,label:r,span:n.span,type:"input",componentProps:n.renderProps}}function B(n){return n.map(a=>"type"in a&&"key"in a?a:$(a))}function C(n){if("type"in n&&"key"in n||typeof n.render!="function")return null;const a=n.render,r=a();return e.isVNode(r)?r:null}const F={class:"ma-search-panel"},I={key:0,class:"ma-search-panel__card ma-search-panel__header"},W={class:"ma-search-panel__title-wrap"},R={key:0,class:"ma-search-panel__title"},U={key:1,class:"ma-search-panel__subtitle"},j={class:"ma-search-panel__card"},q={class:"ma-search-panel__field ma-search-panel__field--full"},O={class:"ma-search-panel__actions"},N=e.defineComponent({__name:"SearchPanel",props:{items:{},modelValue:{default:()=>({})},defaultValue:{default:()=>({})},title:{},subtitle:{},labelWidth:{default:"90px"},cols:{default:()=>({xl:4,lg:4,md:2,sm:2,xs:1})},fold:{type:Boolean,default:!1},foldRows:{default:1},searchText:{default:"搜索"},resetText:{default:"重置"},foldText:{default:"展开搜索"},unfoldText:{default:"收起搜索"}},emits:["update:modelValue","search","reset"],setup(n,{emit:a}){const r=n,f=a,i=e.computed(()=>B(r.items));function h(){const t={};return i.value.forEach(o=>{t[o.key]=r.defaultValue?.[o.key]}),t}const p=e.ref({...h(),...r.modelValue});e.watch(()=>[r.items,r.defaultValue,r.modelValue],()=>{p.value={...h(),...r.modelValue}},{deep:!0});function S(t){p.value=t,f("update:modelValue",t)}const E=e.ref(typeof window>"u"?1440:window.innerWidth);function K(t){if(typeof t=="number")return t;const o=E.value;return o>=1920?t.xl??4:o>=1200?t.lg??3:o>=992?t.md??2:o>=768?t.sm??2:t.xs??1}function k(){typeof window<"u"&&(E.value=window.innerWidth)}e.onMounted(()=>{k(),typeof window<"u"&&window.addEventListener("resize",k)}),e.onBeforeUnmount(()=>{typeof window<"u"&&window.removeEventListener("resize",k)});const m=e.computed(()=>Math.max(K(r.cols),1)),x=e.computed(()=>Math.max(m.value*r.foldRows-1,0)),u=e.ref(r.fold);e.watch(()=>r.fold,t=>{u.value=t});const P=e.computed(()=>i.value.length>x.value),A=e.computed(()=>u.value&&P.value?Math.min(i.value.length,x.value):i.value.length),G=e.computed(()=>({gridTemplateColumns:`repeat(${m.value}, minmax(0, 1fr))`}));function V(t,o){S({...p.value,[t]:o})}function H(){const t=h();S(t),f("reset",t)}function g(){const t={};Object.entries(p.value).forEach(([o,l])=>{l!==""&&l!==void 0&&l!==null&&(t[o]=l)}),f("search",t)}function J(t){return t.type==="input"||t.type==="select"||t.type==="date-picker"||t.type==="input-number"}function Q(t){return t.type==="component"}function X(t){const o={...t.componentProps??{}};return(t.type==="input"||t.type==="select")&&(o.clearable=o.clearable??!0),o}function Y(t){return r.items.find(o=>"type"in o&&"key"in o?o.key===t.key:t.key===(typeof o.prop=="function"?o.prop():o.prop))}function Z(t){return t.type==="slot"?t.slotName:`legacy:${t.key}`}function T(t){const o=Y(t);return o?C(o):null}return(t,o)=>(e.openBlock(),e.createElementBlock("div",F,[n.title||n.subtitle||t.$slots.actions?(e.openBlock(),e.createElementBlock("div",I,[e.createElementVNode("div",W,[n.title?(e.openBlock(),e.createElementBlock("div",R,e.toDisplayString(n.title),1)):e.createCommentVNode("",!0),n.subtitle?(e.openBlock(),e.createElementBlock("div",U,e.toDisplayString(n.subtitle),1)):e.createCommentVNode("",!0)]),e.renderSlot(t.$slots,"actions")])):e.createCommentVNode("",!0),e.createElementVNode("div",j,[e.createVNode(e.unref(s.ElForm),{model:p.value,"label-width":n.labelWidth,onSubmit:e.withModifiers(g,["prevent"])},{default:e.withCtx(()=>[e.createElementVNode("div",{class:"ma-search-panel__grid",style:e.normalizeStyle(G.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,(l,v)=>e.withDirectives((e.openBlock(),e.createBlock(e.unref(s.ElFormItem),{key:l.key,class:"ma-search-panel__item",label:e.unref(w)(l.label),style:e.normalizeStyle(l.span?{gridColumn:`span ${l.span}`}:void 0)},{default:e.withCtx(()=>[e.createElementVNode("div",q,[J(l)?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(L)(l.type)),e.mergeProps({key:0,"model-value":p.value[l.key]},{ref_for:!0},X(l),{class:"ma-search-panel__field--full",onKeyup:e.withKeys(g,["enter"]),"onUpdate:modelValue":d=>V(l.key,d)}),{default:e.withCtx(()=>[l.type==="select"?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(l.options??[],d=>(e.openBlock(),e.createBlock(e.unref(s.ElOption),{key:String(d.value),label:d.label,value:d.value},null,8,["label","value"]))),128)):e.createCommentVNode("",!0)]),_:2},1040,["model-value","onUpdate:modelValue"])):Q(l)?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(l.component),e.mergeProps({key:1,"model-value":p.value[l.key]},{ref_for:!0},l.componentProps,{style:e.unref(D)(l),class:"ma-search-panel__field--full","onUpdate:modelValue":d=>V(l.key,d)}),null,16,["model-value","style","onUpdate:modelValue"])):e.renderSlot(t.$slots,Z(l),{key:2,item:l,model:p.value,update:d=>V(l.key,d)},()=>[T(l)?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(T(l)),{key:0})):e.createCommentVNode("",!0)])])]),_:2},1032,["label","style"])),[[e.vShow,v<A.value]])),128)),e.createElementVNode("div",{class:"ma-search-panel__actions-wrap",style:e.normalizeStyle({gridColumn:`${m.value} / ${m.value+1}`})},[e.createElementVNode("div",O,[e.createVNode(e.unref(s.ElButton),{type:"primary",onClick:g},{icon:e.withCtx(()=>[e.createVNode(e.unref(b.Icon),{icon:"heroicons:magnifying-glass"})]),default:e.withCtx(()=>[e.createTextVNode(" "+e.toDisplayString(n.searchText),1)]),_:1}),e.createVNode(e.unref(s.ElButton),{onClick:H},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(n.resetText),1)]),_:1}),P.value?(e.openBlock(),e.createBlock(e.unref(s.ElLink),{key:0,type:"primary",underline:"never",class:"ma-search-panel__fold-toggle",onClick:o[0]||(o[0]=e.withModifiers(l=>u.value=!u.value,["prevent"]))},{icon:e.withCtx(()=>[e.createVNode(e.unref(b.Icon),{icon:u.value?"material-symbols:keyboard-arrow-down":"material-symbols:keyboard-arrow-up"},null,8,["icon"])]),default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(u.value?n.foldText:n.unfoldText)+" ",1)]),_:1})):e.createCommentVNode("",!0)])],4)],4)]),_:3},8,["model","label-width"])])]))}});c.SearchPanel=N,c.default=N,c.normalizeSearchPanelItems=B,c.resolveLabelValue=w,c.resolveLegacyVNode=C,c.resolvePropValue=_,Object.defineProperties(c,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mywzzz/mineadmin-search-panel",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Library-ready search panel component for MineAdmin and Vue 3 projects",
|
|
6
6
|
"main": "dist/index.umd.cjs",
|
|
@@ -45,4 +45,4 @@
|
|
|
45
45
|
"vite": "^7.2.4",
|
|
46
46
|
"vue-tsc": "^2.2.12"
|
|
47
47
|
}
|
|
48
|
-
}
|
|
48
|
+
}
|