@kingteza/crud-component 1.6.1 → 1.6.2

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 a=require("react/jsx-runtime"),n=require("antd"),E=require("dayjs"),f=require("react"),H=require("../../locale/index.cjs.js"),I=({type:L,required:l,label:i,rules:q=[],placeholder:s,disabledPast:r=!1,disableCurrent:m=!1,onEnter:M,disabled:x,use12Hours:k,nextFocus:N,onChange:o,range:c,disabledFuture:u,defaultValue:T,value:j,format:p,autoComplete:S="off",renderExtraFooter:d,...y})=>{const{t:P}=H.useTranslationLib(),R=f.useMemo(()=>s||(c?["From","To"]:"Select time"),[s,c]),F=c?n.TimePicker.RangePicker:n.TimePicker,$=f.useCallback(e=>{if(!e)return!1;const t=E(),v=r&&e<t,w=u&&e>t,D=m&&e<t&&t<e;return v||w||D},[m,u,r]);return a.jsx(n.Form.Item,{...y,label:i,rules:[{required:l,message:`${i??s??""} ${P("err.validation.required")}`},...q],children:a.jsx(F,{use12Hours:k,renderExtraFooter:d,value:j,defaultValue:T,format:p,onChange:e=>o==null?void 0:o(e),disabledDate:$,disabled:x,className:"w-100",placeholder:R})})};module.exports=I;
1
+ "use strict";const a=require("react/jsx-runtime"),i=require("antd"),E=require("dayjs"),f=require("react"),H=require("../../locale/index.cjs.js"),I=({type:L,required:q,label:o,rules:x=[],placeholder:s,disabledPast:r=!1,disableCurrent:m=!1,onEnter:M,disabled:k,use12Hours:T,nextFocus:N,onChange:c,range:n,disabledFuture:u,defaultValue:j,value:p,format:y,autoComplete:S="off",renderExtraFooter:P,...R})=>{const{t:d}=H.useTranslationLib(),l=f.useMemo(()=>s||(n?["From","To"]:"Select time"),[s,n]),F=n?i.TimePicker.RangePicker:i.TimePicker,$=f.useCallback(e=>{if(!e)return!1;const t=E(),v=r&&e<t,w=u&&e>t,D=m&&e<t&&t<e;return v||w||D},[m,u,r]);return a.jsx(i.Form.Item,{...R,label:o,rules:[{required:q,message:`${o||s||""} ${d("err.validation.required")}`},...x],children:a.jsx(F,{use12Hours:T,renderExtraFooter:P,value:p,defaultValue:j,format:y,onChange:e=>c==null?void 0:c(e),disabledDate:$,disabled:k,className:"w-100",placeholder:l})})};module.exports=I;
@@ -1,38 +1,38 @@
1
1
  import { jsx as f } from "react/jsx-runtime";
2
- import { TimePicker as a, Form as E } from "antd";
2
+ import { TimePicker as p, Form as E } from "antd";
3
3
  import H from "dayjs";
4
4
  import { useMemo as I, useCallback as L } from "react";
5
5
  import { useTranslationLib as M } from "../../locale/index.es.js";
6
6
  const K = ({
7
7
  type: N,
8
- required: p,
9
- label: i,
10
- rules: l = [],
8
+ required: a,
9
+ label: s,
10
+ rules: k = [],
11
11
  placeholder: t,
12
12
  disabledPast: r = !1,
13
13
  disableCurrent: c = !1,
14
14
  onEnter: R,
15
- disabled: k,
16
- use12Hours: u,
15
+ disabled: u,
16
+ use12Hours: T,
17
17
  nextFocus: S,
18
- onChange: m,
19
- range: s,
18
+ onChange: e,
19
+ range: i,
20
20
  disabledFuture: n,
21
- defaultValue: T,
21
+ defaultValue: l,
22
22
  value: x,
23
23
  format: y,
24
24
  autoComplete: z = "off",
25
- renderExtraFooter: d,
26
- ...j
25
+ renderExtraFooter: j,
26
+ ...F
27
27
  }) => {
28
- const { t: F } = M(), P = I(
29
- () => t || (s ? ["From", "To"] : "Select time"),
30
- [t, s]
31
- ), $ = s ? a.RangePicker : a, q = L(
28
+ const { t: P } = M(), $ = I(
29
+ () => t || (i ? ["From", "To"] : "Select time"),
30
+ [t, i]
31
+ ), d = i ? p.RangePicker : p, q = L(
32
32
  (o) => {
33
33
  if (!o)
34
34
  return !1;
35
- const e = H(), v = r && o < e, w = n && o > e, D = c && o < e && e < o;
35
+ const m = H(), v = r && o < m, w = n && o > m, D = c && o < m && m < o;
36
36
  return v || w || D;
37
37
  },
38
38
  [c, n, r]
@@ -41,30 +41,30 @@ const K = ({
41
41
  return /* @__PURE__ */ f(
42
42
  E.Item,
43
43
  {
44
- ...j,
45
- label: i,
44
+ ...F,
45
+ label: s,
46
46
  rules: [
47
47
  {
48
- required: p,
49
- message: `${i ?? t ?? ""} ${F(
48
+ required: a,
49
+ message: `${s || t || ""} ${P(
50
50
  "err.validation.required"
51
51
  )}`
52
52
  },
53
- ...l
53
+ ...k
54
54
  ],
55
55
  children: /* @__PURE__ */ f(
56
- $,
56
+ d,
57
57
  {
58
- use12Hours: u,
59
- renderExtraFooter: d,
58
+ use12Hours: T,
59
+ renderExtraFooter: j,
60
60
  value: x,
61
- defaultValue: T,
61
+ defaultValue: l,
62
62
  format: y,
63
- onChange: (o) => m == null ? void 0 : m(o),
63
+ onChange: (o) => e == null ? void 0 : e(o),
64
64
  disabledDate: q,
65
- disabled: k,
65
+ disabled: u,
66
66
  className: "w-100",
67
- placeholder: P
67
+ placeholder: $
68
68
  }
69
69
  )
70
70
  }
@@ -1 +1 @@
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;
1
+ "use strict";const n=require("react/jsx-runtime"),a=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:s,rules:S=[],required:f,placeholder:l,notSearch:L,children:h,readOnly:o,items:c,dropdownRender:q,itemBuilder:p,loading:m,showLoadingInEmptyIndicator:T,nameFieldInArray:u="name",innerRef:_,tooltip:N,filterOption:R,tagRender:b,help:k,...r}){const{t:U}=B.useTranslationLib(),F=V.useCallback(e=>{const t=typeof e=="string"||typeof e=="number"?e:e==null?void 0:e.id,i=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:i}})},t)},[u]),H=s||l||"";return n.jsx(a.ConfigProvider,{renderEmpty:T&&m?()=>n.jsx(a.Spin,{}):void 0,children:n.jsx(D,{title:N,children:n.jsx(a.Form.Item,{label:s,name:r.name,help:k,className:r.className,required:f,rules:[...S,...f?E.required(H):[]],children:n.jsx(a.Select,{ref:_,loading:m,open:o?!1:void 0,onChange:!o&&r.onChange,allowClear:!o&&r.allowClear,showSearch:!L,className:`max-width ${o?"readOnly":""}`,...r,tagRender:b,placeholder:l??s,filterOption:R??((e,t)=>{var i,g,C,j;try{const d=(C=(g=(i=t==null?void 0:t.children)==null?void 0:i.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 d=="string"?d.toLowerCase():"",M=(((j=t==null?void 0:t.value)==null?void 0:j.toString())??"").toLowerCase(),O=w.replace(/\s/g,"");return I.every(x=>w.indexOf(x)>=0||M.indexOf(x)>=0||O.indexOf(x)>=0)}catch(d){return console.log(d),!0}}),popupRender:q,children:h===null?void 0:h??(c?c==null?void 0:c.map(p??F):n.jsx(n.Fragment,{}))})})})})}module.exports=P;
@@ -5,21 +5,21 @@ import { useTranslationLib as W } from "../../locale/index.es.js";
5
5
  import $ from "../tooltip/TooltipComponent.es.js";
6
6
  import q from "../../util/ValidationUtil.es.js";
7
7
  function Z({
8
- label: m,
8
+ label: o,
9
9
  rules: S = [],
10
- required: f,
11
- placeholder: a,
10
+ required: d,
11
+ placeholder: f,
12
12
  notSearch: L,
13
- children: d,
14
- readOnly: o,
15
- items: s,
13
+ children: l,
14
+ readOnly: s,
15
+ items: c,
16
16
  dropdownRender: u,
17
17
  itemBuilder: T,
18
18
  loading: h,
19
19
  showLoadingInEmptyIndicator: _,
20
20
  nameFieldInArray: g = "name",
21
- innerRef: b,
22
- tooltip: N,
21
+ innerRef: N,
22
+ tooltip: b,
23
23
  filterOption: k,
24
24
  tagRender: F,
25
25
  help: H,
@@ -27,53 +27,53 @@ function Z({
27
27
  }) {
28
28
  const { t: z } = W(), I = U(
29
29
  (e) => {
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];
31
- return /* @__PURE__ */ t("option", { value: r, children: /* @__PURE__ */ t("div", { dangerouslySetInnerHTML: { __html: c } }) }, r);
30
+ const r = typeof e == "string" || typeof e == "number" ? e : e == null ? void 0 : e.id, i = typeof e == "string" || typeof e == "number" ? e : e == null ? void 0 : e[g];
31
+ return /* @__PURE__ */ t("option", { value: r, children: /* @__PURE__ */ t("div", { dangerouslySetInnerHTML: { __html: i } }) }, r);
32
32
  },
33
33
  [g]
34
- ), M = m ?? a ?? "";
34
+ ), M = o || f || "";
35
35
  return /* @__PURE__ */ t(
36
36
  D,
37
37
  {
38
38
  renderEmpty: _ && h ? () => /* @__PURE__ */ t(R, {}) : void 0,
39
- children: /* @__PURE__ */ t($, { title: N, children: /* @__PURE__ */ t(
39
+ children: /* @__PURE__ */ t($, { title: b, children: /* @__PURE__ */ t(
40
40
  E.Item,
41
41
  {
42
- label: m,
42
+ label: o,
43
43
  name: n.name,
44
44
  help: H,
45
45
  className: n.className,
46
- required: f,
46
+ required: d,
47
47
  rules: [
48
48
  ...S,
49
- ...f ? q.required(M) : []
49
+ ...d ? q.required(M) : []
50
50
  ],
51
51
  children: /* @__PURE__ */ t(
52
52
  P,
53
53
  {
54
- ref: b,
54
+ ref: N,
55
55
  loading: h,
56
- open: o ? !1 : void 0,
57
- onChange: !o && n.onChange,
58
- allowClear: !o && n.allowClear,
56
+ open: s ? !1 : void 0,
57
+ onChange: !s && n.onChange,
58
+ allowClear: !s && n.allowClear,
59
59
  showSearch: !L,
60
- className: `max-width ${o ? "readOnly" : ""}`,
60
+ className: `max-width ${s ? "readOnly" : ""}`,
61
61
  ...n,
62
62
  tagRender: F,
63
- placeholder: a ?? m,
63
+ placeholder: f ?? o,
64
64
  filterOption: k ?? ((e, r) => {
65
- var c, p, C, y;
65
+ var i, C, p, y;
66
66
  try {
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, "");
67
+ const m = (p = (C = (i = r == null ? void 0 : r.children) == null ? void 0 : i.props) == null ? void 0 : C.dangerouslySetInnerHTML) == null ? void 0 : p.__html, O = e.toLowerCase().split(/\s+/), w = (r == null ? void 0 : r.children) ?? "", x = typeof w == "string" ? w.toLowerCase() : typeof m == "string" ? m.toLowerCase() : "", V = (((y = r == null ? void 0 : r.value) == null ? void 0 : y.toString()) ?? "").toLowerCase(), j = x.replace(/\s/g, "");
68
68
  return O.every(
69
- (l) => x.indexOf(l) >= 0 || V.indexOf(l) >= 0 || j.indexOf(l) >= 0
69
+ (a) => x.indexOf(a) >= 0 || V.indexOf(a) >= 0 || j.indexOf(a) >= 0
70
70
  );
71
- } catch (i) {
72
- return console.log(i), !0;
71
+ } catch (m) {
72
+ return console.log(m), !0;
73
73
  }
74
74
  }),
75
75
  popupRender: u,
76
- children: d === null ? void 0 : d ?? (s ? s == null ? void 0 : s.map(T ?? I) : /* @__PURE__ */ t(B, {}))
76
+ children: l === null ? void 0 : l ?? (c ? c == null ? void 0 : c.map(T ?? I) : /* @__PURE__ */ t(B, {}))
77
77
  }
78
78
  )
79
79
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react/jsx-runtime"),R=require("@ant-design/icons"),d=require("antd"),S=require("react"),_=require("../../locale/index.cjs.js"),$=require("../tooltip/TooltipComponent.cjs.js"),c=(n,t,e,i)=>{var s;t&&e&&(n.preventDefault(),(s=e==null?void 0:e.getFieldInstance(t))==null||s.focus()),i&&i(n)},A=({type:n,required:t,label:e,disabled:i,rules:s=[],placeholder:u,onEnter:l,size:p,form:x,addonAfter:g,addonBefore:m,nextFocus:I,autoComplete:f="off",defaultValue:j,readOnly:q,value:v,loading:T,onBlur:F,inputRef:P,status:h,autoFocus:C,onChange:D,tooltip:E,...M})=>{const{t:a}=_.useTranslationLib(),w=S.useMemo(()=>{const r=[...s,{required:t,message:`${e??u??""} ${a("err.validation.required")}`}];return n==="email"&&r.push({type:"email",message:a("err.validation.invalidEmail")}),r},[s,t,e,u,a,n]),L={disabled:i,value:v,readOnly:q,defaultValue:j,autoFocus:C,addonBefore:m,ref:P,onBlur:F,addonAfter:T?o.jsx(R.LoadingOutlined,{}):g,status:h,size:p,autoComplete:f,onPressEnter:r=>c(r,I,x,l),type:n,placeholder:u??e},O=n=="password"?d.Input.Password:d.Input;return o.jsx($,{title:E,children:o.jsx(d.Form.Item,{...M,label:e,rules:w,children:o.jsx(O,{...L})})})};exports.default=A;exports.onEnterInternalTextField=c;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("react/jsx-runtime"),R=require("@ant-design/icons"),d=require("antd"),S=require("react"),_=require("../../locale/index.cjs.js"),$=require("../tooltip/TooltipComponent.cjs.js"),c=(n,t,e,i)=>{var s;t&&e&&(n.preventDefault(),(s=e==null?void 0:e.getFieldInstance(t))==null||s.focus()),i&&i(n)},A=({type:n,required:t,label:e,disabled:i,rules:s=[],placeholder:r,onEnter:l,size:x,form:g,addonAfter:m,addonBefore:p,nextFocus:I,autoComplete:f="off",defaultValue:j,readOnly:q,value:v,loading:T,onBlur:F,inputRef:P,status:C,autoFocus:E,onChange:D,tooltip:M,...h})=>{const{t:a}=_.useTranslationLib(),w=S.useMemo(()=>{const o=[...s,{required:t,message:`${e||r||""} ${a("err.validation.required")}`}];return n==="email"&&o.push({type:"email",message:a("err.validation.invalidEmail")}),o},[s,t,e,r,a,n]),L={disabled:i,value:v,readOnly:q,defaultValue:j,autoFocus:E,addonBefore:p,ref:P,onBlur:F,addonAfter:T?u.jsx(R.LoadingOutlined,{}):m,status:C,size:x,autoComplete:f,onPressEnter:o=>c(o,I,g,l),type:n,placeholder:r??e},O=n=="password"?d.Input.Password:d.Input;return u.jsx($,{title:M,children:u.jsx(d.Form.Item,{...h,label:e,rules:w,children:u.jsx(O,{...L})})})};exports.default=A;exports.onEnterInternalTextField=c;
@@ -1,70 +1,70 @@
1
- import { jsx as s } from "react/jsx-runtime";
1
+ import { jsx as m } from "react/jsx-runtime";
2
2
  import { LoadingOutlined as D } from "@ant-design/icons";
3
3
  import { Input as d, Form as M } from "antd";
4
4
  import { useMemo as O } from "react";
5
5
  import { useTranslationLib as k } from "../../locale/index.es.js";
6
6
  import q from "../tooltip/TooltipComponent.es.js";
7
- const z = (n, o, t, e) => {
7
+ const z = (n, o, t, r) => {
8
8
  var i;
9
- o && t && (n.preventDefault(), (i = t == null ? void 0 : t.getFieldInstance(o)) == null || i.focus()), e && e(n);
9
+ o && t && (n.preventDefault(), (i = t == null ? void 0 : t.getFieldInstance(o)) == null || i.focus()), r && r(n);
10
10
  }, R = ({
11
11
  type: n,
12
12
  required: o,
13
13
  label: t,
14
- disabled: e,
14
+ disabled: r,
15
15
  rules: i = [],
16
- placeholder: a,
16
+ placeholder: e,
17
17
  onEnter: p,
18
18
  size: f,
19
- form: l,
20
- addonAfter: u,
21
- addonBefore: c,
19
+ form: u,
20
+ addonAfter: c,
21
+ addonBefore: l,
22
22
  nextFocus: g,
23
23
  autoComplete: v = "off",
24
24
  defaultValue: I,
25
25
  readOnly: T,
26
- value: h,
27
- loading: x,
28
- onBlur: C,
29
- inputRef: F,
30
- status: P,
26
+ value: x,
27
+ loading: C,
28
+ onBlur: F,
29
+ inputRef: P,
30
+ status: h,
31
31
  autoFocus: w,
32
32
  onChange: B,
33
33
  tooltip: E,
34
34
  ...L
35
35
  }) => {
36
- const { t: m } = k(), $ = O(() => {
37
- const r = [
36
+ const { t: a } = k(), $ = O(() => {
37
+ const s = [
38
38
  ...i,
39
39
  {
40
40
  required: o,
41
- message: `${t ?? a ?? ""} ${m(
41
+ message: `${t || e || ""} ${a(
42
42
  "err.validation.required"
43
43
  )}`
44
44
  }
45
45
  ];
46
- return n === "email" && r.push({
46
+ return n === "email" && s.push({
47
47
  type: "email",
48
- message: m("err.validation.invalidEmail")
49
- }), r;
50
- }, [i, o, t, a, m, n]), j = {
51
- disabled: e,
52
- value: h,
48
+ message: a("err.validation.invalidEmail")
49
+ }), s;
50
+ }, [i, o, t, e, a, n]), j = {
51
+ disabled: r,
52
+ value: x,
53
53
  readOnly: T,
54
54
  defaultValue: I,
55
55
  autoFocus: w,
56
- addonBefore: c,
57
- ref: F,
58
- onBlur: C,
59
- addonAfter: x ? /* @__PURE__ */ s(D, {}) : u,
60
- status: P,
56
+ addonBefore: l,
57
+ ref: P,
58
+ onBlur: F,
59
+ addonAfter: C ? /* @__PURE__ */ m(D, {}) : c,
60
+ status: h,
61
61
  size: f,
62
62
  autoComplete: v,
63
- onPressEnter: (r) => z(r, g, l, p),
63
+ onPressEnter: (s) => z(s, g, u, p),
64
64
  type: n,
65
- placeholder: a ?? t
65
+ placeholder: e ?? t
66
66
  }, A = n == "password" ? d.Password : d;
67
- return /* @__PURE__ */ s(q, { title: E, children: /* @__PURE__ */ s(M.Item, { ...L, label: t, rules: $, children: /* @__PURE__ */ s(A, { ...j }) }) });
67
+ return /* @__PURE__ */ m(q, { title: E, children: /* @__PURE__ */ m(M.Item, { ...L, label: t, rules: $, children: /* @__PURE__ */ m(A, { ...j }) }) });
68
68
  };
69
69
  export {
70
70
  R as default,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kingteza/crud-component",
3
3
  "private": false,
4
- "version": "1.6.1",
4
+ "version": "1.6.2",
5
5
  "description": "React CRUD component library with Ant Design",
6
6
  "keywords": [
7
7
  "react",