@iswangh/element-plus-kit 0.3.0 → 0.3.2

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 CHANGED
@@ -1,11 +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';
7
4
  import { useLoadOptions } from '@iswangh/element-plus-kit-form';
5
+ import { WCheckTag } from '@iswangh/element-plus-kit-tag';
8
6
  import { WForm } from '@iswangh/element-plus-kit-form';
7
+ import { WTag } from '@iswangh/element-plus-kit-tag';
9
8
 
10
9
  /**
11
10
  * 默认导出安装函数
@@ -43,12 +42,6 @@ export default _default;
43
42
  */
44
43
  export declare function ElementPlusKitResolver(): ComponentResolver & ResolverFunction;
45
44
 
46
- export { FormActionConfig }
47
-
48
- export { FormItemEventExtendedParams }
49
-
50
- export { FormItems }
51
-
52
45
  /**
53
46
  * Element Plus Kit 全局安装函数
54
47
  *
@@ -58,6 +51,14 @@ export declare function install(app: App): void;
58
51
 
59
52
  export { useLoadOptions }
60
53
 
54
+ export { WCheckTag }
55
+
61
56
  export { WForm }
62
57
 
58
+ export { WTag }
59
+
60
+
61
+ export * from "@iswangh/element-plus-kit-form";
62
+ export * from "@iswangh/element-plus-kit-tag";
63
+
63
64
  export { }
package/dist/index.js CHANGED
@@ -1,14 +1,197 @@
1
- import { WForm as t } from "@iswangh/element-plus-kit-form";
2
- import { WForm as s, useLoadOptions as a } from "@iswangh/element-plus-kit-form";
3
- import { ElementPlusKitResolver as i } from "./resolver.js";
4
- function e(o) {
5
- o.component("WForm", t);
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
- const l = { install: e };
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 };
8
189
  export {
9
- i as ElementPlusKitResolver,
10
- s as WForm,
11
- l as default,
12
- e as install,
13
- a as useLoadOptions
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
14
197
  };
package/dist/resolver.js CHANGED
@@ -1,22 +1,23 @@
1
- const s = {
2
- form: "element-plus-kit-form"
1
+ const r = {
2
+ WForm: "element-plus-kit-form",
3
+ WTag: "element-plus-kit-tag",
4
+ WCheckTag: "element-plus-kit-tag"
3
5
  // 未来扩展
4
- // table: 'element-plus-kit-table',
6
+ // WTable: 'element-plus-kit-table',
7
+ // WTableColumn: 'element-plus-kit-table',
5
8
  };
6
- function r(t) {
7
- if (!t.startsWith("W"))
8
- return;
9
- const n = t.slice(1).toLowerCase();
10
- return s[n];
9
+ function n(o) {
10
+ if (o.startsWith("W"))
11
+ return r[o];
11
12
  }
12
- function c() {
13
+ function i() {
13
14
  return Object.assign({
14
15
  type: "component",
15
- resolve: (o) => {
16
- const e = r(o);
16
+ resolve: (t) => {
17
+ const e = n(t);
17
18
  if (e)
18
19
  return {
19
- name: o,
20
+ name: t,
20
21
  from: `@iswangh/${e}`,
21
22
  // sideEffects 配置:确保样式文件在 Tree Shaking 时不被移除
22
23
  // 注意:packages/form/src/index.ts 中已按需导入了所有 Element Plus 组件样式,
@@ -24,12 +25,12 @@ function c() {
24
25
  sideEffects: `@iswangh/${e}/style.css`
25
26
  };
26
27
  }
27
- }, (o) => {
28
- const e = r(o);
28
+ }, (t) => {
29
+ const e = n(t);
29
30
  if (e)
30
31
  return `@iswangh/${e}`;
31
32
  });
32
33
  }
33
34
  export {
34
- c as ElementPlusKitResolver
35
+ i as ElementPlusKitResolver
35
36
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@iswangh/element-plus-kit",
3
3
  "type": "module",
4
- "version": "0.3.0",
4
+ "version": "0.3.2",
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.3.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",