@aplus-frontend/ui 0.3.4 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Table as
|
|
3
|
-
import { ApForm as
|
|
4
|
-
import { isArray as Z, isNumber as
|
|
1
|
+
import { defineComponent as K, ref as d, unref as n, useSlots as M, watch as g, openBlock as G, createBlock as H, mergeProps as b, withCtx as w, createVNode as W, createSlots as $, renderList as q, renderSlot as U, normalizeProps as J, guardReactiveProps as Q } from "vue";
|
|
2
|
+
import { Table as X } from "@aplus-frontend/antdv";
|
|
3
|
+
import { ApForm as C } from "../ap-form/index.mjs";
|
|
4
|
+
import { isArray as Y, isEqual as Z, isNumber as f, cloneDeep as m, omit as y } from "lodash-unified";
|
|
5
5
|
import "../config-provider/index.mjs";
|
|
6
6
|
import { useInjectForm as I } from "../ap-form/context.mjs";
|
|
7
|
-
import { isDef as
|
|
7
|
+
import { isDef as i } from "../utils/index.mjs";
|
|
8
8
|
import ee from "./hooks/use-get-columns.mjs";
|
|
9
9
|
import { scrollToRowIndex as oe } from "./utils.mjs";
|
|
10
10
|
import { useNamespace as te } from "../config-provider/hooks/use-namespace.mjs";
|
|
11
11
|
import { useGlobalConfig as ae } from "../config-provider/hooks/use-global-config.mjs";
|
|
12
|
-
const he = /* @__PURE__ */
|
|
12
|
+
const he = /* @__PURE__ */ K({
|
|
13
13
|
name: "EditableTableInner",
|
|
14
14
|
__name: "form-item",
|
|
15
15
|
props: {
|
|
@@ -109,102 +109,106 @@ const he = /* @__PURE__ */ O({
|
|
|
109
109
|
default: () => ({})
|
|
110
110
|
}
|
|
111
111
|
},
|
|
112
|
-
setup(
|
|
113
|
-
expose:
|
|
112
|
+
setup(R, {
|
|
113
|
+
expose: B
|
|
114
114
|
}) {
|
|
115
|
-
const l =
|
|
116
|
-
function
|
|
117
|
-
return
|
|
115
|
+
const l = R;
|
|
116
|
+
function D(e, o) {
|
|
117
|
+
return Y(o) ? o.reduce((u, a) => u == null ? void 0 : u[a], e) : e == null ? void 0 : e[o];
|
|
118
118
|
}
|
|
119
119
|
const {
|
|
120
120
|
internalInstance: t,
|
|
121
|
-
model:
|
|
122
|
-
} = I(),
|
|
123
|
-
|
|
121
|
+
model: F
|
|
122
|
+
} = I(), r = d(D(n(F), l.name) || []), L = M(), c = d(l.name);
|
|
123
|
+
g(() => l.name, (e, o) => {
|
|
124
|
+
Z(e, o) || (c.value = e);
|
|
125
|
+
});
|
|
126
|
+
const T = C.useWatch(c);
|
|
127
|
+
g(() => T.value, (e) => {
|
|
124
128
|
var o;
|
|
125
|
-
|
|
129
|
+
r.value = e, (o = l.onChange) == null || o.call(l, e);
|
|
126
130
|
}, {
|
|
127
131
|
deep: !0
|
|
128
132
|
});
|
|
129
133
|
const {
|
|
130
|
-
b:
|
|
131
|
-
} = te("editable-table"),
|
|
132
|
-
function
|
|
134
|
+
b: v
|
|
135
|
+
} = te("editable-table"), p = d(), E = ae("valueTypeMap"), N = ee(l, E);
|
|
136
|
+
function V(e, o) {
|
|
133
137
|
var s;
|
|
134
|
-
const
|
|
135
|
-
if (
|
|
138
|
+
const u = ((s = n(r)) == null ? void 0 : s.length) || 0;
|
|
139
|
+
if (i(l.maxLength) && u >= l.maxLength)
|
|
136
140
|
return;
|
|
137
|
-
const a = [...n(
|
|
138
|
-
|
|
141
|
+
const a = [...n(r) || []];
|
|
142
|
+
i(o) ? a.splice(o, 0, {
|
|
139
143
|
...e || {}
|
|
140
144
|
}) : a.push({
|
|
141
145
|
...e || {}
|
|
142
146
|
}), t == null || t.setFieldValue(l.name, a);
|
|
143
147
|
}
|
|
144
|
-
function
|
|
145
|
-
var
|
|
146
|
-
const
|
|
147
|
-
if (
|
|
148
|
+
function S(e, o = "suffix") {
|
|
149
|
+
var x;
|
|
150
|
+
const u = ((x = n(r)) == null ? void 0 : x.length) || 0, a = f(e) ? e : e.length;
|
|
151
|
+
if (i(l.maxLength) && u + a > l.maxLength)
|
|
148
152
|
return;
|
|
149
|
-
const s = [...n(
|
|
150
|
-
o === "suffix" ? s.push(...
|
|
153
|
+
const s = [...n(r) || []], h = f(e) ? new Array(e).fill({}) : m(e);
|
|
154
|
+
o === "suffix" ? s.push(...h) : s.unshift(...h), t == null || t.setFieldValue(l.name, s);
|
|
151
155
|
}
|
|
152
|
-
function
|
|
153
|
-
let o =
|
|
154
|
-
const
|
|
155
|
-
o = o.filter((a, s) => !
|
|
156
|
+
function _(e) {
|
|
157
|
+
let o = m(n(r) || []);
|
|
158
|
+
const u = f(e) ? [e] : e;
|
|
159
|
+
o = o.filter((a, s) => !u.includes(s)), t == null || t.setFieldValue(l.name, o);
|
|
156
160
|
}
|
|
157
|
-
function
|
|
158
|
-
return n(
|
|
161
|
+
function k() {
|
|
162
|
+
return n(r);
|
|
159
163
|
}
|
|
160
|
-
function
|
|
164
|
+
function j(e) {
|
|
161
165
|
var o;
|
|
162
|
-
return (o = n(
|
|
166
|
+
return (o = n(r)) == null ? void 0 : o[e];
|
|
163
167
|
}
|
|
164
|
-
function
|
|
165
|
-
const a =
|
|
168
|
+
function A(e, o, u = !0) {
|
|
169
|
+
const a = m(n(r));
|
|
166
170
|
a[e] && (a[e] = {
|
|
167
|
-
...
|
|
171
|
+
...u ? a[e] : {},
|
|
168
172
|
...o
|
|
169
173
|
}, t == null || t.setFieldValue(l.name, [...a]));
|
|
170
174
|
}
|
|
171
|
-
function
|
|
175
|
+
function P(e) {
|
|
172
176
|
t == null || t.setFieldValue(l.name, e);
|
|
173
177
|
}
|
|
174
|
-
function
|
|
178
|
+
function z(e, o) {
|
|
175
179
|
var a;
|
|
176
|
-
const
|
|
177
|
-
oe(
|
|
180
|
+
const u = e === "end" ? r.value.length - 1 : e;
|
|
181
|
+
oe(u, (a = p.value) == null ? void 0 : a.$el, o);
|
|
178
182
|
}
|
|
179
|
-
function
|
|
183
|
+
function O() {
|
|
180
184
|
var e;
|
|
181
185
|
(e = t == null ? void 0 : t.setFieldValue) == null || e.call(t, l.name, []);
|
|
182
186
|
}
|
|
183
|
-
return
|
|
184
|
-
add:
|
|
185
|
-
remove:
|
|
186
|
-
getRowData:
|
|
187
|
-
getRowsData:
|
|
188
|
-
setRowData:
|
|
189
|
-
addMultiple:
|
|
190
|
-
scrollTo:
|
|
191
|
-
setTableData:
|
|
192
|
-
clear:
|
|
193
|
-
}), (e, o) => (
|
|
187
|
+
return B({
|
|
188
|
+
add: V,
|
|
189
|
+
remove: _,
|
|
190
|
+
getRowData: j,
|
|
191
|
+
getRowsData: k,
|
|
192
|
+
setRowData: A,
|
|
193
|
+
addMultiple: S,
|
|
194
|
+
scrollTo: z,
|
|
195
|
+
setTableData: P,
|
|
196
|
+
clear: O
|
|
197
|
+
}), (e, o) => (G(), H(n(C).FormItem, b(e.formItem, {
|
|
194
198
|
name: e.name,
|
|
195
199
|
label: e.label
|
|
196
200
|
}), {
|
|
197
|
-
default:
|
|
201
|
+
default: w(() => [W(n(X), b(n(y)(l, ["name", "maxLength", "onChange"]), {
|
|
198
202
|
ref_key: "tableRef",
|
|
199
|
-
ref:
|
|
200
|
-
class: n(
|
|
201
|
-
columns: n(
|
|
202
|
-
"data-source":
|
|
203
|
-
}),
|
|
203
|
+
ref: p,
|
|
204
|
+
class: n(v)(),
|
|
205
|
+
columns: n(N),
|
|
206
|
+
"data-source": r.value
|
|
207
|
+
}), $({
|
|
204
208
|
_: 2
|
|
205
|
-
}, [q(n(
|
|
209
|
+
}, [q(n(y)(L, ["headerCell"]), (u, a) => ({
|
|
206
210
|
name: a,
|
|
207
|
-
fn:
|
|
211
|
+
fn: w((s) => [U(e.$slots, a, J(Q(s || {})))])
|
|
208
212
|
}))]), 1040, ["class", "columns", "data-source"])]),
|
|
209
213
|
_: 3
|
|
210
214
|
}, 16, ["name", "label"]));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue"),V=require("@aplus-frontend/antdv"),h=require("../ap-form/index.js"),d=require("lodash-unified");require("../config-provider/index.js");const P=require("../ap-form/context.js"),f=require("../utils/index.js"),j=require("./hooks/use-get-columns.js"),k=require("./utils.js"),A=require("../config-provider/hooks/use-namespace.js"),M=require("../config-provider/hooks/use-global-config.js"),O=o.defineComponent({name:"EditableTableInner",__name:"form-item",props:{dropdownPrefixCls:{},pagination:{type:[Boolean,Object],default:!1},loading:{type:[Boolean,Object],default:void 0},size:{default:"middle"},bordered:{type:Boolean,default:!1},locale:{},onResizeColumn:{},rowSelection:{},getPopupContainer:{},scroll:{},sortDirections:{default:()=>["ascend","descend"]},showSorterTooltip:{type:[Boolean,Object],default:!0},prefixCls:{},rowKey:{default:"key"},tableLayout:{default:"fixed"},rowClassName:{},title:{},footer:{},id:{},showHeader:{type:Boolean,default:!0},components:{},customRow:{},customHeaderRow:{},direction:{},expandFixed:{type:[String,Boolean],default:!1},expandColumnWidth:{},expandedRowKeys:{},defaultExpandedRowKeys:{},expandedRowRender:{},expandRowByClick:{type:Boolean,default:!1},expandIcon:{},onExpand:{},onExpandedRowsChange:{},defaultExpandAllRows:{type:Boolean,default:!1},indentSize:{default:15},expandIconColumnIndex:{},showExpandColumn:{type:Boolean,default:!0},expandedRowClassName:{},childrenColumnName:{default:"children"},rowExpandable:{},sticky:{type:[Boolean,Object]},transformCellText:{},columns:{},value:{},defaultValue:{},"onUpdate:value":{},onChange:{},maxLength:{},onFieldChange:{},label:{},name:{},formItem:{default:()=>({})}},setup(x,{expose:g}){const l=x;function b(e,t){return d.isArray(t)?t.reduce((u,n)=>u==null?void 0:u[n],e):e==null?void 0:e[t]}const{internalInstance:a,model:w}=P.useInjectForm(),r=o.ref(b(o.unref(w),l.name)||[]),C=o.useSlots(),i=o.ref(l.name);o.watch(()=>l.name,(e,t)=>{d.isEqual(e,t)||(i.value=e)});const y=h.ApForm.useWatch(i);o.watch(()=>y.value,e=>{var t;r.value=e,(t=l.onChange)==null||t.call(l,e)},{deep:!0});const{b:R}=A.useNamespace("editable-table"),c=o.ref(),D=M.useGlobalConfig("valueTypeMap"),B=j.default(l,D);function q(e,t){var s;const u=((s=o.unref(r))==null?void 0:s.length)||0;if(f.isDef(l.maxLength)&&u>=l.maxLength)return;const n=[...o.unref(r)||[]];f.isDef(t)?n.splice(t,0,{...e||{}}):n.push({...e||{}}),a==null||a.setFieldValue(l.name,n)}function v(e,t="suffix"){var p;const u=((p=o.unref(r))==null?void 0:p.length)||0,n=d.isNumber(e)?e:e.length;if(f.isDef(l.maxLength)&&u+n>l.maxLength)return;const s=[...o.unref(r)||[]],m=d.isNumber(e)?new Array(e).fill({}):d.cloneDeep(e);t==="suffix"?s.push(...m):s.unshift(...m),a==null||a.setFieldValue(l.name,s)}function F(e){let t=d.cloneDeep(o.unref(r)||[]);const u=d.isNumber(e)?[e]:e;t=t.filter((n,s)=>!u.includes(s)),a==null||a.setFieldValue(l.name,t)}function N(){return o.unref(r)}function T(e){var t;return(t=o.unref(r))==null?void 0:t[e]}function L(e,t,u=!0){const n=d.cloneDeep(o.unref(r));n[e]&&(n[e]={...u?n[e]:{},...t},a==null||a.setFieldValue(l.name,[...n]))}function S(e){a==null||a.setFieldValue(l.name,e)}function _(e,t){var n;const u=e==="end"?r.value.length-1:e;k.scrollToRowIndex(u,(n=c.value)==null?void 0:n.$el,t)}function E(){var e;(e=a==null?void 0:a.setFieldValue)==null||e.call(a,l.name,[])}return g({add:q,remove:F,getRowData:T,getRowsData:N,setRowData:L,addMultiple:v,scrollTo:_,setTableData:S,clear:E}),(e,t)=>(o.openBlock(),o.createBlock(o.unref(h.ApForm).FormItem,o.mergeProps(e.formItem,{name:e.name,label:e.label}),{default:o.withCtx(()=>[o.createVNode(o.unref(V.Table),o.mergeProps(o.unref(d.omit)(l,["name","maxLength","onChange"]),{ref_key:"tableRef",ref:c,class:o.unref(R)(),columns:o.unref(B),"data-source":r.value}),o.createSlots({_:2},[o.renderList(o.unref(d.omit)(C,["headerCell"]),(u,n)=>({name:n,fn:o.withCtx(s=>[o.renderSlot(e.$slots,n,o.normalizeProps(o.guardReactiveProps(s||{})))])}))]),1040,["class","columns","data-source"])]),_:3},16,["name","label"]))}});exports.default=O;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aplus-frontend/ui",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"sortablejs": "^1.15.2",
|
|
65
65
|
"vue-virtual-scroller": "2.0.0-beta.8",
|
|
66
66
|
"vuedraggable": "^4.1.0",
|
|
67
|
-
"@aplus-frontend/
|
|
68
|
-
"@aplus-frontend/
|
|
67
|
+
"@aplus-frontend/utils": "1.0.43",
|
|
68
|
+
"@aplus-frontend/hooks": "1.0.7"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
71
|
"@aplus-frontend/antdv": "^1.0.8",
|