@kingteza/crud-component 1.32.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"),
|
|
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,9 +1,9 @@
|
|
|
1
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
|
|
2
|
+
import { Form as S, Modal as z, Checkbox as x, List as p, Select as E } from "antd";
|
|
3
3
|
import { useState as f, useEffect as G, useCallback as i, useMemo as H } from "react";
|
|
4
4
|
import L from "../select/SelectComponent.es.js";
|
|
5
5
|
import R from "../../util/ValidationUtil.es.js";
|
|
6
|
-
const
|
|
6
|
+
const K = ({
|
|
7
7
|
className: h,
|
|
8
8
|
onSelect: C,
|
|
9
9
|
label: c,
|
|
@@ -11,26 +11,26 @@ const P = ({
|
|
|
11
11
|
name: o,
|
|
12
12
|
mode: d,
|
|
13
13
|
items: r,
|
|
14
|
-
selectingMode:
|
|
14
|
+
selectingMode: O
|
|
15
15
|
}) => {
|
|
16
|
-
const l = S.useFormInstance(), [
|
|
16
|
+
const l = S.useFormInstance(), [m, g] = f(!0);
|
|
17
17
|
G(() => {
|
|
18
|
-
if (r &&
|
|
18
|
+
if (r && m) {
|
|
19
19
|
const e = r.filter((s) => s.alreadySelected).map((s) => s.id);
|
|
20
20
|
l == null || l.setFieldsValue({
|
|
21
21
|
[o]: d === "multiple" ? e : e == null ? void 0 : e[0]
|
|
22
|
-
}),
|
|
22
|
+
}), g(!1);
|
|
23
23
|
}
|
|
24
|
-
}, [
|
|
25
|
-
const [
|
|
24
|
+
}, [m, l, r, d, o]);
|
|
25
|
+
const [v, u] = f(!1), [b, k] = f(void 0), I = i(() => {
|
|
26
26
|
u(!1), l.setFieldsValue({
|
|
27
|
-
[o]:
|
|
27
|
+
[o]: b
|
|
28
28
|
});
|
|
29
|
-
}, [
|
|
29
|
+
}, [b, l, o]), V = i(() => {
|
|
30
30
|
u(!1), k(void 0);
|
|
31
31
|
}, []), F = i(() => {
|
|
32
32
|
k(l.getFieldValue(o)), u(!0);
|
|
33
|
-
}, [l, o]), n =
|
|
33
|
+
}, [l, o]), n = O === "checkbox", y = i(
|
|
34
34
|
(e) => {
|
|
35
35
|
n && e && F();
|
|
36
36
|
},
|
|
@@ -43,9 +43,9 @@ const P = ({
|
|
|
43
43
|
n && /* @__PURE__ */ t(
|
|
44
44
|
z,
|
|
45
45
|
{
|
|
46
|
-
open:
|
|
47
|
-
onCancel:
|
|
48
|
-
onOk:
|
|
46
|
+
open: v,
|
|
47
|
+
onCancel: I,
|
|
48
|
+
onOk: V,
|
|
49
49
|
destroyOnHidden: !0,
|
|
50
50
|
title: c,
|
|
51
51
|
children: /* @__PURE__ */ t(
|
|
@@ -55,7 +55,7 @@ const P = ({
|
|
|
55
55
|
required: a,
|
|
56
56
|
rules: [...a ? R.required(c) : []],
|
|
57
57
|
className: h,
|
|
58
|
-
children: /* @__PURE__ */ t(
|
|
58
|
+
children: /* @__PURE__ */ t(x.Group, { onChange: C, style: { width: "100%" }, children: /* @__PURE__ */ t(
|
|
59
59
|
p,
|
|
60
60
|
{
|
|
61
61
|
size: "small",
|
|
@@ -64,7 +64,7 @@ const P = ({
|
|
|
64
64
|
renderItem: (e) => /* @__PURE__ */ t(p.Item, { style: { width: "100%" }, children: /* @__PURE__ */ t(
|
|
65
65
|
p.Item.Meta,
|
|
66
66
|
{
|
|
67
|
-
avatar: /* @__PURE__ */ t(
|
|
67
|
+
avatar: /* @__PURE__ */ t(x, { value: e.id, disabled: e.lock }),
|
|
68
68
|
title: e.label
|
|
69
69
|
}
|
|
70
70
|
) }, e.id)
|
|
@@ -85,6 +85,7 @@ const P = ({
|
|
|
85
85
|
onSelect: C,
|
|
86
86
|
items: r,
|
|
87
87
|
showSearch: !1,
|
|
88
|
+
maxTagCount: "responsive",
|
|
88
89
|
...n ? { open: !1, onOpenChange: y } : {},
|
|
89
90
|
itemBuilder: (e) => /* @__PURE__ */ t(E.Option, { value: e.id, disabled: e.lock, children: e.label }, e.id)
|
|
90
91
|
}
|
|
@@ -92,5 +93,5 @@ const P = ({
|
|
|
92
93
|
] });
|
|
93
94
|
};
|
|
94
95
|
export {
|
|
95
|
-
|
|
96
|
+
K as SelectFieldInReport
|
|
96
97
|
};
|