@kingteza/crud-component 1.18.0 → 1.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";var O=Object.create;var j=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var z=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var L=(r,n,s,u)=>{if(n&&typeof n=="object"||typeof n=="function")for(let c of W(n))!K.call(r,c)&&c!==s&&j(r,c,{get:()=>n[c],enumerable:!(u=U(n,c))||u.enumerable});return r};var A=(r,n,s)=>(s=r!=null?O(z(r)):{},L(n||!r||!r.__esModule?j(s,"default",{value:r,enumerable:!0}):s,r));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react/jsx-runtime"),k=require("antd"),o=require("react"),D=require("../../util/ValidationUtil.cjs.js"),G=o.lazy(async()=>{const{default:r}=await import("react-quill"),{Quill:n}=r,s=n.import("blots/block");return s.tagName="div",n.register(s),{default:u=>g.jsx(r,{...u})}}),J=({formLayout:r,name:n,label:s,required:u,rules:c=[],disabled:v,help:F})=>{const d=k.Form.useFormInstance(),[m,x]=o.useState(""),T=o.useRef(!1),i="    ",f=t=>{if(!t)return"";if(typeof t=="string")return t;try{return String(t)}catch{return""}},H=()=>function(t){const e=this.quill,a=e.getSelection(!0);if(a){const b=a.index,S=a.index+a.length,Q=e.getText(),h=[];for(let l=b;l<=S;l++)(l===0||Q[l-1]===`
2
- `)&&h.push(l);if(h.length===0&&h.push(b),t>0){let l=0;h.forEach(p=>{e.insertText(p+l,i),l+=i.length}),e.setSelection(b+i.length,S+h.length*i.length)}else{let l=0;h.forEach(N=>{const R=N-l;e.getText(R,i.length)===i&&(e.deleteText(R,i.length),l+=i.length)});const p=Math.max(0,b-i.length),B=Math.max(p,S-l);e.setSelection(p,B)}}},w=()=>function(){const t=this.quill,e=t.getSelection(!0);return e?(t.insertText(e.index,i),t.setSelection(e.index+i.length),!1):!0},C=()=>function(){const t=this.quill,e=t.getSelection(!0);return e&&e.index>=i.length&&t.getText(e.index-i.length,i.length)===i?(t.deleteText(e.index-i.length,i.length),t.setSelection(e.index-i.length),!1):!0},V=o.useMemo(()=>{const t=H(),e=w(),a=C();return{toolbar:{container:[["bold","italic","underline","strike","blockquote"],[{list:"ordered"},{list:"bullet"}],[{indent:"-1"},{indent:"+1"}],["link"],["clean"]],handlers:{indent:t}},keyboard:{bindings:{tab:{key:"Tab",handler:e},"shift-tab":{key:"Tab",shiftKey:!0,handler:a}}}}},[]),q=o.useMemo(()=>["bold","italic","underline","strike","blockquote","list","bullet","link"],[]);o.useEffect(()=>{const t=d.getFieldValue(n),e=f(t);e&&e!=="<p></p>"&&e!=="<p><br></p>"&&e!=="<div></div>"&&x(e)},[d,n]);const y=k.Form.useWatch(n,d);o.useEffect(()=>{if(T.current)return;const t=f(y),e=f(m);t!==e&&x(!t||t==="<p></p>"||t==="<p><br></p>"||t==="<div></div>"?"":t)},[y]);const E=o.useCallback(t=>{const e=f(t);T.current=!0,x(e);const a=!e||e==="<p></p>"||e.trim()==="<p><br></p>"||e==="<div></div>"||e.trim()==="<div></div>"?void 0:e;d.setFieldValue(n,a),setTimeout(()=>{T.current=!1},0),d.validateFields([n]).catch(()=>{})},[d,n]),I=o.useMemo(()=>u?[...c,...D.required(s??"")]:c,[u,c,s]),M=o.useMemo(()=>f(m)||"",[m]),P=o.useMemo(()=>({readOnly:!!v,value:String(M||""),onChange:E,theme:"snow",className:"rich-text-editor",modules:V,formats:q}),[v,M,E,V,q]);return g.jsx(k.Form.Item,{help:F,name:n,label:s,rules:I,layout:r,children:g.jsx(o.Suspense,{fallback:g.jsx("div",{children:"Loading editor..."}),children:g.jsx(G,{...P})})})};exports.RichTextEditor=J;
1
+ "use strict";var O=Object.create;var j=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var z=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var L=(r,n,s,u)=>{if(n&&typeof n=="object"||typeof n=="function")for(let c of W(n))!K.call(r,c)&&c!==s&&j(r,c,{get:()=>n[c],enumerable:!(u=U(n,c))||u.enumerable});return r};var A=(r,n,s)=>(s=r!=null?O(z(r)):{},L(n||!r||!r.__esModule?j(s,"default",{value:r,enumerable:!0}):s,r));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react/jsx-runtime"),k=require("antd"),o=require("react"),D=require("../../util/ValidationUtil.cjs.js"),G=o.lazy(async()=>{const{default:r}=await import("react-quill"),{Quill:n}=r,s=n.import("blots/block");return s.tagName="div",n.register(s),{default:u=>g.jsx(r,{...u})}}),J=({formLayoutProps:r,name:n,label:s,required:u,rules:c=[],disabled:v,help:F})=>{const d=k.Form.useFormInstance(),[m,x]=o.useState(""),T=o.useRef(!1),i="    ",f=t=>{if(!t)return"";if(typeof t=="string")return t;try{return String(t)}catch{return""}},H=()=>function(t){const e=this.quill,a=e.getSelection(!0);if(a){const b=a.index,S=a.index+a.length,Q=e.getText(),h=[];for(let l=b;l<=S;l++)(l===0||Q[l-1]===`
2
+ `)&&h.push(l);if(h.length===0&&h.push(b),t>0){let l=0;h.forEach(p=>{e.insertText(p+l,i),l+=i.length}),e.setSelection(b+i.length,S+h.length*i.length)}else{let l=0;h.forEach(N=>{const R=N-l;e.getText(R,i.length)===i&&(e.deleteText(R,i.length),l+=i.length)});const p=Math.max(0,b-i.length),B=Math.max(p,S-l);e.setSelection(p,B)}}},w=()=>function(){const t=this.quill,e=t.getSelection(!0);return e?(t.insertText(e.index,i),t.setSelection(e.index+i.length),!1):!0},C=()=>function(){const t=this.quill,e=t.getSelection(!0);return e&&e.index>=i.length&&t.getText(e.index-i.length,i.length)===i?(t.deleteText(e.index-i.length,i.length),t.setSelection(e.index-i.length),!1):!0},V=o.useMemo(()=>{const t=H(),e=w(),a=C();return{toolbar:{container:[["bold","italic","underline","strike","blockquote"],[{list:"ordered"},{list:"bullet"}],[{indent:"-1"},{indent:"+1"}],["link"],["clean"]],handlers:{indent:t}},keyboard:{bindings:{tab:{key:"Tab",handler:e},"shift-tab":{key:"Tab",shiftKey:!0,handler:a}}}}},[]),q=o.useMemo(()=>["bold","italic","underline","strike","blockquote","list","bullet","link"],[]);o.useEffect(()=>{const t=d.getFieldValue(n),e=f(t);e&&e!=="<p></p>"&&e!=="<p><br></p>"&&e!=="<div></div>"&&x(e)},[d,n]);const y=k.Form.useWatch(n,d);o.useEffect(()=>{if(T.current)return;const t=f(y),e=f(m);t!==e&&x(!t||t==="<p></p>"||t==="<p><br></p>"||t==="<div></div>"?"":t)},[y]);const E=o.useCallback(t=>{const e=f(t);T.current=!0,x(e);const a=!e||e==="<p></p>"||e.trim()==="<p><br></p>"||e==="<div></div>"||e.trim()==="<div></div>"?void 0:e;d.setFieldValue(n,a),setTimeout(()=>{T.current=!1},0),d.validateFields([n]).catch(()=>{})},[d,n]),I=o.useMemo(()=>u?[...c,...D.required(s??"")]:c,[u,c,s]),M=o.useMemo(()=>f(m)||"",[m]),P=o.useMemo(()=>({readOnly:!!v,value:String(M||""),onChange:E,theme:"snow",className:"rich-text-editor",modules:V,formats:q}),[v,M,E,V,q]);return g.jsx(k.Form.Item,{help:F,name:n,label:s,rules:I,...r,children:g.jsx(o.Suspense,{fallback:g.jsx("div",{children:"Loading editor..."}),children:g.jsx(G,{...P})})})};exports.RichTextEditor=J;
@@ -1,5 +1,5 @@
1
1
  import { Rule } from 'antd/es/form';
2
- import { FormItemLayout } from 'antd/es/form/Form';
2
+ import { FormItemProps } from 'antd/lib';
3
3
  import { FC, ReactNode } from 'react';
4
4
  export interface RichTextEditorProps {
5
5
  help?: ReactNode;
@@ -8,6 +8,6 @@ export interface RichTextEditorProps {
8
8
  required?: boolean;
9
9
  rules?: Rule[];
10
10
  disabled?: boolean;
11
- formLayout?: FormItemLayout;
11
+ formLayoutProps?: Pick<FormItemProps, "layout" | 'labelCol' | 'wrapperCol'>;
12
12
  }
13
13
  export declare const RichTextEditor: FC<RichTextEditorProps>;
@@ -6,7 +6,7 @@ const A = W.lazy(async () => {
6
6
  const { default: h } = await import("react-quill"), { Quill: r } = h, o = r.import("blots/block");
7
7
  return o.tagName = "div", r.register(o), { default: (f) => /* @__PURE__ */ d(h, { ...f }) };
8
8
  }), Z = ({
9
- formLayout: h,
9
+ formLayoutProps: h,
10
10
  name: r,
11
11
  label: o,
12
12
  required: f,
@@ -79,7 +79,7 @@ const A = W.lazy(async () => {
79
79
  }
80
80
  }
81
81
  };
82
- }, []), y = u(() => [
82
+ }, []), q = u(() => [
83
83
  "bold",
84
84
  "italic",
85
85
  "underline",
@@ -93,13 +93,13 @@ const A = W.lazy(async () => {
93
93
  const e = s.getFieldValue(r), t = a(e);
94
94
  t && t !== "<p></p>" && t !== "<p><br></p>" && t !== "<div></div>" && g(t);
95
95
  }, [s, r]);
96
- const q = S.useWatch(r, s);
96
+ const y = S.useWatch(r, s);
97
97
  w(() => {
98
98
  if (T.current)
99
99
  return;
100
- const e = a(q), t = a(m);
100
+ const e = a(y), t = a(m);
101
101
  e !== t && g(!e || e === "<p></p>" || e === "<p><br></p>" || e === "<div></div>" ? "" : e);
102
- }, [q]);
102
+ }, [y]);
103
103
  const E = K((e) => {
104
104
  const t = a(e);
105
105
  T.current = !0, g(t);
@@ -118,9 +118,9 @@ const A = W.lazy(async () => {
118
118
  theme: "snow",
119
119
  className: "rich-text-editor",
120
120
  modules: v,
121
- formats: y
122
- }), [V, H, E, v, y]);
123
- return /* @__PURE__ */ d(S.Item, { help: C, name: r, label: o, rules: Q, layout: h, children: /* @__PURE__ */ d(L, { fallback: /* @__PURE__ */ d("div", { children: "Loading editor..." }), children: /* @__PURE__ */ d(A, { ...B }) }) });
121
+ formats: q
122
+ }), [V, H, E, v, q]);
123
+ return /* @__PURE__ */ d(S.Item, { help: C, name: r, label: o, rules: Q, ...h, children: /* @__PURE__ */ d(L, { fallback: /* @__PURE__ */ d("div", { children: "Loading editor..." }), children: /* @__PURE__ */ d(A, { ...B }) }) });
124
124
  };
125
125
  export {
126
126
  Z as RichTextEditor
@@ -1 +1 @@
1
- "use strict";const e=require("react/jsx-runtime"),q=require("antd"),n=require("react"),Q=require("./modal/index.cjs.js"),T=require("./import/CrudImportButton.cjs.js"),X=require("./view/CrudViewer.cjs.js"),Y=require("../common/button/NewButton.cjs.js"),Z=require("../common/button/PrintButton.cjs.js");function $({idField:x="id",onCreate:h,onDelete:N,onHide:v,onUpdate:t,onClickUpdate:d,fields:r,data:b,grid:g,isHiding:R,isCreating:y,isDeleting:B,isUpdating:M,paginateProps:S,onPrint:k,printing:I,viewable:O,loadingData:V,formBuilder:W,extraAction:_,minusHeight:w,cloneable:z,fullWidthModal:A=!0,wizard:D,extraView:E,importable:j,onClickNew:l,newButtonProps:c,size:F,headerRender:i,...G}){const a=n.useRef(null),H=n.useCallback(()=>{var s;(s=a.current)==null||s.create()},[]),o=n.useCallback(async(s,C=!0,L=!1)=>{var f;await((f=a.current)==null?void 0:f.update(s,C,L))},[]),J=n.useCallback(async s=>{o(s,!1,!0)},[o]),{onClick:p,...m}=n.useMemo(()=>c||{},[c]),u=n.useMemo(()=>e.jsx(Y.NewButton,{onClick:(s,C)=>{l?l():c!=null&&c.onClick?c.onClick(C):H()},className:"flex-1",...m}),[l,c,m]),K=n.useCallback(()=>i?i({newButton:u}):u,[u,i]);return e.jsxs(e.Fragment,{children:[e.jsxs(q.Space,{direction:"vertical",className:"w-100",children:[e.jsxs("div",{className:"w-100 d-flex",children:[e.jsx("div",{children:K()}),e.jsxs(q.Space,{children:[!!k&&e.jsx(Z.PrintButton,{className:"float-right",loading:I,onClick:k}),!!j&&e.jsx(T,{fields:r,importProps:j})]})]}),e.jsx(X,{...G,minusHeight:w,data:b,size:F,fields:r,extraAction:_,idField:x,isDeleting:B,loadingData:V,onClickUpdate:d||(t?o:void 0),onHide:v,isHiding:R,onDelete:N,onUpdate:t,onClickClone:z?J:void 0,paginateProps:S,viewable:O,extraView:E})]}),e.jsx(Q,{ref:a,fields:r,wizard:D,grid:g,fullWidthModal:A,isCreating:y,isUpdating:M,onCreate:h,onUpdate:t,idField:x,formBuilder:W})]})}module.exports=$;
1
+ "use strict";const e=require("react/jsx-runtime"),q=require("antd"),n=require("react"),T=require("./modal/index.cjs.js"),X=require("./import/CrudImportButton.cjs.js"),Y=require("./view/CrudViewer.cjs.js"),Z=require("../common/button/NewButton.cjs.js"),$=require("../common/button/PrintButton.cjs.js");function p({idField:x="id",onCreate:h,onDelete:N,onHide:v,onUpdate:t,onClickUpdate:d,fields:r,data:b,grid:g,isHiding:R,isCreating:y,isDeleting:B,isUpdating:M,paginateProps:S,onPrint:k,printing:I,viewable:O,loadingData:V,formBuilder:W,extraAction:_,minusHeight:w,scroll:z,cloneable:A,fullWidthModal:D=!0,wizard:E,extraView:F,importable:j,onClickNew:l,newButtonProps:c,size:G,headerRender:i,...H}){const a=n.useRef(null),J=n.useCallback(()=>{var s;(s=a.current)==null||s.create()},[]),o=n.useCallback(async(s,C=!0,Q=!1)=>{var f;await((f=a.current)==null?void 0:f.update(s,C,Q))},[]),K=n.useCallback(async s=>{o(s,!1,!0)},[o]),{onClick:U,...m}=n.useMemo(()=>c||{},[c]),u=n.useMemo(()=>e.jsx(Z.NewButton,{onClick:(s,C)=>{l?l():c!=null&&c.onClick?c.onClick(C):J()},className:"flex-1",...m}),[l,c,m]),L=n.useCallback(()=>i?i({newButton:u}):u,[u,i]);return e.jsxs(e.Fragment,{children:[e.jsxs(q.Space,{direction:"vertical",className:"w-100",children:[e.jsxs("div",{className:"w-100 d-flex",children:[e.jsx("div",{children:L()}),e.jsxs(q.Space,{children:[!!k&&e.jsx($.PrintButton,{className:"float-right",loading:I,onClick:k}),!!j&&e.jsx(X,{fields:r,importProps:j})]})]}),e.jsx(Y,{...H,minusHeight:w,scroll:z,data:b,size:G,fields:r,extraAction:_,idField:x,isDeleting:B,loadingData:V,onClickUpdate:d||(t?o:void 0),onHide:v,isHiding:R,onDelete:N,onUpdate:t,onClickClone:A?K:void 0,paginateProps:S,viewable:O,extraView:F})]}),e.jsx(T,{ref:a,fields:r,wizard:E,grid:g,fullWidthModal:D,isCreating:y,isUpdating:M,onCreate:h,onUpdate:t,idField:x,formBuilder:W})]})}module.exports=p;
@@ -1,6 +1,6 @@
1
1
  import { ButtonProps, ColorPickerProps } from 'antd';
2
2
  import { Rule } from 'antd/es/form';
3
- import { FormInstance, TablePaginationConfig } from 'antd/lib';
3
+ import { FormInstance, FormItemProps, TablePaginationConfig, TableProps } from 'antd/lib';
4
4
  import { Dayjs } from 'dayjs';
5
5
  import { default as React, ReactElement, ReactNode } from 'react';
6
6
  import { CrudSearchComponentProps } from './CrudSearchComponent';
@@ -14,14 +14,13 @@ import { TextAreaBasedFieldProps } from '.';
14
14
  import { SizeType } from 'antd/es/config-provider/SizeContext';
15
15
  import { Copyable } from 'src/util/CopyUtilComponent';
16
16
  import { ColumnType } from 'antd/es/table';
17
- import { FormItemLayout } from 'antd/es/form/Form';
18
17
  export type SelectFieldItem = {
19
18
  key?: string | number;
20
19
  value: string | number;
21
20
  disabled?: boolean;
22
21
  };
23
22
  export interface InitialCrudField<T> {
24
- formLayout?: FormItemLayout;
23
+ formLayoutProps?: Pick<FormItemProps, "layout" | 'labelCol' | 'wrapperCol'>;
25
24
  label: string;
26
25
  fieldHelper?: ReactNode;
27
26
  updatingValue?: T;
@@ -259,6 +258,7 @@ export type CrudComponentProps<T, FormType = T> = {
259
258
  paginateProps?: CrudPaginateProps;
260
259
  formBuilder?: FormBuilderFunc<T>;
261
260
  minusHeight?: string;
261
+ scroll?: TableProps<T>["scroll"];
262
262
  cloneable?: boolean;
263
263
  fullWidthModal?: boolean;
264
264
  wizard?: CrudWizardProp<T>[];
@@ -275,5 +275,5 @@ export type CrudComponentProps<T, FormType = T> = {
275
275
  newButton: JSX.Element;
276
276
  }) => React.ReactElement;
277
277
  } & CrudSearchComponentProps<T, FormType>;
278
- declare function CrudComponent<T, FormType = T>({ idField, onCreate, onDelete, onHide, onUpdate, onClickUpdate, fields, data, grid, isHiding, isCreating, isDeleting, isUpdating, paginateProps, onPrint, printing, viewable, loadingData, formBuilder, extraAction, minusHeight, cloneable, fullWidthModal, wizard, extraView, importable, onClickNew, newButtonProps, size, headerRender, ...props }: CrudComponentProps<T, FormType>): import("react/jsx-runtime").JSX.Element;
278
+ declare function CrudComponent<T, FormType = T>({ idField, onCreate, onDelete, onHide, onUpdate, onClickUpdate, fields, data, grid, isHiding, isCreating, isDeleting, isUpdating, paginateProps, onPrint, printing, viewable, loadingData, formBuilder, extraAction, minusHeight, scroll, cloneable, fullWidthModal, wizard, extraView, importable, onClickNew, newButtonProps, size, headerRender, ...props }: CrudComponentProps<T, FormType>): import("react/jsx-runtime").JSX.Element;
279
279
  export default CrudComponent;
@@ -1,12 +1,12 @@
1
- import { jsx as e, jsxs as l, Fragment as X } from "react/jsx-runtime";
1
+ import { jsx as e, jsxs as l, Fragment as Y } from "react/jsx-runtime";
2
2
  import { Space as x } from "antd";
3
- import { useRef as Y, useCallback as c, useMemo as N } from "react";
4
- import Z from "./modal/index.es.js";
5
- import $ from "./import/CrudImportButton.es.js";
6
- import w from "./view/CrudViewer.es.js";
7
- import { NewButton as U } from "../common/button/NewButton.es.js";
8
- import { PrintButton as P } from "../common/button/PrintButton.es.js";
9
- function mo({
3
+ import { useRef as Z, useCallback as c, useMemo as N } from "react";
4
+ import $ from "./modal/index.es.js";
5
+ import w from "./import/CrudImportButton.es.js";
6
+ import U from "./view/CrudViewer.es.js";
7
+ import { NewButton as P } from "../common/button/NewButton.es.js";
8
+ import { PrintButton as oo } from "../common/button/PrintButton.es.js";
9
+ function so({
10
10
  idField: C = "id",
11
11
  onCreate: g,
12
12
  onDelete: j,
@@ -28,67 +28,69 @@ function mo({
28
28
  formBuilder: z,
29
29
  extraAction: A,
30
30
  minusHeight: B,
31
- cloneable: D,
32
- fullWidthModal: E = !0,
33
- wizard: F,
34
- extraView: G,
31
+ scroll: D,
32
+ cloneable: E,
33
+ fullWidthModal: F = !0,
34
+ wizard: G,
35
+ extraView: H,
35
36
  importable: h,
36
37
  onClickNew: n,
37
38
  newButtonProps: o,
38
- size: H,
39
+ size: J,
39
40
  headerRender: a,
40
- ...J
41
+ ...K
41
42
  }) {
42
- const m = Y(null), K = c(() => {
43
+ const m = Z(null), L = c(() => {
43
44
  var r;
44
45
  (r = m.current) == null || r.create();
45
46
  }, []), s = c(
46
- async (r, u = !0, T = !1) => {
47
+ async (r, u = !0, X = !1) => {
47
48
  var v;
48
- await ((v = m.current) == null ? void 0 : v.update(r, u, T));
49
+ await ((v = m.current) == null ? void 0 : v.update(r, u, X));
49
50
  },
50
51
  []
51
- ), L = c(
52
+ ), Q = c(
52
53
  async (r) => {
53
54
  s(r, !1, !0);
54
55
  },
55
56
  [s]
56
- ), { onClick: oo, ...p } = N(() => o || {}, [o]), f = N(
57
+ ), { onClick: ro, ...p } = N(() => o || {}, [o]), f = N(
57
58
  () => /* @__PURE__ */ e(
58
- U,
59
+ P,
59
60
  {
60
61
  onClick: (r, u) => {
61
- n ? n() : o != null && o.onClick ? o.onClick(u) : K();
62
+ n ? n() : o != null && o.onClick ? o.onClick(u) : L();
62
63
  },
63
64
  className: "flex-1",
64
65
  ...p
65
66
  }
66
67
  ),
67
68
  [n, o, p]
68
- ), Q = c(() => a ? a({ newButton: f }) : f, [f, a]);
69
- return /* @__PURE__ */ l(X, { children: [
69
+ ), T = c(() => a ? a({ newButton: f }) : f, [f, a]);
70
+ return /* @__PURE__ */ l(Y, { children: [
70
71
  /* @__PURE__ */ l(x, { direction: "vertical", className: "w-100", children: [
71
72
  /* @__PURE__ */ l("div", { className: "w-100 d-flex", children: [
72
- /* @__PURE__ */ e("div", { children: Q() }),
73
+ /* @__PURE__ */ e("div", { children: T() }),
73
74
  /* @__PURE__ */ l(x, { children: [
74
75
  !!k && /* @__PURE__ */ e(
75
- P,
76
+ oo,
76
77
  {
77
78
  className: "float-right",
78
79
  loading: _,
79
80
  onClick: k
80
81
  }
81
82
  ),
82
- !!h && /* @__PURE__ */ e($, { fields: t, importProps: h })
83
+ !!h && /* @__PURE__ */ e(w, { fields: t, importProps: h })
83
84
  ] })
84
85
  ] }),
85
86
  /* @__PURE__ */ e(
86
- w,
87
+ U,
87
88
  {
88
- ...J,
89
+ ...K,
89
90
  minusHeight: B,
91
+ scroll: D,
90
92
  data: M,
91
- size: H,
93
+ size: J,
92
94
  fields: t,
93
95
  extraAction: A,
94
96
  idField: C,
@@ -99,21 +101,21 @@ function mo({
99
101
  isHiding: O,
100
102
  onDelete: j,
101
103
  onUpdate: i,
102
- onClickClone: D ? L : void 0,
104
+ onClickClone: E ? Q : void 0,
103
105
  paginateProps: W,
104
106
  viewable: b,
105
- extraView: G
107
+ extraView: H
106
108
  }
107
109
  )
108
110
  ] }),
109
111
  /* @__PURE__ */ e(
110
- Z,
112
+ $,
111
113
  {
112
114
  ref: m,
113
115
  fields: t,
114
- wizard: F,
116
+ wizard: G,
115
117
  grid: I,
116
- fullWidthModal: E,
118
+ fullWidthModal: F,
117
119
  isCreating: R,
118
120
  isUpdating: V,
119
121
  onCreate: g,
@@ -125,5 +127,5 @@ function mo({
125
127
  ] });
126
128
  }
127
129
  export {
128
- mo as default
130
+ so as default
129
131
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),j=require("antd"),q=require("react"),K=require("react-highlight-words"),Q=require("../locale/index.cjs.js"),V=require("./FileCrudField.cjs.js"),X=require("./ImageCrudField.cjs.js"),Y=require("../common/check-box/CheckBox.cjs.js"),Z=require("../common/date-picker/DatePicker.cjs.js"),ee=require("../common/date-picker/TimePicker.cjs.js"),_=require("../common/select/SelectComponent.cjs.js"),te=require("../common/text-field/NumberField.cjs.js"),re=require("../common/text-field/TextField.cjs.js"),le=require("../common/tooltip/TooltipComponent.cjs.js"),ae=require("./CrudTextAreaComponent.cjs.js"),U=require("../util/CrudUtil.cjs.js");function ne(N){const{label:n,name:c,type:b,required:s,hidden:O,rules:f=[],updatable:g=!0,readonly:S=!1,fieldClassName:m,customFormFieldRender:w,fieldTooltip:v,fieldHelper:p,formLayout:T,...e}=N,x=j.Form.useFormInstance();q.useEffect(()=>{if(b==="select"){const{items:l=[],onSearch:i,searchOnType:o}=e;!(l!=null&&l.length)&&!o&&(i==null||i(void 0,x,e==null?void 0:e.updatingValue))}},[x,e,b,e==null?void 0:e.updatingValue]);const{t:H}=Q.useTranslationLibNoNS();if(S||O)return t.jsx(t.Fragment,{});if(w)return w(x,N);switch(b){case"text":case"email":case"password":{const{onChange:l,placeholder:i,addonAfter:o,addonBefore:u}=e;return t.jsx(re.default,{layout:T,placeholder:i,disabled:!g,rules:f,required:s,onChange:l?C=>l(C,x):void 0,type:b,name:c,tooltip:v,label:n,className:m,autoComplete:"new-password",addonAfter:o,addonBefore:u,help:p})}case"number":{const{onChange:l,placeholder:i,allowMinus:o,min:u,max:C,addonAfter:h,addonBefore:y}=e;return t.jsx(te,{layout:T,placeholder:i,disabled:!g,moneyField:!!e.formatted,type:b,onChange:l?F=>l(F,x):void 0,rules:f,autoComplete:"false",required:s,tooltip:v,className:m,min:o?null:u,max:C,addonAfter:h,addonBefore:y,name:c,label:n,help:p})}case"date":{const{range:l,disableToday:i,disabledFutureDays:o,disabledPastDays:u,onChange:C,placeholder:h,format:y}=e;return t.jsx(Z,{layout:T,placeholder:h,required:s,disabled:!g,type:b,format:y,tooltip:v,range:l,name:c,label:n,onChange:C?F=>C(F,x):void 0,className:m,disableToday:i,disabledFutureDays:o,disabledPastDays:u,help:p})}case"time":{const{range:l=!1,disableCurrent:i,disabledFuture:o,disabledPast:u,onChange:C,use12Hours:h,format:y,placeholder:F}=e;return t.jsx(ee,{layout:T,placeholder:F,required:s,format:y,disabled:!g,type:b,tooltip:v,range:l,use12Hours:h,name:c,label:n,onChange:C?a=>C(a,x):void 0,className:m,disableCurrent:i,disabledFuture:o,disabledPast:u,help:p})}case"textarea":return t.jsx(ae,{...N});case"image":return t.jsx(X.default,{...e,required:s,name:c,label:n,rules:f,fieldHelper:p,fieldClassName:m,onRemoved:e.onRemoved,onUploading:e.onUploading,provider:e.provider});case"file":return t.jsx(V.default,{...e,required:s,name:c,label:n,rules:f,fieldHelper:p,fieldClassName:m,onRemoved:e.onRemoved,onUploading:e.onUploading,provider:e.provider});case"select":return t.jsx(D,{...e,required:s,name:c,label:n,rules:f,fieldClassName:m,form:x,help:p,updatable:g,readonly:S,fieldTooltip:v,fieldHelper:p});case"enum":{const{enum:l,radio:i=!1,translation:o,onChange:u,onSearch:C,multiple:h,tagRender:y}=e,F=Array.isArray(l)?l:Object.keys(l);return i?t.jsx(j.Form.Item,{...e,layout:T,name:c,required:s,tooltip:v,rules:f,label:n,className:["w-100",m].join(" "),help:p,children:t.jsx(j.Radio.Group,{...e,onChange:u?a=>{var k;return u((k=a==null?void 0:a.target)==null?void 0:k.value,x)}:void 0,children:F.map(a=>t.jsx(j.Radio,{disabled:!g,value:a,children:o?H(o[a]):a},a))})}):t.jsx(_,{...e,layout:T,tagRender:typeof y=="function"?y:y?a=>{const{value:k,label:R}=a,P=y[k];return P?t.jsx(j.Tag,{color:P.color,children:R}):t.jsx(j.Tag,{children:R})}:void 0,onChange:u?a=>u(a,x):void 0,className:["w-100",m].join(" "),name:c,items:F,required:s,tooltip:v,rules:f,label:n,help:p,disabled:!g,onSearch:C?a=>C(a,x):void 0,allowClear:!0,mode:h?"multiple":void 0,itemBuilder:a=>t.jsx(j.Select.Option,{value:a,children:o?H(o[a]):a},a)})}case"checkbox":{const{onChange:l,switch:i}=e;return t.jsx(Y,{layout:T,className:m,rules:f,onChange:l?o=>l(o,x):void 0,label:n,tooltip:v,disabled:!g,name:c,help:p,switch:i})}case"color":return t.jsx(W,{...e,type:"color",required:s,name:c,label:n,rules:f,fieldClassName:m,updatable:g,readonly:S,fieldTooltip:v,fieldHelper:p});default:return t.jsx(t.Fragment,{children:`${b} Not Implemented`})}}function D(N){const{items:n=[],loading:c,searchOnType:b,onSearch:s,multiple:O,onChange:f,highlightSearch:g,required:S,fieldClassName:m,rules:w,fieldTooltip:v,updatable:p,label:T,name:e,tagRender:x,updatingValue:H,onSet:l,placeholder:i,allowClear:o=!0,selectOptionRender:u,formLayout:C}=N,h=N.form,[y,F]=q.useState(""),a=q.useMemo(()=>U.getRealName(e),[e]),k=q.useMemo(()=>U.getRealName(e,"upsertFieldName"),[e]),R=j.Form.useWatch(a,h),[P,L]=q.useState(!0);q.useEffect(()=>{l&&P&&R&&(l==null||l(R,n,h),L(!1))},[P,h,n,a,l,R]),q.useEffect(()=>{R&&L(!0)},[R]);const G=q.useCallback(async r=>{F(r),b&&(s==null||s(r,h,H))},[h,s,b,H]),$=q.useCallback(r=>u?u(r):r.value,[u]);return t.jsx(_,{...N,layout:C,maxTagCount:"responsive",maxTagPlaceholder:r=>t.jsxs(le,{title:t.jsx(t.Fragment,{children:r.map(d=>t.jsxs(t.Fragment,{children:[d.label," ",t.jsx("br",{})]}))}),children:["+",r==null?void 0:r.length]}),placeholder:i,onSelect:r=>{l==null||l(r==null?void 0:r.key,n,h)},onChange:f?r=>{F(""),f(r,h)}:void 0,mode:O?"multiple":void 0,className:["w-100",m].join(" "),name:k,items:n,required:S,tooltip:v,tagRender:x,rules:w,disabled:!p,label:T,allowClear:o,onSearch:G,loading:c,filterOption:g?(r,d)=>{var A,B,E;try{const I=r.toLowerCase().split(/\s+/),z=((typeof(d==null?void 0:d.children)=="string"?d==null?void 0:d.children:(B=(A=d==null?void 0:d.children)==null?void 0:A.props)==null?void 0:B.textToHighlight)??"").toLowerCase(),J=(((E=d==null?void 0:d.value)==null?void 0:E.toString())??"").toLowerCase();return I.every(M=>z.indexOf(M)>=0||J.indexOf(M)>=0)}catch{return!0}}:void 0,itemBuilder:g?r=>{const d=r.value?String(r.value):void 0;return t.jsx(j.Select.Option,{value:r.key,title:d,disabled:r.disabled,children:t.jsx(K,{highlightClassName:"highlight-text",searchWords:(y??"").split(" "),autoEscape:!0,textToHighlight:d??""})},r.key)}:r=>t.jsx(j.Select.Option,{value:r.key,title:r.value,disabled:r.disabled,children:$(r)},r.key)})}function W(N){const{formLayout:n,required:c,fieldClassName:b,rules:s,fieldTooltip:O,updatable:f,label:g,name:S,fieldHelper:m}=N;return t.jsx(j.Form.Item,{layout:n,label:g,name:S,required:c,rules:s,tooltip:O,help:m,getValueFromEvent:w=>typeof w=="object"?w.toHexString():w,children:t.jsx(j.ColorPicker,{disabledAlpha:!0,format:"hex",defaultFormat:"hex",showText:!0,trigger:"click",className:b,disabled:!f,...N.innerProps})})}exports.ColorCrudFieldComponent=W;exports.SelectCrudFieldComponent=D;exports.default=ne;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("react/jsx-runtime"),v=require("antd"),q=require("react"),K=require("react-highlight-words"),Q=require("../locale/index.cjs.js"),V=require("./FileCrudField.cjs.js"),X=require("./ImageCrudField.cjs.js"),Y=require("../common/check-box/CheckBox.cjs.js"),Z=require("../common/date-picker/DatePicker.cjs.js"),ee=require("../common/date-picker/TimePicker.cjs.js"),_=require("../common/select/SelectComponent.cjs.js"),re=require("../common/text-field/NumberField.cjs.js"),te=require("../common/text-field/TextField.cjs.js"),le=require("../common/tooltip/TooltipComponent.cjs.js"),ae=require("./CrudTextAreaComponent.cjs.js"),U=require("../util/CrudUtil.cjs.js");function ne(N){const{label:n,name:c,type:b,required:o,hidden:O,rules:f=[],updatable:g=!0,readonly:S=!1,fieldClassName:m,customFormFieldRender:w,fieldTooltip:F,fieldHelper:p,formLayoutProps:T,...e}=N,x=v.Form.useFormInstance();q.useEffect(()=>{if(b==="select"){const{items:l=[],onSearch:i,searchOnType:s}=e;!(l!=null&&l.length)&&!s&&(i==null||i(void 0,x,e==null?void 0:e.updatingValue))}},[x,e,b,e==null?void 0:e.updatingValue]);const{t:P}=Q.useTranslationLibNoNS();if(S||O)return r.jsx(r.Fragment,{});if(w)return w(x,N);switch(b){case"text":case"email":case"password":{const{onChange:l,placeholder:i,addonAfter:s,addonBefore:u}=e;return r.jsx(te.default,{...T,placeholder:i,disabled:!g,rules:f,required:o,onChange:l?C=>l(C,x):void 0,type:b,name:c,tooltip:F,label:n,className:m,autoComplete:"new-password",addonAfter:s,addonBefore:u,help:p})}case"number":{const{onChange:l,placeholder:i,allowMinus:s,min:u,max:C,addonAfter:h,addonBefore:j}=e;return r.jsx(re,{...T,placeholder:i,disabled:!g,moneyField:!!e.formatted,type:b,onChange:l?y=>l(y,x):void 0,rules:f,autoComplete:"false",required:o,tooltip:F,className:m,min:s?null:u,max:C,addonAfter:h,addonBefore:j,name:c,label:n,help:p})}case"date":{const{range:l,disableToday:i,disabledFutureDays:s,disabledPastDays:u,onChange:C,placeholder:h,format:j}=e;return r.jsx(Z,{...T,placeholder:h,required:o,disabled:!g,type:b,format:j,tooltip:F,range:l,name:c,label:n,onChange:C?y=>C(y,x):void 0,className:m,disableToday:i,disabledFutureDays:s,disabledPastDays:u,help:p})}case"time":{const{range:l=!1,disableCurrent:i,disabledFuture:s,disabledPast:u,onChange:C,use12Hours:h,format:j,placeholder:y}=e;return r.jsx(ee,{...T,placeholder:y,required:o,format:j,disabled:!g,type:b,tooltip:F,range:l,use12Hours:h,name:c,label:n,onChange:C?a=>C(a,x):void 0,className:m,disableCurrent:i,disabledFuture:s,disabledPast:u,help:p})}case"textarea":return r.jsx(ae,{...N});case"image":return r.jsx(X.default,{...e,required:o,name:c,label:n,rules:f,fieldHelper:p,fieldClassName:m,onRemoved:e.onRemoved,onUploading:e.onUploading,provider:e.provider});case"file":return r.jsx(V.default,{...e,required:o,name:c,label:n,rules:f,fieldHelper:p,fieldClassName:m,onRemoved:e.onRemoved,onUploading:e.onUploading,provider:e.provider});case"select":return r.jsx(D,{...e,required:o,name:c,label:n,rules:f,fieldClassName:m,form:x,help:p,updatable:g,readonly:S,fieldTooltip:F,fieldHelper:p});case"enum":{const{enum:l,radio:i=!1,translation:s,onChange:u,onSearch:C,multiple:h,tagRender:j}=e,y=Array.isArray(l)?l:Object.keys(l);return i?r.jsx(v.Form.Item,{...e,...T,name:c,required:o,tooltip:F,rules:f,label:n,className:["w-100",m].join(" "),help:p,children:r.jsx(v.Radio.Group,{...e,onChange:u?a=>{var k;return u((k=a==null?void 0:a.target)==null?void 0:k.value,x)}:void 0,children:y.map(a=>r.jsx(v.Radio,{disabled:!g,value:a,children:s?P(s[a]):a},a))})}):r.jsx(_,{...e,...T,tagRender:typeof j=="function"?j:j?a=>{const{value:k,label:R}=a,H=j[k];return H?r.jsx(v.Tag,{color:H.color,children:R}):r.jsx(v.Tag,{children:R})}:void 0,onChange:u?a=>u(a,x):void 0,className:["w-100",m].join(" "),name:c,items:y,required:o,tooltip:F,rules:f,label:n,help:p,disabled:!g,onSearch:C?a=>C(a,x):void 0,allowClear:!0,mode:h?"multiple":void 0,itemBuilder:a=>r.jsx(v.Select.Option,{value:a,children:s?P(s[a]):a},a)})}case"checkbox":{const{onChange:l,switch:i}=e;return r.jsx(Y,{...T,className:m,rules:f,onChange:l?s=>l(s,x):void 0,label:n,tooltip:F,disabled:!g,name:c,help:p,switch:i})}case"color":return r.jsx(W,{...e,type:"color",required:o,name:c,label:n,rules:f,fieldClassName:m,updatable:g,readonly:S,fieldTooltip:F,fieldHelper:p});default:return r.jsx(r.Fragment,{children:`${b} Not Implemented`})}}function D(N){const{items:n=[],loading:c,searchOnType:b,onSearch:o,multiple:O,onChange:f,highlightSearch:g,required:S,fieldClassName:m,rules:w,fieldTooltip:F,updatable:p,label:T,name:e,tagRender:x,updatingValue:P,onSet:l,placeholder:i,allowClear:s=!0,selectOptionRender:u,formLayoutProps:C}=N,h=N.form,[j,y]=q.useState(""),a=q.useMemo(()=>U.getRealName(e),[e]),k=q.useMemo(()=>U.getRealName(e,"upsertFieldName"),[e]),R=v.Form.useWatch(a,h),[H,L]=q.useState(!0);q.useEffect(()=>{l&&H&&R&&(l==null||l(R,n,h),L(!1))},[H,h,n,a,l,R]),q.useEffect(()=>{R&&L(!0)},[R]);const G=q.useCallback(async t=>{y(t),b&&(o==null||o(t,h,P))},[h,o,b,P]),$=q.useCallback(t=>u?u(t):t.value,[u]);return r.jsx(_,{...N,...C,maxTagCount:"responsive",maxTagPlaceholder:t=>r.jsxs(le,{title:r.jsx(r.Fragment,{children:t.map(d=>r.jsxs(r.Fragment,{children:[d.label," ",r.jsx("br",{})]}))}),children:["+",t==null?void 0:t.length]}),placeholder:i,onSelect:t=>{l==null||l(t==null?void 0:t.key,n,h)},onChange:f?t=>{y(""),f(t,h)}:void 0,mode:O?"multiple":void 0,className:["w-100",m].join(" "),name:k,items:n,required:S,tooltip:F,tagRender:x,rules:w,disabled:!p,label:T,allowClear:s,onSearch:G,loading:c,filterOption:g?(t,d)=>{var A,B,E;try{const I=t.toLowerCase().split(/\s+/),z=((typeof(d==null?void 0:d.children)=="string"?d==null?void 0:d.children:(B=(A=d==null?void 0:d.children)==null?void 0:A.props)==null?void 0:B.textToHighlight)??"").toLowerCase(),J=(((E=d==null?void 0:d.value)==null?void 0:E.toString())??"").toLowerCase();return I.every(M=>z.indexOf(M)>=0||J.indexOf(M)>=0)}catch{return!0}}:void 0,itemBuilder:g?t=>{const d=t.value?String(t.value):void 0;return r.jsx(v.Select.Option,{value:t.key,title:d,disabled:t.disabled,children:r.jsx(K,{highlightClassName:"highlight-text",searchWords:(j??"").split(" "),autoEscape:!0,textToHighlight:d??""})},t.key)}:t=>r.jsx(v.Select.Option,{value:t.key,title:t.value,disabled:t.disabled,children:$(t)},t.key)})}function W(N){const{formLayoutProps:n,required:c,fieldClassName:b,rules:o,fieldTooltip:O,updatable:f,label:g,name:S,fieldHelper:m}=N;return r.jsx(v.Form.Item,{...n,label:g,name:S,required:c,rules:o,tooltip:O,help:m,getValueFromEvent:w=>typeof w=="object"?w.toHexString():w,children:r.jsx(v.ColorPicker,{disabledAlpha:!0,format:"hex",defaultFormat:"hex",showText:!0,trigger:"click",className:b,disabled:!f,...N.innerProps})})}exports.ColorCrudFieldComponent=W;exports.SelectCrudFieldComponent=D;exports.default=ne;
@@ -1,220 +1,220 @@
1
- import { jsx as a, Fragment as P, jsxs as W } from "react/jsx-runtime";
1
+ import { jsx as o, Fragment as L, jsxs as W } from "react/jsx-runtime";
2
2
  import { Form as j, Radio as _, Select as A, Tag as G, ColorPicker as ee } from "antd";
3
3
  import { useEffect as B, useState as $, useMemo as z, useCallback as J } from "react";
4
- import te from "react-highlight-words";
5
- import { useTranslationLibNoNS as re } from "../locale/index.es.js";
6
- import ae from "./FileCrudField.es.js";
7
- import le from "./ImageCrudField.es.js";
8
- import oe from "../common/check-box/CheckBox.es.js";
4
+ import re from "react-highlight-words";
5
+ import { useTranslationLibNoNS as te } from "../locale/index.es.js";
6
+ import oe from "./FileCrudField.es.js";
7
+ import ae from "./ImageCrudField.es.js";
8
+ import le from "../common/check-box/CheckBox.es.js";
9
9
  import ne from "../common/date-picker/DatePicker.es.js";
10
10
  import ie from "../common/date-picker/TimePicker.es.js";
11
11
  import Q from "../common/select/SelectComponent.es.js";
12
12
  import de from "../common/text-field/NumberField.es.js";
13
13
  import se from "../common/text-field/TextField.es.js";
14
- import ue from "../common/tooltip/TooltipComponent.es.js";
15
- import ce from "./CrudTextAreaComponent.es.js";
14
+ import ce from "../common/tooltip/TooltipComponent.es.js";
15
+ import me from "./CrudTextAreaComponent.es.js";
16
16
  import K from "../util/CrudUtil.es.js";
17
- function Se(F) {
17
+ function Pe(F) {
18
18
  const {
19
- label: o,
20
- name: c,
21
- type: y,
19
+ label: l,
20
+ name: m,
21
+ type: v,
22
22
  required: i,
23
23
  hidden: O,
24
24
  rules: h = [],
25
25
  updatable: p = !0,
26
26
  readonly: k = !1,
27
- fieldClassName: m,
27
+ fieldClassName: u,
28
28
  customFormFieldRender: w,
29
29
  fieldTooltip: x,
30
30
  fieldHelper: g,
31
- formLayout: T,
31
+ formLayoutProps: T,
32
32
  ...e
33
33
  } = F, C = j.useFormInstance();
34
34
  B(() => {
35
- if (y === "select") {
35
+ if (v === "select") {
36
36
  const {
37
- items: r = [],
37
+ items: t = [],
38
38
  onSearch: d,
39
39
  searchOnType: n
40
40
  } = e;
41
- !(r != null && r.length) && !n && (d == null || d(void 0, C, e == null ? void 0 : e.updatingValue));
41
+ !(t != null && t.length) && !n && (d == null || d(void 0, C, e == null ? void 0 : e.updatingValue));
42
42
  }
43
- }, [C, e, y, e == null ? void 0 : e.updatingValue]);
44
- const { t: S } = re();
45
- if (k || O) return /* @__PURE__ */ a(P, {});
43
+ }, [C, e, v, e == null ? void 0 : e.updatingValue]);
44
+ const { t: P } = te();
45
+ if (k || O) return /* @__PURE__ */ o(L, {});
46
46
  if (w)
47
47
  return w(C, F);
48
- switch (y) {
48
+ switch (v) {
49
49
  case "text":
50
50
  case "email":
51
51
  case "password": {
52
- const { onChange: r, placeholder: d, addonAfter: n, addonBefore: u } = e;
53
- return /* @__PURE__ */ a(
52
+ const { onChange: t, placeholder: d, addonAfter: n, addonBefore: c } = e;
53
+ return /* @__PURE__ */ o(
54
54
  se,
55
55
  {
56
- layout: T,
56
+ ...T,
57
57
  placeholder: d,
58
58
  disabled: !p,
59
59
  rules: h,
60
60
  required: i,
61
- onChange: r ? (b) => r(b, C) : void 0,
62
- type: y,
63
- name: c,
61
+ onChange: t ? (b) => t(b, C) : void 0,
62
+ type: v,
63
+ name: m,
64
64
  tooltip: x,
65
- label: o,
66
- className: m,
65
+ label: l,
66
+ className: u,
67
67
  autoComplete: "new-password",
68
68
  addonAfter: n,
69
- addonBefore: u,
69
+ addonBefore: c,
70
70
  help: g
71
71
  }
72
72
  );
73
73
  }
74
74
  case "number": {
75
75
  const {
76
- onChange: r,
76
+ onChange: t,
77
77
  placeholder: d,
78
78
  allowMinus: n,
79
- min: u,
79
+ min: c,
80
80
  max: b,
81
81
  addonAfter: f,
82
- addonBefore: v
82
+ addonBefore: y
83
83
  } = e;
84
- return /* @__PURE__ */ a(
84
+ return /* @__PURE__ */ o(
85
85
  de,
86
86
  {
87
- layout: T,
87
+ ...T,
88
88
  placeholder: d,
89
89
  disabled: !p,
90
90
  moneyField: !!e.formatted,
91
- type: y,
92
- onChange: r ? (N) => r(N, C) : void 0,
91
+ type: v,
92
+ onChange: t ? (N) => t(N, C) : void 0,
93
93
  rules: h,
94
94
  autoComplete: "false",
95
95
  required: i,
96
96
  tooltip: x,
97
- className: m,
98
- min: n ? null : u,
97
+ className: u,
98
+ min: n ? null : c,
99
99
  max: b,
100
100
  addonAfter: f,
101
- addonBefore: v,
102
- name: c,
103
- label: o,
101
+ addonBefore: y,
102
+ name: m,
103
+ label: l,
104
104
  help: g
105
105
  }
106
106
  );
107
107
  }
108
108
  case "date": {
109
109
  const {
110
- range: r,
110
+ range: t,
111
111
  disableToday: d,
112
112
  disabledFutureDays: n,
113
- disabledPastDays: u,
113
+ disabledPastDays: c,
114
114
  onChange: b,
115
115
  placeholder: f,
116
- format: v
116
+ format: y
117
117
  } = e;
118
- return /* @__PURE__ */ a(
118
+ return /* @__PURE__ */ o(
119
119
  ne,
120
120
  {
121
- layout: T,
121
+ ...T,
122
122
  placeholder: f,
123
123
  required: i,
124
124
  disabled: !p,
125
- type: y,
126
- format: v,
125
+ type: v,
126
+ format: y,
127
127
  tooltip: x,
128
- range: r,
129
- name: c,
130
- label: o,
128
+ range: t,
129
+ name: m,
130
+ label: l,
131
131
  onChange: b ? (N) => b(N, C) : void 0,
132
- className: m,
132
+ className: u,
133
133
  disableToday: d,
134
134
  disabledFutureDays: n,
135
- disabledPastDays: u,
135
+ disabledPastDays: c,
136
136
  help: g
137
137
  }
138
138
  );
139
139
  }
140
140
  case "time": {
141
141
  const {
142
- range: r = !1,
142
+ range: t = !1,
143
143
  disableCurrent: d,
144
144
  disabledFuture: n,
145
- disabledPast: u,
145
+ disabledPast: c,
146
146
  onChange: b,
147
147
  use12Hours: f,
148
- format: v,
148
+ format: y,
149
149
  placeholder: N
150
150
  } = e;
151
- return /* @__PURE__ */ a(
151
+ return /* @__PURE__ */ o(
152
152
  ie,
153
153
  {
154
- layout: T,
154
+ ...T,
155
155
  placeholder: N,
156
156
  required: i,
157
- format: v,
157
+ format: y,
158
158
  disabled: !p,
159
- type: y,
159
+ type: v,
160
160
  tooltip: x,
161
- range: r,
161
+ range: t,
162
162
  use12Hours: f,
163
- name: c,
164
- label: o,
165
- onChange: b ? (l) => b(l, C) : void 0,
166
- className: m,
163
+ name: m,
164
+ label: l,
165
+ onChange: b ? (a) => b(a, C) : void 0,
166
+ className: u,
167
167
  disableCurrent: d,
168
168
  disabledFuture: n,
169
- disabledPast: u,
169
+ disabledPast: c,
170
170
  help: g
171
171
  }
172
172
  );
173
173
  }
174
174
  case "textarea":
175
- return /* @__PURE__ */ a(ce, { ...F });
175
+ return /* @__PURE__ */ o(me, { ...F });
176
176
  case "image":
177
- return /* @__PURE__ */ a(
178
- le,
177
+ return /* @__PURE__ */ o(
178
+ ae,
179
179
  {
180
180
  ...e,
181
181
  required: i,
182
- name: c,
183
- label: o,
182
+ name: m,
183
+ label: l,
184
184
  rules: h,
185
185
  fieldHelper: g,
186
- fieldClassName: m,
186
+ fieldClassName: u,
187
187
  onRemoved: e.onRemoved,
188
188
  onUploading: e.onUploading,
189
189
  provider: e.provider
190
190
  }
191
191
  );
192
192
  case "file":
193
- return /* @__PURE__ */ a(
194
- ae,
193
+ return /* @__PURE__ */ o(
194
+ oe,
195
195
  {
196
196
  ...e,
197
197
  required: i,
198
- name: c,
199
- label: o,
198
+ name: m,
199
+ label: l,
200
200
  rules: h,
201
201
  fieldHelper: g,
202
- fieldClassName: m,
202
+ fieldClassName: u,
203
203
  onRemoved: e.onRemoved,
204
204
  onUploading: e.onUploading,
205
205
  provider: e.provider
206
206
  }
207
207
  );
208
208
  case "select":
209
- return /* @__PURE__ */ a(
210
- me,
209
+ return /* @__PURE__ */ o(
210
+ ue,
211
211
  {
212
212
  ...e,
213
213
  required: i,
214
- name: c,
215
- label: o,
214
+ name: m,
215
+ label: l,
216
216
  rules: h,
217
- fieldClassName: m,
217
+ fieldClassName: u,
218
218
  form: C,
219
219
  help: g,
220
220
  updatable: p,
@@ -225,93 +225,93 @@ function Se(F) {
225
225
  );
226
226
  case "enum": {
227
227
  const {
228
- enum: r,
228
+ enum: t,
229
229
  radio: d = !1,
230
230
  translation: n,
231
- onChange: u,
231
+ onChange: c,
232
232
  onSearch: b,
233
233
  multiple: f,
234
- tagRender: v
235
- } = e, N = Array.isArray(r) ? r : Object.keys(r);
236
- return d ? /* @__PURE__ */ a(
234
+ tagRender: y
235
+ } = e, N = Array.isArray(t) ? t : Object.keys(t);
236
+ return d ? /* @__PURE__ */ o(
237
237
  j.Item,
238
238
  {
239
239
  ...e,
240
- layout: T,
241
- name: c,
240
+ ...T,
241
+ name: m,
242
242
  required: i,
243
243
  tooltip: x,
244
244
  rules: h,
245
- label: o,
246
- className: ["w-100", m].join(" "),
245
+ label: l,
246
+ className: ["w-100", u].join(" "),
247
247
  help: g,
248
- children: /* @__PURE__ */ a(
248
+ children: /* @__PURE__ */ o(
249
249
  _.Group,
250
250
  {
251
251
  ...e,
252
- onChange: u ? (l) => {
252
+ onChange: c ? (a) => {
253
253
  var H;
254
- return u((H = l == null ? void 0 : l.target) == null ? void 0 : H.value, C);
254
+ return c((H = a == null ? void 0 : a.target) == null ? void 0 : H.value, C);
255
255
  } : void 0,
256
- children: N.map((l) => /* @__PURE__ */ a(_, { disabled: !p, value: l, children: n ? S(n[l]) : l }, l))
256
+ children: N.map((a) => /* @__PURE__ */ o(_, { disabled: !p, value: a, children: n ? P(n[a]) : a }, a))
257
257
  }
258
258
  )
259
259
  }
260
- ) : /* @__PURE__ */ a(
260
+ ) : /* @__PURE__ */ o(
261
261
  Q,
262
262
  {
263
263
  ...e,
264
- layout: T,
265
- tagRender: typeof v == "function" ? v : v ? (l) => {
266
- const { value: H, label: R } = l, L = v[H];
267
- return L ? /* @__PURE__ */ a(G, { color: L.color, children: R }) : /* @__PURE__ */ a(G, { children: R });
264
+ ...T,
265
+ tagRender: typeof y == "function" ? y : y ? (a) => {
266
+ const { value: H, label: R } = a, S = y[H];
267
+ return S ? /* @__PURE__ */ o(G, { color: S.color, children: R }) : /* @__PURE__ */ o(G, { children: R });
268
268
  } : void 0,
269
- onChange: u ? (l) => u(l, C) : void 0,
270
- className: ["w-100", m].join(" "),
271
- name: c,
269
+ onChange: c ? (a) => c(a, C) : void 0,
270
+ className: ["w-100", u].join(" "),
271
+ name: m,
272
272
  items: N,
273
273
  required: i,
274
274
  tooltip: x,
275
275
  rules: h,
276
- label: o,
276
+ label: l,
277
277
  help: g,
278
278
  disabled: !p,
279
- onSearch: b ? (l) => b(l, C) : void 0,
279
+ onSearch: b ? (a) => b(a, C) : void 0,
280
280
  allowClear: !0,
281
281
  mode: f ? "multiple" : void 0,
282
- itemBuilder: (l) => /* @__PURE__ */ a(A.Option, { value: l, children: n ? S(n[l]) : l }, l)
282
+ itemBuilder: (a) => /* @__PURE__ */ o(A.Option, { value: a, children: n ? P(n[a]) : a }, a)
283
283
  }
284
284
  );
285
285
  }
286
286
  case "checkbox": {
287
- const { onChange: r, switch: d } = e;
288
- return /* @__PURE__ */ a(
289
- oe,
287
+ const { onChange: t, switch: d } = e;
288
+ return /* @__PURE__ */ o(
289
+ le,
290
290
  {
291
- layout: T,
292
- className: m,
291
+ ...T,
292
+ className: u,
293
293
  rules: h,
294
- onChange: r ? (n) => r(n, C) : void 0,
295
- label: o,
294
+ onChange: t ? (n) => t(n, C) : void 0,
295
+ label: l,
296
296
  tooltip: x,
297
297
  disabled: !p,
298
- name: c,
298
+ name: m,
299
299
  help: g,
300
300
  switch: d
301
301
  }
302
302
  );
303
303
  }
304
304
  case "color":
305
- return /* @__PURE__ */ a(
305
+ return /* @__PURE__ */ o(
306
306
  fe,
307
307
  {
308
308
  ...e,
309
309
  type: "color",
310
310
  required: i,
311
- name: c,
312
- label: o,
311
+ name: m,
312
+ label: l,
313
313
  rules: h,
314
- fieldClassName: m,
314
+ fieldClassName: u,
315
315
  updatable: p,
316
316
  readonly: k,
317
317
  fieldTooltip: x,
@@ -319,81 +319,81 @@ function Se(F) {
319
319
  }
320
320
  );
321
321
  default:
322
- return /* @__PURE__ */ a(P, { children: `${y} Not Implemented` });
322
+ return /* @__PURE__ */ o(L, { children: `${v} Not Implemented` });
323
323
  }
324
324
  }
325
- function me(F) {
325
+ function ue(F) {
326
326
  const {
327
- items: o = [],
328
- loading: c,
329
- searchOnType: y,
327
+ items: l = [],
328
+ loading: m,
329
+ searchOnType: v,
330
330
  onSearch: i,
331
331
  multiple: O,
332
332
  onChange: h,
333
333
  highlightSearch: p,
334
334
  required: k,
335
- fieldClassName: m,
335
+ fieldClassName: u,
336
336
  rules: w,
337
337
  fieldTooltip: x,
338
338
  updatable: g,
339
339
  label: T,
340
340
  name: e,
341
341
  tagRender: C,
342
- updatingValue: S,
343
- onSet: r,
342
+ updatingValue: P,
343
+ onSet: t,
344
344
  placeholder: d,
345
345
  allowClear: n = !0,
346
- selectOptionRender: u,
347
- formLayout: b
348
- } = F, f = F.form, [v, N] = $(""), l = z(() => K.getRealName(e), [e]), H = z(
346
+ selectOptionRender: c,
347
+ formLayoutProps: b
348
+ } = F, f = F.form, [y, N] = $(""), a = z(() => K.getRealName(e), [e]), H = z(
349
349
  () => K.getRealName(e, "upsertFieldName"),
350
350
  [e]
351
- ), R = j.useWatch(l, f), [L, I] = $(!0);
351
+ ), R = j.useWatch(a, f), [S, I] = $(!0);
352
352
  B(() => {
353
- r && L && R && (r == null || r(R, o, f), I(!1));
354
- }, [L, f, o, l, r, R]), B(() => {
353
+ t && S && R && (t == null || t(R, l, f), I(!1));
354
+ }, [S, f, l, a, t, R]), B(() => {
355
355
  R && I(!0);
356
356
  }, [R]);
357
357
  const V = J(
358
- async (t) => {
359
- N(t), y && (i == null || i(t, f, S));
358
+ async (r) => {
359
+ N(r), v && (i == null || i(r, f, P));
360
360
  },
361
- [f, i, y, S]
361
+ [f, i, v, P]
362
362
  ), X = J(
363
- (t) => u ? u(t) : t.value,
364
- [u]
363
+ (r) => c ? c(r) : r.value,
364
+ [c]
365
365
  );
366
- return /* @__PURE__ */ a(
366
+ return /* @__PURE__ */ o(
367
367
  Q,
368
368
  {
369
369
  ...F,
370
- layout: b,
370
+ ...b,
371
371
  maxTagCount: "responsive",
372
- maxTagPlaceholder: (t) => /* @__PURE__ */ W(
373
- ue,
372
+ maxTagPlaceholder: (r) => /* @__PURE__ */ W(
373
+ ce,
374
374
  {
375
- title: /* @__PURE__ */ a(P, { children: t.map((s) => /* @__PURE__ */ W(P, { children: [
375
+ title: /* @__PURE__ */ o(L, { children: r.map((s) => /* @__PURE__ */ W(L, { children: [
376
376
  s.label,
377
377
  " ",
378
- /* @__PURE__ */ a("br", {})
378
+ /* @__PURE__ */ o("br", {})
379
379
  ] })) }),
380
380
  children: [
381
381
  "+",
382
- t == null ? void 0 : t.length
382
+ r == null ? void 0 : r.length
383
383
  ]
384
384
  }
385
385
  ),
386
386
  placeholder: d,
387
- onSelect: (t) => {
388
- r == null || r(t == null ? void 0 : t.key, o, f);
387
+ onSelect: (r) => {
388
+ t == null || t(r == null ? void 0 : r.key, l, f);
389
389
  },
390
- onChange: h ? (t) => {
391
- N(""), h(t, f);
390
+ onChange: h ? (r) => {
391
+ N(""), h(r, f);
392
392
  } : void 0,
393
393
  mode: O ? "multiple" : void 0,
394
- className: ["w-100", m].join(" "),
394
+ className: ["w-100", u].join(" "),
395
395
  name: H,
396
- items: o,
396
+ items: l,
397
397
  required: k,
398
398
  tooltip: x,
399
399
  tagRender: C,
@@ -402,11 +402,11 @@ function me(F) {
402
402
  label: T,
403
403
  allowClear: n,
404
404
  onSearch: V,
405
- loading: c,
406
- filterOption: p ? (t, s) => {
405
+ loading: m,
406
+ filterOption: p ? (r, s) => {
407
407
  var U, q, D;
408
408
  try {
409
- const E = t.toLowerCase().split(/\s+/), Y = ((typeof (s == null ? void 0 : s.children) == "string" ? s == null ? void 0 : s.children : (q = (U = s == null ? void 0 : s.children) == null ? void 0 : U.props) == null ? void 0 : q.textToHighlight) ?? "").toLowerCase(), Z = (((D = s == null ? void 0 : s.value) == null ? void 0 : D.toString()) ?? "").toLowerCase();
409
+ const E = r.toLowerCase().split(/\s+/), Y = ((typeof (s == null ? void 0 : s.children) == "string" ? s == null ? void 0 : s.children : (q = (U = s == null ? void 0 : s.children) == null ? void 0 : U.props) == null ? void 0 : q.textToHighlight) ?? "").toLowerCase(), Z = (((D = s == null ? void 0 : s.value) == null ? void 0 : D.toString()) ?? "").toLowerCase();
410
410
  return E.every(
411
411
  (M) => Y.indexOf(M) >= 0 || Z.indexOf(M) >= 0
412
412
  );
@@ -414,63 +414,63 @@ function me(F) {
414
414
  return !0;
415
415
  }
416
416
  } : void 0,
417
- itemBuilder: p ? (t) => {
418
- const s = t.value ? String(t.value) : void 0;
419
- return /* @__PURE__ */ a(
417
+ itemBuilder: p ? (r) => {
418
+ const s = r.value ? String(r.value) : void 0;
419
+ return /* @__PURE__ */ o(
420
420
  A.Option,
421
421
  {
422
- value: t.key,
422
+ value: r.key,
423
423
  title: s,
424
- disabled: t.disabled,
425
- children: /* @__PURE__ */ a(
426
- te,
424
+ disabled: r.disabled,
425
+ children: /* @__PURE__ */ o(
426
+ re,
427
427
  {
428
428
  highlightClassName: "highlight-text",
429
- searchWords: (v ?? "").split(" "),
429
+ searchWords: (y ?? "").split(" "),
430
430
  autoEscape: !0,
431
431
  textToHighlight: s ?? ""
432
432
  }
433
433
  )
434
434
  },
435
- t.key
435
+ r.key
436
436
  );
437
- } : (t) => /* @__PURE__ */ a(
437
+ } : (r) => /* @__PURE__ */ o(
438
438
  A.Option,
439
439
  {
440
- value: t.key,
441
- title: t.value,
442
- disabled: t.disabled,
443
- children: X(t)
440
+ value: r.key,
441
+ title: r.value,
442
+ disabled: r.disabled,
443
+ children: X(r)
444
444
  },
445
- t.key
445
+ r.key
446
446
  )
447
447
  }
448
448
  );
449
449
  }
450
450
  function fe(F) {
451
451
  const {
452
- formLayout: o,
453
- required: c,
454
- fieldClassName: y,
452
+ formLayoutProps: l,
453
+ required: m,
454
+ fieldClassName: v,
455
455
  rules: i,
456
456
  fieldTooltip: O,
457
457
  updatable: h,
458
458
  label: p,
459
459
  name: k,
460
- fieldHelper: m
460
+ fieldHelper: u
461
461
  } = F;
462
- return /* @__PURE__ */ a(
462
+ return /* @__PURE__ */ o(
463
463
  j.Item,
464
464
  {
465
- layout: o,
465
+ ...l,
466
466
  label: p,
467
467
  name: k,
468
- required: c,
468
+ required: m,
469
469
  rules: i,
470
470
  tooltip: O,
471
- help: m,
471
+ help: u,
472
472
  getValueFromEvent: (w) => typeof w == "object" ? w.toHexString() : w,
473
- children: /* @__PURE__ */ a(
473
+ children: /* @__PURE__ */ o(
474
474
  ee,
475
475
  {
476
476
  disabledAlpha: !0,
@@ -478,7 +478,7 @@ function fe(F) {
478
478
  defaultFormat: "hex",
479
479
  showText: !0,
480
480
  trigger: "click",
481
- className: y,
481
+ className: v,
482
482
  disabled: !h,
483
483
  ...F.innerProps
484
484
  }
@@ -488,6 +488,6 @@ function fe(F) {
488
488
  }
489
489
  export {
490
490
  fe as ColorCrudFieldComponent,
491
- me as SelectCrudFieldComponent,
492
- Se as default
491
+ ue as SelectCrudFieldComponent,
492
+ Pe as default
493
493
  };
@@ -1 +1 @@
1
- "use strict";const u=require("react/jsx-runtime"),C=require("../common/text-field/TextArea.cjs.js"),T=require("../common/rich/index.cjs.js"),j=require("antd"),p=require("../util/CrudUtil.cjs.js"),F=({onChange:r,label:s,required:i,rules:o,name:n,updatable:l=!0,formLayout:c,...e})=>{const a=j.Form.useFormInstance(),m=p.getRealName(n,"upsertFieldName");if(e.rich)return u.jsx(T.RichTextEditor,{name:m,label:s,required:i,rules:o,disabled:!l,help:e.fieldHelper,formLayout:c});{const{placeholder:x,rows:f,cols:h,fieldClassName:N,fieldTooltip:q}=e;return u.jsx(C.default,{layout:c,rules:o,placeholder:x,onChange:r?t=>{var d;return r((d=t==null?void 0:t.target)==null?void 0:d.value,a)}:void 0,tooltip:q,required:i,disabled:!l,name:n,label:s,className:N,rows:f,cols:h,help:e.fieldHelper})}};module.exports=F;
1
+ "use strict";const u=require("react/jsx-runtime"),C=require("../common/text-field/TextArea.cjs.js"),T=require("../common/rich/index.cjs.js"),j=require("antd"),F=require("../util/CrudUtil.cjs.js"),R=({onChange:r,label:i,required:s,rules:n,name:o,updatable:c=!0,formLayoutProps:l,...e})=>{const a=j.Form.useFormInstance(),m=F.getRealName(o,"upsertFieldName");if(e.rich)return u.jsx(T.RichTextEditor,{name:m,label:i,required:s,rules:n,disabled:!c,help:e.fieldHelper,formLayoutProps:l});{const{placeholder:x,rows:f,cols:h,fieldClassName:N,fieldTooltip:q}=e;return u.jsx(C.default,{...l,rules:n,placeholder:x,onChange:r?t=>{var d;return r((d=t==null?void 0:t.target)==null?void 0:d.value,a)}:void 0,tooltip:q,required:s,disabled:!c,name:o,label:i,className:N,rows:f,cols:h,help:e.fieldHelper})}};module.exports=R;
@@ -19,5 +19,5 @@ interface RichTextAreaProps<T> extends InitialTextAreaProps<T> {
19
19
  rich?: true;
20
20
  }
21
21
  export type TextAreaBasedFieldProps<T> = TextAreaProps<T> & RichTextAreaProps<T> & Copyable<false>;
22
- declare const CrudTextAreaComponent: <T>({ onChange, label, required, rules, name, updatable, formLayout, ...props }: TextAreaBasedFieldProps<T>) => import("react/jsx-runtime").JSX.Element;
22
+ declare const CrudTextAreaComponent: <T>({ onChange, label, required, rules, name, updatable, formLayoutProps, ...props }: TextAreaBasedFieldProps<T>) => import("react/jsx-runtime").JSX.Element;
23
23
  export default CrudTextAreaComponent;
@@ -1,4 +1,4 @@
1
- import { jsx as n } from "react/jsx-runtime";
1
+ import { jsx as a } from "react/jsx-runtime";
2
2
  import N from "../common/text-field/TextArea.es.js";
3
3
  import { RichTextEditor as T } from "../common/rich/index.es.js";
4
4
  import { Form as F } from "antd";
@@ -9,44 +9,44 @@ const E = ({
9
9
  required: i,
10
10
  rules: m,
11
11
  name: l,
12
- updatable: s = !0,
13
- formLayout: d,
12
+ updatable: d = !0,
13
+ formLayoutProps: s,
14
14
  ...e
15
15
  }) => {
16
16
  const f = F.useFormInstance(), c = g.getRealName(l, "upsertFieldName");
17
17
  if (e.rich)
18
- return /* @__PURE__ */ n(
18
+ return /* @__PURE__ */ a(
19
19
  T,
20
20
  {
21
21
  name: c,
22
22
  label: r,
23
23
  required: i,
24
24
  rules: m,
25
- disabled: !s,
25
+ disabled: !d,
26
26
  help: e.fieldHelper,
27
- formLayout: d
27
+ formLayoutProps: s
28
28
  }
29
29
  );
30
30
  {
31
- const { placeholder: p, rows: u, cols: h, fieldClassName: x, fieldTooltip: C } = e;
32
- return /* @__PURE__ */ n(
31
+ const { placeholder: p, rows: h, cols: u, fieldClassName: x, fieldTooltip: C } = e;
32
+ return /* @__PURE__ */ a(
33
33
  N,
34
34
  {
35
- layout: d,
35
+ ...s,
36
36
  rules: m,
37
37
  placeholder: p,
38
38
  onChange: o ? (t) => {
39
- var a;
40
- return o((a = t == null ? void 0 : t.target) == null ? void 0 : a.value, f);
39
+ var n;
40
+ return o((n = t == null ? void 0 : t.target) == null ? void 0 : n.value, f);
41
41
  } : void 0,
42
42
  tooltip: C,
43
43
  required: i,
44
- disabled: !s,
44
+ disabled: !d,
45
45
  name: l,
46
46
  label: r,
47
47
  className: x,
48
- rows: u,
49
- cols: h,
48
+ rows: h,
49
+ cols: u,
50
50
  help: e.fieldHelper
51
51
  }
52
52
  );
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),d=require("@ant-design/icons"),F=require("antd"),D=require("mime"),c=require("react"),G=require("../locale/index.cjs.js"),J=require("../util/ValidationUtil.cjs.js"),p=require("../common/button/Button.cjs.js"),K=require("../common/layout/VerticalSpace.cjs.js"),Q=require("../util/CrudUtil.cjs.js");function X({name:n,label:e,required:l,provider:s,onUploading:a,onRemoved:h,fieldClassName:j,accept:P,rules:U,maxCount:O=1,block:k,fieldHelper:E,formLayout:_,...$}){const f=F.Form.useFormInstance(),H=Q.getRealName(n,"upsertFieldName"),x=F.Form.useWatch(H,f),[b,q]=c.useState(!1),[V,R]=c.useState(!1),A=c.useCallback(async r=>{var o,i;try{const{file:u}=r,g=u.name;q(!0),R(!0),a==null||a(!0);const C=g??"",S=C.split("."),W=S[S.length-1],B=s.generateFileName(C),z=`${await s.getInitialPath()}/${B}.${W}`,M=await s.upload({...u,originFileObj:u},z);a==null||a(!1),f.setFieldValue(n,M),(o=r.onSuccess)==null||o.call(r,M)}catch(u){(i=r.onError)==null||i.call(r,u)}finally{q(!1)}},[f,n,a,s]),[w,I]=c.useState([]);c.useEffect(()=>{!V&&x&&Promise.all((Array.isArray(x)?x:[x]).map(async r=>{const o=D.getType(r),i=r.split("/").pop(),u=await s.getRealUrl(r);return{uid:r,url:u,type:o,name:i}})).then(r=>I(()=>r.map(({url:i,type:u,uid:g,name:C})=>({uid:g,url:i,type:u,response:g,thumbUrl:i,name:C}))))},[x,V,b,s]);const L=c.useCallback(async r=>{const o=r.response,i=o||f.getFieldValue(n);await s.delete(i),h==null||h(),r&&f.setFieldsValue({[n]:null})},[f,n,h,s]);return t.jsxs(F.Form.Item,{label:e,required:l,name:n,layout:_,className:j,rules:[...l?J.required(e):[],...U??[]],help:E,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})=>{I(r)},style:k?{width:"100%"}:void 0,children:t.jsx(p,{loading:b,children:"Upload File"})})]})}const Y=({provider:n,value:e})=>{const[l,s]=c.useState();return c.useEffect(()=>{e&&n.getRealUrl(e).then(a=>{s({mimeType:D.getType(e),url:a,fileName:e.split("/").pop()??e})})},[n,e]),l?t.jsx(N,{fileName:l.fileName,url:l==null?void 0:l.url,mimeType:l==null?void 0:l.mimeType}):t.jsx(t.Fragment,{})},N=({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}=G.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"},destroyOnHidden:!0,children:t.jsxs(K,{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=N;exports.FileCrudCellValue=Y;exports.default=X;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),d=require("@ant-design/icons"),F=require("antd"),D=require("mime"),c=require("react"),G=require("../locale/index.cjs.js"),J=require("../util/ValidationUtil.cjs.js"),p=require("../common/button/Button.cjs.js"),K=require("../common/layout/VerticalSpace.cjs.js"),Q=require("../util/CrudUtil.cjs.js");function X({name:n,label:e,required:l,provider:s,onUploading:a,onRemoved:h,fieldClassName:j,accept:P,rules:U,maxCount:O=1,block:k,fieldHelper:E,formLayoutProps:_,...$}){const f=F.Form.useFormInstance(),H=Q.getRealName(n,"upsertFieldName"),x=F.Form.useWatch(H,f),[b,q]=c.useState(!1),[V,R]=c.useState(!1),A=c.useCallback(async r=>{var o,i;try{const{file:u}=r,g=u.name;q(!0),R(!0),a==null||a(!0);const C=g??"",S=C.split("."),W=S[S.length-1],B=s.generateFileName(C),z=`${await s.getInitialPath()}/${B}.${W}`,M=await s.upload({...u,originFileObj:u},z);a==null||a(!1),f.setFieldValue(n,M),(o=r.onSuccess)==null||o.call(r,M)}catch(u){(i=r.onError)==null||i.call(r,u)}finally{q(!1)}},[f,n,a,s]),[w,I]=c.useState([]);c.useEffect(()=>{!V&&x&&Promise.all((Array.isArray(x)?x:[x]).map(async r=>{const o=D.getType(r),i=r.split("/").pop(),u=await s.getRealUrl(r);return{uid:r,url:u,type:o,name:i}})).then(r=>I(()=>r.map(({url:i,type:u,uid:g,name:C})=>({uid:g,url:i,type:u,response:g,thumbUrl:i,name:C}))))},[x,V,b,s]);const L=c.useCallback(async r=>{const o=r.response,i=o||f.getFieldValue(n);await s.delete(i),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?J.required(e):[],...U??[]],help:E,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})=>{I(r)},style:k?{width:"100%"}:void 0,children:t.jsx(p,{loading:b,children:"Upload File"})})]})}const Y=({provider:n,value:e})=>{const[l,s]=c.useState();return c.useEffect(()=>{e&&n.getRealUrl(e).then(a=>{s({mimeType:D.getType(e),url:a,fileName:e.split("/").pop()??e})})},[n,e]),l?t.jsx(N,{fileName:l.fileName,url:l==null?void 0:l.url,mimeType:l==null?void 0:l.mimeType}):t.jsx(t.Fragment,{})},N=({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}=G.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"},destroyOnHidden:!0,children:t.jsxs(K,{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=N;exports.FileCrudCellValue=Y;exports.default=X;
@@ -14,7 +14,7 @@ export interface _FileCrudField<T> extends InitialCrudField<T> {
14
14
  block?: boolean;
15
15
  help?: ReactNode;
16
16
  }
17
- export default function FileCrudFieldComponent<T>({ name, label, required, provider, onUploading, onRemoved, fieldClassName, accept, rules, maxCount, block, fieldHelper: help, formLayout, ...props }: Readonly<_FileCrudField<T>>): import("react/jsx-runtime").JSX.Element;
17
+ export default function FileCrudFieldComponent<T>({ name, label, required, provider, onUploading, onRemoved, fieldClassName, accept, rules, maxCount, block, fieldHelper: help, formLayoutProps, ...props }: Readonly<_FileCrudField<T>>): import("react/jsx-runtime").JSX.Element;
18
18
  export declare const FileCrudCellValue: FC<{
19
19
  value: string;
20
20
  provider: FileDownloadProvider;
@@ -21,7 +21,7 @@ function xt({
21
21
  maxCount: I = 1,
22
22
  block: A,
23
23
  fieldHelper: L,
24
- formLayout: W,
24
+ formLayoutProps: W,
25
25
  ..._
26
26
  }) {
27
27
  const d = P.useFormInstance(), q = nt.getRealName(n, "upsertFieldName"), h = P.useWatch(q, d), [V, D] = p(!1), [N, B] = p(!1), R = M(
@@ -71,7 +71,7 @@ function xt({
71
71
  label: t,
72
72
  required: r,
73
73
  name: n,
74
- layout: W,
74
+ ...W,
75
75
  className: F,
76
76
  rules: [
77
77
  ...r ? rt.required(t) : [],
@@ -1 +1 @@
1
- "use strict";var D=Object.defineProperty;var H=(s,e,t)=>e in s?D(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var g=(s,e,t)=>H(s,typeof e!="symbol"?e+"":e,t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("react/jsx-runtime"),R=require("@ant-design/icons"),f=require("antd"),q=require("path-browserify"),i=require("react"),T=require("../util/NumberUtil.cjs.js"),W=require("../util/ValidationUtil.cjs.js"),v=require("uuid"),z=require("../common/picker/ImagePicker.cjs.js"),G=require("../util/ImageUtil.cjs.js");class y{}class J extends y{constructor(t="",a=""){super();g(this,"rootPath");g(this,"subPath");this.rootPath=t,this.subPath=a}cloneFilePath(t){const a=q.parse(t),r=`${a.name}_cloned_${T.default.randInt(1e5)}`;return q.format({dir:a.dir,ext:a.ext,name:r})}generateFileName(t){return`${t.split(".")[0]}_${v.v4().replace("-","")}`}}function K({formLayout:s,name:e,label:t,required:a,provider:r,onUploading:u,aspectRatio:C,onRemoved:d,fieldClassName:x,hideLabel:N=!1,listType:b,fieldHelper:S,showSkipCropButton:$=!1,skipResize:p=!1,asyncUpload:O=!1},_){const m=f.Form.useFormInstance(),I=f.Form.useWatch(e,m),[w,k]=i.useState(!1),h=i.useCallback(async(l,F)=>{if(F){u==null||u(!0);const c=l.name,o=c.split("."),E=o[o.length-1],M=r.generateFileName(c),A=`${await r.getInitialPath()}/${M}.${E}`,B=await r.upload(l,A);k(!0),u==null||u(!1),m.setFieldValue(e,B)}else{const c=m.getFieldsValue(),o=await r.delete(c[e]);d==null||d(),o&&m.setFieldsValue({[e]:null})}},[m,e,d,u,r]),[P,j]=i.useState();return i.useEffect(()=>{!w&&I?r.getRealUrl(I).then(j):j(P)},[I,w,r,P]),i.useImperativeHandle(_,()=>({async uploadBlob(l,F){const c=await G.getBase64(l),o={name:F,uid:F+Math.random().toString(36).substring(2,15),url:c,originFileObj:l};return h(o,!0)}}),[h]),n.jsxs(f.Form.Item,{rules:a?W.required(t):[],label:N?null:t,required:a,name:e,help:S,layout:s,className:x,children:[n.jsx(z.default,{noStyle:!0,asyncUpload:O,listType:b,aspectRatio:C,values:P,onRemove:l=>{l&&h(l,!1)},onAdd:async l=>{l&&await h(l,!0)},className:x,showSkipCropButton:$,skipResize:p}),n.jsx(f.Input,{hidden:!0})]})}const L=i.forwardRef(K),Q=({provider:s,value:e})=>{const[t,a]=i.useState();return i.useEffect(()=>{e&&s.getRealUrl(e).then(a)},[s,e]),t?n.jsx(V,{url:t}):n.jsx(n.Fragment,{})},V=({url:s})=>n.jsx(f.Avatar,{className:"p-0",children:n.jsx(f.Image,{className:"m-0 p-0 position-relative",src:s,preview:{mask:n.jsx(R.EyeOutlined,{})}})});exports.FileDownloadProvider=y;exports.FileUploadProvider=J;exports.ImageCellValue=V;exports.ImageCrudCellValue=Q;exports.default=L;
1
+ "use strict";var D=Object.defineProperty;var H=(s,e,t)=>e in s?D(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var g=(s,e,t)=>H(s,typeof e!="symbol"?e+"":e,t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("react/jsx-runtime"),R=require("@ant-design/icons"),f=require("antd"),q=require("path-browserify"),i=require("react"),T=require("../util/NumberUtil.cjs.js"),W=require("../util/ValidationUtil.cjs.js"),v=require("uuid"),z=require("../common/picker/ImagePicker.cjs.js"),G=require("../util/ImageUtil.cjs.js");class V{}class J extends V{constructor(t="",a=""){super();g(this,"rootPath");g(this,"subPath");this.rootPath=t,this.subPath=a}cloneFilePath(t){const a=q.parse(t),r=`${a.name}_cloned_${T.default.randInt(1e5)}`;return q.format({dir:a.dir,ext:a.ext,name:r})}generateFileName(t){return`${t.split(".")[0]}_${v.v4().replace("-","")}`}}function K({formLayoutProps:s,name:e,label:t,required:a,provider:r,onUploading:u,aspectRatio:C,onRemoved:d,fieldClassName:x,hideLabel:N=!1,listType:b,fieldHelper:S,showSkipCropButton:$=!1,skipResize:p=!1,asyncUpload:O=!1},_){const m=f.Form.useFormInstance(),I=f.Form.useWatch(e,m),[w,k]=i.useState(!1),h=i.useCallback(async(l,F)=>{if(F){u==null||u(!0);const c=l.name,o=c.split("."),E=o[o.length-1],M=r.generateFileName(c),A=`${await r.getInitialPath()}/${M}.${E}`,B=await r.upload(l,A);k(!0),u==null||u(!1),m.setFieldValue(e,B)}else{const c=m.getFieldsValue(),o=await r.delete(c[e]);d==null||d(),o&&m.setFieldsValue({[e]:null})}},[m,e,d,u,r]),[P,j]=i.useState();return i.useEffect(()=>{!w&&I?r.getRealUrl(I).then(j):j(P)},[I,w,r,P]),i.useImperativeHandle(_,()=>({async uploadBlob(l,F){const c=await G.getBase64(l),o={name:F,uid:F+Math.random().toString(36).substring(2,15),url:c,originFileObj:l};return h(o,!0)}}),[h]),n.jsxs(f.Form.Item,{rules:a?W.required(t):[],label:N?null:t,required:a,name:e,help:S,...s,className:x,children:[n.jsx(z.default,{noStyle:!0,asyncUpload:O,listType:b,aspectRatio:C,values:P,onRemove:l=>{l&&h(l,!1)},onAdd:async l=>{l&&await h(l,!0)},className:x,showSkipCropButton:$,skipResize:p}),n.jsx(f.Input,{hidden:!0})]})}const L=i.forwardRef(K),Q=({provider:s,value:e})=>{const[t,a]=i.useState();return i.useEffect(()=>{e&&s.getRealUrl(e).then(a)},[s,e]),t?n.jsx(y,{url:t}):n.jsx(n.Fragment,{})},y=({url:s})=>n.jsx(f.Avatar,{className:"p-0",children:n.jsx(f.Image,{className:"m-0 p-0 position-relative",src:s,preview:{mask:n.jsx(R.EyeOutlined,{})}})});exports.FileDownloadProvider=V;exports.FileUploadProvider=J;exports.ImageCellValue=y;exports.ImageCrudCellValue=Q;exports.default=L;
@@ -4,7 +4,7 @@ var I = (a, e, t) => M(a, typeof e != "symbol" ? e + "" : e, t);
4
4
  import { jsx as i, Fragment as W, jsxs as q } from "react/jsx-runtime";
5
5
  import { EyeOutlined as z } from "@ant-design/icons";
6
6
  import { Avatar as G, Image as J, Form as d, Input as K } from "antd";
7
- import N from "path-browserify";
7
+ import y from "path-browserify";
8
8
  import L, { useState as P, useEffect as V, useCallback as Q, useImperativeHandle as R } from "react";
9
9
  import T from "../util/NumberUtil.es.js";
10
10
  import X from "../util/ValidationUtil.es.js";
@@ -21,11 +21,11 @@ class he extends v {
21
21
  this.rootPath = t, this.subPath = s;
22
22
  }
23
23
  cloneFilePath(t) {
24
- const s = N.parse(t), r = `${s.name}_cloned_${T.randInt(1e5)}`;
25
- return N.format({
24
+ const s = y.parse(t), l = `${s.name}_cloned_${T.randInt(1e5)}`;
25
+ return y.format({
26
26
  dir: s.dir,
27
27
  ext: s.ext,
28
- name: r
28
+ name: l
29
29
  });
30
30
  }
31
31
  generateFileName(t) {
@@ -33,11 +33,11 @@ class he extends v {
33
33
  }
34
34
  }
35
35
  function ee({
36
- formLayout: a,
36
+ formLayoutProps: a,
37
37
  name: e,
38
38
  label: t,
39
39
  required: s,
40
- provider: r,
40
+ provider: l,
41
41
  onUploading: n,
42
42
  aspectRatio: x,
43
43
  onRemoved: m,
@@ -50,29 +50,29 @@ function ee({
50
50
  asyncUpload: k = !1
51
51
  }, S) {
52
52
  const o = d.useFormInstance(), F = d.useWatch(e, o), [g, _] = P(!1), f = Q(
53
- async (l, h) => {
53
+ async (r, h) => {
54
54
  if (h) {
55
55
  n == null || n(!0);
56
- const c = l.name, u = c.split("."), A = u[u.length - 1], B = r.generateFileName(c), E = `${await r.getInitialPath()}/${B}.${A}`, H = await r.upload(l, E);
56
+ const c = r.name, u = c.split("."), A = u[u.length - 1], B = l.generateFileName(c), E = `${await l.getInitialPath()}/${B}.${A}`, H = await l.upload(r, E);
57
57
  _(!0), n == null || n(!1), o.setFieldValue(e, H);
58
58
  } else {
59
- const c = o.getFieldsValue(), u = await r.delete(c[e]);
59
+ const c = o.getFieldsValue(), u = await l.delete(c[e]);
60
60
  m == null || m(), u && o.setFieldsValue({ [e]: null });
61
61
  }
62
62
  },
63
- [o, e, m, n, r]
64
- ), [p, y] = P();
63
+ [o, e, m, n, l]
64
+ ), [p, N] = P();
65
65
  return V(() => {
66
- !g && F ? r.getRealUrl(F).then(y) : y(p);
67
- }, [F, g, r, p]), R(
66
+ !g && F ? l.getRealUrl(F).then(N) : N(p);
67
+ }, [F, g, l, p]), R(
68
68
  S,
69
69
  () => ({
70
- async uploadBlob(l, h) {
71
- const c = await U.getBase64(l), u = {
70
+ async uploadBlob(r, h) {
71
+ const c = await U.getBase64(r), u = {
72
72
  name: h,
73
73
  uid: h + Math.random().toString(36).substring(2, 15),
74
74
  url: c,
75
- originFileObj: l
75
+ originFileObj: r
76
76
  };
77
77
  return f(u, !0);
78
78
  }
@@ -86,7 +86,7 @@ function ee({
86
86
  required: s,
87
87
  name: e,
88
88
  help: b,
89
- layout: a,
89
+ ...a,
90
90
  className: w,
91
91
  children: [
92
92
  /* @__PURE__ */ i(
@@ -97,11 +97,11 @@ function ee({
97
97
  listType: C,
98
98
  aspectRatio: x,
99
99
  values: p,
100
- onRemove: (l) => {
101
- l && f(l, !1);
100
+ onRemove: (r) => {
101
+ r && f(r, !1);
102
102
  },
103
- onAdd: async (l) => {
104
- l && await f(l, !0);
103
+ onAdd: async (r) => {
104
+ r && await f(r, !0);
105
105
  },
106
106
  className: w,
107
107
  showSkipCropButton: O,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kingteza/crud-component",
3
3
  "private": false,
4
- "version": "1.18.0",
4
+ "version": "1.20.0",
5
5
  "description": "React CRUD component library with Ant Design",
6
6
  "keywords": [
7
7
  "react",