@kingteza/crud-component 1.3.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";var g=Object.create;var p=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var w=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of V(t))!F.call(e,o)&&o!==r&&p(e,o,{get:()=>t[o],enumerable:!(s=q(t,o))||s.enumerable});return e};var R=(e,t,r)=>(r=e!=null?g(j(e)):{},w(t||!e||!e.__esModule?p(r,"default",{value:e,enumerable:!0}):r,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime");;/* empty css */;/* empty css */const h=require("antd"),c=require("react"),y=require("../../util/ValidationUtil.cjs.js"),E=c.lazy(async()=>{const{default:e}=await import("react-quill");return{default:t=>a.jsx(e,{...t})}}),S=({name:e,label:t,required:r,rules:s=[],disabled:o})=>{const n=h.Form.useFormInstance(),[u,d]=c.useState(""),f={toolbar:[["bold","italic","underline","strike","blockquote"],[{list:"ordered"},{list:"bullet"}],["link"],["clean"]]},b=["bold","italic","underline","strike","blockquote","list","bullet","link"];c.useEffect(()=>{const i=n.getFieldValue(e);i&&i!=="<p></p>"&&i!=="<p><br></p>"&&d(i)},[n,e]);const l=h.Form.useWatch(e,n);c.useEffect(()=>{l!==u&&d(!l||l==="<p></p>"||l==="<p><br></p>"?"":l)},[l,u]);const k=i=>{d(i);const x=!i||i==="<p></p>"||i.trim()==="<p><br></p>"?void 0:i;n.setFieldValue(e,x),n.validateFields([e]).catch(()=>{})},m=c.useMemo(()=>r?[...s,...y.required(t??"")]:s,[r,s,t]);return a.jsx(h.Form.Item,{name:e,label:t,rules:m,children:a.jsx(c.Suspense,{fallback:a.jsx("div",{children:"Loading editor..."}),children:a.jsx(E,{readOnly:o,value:u,onChange:k,theme:"snow",className:"bg-white dark:!bg-[#141414] dark:text-white dark:!fill-white",modules:f,formats:b})})})};exports.RichTextEditor=S;
1
+ "use strict";var q=Object.create;var p=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var F=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var R=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of j(t))!w.call(e,o)&&o!==r&&p(e,o,{get:()=>t[o],enumerable:!(s=V(t,o))||s.enumerable});return e};var y=(e,t,r)=>(r=e!=null?q(F(e)):{},R(t||!e||!e.__esModule?p(r,"default",{value:e,enumerable:!0}):r,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime");;/* empty css */;/* empty css */const h=require("antd"),c=require("react"),E=require("../../util/ValidationUtil.cjs.js"),S=c.lazy(async()=>{const{default:e}=await import("react-quill");return{default:t=>a.jsx(e,{...t})}}),T=({name:e,label:t,required:r,rules:s=[],disabled:o,help:f})=>{const n=h.Form.useFormInstance(),[u,d]=c.useState(""),b={toolbar:[["bold","italic","underline","strike","blockquote"],[{list:"ordered"},{list:"bullet"}],["link"],["clean"]]},k=["bold","italic","underline","strike","blockquote","list","bullet","link"];c.useEffect(()=>{const i=n.getFieldValue(e);i&&i!=="<p></p>"&&i!=="<p><br></p>"&&d(i)},[n,e]);const l=h.Form.useWatch(e,n);c.useEffect(()=>{l!==u&&d(!l||l==="<p></p>"||l==="<p><br></p>"?"":l)},[l,u]);const m=i=>{d(i);const g=!i||i==="<p></p>"||i.trim()==="<p><br></p>"?void 0:i;n.setFieldValue(e,g),n.validateFields([e]).catch(()=>{})},x=c.useMemo(()=>r?[...s,...E.required(t??"")]:s,[r,s,t]);return a.jsx(h.Form.Item,{help:f,name:e,label:t,rules:x,children:a.jsx(c.Suspense,{fallback:a.jsx("div",{children:"Loading editor..."}),children:a.jsx(S,{readOnly:o,value:u,onChange:m,theme:"snow",className:"bg-white dark:!bg-[#141414] dark:text-white dark:!fill-white",modules:b,formats:k})})})};exports.RichTextEditor=T;
@@ -1,6 +1,7 @@
1
1
  import { Rule } from 'antd/es/form';
2
- import { FC } from 'react';
2
+ import { FC, ReactNode } from 'react';
3
3
  export interface RichTextEditorProps {
4
+ help?: ReactNode;
4
5
  label?: string;
5
6
  name: string;
6
7
  required?: boolean;
@@ -2,26 +2,27 @@ import { jsx as l } from "react/jsx-runtime";
2
2
  /* empty css */
3
3
  /* empty css */
4
4
  import { Form as a } from "antd";
5
- import V, { useState as g, useEffect as u, useMemo as w, Suspense as F } from "react";
6
- import x from "../../util/ValidationUtil.es.js";
7
- const R = V.lazy(async () => {
5
+ import g, { useState as w, useEffect as u, useMemo as F, Suspense as x } from "react";
6
+ import R from "../../util/ValidationUtil.es.js";
7
+ const y = g.lazy(async () => {
8
8
  const { default: e } = await import("react-quill");
9
9
  return { default: (o) => /* @__PURE__ */ l(e, { ...o }) };
10
- }), S = ({
10
+ }), j = ({
11
11
  name: e,
12
12
  label: o,
13
13
  required: d,
14
14
  rules: c = [],
15
- disabled: p
15
+ disabled: p,
16
+ help: m
16
17
  }) => {
17
- const r = a.useFormInstance(), [n, s] = g(""), m = {
18
+ const r = a.useFormInstance(), [n, s] = w(""), f = {
18
19
  toolbar: [
19
20
  ["bold", "italic", "underline", "strike", "blockquote"],
20
21
  [{ list: "ordered" }, { list: "bullet" }],
21
22
  ["link"],
22
23
  ["clean"]
23
24
  ]
24
- }, f = [
25
+ }, h = [
25
26
  "bold",
26
27
  "italic",
27
28
  "underline",
@@ -39,28 +40,28 @@ const R = V.lazy(async () => {
39
40
  u(() => {
40
41
  i !== n && s(!i || i === "<p></p>" || i === "<p><br></p>" ? "" : i);
41
42
  }, [i, n]);
42
- const h = (t) => {
43
+ const b = (t) => {
43
44
  s(t);
44
- const k = !t || t === "<p></p>" || t.trim() === "<p><br></p>" ? void 0 : t;
45
- r.setFieldValue(e, k), r.validateFields([e]).catch(() => {
45
+ const V = !t || t === "<p></p>" || t.trim() === "<p><br></p>" ? void 0 : t;
46
+ r.setFieldValue(e, V), r.validateFields([e]).catch(() => {
46
47
  });
47
- }, b = w(
48
- () => d ? [...c, ...x.required(o ?? "")] : c,
48
+ }, k = F(
49
+ () => d ? [...c, ...R.required(o ?? "")] : c,
49
50
  [d, c, o]
50
51
  );
51
- return /* @__PURE__ */ l(a.Item, { name: e, label: o, rules: b, children: /* @__PURE__ */ l(F, { fallback: /* @__PURE__ */ l("div", { children: "Loading editor..." }), children: /* @__PURE__ */ l(
52
- R,
52
+ return /* @__PURE__ */ l(a.Item, { help: m, name: e, label: o, rules: k, children: /* @__PURE__ */ l(x, { fallback: /* @__PURE__ */ l("div", { children: "Loading editor..." }), children: /* @__PURE__ */ l(
53
+ y,
53
54
  {
54
55
  readOnly: p,
55
56
  value: n,
56
- onChange: h,
57
+ onChange: b,
57
58
  theme: "snow",
58
59
  className: "bg-white dark:!bg-[#141414] dark:text-white dark:!fill-white",
59
- modules: m,
60
- formats: f
60
+ modules: f,
61
+ formats: h
61
62
  }
62
63
  ) }) });
63
64
  };
64
65
  export {
65
- S as RichTextEditor
66
+ j as RichTextEditor
66
67
  };
@@ -1 +1 @@
1
- "use strict";const n=require("react/jsx-runtime"),l=require("antd"),O=require("react"),V=require("../../locale/index.cjs.js"),B=require("../tooltip/TooltipComponent.cjs.js"),D=require("../../util/ValidationUtil.cjs.js");function E({label:a,rules:S=[],required:h,placeholder:x,notSearch:L,children:f,readOnly:s,items:o,dropdownRender:p,itemBuilder:q,loading:m,showLoadingInEmptyIndicator:T,nameFieldInArray:u="name",innerRef:_,tooltip:b,filterOption:N,tagRender:R,...r}){const{t:P}=V.useTranslationLib(),k=O.useCallback(e=>{const t=typeof e=="string"||typeof e=="number"?e:e==null?void 0:e.id,c=typeof e=="string"||typeof e=="number"?e:e==null?void 0:e[u];return n.jsx("option",{value:t,children:n.jsx("div",{dangerouslySetInnerHTML:{__html:c}})},t)},[u]),F=a??x??"";return n.jsx(l.ConfigProvider,{renderEmpty:T&&m?()=>n.jsx(l.Spin,{}):void 0,children:n.jsx(B,{title:b,children:n.jsx(l.Form.Item,{label:a,name:r.name,help:r.help,className:r.className,required:h,rules:[...S,...h?D.required(F):[]],children:n.jsx(l.Select,{ref:_,loading:m,open:s?!1:void 0,onChange:!s&&r.onChange,allowClear:!s&&r.allowClear,showSearch:!L,className:`max-width ${s?"readOnly":""}`,...r,tagRender:R,placeholder:x??a,filterOption:N??((e,t)=>{var c,g,C,j;try{const i=(C=(g=(c=t==null?void 0:t.children)==null?void 0:c.props)==null?void 0:g.dangerouslySetInnerHTML)==null?void 0:C.__html,H=e.toLowerCase().split(/\s+/),y=(t==null?void 0:t.children)??"",w=typeof y=="string"?y.toLowerCase():typeof i=="string"?i.toLowerCase():"",I=(((j=t==null?void 0:t.value)==null?void 0:j.toString())??"").toLowerCase(),M=w.replace(/\s/g,"");return H.every(d=>w.indexOf(d)>=0||I.indexOf(d)>=0||M.indexOf(d)>=0)}catch(i){return console.log(i),!0}}),popupRender:p,children:f===null?void 0:f??(o?o==null?void 0:o.map(q??k):n.jsx(n.Fragment,{}))})})})})}module.exports=E;
1
+ "use strict";const r=require("react/jsx-runtime"),l=require("antd"),V=require("react"),B=require("../../locale/index.cjs.js"),D=require("../tooltip/TooltipComponent.cjs.js"),E=require("../../util/ValidationUtil.cjs.js");function P({label:a,rules:S=[],required:x,placeholder:h,notSearch:L,children:f,readOnly:s,items:o,dropdownRender:p,itemBuilder:q,loading:m,showLoadingInEmptyIndicator:T,nameFieldInArray:u="name",innerRef:_,tooltip:b,filterOption:N,tagRender:R,help:k,...n}){const{t:U}=B.useTranslationLib(),F=V.useCallback(e=>{const t=typeof e=="string"||typeof e=="number"?e:e==null?void 0:e.id,c=typeof e=="string"||typeof e=="number"?e:e==null?void 0:e[u];return r.jsx("option",{value:t,children:r.jsx("div",{dangerouslySetInnerHTML:{__html:c}})},t)},[u]),H=a??h??"";return r.jsx(l.ConfigProvider,{renderEmpty:T&&m?()=>r.jsx(l.Spin,{}):void 0,children:r.jsx(D,{title:b,children:r.jsx(l.Form.Item,{label:a,name:n.name,help:k,className:n.className,required:x,rules:[...S,...x?E.required(H):[]],children:r.jsx(l.Select,{ref:_,loading:m,open:s?!1:void 0,onChange:!s&&n.onChange,allowClear:!s&&n.allowClear,showSearch:!L,className:`max-width ${s?"readOnly":""}`,...n,tagRender:R,placeholder:h??a,filterOption:N??((e,t)=>{var c,g,C,j;try{const i=(C=(g=(c=t==null?void 0:t.children)==null?void 0:c.props)==null?void 0:g.dangerouslySetInnerHTML)==null?void 0:C.__html,I=e.toLowerCase().split(/\s+/),y=(t==null?void 0:t.children)??"",w=typeof y=="string"?y.toLowerCase():typeof i=="string"?i.toLowerCase():"",M=(((j=t==null?void 0:t.value)==null?void 0:j.toString())??"").toLowerCase(),O=w.replace(/\s/g,"");return I.every(d=>w.indexOf(d)>=0||M.indexOf(d)>=0||O.indexOf(d)>=0)}catch(i){return console.log(i),!0}}),popupRender:p,children:f===null?void 0:f??(o?o==null?void 0:o.map(q??F):r.jsx(r.Fragment,{}))})})})})}module.exports=P;
@@ -17,5 +17,5 @@ interface SelectComponentProps<T> extends SelectProps<any>, FormItemProps<any> {
17
17
  filterOption?: SelectProps["filterOption"];
18
18
  tagRender?: SelectTagRenderProps;
19
19
  }
20
- declare function SelectComponent<T = any>({ label, rules, required, placeholder, notSearch, children, readOnly, items, dropdownRender, itemBuilder, loading, showLoadingInEmptyIndicator, nameFieldInArray, innerRef, tooltip, filterOption, tagRender, ...props }: Readonly<SelectComponentProps<T>>): import("react/jsx-runtime").JSX.Element;
20
+ declare function SelectComponent<T = any>({ label, rules, required, placeholder, notSearch, children, readOnly, items, dropdownRender, itemBuilder, loading, showLoadingInEmptyIndicator, nameFieldInArray, innerRef, tooltip, filterOption, tagRender, help, ...props }: Readonly<SelectComponentProps<T>>): import("react/jsx-runtime").JSX.Element;
21
21
  export default SelectComponent;
@@ -1,10 +1,10 @@
1
- import { jsx as t, Fragment as j } from "react/jsx-runtime";
2
- import { ConfigProvider as B, Form as D, Select as E, Spin as P } from "antd";
3
- import { useCallback as R } from "react";
4
- import { useTranslationLib as U } from "../../locale/index.es.js";
5
- import W from "../tooltip/TooltipComponent.es.js";
6
- import $ from "../../util/ValidationUtil.es.js";
7
- function Y({
1
+ import { jsx as t, Fragment as B } from "react/jsx-runtime";
2
+ import { ConfigProvider as D, Form as E, Select as P, Spin as R } from "antd";
3
+ import { useCallback as U } from "react";
4
+ import { useTranslationLib as W } from "../../locale/index.es.js";
5
+ import $ from "../tooltip/TooltipComponent.es.js";
6
+ import q from "../../util/ValidationUtil.es.js";
7
+ function Z({
8
8
  label: m,
9
9
  rules: S = [],
10
10
  required: f,
@@ -22,33 +22,34 @@ function Y({
22
22
  tooltip: N,
23
23
  filterOption: k,
24
24
  tagRender: F,
25
+ help: H,
25
26
  ...n
26
27
  }) {
27
- const { t: q } = U(), H = R(
28
+ const { t: z } = W(), I = U(
28
29
  (e) => {
29
30
  const r = typeof e == "string" || typeof e == "number" ? e : e == null ? void 0 : e.id, c = typeof e == "string" || typeof e == "number" ? e : e == null ? void 0 : e[g];
30
31
  return /* @__PURE__ */ t("option", { value: r, children: /* @__PURE__ */ t("div", { dangerouslySetInnerHTML: { __html: c } }) }, r);
31
32
  },
32
33
  [g]
33
- ), I = m ?? a ?? "";
34
+ ), M = m ?? a ?? "";
34
35
  return /* @__PURE__ */ t(
35
- B,
36
+ D,
36
37
  {
37
- renderEmpty: _ && h ? () => /* @__PURE__ */ t(P, {}) : void 0,
38
- children: /* @__PURE__ */ t(W, { title: N, children: /* @__PURE__ */ t(
39
- D.Item,
38
+ renderEmpty: _ && h ? () => /* @__PURE__ */ t(R, {}) : void 0,
39
+ children: /* @__PURE__ */ t($, { title: N, children: /* @__PURE__ */ t(
40
+ E.Item,
40
41
  {
41
42
  label: m,
42
43
  name: n.name,
43
- help: n.help,
44
+ help: H,
44
45
  className: n.className,
45
46
  required: f,
46
47
  rules: [
47
48
  ...S,
48
- ...f ? $.required(I) : []
49
+ ...f ? q.required(M) : []
49
50
  ],
50
51
  children: /* @__PURE__ */ t(
51
- E,
52
+ P,
52
53
  {
53
54
  ref: b,
54
55
  loading: h,
@@ -63,16 +64,16 @@ function Y({
63
64
  filterOption: k ?? ((e, r) => {
64
65
  var c, p, C, y;
65
66
  try {
66
- const i = (C = (p = (c = r == null ? void 0 : r.children) == null ? void 0 : c.props) == null ? void 0 : p.dangerouslySetInnerHTML) == null ? void 0 : C.__html, M = e.toLowerCase().split(/\s+/), w = (r == null ? void 0 : r.children) ?? "", x = typeof w == "string" ? w.toLowerCase() : typeof i == "string" ? i.toLowerCase() : "", O = (((y = r == null ? void 0 : r.value) == null ? void 0 : y.toString()) ?? "").toLowerCase(), V = x.replace(/\s/g, "");
67
- return M.every(
68
- (l) => x.indexOf(l) >= 0 || O.indexOf(l) >= 0 || V.indexOf(l) >= 0
67
+ const i = (C = (p = (c = r == null ? void 0 : r.children) == null ? void 0 : c.props) == null ? void 0 : p.dangerouslySetInnerHTML) == null ? void 0 : C.__html, O = e.toLowerCase().split(/\s+/), w = (r == null ? void 0 : r.children) ?? "", x = typeof w == "string" ? w.toLowerCase() : typeof i == "string" ? i.toLowerCase() : "", V = (((y = r == null ? void 0 : r.value) == null ? void 0 : y.toString()) ?? "").toLowerCase(), j = x.replace(/\s/g, "");
68
+ return O.every(
69
+ (l) => x.indexOf(l) >= 0 || V.indexOf(l) >= 0 || j.indexOf(l) >= 0
69
70
  );
70
71
  } catch (i) {
71
72
  return console.log(i), !0;
72
73
  }
73
74
  }),
74
75
  popupRender: u,
75
- children: d === null ? void 0 : d ?? (s ? s == null ? void 0 : s.map(T ?? H) : /* @__PURE__ */ t(j, {}))
76
+ children: d === null ? void 0 : d ?? (s ? s == null ? void 0 : s.map(T ?? I) : /* @__PURE__ */ t(B, {}))
76
77
  }
77
78
  )
78
79
  }
@@ -81,5 +82,5 @@ function Y({
81
82
  );
82
83
  }
83
84
  export {
84
- Y as default
85
+ Z as default
85
86
  };
@@ -1 +1 @@
1
- "use strict";const e=require("react/jsx-runtime"),l=require("antd"),t=require("react"),H=require("./modal/index.cjs.js"),J=require("./import/CrudImportButton.cjs.js"),K=require("./view/CrudViewer.cjs.js"),L=require("../common/button/NewButton.cjs.js"),M=require("../common/button/PrintButton.cjs.js"),{useForm:Q}=l.Form;function O({idField:a="id",onCreate:C,onDelete:j,onHide:m,onUpdate:n,fields:r,data:f,grid:k,isHiding:q,isCreating:h,isDeleting:p,isUpdating:B,paginateProps:w,onPrint:i,printing:N,viewable:v,loadingData:R,formBuilder:g,extraAction:y,minusHeight:b,cloneable:F,fullWidthModal:P=!0,wizard:S,extraView:I,importable:u,onClickNew:d,size:V,...z}){const c=t.useRef(null),A=t.useCallback(()=>{var s;(s=c.current)==null||s.create()},[]),o=t.useCallback(async(s,E=!0,G=!1)=>{var x;await((x=c.current)==null?void 0:x.update(s,E,G))},[]),D=t.useCallback(async s=>{o(s,!1,!0)},[o]);return e.jsxs(e.Fragment,{children:[e.jsxs(l.Space,{direction:"vertical",className:"w-100",children:[e.jsxs("div",{className:"w-100 d-flex",children:[e.jsx("div",{style:{flex:1},children:e.jsx(L.NewButton,{onClick:()=>{d?d():A()},className:"flex-1"})}),e.jsxs(l.Space,{children:[!!i&&e.jsx(M.PrintButton,{className:"float-right",loading:N,onClick:i}),!!u&&e.jsx(J,{fields:r,importProps:u})]})]}),e.jsx(K,{...z,minusHeight:b,data:f,size:V,fields:r,extraAction:y,idField:a,isDeleting:p,loadingData:R,onClickUpdate:n?o:void 0,onHide:m,isHiding:q,onDelete:j,onUpdate:n,onClickClone:F?D:void 0,paginateProps:w,viewable:v,extraView:I})]}),e.jsx(H,{ref:c,fields:r,wizard:S,grid:k,fullWidthModal:P,isCreating:h,isUpdating:B,onCreate:C,onUpdate:n,idField:a,formBuilder:g})]})}module.exports=O;
1
+ "use strict";const e=require("react/jsx-runtime"),x=require("antd"),t=require("react"),H=require("./modal/index.cjs.js"),J=require("./import/CrudImportButton.cjs.js"),K=require("./view/CrudViewer.cjs.js"),L=require("../common/button/NewButton.cjs.js"),M=require("../common/button/PrintButton.cjs.js");function O({idField:l="id",onCreate:C,onDelete:j,onHide:f,onUpdate:n,fields:r,data:m,grid:k,isHiding:q,isCreating:h,isDeleting:p,isUpdating:B,paginateProps:w,onPrint:a,printing:N,viewable:v,loadingData:R,formBuilder:g,extraAction:y,minusHeight:b,cloneable:P,fullWidthModal:S=!0,wizard:I,extraView:V,importable:i,onClickNew:u,size:z,...A}){const c=t.useRef(null),D=t.useCallback(()=>{var s;(s=c.current)==null||s.create()},[]),o=t.useCallback(async(s,F=!0,G=!1)=>{var d;await((d=c.current)==null?void 0:d.update(s,F,G))},[]),E=t.useCallback(async s=>{o(s,!1,!0)},[o]);return e.jsxs(e.Fragment,{children:[e.jsxs(x.Space,{direction:"vertical",className:"w-100",children:[e.jsxs("div",{className:"w-100 d-flex",children:[e.jsx("div",{style:{flex:1},children:e.jsx(L.NewButton,{onClick:()=>{u?u():D()},className:"flex-1"})}),e.jsxs(x.Space,{children:[!!a&&e.jsx(M.PrintButton,{className:"float-right",loading:N,onClick:a}),!!i&&e.jsx(J,{fields:r,importProps:i})]})]}),e.jsx(K,{...A,minusHeight:b,data:m,size:z,fields:r,extraAction:y,idField:l,isDeleting:p,loadingData:R,onClickUpdate:n?o:void 0,onHide:f,isHiding:q,onDelete:j,onUpdate:n,onClickClone:P?E:void 0,paginateProps:w,viewable:v,extraView:V})]}),e.jsx(H,{ref:c,fields:r,wizard:I,grid:k,fullWidthModal:S,isCreating:h,isUpdating:B,onCreate:C,onUpdate:n,idField:l,formBuilder:g})]})}module.exports=O;
@@ -140,6 +140,7 @@ export interface ColorPickerFieldProps<T> extends Omit<InitialCrudField<T>, "pla
140
140
  export interface CheckboxBasedFieldProps<T> extends InitialCrudField<T> {
141
141
  type: "checkbox";
142
142
  onChange?: (value: boolean, form: FormInstance<T>) => void;
143
+ switch?: boolean;
143
144
  }
144
145
  export interface NumberBasedFieldProps<T> extends InitialCrudField<T>, AddonFieldProps {
145
146
  type: "number";
@@ -1,19 +1,18 @@
1
1
  import { jsxs as e, Fragment as H, jsx as r } from "react/jsx-runtime";
2
- import { Space as f, Form as J } from "antd";
3
- import { useRef as K, useCallback as c } from "react";
4
- import L from "./modal/index.es.js";
5
- import O from "./import/CrudImportButton.es.js";
6
- import Q from "./view/CrudViewer.es.js";
7
- import { NewButton as T } from "../common/button/NewButton.es.js";
8
- import { PrintButton as U } from "../common/button/PrintButton.es.js";
9
- const { useForm: eo } = J;
10
- function to({
2
+ import { Space as f } from "antd";
3
+ import { useRef as J, useCallback as c } from "react";
4
+ import K from "./modal/index.es.js";
5
+ import L from "./import/CrudImportButton.es.js";
6
+ import O from "./view/CrudViewer.es.js";
7
+ import { NewButton as Q } from "../common/button/NewButton.es.js";
8
+ import { PrintButton as T } from "../common/button/PrintButton.es.js";
9
+ function ro({
11
10
  idField: i = "id",
12
11
  onCreate: p,
13
12
  onDelete: C,
14
13
  onHide: h,
15
14
  onUpdate: t,
16
- fields: n,
15
+ fields: l,
17
16
  data: k,
18
17
  grid: x,
19
18
  isHiding: v,
@@ -24,29 +23,29 @@ function to({
24
23
  onPrint: m,
25
24
  printing: y,
26
25
  viewable: j,
27
- loadingData: F,
28
- formBuilder: R,
29
- extraAction: I,
30
- minusHeight: M,
31
- cloneable: P,
32
- fullWidthModal: S = !0,
33
- wizard: V,
34
- extraView: b,
26
+ loadingData: R,
27
+ formBuilder: I,
28
+ extraAction: M,
29
+ minusHeight: P,
30
+ cloneable: S,
31
+ fullWidthModal: V = !0,
32
+ wizard: b,
33
+ extraView: q,
35
34
  importable: s,
36
35
  onClickNew: u,
37
- size: q,
38
- ...z
36
+ size: z,
37
+ ...A
39
38
  }) {
40
- const l = K(null), A = c(() => {
39
+ const n = J(null), D = c(() => {
41
40
  var o;
42
- (o = l.current) == null || o.create();
41
+ (o = n.current) == null || o.create();
43
42
  }, []), a = c(
44
- async (o, E = !0, G = !1) => {
43
+ async (o, F = !0, G = !1) => {
45
44
  var d;
46
- await ((d = l.current) == null ? void 0 : d.update(o, E, G));
45
+ await ((d = n.current) == null ? void 0 : d.update(o, F, G));
47
46
  },
48
47
  []
49
- ), D = c(
48
+ ), E = c(
50
49
  async (o) => {
51
50
  a(o, !1, !0);
52
51
  },
@@ -56,68 +55,68 @@ function to({
56
55
  /* @__PURE__ */ e(f, { direction: "vertical", className: "w-100", children: [
57
56
  /* @__PURE__ */ e("div", { className: "w-100 d-flex", children: [
58
57
  /* @__PURE__ */ r("div", { style: { flex: 1 }, children: /* @__PURE__ */ r(
59
- T,
58
+ Q,
60
59
  {
61
60
  onClick: () => {
62
- u ? u() : A();
61
+ u ? u() : D();
63
62
  },
64
63
  className: "flex-1"
65
64
  }
66
65
  ) }),
67
66
  /* @__PURE__ */ e(f, { children: [
68
67
  !!m && /* @__PURE__ */ r(
69
- U,
68
+ T,
70
69
  {
71
70
  className: "float-right",
72
71
  loading: y,
73
72
  onClick: m
74
73
  }
75
74
  ),
76
- !!s && /* @__PURE__ */ r(O, { fields: n, importProps: s })
75
+ !!s && /* @__PURE__ */ r(L, { fields: l, importProps: s })
77
76
  ] })
78
77
  ] }),
79
78
  /* @__PURE__ */ r(
80
- Q,
79
+ O,
81
80
  {
82
- ...z,
83
- minusHeight: M,
81
+ ...A,
82
+ minusHeight: P,
84
83
  data: k,
85
- size: q,
86
- fields: n,
87
- extraAction: I,
84
+ size: z,
85
+ fields: l,
86
+ extraAction: M,
88
87
  idField: i,
89
88
  isDeleting: B,
90
- loadingData: F,
89
+ loadingData: R,
91
90
  onClickUpdate: t ? a : void 0,
92
91
  onHide: h,
93
92
  isHiding: v,
94
93
  onDelete: C,
95
94
  onUpdate: t,
96
- onClickClone: P ? D : void 0,
95
+ onClickClone: S ? E : void 0,
97
96
  paginateProps: g,
98
97
  viewable: j,
99
- extraView: b
98
+ extraView: q
100
99
  }
101
100
  )
102
101
  ] }),
103
102
  /* @__PURE__ */ r(
104
- L,
103
+ K,
105
104
  {
106
- ref: l,
107
- fields: n,
108
- wizard: V,
105
+ ref: n,
106
+ fields: l,
107
+ wizard: b,
109
108
  grid: x,
110
- fullWidthModal: S,
109
+ fullWidthModal: V,
111
110
  isCreating: w,
112
111
  isUpdating: N,
113
112
  onCreate: p,
114
113
  onUpdate: t,
115
114
  idField: i,
116
- formBuilder: R
115
+ formBuilder: I
117
116
  }
118
117
  )
119
118
  ] });
120
119
  }
121
120
  export {
122
- to as default
121
+ ro as default
123
122
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),b=require("antd"),q=require("react"),$=require("react-highlight-words"),z=require("../locale/index.cjs.js"),J=require("./FileCrudField.cjs.js"),K=require("./ImageCrudField.cjs.js"),Q=require("../common/check-box/CheckBox.cjs.js"),X=require("../common/date-picker/DatePicker.cjs.js"),Y=require("../common/date-picker/TimePicker.cjs.js"),U=require("../common/select/SelectComponent.cjs.js"),Z=require("../common/text-field/NumberField.cjs.js"),V=require("../common/text-field/TextField.cjs.js"),ee=require("../common/tooltip/TooltipComponent.cjs.js"),re=require("./CrudTextAreaComponent.cjs.js"),M=require("../util/CrudUtil.cjs.js");function te(y){const{label:o,name:m,type:x,required:i,hidden:S,rules:h=[],updatable:g=!0,readonly:R=!1,fieldClassName:C,customFormFieldRender:O,fieldTooltip:j,fieldHelper:v,...r}=y,d=b.Form.useFormInstance();q.useEffect(()=>{if(x==="select"){const{items:a=[],onSearch:l,searchOnType:u}=r;!(a!=null&&a.length)&&!u&&(l==null||l(void 0,d,r==null?void 0:r.updatingValue))}},[d,r,x,r==null?void 0:r.updatingValue]);const{t:P}=z.useTranslationLibNoNS();if(R||S)return e.jsx(e.Fragment,{});if(O)return O(d,y);switch(x){case"text":case"email":case"password":{const{onChange:a,placeholder:l,addonAfter:u,addonBefore:f}=r;return e.jsx(V.default,{placeholder:l,disabled:!g,rules:h,required:i,onChange:a?s=>a(s,d):void 0,type:x,name:m,tooltip:j,label:o,className:C,autoComplete:"new-password",addonAfter:u,addonBefore:f,help:v})}case"number":{const{onChange:a,placeholder:l,allowMinus:u,min:f,max:s,addonAfter:T,addonBefore:p}=r;return e.jsx(Z,{placeholder:l,disabled:!g,moneyField:!!r.formatted,type:x,onChange:a?F=>a(F,d):void 0,rules:h,autoComplete:"false",required:i,tooltip:j,className:C,min:u?null:f,max:s,addonAfter:T,addonBefore:p,name:m,label:o,help:v})}case"date":{const{range:a,disableToday:l,disabledFutureDays:u,disabledPastDays:f,onChange:s,placeholder:T,format:p}=r;return e.jsx(X,{placeholder:T,required:i,disabled:!g,type:x,format:p,tooltip:j,range:a,name:m,label:o,onChange:s?F=>s(F,d):void 0,className:C,disableToday:l,disabledFutureDays:u,disabledPastDays:f,help:v})}case"time":{const{range:a=!1,disableCurrent:l,disabledFuture:u,disabledPast:f,onChange:s,use12Hours:T,format:p,placeholder:F}=r;return e.jsx(Y,{placeholder:F,required:i,format:p,disabled:!g,type:x,tooltip:j,range:a,use12Hours:T,name:m,label:o,onChange:s?n=>s(n,d):void 0,className:C,disableCurrent:l,disabledFuture:u,disabledPast:f,help:v})}case"textarea":return e.jsx(re,{...y});case"image":return e.jsx(K.default,{...r,required:i,name:m,label:o,rules:h,fieldClassName:C,onRemoved:r.onRemoved,onUploading:r.onUploading,provider:r.provider});case"file":return e.jsx(J.default,{...r,required:i,name:m,label:o,rules:h,fieldClassName:C,onRemoved:r.onRemoved,onUploading:r.onUploading,provider:r.provider});case"select":return e.jsx(E,{...r,required:i,name:m,label:o,rules:h,fieldClassName:C,form:d,updatable:g,readonly:R,fieldTooltip:j,fieldHelper:v});case"enum":{const{enum:a,radio:l=!1,translation:u,onChange:f,onSearch:s,multiple:T,tagRender:p}=r,F=Array.isArray(a)?a:Object.keys(a);return l?e.jsx(b.Form.Item,{...r,name:m,required:i,tooltip:j,rules:h,label:o,className:["w-100",C].join(" "),help:v,children:e.jsx(b.Radio.Group,{...r,onChange:f?n=>{var N;return f((N=n==null?void 0:n.target)==null?void 0:N.value,d)}:void 0,children:F.map(n=>e.jsx(b.Radio,{disabled:!g,value:n,children:u?P(u[n]):n},n))})}):e.jsx(U,{...r,tagRender:typeof p=="function"?p:p?n=>{const{value:N,label:w}=n,k=p[N];return k?e.jsx(b.Tag,{color:k.color,children:w}):e.jsx(b.Tag,{children:w})}:void 0,onChange:f?n=>f(n,d):void 0,className:["w-100",C].join(" "),name:m,items:F,required:i,tooltip:j,rules:h,label:o,help:v,disabled:!g,onSearch:s?n=>s(n,d):void 0,allowClear:!0,mode:T?"multiple":void 0,itemBuilder:n=>e.jsx(b.Select.Option,{value:n,children:u?P(u[n]):n},n)})}case"checkbox":{const{onChange:a}=r;return e.jsx(Q,{className:C,rules:h,onChange:a?l=>a(l,d):void 0,label:o,tooltip:j,disabled:!g,name:m,help:v})}case"color":return e.jsx(D,{...r,type:"color",required:i,name:m,label:o,rules:h,fieldClassName:C,updatable:g,readonly:R,fieldTooltip:j,fieldHelper:v});default:return e.jsx(e.Fragment,{children:`${x} Not Implemented`})}}function E(y){const{items:o=[],loading:m,searchOnType:x,onSearch:i,multiple:S,onChange:h,highlightSearch:g,required:R,fieldClassName:C,rules:O,fieldTooltip:j,updatable:v,label:r,name:d,tagRender:P,updatingValue:a,onSet:l,placeholder:u,allowClear:f=!0}=y,s=y.form,[T,p]=q.useState(""),F=q.useMemo(()=>M.getRealName(d),[d]),n=q.useMemo(()=>M.getRealName(d,"upsertFieldName"),[d]),N=b.Form.useWatch(F,s),[w,k]=q.useState(!0);q.useEffect(()=>{l&&w&&N&&(l==null||l(N,o,s),k(!1))},[w,s,o,F,l,N]),q.useEffect(()=>{N&&k(!0)},[N]);const _=q.useCallback(async t=>{p(t),x&&(i==null||i(t,s,a))},[s,i,x,a]);return e.jsx(U,{...y,maxTagCount:"responsive",maxTagPlaceholder:t=>e.jsxs(ee,{title:e.jsx(e.Fragment,{children:t.map(c=>e.jsxs(e.Fragment,{children:[c.label," ",e.jsx("br",{})]}))}),children:["+",t==null?void 0:t.length]}),placeholder:u,onSelect:t=>{l==null||l(t==null?void 0:t.key,o,s)},onChange:h?t=>{p(""),h(t,s)}:void 0,mode:S?"multiple":void 0,className:["w-100",C].join(" "),name:n,items:o,required:R,tooltip:j,tagRender:P,rules:O,disabled:!v,label:r,allowClear:f,onSearch:_,loading:m,filterOption:g?(t,c)=>{var H,A,B;try{const I=t.toLowerCase().split(/\s+/),W=((typeof(c==null?void 0:c.children)=="string"?c==null?void 0:c.children:(A=(H=c==null?void 0:c.children)==null?void 0:H.props)==null?void 0:A.textToHighlight)??"").toLowerCase(),G=(((B=c==null?void 0:c.value)==null?void 0:B.toString())??"").toLowerCase();return I.every(L=>W.indexOf(L)>=0||G.indexOf(L)>=0)}catch{return!0}}:void 0,itemBuilder:g?t=>{const c=t.value?String(t.value):void 0;return e.jsx(b.Select.Option,{value:t.key,title:c,disabled:t.disabled,children:e.jsx($,{highlightClassName:"highlight-text",searchWords:(T??"").split(" "),autoEscape:!0,textToHighlight:c??""})},t.key)}:t=>e.jsx(b.Select.Option,{value:t.key,title:t.value,disabled:t.disabled,children:t.value},t.key)})}function D(y){const{required:o,fieldClassName:m,rules:x,fieldTooltip:i,updatable:S,label:h,name:g,fieldHelper:R}=y;return e.jsx(b.Form.Item,{label:h,name:g,required:o,rules:x,tooltip:i,help:R,children:e.jsx(b.ColorPicker,{disabledAlpha:!0,format:"hex",defaultFormat:"hex",showText:!0,trigger:"click",className:m,disabled:!S,...y.innerProps})})}exports.ColorCrudFieldComponent=D;exports.SelectCrudFieldComponent=E;exports.default=te;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),j=require("antd"),q=require("react"),$=require("react-highlight-words"),z=require("../locale/index.cjs.js"),J=require("./FileCrudField.cjs.js"),K=require("./ImageCrudField.cjs.js"),Q=require("../common/check-box/CheckBox.cjs.js"),X=require("../common/date-picker/DatePicker.cjs.js"),Y=require("../common/date-picker/TimePicker.cjs.js"),U=require("../common/select/SelectComponent.cjs.js"),Z=require("../common/text-field/NumberField.cjs.js"),V=require("../common/text-field/TextField.cjs.js"),ee=require("../common/tooltip/TooltipComponent.cjs.js"),re=require("./CrudTextAreaComponent.cjs.js"),M=require("../util/CrudUtil.cjs.js");function te(y){const{label:i,name:m,type:x,required:d,hidden:S,rules:h=[],updatable:g=!0,readonly:w=!1,fieldClassName:C,customFormFieldRender:H,fieldTooltip:v,fieldHelper:f,...r}=y,c=j.Form.useFormInstance();q.useEffect(()=>{if(x==="select"){const{items:a=[],onSearch:l,searchOnType:o}=r;!(a!=null&&a.length)&&!o&&(l==null||l(void 0,c,r==null?void 0:r.updatingValue))}},[c,r,x,r==null?void 0:r.updatingValue]);const{t:O}=z.useTranslationLibNoNS();if(w||S)return e.jsx(e.Fragment,{});if(H)return H(c,y);switch(x){case"text":case"email":case"password":{const{onChange:a,placeholder:l,addonAfter:o,addonBefore:p}=r;return e.jsx(V.default,{placeholder:l,disabled:!g,rules:h,required:d,onChange:a?s=>a(s,c):void 0,type:x,name:m,tooltip:v,label:i,className:C,autoComplete:"new-password",addonAfter:o,addonBefore:p,help:f})}case"number":{const{onChange:a,placeholder:l,allowMinus:o,min:p,max:s,addonAfter:T,addonBefore:b}=r;return e.jsx(Z,{placeholder:l,disabled:!g,moneyField:!!r.formatted,type:x,onChange:a?F=>a(F,c):void 0,rules:h,autoComplete:"false",required:d,tooltip:v,className:C,min:o?null:p,max:s,addonAfter:T,addonBefore:b,name:m,label:i,help:f})}case"date":{const{range:a,disableToday:l,disabledFutureDays:o,disabledPastDays:p,onChange:s,placeholder:T,format:b}=r;return e.jsx(X,{placeholder:T,required:d,disabled:!g,type:x,format:b,tooltip:v,range:a,name:m,label:i,onChange:s?F=>s(F,c):void 0,className:C,disableToday:l,disabledFutureDays:o,disabledPastDays:p,help:f})}case"time":{const{range:a=!1,disableCurrent:l,disabledFuture:o,disabledPast:p,onChange:s,use12Hours:T,format:b,placeholder:F}=r;return e.jsx(Y,{placeholder:F,required:d,format:b,disabled:!g,type:x,tooltip:v,range:a,use12Hours:T,name:m,label:i,onChange:s?n=>s(n,c):void 0,className:C,disableCurrent:l,disabledFuture:o,disabledPast:p,help:f})}case"textarea":return e.jsx(re,{...y});case"image":return e.jsx(K.default,{...r,required:d,name:m,label:i,rules:h,fieldHelper:f,fieldClassName:C,onRemoved:r.onRemoved,onUploading:r.onUploading,provider:r.provider});case"file":return e.jsx(J.default,{...r,required:d,name:m,label:i,rules:h,fieldHelper:f,fieldClassName:C,onRemoved:r.onRemoved,onUploading:r.onUploading,provider:r.provider});case"select":return e.jsx(E,{...r,required:d,name:m,label:i,rules:h,fieldClassName:C,form:c,help:f,updatable:g,readonly:w,fieldTooltip:v,fieldHelper:f});case"enum":{const{enum:a,radio:l=!1,translation:o,onChange:p,onSearch:s,multiple:T,tagRender:b}=r,F=Array.isArray(a)?a:Object.keys(a);return l?e.jsx(j.Form.Item,{...r,name:m,required:d,tooltip:v,rules:h,label:i,className:["w-100",C].join(" "),help:f,children:e.jsx(j.Radio.Group,{...r,onChange:p?n=>{var N;return p((N=n==null?void 0:n.target)==null?void 0:N.value,c)}:void 0,children:F.map(n=>e.jsx(j.Radio,{disabled:!g,value:n,children:o?O(o[n]):n},n))})}):e.jsx(U,{...r,tagRender:typeof b=="function"?b:b?n=>{const{value:N,label:R}=n,k=b[N];return k?e.jsx(j.Tag,{color:k.color,children:R}):e.jsx(j.Tag,{children:R})}:void 0,onChange:p?n=>p(n,c):void 0,className:["w-100",C].join(" "),name:m,items:F,required:d,tooltip:v,rules:h,label:i,help:f,disabled:!g,onSearch:s?n=>s(n,c):void 0,allowClear:!0,mode:T?"multiple":void 0,itemBuilder:n=>e.jsx(j.Select.Option,{value:n,children:o?O(o[n]):n},n)})}case"checkbox":{const{onChange:a,switch:l}=r;return e.jsx(Q,{className:C,rules:h,onChange:a?o=>a(o,c):void 0,label:i,tooltip:v,disabled:!g,name:m,help:f,switch:l})}case"color":return e.jsx(D,{...r,type:"color",required:d,name:m,label:i,rules:h,fieldClassName:C,updatable:g,readonly:w,fieldTooltip:v,fieldHelper:f});default:return e.jsx(e.Fragment,{children:`${x} Not Implemented`})}}function E(y){const{items:i=[],loading:m,searchOnType:x,onSearch:d,multiple:S,onChange:h,highlightSearch:g,required:w,fieldClassName:C,rules:H,fieldTooltip:v,updatable:f,label:r,name:c,tagRender:O,updatingValue:a,onSet:l,placeholder:o,allowClear:p=!0}=y,s=y.form,[T,b]=q.useState(""),F=q.useMemo(()=>M.getRealName(c),[c]),n=q.useMemo(()=>M.getRealName(c,"upsertFieldName"),[c]),N=j.Form.useWatch(F,s),[R,k]=q.useState(!0);q.useEffect(()=>{l&&R&&N&&(l==null||l(N,i,s),k(!1))},[R,s,i,F,l,N]),q.useEffect(()=>{N&&k(!0)},[N]);const _=q.useCallback(async t=>{b(t),x&&(d==null||d(t,s,a))},[s,d,x,a]);return e.jsx(U,{...y,maxTagCount:"responsive",maxTagPlaceholder:t=>e.jsxs(ee,{title:e.jsx(e.Fragment,{children:t.map(u=>e.jsxs(e.Fragment,{children:[u.label," ",e.jsx("br",{})]}))}),children:["+",t==null?void 0:t.length]}),placeholder:o,onSelect:t=>{l==null||l(t==null?void 0:t.key,i,s)},onChange:h?t=>{b(""),h(t,s)}:void 0,mode:S?"multiple":void 0,className:["w-100",C].join(" "),name:n,items:i,required:w,tooltip:v,tagRender:O,rules:H,disabled:!f,label:r,allowClear:p,onSearch:_,loading:m,filterOption:g?(t,u)=>{var P,A,B;try{const I=t.toLowerCase().split(/\s+/),W=((typeof(u==null?void 0:u.children)=="string"?u==null?void 0:u.children:(A=(P=u==null?void 0:u.children)==null?void 0:P.props)==null?void 0:A.textToHighlight)??"").toLowerCase(),G=(((B=u==null?void 0:u.value)==null?void 0:B.toString())??"").toLowerCase();return I.every(L=>W.indexOf(L)>=0||G.indexOf(L)>=0)}catch{return!0}}:void 0,itemBuilder:g?t=>{const u=t.value?String(t.value):void 0;return e.jsx(j.Select.Option,{value:t.key,title:u,disabled:t.disabled,children:e.jsx($,{highlightClassName:"highlight-text",searchWords:(T??"").split(" "),autoEscape:!0,textToHighlight:u??""})},t.key)}:t=>e.jsx(j.Select.Option,{value:t.key,title:t.value,disabled:t.disabled,children:t.value},t.key)})}function D(y){const{required:i,fieldClassName:m,rules:x,fieldTooltip:d,updatable:S,label:h,name:g,fieldHelper:w}=y;return e.jsx(j.Form.Item,{label:h,name:g,required:i,rules:x,tooltip:d,help:w,children:e.jsx(j.ColorPicker,{disabledAlpha:!0,format:"hex",defaultFormat:"hex",showText:!0,trigger:"click",className:m,disabled:!S,...y.innerProps})})}exports.ColorCrudFieldComponent=D;exports.SelectCrudFieldComponent=E;exports.default=te;