@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 I, jsx as l } from "react/jsx-runtime";
2
- import { FormControl as E, FormGroup as G, FormControlLabel as L, Checkbox as O, FormHelperText as i } from "@mui/material";
3
- import { useState as m } from "react";
4
- function w({
5
- options: a,
6
- required: h = !1,
7
- minChecked: t,
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: u,
11
- onChange: f,
12
- sx: b
10
+ helperText: m,
11
+ onChange: i,
12
+ sx: p
13
13
  }) {
14
- const [n, p] = m(
15
- a.reduce((e, o) => ({
14
+ const [a, h] = d(
15
+ s.reduce((e, t) => ({
16
16
  ...e,
17
- [o.name]: o.defaultChecked || !1
17
+ [t.name]: t.defaultChecked || !1
18
18
  }), {})
19
- ), [g, v] = m(!1), F = (e) => {
20
- v(!0);
21
- const o = {
22
- ...n,
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
- p(o);
26
- const $ = Object.keys(o).filter(
27
- (x) => o[x]
25
+ h(t);
26
+ const L = Object.keys(t).filter(
27
+ (M) => t[M]
28
28
  );
29
- f && f($);
30
- }, s = Object.values(n).filter(Boolean).length, d = g && (t !== void 0 && s < t || r !== void 0 && s > r), j = () => c || (t !== void 0 && s < t ? `Please select at least ${t} option${t > 1 ? "s" : ""}` : r !== void 0 && s > r ? `Please select no more than ${r} option${r > 1 ? "s" : ""}` : "");
31
- return /* @__PURE__ */ I(
32
- E,
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: h,
35
- error: d,
34
+ required: b,
35
+ error: u,
36
36
  component: "fieldset",
37
- sx: { m: 3, ...b },
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: a.map((e) => /* @__PURE__ */ l(
41
- L,
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
- O,
63
+ B,
51
64
  {
52
- checked: n[e.name] || !1,
53
- onChange: F,
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
- d ? /* @__PURE__ */ l(i, { children: j() }) : u ? /* @__PURE__ */ l(i, { children: u }) : null
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
- w as CheckboxGroup
80
+ P as CheckboxGroup
68
81
  };