@kingteza/crud-component 1.0.63 → 1.0.64

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.
@@ -7,7 +7,7 @@ import { CrudSearchComponentProps } from './CrudSearchComponent';
7
7
  import { FileCrudField } from './FileCrudField';
8
8
  import { ImageCrudField } from './ImageCrudField';
9
9
  import { CrudImportProps } from './import/CrudImportComponent';
10
- import { CrudDragableProps } from './view/CrudViewer';
10
+ import { CrudDragableProps, CrudViewableProps } from './view/CrudViewer';
11
11
  import { SelectTagRenderProps } from '../common/select/SelectComponent';
12
12
  import { default as IdProps } from '../types/Id';
13
13
  import { TextAreaBasedFieldProps } from './CrudTextAreaComponent';
@@ -226,7 +226,7 @@ export type CrudComponentProps<T, FormType = T> = {
226
226
  isHiding?: boolean;
227
227
  isDeleting?: boolean;
228
228
  isUpdating?: boolean;
229
- viewable?: boolean | keyof T;
229
+ viewable?: CrudViewableProps<T>;
230
230
  extraAction?: (t: T) => ReactElement;
231
231
  paginateProps?: CrudPaginateProps;
232
232
  formBuilder?: FormBuilderFunc<T>;
@@ -1 +1 @@
1
- "use strict";const n=require("react/jsx-runtime"),xt=require("antd"),jt=require("@dnd-kit/core"),lt=require("@dnd-kit/modifiers"),ht=require("@dnd-kit/utilities"),M=require("@dnd-kit/sortable"),qt=require("../../common/button/Button.cjs.js"),yt=require("../../common/button/CloneButtonTable.cjs.js"),vt=require("../../common/button/DeleteButtonTable.cjs.js"),St=require("../../common/button/ExportButton.cjs.js"),Bt=require("../../common/button/HideButtonTable.cjs.js"),Ct=require("../../common/button/RefreshButton.cjs.js"),It=require("../../common/button/UpdateButtonTable.cjs.js"),Tt=require("../../common/button/ViewButtonTable.cjs.js"),Rt=require("../../common/table/table.cjs.js"),u=require("react"),Mt=require("../../locale/index.cjs.js"),Vt=require("../CrudSearchComponent.cjs.js"),Et=require("./CrudDecListView.cjs.js"),et=require("./CrudViewerUtil.cjs.js"),Nt=require("@ant-design/icons"),nt=require("../../util/CrudUtil.cjs.js"),wt=require("../../common/layout/VerticalSpace.cjs.js"),Dt=u.memo(Rt);function Lt({idField:e="id",loadingData:v,fields:m,isDeleting:I,isHiding:S,viewable:f=!1,paginateProps:j,onDelete:l,onHide:T,onUpdate:y,data:B=[],extraAction:C,onClickUpdate:h,minusHeight:w,scroll:G,onClickClone:V,className:J,expandable:K,size:Q,bordered:X,descListColumn:ot,extraView:D,decListLayout:rt,scrollToTop:_t,onClickRefresh:Y,closeViewOnClickUpdate:Z,onExport:L,confirmHiding:A,confirmDeleting:P,rowClassName:W,actionWidth:a=190,draggable:o,...ut}){const{t:H}=Mt.useTranslationLib(),p=u.useMemo(()=>m.map(({hideInTable:t,hidden:s,width:c,label:r,halign:$,...R})=>{const N=nt.getRealName(R.name);return{title:r,width:c,key:N,dataIndex:N,hidden:t||s,align:$??(R.type==="number"?"right":void 0),render:et.getRendererValueCrudViewer(R)}}),[m]),[i,E]=u.useState(),[O,z]=u.useState(),[q,U]=u.useState([]);u.useEffect(()=>{B&&U(B)},[B]),u.useEffect(()=>{B&&E(t=>{if(t)return B.find(s=>s[e]===t[e])})},[B,e,i]);const _=u.useCallback(t=>{var c;const s=C==null?void 0:C(t);return(Array.isArray(s)?(c=s==null?void 0:s.filter(Boolean))!=null&&c.length:s)||y||h||V||l?n.jsxs(n.Fragment,{children:[s,(y||h)&&n.jsx(It,{value:t,onClick:r=>{z(r[e]),h==null||h(t),Z&&E(void 0)}}),V&&n.jsx(yt,{value:t,onClick:r=>V(r)}),L&&n.jsx(St.ExportButton,{value:t,onClick:async r=>await L(r)}),T&&n.jsx(Bt,{value:t,disabled:S,shouldConfirm:A,loading:S&&t[e]===O,onClick:async r=>{z(r[e]),await T({[e]:r[e]})}}),l&&n.jsx(vt,{value:t,disabled:I,shouldConfirm:P,loading:I&&t[e]===O,onClick:async r=>{z(r[e]),await l({[e]:r[e]})}})]}):void 0},[Z,P,A,C,e,I,S,V,h,l,L,T,y,O]),d=u.useCallback(t=>{var r;const{active:s,over:c}=t;if(o!=null&&o.onDragEnd&&(o==null||o.onDragEnd(t)),s.id!==(c==null?void 0:c.id)){const $=q.findIndex(x=>x[e]===s.id),R=q.findIndex(x=>x[e]===(c==null?void 0:c.id)),N=M.arrayMove(q,$,R);U(x=>{const mt=x.findIndex(k=>k[e]===(s==null?void 0:s.id)),ft=x.findIndex(k=>k[e]===(c==null?void 0:c.id));return M.arrayMove(x,mt,ft)}),(r=o==null?void 0:o.onDrag)==null||r.call(o,{newOrder:N.map(x=>x[e])})}},[q,e,o]),ct=u.useMemo(()=>{let t=typeof f=="string"?i==null?void 0:i[f]:void 0;if(typeof t=="object"){const s=m.find(c=>nt.getRealName(c.name)===f);t=et.getRendererValueCrudViewer(s)(t,i,0)}return t},[f,i,m]),b=u.useMemo(()=>({rowClassName:W,className:J,scroll:G??(w?{y:`calc(100vh - ${w})`}:void 0),id:"crud-table",bordered:X,size:Q,expandable:K}),[W,J,G,w,X,Q,K]),F=u.useMemo(()=>j?{total:j.count,onChange:j.setPage,current:j.page,pageSize:j.pageSize}:void 0,[j]),g=u.useMemo(()=>{const t=y||h||l||C||f,s=[];return o&&s.push({key:"key",align:"center",width:5,title:o==null?void 0:o.columnLabel,render:()=>n.jsx(Ot,{tooltip:o==null?void 0:o.tooltip})}),s.push(...p),t&&t&&s.push({title:H("str.action"),fixed:"right",width:a,render:(c,r)=>n.jsxs(n.Fragment,{children:[f&&n.jsx(Tt,{value:r,onClick:E}),_(r)]})}),s},[p,y,h,l,C,f,H,a,_]),tt=u.useMemo(()=>q.map(t=>t[e]),[q,e]),it=u.useCallback(()=>{const t=n.jsx(Dt,{...b,dataSource:q,loading:v,components:o?{body:{row:zt}}:void 0,pagination:F,columns:g});return o?n.jsx(jt.DndContext,{modifiers:[lt.restrictToVerticalAxis],onDragEnd:d,children:n.jsx(M.SortableContext,{items:tt,strategy:M.verticalListSortingStrategy,children:t})}):t},[b,q,v,F,g,o,tt,d]);return n.jsxs("div",{children:[f&&n.jsx(xt.Modal,{width:"100%",open:!!i,title:ct??n.jsx("div",{children:" "}),footer:n.jsx(n.Fragment,{}),closable:!0,onCancel:()=>E(void 0),children:!!i&&n.jsxs("div",{children:[n.jsx(Et.CrudDecListView,{layout:rt,descListColumn:ot,data:i,fields:m,action:_(i)}),D==null?void 0:D(i)]},i==null?void 0:i[e])}),n.jsx(Vt,{fields:m,...ut}),n.jsxs(wt,{children:[!!Y&&n.jsx(Ct.RefreshButton,{onClick:Y}),it()]})]})}const st=u.createContext({}),Ot=({tooltip:e})=>{const{setActivatorNodeRef:v,listeners:m}=u.useContext(st);return n.jsx(qt,{type:"text",size:"small",tooltip:e,icon:n.jsx(Nt.HolderOutlined,{}),style:{cursor:"move",border:"none"},ref:v,...m})},zt=e=>{const{attributes:v,listeners:m,setNodeRef:I,setActivatorNodeRef:S,transform:f,transition:j,isDragging:l}=M.useSortable({id:e["data-row-key"]}),T={...e.style,transform:ht.CSS.Translate.toString(f),transition:j,...l?{position:"relative",zIndex:9999}:{}},y=u.useMemo(()=>({setActivatorNodeRef:S,listeners:m}),[S,m]);return n.jsx(st.Provider,{value:y,children:n.jsx("tr",{...e,ref:I,style:T,...v})})};module.exports=Lt;
1
+ "use strict";const n=require("react/jsx-runtime"),xt=require("antd"),jt=require("@dnd-kit/core"),yt=require("@dnd-kit/modifiers"),ht=require("@dnd-kit/utilities"),V=require("@dnd-kit/sortable"),qt=require("../../common/button/Button.cjs.js"),lt=require("../../common/button/CloneButtonTable.cjs.js"),Ct=require("../../common/button/DeleteButtonTable.cjs.js"),St=require("../../common/button/ExportButton.cjs.js"),Bt=require("../../common/button/HideButtonTable.cjs.js"),It=require("../../common/button/RefreshButton.cjs.js"),Tt=require("../../common/button/UpdateButtonTable.cjs.js"),Rt=require("../../common/button/ViewButtonTable.cjs.js"),Mt=require("../../common/table/table.cjs.js"),u=require("react"),vt=require("../../locale/index.cjs.js"),Vt=require("../CrudSearchComponent.cjs.js"),Et=require("./CrudDecListView.cjs.js"),et=require("./CrudViewerUtil.cjs.js"),Nt=require("@ant-design/icons"),nt=require("../../util/CrudUtil.cjs.js"),Dt=require("../../common/layout/VerticalSpace.cjs.js"),Lt=u.memo(Mt);function Ot({idField:e="id",loadingData:C,fields:f,isDeleting:R,isHiding:S,viewable:i=!1,paginateProps:j,onDelete:y,onHide:M,onUpdate:l,data:B=[],extraAction:I,onClickUpdate:h,minusHeight:L,scroll:J,onClickClone:E,className:K,expandable:Q,size:X,bordered:Y,descListColumn:ot,extraView:O,decListLayout:rt,scrollToTop:_t,onClickRefresh:Z,closeViewOnClickUpdate:A,onExport:z,confirmHiding:P,confirmDeleting:W,rowClassName:w,actionWidth:p=190,draggable:o,...ut}){const{t:H}=vt.useTranslationLib(),U=u.useMemo(()=>f.map(({hideInTable:t,hidden:s,width:c,label:r,halign:T,...v})=>{const D=nt.getRealName(v.name);return{title:r,width:c,key:D,dataIndex:D,hidden:t||s,align:T??(v.type==="number"?"right":void 0),render:et.getRendererValueCrudViewer(v)}}),[f]),[m,N]=u.useState(),[k,_]=u.useState(),[q,a]=u.useState([]);u.useEffect(()=>{B&&a(B)},[B]),u.useEffect(()=>{B&&N(t=>{if(t)return B.find(s=>s[e]===t[e])})},[B,e,m]);const $=u.useCallback(t=>{var c;const s=I==null?void 0:I(t);return(Array.isArray(s)?(c=s==null?void 0:s.filter(Boolean))!=null&&c.length:s)||l||h||E||y?n.jsxs(n.Fragment,{children:[s,(l||h)&&n.jsx(Tt,{value:t,onClick:r=>{_(r[e]),h==null||h(t),A&&N(void 0)}}),E&&n.jsx(lt,{value:t,onClick:r=>E(r)}),z&&n.jsx(St.ExportButton,{value:t,onClick:async r=>await z(r)}),M&&n.jsx(Bt,{value:t,disabled:S,shouldConfirm:P,loading:S&&t[e]===k,onClick:async r=>{_(r[e]),await M({[e]:r[e]})}}),y&&n.jsx(Ct,{value:t,disabled:R,shouldConfirm:W,loading:R&&t[e]===k,onClick:async r=>{_(r[e]),await y({[e]:r[e]})}})]}):void 0},[A,W,P,I,e,R,S,E,h,y,z,M,l,k]),d=u.useCallback(t=>{var r;const{active:s,over:c}=t;if(o!=null&&o.onDragEnd&&(o==null||o.onDragEnd(t)),s.id!==(c==null?void 0:c.id)){const T=q.findIndex(x=>x[e]===s.id),v=q.findIndex(x=>x[e]===(c==null?void 0:c.id)),D=V.arrayMove(q,T,v);a(x=>{const mt=x.findIndex(G=>G[e]===(s==null?void 0:s.id)),ft=x.findIndex(G=>G[e]===(c==null?void 0:c.id));return V.arrayMove(x,mt,ft)}),(r=o==null?void 0:o.onDrag)==null||r.call(o,{newOrder:D.map(x=>x[e])})}},[q,e,o]),ct=u.useMemo(()=>{let t=typeof i=="string"?m==null?void 0:m[i]:void 0;if(typeof t=="object"){const s=f.find(c=>nt.getRealName(c.name)===i);t=et.getRendererValueCrudViewer(s)(t,m,0)}return t},[i,m,f]),b=u.useMemo(()=>({rowClassName:w,className:K,scroll:J??(L?{y:`calc(100vh - ${L})`}:void 0),id:"crud-table",bordered:Y,size:X,expandable:Q}),[w,K,J,L,Y,X,Q]),F=u.useMemo(()=>j?{total:j.count,onChange:j.setPage,current:j.page,pageSize:j.pageSize}:void 0,[j]),g=u.useMemo(()=>{const t=l||h||y||I||i,s=[];return o&&s.push({key:"key",align:"center",width:5,title:o==null?void 0:o.columnLabel,render:()=>n.jsx(zt,{tooltip:o==null?void 0:o.tooltip})}),s.push(...U),t&&t&&s.push({title:H("str.action"),fixed:"right",width:p,render:(c,r)=>n.jsxs(n.Fragment,{children:[i&&n.jsx(Rt,{value:r,onClick:typeof i=="object"?()=>{var T;return(T=i.onClick)==null?void 0:T.call(i,r)}:N}),$(r)]})}),s},[U,l,h,y,I,i,H,p,$]),tt=u.useMemo(()=>q.map(t=>t[e]),[q,e]),it=u.useCallback(()=>{const t=n.jsx(Lt,{...b,dataSource:q,loading:C,components:o?{body:{row:kt}}:void 0,pagination:F,columns:g});return o?n.jsx(jt.DndContext,{modifiers:[yt.restrictToVerticalAxis],onDragEnd:d,children:n.jsx(V.SortableContext,{items:tt,strategy:V.verticalListSortingStrategy,children:t})}):t},[b,q,C,F,g,o,tt,d]);return n.jsxs("div",{children:[typeof i=="boolean"||typeof i=="string"&&n.jsx(xt.Modal,{width:"100%",open:!!m,title:ct??n.jsx("div",{children:" "}),footer:n.jsx(n.Fragment,{}),closable:!0,onCancel:()=>N(void 0),children:!!m&&n.jsxs("div",{children:[n.jsx(Et.CrudDecListView,{layout:rt,descListColumn:ot,data:m,fields:f,action:$(m)}),O==null?void 0:O(m)]},m==null?void 0:m[e])}),n.jsx(Vt,{fields:f,...ut}),n.jsxs(Dt,{children:[!!Z&&n.jsx(It.RefreshButton,{onClick:Z}),it()]})]})}const st=u.createContext({}),zt=({tooltip:e})=>{const{setActivatorNodeRef:C,listeners:f}=u.useContext(st);return n.jsx(qt,{type:"text",size:"small",tooltip:e,icon:n.jsx(Nt.HolderOutlined,{}),style:{cursor:"move",border:"none"},ref:C,...f})},kt=e=>{const{attributes:C,listeners:f,setNodeRef:R,setActivatorNodeRef:S,transform:i,transition:j,isDragging:y}=V.useSortable({id:e["data-row-key"]}),M={...e.style,transform:ht.CSS.Translate.toString(i),transition:j,...y?{position:"relative",zIndex:9999}:{}},l=u.useMemo(()=>({setActivatorNodeRef:S,listeners:f}),[S,f]);return n.jsx(st.Provider,{value:l,children:n.jsx("tr",{...e,ref:R,style:M,...C})})};module.exports=Ot;
@@ -15,10 +15,13 @@ export type CrudDragableProps<T> = {
15
15
  columnLabel?: string;
16
16
  tooltip?: string;
17
17
  };
18
+ export type CrudViewableProps<T> = boolean | keyof T | {
19
+ onClick: (t: T) => void;
20
+ };
18
21
  export type CrudViewerProps<T, FormType> = {
19
22
  fields: CrudFieldProps<T>[];
20
23
  decListLayout?: "horizontal" | "vertical";
21
- viewable?: boolean | keyof T;
24
+ viewable?: CrudViewableProps<T>;
22
25
  paginateProps?: CrudPaginateProps;
23
26
  onDelete?: (id: any) => Promise<any>;
24
27
  confirmDeleting?: boolean;
@@ -1,131 +1,129 @@
1
- import { jsxs as D, Fragment as G, jsx as s } from "react/jsx-runtime";
2
- import { Modal as It } from "antd";
3
- import { DndContext as St } from "@dnd-kit/core";
4
- import { restrictToVerticalAxis as Bt } from "@dnd-kit/modifiers";
5
- import { CSS as Ct } from "@dnd-kit/utilities";
6
- import { arrayMove as et, SortableContext as Rt, verticalListSortingStrategy as xt, useSortable as Nt } from "@dnd-kit/sortable";
7
- import Dt from "../../common/button/Button.es.js";
8
- import Et from "../../common/button/CloneButtonTable.es.js";
9
- import Lt from "../../common/button/DeleteButtonTable.es.js";
10
- import { ExportButton as Mt } from "../../common/button/ExportButton.es.js";
11
- import Ot from "../../common/button/HideButtonTable.es.js";
12
- import { RefreshButton as jt } from "../../common/button/RefreshButton.es.js";
1
+ import { jsxs as D, Fragment as J, jsx as m } from "react/jsx-runtime";
2
+ import { Modal as St } from "antd";
3
+ import { DndContext as Bt } from "@dnd-kit/core";
4
+ import { restrictToVerticalAxis as Ct } from "@dnd-kit/modifiers";
5
+ import { CSS as Rt } from "@dnd-kit/utilities";
6
+ import { arrayMove as st, SortableContext as vt, verticalListSortingStrategy as xt, useSortable as Nt } from "@dnd-kit/sortable";
7
+ import jt from "../../common/button/Button.es.js";
8
+ import Dt from "../../common/button/CloneButtonTable.es.js";
9
+ import Et from "../../common/button/DeleteButtonTable.es.js";
10
+ import { ExportButton as Lt } from "../../common/button/ExportButton.es.js";
11
+ import Mt from "../../common/button/HideButtonTable.es.js";
12
+ import { RefreshButton as Ot } from "../../common/button/RefreshButton.es.js";
13
13
  import zt from "../../common/button/UpdateButtonTable.es.js";
14
14
  import Vt from "../../common/button/ViewButtonTable.es.js";
15
- import wt from "../../common/table/table.es.js";
16
- import ut, { useMemo as T, useState as J, useEffect as st, useCallback as K, useContext as _t } from "react";
17
- import { useTranslationLib as $t } from "../../locale/index.es.js";
18
- import qt from "../CrudSearchComponent.es.js";
19
- import { CrudDecListView as Gt } from "./CrudDecListView.es.js";
20
- import { getRendererValueCrudViewer as mt } from "./CrudViewerUtil.es.js";
21
- import { HolderOutlined as Jt } from "@ant-design/icons";
15
+ import _t from "../../common/table/table.es.js";
16
+ import ut, { useMemo as I, useState as K, useEffect as mt, useCallback as Q, useContext as $t } from "react";
17
+ import { useTranslationLib as qt } from "../../locale/index.es.js";
18
+ import Gt from "../CrudSearchComponent.es.js";
19
+ import { CrudDecListView as Jt } from "./CrudDecListView.es.js";
20
+ import { getRendererValueCrudViewer as et } from "./CrudViewerUtil.es.js";
21
+ import { HolderOutlined as Kt } from "@ant-design/icons";
22
22
  import ct from "../../util/CrudUtil.es.js";
23
- import Kt from "../../common/layout/VerticalSpace.es.js";
24
- const Qt = ut.memo(wt);
25
- function yo({
23
+ import Qt from "../../common/layout/VerticalSpace.es.js";
24
+ const Xt = ut.memo(_t);
25
+ function ho({
26
26
  idField: o = "id",
27
- loadingData: I,
28
- fields: u,
29
- isDeleting: R,
30
- isHiding: S,
31
- viewable: f = !1,
32
- paginateProps: h,
33
- onDelete: y,
34
- onHide: x,
35
- onUpdate: v,
36
- data: B = [],
37
- extraAction: C,
38
- onClickUpdate: l,
27
+ loadingData: S,
28
+ fields: f,
29
+ isDeleting: x,
30
+ isHiding: B,
31
+ viewable: c = !1,
32
+ paginateProps: y,
33
+ onDelete: h,
34
+ onHide: N,
35
+ onUpdate: l,
36
+ data: C = [],
37
+ extraAction: R,
38
+ onClickUpdate: p,
39
39
  minusHeight: O,
40
- scroll: Q,
40
+ scroll: X,
41
41
  onClickClone: E,
42
- className: X,
43
- expandable: Y,
44
- size: Z,
42
+ className: Y,
43
+ expandable: Z,
44
+ size: k,
45
45
  bordered: A,
46
46
  descListColumn: it,
47
- extraView: j,
48
- decListLayout: ht,
49
- scrollToTop: Zt,
47
+ extraView: z,
48
+ decListLayout: yt,
49
+ scrollToTop: kt,
50
50
  onClickRefresh: P,
51
51
  closeViewOnClickUpdate: W,
52
- onExport: z,
53
- confirmHiding: k,
54
- confirmDeleting: H,
52
+ onExport: V,
53
+ confirmHiding: H,
54
+ confirmDeleting: w,
55
55
  rowClassName: U,
56
- actionWidth: a = 190,
56
+ actionWidth: d = 190,
57
57
  draggable: r,
58
- ...yt
58
+ ...ht
59
59
  }) {
60
- const { t: b } = $t(), d = T(
61
- () => u.map(
62
- ({ hideInTable: t, hidden: n, width: m, label: e, halign: $, ...N }) => {
63
- const M = ct.getRealName(N.name);
64
- return {
65
- title: e,
66
- width: m,
67
- key: M,
68
- dataIndex: M,
69
- hidden: t || n,
70
- align: $ ?? (N.type === "number" ? "right" : void 0),
71
- render: mt(N)
72
- };
73
- }
74
- ),
75
- [u]
76
- ), [c, L] = J(), [V, w] = J(), [p, F] = J([]);
77
- st(() => {
78
- B && F(B);
79
- }, [B]), st(() => {
80
- B && L((t) => {
60
+ const { t: F } = qt(), a = I(
61
+ () => f.map(({ hideInTable: t, hidden: n, width: e, label: s, halign: v, ...j }) => {
62
+ const M = ct.getRealName(j.name);
63
+ return {
64
+ title: s,
65
+ width: e,
66
+ key: M,
67
+ dataIndex: M,
68
+ hidden: t || n,
69
+ align: v ?? (j.type === "number" ? "right" : void 0),
70
+ render: et(j)
71
+ };
72
+ }),
73
+ [f]
74
+ ), [u, L] = K(), [_, $] = K(), [T, b] = K([]);
75
+ mt(() => {
76
+ C && b(C);
77
+ }, [C]), mt(() => {
78
+ C && L((t) => {
81
79
  if (t)
82
- return B.find((n) => n[o] === t[o]);
80
+ return C.find((n) => n[o] === t[o]);
83
81
  });
84
- }, [B, o, c]);
85
- const _ = K(
82
+ }, [C, o, u]);
83
+ const q = Q(
86
84
  (t) => {
87
- var m;
88
- const n = C == null ? void 0 : C(t);
89
- return (Array.isArray(n) ? (m = n == null ? void 0 : n.filter(Boolean)) != null && m.length : n) || v || l || E || y ? /* @__PURE__ */ D(G, { children: [
85
+ var e;
86
+ const n = R == null ? void 0 : R(t);
87
+ return (Array.isArray(n) ? (e = n == null ? void 0 : n.filter(Boolean)) != null && e.length : n) || l || p || E || h ? /* @__PURE__ */ D(J, { children: [
90
88
  n,
91
- (v || l) && /* @__PURE__ */ s(
89
+ (l || p) && /* @__PURE__ */ m(
92
90
  zt,
93
91
  {
94
92
  value: t,
95
- onClick: (e) => {
96
- w(e[o]), l == null || l(t), W && L(void 0);
93
+ onClick: (s) => {
94
+ $(s[o]), p == null || p(t), W && L(void 0);
97
95
  }
98
96
  }
99
97
  ),
100
- E && /* @__PURE__ */ s(Et, { value: t, onClick: (e) => E(e) }),
101
- z && /* @__PURE__ */ s(
102
- Mt,
98
+ E && /* @__PURE__ */ m(Dt, { value: t, onClick: (s) => E(s) }),
99
+ V && /* @__PURE__ */ m(
100
+ Lt,
103
101
  {
104
102
  value: t,
105
- onClick: async (e) => await z(e)
103
+ onClick: async (s) => await V(s)
106
104
  }
107
105
  ),
108
- x && /* @__PURE__ */ s(
109
- Ot,
106
+ N && /* @__PURE__ */ m(
107
+ Mt,
110
108
  {
111
109
  value: t,
112
- disabled: S,
113
- shouldConfirm: k,
114
- loading: S && t[o] === V,
115
- onClick: async (e) => {
116
- w(e[o]), await x({ [o]: e[o] });
110
+ disabled: B,
111
+ shouldConfirm: H,
112
+ loading: B && t[o] === _,
113
+ onClick: async (s) => {
114
+ $(s[o]), await N({ [o]: s[o] });
117
115
  }
118
116
  }
119
117
  ),
120
- y && /* @__PURE__ */ s(
121
- Lt,
118
+ h && /* @__PURE__ */ m(
119
+ Et,
122
120
  {
123
121
  value: t,
124
- disabled: R,
125
- shouldConfirm: H,
126
- loading: R && t[o] === V,
127
- onClick: async (e) => {
128
- w(e[o]), await y({ [o]: e[o] });
122
+ disabled: x,
123
+ shouldConfirm: w,
124
+ loading: x && t[o] === _,
125
+ onClick: async (s) => {
126
+ $(s[o]), await h({ [o]: s[o] });
129
127
  }
130
128
  }
131
129
  )
@@ -133,117 +131,126 @@ function yo({
133
131
  },
134
132
  [
135
133
  W,
134
+ w,
136
135
  H,
137
- k,
138
- C,
139
- o,
140
136
  R,
141
- S,
137
+ o,
138
+ x,
139
+ B,
142
140
  E,
141
+ p,
142
+ h,
143
+ V,
144
+ N,
143
145
  l,
144
- y,
145
- z,
146
- x,
147
- v,
148
- V
146
+ _
149
147
  ]
150
- ), g = K(
148
+ ), g = Q(
151
149
  (t) => {
152
- var e;
153
- const { active: n, over: m } = t;
154
- if (r != null && r.onDragEnd && (r == null || r.onDragEnd(t)), n.id !== (m == null ? void 0 : m.id)) {
155
- const $ = p.findIndex(
150
+ var s;
151
+ const { active: n, over: e } = t;
152
+ if (r != null && r.onDragEnd && (r == null || r.onDragEnd(t)), n.id !== (e == null ? void 0 : e.id)) {
153
+ const v = T.findIndex(
156
154
  (i) => i[o] === n.id
157
- ), N = p.findIndex(
158
- (i) => i[o] === (m == null ? void 0 : m.id)
159
- ), M = et(p, $, N);
160
- F((i) => {
161
- const vt = i.findIndex(
162
- (q) => q[o] === (n == null ? void 0 : n.id)
163
- ), Tt = i.findIndex(
164
- (q) => q[o] === (m == null ? void 0 : m.id)
155
+ ), j = T.findIndex(
156
+ (i) => i[o] === (e == null ? void 0 : e.id)
157
+ ), M = st(T, v, j);
158
+ b((i) => {
159
+ const lt = i.findIndex(
160
+ (G) => G[o] === (n == null ? void 0 : n.id)
161
+ ), It = i.findIndex(
162
+ (G) => G[o] === (e == null ? void 0 : e.id)
165
163
  );
166
- return et(i, vt, Tt);
167
- }), (e = r == null ? void 0 : r.onDrag) == null || e.call(r, {
164
+ return st(i, lt, It);
165
+ }), (s = r == null ? void 0 : r.onDrag) == null || s.call(r, {
168
166
  newOrder: M.map((i) => i[o])
169
167
  });
170
168
  }
171
169
  },
172
- [p, o, r]
173
- ), lt = T(() => {
174
- let t = typeof f == "string" ? c == null ? void 0 : c[f] : void 0;
170
+ [T, o, r]
171
+ ), pt = I(() => {
172
+ let t = typeof c == "string" ? u == null ? void 0 : u[c] : void 0;
175
173
  if (typeof t == "object") {
176
- const n = u.find((m) => ct.getRealName(m.name) === f);
177
- t = mt(n)(
174
+ const n = f.find((e) => ct.getRealName(e.name) === c);
175
+ t = et(n)(
178
176
  t,
179
- c,
177
+ u,
180
178
  0
181
179
  );
182
180
  }
183
181
  return t;
184
- }, [f, c, u]), tt = T(
182
+ }, [c, u, f]), tt = I(
185
183
  () => ({
186
184
  rowClassName: U,
187
- className: X,
188
- scroll: Q ?? (O ? { y: `calc(100vh - ${O})` } : void 0),
185
+ className: Y,
186
+ scroll: X ?? (O ? { y: `calc(100vh - ${O})` } : void 0),
189
187
  id: "crud-table",
190
188
  bordered: A,
191
- size: Z,
192
- expandable: Y
189
+ size: k,
190
+ expandable: Z
193
191
  }),
194
- [U, X, Q, O, A, Z, Y]
195
- ), ot = T(
196
- () => h ? {
197
- total: h.count,
198
- onChange: h.setPage,
199
- current: h.page,
200
- pageSize: h.pageSize
192
+ [U, Y, X, O, A, k, Z]
193
+ ), ot = I(
194
+ () => y ? {
195
+ total: y.count,
196
+ onChange: y.setPage,
197
+ current: y.page,
198
+ pageSize: y.pageSize
201
199
  } : void 0,
202
- [h]
203
- ), nt = T(() => {
204
- const t = v || l || y || C || f, n = [];
200
+ [y]
201
+ ), nt = I(() => {
202
+ const t = l || p || h || R || c, n = [];
205
203
  return r && n.push({
206
204
  key: "key",
207
205
  align: "center",
208
206
  width: 5,
209
207
  title: r == null ? void 0 : r.columnLabel,
210
- render: () => /* @__PURE__ */ s(Xt, { tooltip: r == null ? void 0 : r.tooltip })
211
- }), n.push(...d), t && t && n.push({
212
- title: b("str.action"),
208
+ render: () => /* @__PURE__ */ m(Yt, { tooltip: r == null ? void 0 : r.tooltip })
209
+ }), n.push(...a), t && t && n.push({
210
+ title: F("str.action"),
213
211
  fixed: "right",
214
- width: a,
215
- render: (m, e) => /* @__PURE__ */ D(G, { children: [
216
- f && /* @__PURE__ */ s(Vt, { value: e, onClick: L }),
217
- _(e)
212
+ width: d,
213
+ render: (e, s) => /* @__PURE__ */ D(J, { children: [
214
+ c && /* @__PURE__ */ m(
215
+ Vt,
216
+ {
217
+ value: s,
218
+ onClick: typeof c == "object" ? () => {
219
+ var v;
220
+ return (v = c.onClick) == null ? void 0 : v.call(c, s);
221
+ } : L
222
+ }
223
+ ),
224
+ q(s)
218
225
  ] })
219
226
  }), n;
220
227
  }, [
221
- d,
222
- v,
223
- l,
224
- y,
225
- C,
226
- f,
227
- b,
228
228
  a,
229
- _
230
- ]), rt = T(
231
- () => p.map((t) => t[o]),
232
- [p, o]
233
- ), pt = K(() => {
234
- const t = /* @__PURE__ */ s(
235
- Qt,
229
+ l,
230
+ p,
231
+ h,
232
+ R,
233
+ c,
234
+ F,
235
+ d,
236
+ q
237
+ ]), rt = I(
238
+ () => T.map((t) => t[o]),
239
+ [T, o]
240
+ ), Tt = Q(() => {
241
+ const t = /* @__PURE__ */ m(
242
+ Xt,
236
243
  {
237
244
  ...tt,
238
- dataSource: p,
239
- loading: I,
240
- components: r ? { body: { row: Yt } } : void 0,
245
+ dataSource: T,
246
+ loading: S,
247
+ components: r ? { body: { row: Zt } } : void 0,
241
248
  pagination: ot,
242
249
  columns: nt
243
250
  }
244
251
  );
245
- return r ? /* @__PURE__ */ s(St, { modifiers: [Bt], onDragEnd: g, children: /* @__PURE__ */ s(
246
- Rt,
252
+ return r ? /* @__PURE__ */ m(Bt, { modifiers: [Ct], onDragEnd: g, children: /* @__PURE__ */ m(
253
+ vt,
247
254
  {
248
255
  items: rt,
249
256
  strategy: xt,
@@ -252,8 +259,8 @@ function yo({
252
259
  ) }) : t;
253
260
  }, [
254
261
  tt,
255
- p,
256
- I,
262
+ T,
263
+ S,
257
264
  ot,
258
265
  nt,
259
266
  r,
@@ -261,71 +268,71 @@ function yo({
261
268
  g
262
269
  ]);
263
270
  return /* @__PURE__ */ D("div", { children: [
264
- f && /* @__PURE__ */ s(
265
- It,
271
+ typeof c == "boolean" || typeof c == "string" && /* @__PURE__ */ m(
272
+ St,
266
273
  {
267
274
  width: "100%",
268
- open: !!c,
269
- title: lt ?? /* @__PURE__ */ s("div", { children: " " }),
270
- footer: /* @__PURE__ */ s(G, {}),
275
+ open: !!u,
276
+ title: pt ?? /* @__PURE__ */ m("div", { children: " " }),
277
+ footer: /* @__PURE__ */ m(J, {}),
271
278
  closable: !0,
272
279
  onCancel: () => L(void 0),
273
- children: !!c && /* @__PURE__ */ D("div", { children: [
274
- /* @__PURE__ */ s(
275
- Gt,
280
+ children: !!u && /* @__PURE__ */ D("div", { children: [
281
+ /* @__PURE__ */ m(
282
+ Jt,
276
283
  {
277
- layout: ht,
284
+ layout: yt,
278
285
  descListColumn: it,
279
- data: c,
280
- fields: u,
281
- action: _(c)
286
+ data: u,
287
+ fields: f,
288
+ action: q(u)
282
289
  }
283
290
  ),
284
- j == null ? void 0 : j(c)
285
- ] }, c == null ? void 0 : c[o])
291
+ z == null ? void 0 : z(u)
292
+ ] }, u == null ? void 0 : u[o])
286
293
  }
287
294
  ),
288
- /* @__PURE__ */ s(qt, { fields: u, ...yt }),
289
- /* @__PURE__ */ D(Kt, { children: [
290
- !!P && /* @__PURE__ */ s(jt, { onClick: P }),
291
- pt()
295
+ /* @__PURE__ */ m(Gt, { fields: f, ...ht }),
296
+ /* @__PURE__ */ D(Qt, { children: [
297
+ !!P && /* @__PURE__ */ m(Ot, { onClick: P }),
298
+ Tt()
292
299
  ] })
293
300
  ] });
294
301
  }
295
- const ft = ut.createContext({}), Xt = ({ tooltip: o }) => {
296
- const { setActivatorNodeRef: I, listeners: u } = _t(ft);
297
- return /* @__PURE__ */ s(
298
- Dt,
302
+ const ft = ut.createContext({}), Yt = ({ tooltip: o }) => {
303
+ const { setActivatorNodeRef: S, listeners: f } = $t(ft);
304
+ return /* @__PURE__ */ m(
305
+ jt,
299
306
  {
300
307
  type: "text",
301
308
  size: "small",
302
309
  tooltip: o,
303
- icon: /* @__PURE__ */ s(Jt, {}),
310
+ icon: /* @__PURE__ */ m(Kt, {}),
304
311
  style: { cursor: "move", border: "none" },
305
- ref: I,
306
- ...u
312
+ ref: S,
313
+ ...f
307
314
  }
308
315
  );
309
- }, Yt = (o) => {
316
+ }, Zt = (o) => {
310
317
  const {
311
- attributes: I,
312
- listeners: u,
313
- setNodeRef: R,
314
- setActivatorNodeRef: S,
315
- transform: f,
316
- transition: h,
317
- isDragging: y
318
- } = Nt({ id: o["data-row-key"] }), x = {
318
+ attributes: S,
319
+ listeners: f,
320
+ setNodeRef: x,
321
+ setActivatorNodeRef: B,
322
+ transform: c,
323
+ transition: y,
324
+ isDragging: h
325
+ } = Nt({ id: o["data-row-key"] }), N = {
319
326
  ...o.style,
320
- transform: Ct.Translate.toString(f),
321
- transition: h,
322
- ...y ? { position: "relative", zIndex: 9999 } : {}
323
- }, v = T(
324
- () => ({ setActivatorNodeRef: S, listeners: u }),
325
- [S, u]
327
+ transform: Rt.Translate.toString(c),
328
+ transition: y,
329
+ ...h ? { position: "relative", zIndex: 9999 } : {}
330
+ }, l = I(
331
+ () => ({ setActivatorNodeRef: B, listeners: f }),
332
+ [B, f]
326
333
  );
327
- return /* @__PURE__ */ s(ft.Provider, { value: v, children: /* @__PURE__ */ s("tr", { ...o, ref: R, style: x, ...I }) });
334
+ return /* @__PURE__ */ m(ft.Provider, { value: l, children: /* @__PURE__ */ m("tr", { ...o, ref: x, style: N, ...S }) });
328
335
  };
329
336
  export {
330
- yo as default
337
+ ho as default
331
338
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kingteza/crud-component",
3
3
  "private": false,
4
- "version": "1.0.63",
4
+ "version": "1.0.64",
5
5
  "description": "React CRUD component library with Ant Design",
6
6
  "keywords": [
7
7
  "react",