@kingteza/crud-component 1.0.57 → 1.0.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";const t=require("react/jsx-runtime"),d=require("antd"),R=require("react"),B=require("../../locale/index.cjs.js"),D=require("../tooltip/TooltipComponent.cjs.js");function E({label:l,rules:w=[],required:S,placeholder:h,notSearch:L,children:x,readOnly:s,items:c,dropdownRender:q,itemBuilder:T,loading:f,showLoadingInEmptyIndicator:_,nameFieldInArray:m="name",innerRef:p,tooltip:N,filterOption:$,tagRender:b,...n}){const{t:k}=B.useTranslationLib(),H=R.useCallback(e=>{const r=typeof e=="string"||typeof e=="number"?e:e==null?void 0:e.id,o=typeof e=="string"||typeof e=="number"?e:e==null?void 0:e[m];return t.jsx("option",{value:r,children:t.jsx("div",{dangerouslySetInnerHTML:{__html:o}})},r)},[m]);return t.jsx(d.ConfigProvider,{renderEmpty:_&&f?()=>t.jsx(d.Spin,{}):void 0,children:t.jsx(D,{title:N,children:t.jsx(d.Form.Item,{label:l,name:n.name,help:n.help,className:n.className,rules:[...w,{required:S,message:`${l??h??""} ${k("err.validation.required")}`}],children:t.jsx(d.Select,{ref:p,loading:f,open:s?!1:void 0,onChange:!s&&n.onChange,allowClear:!s&&n.allowClear,showSearch:!L,className:`max-width ${s?"readOnly":""}`,...n,tagRender:b,placeholder:h??l,filterOption:$??((e,r)=>{var o,g,u,C;try{const i=(u=(g=(o=r==null?void 0:r.children)==null?void 0:o.props)==null?void 0:g.dangerouslySetInnerHTML)==null?void 0:u.__html,I=e.toLowerCase().split(/\s+/),y=(r==null?void 0:r.children)??"",j=typeof y=="string"?y.toLowerCase():typeof i=="string"?i.toLowerCase():"",M=(((C=r==null?void 0:r.value)==null?void 0:C.toString())??"").toLowerCase(),O=j.replace(/\s/g,"");return I.every(a=>j.indexOf(a)>=0||M.indexOf(a)>=0||O.indexOf(a)>=0)}catch(i){return console.log(i),!0}}),dropdownRender:q,children:x===null?void 0:x??(c&&(c==null?void 0:c.map(T??H)))})})})})}module.exports=E;
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;
@@ -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 }: 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, ...props }: Readonly<SelectComponentProps<T>>): import("react/jsx-runtime").JSX.Element;
21
21
  export default SelectComponent;
@@ -1,81 +1,78 @@
1
- import { jsx as t } from "react/jsx-runtime";
2
- import { ConfigProvider as q, Form as B, Select as D, Spin as E } from "antd";
3
- import { useCallback as F } from "react";
4
- import { useTranslationLib as P } from "../../locale/index.es.js";
5
- import V from "../tooltip/TooltipComponent.es.js";
6
- function Q({
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({
7
8
  label: m,
8
- rules: x = [],
9
- required: S,
10
- placeholder: f,
9
+ rules: S = [],
10
+ required: f,
11
+ placeholder: a,
11
12
  notSearch: L,
12
- children: a,
13
+ children: d,
13
14
  readOnly: o,
14
15
  items: s,
15
16
  dropdownRender: u,
16
17
  itemBuilder: T,
17
- loading: d,
18
+ loading: h,
18
19
  showLoadingInEmptyIndicator: _,
19
- nameFieldInArray: h = "name",
20
- innerRef: N,
21
- tooltip: $,
22
- filterOption: b,
23
- tagRender: k,
20
+ nameFieldInArray: g = "name",
21
+ innerRef: b,
22
+ tooltip: N,
23
+ filterOption: k,
24
+ tagRender: F,
24
25
  ...n
25
26
  }) {
26
- const { t: H } = P(), I = F(
27
+ const { t: q } = U(), H = R(
27
28
  (e) => {
28
- 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[h];
29
+ 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];
29
30
  return /* @__PURE__ */ t("option", { value: r, children: /* @__PURE__ */ t("div", { dangerouslySetInnerHTML: { __html: c } }) }, r);
30
31
  },
31
- [h]
32
- );
32
+ [g]
33
+ ), I = m ?? a ?? "";
33
34
  return /* @__PURE__ */ t(
34
- q,
35
+ B,
35
36
  {
36
- renderEmpty: _ && d ? () => /* @__PURE__ */ t(E, {}) : void 0,
37
- children: /* @__PURE__ */ t(V, { title: $, children: /* @__PURE__ */ t(
38
- B.Item,
37
+ renderEmpty: _ && h ? () => /* @__PURE__ */ t(P, {}) : void 0,
38
+ children: /* @__PURE__ */ t(W, { title: N, children: /* @__PURE__ */ t(
39
+ D.Item,
39
40
  {
40
41
  label: m,
41
42
  name: n.name,
42
43
  help: n.help,
43
44
  className: n.className,
45
+ required: f,
44
46
  rules: [
45
- ...x,
46
- {
47
- required: S,
48
- message: `${m ?? f ?? ""} ${H(
49
- "err.validation.required"
50
- )}`
51
- }
47
+ ...S,
48
+ ...f ? $.required(I) : []
52
49
  ],
53
50
  children: /* @__PURE__ */ t(
54
- D,
51
+ E,
55
52
  {
56
- ref: N,
57
- loading: d,
53
+ ref: b,
54
+ loading: h,
58
55
  open: o ? !1 : void 0,
59
56
  onChange: !o && n.onChange,
60
57
  allowClear: !o && n.allowClear,
61
58
  showSearch: !L,
62
59
  className: `max-width ${o ? "readOnly" : ""}`,
63
60
  ...n,
64
- tagRender: k,
65
- placeholder: f ?? m,
66
- filterOption: b ?? ((e, r) => {
67
- var c, g, C, y;
61
+ tagRender: F,
62
+ placeholder: a ?? m,
63
+ filterOption: k ?? ((e, r) => {
64
+ var c, p, C, y;
68
65
  try {
69
- const i = (C = (g = (c = r == null ? void 0 : r.children) == null ? void 0 : c.props) == null ? void 0 : g.dangerouslySetInnerHTML) == null ? void 0 : C.__html, M = e.toLowerCase().split(/\s+/), p = (r == null ? void 0 : r.children) ?? "", w = typeof p == "string" ? p.toLowerCase() : typeof i == "string" ? i.toLowerCase() : "", O = (((y = r == null ? void 0 : r.value) == null ? void 0 : y.toString()) ?? "").toLowerCase(), j = w.replace(/\s/g, "");
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, "");
70
67
  return M.every(
71
- (l) => w.indexOf(l) >= 0 || O.indexOf(l) >= 0 || j.indexOf(l) >= 0
68
+ (l) => x.indexOf(l) >= 0 || O.indexOf(l) >= 0 || V.indexOf(l) >= 0
72
69
  );
73
70
  } catch (i) {
74
71
  return console.log(i), !0;
75
72
  }
76
73
  }),
77
- dropdownRender: u,
78
- children: a === null ? void 0 : a ?? (s && (s == null ? void 0 : s.map(T ?? I)))
74
+ popupRender: u,
75
+ children: d === null ? void 0 : d ?? (s ? s == null ? void 0 : s.map(T ?? H) : /* @__PURE__ */ t(j, {}))
79
76
  }
80
77
  )
81
78
  }
@@ -84,5 +81,5 @@ function Q({
84
81
  );
85
82
  }
86
83
  export {
87
- Q as default
84
+ Y as default
88
85
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kingteza/crud-component",
3
3
  "private": false,
4
- "version": "1.0.57",
4
+ "version": "1.0.59",
5
5
  "description": "React CRUD component library with Ant Design",
6
6
  "keywords": [
7
7
  "react",
@@ -114,6 +114,6 @@
114
114
  "antd": ">=5.22.6",
115
115
  "react": ">=18.3.1",
116
116
  "react-dom": ">=18.3.1",
117
- "react-router-dom": ">=7.0.0"
117
+ "react-router-dom": ">=6.3.0"
118
118
  }
119
119
  }