@kingteza/crud-component 1.27.2 → 1.29.0

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,143 +1,145 @@
1
- import { jsx as e, jsxs as L, Fragment as et } from "react/jsx-runtime";
2
- import { Modal as lt } from "antd";
3
- import { DndContext as Rt } from "@dnd-kit/core";
4
- import { restrictToVerticalAxis as dt } from "@dnd-kit/modifiers";
5
- import { CSS as Ot } from "@dnd-kit/utilities";
6
- import { arrayMove as ct, SortableContext as Bt, verticalListSortingStrategy as Dt, useSortable as Nt } from "@dnd-kit/sortable";
7
- import jt from "../../common/button/Button.es.js";
8
- import { RefreshButton as Et } from "../../common/button/RefreshButton.es.js";
9
- import Lt from "../../common/button/ViewButtonTable.es.js";
10
- import Mt from "../actions/index.es.js";
11
- import Vt from "../../common/table/table.es.js";
12
- import ft, { useMemo as x, useState as z, useCallback as v, useEffect as st, useContext as kt } from "react";
13
- import { useTranslationLib as zt } from "../../locale/index.es.js";
14
- import vt from "../CrudSearchComponent.es.js";
15
- import { CrudDecListView as At } from "./CrudDecListView.es.js";
16
- import { getRendererValueCrudViewer as mt } from "./CrudViewerUtil.es.js";
17
- import { HolderOutlined as _t } from "@ant-design/icons";
18
- import ut from "../../util/CrudUtil.es.js";
19
- import $t from "../../common/layout/VerticalSpace.es.js";
20
- const qt = ft.memo(Vt);
21
- function so({
1
+ import { jsx as e, jsxs as L, Fragment as st } from "react/jsx-runtime";
2
+ import { Modal as Bt } from "antd";
3
+ import { DndContext as Dt } from "@dnd-kit/core";
4
+ import { restrictToVerticalAxis as Nt } from "@dnd-kit/modifiers";
5
+ import { CSS as dt } from "@dnd-kit/utilities";
6
+ import { arrayMove as mt, SortableContext as jt, verticalListSortingStrategy as lt, useSortable as Et } from "@dnd-kit/sortable";
7
+ import Lt from "../../common/button/Button.es.js";
8
+ import { RefreshButton as Mt } from "../../common/button/RefreshButton.es.js";
9
+ import Vt from "../../common/button/ViewButtonTable.es.js";
10
+ import kt from "../actions/index.es.js";
11
+ import zt from "../../common/table/table.es.js";
12
+ import ht, { useMemo as x, useState as v, useCallback as A, useEffect as ut, useContext as vt } from "react";
13
+ import { useTranslationLib as At } from "../../locale/index.es.js";
14
+ import _t from "../CrudSearchComponent.es.js";
15
+ import { CrudDecListView as $t } from "./CrudDecListView.es.js";
16
+ import { getRendererValueCrudViewer as ft } from "./CrudViewerUtil.es.js";
17
+ import { HolderOutlined as qt } from "@ant-design/icons";
18
+ import it from "../../util/CrudUtil.es.js";
19
+ import Gt from "../../common/layout/VerticalSpace.es.js";
20
+ const Jt = ht.memo(zt);
21
+ function uo({
22
22
  summary: h,
23
23
  idField: n = "id",
24
- loadingData: C,
24
+ loadingData: p,
25
25
  fields: y,
26
- isDeleting: R,
27
- isHiding: O,
26
+ isDeleting: O,
27
+ isHiding: N,
28
28
  viewable: c = !1,
29
29
  paginateProps: u,
30
30
  onDelete: I,
31
- onHide: B,
32
- onUpdate: D,
31
+ deletable: B,
32
+ updatable: M,
33
+ onHide: _,
34
+ onUpdate: d,
33
35
  data: T = [],
34
- extraAction: N,
35
- onClickUpdate: j,
36
- minusHeight: M,
37
- scroll: A,
38
- onClickClone: _,
39
- className: $,
40
- expandable: q,
41
- size: G,
42
- bordered: J,
43
- descListColumn: ht,
44
- extraView: V,
45
- decListLayout: yt,
46
- scrollToTop: Kt,
47
- onClickRefresh: K,
48
- closeViewOnClickUpdate: Q,
49
- onExport: X,
50
- confirmHiding: Y,
51
- confirmDeleting: Z,
52
- rowClassName: W,
53
- actionWidth: P = 190,
36
+ extraAction: j,
37
+ onClickUpdate: l,
38
+ minusHeight: V,
39
+ scroll: $,
40
+ onClickClone: q,
41
+ className: G,
42
+ expandable: J,
43
+ size: K,
44
+ bordered: Q,
45
+ descListColumn: Ct,
46
+ extraView: k,
47
+ decListLayout: pt,
48
+ scrollToTop: Xt,
49
+ onClickRefresh: X,
50
+ closeViewOnClickUpdate: Y,
51
+ onExport: Z,
52
+ confirmHiding: W,
53
+ confirmDeleting: P,
54
+ rowClassName: H,
55
+ actionWidth: U = 190,
54
56
  draggable: t,
55
- rowSelection: H,
56
- ...pt
57
+ rowSelection: w,
58
+ ...St
57
59
  }) {
58
- const { t: U } = zt(), w = x(
59
- () => y.map(({ hideInTable: o, hidden: r, width: s, label: f, halign: l, ...S }) => {
60
- const E = ut.getRealName(S.name);
60
+ const { t: F } = At(), a = x(
61
+ () => y.map(({ hideInTable: o, hidden: r, width: s, label: f, halign: R, ...S }) => {
62
+ const E = it.getRealName(S.name);
61
63
  return {
62
64
  title: f,
63
65
  width: s,
64
66
  key: E,
65
67
  dataIndex: E,
66
68
  hidden: o || r,
67
- align: l ?? (S.type === "number" ? "right" : void 0),
68
- render: mt(S),
69
+ align: R ?? (S.type === "number" ? "right" : void 0),
70
+ render: ft(S),
69
71
  sorter: S.sorter,
70
72
  defaultSortOrder: S.defaultSortOrder
71
73
  };
72
74
  }),
73
75
  [y]
74
- ), [m, d] = z(), [F, a] = z(), [p, b] = z([]), Ct = v((o) => {
75
- d(o);
76
+ ), [m, D] = v(), [b, g] = v(), [C, tt] = v([]), xt = A((o) => {
77
+ D(o);
76
78
  }, []);
77
- st(() => {
78
- T && b(T);
79
- }, [T]), st(() => {
80
- T && d((o) => {
79
+ ut(() => {
80
+ T && tt(T);
81
+ }, [T]), ut(() => {
82
+ T && D((o) => {
81
83
  if (o)
82
84
  return T.find((r) => r[n] === o[n]);
83
85
  });
84
86
  }, [T, n, m]);
85
- const g = v(
87
+ const ot = A(
86
88
  (o) => {
87
89
  var f;
88
90
  const { active: r, over: s } = o;
89
91
  if (t != null && t.onDragEnd && (t == null || t.onDragEnd(o)), r.id !== (s == null ? void 0 : s.id)) {
90
- const l = p.findIndex(
92
+ const R = C.findIndex(
91
93
  (i) => i[n] === r.id
92
- ), S = p.findIndex(
94
+ ), S = C.findIndex(
93
95
  (i) => i[n] === (s == null ? void 0 : s.id)
94
- ), E = ct(p, l, S);
95
- b((i) => {
96
- const It = i.findIndex(
97
- (k) => k[n] === (r == null ? void 0 : r.id)
98
- ), Tt = i.findIndex(
99
- (k) => k[n] === (s == null ? void 0 : s.id)
96
+ ), E = mt(C, R, S);
97
+ tt((i) => {
98
+ const Rt = i.findIndex(
99
+ (z) => z[n] === (r == null ? void 0 : r.id)
100
+ ), Ot = i.findIndex(
101
+ (z) => z[n] === (s == null ? void 0 : s.id)
100
102
  );
101
- return ct(i, It, Tt);
103
+ return mt(i, Rt, Ot);
102
104
  }), (f = t == null ? void 0 : t.onDrag) == null || f.call(t, {
103
105
  newOrder: E.map((i) => i[n])
104
106
  });
105
107
  }
106
108
  },
107
- [p, n, t]
108
- ), St = x(() => {
109
+ [C, n, t]
110
+ ), It = x(() => {
109
111
  let o = typeof c == "string" ? m == null ? void 0 : m[c] : void 0;
110
112
  if (typeof o == "object") {
111
- const r = y.find((s) => ut.getRealName(s.name) === c);
112
- o = mt(r)(
113
+ const r = y.find((s) => it.getRealName(s.name) === c);
114
+ o = ft(r)(
113
115
  o,
114
116
  m,
115
117
  0
116
118
  );
117
119
  }
118
120
  return o;
119
- }, [c, m, y]), tt = x(
121
+ }, [c, m, y]), nt = x(
120
122
  () => ({
121
- rowSelection: H,
122
- rowClassName: W,
123
- className: $,
124
- scroll: A ?? (M ? { y: `calc(100vh - ${M})` } : void 0),
123
+ rowSelection: w,
124
+ rowClassName: H,
125
+ className: G,
126
+ scroll: $ ?? (V ? { y: `calc(100vh - ${V})` } : void 0),
125
127
  id: "crud-table",
126
- bordered: J,
127
- size: G,
128
- expandable: q
128
+ bordered: Q,
129
+ size: K,
130
+ expandable: J
129
131
  }),
130
132
  [
133
+ w,
131
134
  H,
132
- W,
133
- $,
134
- A,
135
- M,
136
- J,
137
135
  G,
138
- q
136
+ $,
137
+ V,
138
+ Q,
139
+ K,
140
+ J
139
141
  ]
140
- ), ot = x(
142
+ ), rt = x(
141
143
  () => u ? {
142
144
  ...u,
143
145
  total: u.count,
@@ -146,178 +148,184 @@ function so({
146
148
  pageSize: u.pageSize
147
149
  } : void 0,
148
150
  [u]
149
- ), nt = x(() => {
150
- const o = D || j || I || N || c, r = [];
151
+ ), et = x(() => {
152
+ const o = d || l || I || j || c, r = [];
151
153
  return t && r.push({
152
154
  key: "key",
153
155
  align: "center",
154
156
  width: 5,
155
157
  title: t == null ? void 0 : t.columnLabel,
156
- render: () => /* @__PURE__ */ e(Gt, { tooltip: t == null ? void 0 : t.tooltip })
157
- }), r.push(...w), o && o && r.push({
158
- title: U("str.action"),
158
+ render: () => /* @__PURE__ */ e(Kt, { tooltip: t == null ? void 0 : t.tooltip })
159
+ }), r.push(...a), o && o && r.push({
160
+ title: F("str.action"),
159
161
  fixed: "right",
160
- width: P,
161
- render: (s, f) => /* @__PURE__ */ L(et, { children: [
162
+ width: U,
163
+ render: (s, f) => /* @__PURE__ */ L(st, { children: [
162
164
  c && /* @__PURE__ */ e(
163
- Lt,
165
+ Vt,
164
166
  {
165
167
  value: f,
166
168
  onClick: typeof c == "object" ? () => {
167
- var l;
168
- return (l = c.onClick) == null ? void 0 : l.call(c, f);
169
- } : Ct
169
+ var R;
170
+ return (R = c.onClick) == null ? void 0 : R.call(c, f);
171
+ } : xt
170
172
  }
171
173
  ),
172
174
  /* @__PURE__ */ e(
173
- Mt,
175
+ kt,
174
176
  {
175
177
  data: f,
176
178
  idField: n,
177
- extraAction: N,
178
- onUpdate: D,
179
- onClickUpdate: j,
180
- onClickClone: _,
179
+ extraAction: j,
180
+ onUpdate: d,
181
+ onClickUpdate: l,
182
+ onClickClone: q,
181
183
  onDelete: I,
182
- onHide: B,
183
- onExport: X,
184
- isHiding: O,
185
- isDeleting: R,
186
- confirmHiding: Y,
187
- confirmDeleting: Z,
188
- closeViewOnClickUpdate: Q,
189
- recentUpdateOrDeleteId: F,
190
- setRecentUpdateOrDeleteId: a,
191
- setOpenView: d
184
+ deletable: B,
185
+ updatable: M,
186
+ onHide: _,
187
+ onExport: Z,
188
+ isHiding: N,
189
+ isDeleting: O,
190
+ confirmHiding: W,
191
+ confirmDeleting: P,
192
+ closeViewOnClickUpdate: Y,
193
+ recentUpdateOrDeleteId: b,
194
+ setRecentUpdateOrDeleteId: g,
195
+ setOpenView: D
192
196
  }
193
197
  )
194
198
  ] })
195
199
  }), r;
196
200
  }, [
197
- w,
198
- D,
199
- j,
201
+ a,
202
+ d,
203
+ l,
200
204
  I,
201
- N,
205
+ B,
206
+ M,
207
+ j,
202
208
  c,
203
- U,
204
- P
205
- ]), rt = x(
206
- () => p.map((o) => o[n]),
207
- [p, n]
208
- ), xt = v(() => {
209
+ F,
210
+ U
211
+ ]), ct = x(
212
+ () => C.map((o) => o[n]),
213
+ [C, n]
214
+ ), Tt = A(() => {
209
215
  const o = /* @__PURE__ */ e(
210
- qt,
216
+ Jt,
211
217
  {
212
- ...tt,
218
+ ...nt,
213
219
  summary: h,
214
- dataSource: p,
215
- loading: C,
216
- components: t ? { body: { row: Jt } } : void 0,
217
- pagination: ot,
218
- columns: nt
220
+ dataSource: C,
221
+ loading: p,
222
+ components: t ? { body: { row: Qt } } : void 0,
223
+ pagination: rt,
224
+ columns: et
219
225
  }
220
226
  );
221
- return t ? /* @__PURE__ */ e(Rt, { modifiers: [dt], onDragEnd: g, children: /* @__PURE__ */ e(
222
- Bt,
227
+ return t ? /* @__PURE__ */ e(Dt, { modifiers: [Nt], onDragEnd: ot, children: /* @__PURE__ */ e(
228
+ jt,
223
229
  {
224
- items: rt,
225
- strategy: Dt,
230
+ items: ct,
231
+ strategy: lt,
226
232
  children: o
227
233
  }
228
234
  ) }) : o;
229
235
  }, [
230
- tt,
231
- p,
232
- C,
233
- ot,
234
236
  nt,
237
+ C,
238
+ p,
239
+ rt,
240
+ et,
235
241
  h,
236
242
  t,
237
- rt,
238
- g
243
+ ct,
244
+ ot
239
245
  ]);
240
246
  return /* @__PURE__ */ L("div", { children: [
241
247
  (typeof c == "boolean" || typeof c == "string") && /* @__PURE__ */ e(
242
- lt,
248
+ Bt,
243
249
  {
244
250
  width: "100%",
245
251
  open: !!m,
246
- title: St ?? /* @__PURE__ */ e("div", { children: " " }),
247
- footer: /* @__PURE__ */ e(et, {}),
252
+ title: It ?? /* @__PURE__ */ e("div", { children: " " }),
253
+ footer: /* @__PURE__ */ e(st, {}),
248
254
  closable: !0,
249
- onCancel: () => d(void 0),
255
+ onCancel: () => D(void 0),
250
256
  children: !!m && /* @__PURE__ */ L("div", { children: [
251
257
  /* @__PURE__ */ e(
252
- At,
258
+ $t,
253
259
  {
254
- layout: yt,
255
- descListColumn: ht,
260
+ layout: pt,
261
+ descListColumn: Ct,
256
262
  data: m,
257
263
  fields: y,
258
264
  idField: n,
259
- extraAction: N,
260
- onUpdate: D,
261
- onClickUpdate: j,
262
- onClickClone: _,
265
+ extraAction: j,
266
+ onUpdate: d,
267
+ onClickUpdate: l,
268
+ onClickClone: q,
263
269
  onDelete: I,
264
- onHide: B,
265
- onExport: X,
266
- isHiding: O,
267
- isDeleting: R,
268
- confirmHiding: Y,
269
- confirmDeleting: Z,
270
- closeViewOnClickUpdate: Q,
271
- recentUpdateOrDeleteId: F,
272
- setRecentUpdateOrDeleteId: a,
273
- setOpenView: d
270
+ deletable: B,
271
+ updatable: M,
272
+ onHide: _,
273
+ onExport: Z,
274
+ isHiding: N,
275
+ isDeleting: O,
276
+ confirmHiding: W,
277
+ confirmDeleting: P,
278
+ closeViewOnClickUpdate: Y,
279
+ recentUpdateOrDeleteId: b,
280
+ setRecentUpdateOrDeleteId: g,
281
+ setOpenView: D
274
282
  }
275
283
  ),
276
- V == null ? void 0 : V(m)
284
+ k == null ? void 0 : k(m)
277
285
  ] }, m == null ? void 0 : m[n])
278
286
  }
279
287
  ),
280
- /* @__PURE__ */ e(vt, { fields: y, ...pt }),
281
- /* @__PURE__ */ L($t, { children: [
282
- !!K && /* @__PURE__ */ e(Et, { onClick: K }),
283
- xt()
288
+ /* @__PURE__ */ e(_t, { fields: y, ...St }),
289
+ /* @__PURE__ */ L(Gt, { children: [
290
+ !!X && /* @__PURE__ */ e(Mt, { onClick: X }),
291
+ Tt()
284
292
  ] })
285
293
  ] });
286
294
  }
287
- const it = ft.createContext({}), Gt = ({ tooltip: h }) => {
288
- const { setActivatorNodeRef: n, listeners: C } = kt(it);
295
+ const yt = ht.createContext({}), Kt = ({ tooltip: h }) => {
296
+ const { setActivatorNodeRef: n, listeners: p } = vt(yt);
289
297
  return /* @__PURE__ */ e(
290
- jt,
298
+ Lt,
291
299
  {
292
300
  type: "text",
293
301
  size: "small",
294
302
  tooltip: h,
295
- icon: /* @__PURE__ */ e(_t, {}),
303
+ icon: /* @__PURE__ */ e(qt, {}),
296
304
  style: { cursor: "move", border: "none" },
297
305
  ref: n,
298
- ...C
306
+ ...p
299
307
  }
300
308
  );
301
- }, Jt = (h) => {
309
+ }, Qt = (h) => {
302
310
  const {
303
311
  attributes: n,
304
- listeners: C,
312
+ listeners: p,
305
313
  setNodeRef: y,
306
- setActivatorNodeRef: R,
307
- transform: O,
314
+ setActivatorNodeRef: O,
315
+ transform: N,
308
316
  transition: c,
309
317
  isDragging: u
310
- } = Nt({ id: h["data-row-key"] }), I = {
318
+ } = Et({ id: h["data-row-key"] }), I = {
311
319
  ...h.style,
312
- transform: Ot.Translate.toString(O),
320
+ transform: dt.Translate.toString(N),
313
321
  transition: c,
314
322
  ...u ? { position: "relative", zIndex: 9999 } : {}
315
323
  }, B = x(
316
- () => ({ setActivatorNodeRef: R, listeners: C }),
317
- [R, C]
324
+ () => ({ setActivatorNodeRef: O, listeners: p }),
325
+ [O, p]
318
326
  );
319
- return /* @__PURE__ */ e(it.Provider, { value: B, children: /* @__PURE__ */ e("tr", { ...h, ref: y, style: I, ...n }) });
327
+ return /* @__PURE__ */ e(yt.Provider, { value: B, children: /* @__PURE__ */ e("tr", { ...h, ref: y, style: I, ...n }) });
320
328
  };
321
329
  export {
322
- so as default
330
+ uo as default
323
331
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kingteza/crud-component",
3
3
  "private": false,
4
- "version": "1.27.2",
4
+ "version": "1.29.0",
5
5
  "description": "React CRUD component library with Ant Design",
6
6
  "keywords": [
7
7
  "react",