@kingteza/crud-component 1.5.0 → 1.6.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 i=require("react/jsx-runtime"),a=require("antd"),m=require("react"),L=require("../../locale/index.cjs.js"),M=require("../tooltip/TooltipComponent.cjs.js"),P=require("./TextField.cjs.js"),k=m.forwardRef(function({type:y,required:o,label:t,rules:c=[],placeholder:r,onEnter:x,form:f,nextFocus:q,min:d,moneyField:n,addonAfter:j,minLength:l,defaultValue:T,pattern:$,disabled:g,readOnly:h,onChange:I,value:N,max:R,addonBefore:w,size:B,isInt:p=!1,tooltip:E,help:z,...F},b){const{t:u}=L.useTranslationLib(),C=m.useMemo(()=>[...c,{required:o,message:`${t??r??""} ${u("err.validation.required")}`}],[c,t,r,u,o]);return i.jsx(M,{title:E,children:i.jsx(a.Form.Item,{...F,label:t,rules:C,children:i.jsx(a.InputNumber,{ref:b,disabled:g,defaultValue:T,value:N,readOnly:h,addonBefore:w,minLength:l,addonAfter:j,step:p?1:void 0,pattern:p?"d*":$,onChange:I,onPressEnter:e=>P.onEnterInternalTextField(e,q,f,x),className:"max-width",min:d===null?void 0:d??0,max:R,type:n?void 0:"number",size:B,formatter:n?e=>{if(e.includes(".")){const s=`${e}`.split(".");return s[0]=s[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),s.join(".")}else return`${e}`.replace(/\B(?=(\d{3})+(?!\d))/g,",")}:void 0,parser:n?e=>e==null?void 0:e.replace(/\$\s?|(,*)/g,""):void 0,placeholder:r??t})})})});module.exports=k;
1
+ "use strict";const i=require("react/jsx-runtime"),m=require("antd"),x=require("react"),M=require("../../locale/index.cjs.js"),P=require("../tooltip/TooltipComponent.cjs.js"),b=require("./TextField.cjs.js"),k=x.forwardRef(function({type:y,required:o,label:t,rules:c=[],placeholder:r,onEnter:a,form:f,nextFocus:q,min:d,moneyField:n,addonAfter:j,minLength:T,defaultValue:$,pattern:g,disabled:I,readOnly:N,onChange:R,value:h,max:w,addonBefore:B,size:E,isInt:u=!1,tooltip:F,help:z,...l},C){const{t:p}=M.useTranslationLib(),L=x.useMemo(()=>[...c,{required:o,message:`${t||r||""} ${p("err.validation.required")}`}],[c,t,r,p,o]);return i.jsx(P,{title:F,children:i.jsx(m.Form.Item,{...l,label:t,rules:L,children:i.jsx(m.InputNumber,{ref:C,disabled:I,defaultValue:$,value:h,readOnly:N,addonBefore:B,minLength:T,addonAfter:j,step:u?1:void 0,pattern:u?"d*":g,onChange:R,onPressEnter:e=>b.onEnterInternalTextField(e,q,f,a),className:"max-width",min:d===null?void 0:d??0,max:w,type:n?void 0:"number",size:E,formatter:n?e=>{if(e.includes(".")){const s=`${e}`.split(".");return s[0]=s[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),s.join(".")}else return`${e}`.replace(/\B(?=(\d{3})+(?!\d))/g,",")}:void 0,parser:n?e=>e==null?void 0:e.replace(/\$\s?|(,*)/g,""):void 0,placeholder:r??t})})})});module.exports=k;
@@ -1,10 +1,10 @@
1
1
  import { jsx as i } from "react/jsx-runtime";
2
- import { Form as L, InputNumber as M } from "antd";
3
- import { forwardRef as P, useMemo as R } from "react";
2
+ import { Form as M, InputNumber as P } from "antd";
3
+ import { forwardRef as R, useMemo as b } from "react";
4
4
  import { useTranslationLib as k } from "../../locale/index.es.js";
5
5
  import q from "../tooltip/TooltipComponent.es.js";
6
6
  import { onEnterInternalTextField as v } from "./TextField.es.js";
7
- const Q = P(
7
+ const Q = R(
8
8
  function({
9
9
  // eslint-disable-next-line no-unused-vars
10
10
  type: z,
@@ -17,54 +17,54 @@ const Q = P(
17
17
  nextFocus: u,
18
18
  min: p,
19
19
  moneyField: e,
20
- addonAfter: l,
21
- minLength: x,
22
- defaultValue: $,
23
- pattern: g,
24
- disabled: T,
25
- readOnly: h,
26
- onChange: I,
27
- value: N,
28
- max: j,
29
- addonBefore: w,
30
- size: B,
20
+ addonAfter: x,
21
+ minLength: $,
22
+ defaultValue: g,
23
+ pattern: T,
24
+ disabled: I,
25
+ readOnly: N,
26
+ onChange: h,
27
+ value: j,
28
+ max: w,
29
+ addonBefore: B,
30
+ size: E,
31
31
  isInt: d = !1,
32
- tooltip: E,
32
+ tooltip: l,
33
33
  help: A,
34
- ...b
35
- }, C) {
36
- const { t: f } = k(), F = R(
34
+ ...C
35
+ }, F) {
36
+ const { t: f } = k(), L = b(
37
37
  () => [
38
38
  ...m,
39
39
  {
40
40
  required: s,
41
- message: `${t ?? o ?? ""} ${f(
41
+ message: `${t || o || ""} ${f(
42
42
  "err.validation.required"
43
43
  )}`
44
44
  }
45
45
  ],
46
46
  [m, t, o, f, s]
47
47
  );
48
- return /* @__PURE__ */ i(q, { title: E, children: /* @__PURE__ */ i(L.Item, { ...b, label: t, rules: F, children: /* @__PURE__ */ i(
49
- M,
48
+ return /* @__PURE__ */ i(q, { title: l, children: /* @__PURE__ */ i(M.Item, { ...C, label: t, rules: L, children: /* @__PURE__ */ i(
49
+ P,
50
50
  {
51
- ref: C,
52
- disabled: T,
53
- defaultValue: $,
54
- value: N,
55
- readOnly: h,
56
- addonBefore: w,
57
- minLength: x,
58
- addonAfter: l,
51
+ ref: F,
52
+ disabled: I,
53
+ defaultValue: g,
54
+ value: j,
55
+ readOnly: N,
56
+ addonBefore: B,
57
+ minLength: $,
58
+ addonAfter: x,
59
59
  step: d ? 1 : void 0,
60
- pattern: d ? "d*" : g,
61
- onChange: I,
60
+ pattern: d ? "d*" : T,
61
+ onChange: h,
62
62
  onPressEnter: (r) => v(r, u, a, c),
63
63
  className: "max-width",
64
64
  min: p === null ? void 0 : p ?? 0,
65
- max: j,
65
+ max: w,
66
66
  type: e ? void 0 : "number",
67
- size: B,
67
+ size: E,
68
68
  formatter: e ? (r) => {
69
69
  if (r.includes(".")) {
70
70
  const n = `${r}`.split(".");
@@ -1 +1 @@
1
- "use strict";const e=require("react/jsx-runtime"),xt=require("antd"),ft=require("@dnd-kit/core"),jt=require("@dnd-kit/modifiers"),yt=require("@dnd-kit/utilities"),d=require("@dnd-kit/sortable"),ht=require("../../common/button/Button.cjs.js"),qt=require("../../common/button/RefreshButton.cjs.js"),Ct=require("../../common/button/ViewButtonTable.cjs.js"),St=require("../actions/index.cjs.js"),It=require("../../common/table/table.cjs.js"),r=require("react"),lt=require("../../locale/index.cjs.js"),Rt=require("../CrudSearchComponent.cjs.js"),Mt=require("./CrudDecListView.cjs.js"),tt=require("./CrudViewerUtil.cjs.js"),dt=require("@ant-design/icons"),et=require("../../util/CrudUtil.cjs.js"),Tt=require("../../common/layout/VerticalSpace.cjs.js"),Bt=r.memo(It);function Dt({idField:n="id",loadingData:h,fields:m,isDeleting:T,isHiding:l,viewable:c=!1,paginateProps:j,onDelete:q,onHide:B,onUpdate:C,data:S=[],extraAction:D,onClickUpdate:V,minusHeight:E,scroll:k,onClickClone:v,className:z,expandable:$,size:p,bordered:A,descListColumn:ot,extraView:L,decListLayout:st,scrollToTop:Et,onClickRefresh:_,closeViewOnClickUpdate:G,onExport:J,confirmHiding:K,confirmDeleting:Q,rowClassName:X,actionWidth:Y=190,draggable:t,...rt}){const{t:Z}=lt.useTranslationLib(),P=r.useMemo(()=>m.map(({hideInTable:o,hidden:s,width:u,label:x,halign:I,...M})=>{const N=et.getRealName(M.name);return{title:x,width:u,key:N,dataIndex:N,hidden:o||s,align:I??(M.type==="number"?"right":void 0),render:tt.getRendererValueCrudViewer(M)}}),[m]),[i,R]=r.useState(),[W,H]=r.useState(),[y,U]=r.useState([]);r.useEffect(()=>{S&&U(S)},[S]),r.useEffect(()=>{S&&R(o=>{if(o)return S.find(s=>s[n]===o[n])})},[S,n,i]);const w=r.useCallback(o=>{var x;const{active:s,over:u}=o;if(t!=null&&t.onDragEnd&&(t==null||t.onDragEnd(o)),s.id!==(u==null?void 0:u.id)){const I=y.findIndex(f=>f[n]===s.id),M=y.findIndex(f=>f[n]===(u==null?void 0:u.id)),N=d.arrayMove(y,I,M);U(f=>{const it=f.findIndex(O=>O[n]===(s==null?void 0:s.id)),mt=f.findIndex(O=>O[n]===(u==null?void 0:u.id));return d.arrayMove(f,it,mt)}),(x=t==null?void 0:t.onDrag)==null||x.call(t,{newOrder:N.map(f=>f[n])})}},[y,n,t]),ct=r.useMemo(()=>{let o=typeof c=="string"?i==null?void 0:i[c]:void 0;if(typeof o=="object"){const s=m.find(u=>et.getRealName(u.name)===c);o=tt.getRendererValueCrudViewer(s)(o,i,0)}return o},[c,i,m]),a=r.useMemo(()=>({rowClassName:X,className:z,scroll:k??(E?{y:`calc(100vh - ${E})`}:void 0),id:"crud-table",bordered:A,size:p,expandable:$}),[X,z,k,E,A,p,$]),F=r.useMemo(()=>j?{total:j.count,onChange:j.setPage,current:j.page,pageSize:j.pageSize}:void 0,[j]),b=r.useMemo(()=>{const o=C||V||q||D||c,s=[];return t&&s.push({key:"key",align:"center",width:5,title:t==null?void 0:t.columnLabel,render:()=>e.jsx(Vt,{tooltip:t==null?void 0:t.tooltip})}),s.push(...P),o&&o&&s.push({title:Z("str.action"),fixed:"right",width:Y,render:(u,x)=>e.jsxs(e.Fragment,{children:[c&&e.jsx(Ct,{value:x,onClick:typeof c=="object"?()=>{var I;return(I=c.onClick)==null?void 0:I.call(c,x)}:R}),e.jsx(St,{data:x,idField:n,extraAction:D,onUpdate:C,onClickUpdate:V,onClickClone:v,onDelete:q,onHide:B,onExport:J,isHiding:l,isDeleting:T,confirmHiding:K,confirmDeleting:Q,closeViewOnClickUpdate:G,recentUpdateOrDeleteId:W,setRecentUpdateOrDeleteId:H,setOpenView:R})]})}),s},[P,C,V,q,D,c,Z,Y]),g=r.useMemo(()=>y.map(o=>o[n]),[y,n]),ut=r.useCallback(()=>{const o=e.jsx(Bt,{...a,dataSource:y,loading:h,components:t?{body:{row:Nt}}:void 0,pagination:F,columns:b});return t?e.jsx(ft.DndContext,{modifiers:[jt.restrictToVerticalAxis],onDragEnd:w,children:e.jsx(d.SortableContext,{items:g,strategy:d.verticalListSortingStrategy,children:o})}):o},[a,y,h,F,b,t,g,w]);return e.jsxs("div",{children:[typeof c=="boolean"||typeof c=="string"&&e.jsx(xt.Modal,{width:"100%",open:!!i,title:ct??e.jsx("div",{children:" "}),footer:e.jsx(e.Fragment,{}),closable:!0,onCancel:()=>R(void 0),children:!!i&&e.jsxs("div",{children:[e.jsx(Mt.CrudDecListView,{layout:st,descListColumn:ot,data:i,fields:m,idField:n,extraAction:D,onUpdate:C,onClickUpdate:V,onClickClone:v,onDelete:q,onHide:B,onExport:J,isHiding:l,isDeleting:T,confirmHiding:K,confirmDeleting:Q,closeViewOnClickUpdate:G,recentUpdateOrDeleteId:W,setRecentUpdateOrDeleteId:H,setOpenView:R}),L==null?void 0:L(i)]},i==null?void 0:i[n])}),e.jsx(Rt,{fields:m,...rt}),e.jsxs(Tt,{children:[!!_&&e.jsx(qt.RefreshButton,{onClick:_}),ut()]})]})}const nt=r.createContext({}),Vt=({tooltip:n})=>{const{setActivatorNodeRef:h,listeners:m}=r.useContext(nt);return e.jsx(ht,{type:"text",size:"small",tooltip:n,icon:e.jsx(dt.HolderOutlined,{}),style:{cursor:"move",border:"none"},ref:h,...m})},Nt=n=>{const{attributes:h,listeners:m,setNodeRef:T,setActivatorNodeRef:l,transform:c,transition:j,isDragging:q}=d.useSortable({id:n["data-row-key"]}),B={...n.style,transform:yt.CSS.Translate.toString(c),transition:j,...q?{position:"relative",zIndex:9999}:{}},C=r.useMemo(()=>({setActivatorNodeRef:l,listeners:m}),[l,m]);return e.jsx(nt.Provider,{value:C,children:e.jsx("tr",{...n,ref:T,style:B,...h})})};module.exports=Dt;
1
+ "use strict";const e=require("react/jsx-runtime"),ft=require("antd"),jt=require("@dnd-kit/core"),yt=require("@dnd-kit/modifiers"),ht=require("@dnd-kit/utilities"),d=require("@dnd-kit/sortable"),qt=require("../../common/button/Button.cjs.js"),Ct=require("../../common/button/RefreshButton.cjs.js"),It=require("../../common/button/ViewButtonTable.cjs.js"),St=require("../actions/index.cjs.js"),Rt=require("../../common/table/table.cjs.js"),r=require("react"),lt=require("../../locale/index.cjs.js"),Mt=require("../CrudSearchComponent.cjs.js"),dt=require("./CrudDecListView.cjs.js"),et=require("./CrudViewerUtil.cjs.js"),Tt=require("@ant-design/icons"),nt=require("../../util/CrudUtil.cjs.js"),Bt=require("../../common/layout/VerticalSpace.cjs.js"),Dt=r.memo(Rt);function Vt({idField:n="id",loadingData:h,fields:m,isDeleting:T,isHiding:R,viewable:c=!1,paginateProps:j,onDelete:q,onHide:B,onUpdate:C,data:I=[],extraAction:D,onClickUpdate:V,minusHeight:E,scroll:k,onClickClone:v,className:z,expandable:$,size:p,bordered:A,descListColumn:st,extraView:L,decListLayout:rt,scrollToTop:Lt,onClickRefresh:_,closeViewOnClickUpdate:G,onExport:J,confirmHiding:K,confirmDeleting:Q,rowClassName:X,actionWidth:Y=190,draggable:t,rowSelection:Z,...ct}){const{t:P}=lt.useTranslationLib(),W=r.useMemo(()=>m.map(({hideInTable:o,hidden:s,width:u,label:x,halign:S,...M})=>{const N=nt.getRealName(M.name);return{title:x,width:u,key:N,dataIndex:N,hidden:o||s,align:S??(M.type==="number"?"right":void 0),render:et.getRendererValueCrudViewer(M)}}),[m]),[i,l]=r.useState(),[H,U]=r.useState(),[y,w]=r.useState([]);r.useEffect(()=>{I&&w(I)},[I]),r.useEffect(()=>{I&&l(o=>{if(o)return I.find(s=>s[n]===o[n])})},[I,n,i]);const a=r.useCallback(o=>{var x;const{active:s,over:u}=o;if(t!=null&&t.onDragEnd&&(t==null||t.onDragEnd(o)),s.id!==(u==null?void 0:u.id)){const S=y.findIndex(f=>f[n]===s.id),M=y.findIndex(f=>f[n]===(u==null?void 0:u.id)),N=d.arrayMove(y,S,M);w(f=>{const mt=f.findIndex(O=>O[n]===(s==null?void 0:s.id)),xt=f.findIndex(O=>O[n]===(u==null?void 0:u.id));return d.arrayMove(f,mt,xt)}),(x=t==null?void 0:t.onDrag)==null||x.call(t,{newOrder:N.map(f=>f[n])})}},[y,n,t]),ut=r.useMemo(()=>{let o=typeof c=="string"?i==null?void 0:i[c]:void 0;if(typeof o=="object"){const s=m.find(u=>nt.getRealName(u.name)===c);o=et.getRendererValueCrudViewer(s)(o,i,0)}return o},[c,i,m]),F=r.useMemo(()=>({rowSelection:Z,rowClassName:X,className:z,scroll:k??(E?{y:`calc(100vh - ${E})`}:void 0),id:"crud-table",bordered:A,size:p,expandable:$}),[Z,X,z,k,E,A,p,$]),b=r.useMemo(()=>j?{total:j.count,onChange:j.setPage,current:j.page,pageSize:j.pageSize}:void 0,[j]),g=r.useMemo(()=>{const o=C||V||q||D||c,s=[];return t&&s.push({key:"key",align:"center",width:5,title:t==null?void 0:t.columnLabel,render:()=>e.jsx(Nt,{tooltip:t==null?void 0:t.tooltip})}),s.push(...W),o&&o&&s.push({title:P("str.action"),fixed:"right",width:Y,render:(u,x)=>e.jsxs(e.Fragment,{children:[c&&e.jsx(It,{value:x,onClick:typeof c=="object"?()=>{var S;return(S=c.onClick)==null?void 0:S.call(c,x)}:l}),e.jsx(St,{data:x,idField:n,extraAction:D,onUpdate:C,onClickUpdate:V,onClickClone:v,onDelete:q,onHide:B,onExport:J,isHiding:R,isDeleting:T,confirmHiding:K,confirmDeleting:Q,closeViewOnClickUpdate:G,recentUpdateOrDeleteId:H,setRecentUpdateOrDeleteId:U,setOpenView:l})]})}),s},[W,C,V,q,D,c,P,Y]),tt=r.useMemo(()=>y.map(o=>o[n]),[y,n]),it=r.useCallback(()=>{const o=e.jsx(Dt,{...F,dataSource:y,loading:h,components:t?{body:{row:Et}}:void 0,pagination:b,columns:g});return t?e.jsx(jt.DndContext,{modifiers:[yt.restrictToVerticalAxis],onDragEnd:a,children:e.jsx(d.SortableContext,{items:tt,strategy:d.verticalListSortingStrategy,children:o})}):o},[F,y,h,b,g,t,tt,a]);return e.jsxs("div",{children:[typeof c=="boolean"||typeof c=="string"&&e.jsx(ft.Modal,{width:"100%",open:!!i,title:ut??e.jsx("div",{children:" "}),footer:e.jsx(e.Fragment,{}),closable:!0,onCancel:()=>l(void 0),children:!!i&&e.jsxs("div",{children:[e.jsx(dt.CrudDecListView,{layout:rt,descListColumn:st,data:i,fields:m,idField:n,extraAction:D,onUpdate:C,onClickUpdate:V,onClickClone:v,onDelete:q,onHide:B,onExport:J,isHiding:R,isDeleting:T,confirmHiding:K,confirmDeleting:Q,closeViewOnClickUpdate:G,recentUpdateOrDeleteId:H,setRecentUpdateOrDeleteId:U,setOpenView:l}),L==null?void 0:L(i)]},i==null?void 0:i[n])}),e.jsx(Mt,{fields:m,...ct}),e.jsxs(Bt,{children:[!!_&&e.jsx(Ct.RefreshButton,{onClick:_}),it()]})]})}const ot=r.createContext({}),Nt=({tooltip:n})=>{const{setActivatorNodeRef:h,listeners:m}=r.useContext(ot);return e.jsx(qt,{type:"text",size:"small",tooltip:n,icon:e.jsx(Tt.HolderOutlined,{}),style:{cursor:"move",border:"none"},ref:h,...m})},Et=n=>{const{attributes:h,listeners:m,setNodeRef:T,setActivatorNodeRef:R,transform:c,transition:j,isDragging:q}=d.useSortable({id:n["data-row-key"]}),B={...n.style,transform:ht.CSS.Translate.toString(c),transition:j,...q?{position:"relative",zIndex:9999}:{}},C=r.useMemo(()=>({setActivatorNodeRef:R,listeners:m}),[R,m]);return e.jsx(ot.Provider,{value:C,children:e.jsx("tr",{...n,ref:T,style:B,...h})})};module.exports=Vt;
@@ -7,6 +7,7 @@ import { default as React } from 'react';
7
7
  import { CrudFieldProps, CrudPaginateProps } from '../CrudComponent';
8
8
  import { CrudSearchComponentProps } from '../CrudSearchComponent';
9
9
  import { DescListColumn } from './CrudDecListView';
10
+ type TableRowSelection<T> = TableProps<T>['rowSelection'];
10
11
  export type CrudDragableProps<T> = {
11
12
  onDragEnd?: (event: DragEndEvent) => void;
12
13
  onDrag?: (params: {
@@ -32,6 +33,7 @@ export type CrudViewerProps<T, FormType> = {
32
33
  size?: SizeType;
33
34
  onClickRefresh?: () => void;
34
35
  expandable?: ExpandableConfig<T>;
36
+ rowSelection?: TableRowSelection<T>;
35
37
  descListColumn?: DescListColumn;
36
38
  extraView?: (t: T) => React.ReactElement;
37
39
  scrollToTop?: boolean;
@@ -39,5 +41,5 @@ export type CrudViewerProps<T, FormType> = {
39
41
  actionWidth?: string | number;
40
42
  draggable?: CrudDragableProps<T>;
41
43
  } & CrudActionsProps<T, FormType> & CrudSearchComponentProps<T, FormType>;
42
- declare function CrudViewer<T, FormType = T>({ 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, ...props }: CrudViewerProps<T, FormType>): import("react/jsx-runtime").JSX.Element;
44
+ declare function CrudViewer<T, FormType = T>({ 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;
43
45
  export default CrudViewer;
@@ -1,30 +1,30 @@
1
- import { jsx as e, jsxs as L, Fragment as ot } from "react/jsx-runtime";
2
- import { Modal as It } from "antd";
3
- import { DndContext as St } from "@dnd-kit/core";
4
- import { restrictToVerticalAxis as Tt } from "@dnd-kit/modifiers";
5
- import { CSS as Rt } from "@dnd-kit/utilities";
6
- import { arrayMove as nt, SortableContext as lt, verticalListSortingStrategy as Bt, useSortable as Dt } from "@dnd-kit/sortable";
7
- import Nt from "../../common/button/Button.es.js";
8
- import { RefreshButton as dt } from "../../common/button/RefreshButton.es.js";
9
- import jt from "../../common/button/ViewButtonTable.es.js";
10
- import Et from "../actions/index.es.js";
11
- import Lt from "../../common/table/table.es.js";
12
- import mt, { useMemo as h, useState as V, useEffect as rt, useCallback as et, useContext as Mt } from "react";
13
- import { useTranslationLib as Ot } from "../../locale/index.es.js";
14
- import zt from "../CrudSearchComponent.es.js";
15
- import { CrudDecListView as Vt } from "./CrudDecListView.es.js";
1
+ import { jsx as e, jsxs as L, Fragment as nt } from "react/jsx-runtime";
2
+ import { Modal as St } from "antd";
3
+ import { DndContext as Tt } from "@dnd-kit/core";
4
+ import { restrictToVerticalAxis as Rt } from "@dnd-kit/modifiers";
5
+ import { CSS as lt } from "@dnd-kit/utilities";
6
+ import { arrayMove as rt, SortableContext as Bt, verticalListSortingStrategy as Dt, useSortable as Nt } from "@dnd-kit/sortable";
7
+ import dt from "../../common/button/Button.es.js";
8
+ import { RefreshButton as jt } from "../../common/button/RefreshButton.es.js";
9
+ import Et from "../../common/button/ViewButtonTable.es.js";
10
+ import Lt from "../actions/index.es.js";
11
+ import Mt from "../../common/table/table.es.js";
12
+ import ut, { useMemo as h, useState as V, useEffect as et, useCallback as st, useContext as Ot } from "react";
13
+ import { useTranslationLib as zt } from "../../locale/index.es.js";
14
+ import Vt from "../CrudSearchComponent.es.js";
15
+ import { CrudDecListView as kt } from "./CrudDecListView.es.js";
16
16
  import { getRendererValueCrudViewer as ct } from "./CrudViewerUtil.es.js";
17
- import { HolderOutlined as kt } from "@ant-design/icons";
18
- import st from "../../util/CrudUtil.es.js";
19
- import vt from "../../common/layout/VerticalSpace.es.js";
20
- const At = mt.memo(Lt);
21
- function ro({
17
+ import { HolderOutlined as vt } from "@ant-design/icons";
18
+ import mt from "../../util/CrudUtil.es.js";
19
+ import At from "../../common/layout/VerticalSpace.es.js";
20
+ const _t = ut.memo(Mt);
21
+ function eo({
22
22
  idField: o = "id",
23
23
  loadingData: C,
24
24
  fields: u,
25
25
  isDeleting: D,
26
26
  isHiding: R,
27
- viewable: c = !1,
27
+ viewable: s = !1,
28
28
  paginateProps: p,
29
29
  onDelete: x,
30
30
  onHide: N,
@@ -39,10 +39,10 @@ function ro({
39
39
  expandable: _,
40
40
  size: $,
41
41
  bordered: q,
42
- descListColumn: ft,
42
+ descListColumn: it,
43
43
  extraView: O,
44
- decListLayout: it,
45
- scrollToTop: qt,
44
+ decListLayout: pt,
45
+ scrollToTop: Gt,
46
46
  onClickRefresh: G,
47
47
  closeViewOnClickUpdate: J,
48
48
  onExport: K,
@@ -51,14 +51,15 @@ function ro({
51
51
  rowClassName: Y,
52
52
  actionWidth: Z = 190,
53
53
  draggable: t,
54
- ...pt
54
+ rowSelection: P,
55
+ ...yt
55
56
  }) {
56
- const { t: P } = Ot(), W = h(
57
- () => u.map(({ hideInTable: n, hidden: r, width: s, label: f, halign: T, ...B }) => {
58
- const E = st.getRealName(B.name);
57
+ const { t: W } = zt(), H = h(
58
+ () => u.map(({ hideInTable: n, hidden: r, width: c, label: f, halign: T, ...B }) => {
59
+ const E = mt.getRealName(B.name);
59
60
  return {
60
61
  title: f,
61
- width: s,
62
+ width: c,
62
63
  key: E,
63
64
  dataIndex: E,
64
65
  hidden: n || r,
@@ -67,42 +68,42 @@ function ro({
67
68
  };
68
69
  }),
69
70
  [u]
70
- ), [m, l] = V(), [H, U] = V(), [y, w] = V([]);
71
- rt(() => {
72
- S && w(S);
73
- }, [S]), rt(() => {
71
+ ), [m, l] = V(), [U, w] = V(), [y, F] = V([]);
72
+ et(() => {
73
+ S && F(S);
74
+ }, [S]), et(() => {
74
75
  S && l((n) => {
75
76
  if (n)
76
77
  return S.find((r) => r[o] === n[o]);
77
78
  });
78
79
  }, [S, o, m]);
79
- const F = et(
80
+ const a = st(
80
81
  (n) => {
81
82
  var f;
82
- const { active: r, over: s } = n;
83
- if (t != null && t.onDragEnd && (t == null || t.onDragEnd(n)), r.id !== (s == null ? void 0 : s.id)) {
83
+ const { active: r, over: c } = n;
84
+ if (t != null && t.onDragEnd && (t == null || t.onDragEnd(n)), r.id !== (c == null ? void 0 : c.id)) {
84
85
  const T = y.findIndex(
85
86
  (i) => i[o] === r.id
86
87
  ), B = y.findIndex(
87
- (i) => i[o] === (s == null ? void 0 : s.id)
88
- ), E = nt(y, T, B);
89
- w((i) => {
90
- const Ct = i.findIndex(
88
+ (i) => i[o] === (c == null ? void 0 : c.id)
89
+ ), E = rt(y, T, B);
90
+ F((i) => {
91
+ const xt = i.findIndex(
91
92
  (z) => z[o] === (r == null ? void 0 : r.id)
92
- ), xt = i.findIndex(
93
- (z) => z[o] === (s == null ? void 0 : s.id)
93
+ ), It = i.findIndex(
94
+ (z) => z[o] === (c == null ? void 0 : c.id)
94
95
  );
95
- return nt(i, Ct, xt);
96
+ return rt(i, xt, It);
96
97
  }), (f = t == null ? void 0 : t.onDrag) == null || f.call(t, {
97
98
  newOrder: E.map((i) => i[o])
98
99
  });
99
100
  }
100
101
  },
101
102
  [y, o, t]
102
- ), yt = h(() => {
103
- let n = typeof c == "string" ? m == null ? void 0 : m[c] : void 0;
103
+ ), ht = h(() => {
104
+ let n = typeof s == "string" ? m == null ? void 0 : m[s] : void 0;
104
105
  if (typeof n == "object") {
105
- const r = u.find((s) => st.getRealName(s.name) === c);
106
+ const r = u.find((c) => mt.getRealName(c.name) === s);
106
107
  n = ct(r)(
107
108
  n,
108
109
  m,
@@ -110,8 +111,9 @@ function ro({
110
111
  );
111
112
  }
112
113
  return n;
113
- }, [c, m, u]), a = h(
114
+ }, [s, m, u]), b = h(
114
115
  () => ({
116
+ rowSelection: P,
115
117
  rowClassName: Y,
116
118
  className: A,
117
119
  scroll: k ?? (M ? { y: `calc(100vh - ${M})` } : void 0),
@@ -120,8 +122,8 @@ function ro({
120
122
  size: $,
121
123
  expandable: _
122
124
  }),
123
- [Y, A, k, M, q, $, _]
124
- ), b = h(
125
+ [P, Y, A, k, M, q, $, _]
126
+ ), g = h(
125
127
  () => p ? {
126
128
  total: p.count,
127
129
  onChange: p.setPage,
@@ -129,31 +131,31 @@ function ro({
129
131
  pageSize: p.pageSize
130
132
  } : void 0,
131
133
  [p]
132
- ), g = h(() => {
133
- const n = I || j || x || d || c, r = [];
134
+ ), tt = h(() => {
135
+ const n = I || j || x || d || s, r = [];
134
136
  return t && r.push({
135
137
  key: "key",
136
138
  align: "center",
137
139
  width: 5,
138
140
  title: t == null ? void 0 : t.columnLabel,
139
- render: () => /* @__PURE__ */ e(_t, { tooltip: t == null ? void 0 : t.tooltip })
140
- }), r.push(...W), n && n && r.push({
141
- title: P("str.action"),
141
+ render: () => /* @__PURE__ */ e($t, { tooltip: t == null ? void 0 : t.tooltip })
142
+ }), r.push(...H), n && n && r.push({
143
+ title: W("str.action"),
142
144
  fixed: "right",
143
145
  width: Z,
144
- render: (s, f) => /* @__PURE__ */ L(ot, { children: [
145
- c && /* @__PURE__ */ e(
146
- jt,
146
+ render: (c, f) => /* @__PURE__ */ L(nt, { children: [
147
+ s && /* @__PURE__ */ e(
148
+ Et,
147
149
  {
148
150
  value: f,
149
- onClick: typeof c == "object" ? () => {
151
+ onClick: typeof s == "object" ? () => {
150
152
  var T;
151
- return (T = c.onClick) == null ? void 0 : T.call(c, f);
153
+ return (T = s.onClick) == null ? void 0 : T.call(s, f);
152
154
  } : l
153
155
  }
154
156
  ),
155
157
  /* @__PURE__ */ e(
156
- Et,
158
+ Lt,
157
159
  {
158
160
  data: f,
159
161
  idField: o,
@@ -169,71 +171,71 @@ function ro({
169
171
  confirmHiding: Q,
170
172
  confirmDeleting: X,
171
173
  closeViewOnClickUpdate: J,
172
- recentUpdateOrDeleteId: H,
173
- setRecentUpdateOrDeleteId: U,
174
+ recentUpdateOrDeleteId: U,
175
+ setRecentUpdateOrDeleteId: w,
174
176
  setOpenView: l
175
177
  }
176
178
  )
177
179
  ] })
178
180
  }), r;
179
181
  }, [
180
- W,
182
+ H,
181
183
  I,
182
184
  j,
183
185
  x,
184
186
  d,
185
- c,
186
- P,
187
+ s,
188
+ W,
187
189
  Z
188
- ]), tt = h(
190
+ ]), ot = h(
189
191
  () => y.map((n) => n[o]),
190
192
  [y, o]
191
- ), ht = et(() => {
193
+ ), Ct = st(() => {
192
194
  const n = /* @__PURE__ */ e(
193
- At,
195
+ _t,
194
196
  {
195
- ...a,
197
+ ...b,
196
198
  dataSource: y,
197
199
  loading: C,
198
- components: t ? { body: { row: $t } } : void 0,
199
- pagination: b,
200
- columns: g
200
+ components: t ? { body: { row: qt } } : void 0,
201
+ pagination: g,
202
+ columns: tt
201
203
  }
202
204
  );
203
- return t ? /* @__PURE__ */ e(St, { modifiers: [Tt], onDragEnd: F, children: /* @__PURE__ */ e(
204
- lt,
205
+ return t ? /* @__PURE__ */ e(Tt, { modifiers: [Rt], onDragEnd: a, children: /* @__PURE__ */ e(
206
+ Bt,
205
207
  {
206
- items: tt,
207
- strategy: Bt,
208
+ items: ot,
209
+ strategy: Dt,
208
210
  children: n
209
211
  }
210
212
  ) }) : n;
211
213
  }, [
212
- a,
214
+ b,
213
215
  y,
214
216
  C,
215
- b,
216
217
  g,
217
- t,
218
218
  tt,
219
- F
219
+ t,
220
+ ot,
221
+ a
220
222
  ]);
221
223
  return /* @__PURE__ */ L("div", { children: [
222
- typeof c == "boolean" || typeof c == "string" && /* @__PURE__ */ e(
223
- It,
224
+ typeof s == "boolean" || typeof s == "string" && /* @__PURE__ */ e(
225
+ St,
224
226
  {
225
227
  width: "100%",
226
228
  open: !!m,
227
- title: yt ?? /* @__PURE__ */ e("div", { children: " " }),
228
- footer: /* @__PURE__ */ e(ot, {}),
229
+ title: ht ?? /* @__PURE__ */ e("div", { children: " " }),
230
+ footer: /* @__PURE__ */ e(nt, {}),
229
231
  closable: !0,
230
232
  onCancel: () => l(void 0),
231
233
  children: !!m && /* @__PURE__ */ L("div", { children: [
232
234
  /* @__PURE__ */ e(
233
- Vt,
235
+ kt,
234
236
  {
235
- layout: it,
236
- descListColumn: ft,
237
+ layout: pt,
238
+ descListColumn: it,
237
239
  data: m,
238
240
  fields: u,
239
241
  idField: o,
@@ -249,8 +251,8 @@ function ro({
249
251
  confirmHiding: Q,
250
252
  confirmDeleting: X,
251
253
  closeViewOnClickUpdate: J,
252
- recentUpdateOrDeleteId: H,
253
- setRecentUpdateOrDeleteId: U,
254
+ recentUpdateOrDeleteId: U,
255
+ setRecentUpdateOrDeleteId: w,
254
256
  setOpenView: l
255
257
  }
256
258
  ),
@@ -258,47 +260,47 @@ function ro({
258
260
  ] }, m == null ? void 0 : m[o])
259
261
  }
260
262
  ),
261
- /* @__PURE__ */ e(zt, { fields: u, ...pt }),
262
- /* @__PURE__ */ L(vt, { children: [
263
- !!G && /* @__PURE__ */ e(dt, { onClick: G }),
264
- ht()
263
+ /* @__PURE__ */ e(Vt, { fields: u, ...yt }),
264
+ /* @__PURE__ */ L(At, { children: [
265
+ !!G && /* @__PURE__ */ e(jt, { onClick: G }),
266
+ Ct()
265
267
  ] })
266
268
  ] });
267
269
  }
268
- const ut = mt.createContext({}), _t = ({ tooltip: o }) => {
269
- const { setActivatorNodeRef: C, listeners: u } = Mt(ut);
270
+ const ft = ut.createContext({}), $t = ({ tooltip: o }) => {
271
+ const { setActivatorNodeRef: C, listeners: u } = Ot(ft);
270
272
  return /* @__PURE__ */ e(
271
- Nt,
273
+ dt,
272
274
  {
273
275
  type: "text",
274
276
  size: "small",
275
277
  tooltip: o,
276
- icon: /* @__PURE__ */ e(kt, {}),
278
+ icon: /* @__PURE__ */ e(vt, {}),
277
279
  style: { cursor: "move", border: "none" },
278
280
  ref: C,
279
281
  ...u
280
282
  }
281
283
  );
282
- }, $t = (o) => {
284
+ }, qt = (o) => {
283
285
  const {
284
286
  attributes: C,
285
287
  listeners: u,
286
288
  setNodeRef: D,
287
289
  setActivatorNodeRef: R,
288
- transform: c,
290
+ transform: s,
289
291
  transition: p,
290
292
  isDragging: x
291
- } = Dt({ id: o["data-row-key"] }), N = {
293
+ } = Nt({ id: o["data-row-key"] }), N = {
292
294
  ...o.style,
293
- transform: Rt.Translate.toString(c),
295
+ transform: lt.Translate.toString(s),
294
296
  transition: p,
295
297
  ...x ? { position: "relative", zIndex: 9999 } : {}
296
298
  }, I = h(
297
299
  () => ({ setActivatorNodeRef: R, listeners: u }),
298
300
  [R, u]
299
301
  );
300
- return /* @__PURE__ */ e(ut.Provider, { value: I, children: /* @__PURE__ */ e("tr", { ...o, ref: D, style: N, ...C }) });
302
+ return /* @__PURE__ */ e(ft.Provider, { value: I, children: /* @__PURE__ */ e("tr", { ...o, ref: D, style: N, ...C }) });
301
303
  };
302
304
  export {
303
- ro as default
305
+ eo as default
304
306
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kingteza/crud-component",
3
3
  "private": false,
4
- "version": "1.5.0",
4
+ "version": "1.6.1",
5
5
  "description": "React CRUD component library with Ant Design",
6
6
  "keywords": [
7
7
  "react",