@kingteza/crud-component 1.0.45 → 1.0.47
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/App.d.ts +2 -0
- package/common/index.cjs.js +1 -1
- package/common/index.d.ts +1 -0
- package/common/index.es.js +70 -68
- package/common/rich/index.cjs.js +1 -0
- package/common/rich/index.d.ts +10 -0
- package/common/rich/index.es.js +64 -0
- package/crud/CrudComponent.d.ts +1 -12
- package/crud/CrudField.cjs.js +1 -1
- package/crud/CrudField.d.ts +2 -2
- package/crud/CrudField.es.js +251 -272
- package/crud/CrudForm.cjs.js +1 -1
- package/crud/CrudForm.d.ts +3 -3
- package/crud/CrudForm.es.js +71 -61
- package/crud/CrudFormWizard.cjs.js +1 -1
- package/crud/CrudFormWizard.d.ts +1 -1
- package/crud/CrudFormWizard.es.js +47 -47
- package/crud/CrudReportComponent.cjs.js +2 -2
- package/crud/CrudReportComponent.d.ts +1 -1
- package/crud/CrudReportComponent.es.js +33 -33
- package/crud/CrudSearchComponent.d.ts +1 -1
- package/crud/CrudTextAreaComponent.cjs.js +1 -0
- package/crud/CrudTextAreaComponent.d.ts +22 -0
- package/crud/CrudTextAreaComponent.es.js +51 -0
- package/crud/FileCrudField.cjs.js +1 -1
- package/crud/FileCrudField.d.ts +1 -1
- package/crud/FileCrudField.es.js +1 -2
- package/crud/ImageCrudField.cjs.js +1 -1
- package/crud/ImageCrudField.d.ts +1 -1
- package/crud/ImageCrudField.es.js +26 -26
- package/crud/index.d.ts +1 -1
- package/crud/view/CrudDecListView.d.ts +1 -1
- package/crud/view/CrudViewerUtil.cjs.js +1 -1
- package/crud/view/CrudViewerUtil.d.ts +1 -1
- package/crud/view/CrudViewerUtil.es.js +88 -58
- package/package.json +2 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { InitialCrudField } from './CrudComponent';
|
|
2
|
+
import { FormInstance } from 'antd/lib';
|
|
3
|
+
interface InitialTextAreaProps<T> extends InitialCrudField<T> {
|
|
4
|
+
type: "textarea";
|
|
5
|
+
onChange?: (value: string, form: FormInstance<T>) => void;
|
|
6
|
+
/**
|
|
7
|
+
* number of lines to show. If false will not show truncated
|
|
8
|
+
* @default 2
|
|
9
|
+
*/
|
|
10
|
+
truncated?: boolean | number;
|
|
11
|
+
}
|
|
12
|
+
interface TextAreaProps<T> extends InitialTextAreaProps<T> {
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
rows?: number;
|
|
15
|
+
cols?: number;
|
|
16
|
+
}
|
|
17
|
+
interface RichTextAreaProps<T> extends InitialTextAreaProps<T> {
|
|
18
|
+
rich?: true;
|
|
19
|
+
}
|
|
20
|
+
export type TextAreaBasedFieldProps<T> = TextAreaProps<T> & RichTextAreaProps<T>;
|
|
21
|
+
declare const CrudTextAreaComponent: <T>({ onChange, label, required, rules, name, updatable, ...props }: TextAreaBasedFieldProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export default CrudTextAreaComponent;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import C from "../common/text-field/TextArea.es.js";
|
|
3
|
+
import { RichTextEditor as T } from "../common/rich/index.es.js";
|
|
4
|
+
import { Form as h } from "antd";
|
|
5
|
+
const j = ({
|
|
6
|
+
onChange: t,
|
|
7
|
+
label: r,
|
|
8
|
+
required: e,
|
|
9
|
+
rules: i,
|
|
10
|
+
name: m,
|
|
11
|
+
updatable: s = !0,
|
|
12
|
+
...n
|
|
13
|
+
}) => {
|
|
14
|
+
const f = h.useFormInstance();
|
|
15
|
+
if (n.rich)
|
|
16
|
+
return /* @__PURE__ */ d(
|
|
17
|
+
T,
|
|
18
|
+
{
|
|
19
|
+
name: m,
|
|
20
|
+
label: r,
|
|
21
|
+
required: e,
|
|
22
|
+
rules: i,
|
|
23
|
+
disabled: !s
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
{
|
|
27
|
+
const { placeholder: p, rows: a, cols: l, fieldClassName: x, fieldTooltip: u } = n;
|
|
28
|
+
return /* @__PURE__ */ d(
|
|
29
|
+
C,
|
|
30
|
+
{
|
|
31
|
+
rules: i,
|
|
32
|
+
placeholder: p,
|
|
33
|
+
onChange: t ? (o) => {
|
|
34
|
+
var c;
|
|
35
|
+
return t((c = o == null ? void 0 : o.target) == null ? void 0 : c.value, f);
|
|
36
|
+
} : void 0,
|
|
37
|
+
tooltip: u,
|
|
38
|
+
required: e,
|
|
39
|
+
disabled: !s,
|
|
40
|
+
name: m,
|
|
41
|
+
label: r,
|
|
42
|
+
className: x,
|
|
43
|
+
rows: a,
|
|
44
|
+
cols: l
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
export {
|
|
50
|
+
j as default
|
|
51
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime");;/* empty css */const d=require("@ant-design/icons"),F=require("antd"),k=require("mime"),c=require("react"),B=require("../locale/index.cjs.js"),H=require("../util/ValidationUtil.cjs.js"),p=require("../common/button/Button.cjs.js"),z=require("../common/layout/VerticalSpace.cjs.js");function G({name:n,label:e,required:l,provider:s,onUploading:a,onRemoved:h,fieldClassName:j,accept:P,rules:U,maxCount:O=1,block:_,...$}){const f=F.Form.useFormInstance(),x=F.Form.useWatch(n,f),[b,q]=c.useState(!1),[V,N]=c.useState(!1),A=c.useCallback(async r=>{var i,u;try{const{file:o}=r,g=o.name;q(!0),N(!0),a==null||a(!0);const C=g??"",I=C.split("."),R=I[I.length-1],W=s.generateFileName(C),M=`${await s.getInitialPath()}/${W}.${R}`;console.log({filePath:M});const D=await s.upload({...o,originFileObj:o},M);a==null||a(!1),f.setFieldValue(n,D),(i=r.onSuccess)==null||i.call(r,D)}catch(o){(u=r.onError)==null||u.call(r,o)}finally{q(!1)}},[f,n,a,s]),[w,S]=c.useState([]);c.useEffect(()=>{!V&&x&&Promise.all((Array.isArray(x)?x:[x]).map(async r=>{const i=k.getType(r),u=r.split("/").pop(),o=await s.getRealUrl(r);return{uid:r,url:o,type:i,name:u}})).then(r=>S(()=>{const i=r.map(({url:u,type:o,uid:g,name:C})=>({uid:g,url:u,type:o,response:g,thumbUrl:u,name:C}));return console.log(i),i}))},[x,V,b,s]);const L=c.useCallback(async r=>{const i=r.response,u=i||f.getFieldValue(n);await s.delete(u),h==null||h(),r&&f.setFieldsValue({[n]:null})},[f,n,h,s]);return t.jsxs(F.Form.Item,{label:e,required:l,name:n,className:j,rules:[...l?H.required(e):[],...U??[]],children:[t.jsx("input",{hidden:!0}),t.jsx(F.Upload,{...$,fileList:w,className:((w==null?void 0:w.length)??0)>=O?"hide-upload":"",maxCount:O,customRequest:A,onRemove:L,listType:"picture",onChange:({fileList:r})=>{S(r)},style:_?{width:"100%"}:void 0,children:t.jsx(p,{loading:b,children:"Upload File"})})]})}const J=({provider:n,value:e})=>{const[l,s]=c.useState();return c.useEffect(()=>{e&&n.getRealUrl(e).then(a=>{s({mimeType:k.getType(e),url:a,fileName:e.split("/").pop()??e})})},[n,e]),l?t.jsx(E,{fileName:l.fileName,url:l==null?void 0:l.url,mimeType:l==null?void 0:l.mimeType}):t.jsx(t.Fragment,{})},E=({url:n,mimeType:e="",fileName:l})=>{const s=c.useMemo(()=>e!=null&&e.includes("image")?"image":e!=null&&e.includes("pdf")?"pdf":e!=null&&e.includes("word")?"word":e!=null&&e.includes("text")?"text":e!=null&&e.includes("presentation")?"presentation":e!=null&&e.includes("excel")||e!=null&&e.includes("spreadsheet")?"excel":"file",[e]),a=c.useMemo(()=>{switch(s){case"image":return t.jsx(d.FileImageOutlined,{});case"pdf":return t.jsx(d.FilePdfOutlined,{});case"word":return t.jsx(d.FileWordOutlined,{});case"text":return t.jsx(d.FileTextOutlined,{});case"excel":return t.jsx(d.FileExcelOutlined,{});case"presentation":return t.jsx(d.FilePptOutlined,{});default:return t.jsx(d.FileOutlined,{})}},[s]),[h,j]=c.useState(!1),{t:P}=B.useTranslationLib();return s!=="file"&&s!=="text"?t.jsxs(t.Fragment,{children:[t.jsx(F.Modal,{open:h,title:l,onCancel:()=>j(!1),footer:t.jsx(t.Fragment,{}),width:"100%",style:{top:"8px",minHeight:"700px"},destroyOnClose:!0,children:t.jsxs(z,{children:[t.jsx(p,{tooltip:l,icon:t.jsx(d.ExportOutlined,{}),target:"_blank",href:n,style:{textDecoration:"none"},children:P("str.openInNewTab")}),s==="image"?t.jsx("img",{src:n,alt:l,style:{width:"100%"}}):s==="pdf"?t.jsxs("iframe",{title:l,src:n,width:"100%",height:"700px",children:["This browser does not support PDFs. Please download the PDF to view it:",t.jsx("a",{href:n,children:"Download PDF"})
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime");;/* empty css */const d=require("@ant-design/icons"),F=require("antd"),k=require("mime"),c=require("react"),B=require("../locale/index.cjs.js"),H=require("../util/ValidationUtil.cjs.js"),p=require("../common/button/Button.cjs.js"),z=require("../common/layout/VerticalSpace.cjs.js");function G({name:n,label:e,required:l,provider:s,onUploading:a,onRemoved:h,fieldClassName:j,accept:P,rules:U,maxCount:O=1,block:_,...$}){const f=F.Form.useFormInstance(),x=F.Form.useWatch(n,f),[b,q]=c.useState(!1),[V,N]=c.useState(!1),A=c.useCallback(async r=>{var i,u;try{const{file:o}=r,g=o.name;q(!0),N(!0),a==null||a(!0);const C=g??"",I=C.split("."),R=I[I.length-1],W=s.generateFileName(C),M=`${await s.getInitialPath()}/${W}.${R}`;console.log({filePath:M});const D=await s.upload({...o,originFileObj:o},M);a==null||a(!1),f.setFieldValue(n,D),(i=r.onSuccess)==null||i.call(r,D)}catch(o){(u=r.onError)==null||u.call(r,o)}finally{q(!1)}},[f,n,a,s]),[w,S]=c.useState([]);c.useEffect(()=>{!V&&x&&Promise.all((Array.isArray(x)?x:[x]).map(async r=>{const i=k.getType(r),u=r.split("/").pop(),o=await s.getRealUrl(r);return{uid:r,url:o,type:i,name:u}})).then(r=>S(()=>{const i=r.map(({url:u,type:o,uid:g,name:C})=>({uid:g,url:u,type:o,response:g,thumbUrl:u,name:C}));return console.log(i),i}))},[x,V,b,s]);const L=c.useCallback(async r=>{const i=r.response,u=i||f.getFieldValue(n);await s.delete(u),h==null||h(),r&&f.setFieldsValue({[n]:null})},[f,n,h,s]);return t.jsxs(F.Form.Item,{label:e,required:l,name:n,className:j,rules:[...l?H.required(e):[],...U??[]],children:[t.jsx("input",{hidden:!0}),t.jsx(F.Upload,{...$,fileList:w,className:((w==null?void 0:w.length)??0)>=O?"hide-upload":"",maxCount:O,customRequest:A,onRemove:L,listType:"picture",onChange:({fileList:r})=>{S(r)},style:_?{width:"100%"}:void 0,children:t.jsx(p,{loading:b,children:"Upload File"})})]})}const J=({provider:n,value:e})=>{const[l,s]=c.useState();return c.useEffect(()=>{e&&n.getRealUrl(e).then(a=>{s({mimeType:k.getType(e),url:a,fileName:e.split("/").pop()??e})})},[n,e]),l?t.jsx(E,{fileName:l.fileName,url:l==null?void 0:l.url,mimeType:l==null?void 0:l.mimeType}):t.jsx(t.Fragment,{})},E=({url:n,mimeType:e="",fileName:l})=>{const s=c.useMemo(()=>e!=null&&e.includes("image")?"image":e!=null&&e.includes("pdf")?"pdf":e!=null&&e.includes("word")?"word":e!=null&&e.includes("text")?"text":e!=null&&e.includes("presentation")?"presentation":e!=null&&e.includes("excel")||e!=null&&e.includes("spreadsheet")?"excel":"file",[e]),a=c.useMemo(()=>{switch(s){case"image":return t.jsx(d.FileImageOutlined,{});case"pdf":return t.jsx(d.FilePdfOutlined,{});case"word":return t.jsx(d.FileWordOutlined,{});case"text":return t.jsx(d.FileTextOutlined,{});case"excel":return t.jsx(d.FileExcelOutlined,{});case"presentation":return t.jsx(d.FilePptOutlined,{});default:return t.jsx(d.FileOutlined,{})}},[s]),[h,j]=c.useState(!1),{t:P}=B.useTranslationLib();return s!=="file"&&s!=="text"?t.jsxs(t.Fragment,{children:[t.jsx(F.Modal,{open:h,title:l,onCancel:()=>j(!1),footer:t.jsx(t.Fragment,{}),width:"100%",style:{top:"8px",minHeight:"700px"},destroyOnClose:!0,children:t.jsxs(z,{children:[t.jsx(p,{tooltip:l,icon:t.jsx(d.ExportOutlined,{}),target:"_blank",href:n,style:{textDecoration:"none"},children:P("str.openInNewTab")}),s==="image"?t.jsx("img",{src:n,alt:l,style:{width:"100%"}}):s==="pdf"?t.jsxs("iframe",{title:l,src:n,width:"100%",height:"700px",children:["This browser does not support PDFs. Please download the PDF to view it:",t.jsx("a",{href:n,children:"Download PDF"})]}):t.jsxs("iframe",{title:l,src:`https://view.officeapps.live.com/op/view.aspx?src=${encodeURIComponent(n)}`,width:"100%",height:"700px",children:["This browser does not support open ",s.toUpperCase(),". Please download the",s.toUpperCase()," to view it:",t.jsxs("a",{href:n,children:["Download ",s.toUpperCase()]}),"."]})]})}),t.jsx(p,{tooltip:l,icon:a,shape:"circle",onClick:()=>j(!0)})]}):t.jsx(p,{tooltip:l,icon:a,target:"_blank",href:n,shape:"circle"})};exports.FileCellValue=E;exports.FileCrudCellValue=J;exports.default=G;
|
package/crud/FileCrudField.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export interface _FileCrudField<T> extends InitialCrudField<T> {
|
|
|
13
13
|
maxCount?: number;
|
|
14
14
|
block?: boolean;
|
|
15
15
|
}
|
|
16
|
-
export default function FileCrudFieldComponent<T>({ name, label, required, provider, onUploading, onRemoved, fieldClassName, accept, rules, maxCount, block, ...props }: _FileCrudField<T
|
|
16
|
+
export default function FileCrudFieldComponent<T>({ name, label, required, provider, onUploading, onRemoved, fieldClassName, accept, rules, maxCount, block, ...props }: Readonly<_FileCrudField<T>>): import("react/jsx-runtime").JSX.Element;
|
|
17
17
|
export declare const FileCrudCellValue: FC<{
|
|
18
18
|
value: string;
|
|
19
19
|
provider: FileDownloadProvider;
|
package/crud/FileCrudField.es.js
CHANGED
|
@@ -164,8 +164,7 @@ const pt = ({ provider: n, value: t }) => {
|
|
|
164
164
|
),
|
|
165
165
|
e === "image" ? /* @__PURE__ */ s("img", { src: n, alt: l, style: { width: "100%" } }) : e === "pdf" ? /* @__PURE__ */ f("iframe", { title: l, src: n, width: "100%", height: "700px", children: [
|
|
166
166
|
"This browser does not support PDFs. Please download the PDF to view it:",
|
|
167
|
-
/* @__PURE__ */ s("a", { href: n, children: "Download PDF" })
|
|
168
|
-
"."
|
|
167
|
+
/* @__PURE__ */ s("a", { href: n, children: "Download PDF" })
|
|
169
168
|
] }) : /* @__PURE__ */ f(
|
|
170
169
|
"iframe",
|
|
171
170
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var k=Object.defineProperty;var E=(e,a,t)=>a in e?k(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t;var F=(e,a,t)=>E(e,typeof a!="symbol"?a+"":a,t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";var k=Object.defineProperty;var E=(e,a,t)=>a in e?k(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t;var F=(e,a,t)=>E(e,typeof a!="symbol"?a+"":a,t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("react/jsx-runtime");;/* empty css */const p=require("@ant-design/icons"),n=require("antd"),q=require("path-browserify"),i=require("react"),A=require("../util/NumberUtil.cjs.js"),D=require("../util/ValidationUtil.cjs.js"),M=require("uuid"),T=require("../common/picker/ImagePicker.cjs.js");class w{}class W extends w{constructor(t="",s=""){super();F(this,"rootPath");F(this,"subPath");this.rootPath=t,this.subPath=s}cloneFilePath(t){const s=q.parse(t),l=`${s.name}_cloned_${A.default.randInt(1e5)}`;return q.format({dir:s.dir,ext:s.ext,name:l})}generateFileName(t){return`${t.split(".")[0]}_${M.v4().replace("-","")}`}}function z({name:e,label:a,required:t,provider:s,onUploading:l,aspectRatio:P,onRemoved:o,fieldClassName:N,hideLabel:V=!1,listType:g}){const c=n.Form.useFormInstance(),h=n.Form.useWatch(e,c),[I,y]=i.useState(!1),x=i.useCallback(async(r,$)=>{if($){l==null||l(!0);const f=r.name,m=f.split("."),b=m[m.length-1],S=s.generateFileName(f),_=`${await s.getInitialPath()}/${S}.${b}`,O=await s.upload(r,_);y(!0),l==null||l(!1),c.setFieldValue(e,O)}else{console.log(r);const f=c.getFieldsValue(),m=await s.delete(f[e]);o==null||o(),m&&c.setFieldsValue({[e]:null})}},[c,e,o,l,s]),[d,j]=i.useState();return i.useEffect(()=>{!I&&h?s.getRealUrl(h).then(j):j(d)},[h,I,s,d]),u.jsxs(n.Form.Item,{rules:t?D.required(a):[],label:V?null:a,required:t,name:e,children:[u.jsx(T.default,{noStyle:!0,listType:g,aspectRatio:P,values:d,onRemove:r=>{r&&x(r,!1)},onAdd:async r=>{r&&await x(r,!0)},className:N}),u.jsx(n.Input,{hidden:!0})]})}const B=({provider:e,value:a})=>{const[t,s]=i.useState();return i.useEffect(()=>{a&&e.getRealUrl(a).then(s)},[e,a]),t?u.jsx(C,{url:t}):u.jsx(u.Fragment,{})},C=({url:e})=>u.jsx(n.Avatar,{className:"p-0",children:u.jsx(n.Image,{className:"m-0 p-0 position-relative",src:e,preview:{mask:u.jsx(p.EyeOutlined,{})}})});exports.FileDownloadProvider=w;exports.FileUploadProvider=W;exports.ImageCellValue=C;exports.ImageCrudCellValue=B;exports.default=z;
|
package/crud/ImageCrudField.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare abstract class FileUploadProvider extends FileDownloadProvider {
|
|
|
28
28
|
abstract getRealUrl(filePath: string): Promise<string>;
|
|
29
29
|
generateFileName(initialFileName: string): string;
|
|
30
30
|
}
|
|
31
|
-
export default function ImageCrudFieldComponent<T>({ name, label, required, provider, onUploading, aspectRatio, onRemoved, fieldClassName, hideLabel, listType, }: _ImageCrudField<T
|
|
31
|
+
export default function ImageCrudFieldComponent<T>({ name, label, required, provider, onUploading, aspectRatio, onRemoved, fieldClassName, hideLabel, listType, }: Readonly<_ImageCrudField<T>>): import("react/jsx-runtime").JSX.Element;
|
|
32
32
|
export declare const ImageCrudCellValue: FC<{
|
|
33
33
|
value: string;
|
|
34
34
|
provider: FileDownloadProvider;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var h = (e, a, t) =>
|
|
4
|
-
import {
|
|
1
|
+
var j = Object.defineProperty;
|
|
2
|
+
var A = (e, a, t) => a in e ? j(e, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[a] = t;
|
|
3
|
+
var h = (e, a, t) => A(e, typeof a != "symbol" ? a + "" : a, t);
|
|
4
|
+
import { jsxs as E, jsx as n, Fragment as S } from "react/jsx-runtime";
|
|
5
5
|
/* empty css */
|
|
6
6
|
import { EyeOutlined as D } from "@ant-design/icons";
|
|
7
7
|
import { Form as F, Input as W, Avatar as q, Image as z } from "antd";
|
|
8
|
-
import
|
|
9
|
-
import { useState as P, useCallback as B, useEffect as
|
|
8
|
+
import d from "path-browserify";
|
|
9
|
+
import { useState as P, useCallback as B, useEffect as V } from "react";
|
|
10
10
|
import G from "../util/NumberUtil.es.js";
|
|
11
11
|
import H from "../util/ValidationUtil.es.js";
|
|
12
12
|
import { v4 as J } from "uuid";
|
|
@@ -21,8 +21,8 @@ class ae extends L {
|
|
|
21
21
|
this.rootPath = t, this.subPath = s;
|
|
22
22
|
}
|
|
23
23
|
cloneFilePath(t) {
|
|
24
|
-
const s =
|
|
25
|
-
return
|
|
24
|
+
const s = d.parse(t), l = `${s.name}_cloned_${G.randInt(1e5)}`;
|
|
25
|
+
return d.format({
|
|
26
26
|
dir: s.dir,
|
|
27
27
|
ext: s.ext,
|
|
28
28
|
name: l
|
|
@@ -40,16 +40,16 @@ function le({
|
|
|
40
40
|
onUploading: l,
|
|
41
41
|
aspectRatio: I,
|
|
42
42
|
onRemoved: c,
|
|
43
|
-
fieldClassName:
|
|
44
|
-
hideLabel:
|
|
45
|
-
listType:
|
|
43
|
+
fieldClassName: x,
|
|
44
|
+
hideLabel: y = !1,
|
|
45
|
+
listType: C
|
|
46
46
|
}) {
|
|
47
|
-
const i = F.useFormInstance(), u = F.useWatch(e, i), [p,
|
|
48
|
-
async (r,
|
|
49
|
-
if (
|
|
47
|
+
const i = F.useFormInstance(), u = F.useWatch(e, i), [p, $] = P(!1), N = B(
|
|
48
|
+
async (r, g) => {
|
|
49
|
+
if (g) {
|
|
50
50
|
l == null || l(!0);
|
|
51
|
-
const m = r.name, o = m.split("."),
|
|
52
|
-
|
|
51
|
+
const m = r.name, o = m.split("."), b = o[o.length - 1], k = s.generateFileName(m), O = `${await s.getInitialPath()}/${k}.${b}`, _ = await s.upload(r, O);
|
|
52
|
+
$(!0), l == null || l(!1), i.setFieldValue(e, _);
|
|
53
53
|
} else {
|
|
54
54
|
console.log(r);
|
|
55
55
|
const m = i.getFieldsValue(), o = await s.delete(m[e]);
|
|
@@ -57,14 +57,14 @@ function le({
|
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
59
|
[i, e, c, l, s]
|
|
60
|
-
), [f,
|
|
61
|
-
return
|
|
62
|
-
!p && u ? s.getRealUrl(u).then(
|
|
63
|
-
}, [u, p, s, f]), /* @__PURE__ */
|
|
60
|
+
), [f, w] = P();
|
|
61
|
+
return V(() => {
|
|
62
|
+
!p && u ? s.getRealUrl(u).then(w) : w(f);
|
|
63
|
+
}, [u, p, s, f]), /* @__PURE__ */ E(
|
|
64
64
|
F.Item,
|
|
65
65
|
{
|
|
66
66
|
rules: t ? H.required(a) : [],
|
|
67
|
-
label:
|
|
67
|
+
label: y ? null : a,
|
|
68
68
|
required: t,
|
|
69
69
|
name: e,
|
|
70
70
|
children: [
|
|
@@ -72,7 +72,7 @@ function le({
|
|
|
72
72
|
K,
|
|
73
73
|
{
|
|
74
74
|
noStyle: !0,
|
|
75
|
-
listType:
|
|
75
|
+
listType: C,
|
|
76
76
|
aspectRatio: I,
|
|
77
77
|
values: f,
|
|
78
78
|
onRemove: (r) => {
|
|
@@ -81,19 +81,19 @@ function le({
|
|
|
81
81
|
onAdd: async (r) => {
|
|
82
82
|
r && await N(r, !0);
|
|
83
83
|
},
|
|
84
|
-
className:
|
|
84
|
+
className: x
|
|
85
85
|
}
|
|
86
86
|
),
|
|
87
87
|
/* @__PURE__ */ n(W, { hidden: !0 })
|
|
88
88
|
]
|
|
89
89
|
}
|
|
90
|
-
)
|
|
90
|
+
);
|
|
91
91
|
}
|
|
92
92
|
const re = ({ provider: e, value: a }) => {
|
|
93
93
|
const [t, s] = P();
|
|
94
|
-
return
|
|
94
|
+
return V(() => {
|
|
95
95
|
a && e.getRealUrl(a).then(s);
|
|
96
|
-
}, [e, a]), t ? /* @__PURE__ */ n(M, { url: t }) : /* @__PURE__ */ n(
|
|
96
|
+
}, [e, a]), t ? /* @__PURE__ */ n(M, { url: t }) : /* @__PURE__ */ n(S, {});
|
|
97
97
|
}, M = ({ url: e }) => /* @__PURE__ */ n(q, { className: "p-0", children: /* @__PURE__ */ n(
|
|
98
98
|
z,
|
|
99
99
|
{
|
package/crud/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { CheckboxBasedFieldProps, ColorPickerFieldProps, CrudComponentProps, CrudFieldGrid, CrudFieldProps, CrudPaginateProps, CrudPurpose, CrudWizardProp, DateBasedFieldProps, EnumCrudField, FormBuilderFunc, FormBuilderFunc0, GetFormFieldOptions, InitialCrudField, NumberBasedFieldProps, ObjectCrudField, SelectCrudField, SelectFieldItem,
|
|
1
|
+
export type { CheckboxBasedFieldProps, ColorPickerFieldProps, CrudComponentProps, CrudFieldGrid, CrudFieldProps, CrudPaginateProps, CrudPurpose, CrudWizardProp, DateBasedFieldProps, EnumCrudField, FormBuilderFunc, FormBuilderFunc0, GetFormFieldOptions, InitialCrudField, NumberBasedFieldProps, ObjectCrudField, SelectCrudField, SelectFieldItem, TextBasedFieldProps, TimeBasedFieldProps, } from './CrudComponent';
|
|
2
2
|
export { default as CrudComponent } from './CrudComponent';
|
|
3
3
|
export { default as CrudField, ColorCrudFieldComponent, SelectCrudFieldComponent, } from './CrudField';
|
|
4
4
|
export { CrudForm, CrudFormFields } from './CrudForm';
|
|
@@ -11,4 +11,4 @@ export interface CrudDecListViewProps<T> {
|
|
|
11
11
|
action?: React.JSX.Element;
|
|
12
12
|
keepEmptyValues?: boolean;
|
|
13
13
|
}
|
|
14
|
-
export declare function CrudDecListView<T>({ className, fields, data, descListColumn, layout, action, keepEmptyValues, }: CrudDecListViewProps<T
|
|
14
|
+
export declare function CrudDecListView<T>({ className, fields, data, descListColumn, layout, action, keepEmptyValues, }: Readonly<CrudDecListViewProps<T>>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),C=require("@ant-design/icons"),d=require("antd"),A=require("../../common/show-more/index.cjs.js"),S=require("../FileCrudField.cjs.js"),T=require("../ImageCrudField.cjs.js"),m=require("../../util/DateUtil.cjs.js"),q=require("../../util/NumberUtil.cjs.js"),j=require("../../locale/index.cjs.js");function F({type:l,render:i,...a}){try{return l==="object"?(t,e,o)=>typeof i=="function"?i(t,e,o):"":l==="select"?(t,e,o)=>{const n=a,r=n.multiple?Array.isArray(t)?t.map(f=>f==null?void 0:f[n.innerFieldLabel??"name"]):void 0:t==null?void 0:t[n.innerFieldLabel??"name"];return typeof i=="function"?i(r,e,o):Array.isArray(r)?r.join(", "):r}:l==="number"?(t,e,o)=>typeof i=="function"?i(t,e,o):a!=null&&a.int?q.default.toInt(t,a.formatted):q.default.toMoney(t):l==="enum"?(t,e,o)=>{var y;const n=a;if(typeof i=="function")return i(t,e,o);if(n.multiple){const c=Array.isArray(t)?t:t?[t]:[];return typeof n.tagRender=="object"?u.jsx(d.Space,{wrap:!0,children:c.map((s,g)=>{var x,b;const v=(x=n.tagRender)==null?void 0:x[s],h=j.t(((b=n==null?void 0:n.translation)==null?void 0:b[s??""])??s);return v?u.jsx(d.Tag,{color:v.color,children:h},g+s):h})}):n!=null&&n.translation?c==null?void 0:c.map(s=>{var g;return j.t(((g=n==null?void 0:n.translation)==null?void 0:g[s??""])??s)}).join(", "):c==null?void 0:c.join(", ")}const r=((y=n==null?void 0:n.translation)==null?void 0:y[t??""])??t,f=j.t(r);if(typeof n.tagRender=="object"){const c=n.tagRender[t];if(c)return u.jsx(d.Tag,{color:c.color,children:f})}return f}:l==="date"?(t,e,o)=>{if(!t)return"-";const n=a!=null&&a.formatTime?m.formatDateTime(t):m.formatDate(t);return typeof i=="function"?i(t,e,o):n}:l==="checkbox"?(t,e,o)=>typeof i=="function"?i(t,e,o):t?u.jsx(C.CheckOutlined,{}):u.jsx(C.CloseOutlined,{}):l==="image"?(t,e,o)=>typeof i=="function"?i(t,e,o):u.jsx(T.ImageCrudCellValue,{value:t,provider:a.provider}):l==="file"?(t,e,o)=>typeof i=="function"?i(t,e,o):u.jsx(S.FileCrudCellValue,{value:t,provider:a.provider}):l==="time"?(t,e,o)=>{if(!t)return"-";const n=a==null?void 0:a.format,r=a==null?void 0:a.use12Hours,f=m.formatTime(t,n||(r?"hh:mm:ss A":void 0));return typeof i=="function"?i(t,e,o):f}:l==="color"?(t,e,o)=>typeof i=="function"?i(t,e,o):typeof t=="string"&&t.startsWith("#")?u.jsx(d.Tooltip,{title:t,children:u.jsx(d.Avatar,{style:{backgroundColor:t}})}):String(t):l==="textarea"?(t,e,o)=>{const n=a,r=n.truncated??1;return typeof i=="function"?i(t,e,o):r?u.jsx(A.ShowMore,{lines:r===!0?1:r,children:n.rich?u.jsx("div",{style:{all:"unset"},dangerouslySetInnerHTML:{__html:t}}):t}):n.rich?u.jsx("div",{style:{all:"unset"},dangerouslySetInnerHTML:{__html:t}}):t}:typeof i=="function"?i:(t,e,o)=>t}catch(t){return console.warn("An error occurred while rendering the value for field: "+String(a.name),t),"-"}}exports.getRendererValueCrudViewer=F;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { CrudFieldProps } from '../CrudComponent';
|
|
2
|
-
export declare function getRendererValueCrudViewer<T>({ type, render, ...props }: CrudFieldProps<T>):
|
|
2
|
+
export declare function getRendererValueCrudViewer<T>({ type, render, ...props }: CrudFieldProps<T>): any;
|
|
@@ -1,62 +1,92 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { CheckOutlined as
|
|
3
|
-
import { Tag as
|
|
4
|
-
import { ShowMore as
|
|
5
|
-
import { FileCrudCellValue as
|
|
6
|
-
import { ImageCrudCellValue as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { t as
|
|
10
|
-
function
|
|
11
|
-
type:
|
|
12
|
-
render:
|
|
13
|
-
...
|
|
1
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import { CheckOutlined as S, CloseOutlined as T } from "@ant-design/icons";
|
|
3
|
+
import { Space as w, Tag as C, Tooltip as R, Avatar as V } from "antd";
|
|
4
|
+
import { ShowMore as x } from "../../common/show-more/index.es.js";
|
|
5
|
+
import { FileCrudCellValue as F } from "../FileCrudField.es.js";
|
|
6
|
+
import { ImageCrudCellValue as H } from "../ImageCrudField.es.js";
|
|
7
|
+
import h from "../../util/DateUtil.es.js";
|
|
8
|
+
import j from "../../util/NumberUtil.es.js";
|
|
9
|
+
import { t as s } from "../../locale/index.es.js";
|
|
10
|
+
function N({
|
|
11
|
+
type: u,
|
|
12
|
+
render: n,
|
|
13
|
+
...r
|
|
14
14
|
}) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
15
|
+
try {
|
|
16
|
+
return u === "object" ? (t, i, a) => typeof n == "function" ? n(t, i, a) : "" : u === "select" ? (t, i, a) => {
|
|
17
|
+
const o = r, l = o.multiple ? Array.isArray(t) ? t.map((e) => e == null ? void 0 : e[o.innerFieldLabel ?? "name"]) : void 0 : t == null ? void 0 : t[o.innerFieldLabel ?? "name"];
|
|
18
|
+
return typeof n == "function" ? n(l, i, a) : Array.isArray(l) ? l.join(", ") : l;
|
|
19
|
+
} : u === "number" ? (t, i, a) => typeof n == "function" ? n(t, i, a) : r != null && r.int ? j.toInt(t, r.formatted) : j.toMoney(t) : u === "enum" ? (t, i, a) => {
|
|
20
|
+
var v;
|
|
21
|
+
const o = r;
|
|
22
|
+
if (typeof n == "function")
|
|
23
|
+
return n(t, i, a);
|
|
24
|
+
if (o.multiple) {
|
|
25
|
+
const f = Array.isArray(t) ? t : t ? [t] : [];
|
|
26
|
+
return typeof o.tagRender == "object" ? /* @__PURE__ */ c(w, { wrap: !0, children: f.map((m, g) => {
|
|
27
|
+
var b, A;
|
|
28
|
+
const y = (b = o.tagRender) == null ? void 0 : b[m], d = s(
|
|
29
|
+
((A = o == null ? void 0 : o.translation) == null ? void 0 : A[m ?? ""]) ?? m
|
|
30
|
+
);
|
|
31
|
+
return y ? /* @__PURE__ */ c(C, { color: y.color, children: d }, g + m) : d;
|
|
32
|
+
}) }) : o != null && o.translation ? f == null ? void 0 : f.map((m) => {
|
|
33
|
+
var g;
|
|
34
|
+
return s(((g = o == null ? void 0 : o.translation) == null ? void 0 : g[m ?? ""]) ?? m);
|
|
35
|
+
}).join(", ") : f == null ? void 0 : f.join(", ");
|
|
36
|
+
}
|
|
37
|
+
const l = ((v = o == null ? void 0 : o.translation) == null ? void 0 : v[t ?? ""]) ?? t, e = s(l);
|
|
38
|
+
if (typeof o.tagRender == "object") {
|
|
39
|
+
const f = o.tagRender[t];
|
|
40
|
+
if (f)
|
|
41
|
+
return /* @__PURE__ */ c(C, { color: f.color, children: e });
|
|
42
|
+
}
|
|
43
|
+
return e;
|
|
44
|
+
} : u === "date" ? (t, i, a) => {
|
|
45
|
+
if (!t) return "-";
|
|
46
|
+
const o = r != null && r.formatTime ? h.formatDateTime(t) : h.formatDate(t);
|
|
47
|
+
return typeof n == "function" ? n(t, i, a) : o;
|
|
48
|
+
} : u === "checkbox" ? (t, i, a) => typeof n == "function" ? n(t, i, a) : t ? /* @__PURE__ */ c(S, {}) : /* @__PURE__ */ c(T, {}) : u === "image" ? (t, i, a) => typeof n == "function" ? n(t, i, a) : /* @__PURE__ */ c(
|
|
49
|
+
H,
|
|
50
|
+
{
|
|
51
|
+
value: t,
|
|
52
|
+
provider: r.provider
|
|
53
|
+
}
|
|
54
|
+
) : u === "file" ? (t, i, a) => typeof n == "function" ? n(t, i, a) : /* @__PURE__ */ c(
|
|
55
|
+
F,
|
|
56
|
+
{
|
|
57
|
+
value: t,
|
|
58
|
+
provider: r.provider
|
|
59
|
+
}
|
|
60
|
+
) : u === "time" ? (t, i, a) => {
|
|
61
|
+
if (!t) return "-";
|
|
62
|
+
const o = r == null ? void 0 : r.format, l = r == null ? void 0 : r.use12Hours, e = h.formatTime(
|
|
63
|
+
t,
|
|
64
|
+
o || (l ? "hh:mm:ss A" : void 0)
|
|
65
|
+
);
|
|
66
|
+
return typeof n == "function" ? n(t, i, a) : e;
|
|
67
|
+
} : u === "color" ? (t, i, a) => typeof n == "function" ? n(t, i, a) : typeof t == "string" && t.startsWith("#") ? /* @__PURE__ */ c(R, { title: t, children: /* @__PURE__ */ c(V, { style: { backgroundColor: t } }) }) : String(t) : u === "textarea" ? (t, i, a) => {
|
|
68
|
+
const o = r, l = o.truncated ?? 1;
|
|
69
|
+
return typeof n == "function" ? n(t, i, a) : l ? /* @__PURE__ */ c(x, { lines: l === !0 ? 1 : l, children: o.rich ? /* @__PURE__ */ c(
|
|
70
|
+
"div",
|
|
71
|
+
{
|
|
72
|
+
style: { all: "unset" },
|
|
73
|
+
dangerouslySetInnerHTML: { __html: t }
|
|
74
|
+
}
|
|
75
|
+
) : t }) : o.rich ? /* @__PURE__ */ c(
|
|
76
|
+
"div",
|
|
77
|
+
{
|
|
78
|
+
style: { all: "unset" },
|
|
79
|
+
dangerouslySetInnerHTML: { __html: t }
|
|
80
|
+
}
|
|
81
|
+
) : t;
|
|
82
|
+
} : typeof n == "function" ? n : (t, i, a) => t;
|
|
83
|
+
} catch (t) {
|
|
84
|
+
return console.warn(
|
|
85
|
+
"An error occurred while rendering the value for field: " + String(r.name),
|
|
86
|
+
t
|
|
87
|
+
), "-";
|
|
88
|
+
}
|
|
59
89
|
}
|
|
60
90
|
export {
|
|
61
|
-
|
|
91
|
+
N as getRendererValueCrudViewer
|
|
62
92
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kingteza/crud-component",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.47",
|
|
5
5
|
"description": "React CRUD component library with Ant Design",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"react",
|
|
@@ -72,6 +72,7 @@
|
|
|
72
72
|
"react-cropper": "^2.3.3",
|
|
73
73
|
"react-highlight-words": "^0.20.0",
|
|
74
74
|
"react-i18next": "^15.2.0",
|
|
75
|
+
"react-quill": "^2.0.0",
|
|
75
76
|
"react-responsive": "^10.0.0",
|
|
76
77
|
"react-show-more-text": "^1.7.1",
|
|
77
78
|
"uuid": "^11.0.3"
|