@kingteza/crud-component 1.20.0 → 1.21.1
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"),q=require("antd"),n=require("react"),
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),q=require("antd"),n=require("react"),X=require("./modal/index.cjs.js"),Y=require("./import/CrudImportButton.cjs.js"),Z=require("./view/CrudViewer.cjs.js"),$=require("../common/button/NewButton.cjs.js"),p=require("../common/button/PrintButton.cjs.js");function U({idField:x="id",onCreate:h,onDelete:N,onHide:v,onUpdate:t,onClickUpdate:d,fields:l,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,scroll:z,cloneable:A,fullWidthModal:D=!0,wizard:E,extraView:F,importable:m,onClickNew:r,newButtonProps:c,size:G,headerRender:i,actionWidth:H,...J}){const a=n.useRef(null),K=n.useCallback(()=>{var s;(s=a.current)==null||s.create()},[]),o=n.useCallback(async(s,C=!0,T=!1)=>{var j;await((j=a.current)==null?void 0:j.update(s,C,T))},[]),L=n.useCallback(async s=>{o(s,!1,!0)},[o]),{onClick:P,...f}=n.useMemo(()=>c||{},[c]),u=n.useMemo(()=>e.jsx($.NewButton,{onClick:(s,C)=>{r?r():c!=null&&c.onClick?c.onClick(C):K()},className:"flex-1",...f}),[r,c,f]),Q=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",{className:"flex-1",children:Q()}),e.jsxs(q.Space,{children:[!!k&&e.jsx(p.PrintButton,{className:"float-right",loading:I,onClick:k}),!!m&&e.jsx(Y,{fields:l,importProps:m})]})]}),e.jsx(Z,{...J,minusHeight:w,scroll:z,data:b,size:G,fields:l,extraAction:_,actionWidth:H,idField:x,isDeleting:B,loadingData:V,onClickUpdate:d||(t?o:void 0),onHide:v,isHiding:R,onDelete:N,onUpdate:t,onClickClone:A?L:void 0,paginateProps:S,viewable:O,extraView:F})]}),e.jsx(X,{ref:a,fields:l,wizard:E,grid:g,fullWidthModal:D,isCreating:y,isUpdating:M,onCreate:h,onUpdate:t,idField:x,formBuilder:W})]})}module.exports=U;
|
|
@@ -263,6 +263,7 @@ export type CrudComponentProps<T, FormType = T> = {
|
|
|
263
263
|
fullWidthModal?: boolean;
|
|
264
264
|
wizard?: CrudWizardProp<T>[];
|
|
265
265
|
extraView?: (t: T) => React.ReactElement;
|
|
266
|
+
actionWidth?: string | number | undefined;
|
|
266
267
|
importable?: CrudImportProps<T>;
|
|
267
268
|
/**
|
|
268
269
|
* @deprecated Use {@link CrudComponentProps.newButtonProps?.onClick} instead.
|
|
@@ -275,5 +276,5 @@ export type CrudComponentProps<T, FormType = T> = {
|
|
|
275
276
|
newButton: JSX.Element;
|
|
276
277
|
}) => React.ReactElement;
|
|
277
278
|
} & CrudSearchComponentProps<T, FormType>;
|
|
278
|
-
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, scroll, cloneable, fullWidthModal, wizard, extraView, importable, onClickNew, newButtonProps, size, headerRender, ...props }: CrudComponentProps<T, FormType>): import("react/jsx-runtime").JSX.Element;
|
|
279
|
+
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, scroll, cloneable, fullWidthModal, wizard, extraView, importable, onClickNew, newButtonProps, size, headerRender, actionWidth, ...props }: CrudComponentProps<T, FormType>): import("react/jsx-runtime").JSX.Element;
|
|
279
280
|
export default CrudComponent;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { Space as
|
|
3
|
-
import { useRef as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { NewButton as
|
|
8
|
-
import { PrintButton as
|
|
9
|
-
function
|
|
1
|
+
import { jsx as r, jsxs as l, Fragment as Z } from "react/jsx-runtime";
|
|
2
|
+
import { Space as N } from "antd";
|
|
3
|
+
import { useRef as $, useCallback as c, useMemo as v } from "react";
|
|
4
|
+
import w from "./modal/index.es.js";
|
|
5
|
+
import U from "./import/CrudImportButton.es.js";
|
|
6
|
+
import P from "./view/CrudViewer.es.js";
|
|
7
|
+
import { NewButton as ee } from "../common/button/NewButton.es.js";
|
|
8
|
+
import { PrintButton as oe } from "../common/button/PrintButton.es.js";
|
|
9
|
+
function fe({
|
|
10
10
|
idField: C = "id",
|
|
11
11
|
onCreate: g,
|
|
12
12
|
onDelete: j,
|
|
@@ -34,65 +34,67 @@ function so({
|
|
|
34
34
|
wizard: G,
|
|
35
35
|
extraView: H,
|
|
36
36
|
importable: h,
|
|
37
|
-
onClickNew:
|
|
38
|
-
newButtonProps:
|
|
37
|
+
onClickNew: a,
|
|
38
|
+
newButtonProps: e,
|
|
39
39
|
size: J,
|
|
40
|
-
headerRender:
|
|
41
|
-
|
|
40
|
+
headerRender: n,
|
|
41
|
+
actionWidth: K,
|
|
42
|
+
...L
|
|
42
43
|
}) {
|
|
43
|
-
const m =
|
|
44
|
-
var
|
|
45
|
-
(
|
|
44
|
+
const m = $(null), Q = c(() => {
|
|
45
|
+
var o;
|
|
46
|
+
(o = m.current) == null || o.create();
|
|
46
47
|
}, []), s = c(
|
|
47
|
-
async (
|
|
48
|
-
var
|
|
49
|
-
await ((
|
|
48
|
+
async (o, u = !0, Y = !1) => {
|
|
49
|
+
var x;
|
|
50
|
+
await ((x = m.current) == null ? void 0 : x.update(o, u, Y));
|
|
50
51
|
},
|
|
51
52
|
[]
|
|
52
|
-
),
|
|
53
|
-
async (
|
|
54
|
-
s(
|
|
53
|
+
), T = c(
|
|
54
|
+
async (o) => {
|
|
55
|
+
s(o, !1, !0);
|
|
55
56
|
},
|
|
56
57
|
[s]
|
|
57
|
-
), { onClick:
|
|
58
|
-
() => /* @__PURE__ */
|
|
59
|
-
|
|
58
|
+
), { onClick: re, ...p } = v(() => e || {}, [e]), f = v(
|
|
59
|
+
() => /* @__PURE__ */ r(
|
|
60
|
+
ee,
|
|
60
61
|
{
|
|
61
|
-
onClick: (
|
|
62
|
-
|
|
62
|
+
onClick: (o, u) => {
|
|
63
|
+
a ? a() : e != null && e.onClick ? e.onClick(u) : Q();
|
|
63
64
|
},
|
|
64
65
|
className: "flex-1",
|
|
65
66
|
...p
|
|
66
67
|
}
|
|
67
68
|
),
|
|
68
|
-
[
|
|
69
|
-
),
|
|
70
|
-
return /* @__PURE__ */ l(
|
|
71
|
-
/* @__PURE__ */ l(
|
|
69
|
+
[a, e, p]
|
|
70
|
+
), X = c(() => n ? n({ newButton: f }) : f, [f, n]);
|
|
71
|
+
return /* @__PURE__ */ l(Z, { children: [
|
|
72
|
+
/* @__PURE__ */ l(N, { direction: "vertical", className: "w-100", children: [
|
|
72
73
|
/* @__PURE__ */ l("div", { className: "w-100 d-flex", children: [
|
|
73
|
-
/* @__PURE__ */
|
|
74
|
-
/* @__PURE__ */ l(
|
|
75
|
-
!!k && /* @__PURE__ */
|
|
76
|
-
|
|
74
|
+
/* @__PURE__ */ r("div", { className: "flex-1", children: X() }),
|
|
75
|
+
/* @__PURE__ */ l(N, { children: [
|
|
76
|
+
!!k && /* @__PURE__ */ r(
|
|
77
|
+
oe,
|
|
77
78
|
{
|
|
78
79
|
className: "float-right",
|
|
79
80
|
loading: _,
|
|
80
81
|
onClick: k
|
|
81
82
|
}
|
|
82
83
|
),
|
|
83
|
-
!!h && /* @__PURE__ */
|
|
84
|
+
!!h && /* @__PURE__ */ r(U, { fields: t, importProps: h })
|
|
84
85
|
] })
|
|
85
86
|
] }),
|
|
86
|
-
/* @__PURE__ */
|
|
87
|
-
|
|
87
|
+
/* @__PURE__ */ r(
|
|
88
|
+
P,
|
|
88
89
|
{
|
|
89
|
-
...
|
|
90
|
+
...L,
|
|
90
91
|
minusHeight: B,
|
|
91
92
|
scroll: D,
|
|
92
93
|
data: M,
|
|
93
94
|
size: J,
|
|
94
95
|
fields: t,
|
|
95
96
|
extraAction: A,
|
|
97
|
+
actionWidth: K,
|
|
96
98
|
idField: C,
|
|
97
99
|
isDeleting: S,
|
|
98
100
|
loadingData: q,
|
|
@@ -101,15 +103,15 @@ function so({
|
|
|
101
103
|
isHiding: O,
|
|
102
104
|
onDelete: j,
|
|
103
105
|
onUpdate: i,
|
|
104
|
-
onClickClone: E ?
|
|
106
|
+
onClickClone: E ? T : void 0,
|
|
105
107
|
paginateProps: W,
|
|
106
108
|
viewable: b,
|
|
107
109
|
extraView: H
|
|
108
110
|
}
|
|
109
111
|
)
|
|
110
112
|
] }),
|
|
111
|
-
/* @__PURE__ */
|
|
112
|
-
|
|
113
|
+
/* @__PURE__ */ r(
|
|
114
|
+
w,
|
|
113
115
|
{
|
|
114
116
|
ref: m,
|
|
115
117
|
fields: t,
|
|
@@ -127,5 +129,5 @@ function so({
|
|
|
127
129
|
] });
|
|
128
130
|
}
|
|
129
131
|
export {
|
|
130
|
-
|
|
132
|
+
fe as default
|
|
131
133
|
};
|