@kingteza/crud-component 1.31.0 → 1.32.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";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),s=require("antd"),i=require("react"),I=require("../select/SelectComponent.cjs.js"),v=require("../../util/ValidationUtil.cjs.js"),V=({className:x,onSelect:p,label:r,required:a,name:l,mode:d,items:n,selectingMode:k})=>{const o=s.Form.useFormInstance(),[b,S]=i.useState(!0);i.useEffect(()=>{if(n&&b){const e=n.filter(h=>h.alreadySelected).map(h=>h.id);o==null||o.setFieldsValue({[l]:d==="multiple"?e:e==null?void 0:e[0]}),S(!1)}},[b,o,n,d,l]);const[F,u]=i.useState(!1),[f,C]=i.useState(void 0),O=i.useCallback(()=>{u(!1),o.setFieldsValue({[l]:f})},[f,o,l]),g=i.useCallback(()=>{u(!1),C(void 0)},[]),j=i.useCallback(()=>{C(o.getFieldValue(l)),u(!0)},[o,l]),c=k==="checkbox",y=i.useCallback(e=>{c&&e&&j()},[c,j]);return t.jsxs(t.Fragment,{children:[c&&t.jsx(s.Modal,{open:F,onCancel:O,onOk:g,destroyOnHidden:!0,title:r,children:t.jsx(s.Form.Item,{name:l,required:a,rules:[...a?v.required(r):[]],className:x,children:t.jsx(s.Checkbox.Group,{onChange:p,style:{width:"100%"},children:t.jsx(s.List,{size:"small",style:{width:"100%"},dataSource:n,renderItem:e=>t.jsx(s.List.Item,{style:{width:"100%"},children:t.jsx(s.List.Item.Meta,{avatar:t.jsx(s.Checkbox,{value:e.id,disabled:e.lock}),title:e.label})},e.id)})})})}),t.jsx(I,{required:a,label:r,mode:d,className:x,name:l,onSelect:p,items:n,showSearch:!1,...c?{open:!1,onOpenChange:y}:{},itemBuilder:e=>t.jsx(s.Select.Option,{value:e.id,disabled:e.lock,children:e.label},e.id)})]})};exports.SelectFieldInReport=V;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),s=require("antd"),l=require("react"),V=require("../select/SelectComponent.cjs.js"),M=require("../../util/ValidationUtil.cjs.js"),q=({className:p,onSelect:x,label:a,required:d,name:o,mode:u,items:r,selectingMode:j})=>{const n=s.Form.useFormInstance(),[b,k]=l.useState(!0);l.useEffect(()=>{if(r&&b){const e=r.filter(c=>c.alreadySelected).map(c=>c.id);n==null||n.setFieldsValue({[o]:u==="multiple"?e:e==null?void 0:e[0]}),k(!1)}},[b,n,r,u,o]);const[F,h]=l.useState(!1),[C,f]=l.useState(void 0),g=l.useCallback(()=>{h(!1),n.setFieldsValue({[o]:C})},[C,n,o]),O=l.useCallback(()=>{h(!1),f(void 0)},[]),S=l.useCallback(()=>{f(n.getFieldValue(o)),h(!0)},[n,o]),i=j==="checkbox",v=l.useCallback(e=>{i&&e&&S()},[i,S]),y=l.useMemo(()=>{const e=[...r];return e.sort((c,I)=>c.label.localeCompare(I.label)),e},[r]);return t.jsxs(t.Fragment,{children:[i&&t.jsx(s.Modal,{open:F,onCancel:g,onOk:O,destroyOnHidden:!0,title:a,children:t.jsx(s.Form.Item,{name:o,required:d,rules:[...d?M.required(a):[]],className:p,children:t.jsx(s.Checkbox.Group,{onChange:x,style:{width:"100%"},children:t.jsx(s.List,{size:"small",style:{width:"100%"},dataSource:y,renderItem:e=>t.jsx(s.List.Item,{style:{width:"100%"},children:t.jsx(s.List.Item.Meta,{avatar:t.jsx(s.Checkbox,{value:e.id,disabled:e.lock}),title:e.label})},e.id)})})})}),t.jsx(V,{required:d,label:a,mode:u,className:p,name:o,onSelect:x,items:r,showSearch:!1,maxTagCount:"responsive",...i?{open:!1,onOpenChange:v}:{},itemBuilder:e=>t.jsx(s.Select.Option,{value:e.id,disabled:e.lock,children:e.label},e.id)})]})};exports.SelectFieldInReport=q;
@@ -1,67 +1,70 @@
1
- import { jsxs as w, Fragment as M, jsx as t } from "react/jsx-runtime";
2
- import { Form as O, Modal as j, Checkbox as S, List as p, Select as B } from "antd";
3
- import { useState as f, useEffect as z, useCallback as r } from "react";
4
- import E from "../select/SelectComponent.es.js";
5
- import G from "../../util/ValidationUtil.es.js";
6
- const D = ({
1
+ import { jsxs as j, Fragment as B, jsx as t } from "react/jsx-runtime";
2
+ import { Form as S, Modal as z, Checkbox as x, List as p, Select as E } from "antd";
3
+ import { useState as f, useEffect as G, useCallback as i, useMemo as H } from "react";
4
+ import L from "../select/SelectComponent.es.js";
5
+ import R from "../../util/ValidationUtil.es.js";
6
+ const K = ({
7
7
  className: h,
8
8
  onSelect: C,
9
- label: n,
10
- required: c,
11
- name: l,
9
+ label: c,
10
+ required: a,
11
+ name: o,
12
12
  mode: d,
13
- items: i,
14
- selectingMode: x
13
+ items: r,
14
+ selectingMode: O
15
15
  }) => {
16
- const o = O.useFormInstance(), [k, I] = f(!0);
17
- z(() => {
18
- if (i && k) {
19
- const e = i.filter((u) => u.alreadySelected).map((u) => u.id);
20
- o == null || o.setFieldsValue({
21
- [l]: d === "multiple" ? e : e == null ? void 0 : e[0]
22
- }), I(!1);
16
+ const l = S.useFormInstance(), [m, g] = f(!0);
17
+ G(() => {
18
+ if (r && m) {
19
+ const e = r.filter((s) => s.alreadySelected).map((s) => s.id);
20
+ l == null || l.setFieldsValue({
21
+ [o]: d === "multiple" ? e : e == null ? void 0 : e[0]
22
+ }), g(!1);
23
23
  }
24
- }, [k, o, i, d, l]);
25
- const [V, a] = f(!1), [F, b] = f(void 0), g = r(() => {
26
- a(!1), o.setFieldsValue({
27
- [l]: F
24
+ }, [m, l, r, d, o]);
25
+ const [v, u] = f(!1), [b, k] = f(void 0), I = i(() => {
26
+ u(!1), l.setFieldsValue({
27
+ [o]: b
28
28
  });
29
- }, [F, o, l]), v = r(() => {
30
- a(!1), b(void 0);
31
- }, []), m = r(() => {
32
- b(o.getFieldValue(l)), a(!0);
33
- }, [o, l]), s = x === "checkbox", y = r(
29
+ }, [b, l, o]), V = i(() => {
30
+ u(!1), k(void 0);
31
+ }, []), F = i(() => {
32
+ k(l.getFieldValue(o)), u(!0);
33
+ }, [l, o]), n = O === "checkbox", y = i(
34
34
  (e) => {
35
- s && e && m();
35
+ n && e && F();
36
36
  },
37
- [s, m]
38
- );
39
- return /* @__PURE__ */ w(M, { children: [
40
- s && /* @__PURE__ */ t(
41
- j,
37
+ [n, F]
38
+ ), w = H(() => {
39
+ const e = [...r];
40
+ return e.sort((s, M) => s.label.localeCompare(M.label)), e;
41
+ }, [r]);
42
+ return /* @__PURE__ */ j(B, { children: [
43
+ n && /* @__PURE__ */ t(
44
+ z,
42
45
  {
43
- open: V,
44
- onCancel: g,
45
- onOk: v,
46
+ open: v,
47
+ onCancel: I,
48
+ onOk: V,
46
49
  destroyOnHidden: !0,
47
- title: n,
50
+ title: c,
48
51
  children: /* @__PURE__ */ t(
49
- O.Item,
52
+ S.Item,
50
53
  {
51
- name: l,
52
- required: c,
53
- rules: [...c ? G.required(n) : []],
54
+ name: o,
55
+ required: a,
56
+ rules: [...a ? R.required(c) : []],
54
57
  className: h,
55
- children: /* @__PURE__ */ t(S.Group, { onChange: C, style: { width: "100%" }, children: /* @__PURE__ */ t(
58
+ children: /* @__PURE__ */ t(x.Group, { onChange: C, style: { width: "100%" }, children: /* @__PURE__ */ t(
56
59
  p,
57
60
  {
58
61
  size: "small",
59
62
  style: { width: "100%" },
60
- dataSource: i,
63
+ dataSource: w,
61
64
  renderItem: (e) => /* @__PURE__ */ t(p.Item, { style: { width: "100%" }, children: /* @__PURE__ */ t(
62
65
  p.Item.Meta,
63
66
  {
64
- avatar: /* @__PURE__ */ t(S, { value: e.id, disabled: e.lock }),
67
+ avatar: /* @__PURE__ */ t(x, { value: e.id, disabled: e.lock }),
65
68
  title: e.label
66
69
  }
67
70
  ) }, e.id)
@@ -72,22 +75,23 @@ const D = ({
72
75
  }
73
76
  ),
74
77
  /* @__PURE__ */ t(
75
- E,
78
+ L,
76
79
  {
77
- required: c,
78
- label: n,
80
+ required: a,
81
+ label: c,
79
82
  mode: d,
80
83
  className: h,
81
- name: l,
84
+ name: o,
82
85
  onSelect: C,
83
- items: i,
86
+ items: r,
84
87
  showSearch: !1,
85
- ...s ? { open: !1, onOpenChange: y } : {},
86
- itemBuilder: (e) => /* @__PURE__ */ t(B.Option, { value: e.id, disabled: e.lock, children: e.label }, e.id)
88
+ maxTagCount: "responsive",
89
+ ...n ? { open: !1, onOpenChange: y } : {},
90
+ itemBuilder: (e) => /* @__PURE__ */ t(E.Option, { value: e.id, disabled: e.lock, children: e.label }, e.id)
87
91
  }
88
92
  )
89
93
  ] });
90
94
  };
91
95
  export {
92
- D as SelectFieldInReport
96
+ K as SelectFieldInReport
93
97
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kingteza/crud-component",
3
3
  "private": false,
4
- "version": "1.31.0",
4
+ "version": "1.32.1",
5
5
  "description": "React CRUD component library with Ant Design",
6
6
  "keywords": [
7
7
  "react",