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