@iswangh/element-plus-kit 0.2.1 → 0.3.1
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.d.ts +13 -9
- package/dist/index.js +194 -12
- package/dist/resolver.js +12 -11
- package/package.json +6 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { App } from 'vue';
|
|
2
2
|
import { ComponentResolver } from 'unplugin-vue-components/types';
|
|
3
|
-
import { FormActionConfig } from '@iswangh/element-plus-kit-form';
|
|
4
|
-
import { FormItemEventExtendedParams } from '@iswangh/element-plus-kit-form';
|
|
5
|
-
import { FormItems } from '@iswangh/element-plus-kit-form';
|
|
6
3
|
import { ResolverFunction } from 'unplugin-auto-import/types';
|
|
4
|
+
import { useLoadOptions } from '@iswangh/element-plus-kit-form';
|
|
5
|
+
import { WCheckTag } from '@iswangh/element-plus-kit-tag';
|
|
7
6
|
import { WForm } from '@iswangh/element-plus-kit-form';
|
|
7
|
+
import { WTag } from '@iswangh/element-plus-kit-tag';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* 默认导出安装函数
|
|
@@ -42,12 +42,6 @@ export default _default;
|
|
|
42
42
|
*/
|
|
43
43
|
export declare function ElementPlusKitResolver(): ComponentResolver & ResolverFunction;
|
|
44
44
|
|
|
45
|
-
export { FormActionConfig }
|
|
46
|
-
|
|
47
|
-
export { FormItemEventExtendedParams }
|
|
48
|
-
|
|
49
|
-
export { FormItems }
|
|
50
|
-
|
|
51
45
|
/**
|
|
52
46
|
* Element Plus Kit 全局安装函数
|
|
53
47
|
*
|
|
@@ -55,6 +49,16 @@ export { FormItems }
|
|
|
55
49
|
*/
|
|
56
50
|
export declare function install(app: App): void;
|
|
57
51
|
|
|
52
|
+
export { useLoadOptions }
|
|
53
|
+
|
|
54
|
+
export { WCheckTag }
|
|
55
|
+
|
|
58
56
|
export { WForm }
|
|
59
57
|
|
|
58
|
+
export { WTag }
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
export * from "@iswangh/element-plus-kit-form";
|
|
62
|
+
export * from "@iswangh/element-plus-kit-tag";
|
|
63
|
+
|
|
60
64
|
export { }
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,197 @@
|
|
|
1
|
-
import { WForm as
|
|
2
|
-
import { WForm as
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { WForm as F } from "@iswangh/element-plus-kit-form";
|
|
2
|
+
import { WForm as le, useLoadOptions as te } from "@iswangh/element-plus-kit-form";
|
|
3
|
+
import { defineComponent as x, useAttrs as E, computed as s, createBlock as S, openBlock as P, unref as _, normalizeProps as C, guardReactiveProps as W, withCtx as B, createElementBlock as R, Fragment as $, renderList as w, mergeProps as I, createTextVNode as M, toDisplayString as N, useSlots as L, renderSlot as j } from "vue";
|
|
4
|
+
import { ElSpace as z, ElCheckTag as D, ElTag as H } from "element-plus";
|
|
5
|
+
import { ElementPlusKitResolver as ne } from "./resolver.js";
|
|
6
|
+
const J = /* @__PURE__ */ x({
|
|
7
|
+
name: "WCheckTag",
|
|
8
|
+
__name: "CheckTag",
|
|
9
|
+
props: {
|
|
10
|
+
options: {},
|
|
11
|
+
multiple: { type: Boolean, default: !1 },
|
|
12
|
+
modelValue: { type: [String, Number, Boolean, null, Array] },
|
|
13
|
+
props: { default: () => ({ label: "label", value: "value" }) },
|
|
14
|
+
spaceProps: {},
|
|
15
|
+
disabled: { type: Boolean }
|
|
16
|
+
},
|
|
17
|
+
emits: ["update:modelValue", "change"],
|
|
18
|
+
setup(o, { emit: l }) {
|
|
19
|
+
const n = o, u = l, i = E(), p = s(() => {
|
|
20
|
+
const e = { ...n, ...i }, { multiple: t, options: r, modelValue: f, props: v, onChange: k, key: A, ...T } = e;
|
|
21
|
+
return T;
|
|
22
|
+
});
|
|
23
|
+
function b(e) {
|
|
24
|
+
const t = p.value;
|
|
25
|
+
if (e.tagProps) {
|
|
26
|
+
const { key: r, ...f } = e.tagProps;
|
|
27
|
+
return { ...t, ...f };
|
|
28
|
+
}
|
|
29
|
+
return t;
|
|
30
|
+
}
|
|
31
|
+
const c = s(() => {
|
|
32
|
+
if (n.multiple)
|
|
33
|
+
return;
|
|
34
|
+
const e = n.modelValue;
|
|
35
|
+
return Array.isArray(e) ? e[0] : e;
|
|
36
|
+
}), m = s(() => {
|
|
37
|
+
if (n.multiple)
|
|
38
|
+
return;
|
|
39
|
+
const e = c.value;
|
|
40
|
+
return e == null ? null : n.options.some((t) => t[n.props?.value || "value"] === e) ? e : null;
|
|
41
|
+
}), d = s(() => n.multiple ? (Array.isArray(n.modelValue) ? n.modelValue : []).filter((e) => n.options.some((t) => t[n.props?.value || "value"] === e)) : []);
|
|
42
|
+
function g(e) {
|
|
43
|
+
return n.multiple ? d.value.includes(e) : m.value === e;
|
|
44
|
+
}
|
|
45
|
+
function y(e, t) {
|
|
46
|
+
if (!p.value.disabled && !e.disabled)
|
|
47
|
+
if (n.multiple) {
|
|
48
|
+
const r = d.value, f = r.findIndex((k) => k === t);
|
|
49
|
+
let v;
|
|
50
|
+
f >= 0 ? v = r.filter((k, A) => A !== f) : v = [...r, t], u("update:modelValue", v), u("change", v);
|
|
51
|
+
} else {
|
|
52
|
+
if (m.value === t)
|
|
53
|
+
return;
|
|
54
|
+
u("update:modelValue", t), u("change", t);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function V(e) {
|
|
58
|
+
const t = n.props?.label || "label";
|
|
59
|
+
return e[t] ?? "";
|
|
60
|
+
}
|
|
61
|
+
function h(e) {
|
|
62
|
+
const t = n.props?.value || "value";
|
|
63
|
+
return e[t];
|
|
64
|
+
}
|
|
65
|
+
function a(e, t) {
|
|
66
|
+
const r = h(e);
|
|
67
|
+
return r == null ? t : typeof r == "boolean" ? String(r) : typeof r == "string" || typeof r == "number" ? r : String(r);
|
|
68
|
+
}
|
|
69
|
+
return (e, t) => (P(), S(_(z), C(W(n.spaceProps)), {
|
|
70
|
+
default: B(() => [
|
|
71
|
+
(P(!0), R($, null, w(o.options, (r, f) => (P(), S(_(D), I({
|
|
72
|
+
key: a(r, f)
|
|
73
|
+
}, { ref_for: !0 }, b(r), {
|
|
74
|
+
checked: g(h(r)),
|
|
75
|
+
disabled: p.value.disabled || r.disabled,
|
|
76
|
+
onChange: () => y(r, h(r))
|
|
77
|
+
}), {
|
|
78
|
+
default: B(() => [
|
|
79
|
+
M(N(V(r)), 1)
|
|
80
|
+
]),
|
|
81
|
+
_: 2
|
|
82
|
+
}, 1040, ["checked", "disabled", "onChange"]))), 128))
|
|
83
|
+
]),
|
|
84
|
+
_: 1
|
|
85
|
+
}, 16));
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
function K(o, l, n) {
|
|
89
|
+
if (!n)
|
|
90
|
+
return o === l;
|
|
91
|
+
const u = typeof o, i = typeof l;
|
|
92
|
+
if (u === i)
|
|
93
|
+
return o === l;
|
|
94
|
+
switch (`${u}-${i}`) {
|
|
95
|
+
case "boolean-string":
|
|
96
|
+
return o === (l === "true");
|
|
97
|
+
case "string-boolean":
|
|
98
|
+
return o === "true" === l;
|
|
99
|
+
case "number-string":
|
|
100
|
+
return o === Number(l) || String(o) === l;
|
|
101
|
+
case "string-number":
|
|
102
|
+
return Number(o) === l || o === String(l);
|
|
103
|
+
default:
|
|
104
|
+
return o === l;
|
|
105
|
+
}
|
|
6
106
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
107
|
+
function O(o) {
|
|
108
|
+
const {
|
|
109
|
+
options: l,
|
|
110
|
+
value: n,
|
|
111
|
+
fieldProps: u = { label: "label", value: "value" },
|
|
112
|
+
looseMatch: i = !0
|
|
113
|
+
} = o;
|
|
114
|
+
if (!Array.isArray(l) || l.length === 0)
|
|
115
|
+
return { option: null, label: null, matched: !1 };
|
|
116
|
+
const p = u.label || "label", b = u.value || "value", c = l.find((d) => {
|
|
117
|
+
const g = d[b];
|
|
118
|
+
return K(g, n, i);
|
|
119
|
+
});
|
|
120
|
+
if (!c)
|
|
121
|
+
return { option: null, label: null, matched: !1 };
|
|
122
|
+
const m = c[p];
|
|
123
|
+
return {
|
|
124
|
+
option: c,
|
|
125
|
+
label: m ?? null,
|
|
126
|
+
matched: !0
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
const q = /* @__PURE__ */ x({
|
|
130
|
+
name: "WTag",
|
|
131
|
+
__name: "Tag",
|
|
132
|
+
props: {
|
|
133
|
+
label: {},
|
|
134
|
+
options: {},
|
|
135
|
+
value: { type: [String, Number, Boolean, null, Array] },
|
|
136
|
+
props: { default: () => ({ label: "label", value: "value" }) },
|
|
137
|
+
looseMatch: { type: Boolean, default: !0 },
|
|
138
|
+
separator: { default: ", " }
|
|
139
|
+
},
|
|
140
|
+
setup(o) {
|
|
141
|
+
const l = o, n = E(), u = L(), i = s(() => l.value), p = s(() => {
|
|
142
|
+
const a = i.value;
|
|
143
|
+
return a == null ? [] : Array.isArray(a) ? a : [a];
|
|
144
|
+
}), b = s(() => !!u.default), c = { option: null, label: null, matched: !1 }, m = s(() => {
|
|
145
|
+
if (p.value.length === 0)
|
|
146
|
+
return [];
|
|
147
|
+
const a = p.value;
|
|
148
|
+
return l.options ? a.map((e) => ({
|
|
149
|
+
value: e,
|
|
150
|
+
match: O({
|
|
151
|
+
options: l.options ?? [],
|
|
152
|
+
value: e,
|
|
153
|
+
fieldProps: l.props,
|
|
154
|
+
looseMatch: l.looseMatch
|
|
155
|
+
})
|
|
156
|
+
})) : a.map((e) => ({ value: e, match: c }));
|
|
157
|
+
});
|
|
158
|
+
function d(a) {
|
|
159
|
+
const e = { ...n, ...l }, { label: t, options: r, value: f, props: v, looseMatch: k, separator: A, ...T } = e;
|
|
160
|
+
return a?.option?.tagProps ? { ...T, ...a.option.tagProps } : T;
|
|
161
|
+
}
|
|
162
|
+
function g(a, e, t) {
|
|
163
|
+
return l.label && t === 0 ? l.label : e?.matched && e.label ? e.label : a != null ? String(a) : null;
|
|
164
|
+
}
|
|
165
|
+
const y = s(() => {
|
|
166
|
+
if (l.label)
|
|
167
|
+
return l.label;
|
|
168
|
+
const a = m.value.map((e, t) => g(e.value, e.match, t)).filter((e) => e != null);
|
|
169
|
+
return a.length > 0 ? a.join(l.separator) : null;
|
|
170
|
+
}), V = s(() => b.value ? null : y.value), h = s(() => ({
|
|
171
|
+
value: l.value,
|
|
172
|
+
label: y.value,
|
|
173
|
+
options: m.value.map((a) => a.match.option).filter((a) => a != null)
|
|
174
|
+
}));
|
|
175
|
+
return (a, e) => (P(), S(_(H), C(W(d(m.value[0]?.match ?? c))), {
|
|
176
|
+
default: B(() => [
|
|
177
|
+
j(a.$slots, "default", C(W(h.value)), () => [
|
|
178
|
+
M(N(V.value), 1)
|
|
179
|
+
])
|
|
180
|
+
]),
|
|
181
|
+
_: 3
|
|
182
|
+
}, 16));
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
function G(o) {
|
|
186
|
+
o.component("WForm", F), o.component("WTag", q), o.component("WCheckTag", J);
|
|
187
|
+
}
|
|
188
|
+
const Y = { install: G };
|
|
10
189
|
export {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
190
|
+
ne as ElementPlusKitResolver,
|
|
191
|
+
J as WCheckTag,
|
|
192
|
+
le as WForm,
|
|
193
|
+
q as WTag,
|
|
194
|
+
Y as default,
|
|
195
|
+
G as install,
|
|
196
|
+
te as useLoadOptions
|
|
15
197
|
};
|
package/dist/resolver.js
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
const
|
|
2
|
-
form: "element-plus-kit-form"
|
|
1
|
+
const r = {
|
|
2
|
+
form: "element-plus-kit-form",
|
|
3
|
+
tag: "element-plus-kit-tag"
|
|
3
4
|
// 未来扩展
|
|
4
5
|
// table: 'element-plus-kit-table',
|
|
5
6
|
};
|
|
6
|
-
function
|
|
7
|
-
if (!
|
|
7
|
+
function s(o) {
|
|
8
|
+
if (!o.startsWith("W"))
|
|
8
9
|
return;
|
|
9
|
-
const n =
|
|
10
|
-
return
|
|
10
|
+
const n = o.slice(1).toLowerCase();
|
|
11
|
+
return r[n];
|
|
11
12
|
}
|
|
12
13
|
function c() {
|
|
13
14
|
return Object.assign({
|
|
14
15
|
type: "component",
|
|
15
|
-
resolve: (
|
|
16
|
-
const e =
|
|
16
|
+
resolve: (t) => {
|
|
17
|
+
const e = s(t);
|
|
17
18
|
if (e)
|
|
18
19
|
return {
|
|
19
|
-
name:
|
|
20
|
+
name: t,
|
|
20
21
|
from: `@iswangh/${e}`,
|
|
21
22
|
// sideEffects 配置:确保样式文件在 Tree Shaking 时不被移除
|
|
22
23
|
// 注意:packages/form/src/index.ts 中已按需导入了所有 Element Plus 组件样式,
|
|
@@ -24,8 +25,8 @@ function c() {
|
|
|
24
25
|
sideEffects: `@iswangh/${e}/style.css`
|
|
25
26
|
};
|
|
26
27
|
}
|
|
27
|
-
}, (
|
|
28
|
-
const e =
|
|
28
|
+
}, (t) => {
|
|
29
|
+
const e = s(t);
|
|
29
30
|
if (e)
|
|
30
31
|
return `@iswangh/${e}`;
|
|
31
32
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iswangh/element-plus-kit",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.1",
|
|
5
5
|
"description": "Element Plus Kit - 基于 Element Plus 的 Vue 3 组件集合",
|
|
6
6
|
"author": "iswangh",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -39,7 +39,8 @@
|
|
|
39
39
|
"vue": "^3.5.23"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@iswangh/element-plus-kit-form": "0.
|
|
42
|
+
"@iswangh/element-plus-kit-form": "0.3.0",
|
|
43
|
+
"@iswangh/element-plus-kit-tag": "0.0.1"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
46
|
"@vitejs/plugin-vue": "^6.0.1",
|
|
@@ -52,12 +53,12 @@
|
|
|
52
53
|
"vue-tsc": "^3.1.3"
|
|
53
54
|
},
|
|
54
55
|
"publishConfig": {
|
|
55
|
-
"access": "public"
|
|
56
|
+
"access": "public",
|
|
57
|
+
"registry": "https://registry.npmjs.org/"
|
|
56
58
|
},
|
|
57
59
|
"scripts": {
|
|
58
60
|
"build": "vite build",
|
|
59
61
|
"dev": "vite build --watch",
|
|
60
|
-
"type-check": "vue-tsc --build"
|
|
61
|
-
"clean": "node -e \"require('fs').rmSync('dist', {recursive: true, force: true})\""
|
|
62
|
+
"type-check": "vue-tsc --build"
|
|
62
63
|
}
|
|
63
64
|
}
|