@kingteza/crud-component 1.27.2 → 1.29.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 v=require("react/jsx-runtime"),Y=require("react"),A=require("../../common/button/CloneButtonTable.cjs.js"),H=require("../../common/button/DeleteButtonTable.cjs.js"),V=require("../../common/button/ExportButton.cjs.js"),c=require("../../common/button/HideButtonTable.cjs.js"),k=require("../../common/button/UpdateButtonTable.cjs.js"),s=require("../modal/index.cjs.js");function r({data:b,idField:j="id",extraAction:h,onUpdate:G,onClickUpdate:m,onClickClone:y,onDelete:T,onHide:g,onExport:z,isHiding:J,isDeleting:K,confirmHiding:Z,confirmDeleting:_,closeViewOnClickUpdate:$,recentUpdateOrDeleteId:L,setRecentUpdateOrDeleteId:q,setOpenView:E,inBuiltModalProps:f}){var S;const x=h==null?void 0:h(b),N=Y.useRef(null),Q=Y.useCallback((u,w=!0,W=!1)=>{var X;q==null||q(u[j]),f?(X=N.current)==null||X.update(u,w,W):W?y==null||y(u):m==null||m(u),$&&(E==null||E(void 0))},[f,m]);return(Array.isArray(x)?(S=x==null?void 0:x.filter(Boolean))!=null&&S.length:x)||G||m||f!=null&&f.onUpdate||y||f!=null&&f.onCreate||T||z||g?v.jsxs(v.Fragment,{children:[f&&v.jsx(s,{ref:N,...f}),x,(G||m||(f==null?void 0:f.onUpdate))&&v.jsx(k,{value:b,onClick:u=>Q(u)}),(y||(f==null?void 0:f.onCreate))&&v.jsx(A,{value:b,onClick:u=>Q(u,!1,!0)}),z&&v.jsx(V.ExportButton,{value:b,onClick:async u=>await z(u)}),g&&v.jsx(c,{value:b,disabled:J,shouldConfirm:Z,loading:J&&b[j]===L,onClick:async u=>{q==null||q(u[j]),await g({[j]:u[j]})}}),T&&v.jsx(H,{value:b,disabled:K,shouldConfirm:_,loading:K&&b[j]===L,onClick:async u=>{q==null||q(u[j]),await T({[j]:u[j]})}})]}):void 0}module.exports=r;
1
+ "use strict";const v=require("react/jsx-runtime"),z=require("react"),b=require("../../common/button/CloneButtonTable.cjs.js"),r=require("../../common/button/DeleteButtonTable.cjs.js"),k=require("../../common/button/ExportButton.cjs.js"),C=require("../../common/button/HideButtonTable.cjs.js"),F=require("../../common/button/UpdateButtonTable.cjs.js"),R=require("../modal/index.cjs.js");function B({data:q,idField:u="id",extraAction:E,onUpdate:N,onClickUpdate:x,onClickClone:h,onDelete:G,onHide:J,onExport:K,isHiding:Q,isDeleting:S,confirmHiding:A,confirmDeleting:s,closeViewOnClickUpdate:H,recentUpdateOrDeleteId:W,setRecentUpdateOrDeleteId:m,setOpenView:L,inBuiltModalProps:f,updatable:T,deletable:g}){var $;const y=E==null?void 0:E(q),X=z.useRef(null),Y=z.useCallback((j,V=!0,c=!1)=>{var w;m==null||m(j[u]),f?(w=X.current)==null||w.update(j,V,c):c?h==null||h(j):x==null||x(j),H&&(L==null||L(void 0))},[f,x]),Z=z.useMemo(()=>!!(!T||T!=null&&T(q)),[T,q]),_=z.useMemo(()=>!!(!g||g!=null&&g(q)),[g,q]);return(Array.isArray(y)?($=y==null?void 0:y.filter(Boolean))!=null&&$.length:y)||N||Z&&x||f!=null&&f.onUpdate||h||f!=null&&f.onCreate||_&&G||K||J?v.jsxs(v.Fragment,{children:[f&&v.jsx(R,{ref:X,...f}),y,(N||x||(f==null?void 0:f.onUpdate))&&Z&&v.jsx(F,{value:q,onClick:j=>Y(j)}),(h||(f==null?void 0:f.onCreate))&&v.jsx(b,{value:q,onClick:j=>Y(j,!1,!0)}),K&&v.jsx(k.ExportButton,{value:q,onClick:async j=>await K(j)}),J&&v.jsx(C,{value:q,disabled:Q,shouldConfirm:A,loading:Q&&q[u]===W,onClick:async j=>{m==null||m(j[u]),await J({[u]:j[u]})}}),G&&_&&v.jsx(r,{value:q,disabled:S,shouldConfirm:s,loading:S&&q[u]===W,onClick:async j=>{m==null||m(j[u]),await G({[u]:j[u]})}})]}):void 0}module.exports=B;
@@ -8,6 +8,8 @@ export interface CrudActionsProps<T, FormType> {
8
8
  onClickUpdate?: (t: T) => void;
9
9
  onClickClone?: (t: T) => Promise<any>;
10
10
  onDelete?: (id: any) => Promise<any>;
11
+ updatable?: (t: T) => boolean;
12
+ deletable?: (t: T) => boolean;
11
13
  onHide?: (id: any) => Promise<any>;
12
14
  onExport?: (t: T) => Promise<any>;
13
15
  isHiding?: boolean;
@@ -20,7 +22,7 @@ export interface CrudActionsProps<T, FormType> {
20
22
  setOpenView?: (data: T | undefined) => void;
21
23
  inBuiltModalProps?: CrudModalProps<T, FormType>;
22
24
  }
23
- declare function CrudActions<T, FormType>({ data, idField, extraAction, onUpdate, onClickUpdate, onClickClone, onDelete, onHide, onExport, isHiding, isDeleting, confirmHiding, confirmDeleting, closeViewOnClickUpdate, recentUpdateOrDeleteId, setRecentUpdateOrDeleteId, setOpenView, inBuiltModalProps, }: CrudActionsProps<T, FormType> & {
25
+ declare function CrudActions<T, FormType>({ data, idField, extraAction, onUpdate, onClickUpdate, onClickClone, onDelete, onHide, onExport, isHiding, isDeleting, confirmHiding, confirmDeleting, closeViewOnClickUpdate, recentUpdateOrDeleteId, setRecentUpdateOrDeleteId, setOpenView, inBuiltModalProps, updatable, deletable, }: CrudActionsProps<T, FormType> & {
24
26
  data: T;
25
27
  }): import("react/jsx-runtime").JSX.Element | undefined;
26
28
  export default CrudActions;
@@ -1,83 +1,85 @@
1
- import { jsxs as E, Fragment as H, jsx as g } from "react/jsx-runtime";
2
- import { useRef as x, useCallback as V } from "react";
3
- import k from "../../common/button/CloneButtonTable.es.js";
4
- import C from "../../common/button/DeleteButtonTable.es.js";
5
- import { ExportButton as F } from "../../common/button/ExportButton.es.js";
6
- import r from "../../common/button/HideButtonTable.es.js";
7
- import R from "../../common/button/UpdateButtonTable.es.js";
8
- import c from "../modal/index.es.js";
9
- function a({
10
- data: y,
11
- idField: b = "id",
12
- extraAction: u,
13
- onUpdate: K,
14
- onClickUpdate: h,
15
- onClickClone: j,
16
- onDelete: q,
17
- onHide: z,
18
- onExport: G,
19
- isHiding: L,
20
- isDeleting: N,
21
- confirmHiding: _,
22
- confirmDeleting: $,
23
- closeViewOnClickUpdate: w,
24
- recentUpdateOrDeleteId: Q,
25
- setRecentUpdateOrDeleteId: v,
26
- setOpenView: J,
27
- inBuiltModalProps: f
1
+ import { jsxs as r, Fragment as C, jsx as j } from "react/jsx-runtime";
2
+ import { useRef as F, useCallback as c, useMemo as H } from "react";
3
+ import R from "../../common/button/CloneButtonTable.es.js";
4
+ import B from "../../common/button/DeleteButtonTable.es.js";
5
+ import { ExportButton as I } from "../../common/button/ExportButton.es.js";
6
+ import D from "../../common/button/HideButtonTable.es.js";
7
+ import U from "../../common/button/UpdateButtonTable.es.js";
8
+ import s from "../modal/index.es.js";
9
+ function l({
10
+ data: v,
11
+ idField: y = "id",
12
+ extraAction: J,
13
+ onUpdate: S,
14
+ onClickUpdate: T,
15
+ onClickClone: q,
16
+ onDelete: K,
17
+ onHide: L,
18
+ onExport: N,
19
+ isHiding: W,
20
+ isDeleting: X,
21
+ confirmHiding: x,
22
+ confirmDeleting: V,
23
+ closeViewOnClickUpdate: b,
24
+ recentUpdateOrDeleteId: Y,
25
+ setRecentUpdateOrDeleteId: h,
26
+ setOpenView: Q,
27
+ inBuiltModalProps: f,
28
+ updatable: z,
29
+ deletable: G
28
30
  }) {
29
- var X;
30
- const T = u == null ? void 0 : u(y), S = x(null), W = V(
31
- (m, A = !0, Y = !1) => {
32
- var Z;
33
- v == null || v(m[b]), f ? (Z = S.current) == null || Z.update(m, A, Y) : Y ? j == null || j(m) : h == null || h(m), w && (J == null || J(void 0));
31
+ var A;
32
+ const g = J == null ? void 0 : J(v), Z = F(null), _ = c(
33
+ (m, k = !0, E = !1) => {
34
+ var u;
35
+ h == null || h(m[y]), f ? (u = Z.current) == null || u.update(m, k, E) : E ? q == null || q(m) : T == null || T(m), b && (Q == null || Q(void 0));
34
36
  },
35
- [f, h]
36
- );
37
- return (Array.isArray(T) ? (X = T == null ? void 0 : T.filter(Boolean)) != null && X.length : T) || K || h || f != null && f.onUpdate || j || f != null && f.onCreate || q || G || z ? /* @__PURE__ */ E(H, { children: [
38
- f && /* @__PURE__ */ g(c, { ref: S, ...f }),
39
- T,
40
- (K || h || (f == null ? void 0 : f.onUpdate)) && /* @__PURE__ */ g(R, { value: y, onClick: (m) => W(m) }),
41
- (j || (f == null ? void 0 : f.onCreate)) && /* @__PURE__ */ g(
42
- k,
37
+ [f, T]
38
+ ), $ = H(() => !!(!z || z != null && z(v)), [z, v]), w = H(() => !!(!G || G != null && G(v)), [G, v]);
39
+ return (Array.isArray(g) ? (A = g == null ? void 0 : g.filter(Boolean)) != null && A.length : g) || S || $ && T || f != null && f.onUpdate || q || f != null && f.onCreate || w && K || N || L ? /* @__PURE__ */ r(C, { children: [
40
+ f && /* @__PURE__ */ j(s, { ref: Z, ...f }),
41
+ g,
42
+ (S || T || (f == null ? void 0 : f.onUpdate)) && $ && /* @__PURE__ */ j(U, { value: v, onClick: (m) => _(m) }),
43
+ (q || (f == null ? void 0 : f.onCreate)) && /* @__PURE__ */ j(
44
+ R,
43
45
  {
44
- value: y,
45
- onClick: (m) => W(m, !1, !0)
46
+ value: v,
47
+ onClick: (m) => _(m, !1, !0)
46
48
  }
47
49
  ),
48
- G && /* @__PURE__ */ g(
49
- F,
50
+ N && /* @__PURE__ */ j(
51
+ I,
50
52
  {
51
- value: y,
52
- onClick: async (m) => await G(m)
53
+ value: v,
54
+ onClick: async (m) => await N(m)
53
55
  }
54
56
  ),
55
- z && /* @__PURE__ */ g(
56
- r,
57
+ L && /* @__PURE__ */ j(
58
+ D,
57
59
  {
58
- value: y,
59
- disabled: L,
60
- shouldConfirm: _,
61
- loading: L && y[b] === Q,
60
+ value: v,
61
+ disabled: W,
62
+ shouldConfirm: x,
63
+ loading: W && v[y] === Y,
62
64
  onClick: async (m) => {
63
- v == null || v(m[b]), await z({ [b]: m[b] });
65
+ h == null || h(m[y]), await L({ [y]: m[y] });
64
66
  }
65
67
  }
66
68
  ),
67
- q && /* @__PURE__ */ g(
68
- C,
69
+ K && w && /* @__PURE__ */ j(
70
+ B,
69
71
  {
70
- value: y,
71
- disabled: N,
72
- shouldConfirm: $,
73
- loading: N && y[b] === Q,
72
+ value: v,
73
+ disabled: X,
74
+ shouldConfirm: V,
75
+ loading: X && v[y] === Y,
74
76
  onClick: async (m) => {
75
- v == null || v(m[b]), await q({ [b]: m[b] });
77
+ h == null || h(m[y]), await K({ [y]: m[y] });
76
78
  }
77
79
  }
78
80
  )
79
81
  ] }) : void 0;
80
82
  }
81
83
  export {
82
- a as default
84
+ l as default
83
85
  };
@@ -1 +1 @@
1
- "use strict";const g=require("react/jsx-runtime"),B=require("antd"),t=require("react"),J=require("../CrudForm.cjs.js"),K=require("../CrudFormWizard.cjs.js"),Q=require("../../locale/index.cjs.js"),I=require("../../util/CrudUtil.cjs.js"),X=require("dayjs"),Y=({fields:u,wizard:l,grid:M,fullWidthModal:T,isCreating:h,isUpdating:j,onCreate:b,onUpdate:v,idField:k="id",formBuilder:W,onValuesChange:q},_)=>{const[s]=B.Form.useForm(),{t:S}=Q.useTranslationLib(),[C,m]=t.useState(!1),[p,N]=t.useState("new"),[f,F]=t.useState(),[A,y]=t.useState(),[L,V]=t.useState(!1),[E,x]=t.useState(!1),[$,P]=t.useState(!1),R=t.useCallback(async c=>{var n;const d=l?c:await s.validateFields(),i=u.filter(a=>a.type==="color"),o={};for(const a of i){const e=I.getRealName(a.name,"upsertFieldName"),r=s.getFieldValue(e);o[e]=typeof r=="string"?r:(n=r==null?void 0:r.toHexString())==null?void 0:n.toUpperCase()}Object.assign(d,o),f&&v?(await v({...d,[k]:f[k]}),F(void 0)):!f&&b&&await b(d),y(void 0),s.resetFields(),m(!1)},[u,s,k,b,v,f,l]),U=t.useCallback(async c=>{V(c),x(!0)},[]),O=t.useCallback(async()=>{x(!0)},[]),D=t.useCallback(()=>{m(!0),N("new"),s.resetFields(),F(void 0),y(void 0)},[s]),H=t.useCallback(async(c,d=!0,i=!1)=>{try{P(!0),m(!0),N(i?"clone":"update");const o={};for(const n of u){const a=I.getRealName(n.name,"upsertFieldName"),e=c[a];if(i&&n.type==="image"){const r=e;try{const G=await n.provider.clone(r);o[a]=G;continue}catch{continue}}n.type==="date"||n.type==="time"?e&&(o[a]=X(e)):n.type==="select"?n.multiple&&Array.isArray(e)?o[a]=e.map(r=>r[n.innerFieldId??"id"]):e&&typeof e=="object"?o[a]=e[n.innerFieldId??"id"]:(e&&typeof e=="string"||typeof e=="number")&&(o[a]=e):o[a]=e}s.setFieldsValue(o),y(o),d&&F(c)}finally{P(!1)}},[u,s]);t.useImperativeHandle(_,()=>({create:D,update:H}),[D,H]),t.useEffect(()=>{C&&(V(!1),x(!1))},[C]);const w=t.useCallback(async()=>{try{if(p==="clone"){const c=l?f:s.getFieldsValue(),d=u.filter(i=>i.type==="image");for(const i of d)c[i.name]&&i.provider.delete(c[i.name])}}finally{}l||s.resetFields(),y(void 0),F(void 0),m(!1)},[p,l,s,f,u]);return g.jsx(B.Modal,{width:T?"100%":void 0,title:S(p??"new"),open:C,confirmLoading:h||j,okText:S("str."+(p==="update"?"update":"save")),cancelText:S("str.cancel"),cancelButtonProps:{disabled:E,hidden:!!l},okButtonProps:{disabled:L,hidden:!!l},onCancel:w,onOk:()=>R(),destroyOnHidden:!0,children:g.jsxs(B.Spin,{spinning:$,children:[l?null:g.jsx(J.CrudForm,{purpose:p,fields:u,form:s,formBuilder:W,grid:M,onDeleteFile:O,onUploadFile:U,onValuesChange:q}),l&&g.jsx(K,{submitting:h||j,className:"mt-2",onSave:R,updatingValue:A,fields:u,onDeleteFile:O,onUploadFile:U,purpose:p,wizard:l,onValuesChange:q})]})})},Z=t.forwardRef(Y);module.exports=Z;
1
+ "use strict";const g=require("react/jsx-runtime"),B=require("antd"),t=require("react"),J=require("../CrudForm.cjs.js"),K=require("../CrudFormWizard.cjs.js"),Q=require("../../locale/index.cjs.js"),I=require("../../util/CrudUtil.cjs.js"),X=require("dayjs"),Y=({fields:u,wizard:l,grid:M,fullWidthModal:T,isCreating:h,isUpdating:j,onCreate:b,onUpdate:v,idField:k="id",formBuilder:W,onValuesChange:q},_)=>{const[s]=B.Form.useForm(),{t:S}=Q.useTranslationLib(),[C,m]=t.useState(!1),[p,N]=t.useState("new"),[f,F]=t.useState(),[A,y]=t.useState(),[L,V]=t.useState(!1),[E,x]=t.useState(!1),[$,P]=t.useState(!1),R=t.useCallback(async c=>{var n;const d=l?c:await s.validateFields(),i=u.filter(a=>a.type==="color"),o={};for(const a of i){const e=I.getRealName(a.name,"upsertFieldName"),r=s.getFieldValue(e);o[e]=typeof r=="string"?r:(n=r==null?void 0:r.toHexString())==null?void 0:n.toUpperCase()}Object.assign(d,o),f&&v?(await v({...d,[k]:f[k]}),F(void 0)):!f&&b&&await b(d),y(void 0),s.resetFields(),m(!1)},[u,s,k,b,v,f,l]),U=t.useCallback(async c=>{V(c),x(!0)},[]),O=t.useCallback(async()=>{x(!0)},[]),D=t.useCallback(()=>{m(!0),N("new"),s.resetFields(),F(void 0),y(void 0)},[s]),H=t.useCallback(async(c,d=!0,i=!1)=>{try{P(!0),m(!0),N(i?"clone":"update");const o={};for(const n of u){const a=I.getRealName(n.name,"upsertFieldName"),e=c[a];if(i&&n.type==="image"){const r=e;try{const G=await n.provider.clone(r);o[a]=G;continue}catch{continue}}n.type==="date"||n.type==="time"?e&&(o[a]=X(e)):n.type==="select"?n.multiple&&Array.isArray(e)?o[a]=e.map(r=>r[n.innerFieldId??"id"]):e&&typeof e=="object"?o[a]=e[n.innerFieldId??"id"]:(e&&typeof e=="string"||typeof e=="number")&&(o[a]=e):o[a]=e}s.setFieldsValue(o),y(o),d&&F(c)}finally{P(!1)}},[u,s]);t.useImperativeHandle(_,()=>({create:D,update:H}),[D,H]),t.useEffect(()=>{C&&(V(!1),x(!1))},[C]);const w=t.useCallback(async()=>{try{if(p==="clone"){const c=l?f:s.getFieldsValue(),d=u.filter(i=>i.type==="image");for(const i of d)c[i.name]&&i.provider.delete(c[i.name])}}finally{}l||s.resetFields(),y(void 0),F(void 0),m(!1)},[p,l,s,f,u]);return g.jsx(B.Modal,{width:T?"100%":void 0,title:S("str."+(p??"new")),open:C,confirmLoading:h||j,okText:S("str."+(p==="update"?"update":"save")),cancelText:S("str.cancel"),cancelButtonProps:{disabled:E,hidden:!!l},okButtonProps:{disabled:L,hidden:!!l},onCancel:w,onOk:()=>R(),destroyOnHidden:!0,children:g.jsxs(B.Spin,{spinning:$,children:[l?null:g.jsx(J.CrudForm,{purpose:p,fields:u,form:s,formBuilder:W,grid:M,onDeleteFile:O,onUploadFile:U,onValuesChange:q}),l&&g.jsx(K,{submitting:h||j,className:"mt-2",onSave:R,updatingValue:A,fields:u,onDeleteFile:O,onUploadFile:U,purpose:p,wizard:l,onValuesChange:q})]})})},Z=t.forwardRef(Y);module.exports=Z;
@@ -95,7 +95,7 @@ const se = ({
95
95
  Q,
96
96
  {
97
97
  width: W ? "100%" : void 0,
98
- title: h(p ?? "new"),
98
+ title: h("str." + (p ?? "new")),
99
99
  open: k,
100
100
  confirmLoading: x || C,
101
101
  okText: h("str." + (p === "update" ? "update" : "save")),
@@ -1 +1 @@
1
- "use strict";const n=require("react/jsx-runtime"),ht=require("antd"),yt=require("@dnd-kit/core"),qt=require("@dnd-kit/modifiers"),Ct=require("@dnd-kit/utilities"),M=require("@dnd-kit/sortable"),lt=require("../../common/button/Button.cjs.js"),St=require("../../common/button/RefreshButton.cjs.js"),dt=require("../../common/button/ViewButtonTable.cjs.js"),It=require("../actions/index.cjs.js"),Rt=require("../../common/table/table.cjs.js"),s=require("react"),Mt=require("../../locale/index.cjs.js"),Tt=require("../CrudSearchComponent.cjs.js"),Vt=require("./CrudDecListView.cjs.js"),nt=require("./CrudViewerUtil.cjs.js"),Bt=require("@ant-design/icons"),ot=require("../../util/CrudUtil.cjs.js"),Dt=require("../../common/layout/VerticalSpace.cjs.js"),Ot=s.memo(Rt);function Nt({summary:j,idField:o="id",loadingData:q,fields:h,isDeleting:I,isHiding:T,viewable:c=!1,paginateProps:f,onDelete:l,onHide:V,onUpdate:B,data:S=[],extraAction:D,onClickUpdate:O,minusHeight:k,scroll:v,onClickClone:z,className:$,expandable:A,size:_,bordered:G,descListColumn:rt,extraView:E,decListLayout:ct,scrollToTop:Lt,onClickRefresh:J,closeViewOnClickUpdate:K,onExport:Q,confirmHiding:X,confirmDeleting:Y,rowClassName:Z,actionWidth:W=190,draggable:t,rowSelection:P,...ut}){const{t:H}=Mt.useTranslationLib(),U=s.useMemo(()=>h.map(({hideInTable:e,hidden:r,width:u,label:m,halign:d,...C})=>{const N=ot.getRealName(C.name);return{title:m,width:u,key:N,dataIndex:N,hidden:e||r,align:d??(C.type==="number"?"right":void 0),render:nt.getRendererValueCrudViewer(C),sorter:C.sorter,defaultSortOrder:C.defaultSortOrder}}),[h]),[i,R]=s.useState(),[p,w]=s.useState(),[y,a]=s.useState([]),it=s.useCallback(e=>{R(e)},[]);s.useEffect(()=>{S&&a(S)},[S]),s.useEffect(()=>{S&&R(e=>{if(e)return S.find(r=>r[o]===e[o])})},[S,o,i]);const F=s.useCallback(e=>{var m;const{active:r,over:u}=e;if(t!=null&&t.onDragEnd&&(t==null||t.onDragEnd(e)),r.id!==(u==null?void 0:u.id)){const d=y.findIndex(x=>x[o]===r.id),C=y.findIndex(x=>x[o]===(u==null?void 0:u.id)),N=M.arrayMove(y,d,C);a(x=>{const xt=x.findIndex(L=>L[o]===(r==null?void 0:r.id)),jt=x.findIndex(L=>L[o]===(u==null?void 0:u.id));return M.arrayMove(x,xt,jt)}),(m=t==null?void 0:t.onDrag)==null||m.call(t,{newOrder:N.map(x=>x[o])})}},[y,o,t]),ft=s.useMemo(()=>{let e=typeof c=="string"?i==null?void 0:i[c]:void 0;if(typeof e=="object"){const r=h.find(u=>ot.getRealName(u.name)===c);e=nt.getRendererValueCrudViewer(r)(e,i,0)}return e},[c,i,h]),b=s.useMemo(()=>({rowSelection:P,rowClassName:Z,className:$,scroll:v??(k?{y:`calc(100vh - ${k})`}:void 0),id:"crud-table",bordered:G,size:_,expandable:A}),[P,Z,$,v,k,G,_,A]),g=s.useMemo(()=>f?{...f,total:f.count,onChange:f.setPage,current:f.page,pageSize:f.pageSize}:void 0,[f]),tt=s.useMemo(()=>{const e=B||O||l||D||c,r=[];return t&&r.push({key:"key",align:"center",width:5,title:t==null?void 0:t.columnLabel,render:()=>n.jsx(kt,{tooltip:t==null?void 0:t.tooltip})}),r.push(...U),e&&e&&r.push({title:H("str.action"),fixed:"right",width:W,render:(u,m)=>n.jsxs(n.Fragment,{children:[c&&n.jsx(dt,{value:m,onClick:typeof c=="object"?()=>{var d;return(d=c.onClick)==null?void 0:d.call(c,m)}:it}),n.jsx(It,{data:m,idField:o,extraAction:D,onUpdate:B,onClickUpdate:O,onClickClone:z,onDelete:l,onHide:V,onExport:Q,isHiding:T,isDeleting:I,confirmHiding:X,confirmDeleting:Y,closeViewOnClickUpdate:K,recentUpdateOrDeleteId:p,setRecentUpdateOrDeleteId:w,setOpenView:R})]})}),r},[U,B,O,l,D,c,H,W]),et=s.useMemo(()=>y.map(e=>e[o]),[y,o]),mt=s.useCallback(()=>{const e=n.jsx(Ot,{...b,summary:j,dataSource:y,loading:q,components:t?{body:{row:Et}}:void 0,pagination:g,columns:tt});return t?n.jsx(yt.DndContext,{modifiers:[qt.restrictToVerticalAxis],onDragEnd:F,children:n.jsx(M.SortableContext,{items:et,strategy:M.verticalListSortingStrategy,children:e})}):e},[b,y,q,g,tt,j,t,et,F]);return n.jsxs("div",{children:[(typeof c=="boolean"||typeof c=="string")&&n.jsx(ht.Modal,{width:"100%",open:!!i,title:ft??n.jsx("div",{children:" "}),footer:n.jsx(n.Fragment,{}),closable:!0,onCancel:()=>R(void 0),children:!!i&&n.jsxs("div",{children:[n.jsx(Vt.CrudDecListView,{layout:ct,descListColumn:rt,data:i,fields:h,idField:o,extraAction:D,onUpdate:B,onClickUpdate:O,onClickClone:z,onDelete:l,onHide:V,onExport:Q,isHiding:T,isDeleting:I,confirmHiding:X,confirmDeleting:Y,closeViewOnClickUpdate:K,recentUpdateOrDeleteId:p,setRecentUpdateOrDeleteId:w,setOpenView:R}),E==null?void 0:E(i)]},i==null?void 0:i[o])}),n.jsx(Tt,{fields:h,...ut}),n.jsxs(Dt,{children:[!!J&&n.jsx(St.RefreshButton,{onClick:J}),mt()]})]})}const st=s.createContext({}),kt=({tooltip:j})=>{const{setActivatorNodeRef:o,listeners:q}=s.useContext(st);return n.jsx(lt,{type:"text",size:"small",tooltip:j,icon:n.jsx(Bt.HolderOutlined,{}),style:{cursor:"move",border:"none"},ref:o,...q})},Et=j=>{const{attributes:o,listeners:q,setNodeRef:h,setActivatorNodeRef:I,transform:T,transition:c,isDragging:f}=M.useSortable({id:j["data-row-key"]}),l={...j.style,transform:Ct.CSS.Translate.toString(T),transition:c,...f?{position:"relative",zIndex:9999}:{}},V=s.useMemo(()=>({setActivatorNodeRef:I,listeners:q}),[I,q]);return n.jsx(st.Provider,{value:V,children:n.jsx("tr",{...j,ref:h,style:l,...o})})};module.exports=Nt;
1
+ "use strict";const n=require("react/jsx-runtime"),qt=require("antd"),Ct=require("@dnd-kit/core"),St=require("@dnd-kit/modifiers"),It=require("@dnd-kit/utilities"),T=require("@dnd-kit/sortable"),Rt=require("../../common/button/Button.cjs.js"),lt=require("../../common/button/RefreshButton.cjs.js"),Mt=require("../../common/button/ViewButtonTable.cjs.js"),dt=require("../actions/index.cjs.js"),Tt=require("../../common/table/table.cjs.js"),s=require("react"),Vt=require("../../locale/index.cjs.js"),Bt=require("../CrudSearchComponent.cjs.js"),Dt=require("./CrudDecListView.cjs.js"),st=require("./CrudViewerUtil.cjs.js"),Ot=require("@ant-design/icons"),rt=require("../../util/CrudUtil.cjs.js"),Nt=require("../../common/layout/VerticalSpace.cjs.js"),kt=s.memo(Tt);function Et({summary:j,idField:o="id",loadingData:q,fields:h,isDeleting:l,isHiding:V,viewable:c=!1,paginateProps:f,onDelete:S,deletable:M,updatable:k,onHide:z,onUpdate:B,data:I=[],extraAction:D,onClickUpdate:O,minusHeight:E,scroll:$,onClickClone:A,className:_,expandable:G,size:J,bordered:K,descListColumn:ut,extraView:L,decListLayout:it,scrollToTop:zt,onClickRefresh:Q,closeViewOnClickUpdate:X,onExport:Y,confirmHiding:Z,confirmDeleting:W,rowClassName:P,actionWidth:H=190,draggable:t,rowSelection:U,...ft}){const{t:w}=Vt.useTranslationLib(),p=s.useMemo(()=>h.map(({hideInTable:e,hidden:r,width:u,label:m,halign:R,...C})=>{const N=rt.getRealName(C.name);return{title:m,width:u,key:N,dataIndex:N,hidden:e||r,align:R??(C.type==="number"?"right":void 0),render:st.getRendererValueCrudViewer(C),sorter:C.sorter,defaultSortOrder:C.defaultSortOrder}}),[h]),[i,d]=s.useState(),[F,a]=s.useState(),[y,b]=s.useState([]),mt=s.useCallback(e=>{d(e)},[]);s.useEffect(()=>{I&&b(I)},[I]),s.useEffect(()=>{I&&d(e=>{if(e)return I.find(r=>r[o]===e[o])})},[I,o,i]);const g=s.useCallback(e=>{var m;const{active:r,over:u}=e;if(t!=null&&t.onDragEnd&&(t==null||t.onDragEnd(e)),r.id!==(u==null?void 0:u.id)){const R=y.findIndex(x=>x[o]===r.id),C=y.findIndex(x=>x[o]===(u==null?void 0:u.id)),N=T.arrayMove(y,R,C);b(x=>{const ht=x.findIndex(v=>v[o]===(r==null?void 0:r.id)),yt=x.findIndex(v=>v[o]===(u==null?void 0:u.id));return T.arrayMove(x,ht,yt)}),(m=t==null?void 0:t.onDrag)==null||m.call(t,{newOrder:N.map(x=>x[o])})}},[y,o,t]),xt=s.useMemo(()=>{let e=typeof c=="string"?i==null?void 0:i[c]:void 0;if(typeof e=="object"){const r=h.find(u=>rt.getRealName(u.name)===c);e=st.getRendererValueCrudViewer(r)(e,i,0)}return e},[c,i,h]),tt=s.useMemo(()=>({rowSelection:U,rowClassName:P,className:_,scroll:$??(E?{y:`calc(100vh - ${E})`}:void 0),id:"crud-table",bordered:K,size:J,expandable:G}),[U,P,_,$,E,K,J,G]),et=s.useMemo(()=>f?{...f,total:f.count,onChange:f.setPage,current:f.page,pageSize:f.pageSize}:void 0,[f]),nt=s.useMemo(()=>{const e=B||O||S||D||c,r=[];return t&&r.push({key:"key",align:"center",width:5,title:t==null?void 0:t.columnLabel,render:()=>n.jsx(Lt,{tooltip:t==null?void 0:t.tooltip})}),r.push(...p),e&&e&&r.push({title:w("str.action"),fixed:"right",width:H,render:(u,m)=>n.jsxs(n.Fragment,{children:[c&&n.jsx(Mt,{value:m,onClick:typeof c=="object"?()=>{var R;return(R=c.onClick)==null?void 0:R.call(c,m)}:mt}),n.jsx(dt,{data:m,idField:o,extraAction:D,onUpdate:B,onClickUpdate:O,onClickClone:A,onDelete:S,deletable:M,updatable:k,onHide:z,onExport:Y,isHiding:V,isDeleting:l,confirmHiding:Z,confirmDeleting:W,closeViewOnClickUpdate:X,recentUpdateOrDeleteId:F,setRecentUpdateOrDeleteId:a,setOpenView:d})]})}),r},[p,B,O,S,M,k,D,c,w,H]),ot=s.useMemo(()=>y.map(e=>e[o]),[y,o]),jt=s.useCallback(()=>{const e=n.jsx(kt,{...tt,summary:j,dataSource:y,loading:q,components:t?{body:{row:vt}}:void 0,pagination:et,columns:nt});return t?n.jsx(Ct.DndContext,{modifiers:[St.restrictToVerticalAxis],onDragEnd:g,children:n.jsx(T.SortableContext,{items:ot,strategy:T.verticalListSortingStrategy,children:e})}):e},[tt,y,q,et,nt,j,t,ot,g]);return n.jsxs("div",{children:[(typeof c=="boolean"||typeof c=="string")&&n.jsx(qt.Modal,{width:"100%",open:!!i,title:xt??n.jsx("div",{children:" "}),footer:n.jsx(n.Fragment,{}),closable:!0,onCancel:()=>d(void 0),children:!!i&&n.jsxs("div",{children:[n.jsx(Dt.CrudDecListView,{layout:it,descListColumn:ut,data:i,fields:h,idField:o,extraAction:D,onUpdate:B,onClickUpdate:O,onClickClone:A,onDelete:S,deletable:M,updatable:k,onHide:z,onExport:Y,isHiding:V,isDeleting:l,confirmHiding:Z,confirmDeleting:W,closeViewOnClickUpdate:X,recentUpdateOrDeleteId:F,setRecentUpdateOrDeleteId:a,setOpenView:d}),L==null?void 0:L(i)]},i==null?void 0:i[o])}),n.jsx(Bt,{fields:h,...ft}),n.jsxs(Nt,{children:[!!Q&&n.jsx(lt.RefreshButton,{onClick:Q}),jt()]})]})}const ct=s.createContext({}),Lt=({tooltip:j})=>{const{setActivatorNodeRef:o,listeners:q}=s.useContext(ct);return n.jsx(Rt,{type:"text",size:"small",tooltip:j,icon:n.jsx(Ot.HolderOutlined,{}),style:{cursor:"move",border:"none"},ref:o,...q})},vt=j=>{const{attributes:o,listeners:q,setNodeRef:h,setActivatorNodeRef:l,transform:V,transition:c,isDragging:f}=T.useSortable({id:j["data-row-key"]}),S={...j.style,transform:It.CSS.Translate.toString(V),transition:c,...f?{position:"relative",zIndex:9999}:{}},M=s.useMemo(()=>({setActivatorNodeRef:l,listeners:q}),[l,q]);return n.jsx(ct.Provider,{value:M,children:n.jsx("tr",{...j,ref:h,style:S,...o})})};module.exports=Et;
@@ -42,5 +42,5 @@ export type CrudViewerProps<T, FormType> = {
42
42
  actionWidth?: string | number;
43
43
  draggable?: CrudDragableProps<T>;
44
44
  } & CrudActionsProps<T, FormType> & CrudSearchComponentProps<T, FormType>;
45
- declare function CrudViewer<T, FormType = T>({ summary, idField, loadingData, fields, isDeleting, isHiding, viewable, paginateProps, onDelete, onHide, onUpdate, data, extraAction, onClickUpdate, minusHeight, scroll, onClickClone, className, expandable, size, bordered, descListColumn, extraView, decListLayout, scrollToTop, onClickRefresh, closeViewOnClickUpdate, onExport, confirmHiding, confirmDeleting, rowClassName, actionWidth, draggable, rowSelection, ...props }: CrudViewerProps<T, FormType>): import("react/jsx-runtime").JSX.Element;
45
+ declare function CrudViewer<T, FormType = T>({ summary, idField, loadingData, fields, isDeleting, isHiding, viewable, paginateProps, onDelete, deletable, updatable, onHide, onUpdate, data, extraAction, onClickUpdate, minusHeight, scroll, onClickClone, className, expandable, size, bordered, descListColumn, extraView, decListLayout, scrollToTop, onClickRefresh, closeViewOnClickUpdate, onExport, confirmHiding, confirmDeleting, rowClassName, actionWidth, draggable, rowSelection, ...props }: CrudViewerProps<T, FormType>): import("react/jsx-runtime").JSX.Element;
46
46
  export default CrudViewer;