@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"),
|
|
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
|
|
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 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:
|
|
10
|
-
required:
|
|
11
|
-
name:
|
|
9
|
+
label: c,
|
|
10
|
+
required: a,
|
|
11
|
+
name: o,
|
|
12
12
|
mode: d,
|
|
13
|
-
items:
|
|
14
|
-
selectingMode:
|
|
13
|
+
items: r,
|
|
14
|
+
selectingMode: O
|
|
15
15
|
}) => {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
if (
|
|
19
|
-
const e =
|
|
20
|
-
|
|
21
|
-
[
|
|
22
|
-
}),
|
|
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
|
-
}, [
|
|
25
|
-
const [
|
|
26
|
-
|
|
27
|
-
[
|
|
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
|
-
}, [
|
|
30
|
-
|
|
31
|
-
}, []),
|
|
32
|
-
|
|
33
|
-
}, [
|
|
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
|
-
|
|
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
|
-
open:
|
|
44
|
-
onCancel:
|
|
45
|
-
onOk:
|
|
46
|
+
open: v,
|
|
47
|
+
onCancel: I,
|
|
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(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:
|
|
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(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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
96
|
+
K as SelectFieldInReport
|
|
93
97
|
};
|