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