@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 O, ref as h, unref as n, useSlots as K, toRef as M, watch as G, openBlock as H, createBlock as W, mergeProps as x, withCtx as g, createVNode as $, createSlots as U, renderList as q, renderSlot as J, normalizeProps as Q, guardReactiveProps as X } from "vue";
2
- import { Table as Y } from "@aplus-frontend/antdv";
3
- import { ApForm as b } from "../ap-form/index.mjs";
4
- import { isArray as Z, isNumber as d, cloneDeep as f, omit as w } from "lodash-unified";
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 m } from "../utils/index.mjs";
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__ */ O({
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(C, {
113
- expose: y
112
+ setup(R, {
113
+ expose: B
114
114
  }) {
115
- const l = C;
116
- function R(e, o) {
117
- return Z(o) ? o.reduce((r, a) => r == null ? void 0 : r[a], e) : e == null ? void 0 : e[o];
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: B
122
- } = I(), u = h(R(n(B), l.name) || []), D = K(), F = M(l.name), L = b.useWatch(F);
123
- G(() => L.value, (e) => {
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
- u.value = e, (o = l.onChange) == null || o.call(l, e);
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: T
131
- } = te("editable-table"), c = h(), N = ae("valueTypeMap"), V = ee(l, N);
132
- function v(e, o) {
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 r = ((s = n(u)) == null ? void 0 : s.length) || 0;
135
- if (m(l.maxLength) && r >= l.maxLength)
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(u) || []];
138
- m(o) ? a.splice(o, 0, {
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 E(e, o = "suffix") {
145
- var p;
146
- const r = ((p = n(u)) == null ? void 0 : p.length) || 0, a = d(e) ? e : e.length;
147
- if (m(l.maxLength) && r + a > l.maxLength)
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(u) || []], i = d(e) ? new Array(e).fill({}) : f(e);
150
- o === "suffix" ? s.push(...i) : s.unshift(...i), t == null || t.setFieldValue(l.name, s);
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 S(e) {
153
- let o = f(n(u) || []);
154
- const r = d(e) ? [e] : e;
155
- o = o.filter((a, s) => !r.includes(s)), t == null || t.setFieldValue(l.name, o);
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(u);
161
+ function k() {
162
+ return n(r);
159
163
  }
160
- function k(e) {
164
+ function j(e) {
161
165
  var o;
162
- return (o = n(u)) == null ? void 0 : o[e];
166
+ return (o = n(r)) == null ? void 0 : o[e];
163
167
  }
164
- function j(e, o, r = !0) {
165
- const a = f(n(u));
168
+ function A(e, o, u = !0) {
169
+ const a = m(n(r));
166
170
  a[e] && (a[e] = {
167
- ...r ? a[e] : {},
171
+ ...u ? a[e] : {},
168
172
  ...o
169
173
  }, t == null || t.setFieldValue(l.name, [...a]));
170
174
  }
171
- function A(e) {
175
+ function P(e) {
172
176
  t == null || t.setFieldValue(l.name, e);
173
177
  }
174
- function P(e, o) {
178
+ function z(e, o) {
175
179
  var a;
176
- const r = e === "end" ? u.value.length - 1 : e;
177
- oe(r, (a = c.value) == null ? void 0 : a.$el, o);
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 z() {
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 y({
184
- add: v,
185
- remove: S,
186
- getRowData: k,
187
- getRowsData: _,
188
- setRowData: j,
189
- addMultiple: E,
190
- scrollTo: P,
191
- setTableData: A,
192
- clear: z
193
- }), (e, o) => (H(), W(n(b).FormItem, x(e.formItem, {
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: g(() => [$(n(Y), x(n(w)(l, ["name", "maxLength", "onChange"]), {
201
+ default: w(() => [W(n(X), b(n(y)(l, ["name", "maxLength", "onChange"]), {
198
202
  ref_key: "tableRef",
199
- ref: c,
200
- class: n(T)(),
201
- columns: n(V),
202
- "data-source": u.value
203
- }), U({
203
+ ref: p,
204
+ class: n(v)(),
205
+ columns: n(N),
206
+ "data-source": r.value
207
+ }), $({
204
208
  _: 2
205
- }, [q(n(w)(D, ["headerCell"]), (r, a) => ({
209
+ }, [q(n(y)(L, ["headerCell"]), (u, a) => ({
206
210
  name: a,
207
- fn: g((s) => [J(e.$slots, a, Q(X(s || {})))])
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"),E=require("@aplus-frontend/antdv"),p=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(h,{expose:x}){const u=h;function g(e,t){return d.isArray(t)?t.reduce((l,a)=>l==null?void 0:l[a],e):e==null?void 0:e[t]}const{internalInstance:n,model:b}=P.useInjectForm(),r=o.ref(g(o.unref(b),u.name)||[]),C=o.useSlots(),w=o.toRef(u.name),y=p.ApForm.useWatch(w);o.watch(()=>y.value,e=>{var t;r.value=e,(t=u.onChange)==null||t.call(u,e)},{deep:!0});const{b:R}=A.useNamespace("editable-table"),c=o.ref(),D=M.useGlobalConfig("valueTypeMap"),B=j.default(u,D);function F(e,t){var s;const l=((s=o.unref(r))==null?void 0:s.length)||0;if(f.isDef(u.maxLength)&&l>=u.maxLength)return;const a=[...o.unref(r)||[]];f.isDef(t)?a.splice(t,0,{...e||{}}):a.push({...e||{}}),n==null||n.setFieldValue(u.name,a)}function q(e,t="suffix"){var m;const l=((m=o.unref(r))==null?void 0:m.length)||0,a=d.isNumber(e)?e:e.length;if(f.isDef(u.maxLength)&&l+a>u.maxLength)return;const s=[...o.unref(r)||[]],i=d.isNumber(e)?new Array(e).fill({}):d.cloneDeep(e);t==="suffix"?s.push(...i):s.unshift(...i),n==null||n.setFieldValue(u.name,s)}function v(e){let t=d.cloneDeep(o.unref(r)||[]);const l=d.isNumber(e)?[e]:e;t=t.filter((a,s)=>!l.includes(s)),n==null||n.setFieldValue(u.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,l=!0){const a=d.cloneDeep(o.unref(r));a[e]&&(a[e]={...l?a[e]:{},...t},n==null||n.setFieldValue(u.name,[...a]))}function S(e){n==null||n.setFieldValue(u.name,e)}function _(e,t){var a;const l=e==="end"?r.value.length-1:e;k.scrollToRowIndex(l,(a=c.value)==null?void 0:a.$el,t)}function V(){var e;(e=n==null?void 0:n.setFieldValue)==null||e.call(n,u.name,[])}return x({add:F,remove:v,getRowData:T,getRowsData:N,setRowData:L,addMultiple:q,scrollTo:_,setTableData:S,clear:V}),(e,t)=>(o.openBlock(),o.createBlock(o.unref(p.ApForm).FormItem,o.mergeProps(e.formItem,{name:e.name,label:e.label}),{default:o.withCtx(()=>[o.createVNode(o.unref(E.Table),o.mergeProps(o.unref(d.omit)(u,["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"]),(l,a)=>({name:a,fn:o.withCtx(s=>[o.renderSlot(e.$slots,a,o.normalizeProps(o.guardReactiveProps(s||{})))])}))]),1040,["class","columns","data-source"])]),_:3},16,["name","label"]))}});exports.default=O;
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.4",
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/hooks": "1.0.7",
68
- "@aplus-frontend/utils": "1.0.43"
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",