@kingteza/crud-component 1.15.2 → 1.16.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 +1 @@
1
- "use strict";const e=require("react/jsx-runtime"),j=require("antd"),n=require("react"),H=require("./modal/index.cjs.js"),J=require("./import/CrudImportButton.cjs.js"),K=require("./view/CrudViewer.cjs.js"),L=require("../common/button/NewButton.cjs.js"),Q=require("../common/button/PrintButton.cjs.js");function T({idField:o="id",onCreate:f,onDelete:m,onHide:h,onUpdate:l,onClickUpdate:u,fields:r,data:q,grid:N,isHiding:v,isCreating:R,isDeleting:g,isUpdating:y,paginateProps:b,onPrint:C,printing:B,viewable:S,loadingData:w,formBuilder:I,extraAction:M,minusHeight:O,cloneable:V,fullWidthModal:W=!0,wizard:_,extraView:p,importable:d,onClickNew:x,newButtonProps:s,size:z,...A}){const t=n.useRef(null),D=n.useCallback(()=>{var c;(c=t.current)==null||c.create()},[]),i=n.useCallback(async(c,a=!0,G=!1)=>{var k;await((k=t.current)==null?void 0:k.update(c,a,G))},[]),E=n.useCallback(async c=>{i(c,!1,!0)},[i]),{onClick:X,...F}=n.useMemo(()=>s||{},[s]);return e.jsxs(e.Fragment,{children:[e.jsxs(j.Space,{direction:"vertical",className:"w-100",children:[e.jsxs("div",{className:"w-100 d-flex",children:[e.jsx("div",{style:{flex:1},children:e.jsx(L.NewButton,{onClick:(c,a)=>{x?x():s!=null&&s.onClick?s.onClick(a):D()},className:"flex-1",...F})}),e.jsxs(j.Space,{children:[!!C&&e.jsx(Q.PrintButton,{className:"float-right",loading:B,onClick:C}),!!d&&e.jsx(J,{fields:r,importProps:d})]})]}),e.jsx(K,{...A,minusHeight:O,data:q,size:z,fields:r,extraAction:M,idField:o,isDeleting:g,loadingData:w,onClickUpdate:u||(l?i:void 0),onHide:h,isHiding:v,onDelete:m,onUpdate:l,onClickClone:V?E:void 0,paginateProps:b,viewable:S,extraView:p})]}),e.jsx(H,{ref:t,fields:r,wizard:_,grid:N,fullWidthModal:W,isCreating:R,isUpdating:y,onCreate:f,onUpdate:l,idField:o,formBuilder:I})]})}module.exports=T;
1
+ "use strict";const e=require("react/jsx-runtime"),q=require("antd"),n=require("react"),Q=require("./modal/index.cjs.js"),T=require("./import/CrudImportButton.cjs.js"),X=require("./view/CrudViewer.cjs.js"),Y=require("../common/button/NewButton.cjs.js"),Z=require("../common/button/PrintButton.cjs.js");function $({idField:x="id",onCreate:h,onDelete:N,onHide:v,onUpdate:t,onClickUpdate:d,fields:r,data:b,grid:g,isHiding:R,isCreating:y,isDeleting:B,isUpdating:M,paginateProps:S,onPrint:k,printing:I,viewable:O,loadingData:V,formBuilder:W,extraAction:_,minusHeight:w,cloneable:z,fullWidthModal:A=!0,wizard:D,extraView:E,importable:j,onClickNew:l,newButtonProps:c,size:F,headerRender:i,...G}){const a=n.useRef(null),H=n.useCallback(()=>{var s;(s=a.current)==null||s.create()},[]),o=n.useCallback(async(s,C=!0,L=!1)=>{var f;await((f=a.current)==null?void 0:f.update(s,C,L))},[]),J=n.useCallback(async s=>{o(s,!1,!0)},[o]),{onClick:p,...m}=n.useMemo(()=>c||{},[c]),u=n.useMemo(()=>e.jsx(Y.NewButton,{onClick:(s,C)=>{l?l():c!=null&&c.onClick?c.onClick(C):H()},className:"flex-1",...m}),[l,c,m]),K=n.useCallback(()=>i?i({newButton:u}):u,[u,i]);return e.jsxs(e.Fragment,{children:[e.jsxs(q.Space,{direction:"vertical",className:"w-100",children:[e.jsxs("div",{className:"w-100 d-flex",children:[e.jsx("div",{children:K()}),e.jsxs(q.Space,{children:[!!k&&e.jsx(Z.PrintButton,{className:"float-right",loading:I,onClick:k}),!!j&&e.jsx(T,{fields:r,importProps:j})]})]}),e.jsx(X,{...G,minusHeight:w,data:b,size:F,fields:r,extraAction:_,idField:x,isDeleting:B,loadingData:V,onClickUpdate:d||(t?o:void 0),onHide:v,isHiding:R,onDelete:N,onUpdate:t,onClickClone:z?J:void 0,paginateProps:S,viewable:O,extraView:E})]}),e.jsx(Q,{ref:a,fields:r,wizard:D,grid:g,fullWidthModal:A,isCreating:y,isUpdating:M,onCreate:h,onUpdate:t,idField:x,formBuilder:W})]})}module.exports=$;
@@ -54,7 +54,7 @@ export interface InitialCrudField<T> {
54
54
  hidden?: boolean;
55
55
  };
56
56
  hideLabel?: boolean;
57
- sorter?: ColumnType<T>['sorter'];
57
+ sorter?: ColumnType<T>["sorter"];
58
58
  }
59
59
  export type CrudFieldGrid = {
60
60
  xs?: number;
@@ -269,6 +269,9 @@ export type CrudComponentProps<T, FormType = T> = {
269
269
  newButtonProps?: ButtonProps;
270
270
  draggable?: CrudDragableProps<T>;
271
271
  size?: SizeType;
272
+ headerRender?: (props: {
273
+ newButton: JSX.Element;
274
+ }) => React.ReactElement;
272
275
  } & CrudSearchComponentProps<T, FormType>;
273
- declare function CrudComponent<T, FormType = T>({ idField, onCreate, onDelete, onHide, onUpdate, onClickUpdate, fields, data, grid, isHiding, isCreating, isDeleting, isUpdating, paginateProps, onPrint, printing, viewable, loadingData, formBuilder, extraAction, minusHeight, cloneable, fullWidthModal, wizard, extraView, importable, onClickNew, newButtonProps, size, ...props }: CrudComponentProps<T, FormType>): import("react/jsx-runtime").JSX.Element;
276
+ declare function CrudComponent<T, FormType = T>({ idField, onCreate, onDelete, onHide, onUpdate, onClickUpdate, fields, data, grid, isHiding, isCreating, isDeleting, isUpdating, paginateProps, onPrint, printing, viewable, loadingData, formBuilder, extraAction, minusHeight, cloneable, fullWidthModal, wizard, extraView, importable, onClickNew, newButtonProps, size, headerRender, ...props }: CrudComponentProps<T, FormType>): import("react/jsx-runtime").JSX.Element;
274
277
  export default CrudComponent;
@@ -1,125 +1,129 @@
1
- import { jsxs as l, Fragment as J, jsx as r } from "react/jsx-runtime";
2
- import { Space as h } from "antd";
3
- import { useRef as K, useCallback as m, useMemo as L } from "react";
4
- import Q from "./modal/index.es.js";
5
- import T from "./import/CrudImportButton.es.js";
6
- import X from "./view/CrudViewer.es.js";
7
- import { NewButton as Y } from "../common/button/NewButton.es.js";
8
- import { PrintButton as Z } from "../common/button/PrintButton.es.js";
9
- function te({
10
- idField: s = "id",
11
- onCreate: p,
12
- onDelete: x,
13
- onHide: N,
1
+ import { jsx as e, jsxs as l, Fragment as X } from "react/jsx-runtime";
2
+ import { Space as x } from "antd";
3
+ import { useRef as Y, useCallback as c, useMemo as N } from "react";
4
+ import Z from "./modal/index.es.js";
5
+ import $ from "./import/CrudImportButton.es.js";
6
+ import w from "./view/CrudViewer.es.js";
7
+ import { NewButton as U } from "../common/button/NewButton.es.js";
8
+ import { PrintButton as P } from "../common/button/PrintButton.es.js";
9
+ function mo({
10
+ idField: C = "id",
11
+ onCreate: g,
12
+ onDelete: j,
13
+ onHide: y,
14
14
  onUpdate: i,
15
- onClickUpdate: f,
16
- fields: c,
17
- data: v,
18
- grid: g,
19
- isHiding: y,
20
- isCreating: j,
21
- isDeleting: M,
22
- isUpdating: R,
23
- paginateProps: I,
24
- onPrint: d,
25
- printing: O,
26
- viewable: S,
27
- loadingData: V,
28
- formBuilder: W,
29
- extraAction: _,
30
- minusHeight: b,
31
- cloneable: q,
32
- fullWidthModal: w = !0,
33
- wizard: z,
34
- extraView: A,
35
- importable: C,
36
- onClickNew: u,
15
+ onClickUpdate: d,
16
+ fields: t,
17
+ data: M,
18
+ grid: I,
19
+ isHiding: O,
20
+ isCreating: R,
21
+ isDeleting: S,
22
+ isUpdating: V,
23
+ paginateProps: W,
24
+ onPrint: k,
25
+ printing: _,
26
+ viewable: b,
27
+ loadingData: q,
28
+ formBuilder: z,
29
+ extraAction: A,
30
+ minusHeight: B,
31
+ cloneable: D,
32
+ fullWidthModal: E = !0,
33
+ wizard: F,
34
+ extraView: G,
35
+ importable: h,
36
+ onClickNew: n,
37
37
  newButtonProps: o,
38
- size: B,
39
- ...D
38
+ size: H,
39
+ headerRender: a,
40
+ ...J
40
41
  }) {
41
- const t = K(null), E = m(() => {
42
- var e;
43
- (e = t.current) == null || e.create();
44
- }, []), a = m(
45
- async (e, n = !0, H = !1) => {
46
- var k;
47
- await ((k = t.current) == null ? void 0 : k.update(e, n, H));
42
+ const m = Y(null), K = c(() => {
43
+ var r;
44
+ (r = m.current) == null || r.create();
45
+ }, []), s = c(
46
+ async (r, u = !0, T = !1) => {
47
+ var v;
48
+ await ((v = m.current) == null ? void 0 : v.update(r, u, T));
48
49
  },
49
50
  []
50
- ), F = m(
51
- async (e) => {
52
- a(e, !1, !0);
51
+ ), L = c(
52
+ async (r) => {
53
+ s(r, !1, !0);
53
54
  },
54
- [a]
55
- ), { onClick: $, ...G } = L(() => o || {}, [o]);
56
- return /* @__PURE__ */ l(J, { children: [
57
- /* @__PURE__ */ l(h, { direction: "vertical", className: "w-100", children: [
55
+ [s]
56
+ ), { onClick: oo, ...p } = N(() => o || {}, [o]), f = N(
57
+ () => /* @__PURE__ */ e(
58
+ U,
59
+ {
60
+ onClick: (r, u) => {
61
+ n ? n() : o != null && o.onClick ? o.onClick(u) : K();
62
+ },
63
+ className: "flex-1",
64
+ ...p
65
+ }
66
+ ),
67
+ [n, o, p]
68
+ ), Q = c(() => a ? a({ newButton: f }) : f, [f, a]);
69
+ return /* @__PURE__ */ l(X, { children: [
70
+ /* @__PURE__ */ l(x, { direction: "vertical", className: "w-100", children: [
58
71
  /* @__PURE__ */ l("div", { className: "w-100 d-flex", children: [
59
- /* @__PURE__ */ r("div", { style: { flex: 1 }, children: /* @__PURE__ */ r(
60
- Y,
61
- {
62
- onClick: (e, n) => {
63
- u ? u() : o != null && o.onClick ? o.onClick(n) : E();
64
- },
65
- className: "flex-1",
66
- ...G
67
- }
68
- ) }),
69
- /* @__PURE__ */ l(h, { children: [
70
- !!d && /* @__PURE__ */ r(
71
- Z,
72
+ /* @__PURE__ */ e("div", { children: Q() }),
73
+ /* @__PURE__ */ l(x, { children: [
74
+ !!k && /* @__PURE__ */ e(
75
+ P,
72
76
  {
73
77
  className: "float-right",
74
- loading: O,
75
- onClick: d
78
+ loading: _,
79
+ onClick: k
76
80
  }
77
81
  ),
78
- !!C && /* @__PURE__ */ r(T, { fields: c, importProps: C })
82
+ !!h && /* @__PURE__ */ e($, { fields: t, importProps: h })
79
83
  ] })
80
84
  ] }),
81
- /* @__PURE__ */ r(
82
- X,
85
+ /* @__PURE__ */ e(
86
+ w,
83
87
  {
84
- ...D,
85
- minusHeight: b,
86
- data: v,
87
- size: B,
88
- fields: c,
89
- extraAction: _,
90
- idField: s,
91
- isDeleting: M,
92
- loadingData: V,
93
- onClickUpdate: f || (i ? a : void 0),
94
- onHide: N,
95
- isHiding: y,
96
- onDelete: x,
88
+ ...J,
89
+ minusHeight: B,
90
+ data: M,
91
+ size: H,
92
+ fields: t,
93
+ extraAction: A,
94
+ idField: C,
95
+ isDeleting: S,
96
+ loadingData: q,
97
+ onClickUpdate: d || (i ? s : void 0),
98
+ onHide: y,
99
+ isHiding: O,
100
+ onDelete: j,
97
101
  onUpdate: i,
98
- onClickClone: q ? F : void 0,
99
- paginateProps: I,
100
- viewable: S,
101
- extraView: A
102
+ onClickClone: D ? L : void 0,
103
+ paginateProps: W,
104
+ viewable: b,
105
+ extraView: G
102
106
  }
103
107
  )
104
108
  ] }),
105
- /* @__PURE__ */ r(
106
- Q,
109
+ /* @__PURE__ */ e(
110
+ Z,
107
111
  {
108
- ref: t,
109
- fields: c,
110
- wizard: z,
111
- grid: g,
112
- fullWidthModal: w,
113
- isCreating: j,
114
- isUpdating: R,
115
- onCreate: p,
112
+ ref: m,
113
+ fields: t,
114
+ wizard: F,
115
+ grid: I,
116
+ fullWidthModal: E,
117
+ isCreating: R,
118
+ isUpdating: V,
119
+ onCreate: g,
116
120
  onUpdate: i,
117
- idField: s,
118
- formBuilder: W
121
+ idField: C,
122
+ formBuilder: z
119
123
  }
120
124
  )
121
125
  ] });
122
126
  }
123
127
  export {
124
- te as default
128
+ mo as default
125
129
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kingteza/crud-component",
3
3
  "private": false,
4
- "version": "1.15.2",
4
+ "version": "1.16.0",
5
5
  "description": "React CRUD component library with Ant Design",
6
6
  "keywords": [
7
7
  "react",