@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"),T=require("./modal/index.cjs.js"),X=require("./import/CrudImportButton.cjs.js"),Y=require("./view/CrudViewer.cjs.js"),Z=require("../common/button/NewButton.cjs.js"),$=require("../common/button/PrintButton.cjs.js");function p({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,...H}){const a=n.useRef(null),J=n.useCallback(()=>{var s;(s=a.current)==null||s.create()},[]),o=n.useCallback(async(s,C=!0,Q=!1)=>{var f;await((f=a.current)==null?void 0:f.update(s,C,Q))},[]),K=n.useCallback(async s=>{o(s,!1,!0)},[o]),{onClick:U,...m}=n.useMemo(()=>c||{},[c]),u=n.useMemo(()=>e.jsx(Z.NewButton,{onClick:(s,C)=>{l?l():c!=null&&c.onClick?c.onClick(C):J()},className:"flex-1",...m}),[l,c,m]),L=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:L()}),e.jsxs(q.Space,{children:[!!k&&e.jsx($.PrintButton,{className:"float-right",loading:I,onClick:k}),!!j&&e.jsx(X,{fields:r,importProps:j})]})]}),e.jsx(Y,{...H,minusHeight:w,scroll:z,data:b,size:G,fields:r,extraAction:_,idField:x,isDeleting:B,loadingData:V,onClickUpdate:d||(t?o:void 0),onHide:v,isHiding:R,onDelete:N,onUpdate:t,onClickClone:A?K:void 0,paginateProps:S,viewable:O,extraView:F})]}),e.jsx(T,{ref:a,fields:r,wizard:E,grid:g,fullWidthModal:D,isCreating:y,isUpdating:M,onCreate:h,onUpdate:t,idField:x,formBuilder:W})]})}module.exports=p;
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 e, jsxs as l, Fragment as Y } from "react/jsx-runtime";
2
- import { Space as x } from "antd";
3
- import { useRef as Z, useCallback as c, useMemo as N } from "react";
4
- import $ from "./modal/index.es.js";
5
- import w from "./import/CrudImportButton.es.js";
6
- import U from "./view/CrudViewer.es.js";
7
- import { NewButton as P } from "../common/button/NewButton.es.js";
8
- import { PrintButton as oo } from "../common/button/PrintButton.es.js";
9
- function so({
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: n,
38
- newButtonProps: o,
37
+ onClickNew: a,
38
+ newButtonProps: e,
39
39
  size: J,
40
- headerRender: a,
41
- ...K
40
+ headerRender: n,
41
+ actionWidth: K,
42
+ ...L
42
43
  }) {
43
- const m = Z(null), L = c(() => {
44
- var r;
45
- (r = m.current) == null || r.create();
44
+ const m = $(null), Q = c(() => {
45
+ var o;
46
+ (o = m.current) == null || o.create();
46
47
  }, []), s = c(
47
- async (r, u = !0, X = !1) => {
48
- var v;
49
- await ((v = m.current) == null ? void 0 : v.update(r, u, X));
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
- ), Q = c(
53
- async (r) => {
54
- s(r, !1, !0);
53
+ ), T = c(
54
+ async (o) => {
55
+ s(o, !1, !0);
55
56
  },
56
57
  [s]
57
- ), { onClick: ro, ...p } = N(() => o || {}, [o]), f = N(
58
- () => /* @__PURE__ */ e(
59
- P,
58
+ ), { onClick: re, ...p } = v(() => e || {}, [e]), f = v(
59
+ () => /* @__PURE__ */ r(
60
+ ee,
60
61
  {
61
- onClick: (r, u) => {
62
- n ? n() : o != null && o.onClick ? o.onClick(u) : L();
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
- [n, o, p]
69
- ), T = c(() => a ? a({ newButton: f }) : f, [f, a]);
70
- return /* @__PURE__ */ l(Y, { children: [
71
- /* @__PURE__ */ l(x, { direction: "vertical", className: "w-100", children: [
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__ */ e("div", { children: T() }),
74
- /* @__PURE__ */ l(x, { children: [
75
- !!k && /* @__PURE__ */ e(
76
- oo,
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__ */ e(w, { fields: t, importProps: h })
84
+ !!h && /* @__PURE__ */ r(U, { fields: t, importProps: h })
84
85
  ] })
85
86
  ] }),
86
- /* @__PURE__ */ e(
87
- U,
87
+ /* @__PURE__ */ r(
88
+ P,
88
89
  {
89
- ...K,
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 ? Q : void 0,
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__ */ e(
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
- so as default
132
+ fe as default
131
133
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kingteza/crud-component",
3
3
  "private": false,
4
- "version": "1.20.0",
4
+ "version": "1.21.1",
5
5
  "description": "React CRUD component library with Ant Design",
6
6
  "keywords": [
7
7
  "react",