@ditari/bsui 1.0.24 → 1.0.25

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 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("vue"),S=require("ant-design-vue"),N=require("../../utils/html.cjs.js"),$=require("../theme/index.cjs.js"),A=()=>({data:{type:Object,required:!0},height:{type:Number,default:300},keys:Array,rowKey:{type:String,default:"id"},loading:{type:Boolean,default:!1},pagination:{type:Object,default:()=>({})},config:{type:Object,default:()=>({})}}),y={defaultPageSize:20,hideOnSinglePage:!1,pageSizeOptions:["10","20","30","40"],responsive:!0,showQuickJumper:!0,showLessItems:!0,showTotal:a=>`总共 ${a} 条`},T=`${$.prefixName}-pagination`,J=n.defineComponent({name:"DTable",props:A(),emits:["update:keys"],setup:function(a,{emit:b,slots:p}){const e=n.ref(a.keys||[]),P=n.computed(()=>a.data),R=n.computed(()=>{var t;return((t=a.config)==null?void 0:t.columns)??[]}),f=n.computed(()=>{var t;return((t=a.config)==null?void 0:t.pagination)??{}}),{tableRef:z,tableRootRef:x,tableHeight:E,onPageChange:O,onRowClassName:H}=q();function q(){const{rowClassName:t,keepSelected:l,selection:h,onPageChange:c}=a.config,r=n.ref(),o=n.ref(null),u=n.ref(),i=n.ref(null),g=v=>{var d,C;try{const m=(d=o==null?void 0:o.value)==null?void 0:d.$el,V=N.useEleHeight(m.getElementsByClassName("ant-table-header")[0]);let k=0;if(a.config.pagination){const _=(C=r.value)==null?void 0:C.getElementsByClassName(T)[0];k=N.useEleHeight(_)??0}u.value=v-(V+k),m.getElementsByClassName("ant-table-body")[0].style.height=u.value-10+"px",i.value=m.getElementsByClassName("ant-table-body")[0]}catch(m){console.warn(m)}};return n.watchEffect(()=>{a.height!==0&&n.nextTick(()=>{g(a.height)})}),{tableRef:o,tableRootRef:r,tableHeight:u,onPageChange:(v,d)=>{c&&c({page:v,size:d}),i.value.scrollTop=0,(h==="S"||!l)&&(e.value=[],b("update:keys",e.value))},onRowClassName:(v,d)=>t?t(v,d):void 0}}const B=j();function j(){const{rowKey:t,config:{selection:l,getCheckboxProps:h}}=a;if(l==="N")return;const c=(o,u)=>{l==="S"?(e.value=[],e.value=u?[o[t]]:[]):e.value=u?e.value.concat(o[t]):e.value.filter(i=>i!==o[t]),b("update:keys",e.value)},r=(o,u,i)=>{const g=i.map(s=>s[t]);e.value=o?e.value.concat(g):e.value.filter(s=>!g.includes(s)),b("update:keys",e.value)};return n.watch(()=>a.keys,o=>{e.value=o}),{selectedRowKeys:e,onSelect:c,onSelectAll:r,fixed:!0,columnTitle:l==="S"?"选择":null,columnWidth:l==="S"?60:40,getCheckboxProps:h}}const D=K();function K(){return t=>{let l;const{rowKey:h,config:{click:c,dbClick:r,selection:o,getCheckboxProps:u}}=a,i=t[h],g=()=>{if(o==="N")return;e.value.some(w=>w===i)?e.value=e.value.filter(w=>w!==i):(o==="S"&&(e.value=[]),e.value.push(i)),b("update:keys",e.value)};return{onClick:()=>{const s=u?u(t):null;s&&s.value===i||(clearTimeout(l),l=setTimeout(()=>{g(),c&&c(t)},200))},onDblclick:()=>{clearTimeout(l),r&&r(t)}}}}return()=>{var t;return n.createVNode("div",{ref:x},[n.createVNode(S.Table,{ref:z,"row-key":a.rowKey,bordered:a.config.bordered,columns:R.value,dataSource:P.value,loading:a.loading,size:((t=a.config)==null?void 0:t.size)??"small",scroll:{scrollToFirstRowOnChange:!0,x:"100%",y:E.value+"px"},pagination:!1,customRow:D,rowSelection:B,rowClassName:H},{bodyCell:({column:l})=>{if(l.slot==="action")return n.createVNode(S.Space,null,{default:()=>[p.action&&p.action()]})}}),n.withDirectives(n.createVNode(S.Pagination,{class:[T],current:f.value.current,"onUpdate:current":l=>f.value.current=l,pageSize:f.value.pageSize,"onUpdate:pageSize":l=>f.value.pageSize=l,disabled:a.loading,"show-size-changer":!0,size:"default","hide-on-single-page":y.hideOnSinglePage,"show-quick-jumper":y.showQuickJumper,"default-page-size":y.defaultPageSize,"page-size-options":y.pageSizeOptions,"show-total":y.showTotal,total:f.value.total,onChange:O},null),[[n.vShow,a.config.pagination]])])}}});exports.default=J;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("vue"),w=require("ant-design-vue"),P=require("../../utils/html.cjs.js"),A=require("../theme/index.cjs.js"),J=()=>({data:{type:Object,required:!0},height:{type:Number,default:300},keys:Array,rowKey:{type:String,default:"id"},loading:{type:Boolean,default:!1},pagination:{type:Object,default:()=>({})},config:{type:Object,default:()=>({})}}),y={defaultPageSize:20,hideOnSinglePage:!1,pageSizeOptions:["10","20","30","40"],responsive:!0,showQuickJumper:!0,showLessItems:!0,showTotal:a=>`总共 ${a} 条`},T=`${A.prefixName}-pagination`,M=n.defineComponent({name:"DTable",props:J(),emits:["update:keys"],setup:function(a,{emit:b,slots:S}){const t=n.ref(a.keys||[]),R=n.computed(()=>a.data),z=n.computed(()=>{var e;return((e=a.config)==null?void 0:e.columns)??[]}),f=n.computed(()=>{var e;return((e=a.config)==null?void 0:e.pagination)??{}}),{tableRef:x,tableRootRef:E,tableHeight:O,onPageChange:H,onRowClassName:q}=B();function B(){const{rowClassName:e,keepSelected:o,selection:h,onPageChange:c}=a.config,r=n.ref(),l=n.ref(null),u=n.ref(),i=n.ref(null),g=v=>{var d,k;try{const m=(d=l==null?void 0:l.value)==null?void 0:d.$el,_=P.useEleHeight(m.getElementsByClassName("ant-table-header")[0]);let N=0;if(a.config.pagination){const $=(k=r.value)==null?void 0:k.getElementsByClassName(T)[0];N=P.useEleHeight($)??0}u.value=v-(_+N),m.getElementsByClassName("ant-table-body")[0].style.height=u.value-10+"px",i.value=m.getElementsByClassName("ant-table-body")[0]}catch(m){console.warn(m)}};return n.watchEffect(()=>{a.height!==0&&n.nextTick(()=>{g(a.height)})}),{tableRef:l,tableRootRef:r,tableHeight:u,onPageChange:(v,d)=>{c&&c({page:v,size:d}),i.value.scrollTop=0,(h==="S"||!o)&&(t.value=[],b("update:keys",t.value))},onRowClassName:(v,d)=>e?e(v,d):void 0}}const D=V();function V(){const{rowKey:e,config:{selection:o,getCheckboxProps:h}}=a;if(o==="N")return;const c=(l,u)=>{o==="S"?(t.value=[],t.value=u?[l[e]]:[]):t.value=u?t.value.concat(l[e]):t.value.filter(i=>i!==l[e]),b("update:keys",t.value)},r=(l,u,i)=>{const g=i.map(s=>s[e]);t.value=l?t.value.concat(g):t.value.filter(s=>!g.includes(s)),b("update:keys",t.value)};return n.watch(()=>a.keys,l=>{t.value=l}),{selectedRowKeys:t,onSelect:c,onSelectAll:r,fixed:!0,columnTitle:o==="S"?"选择":null,columnWidth:o==="S"?60:40,getCheckboxProps:h}}const j=K();function K(){return e=>{let o;const{rowKey:h,config:{click:c,dbClick:r,selection:l,getCheckboxProps:u}}=a,i=e[h],g=()=>{if(l==="N")return;t.value.some(p=>p===i)?t.value=t.value.filter(p=>p!==i):(l==="S"&&(t.value=[]),t.value.push(i)),b("update:keys",t.value)};return{onClick:()=>{const s=u?u(e):null;s&&s.value===i||(clearTimeout(o),o=setTimeout(()=>{g(),c&&c(e)},200))},onDblclick:()=>{clearTimeout(o),r&&r(e)}}}}const C=e=>{e.stopPropagation()};return()=>{var e;return n.createVNode("div",{ref:E},[n.createVNode(w.Table,{ref:x,"row-key":a.rowKey,bordered:a.config.bordered,columns:z.value,dataSource:R.value,loading:a.loading,size:((e=a.config)==null?void 0:e.size)??"small",scroll:{scrollToFirstRowOnChange:!0,x:"100%",y:O.value+"px"},pagination:!1,customRow:j,rowSelection:D,rowClassName:q},{bodyCell:({column:o})=>{if(o.slot==="action")return n.createVNode("div",{onClick:C,onDblclick:C},[n.createVNode(w.Space,null,{default:()=>[S.action&&S.action()]})])}}),n.withDirectives(n.createVNode(w.Pagination,{class:[T],current:f.value.current,"onUpdate:current":o=>f.value.current=o,pageSize:f.value.pageSize,"onUpdate:pageSize":o=>f.value.pageSize=o,disabled:a.loading,"show-size-changer":!0,size:"default","hide-on-single-page":y.hideOnSinglePage,"show-quick-jumper":y.showQuickJumper,"default-page-size":y.defaultPageSize,"page-size-options":y.pageSizeOptions,"show-total":y.showTotal,total:f.value.total,onChange:H},null),[[n.vShow,a.config.pagination]])])}}});exports.default=M;
@@ -1,8 +1,8 @@
1
- import { defineComponent as Q, ref as v, computed as S, watchEffect as U, nextTick as F, watch as I, createVNode as b, withDirectives as L, vShow as V } from "vue";
2
- import { Table as W, Space as X, Pagination as _ } from "ant-design-vue";
1
+ import { defineComponent as U, ref as v, computed as S, watchEffect as F, nextTick as I, watch as L, createVNode as p, withDirectives as V, vShow as W } from "vue";
2
+ import { Table as X, Space as _, Pagination as G } from "ant-design-vue";
3
3
  import { useEleHeight as R } from "../../utils/html.esm.js";
4
- import { prefixName as G } from "../theme/index.esm.js";
5
- const M = () => ({
4
+ import { prefixName as M } from "../theme/index.esm.js";
5
+ const Y = () => ({
6
6
  data: {
7
7
  type: Object,
8
8
  required: !0
@@ -36,9 +36,9 @@ const M = () => ({
36
36
  showQuickJumper: !0,
37
37
  showLessItems: !0,
38
38
  showTotal: (a) => `总共 ${a} 条`
39
- }, T = `${G}-pagination`, ae = /* @__PURE__ */ Q({
39
+ }, T = `${M}-pagination`, ne = /* @__PURE__ */ U({
40
40
  name: "DTable",
41
- props: M(),
41
+ props: Y(),
42
42
  // emits: { "update:keys": (keys: []) => void }
43
43
  // TODO 需要做调整
44
44
  emits: ["update:keys"],
@@ -46,41 +46,41 @@ const M = () => ({
46
46
  emit: w,
47
47
  slots: C
48
48
  }) {
49
- const e = v(a.keys || []), z = S(() => a.data), P = S(() => {
50
- var t;
51
- return ((t = a.config) == null ? void 0 : t.columns) ?? [];
49
+ const t = v(a.keys || []), z = S(() => a.data), x = S(() => {
50
+ var e;
51
+ return ((e = a.config) == null ? void 0 : e.columns) ?? [];
52
52
  }), f = S(() => {
53
- var t;
54
- return ((t = a.config) == null ? void 0 : t.pagination) ?? {};
53
+ var e;
54
+ return ((e = a.config) == null ? void 0 : e.pagination) ?? {};
55
55
  }), {
56
- tableRef: x,
57
- tableRootRef: E,
58
- tableHeight: O,
59
- onPageChange: B,
60
- onRowClassName: H
56
+ tableRef: E,
57
+ tableRootRef: O,
58
+ tableHeight: B,
59
+ onPageChange: H,
60
+ onRowClassName: D
61
61
  } = K();
62
62
  function K() {
63
63
  const {
64
- rowClassName: t,
64
+ rowClassName: e,
65
65
  keepSelected: n,
66
66
  selection: d,
67
67
  onPageChange: s
68
68
  } = a.config, c = v(), o = v(null), i = v(), l = v(null), g = (h) => {
69
- var r, k;
69
+ var r, N;
70
70
  try {
71
- const m = (r = o == null ? void 0 : o.value) == null ? void 0 : r.$el, A = R(m.getElementsByClassName("ant-table-header")[0]);
72
- let N = 0;
71
+ const m = (r = o == null ? void 0 : o.value) == null ? void 0 : r.$el, J = R(m.getElementsByClassName("ant-table-header")[0]);
72
+ let P = 0;
73
73
  if (a.config.pagination) {
74
- const J = (k = c.value) == null ? void 0 : k.getElementsByClassName(T)[0];
75
- N = R(J) ?? 0;
74
+ const Q = (N = c.value) == null ? void 0 : N.getElementsByClassName(T)[0];
75
+ P = R(Q) ?? 0;
76
76
  }
77
- i.value = h - (A + N), m.getElementsByClassName("ant-table-body")[0].style.height = i.value - 10 + "px", l.value = m.getElementsByClassName("ant-table-body")[0];
77
+ i.value = h - (J + P), m.getElementsByClassName("ant-table-body")[0].style.height = i.value - 10 + "px", l.value = m.getElementsByClassName("ant-table-body")[0];
78
78
  } catch (m) {
79
79
  console.warn(m);
80
80
  }
81
81
  };
82
- return U(() => {
83
- a.height !== 0 && F(() => {
82
+ return F(() => {
83
+ a.height !== 0 && I(() => {
84
84
  g(a.height);
85
85
  });
86
86
  }), {
@@ -91,15 +91,15 @@ const M = () => ({
91
91
  s && s({
92
92
  page: h,
93
93
  size: r
94
- }), l.value.scrollTop = 0, (d === "S" || !n) && (e.value = [], w("update:keys", e.value));
94
+ }), l.value.scrollTop = 0, (d === "S" || !n) && (t.value = [], w("update:keys", t.value));
95
95
  },
96
- onRowClassName: (h, r) => t ? t(h, r) : void 0
96
+ onRowClassName: (h, r) => e ? e(h, r) : void 0
97
97
  };
98
98
  }
99
- const j = D();
100
- function D() {
99
+ const j = $();
100
+ function $() {
101
101
  const {
102
- rowKey: t,
102
+ rowKey: e,
103
103
  config: {
104
104
  selection: n,
105
105
  getCheckboxProps: d
@@ -108,15 +108,15 @@ const M = () => ({
108
108
  if (n === "N")
109
109
  return;
110
110
  const s = (o, i) => {
111
- n === "S" ? (e.value = [], e.value = i ? [o[t]] : []) : e.value = i ? e.value.concat(o[t]) : e.value.filter((l) => l !== o[t]), w("update:keys", e.value);
111
+ n === "S" ? (t.value = [], t.value = i ? [o[e]] : []) : t.value = i ? t.value.concat(o[e]) : t.value.filter((l) => l !== o[e]), w("update:keys", t.value);
112
112
  }, c = (o, i, l) => {
113
- const g = l.map((u) => u[t]);
114
- e.value = o ? e.value.concat(g) : e.value.filter((u) => !g.includes(u)), w("update:keys", e.value);
113
+ const g = l.map((u) => u[e]);
114
+ t.value = o ? t.value.concat(g) : t.value.filter((u) => !g.includes(u)), w("update:keys", t.value);
115
115
  };
116
- return I(() => a.keys, (o) => {
117
- e.value = o;
116
+ return L(() => a.keys, (o) => {
117
+ t.value = o;
118
118
  }), {
119
- selectedRowKeys: e,
119
+ selectedRowKeys: t,
120
120
  onSelect: s,
121
121
  onSelectAll: c,
122
122
  fixed: !0,
@@ -125,9 +125,9 @@ const M = () => ({
125
125
  getCheckboxProps: d
126
126
  };
127
127
  }
128
- const $ = q();
129
- function q() {
130
- return (t) => {
128
+ const q = A();
129
+ function A() {
130
+ return (e) => {
131
131
  let n;
132
132
  const {
133
133
  rowKey: d,
@@ -137,21 +137,21 @@ const M = () => ({
137
137
  selection: o,
138
138
  getCheckboxProps: i
139
139
  }
140
- } = a, l = t[d], g = () => {
140
+ } = a, l = e[d], g = () => {
141
141
  if (o === "N")
142
142
  return;
143
- e.value.some((p) => p === l) ? e.value = e.value.filter((p) => p !== l) : (o === "S" && (e.value = []), e.value.push(l)), w("update:keys", e.value);
143
+ t.value.some((b) => b === l) ? t.value = t.value.filter((b) => b !== l) : (o === "S" && (t.value = []), t.value.push(l)), w("update:keys", t.value);
144
144
  };
145
145
  return {
146
146
  onClick: () => {
147
- const u = i ? i(t) : null;
147
+ const u = i ? i(e) : null;
148
148
  u && u.value === l || (clearTimeout(n), n = setTimeout(() => {
149
- g(), s && s(t);
149
+ g(), s && s(e);
150
150
  }, 200));
151
151
  },
152
152
  // 点击行
153
153
  onDblclick: () => {
154
- clearTimeout(n), c && c(t);
154
+ clearTimeout(n), c && c(e);
155
155
  }
156
156
  // onContextmenu: (event) => {
157
157
  // //TODO
@@ -165,37 +165,43 @@ const M = () => ({
165
165
  };
166
166
  };
167
167
  }
168
+ const k = (e) => {
169
+ e.stopPropagation();
170
+ };
168
171
  return () => {
169
- var t;
170
- return b("div", {
171
- ref: E
172
- }, [b(W, {
173
- ref: x,
172
+ var e;
173
+ return p("div", {
174
+ ref: O
175
+ }, [p(X, {
176
+ ref: E,
174
177
  "row-key": a.rowKey,
175
178
  bordered: a.config.bordered,
176
- columns: P.value,
179
+ columns: x.value,
177
180
  dataSource: z.value,
178
181
  loading: a.loading,
179
- size: ((t = a.config) == null ? void 0 : t.size) ?? "small",
182
+ size: ((e = a.config) == null ? void 0 : e.size) ?? "small",
180
183
  scroll: {
181
184
  scrollToFirstRowOnChange: !0,
182
185
  x: "100%",
183
- y: O.value + "px"
186
+ y: B.value + "px"
184
187
  },
185
188
  pagination: !1,
186
- customRow: $,
189
+ customRow: q,
187
190
  rowSelection: j,
188
- rowClassName: H
191
+ rowClassName: D
189
192
  }, {
190
193
  bodyCell: ({
191
194
  column: n
192
195
  }) => {
193
196
  if (n.slot === "action")
194
- return b(X, null, {
197
+ return p("div", {
198
+ onClick: k,
199
+ onDblclick: k
200
+ }, [p(_, null, {
195
201
  default: () => [C.action && C.action()]
196
- });
202
+ })]);
197
203
  }
198
- }), L(b(_, {
204
+ }), V(p(G, {
199
205
  class: [T],
200
206
  current: f.value.current,
201
207
  "onUpdate:current": (n) => f.value.current = n,
@@ -210,11 +216,11 @@ const M = () => ({
210
216
  "page-size-options": y.pageSizeOptions,
211
217
  "show-total": y.showTotal,
212
218
  total: f.value.total,
213
- onChange: B
214
- }, null), [[V, a.config.pagination]])]);
219
+ onChange: H
220
+ }, null), [[W, a.config.pagination]])]);
215
221
  };
216
222
  }
217
223
  });
218
224
  export {
219
- ae as default
225
+ ne as default
220
226
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ditari/bsui",
3
- "version": "1.0.24",
3
+ "version": "1.0.25",
4
4
  "files": [
5
5
  "dist/**",
6
6
  "src"
@@ -306,6 +306,9 @@ const DXTable = defineComponent({
306
306
  };
307
307
  }
308
308
 
309
+ const actionStop = (event: MouseEvent) => {
310
+ event.stopPropagation();
311
+ };
309
312
  return () => (
310
313
  <div ref={tableRootRef}>
311
314
  <Table
@@ -329,7 +332,11 @@ const DXTable = defineComponent({
329
332
  {{
330
333
  bodyCell: ({ column }: any) => {
331
334
  if (column.slot === "action") {
332
- return <Space>{slots.action && slots.action()}</Space>;
335
+ return (
336
+ <div onClick={actionStop} onDblclick={actionStop}>
337
+ <Space>{slots.action && slots.action()}</Space>
338
+ </div>
339
+ );
333
340
  }
334
341
  }
335
342
  }}