@fangzsx/component-library 0.0.13 → 0.0.15
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,44 +1,57 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { FormControl as
|
|
3
|
-
import { useState as
|
|
4
|
-
function
|
|
5
|
-
options:
|
|
6
|
-
required:
|
|
7
|
-
minChecked:
|
|
1
|
+
import { jsxs as $, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { FormControl as x, FormGroup as G, FormControlLabel as I, Checkbox as B, FormHelperText as f } from "@mui/material";
|
|
3
|
+
import { useState as d } from "react";
|
|
4
|
+
function P({
|
|
5
|
+
options: s,
|
|
6
|
+
required: b = !1,
|
|
7
|
+
minChecked: o,
|
|
8
8
|
maxChecked: r,
|
|
9
9
|
errorMessage: c,
|
|
10
|
-
helperText:
|
|
11
|
-
onChange:
|
|
12
|
-
sx:
|
|
10
|
+
helperText: m,
|
|
11
|
+
onChange: i,
|
|
12
|
+
sx: p
|
|
13
13
|
}) {
|
|
14
|
-
const [
|
|
15
|
-
|
|
14
|
+
const [a, h] = d(
|
|
15
|
+
s.reduce((e, t) => ({
|
|
16
16
|
...e,
|
|
17
|
-
[
|
|
17
|
+
[t.name]: t.defaultChecked || !1
|
|
18
18
|
}), {})
|
|
19
|
-
), [g,
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
...
|
|
19
|
+
), [g, F] = d(!1), v = (e) => {
|
|
20
|
+
F(!0);
|
|
21
|
+
const t = {
|
|
22
|
+
...a,
|
|
23
23
|
[e.target.name]: e.target.checked
|
|
24
24
|
};
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
(
|
|
25
|
+
h(t);
|
|
26
|
+
const L = Object.keys(t).filter(
|
|
27
|
+
(M) => t[M]
|
|
28
28
|
);
|
|
29
|
-
|
|
30
|
-
},
|
|
31
|
-
return /* @__PURE__ */
|
|
32
|
-
|
|
29
|
+
i && i(L);
|
|
30
|
+
}, n = Object.values(a).filter(Boolean).length, u = g && (o !== void 0 && n < o || r !== void 0 && n > r), j = () => c || (o !== void 0 && n < o ? `Please select at least ${o} option${o > 1 ? "s" : ""}` : r !== void 0 && n > r ? `Please select no more than ${r} option${r > 1 ? "s" : ""}` : "");
|
|
31
|
+
return /* @__PURE__ */ $(
|
|
32
|
+
x,
|
|
33
33
|
{
|
|
34
|
-
required:
|
|
35
|
-
error:
|
|
34
|
+
required: b,
|
|
35
|
+
error: u,
|
|
36
36
|
component: "fieldset",
|
|
37
|
-
sx: {
|
|
37
|
+
sx: {
|
|
38
|
+
m: 0,
|
|
39
|
+
"& .MuiFormGroup-root": {
|
|
40
|
+
gap: 1
|
|
41
|
+
},
|
|
42
|
+
"& .MuiFormControlLabel-root": {
|
|
43
|
+
marginTop: "0 !important",
|
|
44
|
+
marginBottom: "0 !important"
|
|
45
|
+
},
|
|
46
|
+
"& .MuiFormControlLabel-label": {
|
|
47
|
+
margin: "0 !important"
|
|
48
|
+
},
|
|
49
|
+
...p
|
|
50
|
+
},
|
|
38
51
|
variant: "standard",
|
|
39
52
|
children: [
|
|
40
|
-
/* @__PURE__ */ l(G, { children:
|
|
41
|
-
|
|
53
|
+
/* @__PURE__ */ l(G, { children: s.map((e) => /* @__PURE__ */ l(
|
|
54
|
+
I,
|
|
42
55
|
{
|
|
43
56
|
sx: {
|
|
44
57
|
color: "#404A58",
|
|
@@ -47,10 +60,10 @@ function w({
|
|
|
47
60
|
}
|
|
48
61
|
},
|
|
49
62
|
control: /* @__PURE__ */ l(
|
|
50
|
-
|
|
63
|
+
B,
|
|
51
64
|
{
|
|
52
|
-
checked:
|
|
53
|
-
onChange:
|
|
65
|
+
checked: a[e.name] || !1,
|
|
66
|
+
onChange: v,
|
|
54
67
|
name: e.name
|
|
55
68
|
}
|
|
56
69
|
),
|
|
@@ -58,11 +71,11 @@ function w({
|
|
|
58
71
|
},
|
|
59
72
|
e.name
|
|
60
73
|
)) }),
|
|
61
|
-
|
|
74
|
+
u ? /* @__PURE__ */ l(f, { children: j() }) : m ? /* @__PURE__ */ l(f, { children: m }) : null
|
|
62
75
|
]
|
|
63
76
|
}
|
|
64
77
|
);
|
|
65
78
|
}
|
|
66
79
|
export {
|
|
67
|
-
|
|
80
|
+
P as CheckboxGroup
|
|
68
81
|
};
|