@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"),
|
|
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>[
|
|
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 {
|
|
2
|
-
import { Space as
|
|
3
|
-
import { useRef as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { NewButton as
|
|
8
|
-
import { PrintButton as
|
|
9
|
-
function
|
|
10
|
-
idField:
|
|
11
|
-
onCreate:
|
|
12
|
-
onDelete:
|
|
13
|
-
onHide:
|
|
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:
|
|
16
|
-
fields:
|
|
17
|
-
data:
|
|
18
|
-
grid:
|
|
19
|
-
isHiding:
|
|
20
|
-
isCreating:
|
|
21
|
-
isDeleting:
|
|
22
|
-
isUpdating:
|
|
23
|
-
paginateProps:
|
|
24
|
-
onPrint:
|
|
25
|
-
printing:
|
|
26
|
-
viewable:
|
|
27
|
-
loadingData:
|
|
28
|
-
formBuilder:
|
|
29
|
-
extraAction:
|
|
30
|
-
minusHeight:
|
|
31
|
-
cloneable:
|
|
32
|
-
fullWidthModal:
|
|
33
|
-
wizard:
|
|
34
|
-
extraView:
|
|
35
|
-
importable:
|
|
36
|
-
onClickNew:
|
|
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:
|
|
39
|
-
|
|
38
|
+
size: H,
|
|
39
|
+
headerRender: a,
|
|
40
|
+
...J
|
|
40
41
|
}) {
|
|
41
|
-
const
|
|
42
|
-
var
|
|
43
|
-
(
|
|
44
|
-
}, []),
|
|
45
|
-
async (
|
|
46
|
-
var
|
|
47
|
-
await ((
|
|
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
|
-
),
|
|
51
|
-
async (
|
|
52
|
-
|
|
51
|
+
), L = c(
|
|
52
|
+
async (r) => {
|
|
53
|
+
s(r, !1, !0);
|
|
53
54
|
},
|
|
54
|
-
[
|
|
55
|
-
), { onClick:
|
|
56
|
-
|
|
57
|
-
|
|
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__ */
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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:
|
|
75
|
-
onClick:
|
|
78
|
+
loading: _,
|
|
79
|
+
onClick: k
|
|
76
80
|
}
|
|
77
81
|
),
|
|
78
|
-
!!
|
|
82
|
+
!!h && /* @__PURE__ */ e($, { fields: t, importProps: h })
|
|
79
83
|
] })
|
|
80
84
|
] }),
|
|
81
|
-
/* @__PURE__ */
|
|
82
|
-
|
|
85
|
+
/* @__PURE__ */ e(
|
|
86
|
+
w,
|
|
83
87
|
{
|
|
84
|
-
...
|
|
85
|
-
minusHeight:
|
|
86
|
-
data:
|
|
87
|
-
size:
|
|
88
|
-
fields:
|
|
89
|
-
extraAction:
|
|
90
|
-
idField:
|
|
91
|
-
isDeleting:
|
|
92
|
-
loadingData:
|
|
93
|
-
onClickUpdate:
|
|
94
|
-
onHide:
|
|
95
|
-
isHiding:
|
|
96
|
-
onDelete:
|
|
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:
|
|
99
|
-
paginateProps:
|
|
100
|
-
viewable:
|
|
101
|
-
extraView:
|
|
102
|
+
onClickClone: D ? L : void 0,
|
|
103
|
+
paginateProps: W,
|
|
104
|
+
viewable: b,
|
|
105
|
+
extraView: G
|
|
102
106
|
}
|
|
103
107
|
)
|
|
104
108
|
] }),
|
|
105
|
-
/* @__PURE__ */
|
|
106
|
-
|
|
109
|
+
/* @__PURE__ */ e(
|
|
110
|
+
Z,
|
|
107
111
|
{
|
|
108
|
-
ref:
|
|
109
|
-
fields:
|
|
110
|
-
wizard:
|
|
111
|
-
grid:
|
|
112
|
-
fullWidthModal:
|
|
113
|
-
isCreating:
|
|
114
|
-
isUpdating:
|
|
115
|
-
onCreate:
|
|
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:
|
|
118
|
-
formBuilder:
|
|
121
|
+
idField: C,
|
|
122
|
+
formBuilder: z
|
|
119
123
|
}
|
|
120
124
|
)
|
|
121
125
|
] });
|
|
122
126
|
}
|
|
123
127
|
export {
|
|
124
|
-
|
|
128
|
+
mo as default
|
|
125
129
|
};
|