@kingteza/crud-component 1.0.63 → 1.0.65
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.
- package/crud/CrudComponent.cjs.js +1 -1
- package/crud/CrudComponent.d.ts +2 -2
- package/crud/CrudComponent.es.js +96 -185
- package/crud/actions/index.cjs.js +1 -0
- package/crud/actions/index.d.ts +26 -0
- package/crud/actions/index.es.js +83 -0
- package/crud/index.d.ts +4 -0
- package/crud/modal/index.cjs.js +1 -0
- package/crud/modal/index.d.ts +24 -0
- package/crud/modal/index.es.js +146 -0
- package/crud/view/CrudDecListView.cjs.js +1 -1
- package/crud/view/CrudDecListView.d.ts +5 -4
- package/crud/view/CrudDecListView.es.js +38 -26
- package/crud/view/CrudViewer.cjs.js +1 -1
- package/crud/view/CrudViewer.d.ts +7 -17
- package/crud/view/CrudViewer.es.js +243 -270
- package/index.cjs.js +1 -1
- package/index.es.js +24 -20
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),d=require("../../common/description/DescList.cjs.js"),f=require("react"),j=require("../../locale/index.cjs.js"),V=require("./CrudViewerUtil.cjs.js"),p=require("../../util/CrudUtil.cjs.js"),v=require("../actions/index.cjs.js");function w({className:c,fields:n,data:e,descListColumn:m={xs:1,md:3,sm:2,lg:4},layout:b,keepEmptyValues:g,inBuiltModalProps:q,...s}){const{t:u}=j.useTranslationLib(),x=f.useMemo(()=>{const o=n.filter(({hidden:r,hideInDescList:i})=>!r&&!i).map((r,i)=>{const C=p.getRealName(r.name);return{label:r.label,noFormatting:!0,value:V.getRendererValueCrudViewer(r)(e==null?void 0:e[C],e,i)}}),l=e?t.jsx(v,{data:e,...s,inBuiltModalProps:q}):void 0;return l&&o.push({label:u("str.action"),value:l}),o},[e,n,u,s]);return e?t.jsx(d,{keepEmptyValues:g,bordered:!0,column:m,className:c,layout:b,list:x}):t.jsx(t.Fragment,{})}exports.CrudDecListView=w;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { Breakpoint } from 'antd';
|
|
2
|
-
import { default as React } from 'react';
|
|
3
2
|
import { CrudFieldProps } from '../CrudComponent';
|
|
3
|
+
import { CrudActionsProps } from '../actions';
|
|
4
|
+
import { CrudModalProps } from '../modal';
|
|
4
5
|
export type DescListColumn = number | Partial<Record<Breakpoint, number>> | undefined;
|
|
5
|
-
export interface CrudDecListViewProps<T> {
|
|
6
|
+
export interface CrudDecListViewProps<T, FormType = T> extends CrudActionsProps<T, FormType> {
|
|
6
7
|
fields: CrudFieldProps<T>[];
|
|
7
8
|
data: T | undefined;
|
|
8
9
|
className?: string;
|
|
9
10
|
descListColumn?: DescListColumn;
|
|
10
11
|
layout?: "horizontal" | "vertical";
|
|
11
|
-
action?: React.JSX.Element;
|
|
12
12
|
keepEmptyValues?: boolean;
|
|
13
|
+
inBuiltModalProps?: CrudModalProps<T, FormType>;
|
|
13
14
|
}
|
|
14
|
-
export declare function CrudDecListView<T>({ className, fields, data, descListColumn, layout,
|
|
15
|
+
export declare function CrudDecListView<T, FormType = T>({ className, fields, data, descListColumn, layout, keepEmptyValues, inBuiltModalProps, ...crudActionsProps }: Readonly<CrudDecListViewProps<T, FormType>>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,45 +1,57 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as t, Fragment as v } from "react/jsx-runtime";
|
|
2
2
|
import x from "../../common/description/DescList.es.js";
|
|
3
|
-
import { useMemo as
|
|
4
|
-
import { useTranslationLib as
|
|
5
|
-
import { getRendererValueCrudViewer as
|
|
6
|
-
import
|
|
7
|
-
|
|
3
|
+
import { useMemo as F } from "react";
|
|
4
|
+
import { useTranslationLib as L } from "../../locale/index.es.js";
|
|
5
|
+
import { getRendererValueCrudViewer as V } from "./CrudViewerUtil.es.js";
|
|
6
|
+
import w from "../../util/CrudUtil.es.js";
|
|
7
|
+
import D from "../actions/index.es.js";
|
|
8
|
+
function _({
|
|
8
9
|
className: u,
|
|
9
|
-
fields:
|
|
10
|
+
fields: i,
|
|
10
11
|
data: r,
|
|
11
|
-
descListColumn:
|
|
12
|
-
layout:
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
descListColumn: f = { xs: 1, md: 3, sm: 2, lg: 4 },
|
|
13
|
+
layout: p,
|
|
14
|
+
keepEmptyValues: c,
|
|
15
|
+
inBuiltModalProps: b,
|
|
16
|
+
...m
|
|
15
17
|
}) {
|
|
16
|
-
const { t:
|
|
17
|
-
const l =
|
|
18
|
-
const
|
|
18
|
+
const { t: n } = L(), g = F(() => {
|
|
19
|
+
const l = i.filter(({ hidden: e, hideInDescList: o }) => !e && !o).map((e, o) => {
|
|
20
|
+
const C = w.getRealName(e.name);
|
|
19
21
|
return {
|
|
20
22
|
label: e.label,
|
|
21
23
|
noFormatting: !0,
|
|
22
|
-
value:
|
|
23
|
-
r == null ? void 0 : r[
|
|
24
|
+
value: V(e)(
|
|
25
|
+
r == null ? void 0 : r[C],
|
|
24
26
|
r,
|
|
25
27
|
o
|
|
26
28
|
)
|
|
27
29
|
};
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
}), s = r ? /* @__PURE__ */ t(
|
|
31
|
+
D,
|
|
32
|
+
{
|
|
33
|
+
data: r,
|
|
34
|
+
...m,
|
|
35
|
+
inBuiltModalProps: b
|
|
36
|
+
}
|
|
37
|
+
) : void 0;
|
|
38
|
+
return s && l.push({
|
|
39
|
+
label: n("str.action"),
|
|
40
|
+
value: s
|
|
41
|
+
}), l;
|
|
42
|
+
}, [r, i, n, m]);
|
|
43
|
+
return r ? /* @__PURE__ */ t(
|
|
32
44
|
x,
|
|
33
45
|
{
|
|
34
|
-
keepEmptyValues:
|
|
46
|
+
keepEmptyValues: c,
|
|
35
47
|
bordered: !0,
|
|
36
|
-
column:
|
|
48
|
+
column: f,
|
|
37
49
|
className: u,
|
|
38
|
-
layout:
|
|
39
|
-
list:
|
|
50
|
+
layout: p,
|
|
51
|
+
list: g
|
|
40
52
|
}
|
|
41
|
-
) : /* @__PURE__ */
|
|
53
|
+
) : /* @__PURE__ */ t(v, {});
|
|
42
54
|
}
|
|
43
55
|
export {
|
|
44
|
-
|
|
56
|
+
_ as CrudDecListView
|
|
45
57
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
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;
|
|
@@ -2,8 +2,8 @@ import { SizeType } from 'antd/es/config-provider/SizeContext';
|
|
|
2
2
|
import { ExpandableConfig } from 'antd/es/table/interface';
|
|
3
3
|
import { DragEndEvent } from '@dnd-kit/core';
|
|
4
4
|
import { TableProps } from 'antd/lib';
|
|
5
|
-
import {
|
|
6
|
-
import { default as
|
|
5
|
+
import { CrudActionsProps } from '../actions';
|
|
6
|
+
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';
|
|
@@ -15,31 +15,21 @@ 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?:
|
|
24
|
+
viewable?: CrudViewableProps<T>;
|
|
22
25
|
paginateProps?: CrudPaginateProps;
|
|
23
|
-
onDelete?: (id: any) => Promise<any>;
|
|
24
|
-
confirmDeleting?: boolean;
|
|
25
|
-
confirmHiding?: boolean;
|
|
26
|
-
onHide?: (id: any) => Promise<any>;
|
|
27
|
-
onUpdate?: (t: FormType & IdProps) => Promise<any>;
|
|
28
|
-
onExport?: (t: T) => Promise<any>;
|
|
29
26
|
data: T[] | undefined;
|
|
30
|
-
extraAction?: (t: T) => ReactElement | undefined | ReactElement[];
|
|
31
|
-
onClickUpdate?: (t: T) => void;
|
|
32
|
-
closeViewOnClickUpdate?: boolean;
|
|
33
|
-
isHiding?: boolean;
|
|
34
|
-
isDeleting?: boolean;
|
|
35
|
-
idField?: string;
|
|
36
27
|
loadingData?: boolean;
|
|
37
28
|
minusHeight?: string;
|
|
38
29
|
scroll?: TableProps<T>["scroll"];
|
|
39
30
|
className?: string;
|
|
40
31
|
bordered?: boolean;
|
|
41
32
|
size?: SizeType;
|
|
42
|
-
onClickClone?: (t: T) => Promise<any>;
|
|
43
33
|
onClickRefresh?: () => void;
|
|
44
34
|
expandable?: ExpandableConfig<T>;
|
|
45
35
|
descListColumn?: DescListColumn;
|
|
@@ -48,6 +38,6 @@ export type CrudViewerProps<T, FormType> = {
|
|
|
48
38
|
rowClassName?: TableProps<T>["rowClassName"];
|
|
49
39
|
actionWidth?: string | number;
|
|
50
40
|
draggable?: CrudDragableProps<T>;
|
|
51
|
-
} & CrudSearchComponentProps<T, FormType>;
|
|
41
|
+
} & CrudActionsProps<T, FormType> & CrudSearchComponentProps<T, FormType>;
|
|
52
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;
|
|
53
43
|
export default CrudViewer;
|