@silver-formily/element-plus 3.0.1 → 3.0.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/esm/__builtins__/shared/loading.mjs +1 -1
- package/esm/__builtins__/shared/loading.mjs.map +1 -1
- package/esm/__builtins__/shared/use-enter-submit.mjs +57 -16
- package/esm/__builtins__/shared/use-enter-submit.mjs.map +1 -1
- package/esm/array-base/index.mjs +21 -22
- package/esm/array-base/index.mjs.map +1 -1
- package/esm/array-base/utils.mjs +17 -18
- package/esm/array-base/utils.mjs.map +1 -1
- package/esm/array-cards/index.mjs +11 -12
- package/esm/array-cards/index.mjs.map +1 -1
- package/esm/array-collapse/index.mjs +26 -27
- package/esm/array-collapse/index.mjs.map +1 -1
- package/esm/array-collapse/utils.mjs +3 -4
- package/esm/array-collapse/utils.mjs.map +1 -1
- package/esm/array-items/index.mjs +20 -21
- package/esm/array-items/index.mjs.map +1 -1
- package/esm/array-list-tabs/index.mjs +28 -29
- package/esm/array-list-tabs/index.mjs.map +1 -1
- package/esm/array-list-tabs/utils.mjs +5 -6
- package/esm/array-list-tabs/utils.mjs.map +1 -1
- package/esm/array-table/index.mjs +52 -53
- package/esm/array-table/index.mjs.map +1 -1
- package/esm/array-table/utils.mjs +10 -11
- package/esm/array-table/utils.mjs.map +1 -1
- package/esm/array-tabs/index.mjs +40 -43
- package/esm/array-tabs/index.mjs.map +1 -1
- package/esm/autocomplete/index.mjs +4 -5
- package/esm/autocomplete/index.mjs.map +1 -1
- package/esm/cascader/index.mjs +7 -8
- package/esm/cascader/index.mjs.map +1 -1
- package/esm/checkbox/index.mjs +4 -5
- package/esm/checkbox/index.mjs.map +1 -1
- package/esm/color-picker/index.mjs +1 -1
- package/esm/color-picker-panel/index.mjs +1 -1
- package/esm/date-picker/index.mjs +1 -1
- package/esm/date-picker-panel/index.mjs +1 -1
- package/esm/editable/index.mjs +28 -29
- package/esm/editable/index.mjs.map +1 -1
- package/esm/form-button-group/index.mjs +8 -9
- package/esm/form-button-group/index.mjs.map +1 -1
- package/esm/form-button-group/utils.mjs +3 -4
- package/esm/form-button-group/utils.mjs.map +1 -1
- package/esm/form-collapse/index.mjs +4 -5
- package/esm/form-collapse/index.mjs.map +1 -1
- package/esm/form-grid/index.mjs +3 -4
- package/esm/form-grid/index.mjs.map +1 -1
- package/esm/form-item/index.mjs +4 -5
- package/esm/form-item/index.mjs.map +1 -1
- package/esm/form-layout/form-layout.mjs +3 -4
- package/esm/form-layout/form-layout.mjs.map +1 -1
- package/esm/form-step/index.mjs +12 -13
- package/esm/form-step/index.mjs.map +1 -1
- package/esm/form-tab/index.mjs +19 -20
- package/esm/form-tab/index.mjs.map +1 -1
- package/esm/input/index.mjs +13 -14
- package/esm/input/index.mjs.map +1 -1
- package/esm/input-number/index.mjs +1 -1
- package/esm/input-tag/index.mjs +12 -13
- package/esm/input-tag/index.mjs.map +1 -1
- package/esm/mention/index.mjs +12 -13
- package/esm/mention/index.mjs.map +1 -1
- package/esm/preview-text/index.mjs +4 -5
- package/esm/preview-text/index.mjs.map +1 -1
- package/esm/query-form/index.mjs +135 -136
- package/esm/query-form/index.mjs.map +1 -1
- package/esm/query-form-item/index.mjs +23 -24
- package/esm/query-form-item/index.mjs.map +1 -1
- package/esm/radio/index.mjs +4 -5
- package/esm/radio/index.mjs.map +1 -1
- package/esm/rate/index.mjs +1 -1
- package/esm/segmented/index.mjs +4 -5
- package/esm/segmented/index.mjs.map +1 -1
- package/esm/select/index.mjs +13 -14
- package/esm/select/index.mjs.map +1 -1
- package/esm/select-table/index.mjs +4 -5
- package/esm/select-table/index.mjs.map +1 -1
- package/esm/slider/index.mjs +1 -1
- package/esm/time-picker/index.mjs +1 -1
- package/esm/time-select/index.d.ts +8 -8
- package/esm/time-select/index.mjs +1 -1
- package/esm/tree/index.mjs +8 -9
- package/esm/tree/index.mjs.map +1 -1
- package/esm/tree-select/index.mjs +4 -5
- package/esm/tree-select/index.mjs.map +1 -1
- package/esm/upload/index.mjs +36 -40
- package/esm/upload/index.mjs.map +1 -1
- package/package.json +9 -9
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { stylePrefix as i } from "../__builtins__/configs/index.mjs";
|
|
2
2
|
import "element-plus";
|
|
3
|
-
import "@formily/reactive";
|
|
3
|
+
import "@silver-formily/reactive-vue";
|
|
4
4
|
import "@vueuse/core";
|
|
5
5
|
import "vue";
|
|
6
6
|
import "@formily/core";
|
|
7
|
-
import "@silver-formily/reactive-vue";
|
|
8
7
|
import "@silver-formily/vue";
|
|
9
|
-
const
|
|
10
|
-
function
|
|
8
|
+
const u = `${i}-array-list-tabs`;
|
|
9
|
+
function l(r, t) {
|
|
11
10
|
return r.type !== "void" ? r.name === t : r.properties ? t in r.properties : !1;
|
|
12
11
|
}
|
|
13
12
|
export {
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
l as isTabTitleComponent,
|
|
14
|
+
u as prefixCls
|
|
16
15
|
};
|
|
17
16
|
//# sourceMappingURL=utils.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","sources":["../../src/array-list-tabs/utils.ts"],"sourcesContent":["import type { ISchema } from '@formily/json-schema'\nimport { stylePrefix } from '../__builtins__'\n\nexport const prefixCls = `${stylePrefix}-array-list-tabs`\n\nexport function isTabTitleComponent(schema: ISchema, tabTitleField: string) {\n if (schema.type !== 'void') {\n return schema.name === tabTitleField\n }\n if (schema.properties) {\n return tabTitleField in schema.properties\n }\n return false\n}\n"],"names":["prefixCls","stylePrefix","isTabTitleComponent","schema","tabTitleField"],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.mjs","sources":["../../src/array-list-tabs/utils.ts"],"sourcesContent":["import type { ISchema } from '@formily/json-schema'\nimport { stylePrefix } from '../__builtins__'\n\nexport const prefixCls = `${stylePrefix}-array-list-tabs`\n\nexport function isTabTitleComponent(schema: ISchema, tabTitleField: string) {\n if (schema.type !== 'void') {\n return schema.name === tabTitleField\n }\n if (schema.properties) {\n return tabTitleField in schema.properties\n }\n return false\n}\n"],"names":["prefixCls","stylePrefix","isTabTitleComponent","schema","tabTitleField"],"mappings":";;;;;;;AAGO,MAAMA,IAAY,GAAGC,CAAW;AAEhC,SAASC,EAAoBC,GAAiBC,GAAuB;AAC1E,SAAID,EAAO,SAAS,SACXA,EAAO,SAASC,IAErBD,EAAO,aACFC,KAAiBD,EAAO,aAE1B;AACT;"}
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import { ElTable as Y, ElTableColumn as Z, vLoading as ee } from "element-plus";
|
|
2
|
-
import {
|
|
2
|
+
import { reactionWatch as re, autorunEffect as ae, formilyComputed as te } from "@silver-formily/reactive-vue";
|
|
3
3
|
import "@vueuse/core";
|
|
4
|
-
import { defineComponent as
|
|
4
|
+
import { defineComponent as ne, computed as y, ref as g, watch as oe, openBlock as n, createElementBlock as m, normalizeClass as z, unref as t, createBlock as i, withCtx as f, createVNode as le, withDirectives as se, mergeProps as k, Fragment as h, renderList as A, resolveDynamicComponent as ue, createElementVNode as ie, createTextVNode as pe, toDisplayString as ce, createCommentVNode as _, nextTick as de } from "vue";
|
|
5
5
|
import "@formily/core";
|
|
6
|
-
import {
|
|
7
|
-
import { useField as me, useFieldSchema as fe, RecursionField as R } from "@silver-formily/vue";
|
|
6
|
+
import { useField as me, useFieldSchema as fe, RecursionField as E } from "@silver-formily/vue";
|
|
8
7
|
import { useCleanAttrs as ve, composeExport as ye } from "../__builtins__/shared/utils.mjs";
|
|
9
|
-
import { ArrayBase as
|
|
10
|
-
import { isEqual as ge, isArr as
|
|
8
|
+
import { ArrayBase as o } from "../array-base/index.mjs";
|
|
9
|
+
import { isEqual as ge, isArr as R } from "@formily/shared";
|
|
11
10
|
import { VueDraggable as be } from "vue-draggable-plus";
|
|
12
11
|
import { stylePrefix as ke } from "../__builtins__/configs/index.mjs";
|
|
13
12
|
import { isAdditionComponent as he } from "../array-base/utils.mjs";
|
|
14
13
|
import xe from "../pagination/pagination.mjs";
|
|
15
|
-
import { isColumnComponent as F, prefixCls as
|
|
14
|
+
import { isColumnComponent as F, prefixCls as w, isTableComponent as Ce, hasRequiredProperty as Pe } from "./utils.mjs";
|
|
16
15
|
import { o as Se } from "../vendor/lodash.mjs";
|
|
17
|
-
import '../styles/array-table/index.css';const Te = { key: 1 }, Ae = /* @__PURE__ */
|
|
16
|
+
import '../styles/array-table/index.css';const Te = { key: 1 }, Ae = /* @__PURE__ */ ne({
|
|
18
17
|
name: "FArrayTable",
|
|
19
18
|
inheritAttrs: !1,
|
|
20
19
|
__name: "array-table",
|
|
@@ -25,7 +24,7 @@ import '../styles/array-table/index.css';const Te = { key: 1 }, Ae = /* @__PURE_
|
|
|
25
24
|
height: {}
|
|
26
25
|
},
|
|
27
26
|
setup(V) {
|
|
28
|
-
const c = V, { props: B } = ve(), N = y(() => Se(c.paginationProps, ["pageSize", "currentPage"])), x = me(), l = x.value, C = fe(), U = y(() => C.value?.properties ?? {}), { getKey: P, keyMap: $ } =
|
|
27
|
+
const c = V, { props: B } = ve(), N = y(() => Se(c.paginationProps, ["pageSize", "currentPage"])), x = me(), l = x.value, C = fe(), U = y(() => C.value?.properties ?? {}), { getKey: P, keyMap: $ } = o.useKey(C.value), D = g();
|
|
29
28
|
function I(a) {
|
|
30
29
|
return Ce(a) ? H(a) : a.properties ? Object.values(a.properties).flatMap((r) => I(r)) : [];
|
|
31
30
|
}
|
|
@@ -56,7 +55,7 @@ import '../styles/array-table/index.css';const Te = { key: 1 }, Ae = /* @__PURE_
|
|
|
56
55
|
}, { equals: ge });
|
|
57
56
|
const v = g([]), d = g(c.paginationProps?.pageSize ?? 10), p = g(c.paginationProps?.currentPage ?? 1);
|
|
58
57
|
function M() {
|
|
59
|
-
if (!
|
|
58
|
+
if (!R(l.value)) {
|
|
60
59
|
v.value = [];
|
|
61
60
|
return;
|
|
62
61
|
}
|
|
@@ -67,83 +66,83 @@ import '../styles/array-table/index.css';const Te = { key: 1 }, Ae = /* @__PURE_
|
|
|
67
66
|
v.value = l.value.slice((p.value - 1) * d.value, p.value * d.value);
|
|
68
67
|
}
|
|
69
68
|
oe([d, p], M), ae(M);
|
|
70
|
-
const T =
|
|
69
|
+
const T = te(() => {
|
|
71
70
|
const a = C.value.items;
|
|
72
|
-
return (
|
|
73
|
-
const s = I(
|
|
71
|
+
return (R(a) ? a : [a]).reduce((e, u) => {
|
|
72
|
+
const s = I(u);
|
|
74
73
|
return e.concat(s);
|
|
75
74
|
}, []).filter((e) => e.display !== "none");
|
|
76
75
|
}), K = y(() => (T.value ?? []).map((r, e) => ({ source: r, index: e })).filter(({ source: r }) => r.display === "visible" && F(r.schema)).map(({ source: r, index: e }) => {
|
|
77
|
-
const { name:
|
|
76
|
+
const { name: u, columnProps: s, required: b, field: j } = r, { title: G, asterisk: J, ...Q } = s, X = {
|
|
78
77
|
label: G,
|
|
79
78
|
...Q,
|
|
80
|
-
prop:
|
|
79
|
+
prop: u
|
|
81
80
|
};
|
|
82
81
|
return {
|
|
83
82
|
key: e,
|
|
84
83
|
props: X,
|
|
85
|
-
field:
|
|
84
|
+
field: j,
|
|
86
85
|
asterisk: J ?? b
|
|
87
86
|
};
|
|
88
87
|
})), L = y(() => (T.value ?? []).filter((r) => r.display !== "none" && F(r.schema))), q = y(() => (p.value - 1) * d.value);
|
|
89
88
|
async function O() {
|
|
90
89
|
if (c.pagination === !1) {
|
|
91
|
-
await
|
|
92
|
-
const a =
|
|
90
|
+
await de();
|
|
91
|
+
const a = D.value?.$el.querySelector(".el-scrollbar__wrap");
|
|
93
92
|
a?.scrollTo({
|
|
94
93
|
top: a.scrollHeight,
|
|
95
94
|
behavior: "smooth"
|
|
96
95
|
});
|
|
97
96
|
return;
|
|
98
97
|
}
|
|
99
|
-
if (!
|
|
98
|
+
if (!R(l.value)) {
|
|
100
99
|
p.value = 1;
|
|
101
100
|
return;
|
|
102
101
|
}
|
|
103
102
|
p.value = Math.ceil(l.value.length / d.value);
|
|
104
103
|
}
|
|
105
|
-
async function
|
|
104
|
+
async function W(a) {
|
|
106
105
|
const { oldIndex: r, newIndex: e } = a;
|
|
107
106
|
await l.move(r, e), S.value++;
|
|
108
107
|
}
|
|
109
|
-
return (a, r) => (
|
|
110
|
-
class: z(t(
|
|
108
|
+
return (a, r) => (n(), m("div", {
|
|
109
|
+
class: z(t(w))
|
|
111
110
|
}, [
|
|
112
|
-
(
|
|
111
|
+
(n(), i(t(o), {
|
|
113
112
|
key: S.value,
|
|
114
113
|
"key-map": t($),
|
|
115
114
|
add: O
|
|
116
115
|
}, {
|
|
117
116
|
default: f(() => [
|
|
118
|
-
|
|
117
|
+
le(t(be), {
|
|
119
118
|
"model-value": v.value,
|
|
120
119
|
target: "tbody",
|
|
121
120
|
handle: `.${t(ke)}-array-base-sort-handle`,
|
|
122
121
|
animation: 150,
|
|
123
|
-
onEnd:
|
|
122
|
+
onEnd: W
|
|
124
123
|
}, {
|
|
125
124
|
default: f(() => [
|
|
126
|
-
|
|
125
|
+
se((n(), i(t(Y), k({
|
|
127
126
|
ref_key: "elTableRef",
|
|
128
|
-
ref:
|
|
127
|
+
ref: D,
|
|
129
128
|
"row-key": t(P),
|
|
130
129
|
data: v.value
|
|
131
130
|
}, t(B)), {
|
|
132
131
|
default: f(() => [
|
|
133
|
-
(
|
|
132
|
+
(n(!0), m(h, null, A(K.value, (e, u) => (n(), i(t(Z), k({
|
|
134
133
|
key: e.key,
|
|
135
134
|
ref_for: !0
|
|
136
135
|
}, e.props), {
|
|
137
136
|
default: f(({ row: s, $index: b }) => [
|
|
138
|
-
(
|
|
137
|
+
(n(), i(t(o).Item, {
|
|
139
138
|
key: t(P)(s),
|
|
140
139
|
index: b + q.value,
|
|
141
140
|
record: s
|
|
142
141
|
}, {
|
|
143
142
|
default: f(() => [
|
|
144
|
-
(
|
|
143
|
+
(n(), i(t(E), {
|
|
145
144
|
key: `${t(P)(s)}`,
|
|
146
|
-
schema: t(T)[
|
|
145
|
+
schema: t(T)[u].schema,
|
|
147
146
|
name: b + q.value,
|
|
148
147
|
"only-render-properties": ""
|
|
149
148
|
}, null, 8, ["schema", "name"]))
|
|
@@ -152,14 +151,14 @@ import '../styles/array-table/index.css';const Te = { key: 1 }, Ae = /* @__PURE_
|
|
|
152
151
|
}, 1032, ["index", "record"]))
|
|
153
152
|
]),
|
|
154
153
|
header: f(({ column: s }) => [
|
|
155
|
-
e.field.content?.header ? (
|
|
154
|
+
e.field.content?.header ? (n(), i(ue(e.field.content.header), k({
|
|
156
155
|
key: 0,
|
|
157
156
|
ref_for: !0
|
|
158
|
-
}, { ...s, field: t(l) }), null, 16)) : e.asterisk ? (
|
|
157
|
+
}, { ...s, field: t(l) }), null, 16)) : e.asterisk ? (n(), m("span", Te, [
|
|
159
158
|
ie("span", {
|
|
160
|
-
class: z(`${t(
|
|
159
|
+
class: z(`${t(w)}-asterisk`)
|
|
161
160
|
}, "*", 2),
|
|
162
|
-
|
|
161
|
+
pe(" " + ce(s.label), 1)
|
|
163
162
|
])) : _("", !0)
|
|
164
163
|
]),
|
|
165
164
|
_: 2
|
|
@@ -172,25 +171,25 @@ import '../styles/array-table/index.css';const Te = { key: 1 }, Ae = /* @__PURE_
|
|
|
172
171
|
]),
|
|
173
172
|
_: 1
|
|
174
173
|
}, 8, ["model-value", "handle"]),
|
|
175
|
-
(
|
|
176
|
-
key:
|
|
174
|
+
(n(!0), m(h, null, A(L.value, (e, u) => (n(), i(t(E), {
|
|
175
|
+
key: u,
|
|
177
176
|
name: e.name,
|
|
178
177
|
schema: e.schema,
|
|
179
178
|
"only-render-self": !0
|
|
180
179
|
}, null, 8, ["name", "schema"]))), 128)),
|
|
181
|
-
c.pagination ? (
|
|
180
|
+
c.pagination ? (n(), i(t(xe), k({
|
|
182
181
|
key: 0,
|
|
183
182
|
"current-page": p.value,
|
|
184
183
|
"onUpdate:currentPage": r[0] || (r[0] = (e) => p.value = e),
|
|
185
184
|
"page-size": d.value,
|
|
186
185
|
"onUpdate:pageSize": r[1] || (r[1] = (e) => d.value = e),
|
|
187
|
-
class: `${t(
|
|
186
|
+
class: `${t(w)}-pagination`,
|
|
188
187
|
background: "",
|
|
189
188
|
layout: "total, sizes, prev, pager, next",
|
|
190
189
|
total: c.modelValue.length
|
|
191
190
|
}, N.value), null, 16, ["current-page", "page-size", "class", "total"])) : _("", !0),
|
|
192
|
-
(
|
|
193
|
-
t(he)(e) ? (
|
|
191
|
+
(n(!0), m(h, null, A(U.value, (e, u) => (n(), m(h, { key: u }, [
|
|
192
|
+
t(he)(e) ? (n(), i(t(E), {
|
|
194
193
|
key: 0,
|
|
195
194
|
schema: e,
|
|
196
195
|
name: "addition"
|
|
@@ -206,20 +205,20 @@ import '../styles/array-table/index.css';const Te = { key: 1 }, Ae = /* @__PURE_
|
|
|
206
205
|
render() {
|
|
207
206
|
return null;
|
|
208
207
|
}
|
|
209
|
-
},
|
|
208
|
+
}, Ke = ye(Ae, {
|
|
210
209
|
Column: _e,
|
|
211
|
-
Index:
|
|
212
|
-
SortHandle:
|
|
213
|
-
Addition:
|
|
214
|
-
Remove:
|
|
215
|
-
MoveDown:
|
|
216
|
-
MoveUp:
|
|
217
|
-
useArray:
|
|
218
|
-
useIndex:
|
|
219
|
-
useRecord:
|
|
210
|
+
Index: o.Index,
|
|
211
|
+
SortHandle: o.SortHandle,
|
|
212
|
+
Addition: o.Addition,
|
|
213
|
+
Remove: o.Remove,
|
|
214
|
+
MoveDown: o.MoveDown,
|
|
215
|
+
MoveUp: o.MoveUp,
|
|
216
|
+
useArray: o.useArray,
|
|
217
|
+
useIndex: o.useIndex,
|
|
218
|
+
useRecord: o.useRecord
|
|
220
219
|
});
|
|
221
220
|
export {
|
|
222
|
-
|
|
223
|
-
|
|
221
|
+
Ke as ArrayTable,
|
|
222
|
+
Ke as default
|
|
224
223
|
};
|
|
225
224
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/array-table/array-table.vue","../../src/array-table/index.ts"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { ArrayField } from '@formily/core'\nimport type { Schema } from '@formily/json-schema'\nimport type { TableInstance } from 'element-plus'\nimport type { IArrayTableProps } from './types'\nimport { autorun, reaction } from '@formily/reactive'\nimport { isArr, isEqual } from '@formily/shared'\nimport { formilyComputed } from '@silver-formily/reactive-vue'\nimport { RecursionField, useField, useFieldSchema } from '@silver-formily/vue'\nimport { ElTable, ElTableColumn, vLoading } from 'element-plus'\nimport { omit } from 'lodash-es'\nimport { computed, nextTick, ref, watch } from 'vue'\nimport { VueDraggable } from 'vue-draggable-plus'\nimport { stylePrefix, useCleanAttrs } from '../__builtins__'\nimport { ArrayBase } from '../array-base'\nimport { isAdditionComponent } from '../array-base/utils'\nimport ElPagination from '../pagination/pagination'\nimport { hasRequiredProperty, isColumnComponent, isTableComponent, prefixCls } from './utils'\n\ndefineOptions({\n name: 'FArrayTable',\n inheritAttrs: false,\n})\n\nconst props = withDefaults(defineProps<IArrayTableProps>(), {\n modelValue: () => [],\n pagination: true,\n})\nconst { props: elTableProps } = useCleanAttrs()\nconst paginationProps = computed(() => omit(props.paginationProps, ['pageSize', 'currentPage']))\nconst fieldRef = useField<ArrayField>()\nconst field = fieldRef.value\nconst schemaRef = useFieldSchema()\nconst additionSchemas = computed<Record<string, Schema>>(() => schemaRef.value?.properties ?? {})\nconst { getKey, keyMap } = ArrayBase.useKey(schemaRef.value)\n\nconst elTableRef = ref<TableInstance>()\n\nfunction extractTableSources(schema: Schema): any[] {\n if (isTableComponent(schema)) {\n return createTableSource(schema)\n }\n return schema.properties\n ? Object.values(schema.properties).flatMap(element => extractTableSources(element))\n : []\n}\n\nfunction createTableSource(schema: Schema): any[] {\n const propName = schema['x-component-props']?.prop || schema.name\n /* istanbul ignore if -- @preserve */\n if (!propName)\n return []\n\n const field = fieldRef.value.query(fieldRef.value.address.concat(propName)).take()\n\n return [{\n name: propName,\n display: field?.display || schema['x-display'],\n required: hasRequiredProperty(schema),\n field,\n fieldProps: field?.props || schema.toFieldProps(),\n schema,\n columnProps: (field?.component as any[])?.[1] || schema['x-component-props'] || {},\n }]\n}\n\nconst triggerUpdateKey = ref(0)\nreaction(() => {\n const path = field.path.entire\n return field.query(`${path}.*`).map((item) => {\n return {\n name: item.component[0],\n visible: item.visible,\n }\n }).filter(item => item.name.includes('Column'))\n}, async () => {\n triggerUpdateKey.value++\n}, { equals: isEqual })\n\nconst dataSource = ref([])\nconst pageSize = ref(props.paginationProps?.pageSize ?? 10)\nconst currentPage = ref(props.paginationProps?.currentPage ?? 1)\n\nfunction updateDataSource() {\n /* istanbul ignore if -- @preserve */\n if (!isArr(field.value)) {\n dataSource.value = []\n return\n }\n if (props.pagination === false) {\n dataSource.value = [...field.value]\n return\n }\n dataSource.value = field.value.slice((currentPage.value - 1) * pageSize.value, (currentPage.value) * pageSize.value)\n}\nwatch([pageSize, currentPage], updateDataSource)\nautorun(updateDataSource)\n\nconst sources = formilyComputed(() => {\n const schema = schemaRef.value.items\n const items = isArr(schema) ? schema : [schema]\n return items.reduce((columns, schema) => {\n const item = extractTableSources(schema)\n return columns.concat(item)\n }, []).filter(item => item.display !== 'none')\n})\n\nconst columns = computed(() => {\n const currentSources = sources.value ?? []\n return currentSources\n .map((source, index) => ({ source, index }))\n .filter(({ source }) => source.display === 'visible' && isColumnComponent(source.schema))\n .map(({ source, index: key }) => {\n const { name, columnProps, required, field } = source\n const { title, asterisk, ...restProps } = columnProps\n const props = {\n label: title,\n ...restProps,\n prop: name,\n }\n return {\n key,\n props,\n field,\n asterisk: asterisk ?? required,\n }\n })\n})\n\nconst stateManagerColumns = computed(() => {\n const currentSources = sources.value ?? []\n return currentSources.filter((column) => {\n return column.display !== 'none' && isColumnComponent(column.schema)\n })\n})\n\nconst baseIndex = computed(() => {\n return (currentPage.value - 1) * pageSize.value\n})\n\nasync function onAddItemClick() {\n if (props.pagination === false) {\n await nextTick()\n const scrollWarpDOM = elTableRef.value?.$el.querySelector('.el-scrollbar__wrap')\n scrollWarpDOM?.scrollTo({\n top: scrollWarpDOM.scrollHeight,\n behavior: 'smooth',\n })\n return\n }\n /* istanbul ignore if -- @preserve */\n if (!isArr(field.value)) {\n currentPage.value = 1\n return\n }\n currentPage.value = Math.ceil(field.value.length / pageSize.value)\n}\n\nasync function handleDragEnd(evt: { oldIndex: number, newIndex: number }) {\n const { oldIndex, newIndex } = evt\n await field.move(oldIndex, newIndex)\n triggerUpdateKey.value++\n}\n</script>\n\n<template>\n <div :class=\"prefixCls\">\n <ArrayBase :key=\"triggerUpdateKey\" :key-map=\"keyMap\" :add=\"onAddItemClick\">\n <VueDraggable\n :model-value=\"dataSource\" target=\"tbody\" :handle=\"`.${stylePrefix}-array-base-sort-handle`\"\n :animation=\"150\" @end=\"handleDragEnd\"\n >\n <ElTable ref=\"elTableRef\" v-loading=\"field.loading\" :row-key=\"getKey\" :data=\"dataSource\" v-bind=\"elTableProps\">\n <template v-for=\"(column, colIndex) of columns\" :key=\"column.key\">\n <ElTableColumn v-bind=\"column.props\">\n <template #default=\"{ row, $index }\">\n <ArrayBase.Item :key=\"getKey(row)\" :index=\"$index + baseIndex\" :record=\"row\">\n <RecursionField\n :key=\"`${getKey(row)}`\" :schema=\"sources[colIndex].schema\"\n :name=\"$index + baseIndex\" only-render-properties\n />\n </ArrayBase.Item>\n </template>\n <template #header=\"{ column: col }\">\n <template v-if=\"column.field.content?.header\">\n <component :is=\"column.field.content.header\" v-bind=\"{ ...col, field }\" />\n </template>\n <span v-else-if=\"column.asterisk\">\n <span :class=\"`${prefixCls}-asterisk`\">*</span>\n {{ col.label }}\n </span>\n </template>\n </ElTableColumn>\n </template>\n </ElTable>\n </VueDraggable>\n\n <!-- 状态管理器 -->\n <template v-for=\"(column, key) of stateManagerColumns\" :key=\"key\">\n <RecursionField :name=\"column.name\" :schema=\"column.schema\" :only-render-self=\"true\" />\n </template>\n <ElPagination\n v-if=\"props.pagination\" v-model:current-page=\"currentPage\" v-model:page-size=\"pageSize\"\n :class=\"`${prefixCls}-pagination`\" background layout=\"total, sizes, prev, pager, next\"\n :total=\"props.modelValue.length\" v-bind=\"paginationProps\"\n />\n <template v-for=\"(itemSchema, key) of additionSchemas\" :key=\"key\">\n <RecursionField v-if=\"isAdditionComponent(itemSchema)\" :schema=\"itemSchema\" name=\"addition\" />\n </template>\n </ArrayBase>\n </div>\n</template>\n","import type { Component } from 'vue'\nimport { composeExport } from '../__builtins__/shared'\nimport { ArrayBase } from '../array-base'\nimport ArrayTableInner from './array-table.vue'\nimport './style.scss'\n\nconst ArrayTableColumn: Component = {\n name: 'FArrayTableColumn',\n render() {\n return null\n },\n}\n\nexport const ArrayTable = composeExport(ArrayTableInner, {\n Column: ArrayTableColumn,\n Index: ArrayBase.Index,\n SortHandle: ArrayBase.SortHandle,\n Addition: ArrayBase.Addition,\n Remove: ArrayBase.Remove,\n MoveDown: ArrayBase.MoveDown,\n MoveUp: ArrayBase.MoveUp,\n useArray: ArrayBase.useArray,\n useIndex: ArrayBase.useIndex,\n useRecord: ArrayBase.useRecord,\n})\n\nexport default ArrayTable\n"],"names":["props","__props","elTableProps","useCleanAttrs","paginationProps","computed","omit","fieldRef","useField","field","schemaRef","useFieldSchema","additionSchemas","getKey","keyMap","ArrayBase","elTableRef","ref","extractTableSources","schema","isTableComponent","createTableSource","element","propName","hasRequiredProperty","triggerUpdateKey","reaction","path","item","isEqual","dataSource","pageSize","currentPage","updateDataSource","isArr","watch","autorun","sources","formilyComputed","columns","source","index","isColumnComponent","key","name","columnProps","required","title","asterisk","restProps","stateManagerColumns","column","baseIndex","onAddItemClick","nextTick","scrollWarpDOM","handleDragEnd","evt","oldIndex","newIndex","_createElementBlock","_unref","prefixCls","_createBlock","_createVNode","VueDraggable","stylePrefix","_withDirectives","_openBlock","_mergeProps","_Fragment","_renderList","colIndex","_withCtx","row","$index","RecursionField","col","_resolveDynamicComponent","_hoisted_1","_createElementVNode","_toDisplayString","vLoading","$event","itemSchema","isAdditionComponent","ArrayTableColumn","ArrayTable","composeExport","ArrayTableInner"],"mappings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AA,MAAAC,EAF2B3D,EAAA,OAAe,CAAnCwE,GAAYzC,6BAAkC;AAAA,YACxCkB,EAAAwB,EAAA,EAAoBD,CAAU,UAApDrB,EAA8FF,EAAAe,CAAA,GAAA;AAAA;cAAtC,QAAQQ;AAAA,cAAY,MAAK;AAAA,YAAA;;;;;;;ICzMnFE,KAA8B;AAAA,EAClC,MAAM;AAAA,EACN,SAAS;AACP,WAAO;AAAA,EACT;AACF,GAEaC,KAAaC,GAAcC,IAAiB;AAAA,EACvD,QAAQH;AAAA,EACR,OAAOvE,EAAU;AAAA,EACjB,YAAYA,EAAU;AAAA,EACtB,UAAUA,EAAU;AAAA,EACpB,QAAQA,EAAU;AAAA,EAClB,UAAUA,EAAU;AAAA,EACpB,QAAQA,EAAU;AAAA,EAClB,UAAUA,EAAU;AAAA,EACpB,UAAUA,EAAU;AAAA,EACpB,WAAWA,EAAU;AACvB,CAAC;"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/array-table/array-table.vue","../../src/array-table/index.ts"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { ArrayField } from '@formily/core'\nimport type { Schema } from '@formily/json-schema'\nimport type { TableInstance } from 'element-plus'\nimport type { IArrayTableProps } from './types'\nimport { isArr, isEqual } from '@formily/shared'\nimport { autorunEffect, formilyComputed, reactionWatch } from '@silver-formily/reactive-vue'\nimport { RecursionField, useField, useFieldSchema } from '@silver-formily/vue'\nimport { ElTable, ElTableColumn, vLoading } from 'element-plus'\nimport { omit } from 'lodash-es'\nimport { computed, nextTick, ref, watch } from 'vue'\nimport { VueDraggable } from 'vue-draggable-plus'\nimport { stylePrefix, useCleanAttrs } from '../__builtins__'\nimport { ArrayBase } from '../array-base'\nimport { isAdditionComponent } from '../array-base/utils'\nimport ElPagination from '../pagination/pagination'\nimport { hasRequiredProperty, isColumnComponent, isTableComponent, prefixCls } from './utils'\n\ndefineOptions({\n name: 'FArrayTable',\n inheritAttrs: false,\n})\n\nconst props = withDefaults(defineProps<IArrayTableProps>(), {\n modelValue: () => [],\n pagination: true,\n})\nconst { props: elTableProps } = useCleanAttrs()\nconst paginationProps = computed(() => omit(props.paginationProps, ['pageSize', 'currentPage']))\nconst fieldRef = useField<ArrayField>()\nconst field = fieldRef.value\nconst schemaRef = useFieldSchema()\nconst additionSchemas = computed<Record<string, Schema>>(() => schemaRef.value?.properties ?? {})\nconst { getKey, keyMap } = ArrayBase.useKey(schemaRef.value)\n\nconst elTableRef = ref<TableInstance>()\n\nfunction extractTableSources(schema: Schema): any[] {\n if (isTableComponent(schema)) {\n return createTableSource(schema)\n }\n return schema.properties\n ? Object.values(schema.properties).flatMap(element => extractTableSources(element))\n : []\n}\n\nfunction createTableSource(schema: Schema): any[] {\n const propName = schema['x-component-props']?.prop || schema.name\n /* istanbul ignore if -- @preserve */\n if (!propName)\n return []\n\n const field = fieldRef.value.query(fieldRef.value.address.concat(propName)).take()\n\n return [{\n name: propName,\n display: field?.display || schema['x-display'],\n required: hasRequiredProperty(schema),\n field,\n fieldProps: field?.props || schema.toFieldProps(),\n schema,\n columnProps: (field?.component as any[])?.[1] || schema['x-component-props'] || {},\n }]\n}\n\nconst triggerUpdateKey = ref(0)\nreactionWatch(() => {\n const path = field.path.entire\n return field.query(`${path}.*`).map((item) => {\n return {\n name: item.component[0],\n visible: item.visible,\n }\n }).filter(item => item.name.includes('Column'))\n}, async () => {\n triggerUpdateKey.value++\n}, { equals: isEqual })\n\nconst dataSource = ref([])\nconst pageSize = ref(props.paginationProps?.pageSize ?? 10)\nconst currentPage = ref(props.paginationProps?.currentPage ?? 1)\n\nfunction updateDataSource() {\n /* istanbul ignore if -- @preserve */\n if (!isArr(field.value)) {\n dataSource.value = []\n return\n }\n if (props.pagination === false) {\n dataSource.value = [...field.value]\n return\n }\n dataSource.value = field.value.slice((currentPage.value - 1) * pageSize.value, (currentPage.value) * pageSize.value)\n}\nwatch([pageSize, currentPage], updateDataSource)\nautorunEffect(updateDataSource)\n\nconst sources = formilyComputed(() => {\n const schema = schemaRef.value.items\n const items = isArr(schema) ? schema : [schema]\n return items.reduce((columns, schema) => {\n const item = extractTableSources(schema)\n return columns.concat(item)\n }, []).filter(item => item.display !== 'none')\n})\n\nconst columns = computed(() => {\n const currentSources = sources.value ?? []\n return currentSources\n .map((source, index) => ({ source, index }))\n .filter(({ source }) => source.display === 'visible' && isColumnComponent(source.schema))\n .map(({ source, index: key }) => {\n const { name, columnProps, required, field } = source\n const { title, asterisk, ...restProps } = columnProps\n const props = {\n label: title,\n ...restProps,\n prop: name,\n }\n return {\n key,\n props,\n field,\n asterisk: asterisk ?? required,\n }\n })\n})\n\nconst stateManagerColumns = computed(() => {\n const currentSources = sources.value ?? []\n return currentSources.filter((column) => {\n return column.display !== 'none' && isColumnComponent(column.schema)\n })\n})\n\nconst baseIndex = computed(() => {\n return (currentPage.value - 1) * pageSize.value\n})\n\nasync function onAddItemClick() {\n if (props.pagination === false) {\n await nextTick()\n const scrollWarpDOM = elTableRef.value?.$el.querySelector('.el-scrollbar__wrap')\n scrollWarpDOM?.scrollTo({\n top: scrollWarpDOM.scrollHeight,\n behavior: 'smooth',\n })\n return\n }\n /* istanbul ignore if -- @preserve */\n if (!isArr(field.value)) {\n currentPage.value = 1\n return\n }\n currentPage.value = Math.ceil(field.value.length / pageSize.value)\n}\n\nasync function handleDragEnd(evt: { oldIndex: number, newIndex: number }) {\n const { oldIndex, newIndex } = evt\n await field.move(oldIndex, newIndex)\n triggerUpdateKey.value++\n}\n</script>\n\n<template>\n <div :class=\"prefixCls\">\n <ArrayBase :key=\"triggerUpdateKey\" :key-map=\"keyMap\" :add=\"onAddItemClick\">\n <VueDraggable\n :model-value=\"dataSource\" target=\"tbody\" :handle=\"`.${stylePrefix}-array-base-sort-handle`\"\n :animation=\"150\" @end=\"handleDragEnd\"\n >\n <ElTable ref=\"elTableRef\" v-loading=\"field.loading\" :row-key=\"getKey\" :data=\"dataSource\" v-bind=\"elTableProps\">\n <template v-for=\"(column, colIndex) of columns\" :key=\"column.key\">\n <ElTableColumn v-bind=\"column.props\">\n <template #default=\"{ row, $index }\">\n <ArrayBase.Item :key=\"getKey(row)\" :index=\"$index + baseIndex\" :record=\"row\">\n <RecursionField\n :key=\"`${getKey(row)}`\" :schema=\"sources[colIndex].schema\"\n :name=\"$index + baseIndex\" only-render-properties\n />\n </ArrayBase.Item>\n </template>\n <template #header=\"{ column: col }\">\n <template v-if=\"column.field.content?.header\">\n <component :is=\"column.field.content.header\" v-bind=\"{ ...col, field }\" />\n </template>\n <span v-else-if=\"column.asterisk\">\n <span :class=\"`${prefixCls}-asterisk`\">*</span>\n {{ col.label }}\n </span>\n </template>\n </ElTableColumn>\n </template>\n </ElTable>\n </VueDraggable>\n\n <!-- 状态管理器 -->\n <template v-for=\"(column, key) of stateManagerColumns\" :key=\"key\">\n <RecursionField :name=\"column.name\" :schema=\"column.schema\" :only-render-self=\"true\" />\n </template>\n <ElPagination\n v-if=\"props.pagination\" v-model:current-page=\"currentPage\" v-model:page-size=\"pageSize\"\n :class=\"`${prefixCls}-pagination`\" background layout=\"total, sizes, prev, pager, next\"\n :total=\"props.modelValue.length\" v-bind=\"paginationProps\"\n />\n <template v-for=\"(itemSchema, key) of additionSchemas\" :key=\"key\">\n <RecursionField v-if=\"isAdditionComponent(itemSchema)\" :schema=\"itemSchema\" name=\"addition\" />\n </template>\n </ArrayBase>\n </div>\n</template>\n","import type { Component } from 'vue'\nimport { composeExport } from '../__builtins__/shared'\nimport { ArrayBase } from '../array-base'\nimport ArrayTableInner from './array-table.vue'\nimport './style.scss'\n\nconst ArrayTableColumn: Component = {\n name: 'FArrayTableColumn',\n render() {\n return null\n },\n}\n\nexport const ArrayTable = composeExport(ArrayTableInner, {\n Column: ArrayTableColumn,\n Index: ArrayBase.Index,\n SortHandle: ArrayBase.SortHandle,\n Addition: ArrayBase.Addition,\n Remove: ArrayBase.Remove,\n MoveDown: ArrayBase.MoveDown,\n MoveUp: ArrayBase.MoveUp,\n useArray: ArrayBase.useArray,\n useIndex: ArrayBase.useIndex,\n useRecord: ArrayBase.useRecord,\n})\n\nexport default ArrayTable\n"],"names":["props","__props","elTableProps","useCleanAttrs","paginationProps","computed","omit","fieldRef","useField","field","schemaRef","useFieldSchema","additionSchemas","getKey","keyMap","ArrayBase","elTableRef","ref","extractTableSources","schema","isTableComponent","createTableSource","element","propName","hasRequiredProperty","triggerUpdateKey","reactionWatch","path","item","isEqual","dataSource","pageSize","currentPage","updateDataSource","isArr","watch","autorunEffect","sources","formilyComputed","columns","source","index","isColumnComponent","key","name","columnProps","required","title","asterisk","restProps","stateManagerColumns","column","baseIndex","onAddItemClick","nextTick","scrollWarpDOM","handleDragEnd","evt","oldIndex","newIndex","_createElementBlock","_unref","prefixCls","_createBlock","_createVNode","VueDraggable","stylePrefix","_withDirectives","_openBlock","_mergeProps","_Fragment","_renderList","colIndex","_withCtx","row","$index","RecursionField","col","_resolveDynamicComponent","_hoisted_1","_createElementVNode","_toDisplayString","vLoading","$event","itemSchema","isAdditionComponent","ArrayTableColumn","ArrayTable","composeExport","ArrayTableInner"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,UAAMA,IAAQC,GAIR,EAAE,OAAOC,EAAA,IAAiBC,GAAA,GAC1BC,IAAkBC,EAAS,MAAMC,GAAKN,EAAM,iBAAiB,CAAC,YAAY,aAAa,CAAC,CAAC,GACzFO,IAAWC,GAAA,GACXC,IAAQF,EAAS,OACjBG,IAAYC,GAAA,GACZC,IAAkBP,EAAiC,MAAMK,EAAU,OAAO,cAAc,EAAE,GAC1F,EAAE,QAAAG,GAAQ,QAAAC,EAAA,IAAWC,EAAU,OAAOL,EAAU,KAAK,GAErDM,IAAaC,EAAA;AAEnB,aAASC,EAAoBC,GAAuB;AAClD,aAAIC,GAAiBD,CAAM,IAClBE,EAAkBF,CAAM,IAE1BA,EAAO,aACV,OAAO,OAAOA,EAAO,UAAU,EAAE,QAAQ,CAAAG,MAAWJ,EAAoBI,CAAO,CAAC,IAChF,CAAA;AAAA,IACN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-1,26 +1,25 @@
|
|
|
1
|
-
import { stylePrefix as
|
|
1
|
+
import { stylePrefix as n } from "../__builtins__/configs/index.mjs";
|
|
2
2
|
import "element-plus";
|
|
3
|
-
import "@formily/reactive";
|
|
3
|
+
import "@silver-formily/reactive-vue";
|
|
4
4
|
import "@vueuse/core";
|
|
5
5
|
import "vue";
|
|
6
6
|
import "@formily/core";
|
|
7
|
-
import "@silver-formily/reactive-vue";
|
|
8
7
|
import "@silver-formily/vue";
|
|
9
|
-
import { isOperationComponent as
|
|
10
|
-
const
|
|
8
|
+
import { isOperationComponent as e, isAdditionComponent as i } from "../array-base/utils.mjs";
|
|
9
|
+
const x = `${n}-array-table`;
|
|
11
10
|
function p(o) {
|
|
12
11
|
return o["x-component"]?.indexOf("Column") > -1;
|
|
13
12
|
}
|
|
14
|
-
function
|
|
15
|
-
return p(o) ||
|
|
13
|
+
function c(o) {
|
|
14
|
+
return p(o) || e(o) || i(o);
|
|
16
15
|
}
|
|
17
|
-
function
|
|
16
|
+
function y(o) {
|
|
18
17
|
return o.reduceProperties((r, t) => r || !!t.required, !1);
|
|
19
18
|
}
|
|
20
19
|
export {
|
|
21
|
-
|
|
20
|
+
y as hasRequiredProperty,
|
|
22
21
|
p as isColumnComponent,
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
c as isTableComponent,
|
|
23
|
+
x as prefixCls
|
|
25
24
|
};
|
|
26
25
|
//# sourceMappingURL=utils.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","sources":["../../src/array-table/utils.ts"],"sourcesContent":["import type { Schema } from '@formily/json-schema'\nimport { stylePrefix } from '../__builtins__'\nimport { isAdditionComponent, isOperationComponent } from '../array-base/utils'\n\nexport const prefixCls = `${stylePrefix}-array-table`\n\nexport function isColumnComponent(schema: Schema) {\n return schema['x-component']?.indexOf('Column') > -1\n}\n\nexport function isTableComponent(schema: Schema): boolean {\n return isColumnComponent(schema) || isOperationComponent(schema) || isAdditionComponent(schema)\n}\n\nexport function hasRequiredProperty(schema: Schema): boolean {\n return schema.reduceProperties((hasRequired, property) =>\n hasRequired || !!property.required, false)\n}\n"],"names":["prefixCls","stylePrefix","isColumnComponent","schema","isTableComponent","isOperationComponent","isAdditionComponent","hasRequiredProperty","hasRequired","property"],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.mjs","sources":["../../src/array-table/utils.ts"],"sourcesContent":["import type { Schema } from '@formily/json-schema'\nimport { stylePrefix } from '../__builtins__'\nimport { isAdditionComponent, isOperationComponent } from '../array-base/utils'\n\nexport const prefixCls = `${stylePrefix}-array-table`\n\nexport function isColumnComponent(schema: Schema) {\n return schema['x-component']?.indexOf('Column') > -1\n}\n\nexport function isTableComponent(schema: Schema): boolean {\n return isColumnComponent(schema) || isOperationComponent(schema) || isAdditionComponent(schema)\n}\n\nexport function hasRequiredProperty(schema: Schema): boolean {\n return schema.reduceProperties((hasRequired, property) =>\n hasRequired || !!property.required, false)\n}\n"],"names":["prefixCls","stylePrefix","isColumnComponent","schema","isTableComponent","isOperationComponent","isAdditionComponent","hasRequiredProperty","hasRequired","property"],"mappings":";;;;;;;;AAIO,MAAMA,IAAY,GAAGC,CAAW;AAEhC,SAASC,EAAkBC,GAAgB;AAChD,SAAOA,EAAO,aAAa,GAAG,QAAQ,QAAQ,IAAI;AACpD;AAEO,SAASC,EAAiBD,GAAyB;AACxD,SAAOD,EAAkBC,CAAM,KAAKE,EAAqBF,CAAM,KAAKG,EAAoBH,CAAM;AAChG;AAEO,SAASI,EAAoBJ,GAAyB;AAC3D,SAAOA,EAAO,iBAAiB,CAACK,GAAaC,MAC3CD,KAAe,CAAC,CAACC,EAAS,UAAU,EAAK;AAC7C;"}
|
package/esm/array-tabs/index.mjs
CHANGED
|
@@ -1,77 +1,74 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { useField as
|
|
5
|
-
import { ElTabs as
|
|
6
|
-
import { stylePrefix as
|
|
1
|
+
import { defineComponent as k, ref as p, openBlock as s, createBlock as f, unref as e, mergeProps as C, withCtx as u, createElementBlock as i, Fragment as E, renderList as F, createVNode as b, normalizeClass as _, createTextVNode as A, toDisplayString as v } from "vue";
|
|
2
|
+
import { isEqual as B, isFn as h } from "@formily/shared";
|
|
3
|
+
import { reactionWatch as N } from "@silver-formily/reactive-vue";
|
|
4
|
+
import { useField as P, useFieldSchema as R, RecursionField as S } from "@silver-formily/vue";
|
|
5
|
+
import { ElTabs as V, ElTabPane as q, ElBadge as L } from "element-plus";
|
|
6
|
+
import { stylePrefix as U } from "../__builtins__/configs/index.mjs";
|
|
7
7
|
import "@vueuse/core";
|
|
8
8
|
import "@formily/core";
|
|
9
|
-
import "
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import '../styles/array-tabs/index.css';const K = { key: 0 }, j = { key: 1 }, G = /* @__PURE__ */ C({
|
|
9
|
+
import { useCleanAttrs as w } from "../__builtins__/shared/utils.mjs";
|
|
10
|
+
import { getArrayItemSchema as z } from "../array-base/utils.mjs";
|
|
11
|
+
import '../styles/array-tabs/index.css';const D = { key: 0 }, I = { key: 1 }, K = /* @__PURE__ */ k({
|
|
13
12
|
name: "FArrayTabs",
|
|
14
13
|
inheritAttrs: !1,
|
|
15
14
|
__name: "array-tabs",
|
|
16
|
-
setup(
|
|
17
|
-
const y =
|
|
15
|
+
setup(W) {
|
|
16
|
+
const y = P(), $ = R(), c = `${U}-array-tabs`, n = p("tab-0"), t = y.value;
|
|
18
17
|
t.value.length === 0 && t.value.push(null);
|
|
19
18
|
const g = $.value;
|
|
20
19
|
function d(r) {
|
|
21
20
|
return `${t.title || "Untitled"} ${r + 1}`;
|
|
22
21
|
}
|
|
23
|
-
const
|
|
22
|
+
const m = p([]);
|
|
23
|
+
N(() => t.value.map((r, o) => t.form.queryFeedbacks({
|
|
24
24
|
type: "error",
|
|
25
|
-
address: `${t.address.concat(
|
|
25
|
+
address: `${t.address.concat(o)}.**`
|
|
26
26
|
}).length), (r) => {
|
|
27
|
-
|
|
27
|
+
m.value = r;
|
|
28
28
|
}, {
|
|
29
|
-
equals:
|
|
29
|
+
equals: B
|
|
30
30
|
});
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
});
|
|
34
|
-
const { props: k } = D(["value", "modelValue", "onUpdate:modelValue"]);
|
|
35
|
-
return (r, l) => (s(), f(e(U), F(e(k), {
|
|
31
|
+
const { props: T } = w(["value", "modelValue", "onUpdate:modelValue"]);
|
|
32
|
+
return (r, o) => (s(), f(e(V), C(e(T), {
|
|
36
33
|
"model-value": n.value,
|
|
37
34
|
class: c,
|
|
38
35
|
type: "card",
|
|
39
36
|
addable: !0,
|
|
40
|
-
onTabRemove:
|
|
41
|
-
const a =
|
|
42
|
-
e(t).remove(Number(a)), n.value ===
|
|
37
|
+
onTabRemove: o[0] || (o[0] = (l) => {
|
|
38
|
+
const a = l.toString().match(/tab-(\d+)/)?.[1];
|
|
39
|
+
e(t).remove(Number(a)), n.value === l && (n.value = `tab-${Number(a) - 1}`), e(h)(r.$attrs["tab-remove"]) && r.$attrs["tab-remove"](l);
|
|
43
40
|
}),
|
|
44
|
-
onTabAdd:
|
|
45
|
-
const
|
|
46
|
-
e(t).value.push(null), n.value = `tab-${
|
|
41
|
+
onTabAdd: o[1] || (o[1] = () => {
|
|
42
|
+
const l = e(t).value.length;
|
|
43
|
+
e(t).value.push(null), n.value = `tab-${l}`, e(h)(r.$attrs["tab-add"]) && r.$attrs["tab-add"]();
|
|
47
44
|
}),
|
|
48
45
|
onChange: () => {
|
|
49
46
|
}
|
|
50
47
|
}), {
|
|
51
|
-
default:
|
|
52
|
-
(s(!0), i(
|
|
48
|
+
default: u(() => [
|
|
49
|
+
(s(!0), i(E, null, F(e(t).value, (l, a) => (s(), f(e(q), {
|
|
53
50
|
key: `tab-${a}`,
|
|
54
51
|
closable: a !== 0,
|
|
55
52
|
name: `tab-${a}`
|
|
56
53
|
}, {
|
|
57
|
-
default:
|
|
58
|
-
b(e(
|
|
59
|
-
schema: e(
|
|
54
|
+
default: u(() => [
|
|
55
|
+
b(e(S), {
|
|
56
|
+
schema: e(z)(e(g), a),
|
|
60
57
|
name: a
|
|
61
58
|
}, null, 8, ["schema", "name"])
|
|
62
59
|
]),
|
|
63
|
-
label:
|
|
64
|
-
|
|
65
|
-
b(e(
|
|
66
|
-
class:
|
|
67
|
-
value:
|
|
60
|
+
label: u(() => [
|
|
61
|
+
m.value[a] > 0 ? (s(), i("span", D, [
|
|
62
|
+
b(e(L), {
|
|
63
|
+
class: _([`${c}-errors-badge`]),
|
|
64
|
+
value: m.value[a]
|
|
68
65
|
}, {
|
|
69
|
-
default:
|
|
70
|
-
|
|
66
|
+
default: u(() => [
|
|
67
|
+
A(v(d(a)), 1)
|
|
71
68
|
]),
|
|
72
69
|
_: 2
|
|
73
70
|
}, 1032, ["class", "value"])
|
|
74
|
-
])) : (s(), i("span",
|
|
71
|
+
])) : (s(), i("span", I, v(d(a)), 1))
|
|
75
72
|
]),
|
|
76
73
|
_: 2
|
|
77
74
|
}, 1032, ["closable", "name"]))), 128))
|
|
@@ -79,9 +76,9 @@ import '../styles/array-tabs/index.css';const K = { key: 0 }, j = { key: 1 }, G
|
|
|
79
76
|
_: 1
|
|
80
77
|
}, 16, ["model-value"]));
|
|
81
78
|
}
|
|
82
|
-
}),
|
|
79
|
+
}), x = K;
|
|
83
80
|
export {
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
x as ArrayTabs,
|
|
82
|
+
x as default
|
|
86
83
|
};
|
|
87
84
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/array-tabs/array-tabs.vue","../../src/array-tabs/index.ts"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { ArrayField } from '@formily/core'\nimport type { TabPaneName } from 'element-plus'\nimport {
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/array-tabs/array-tabs.vue","../../src/array-tabs/index.ts"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { ArrayField } from '@formily/core'\nimport type { TabPaneName } from 'element-plus'\nimport { isEqual, isFn } from '@formily/shared'\nimport { reactionWatch } from '@silver-formily/reactive-vue'\nimport { RecursionField, useField, useFieldSchema } from '@silver-formily/vue'\nimport { ElBadge, ElTabPane, ElTabs } from 'element-plus'\nimport { ref } from 'vue'\nimport { useCleanAttrs } from '../__builtins__'\nimport { stylePrefix } from '../__builtins__/configs'\nimport { getArrayItemSchema } from '../array-base/utils'\n\ndefineOptions({\n name: 'FArrayTabs',\n inheritAttrs: false,\n})\n\nconst fieldRef = useField<ArrayField>()\nconst schemaRef = useFieldSchema()\n\nconst prefixCls = `${stylePrefix}-array-tabs`\nconst activeKey = ref<TabPaneName>('tab-0')\n\nconst field = fieldRef.value\n/* istanbul ignore else -- @preserve */\nif (field.value.length === 0) {\n field.value.push(null)\n}\nconst schema = schemaRef.value\nfunction getTabTitle(index: number) {\n return `${field.title || 'Untitled'} ${index + 1}`\n}\n\nconst errorCountList = ref([])\nreactionWatch(() => {\n return field.value.map((item, index) => {\n const panelErrors = field.form.queryFeedbacks({\n type: 'error',\n address: `${field.address.concat(index)}.**`,\n })\n return panelErrors.length\n })\n}, (newVal) => {\n errorCountList.value = newVal\n}, {\n equals: isEqual,\n})\nconst { props: elTabProps } = useCleanAttrs(['value', 'modelValue', 'onUpdate:modelValue'])\n</script>\n\n<template>\n <ElTabs\n v-bind=\"elTabProps\"\n :model-value=\"activeKey\"\n :class=\"prefixCls\"\n type=\"card\"\n :addable=\"true\"\n @tab-remove=\"(target) => {\n const index = target.toString().match(/tab-(\\d+)/)?.[1]\n field.remove(Number(index))\n if (activeKey === target) {\n activeKey = `tab-${Number(index) - 1}`\n }\n\n if (isFn($attrs['tab-remove'])) {\n $attrs['tab-remove'](target)\n }\n }\"\n @tab-add=\"() => {\n const id = field.value.length\n field.value.push(null)\n activeKey = `tab-${id}`\n if (isFn($attrs['tab-add'])) {\n $attrs['tab-add']()\n }\n }\"\n @change=\"() => {}\"\n >\n <ElTabPane\n v-for=\"(item, index) of field.value\"\n :key=\"`tab-${index}`\"\n :closable=\"index !== 0\"\n :name=\"`tab-${index}`\"\n >\n <template #default>\n <RecursionField\n :schema=\"getArrayItemSchema(schema, index)\"\n :name=\"index\"\n />\n </template>\n <template #label>\n <span v-if=\"errorCountList[index] > 0\">\n <ElBadge\n :class=\"[`${prefixCls}-errors-badge`]\"\n :value=\"errorCountList[index]\"\n >\n {{ getTabTitle(index) }}\n </ElBadge>\n </span>\n <span v-else>\n {{ getTabTitle(index) }}\n </span>\n </template>\n </ElTabPane>\n </ElTabs>\n</template>\n","import FArrayTabs from './array-tabs.vue'\nimport './style.scss'\n\nexport const ArrayTabs = FArrayTabs\n\nexport default ArrayTabs\n"],"names":["fieldRef","useField","schemaRef","useFieldSchema","prefixCls","stylePrefix","activeKey","ref","field","schema","getTabTitle","index","errorCountList","reactionWatch","item","newVal","isEqual","elTabProps","useCleanAttrs","_createBlock","_unref","ElTabs","_mergeProps","target","isFn","$attrs","_cache","id","_openBlock","_createElementBlock","_Fragment","ElTabPane","_createVNode","RecursionField","getArrayItemSchema","_hoisted_1","ElBadge","_createTextVNode","_toDisplayString","_hoisted_2","ArrayTabs","FArrayTabs"],"mappings":";;;;;;;;;;;;;;;AAiBA,UAAMA,IAAWC,EAAA,GACXC,IAAYC,EAAA,GAEZC,IAAY,GAAGC,CAAW,eAC1BC,IAAYC,EAAiB,OAAO,GAEpCC,IAAQR,EAAS;AAEvB,IAAIQ,EAAM,MAAM,WAAW,KACzBA,EAAM,MAAM,KAAK,IAAI;AAEvB,UAAMC,IAASP,EAAU;AACzB,aAASQ,EAAYC,GAAe;AAClC,aAAO,GAAGH,EAAM,SAAS,UAAU,IAAIG,IAAQ,CAAC;AAAA,IAClD;AAEA,UAAMC,IAAiBL,EAAI,EAAE;AAC7B,IAAAM,EAAc,MACLL,EAAM,MAAM,IAAI,CAACM,GAAMH,MACRH,EAAM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,CAAK;AAAA,UACjB,UAAUA,MAAK;AAAA,UACf,aAAaA,CAAK;AAAA,QAAA;UAER,WACT,MAGE;AAAA,YAHFqB,EAGEZ,EAAAa,CAAA,GAAA;AAAA,cAFC,QAAQb,EAAAc,CAAA,EAAmBd,EAAAX,CAAA,GAAQE,CAAK;AAAA,cACxC,MAAMA;AAAA,YAAA;;UAGA,SACT,MAOO;AAAA,YAPKC,EAAA,MAAeD,CAAK,IAAA,UAAhCkB,EAOO,QAAAM,GAAA;AAAA,cANLH,EAKUZ,EAAAgB,CAAA,GAAA;AAAA,gBAJP,aAAWhC,CAAS,eAAA,CAAA;AAAA,gBACpB,OAAOQ,EAAA,MAAeD,CAAK;AAAA,cAAA;2BAE5B,MAAwB;AAAA,kBAArB0B,EAAAC,EAAA5B,EAAYC,CAAK,CAAA,GAAA,CAAA;AAAA,gBAAA;;;wBAGxBkB,EAEO,QAAAU,GAAAD,EADF5B,EAAYC,CAAK,CAAA,GAAA,CAAA;AAAA,UAAA;;;;;;;ICjGjB6B,IAAYC;"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { useField as S, connect as $, mapProps as P } from "@silver-formily/vue";
|
|
2
2
|
import { ElAutocomplete as A } from "element-plus";
|
|
3
|
-
import "@formily/reactive";
|
|
3
|
+
import "@silver-formily/reactive-vue";
|
|
4
4
|
import "@vueuse/core";
|
|
5
5
|
import { defineComponent as R, useSlots as w, ref as C, computed as d, openBlock as F, createBlock as x, unref as p, mergeProps as z, createSlots as B, withCtx as n, renderSlot as r, normalizeProps as E, guardReactiveProps as K } from "vue";
|
|
6
6
|
import { mapReadPretty as L } from "../__builtins__/shared/transform-component.mjs";
|
|
7
7
|
import { PreviewText as O } from "../preview-text/index.mjs";
|
|
8
8
|
import "@formily/core";
|
|
9
|
-
import "@silver-formily/reactive-vue";
|
|
10
9
|
import { useCleanAttrs as b } from "../__builtins__/shared/utils.mjs";
|
|
11
10
|
const j = /* @__PURE__ */ R({
|
|
12
11
|
name: "FAutocomplete",
|
|
@@ -102,13 +101,13 @@ const j = /* @__PURE__ */ R({
|
|
|
102
101
|
} : void 0
|
|
103
102
|
]), 1040));
|
|
104
103
|
}
|
|
105
|
-
}),
|
|
104
|
+
}), Q = $(
|
|
106
105
|
j,
|
|
107
106
|
P({ dataSource: "options", readOnly: "readonly", disabled: !0 }),
|
|
108
107
|
L(O.Input)
|
|
109
108
|
);
|
|
110
109
|
export {
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
Q as Autocomplete,
|
|
111
|
+
Q as default
|
|
113
112
|
};
|
|
114
113
|
//# sourceMappingURL=index.mjs.map
|