@fangzsx/component-library 0.0.31 → 0.0.32

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,3 +1,6 @@
1
1
  import { CheckboxProps } from '@mui/material/Checkbox';
2
2
 
3
- export declare function CheckBox(props: CheckboxProps): import("react/jsx-runtime").JSX.Element;
3
+ export interface CheckBoxProps extends CheckboxProps {
4
+ forceError?: boolean;
5
+ }
6
+ export declare function CheckBox(props: CheckBoxProps): import("react/jsx-runtime").JSX.Element;
@@ -1,50 +1,50 @@
1
- import { jsx as r } from "react/jsx-runtime";
1
+ import { jsx as s } from "react/jsx-runtime";
2
2
  import * as f from "react";
3
- import { a as j, g as w, c as l, P as e } from "../../generateUtilityClasses-BCID9NF1.js";
4
- import { u as M, c as $, s as N, a as V, r as F, m as H } from "../../DefaultPropsProvider-DVX_ssOt.js";
3
+ import { a as M, g as j, c as p, P as o } from "../../generateUtilityClasses-BCID9NF1.js";
4
+ import { u as w, c as $, s as F, a as H, r as N, m as V } from "../../DefaultPropsProvider-DVX_ssOt.js";
5
5
  import { S as E } from "../../SwitchBase-V2UoemN5.js";
6
6
  import { c as h } from "../../createSvgIcon-C0YrvByi.js";
7
7
  import { c as I } from "../../useTimeout-DmOXPFt0.js";
8
8
  import { u as U } from "../../useSlot-DKccmcQE.js";
9
- import { m as D } from "../../mergeSlotProps-S3NX_8iG.js";
10
- const L = h(/* @__PURE__ */ r("path", {
9
+ import { m as L } from "../../mergeSlotProps-S3NX_8iG.js";
10
+ const D = h(/* @__PURE__ */ s("path", {
11
11
  d: "M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"
12
- }), "CheckBoxOutlineBlank"), q = h(/* @__PURE__ */ r("path", {
12
+ }), "CheckBoxOutlineBlank"), q = h(/* @__PURE__ */ s("path", {
13
13
  d: "M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2zm-9 14l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"
14
- }), "CheckBox"), _ = h(/* @__PURE__ */ r("path", {
14
+ }), "CheckBox"), _ = h(/* @__PURE__ */ s("path", {
15
15
  d: "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-2 10H7v-2h10v2z"
16
16
  }), "IndeterminateCheckBox");
17
- function A(o) {
18
- return w("MuiCheckbox", o);
17
+ function A(e) {
18
+ return j("MuiCheckbox", e);
19
19
  }
20
- const b = j("MuiCheckbox", ["root", "checked", "disabled", "indeterminate", "colorPrimary", "colorSecondary", "sizeSmall", "sizeMedium"]), G = (o) => {
20
+ const b = M("MuiCheckbox", ["root", "checked", "disabled", "indeterminate", "colorPrimary", "colorSecondary", "sizeSmall", "sizeMedium"]), G = (e) => {
21
21
  const {
22
22
  classes: t,
23
- indeterminate: s,
23
+ indeterminate: r,
24
24
  color: n,
25
25
  size: c
26
- } = o, a = {
27
- root: ["root", s && "indeterminate", `color${l(n)}`, `size${l(c)}`]
28
- }, p = V(a, A, t);
26
+ } = e, a = {
27
+ root: ["root", r && "indeterminate", `color${p(n)}`, `size${p(c)}`]
28
+ }, i = H(a, A, t);
29
29
  return {
30
30
  ...t,
31
31
  // forward the disabled and checked classes to the SwitchBase
32
- ...p
32
+ ...i
33
33
  };
34
- }, J = N(E, {
35
- shouldForwardProp: (o) => F(o) || o === "classes",
34
+ }, J = F(E, {
35
+ shouldForwardProp: (e) => N(e) || e === "classes",
36
36
  name: "MuiCheckbox",
37
37
  slot: "Root",
38
- overridesResolver: (o, t) => {
38
+ overridesResolver: (e, t) => {
39
39
  const {
40
- ownerState: s
41
- } = o;
42
- return [t.root, s.indeterminate && t.indeterminate, t[`size${l(s.size)}`], s.color !== "default" && t[`color${l(s.color)}`]];
40
+ ownerState: r
41
+ } = e;
42
+ return [t.root, r.indeterminate && t.indeterminate, t[`size${p(r.size)}`], r.color !== "default" && t[`color${p(r.color)}`]];
43
43
  }
44
- })(H(({
45
- theme: o
44
+ })(V(({
45
+ theme: e
46
46
  }) => ({
47
- color: (o.vars || o).palette.text.secondary,
47
+ color: (e.vars || e).palette.text.secondary,
48
48
  variants: [{
49
49
  props: {
50
50
  color: "default",
@@ -52,29 +52,29 @@ const b = j("MuiCheckbox", ["root", "checked", "disabled", "indeterminate", "col
52
52
  },
53
53
  style: {
54
54
  "&:hover": {
55
- backgroundColor: o.alpha((o.vars || o).palette.action.active, (o.vars || o).palette.action.hoverOpacity)
55
+ backgroundColor: e.alpha((e.vars || e).palette.action.active, (e.vars || e).palette.action.hoverOpacity)
56
56
  }
57
57
  }
58
- }, ...Object.entries(o.palette).filter(I()).map(([t]) => ({
58
+ }, ...Object.entries(e.palette).filter(I()).map(([t]) => ({
59
59
  props: {
60
60
  color: t,
61
61
  disableRipple: !1
62
62
  },
63
63
  style: {
64
64
  "&:hover": {
65
- backgroundColor: o.alpha((o.vars || o).palette[t].main, (o.vars || o).palette.action.hoverOpacity)
65
+ backgroundColor: e.alpha((e.vars || e).palette[t].main, (e.vars || e).palette.action.hoverOpacity)
66
66
  }
67
67
  }
68
- })), ...Object.entries(o.palette).filter(I()).map(([t]) => ({
68
+ })), ...Object.entries(e.palette).filter(I()).map(([t]) => ({
69
69
  props: {
70
70
  color: t
71
71
  },
72
72
  style: {
73
73
  [`&.${b.checked}, &.${b.indeterminate}`]: {
74
- color: (o.vars || o).palette[t].main
74
+ color: (e.vars || e).palette[t].main
75
75
  },
76
76
  [`&.${b.disabled}`]: {
77
- color: (o.vars || o).palette.action.disabled
77
+ color: (e.vars || e).palette.action.disabled
78
78
  }
79
79
  }
80
80
  })), {
@@ -91,33 +91,33 @@ const b = j("MuiCheckbox", ["root", "checked", "disabled", "indeterminate", "col
91
91
  }
92
92
  }
93
93
  }]
94
- }))), K = /* @__PURE__ */ r(q, {}), Q = /* @__PURE__ */ r(L, {}), W = /* @__PURE__ */ r(_, {}), S = /* @__PURE__ */ f.forwardRef(function(t, s) {
95
- const n = M({
94
+ }))), K = /* @__PURE__ */ s(q, {}), Q = /* @__PURE__ */ s(D, {}), W = /* @__PURE__ */ s(_, {}), g = /* @__PURE__ */ f.forwardRef(function(t, r) {
95
+ const n = w({
96
96
  props: t,
97
97
  name: "MuiCheckbox"
98
98
  }), {
99
99
  checkedIcon: c = K,
100
100
  color: a = "primary",
101
- icon: p = Q,
102
- indeterminate: i = !1,
101
+ icon: i = Q,
102
+ indeterminate: l = !1,
103
103
  indeterminateIcon: k = W,
104
- inputProps: O,
104
+ inputProps: S,
105
105
  size: d = "medium",
106
106
  disableRipple: y = !1,
107
- className: g,
107
+ className: O,
108
108
  slots: C = {},
109
109
  slotProps: v = {},
110
110
  ...T
111
- } = n, x = i ? k : p, P = i ? k : c, m = {
111
+ } = n, x = l ? k : i, P = l ? k : c, m = {
112
112
  ...n,
113
113
  disableRipple: y,
114
114
  color: a,
115
- indeterminate: i,
115
+ indeterminate: l,
116
116
  size: d
117
- }, z = G(m), u = v.input ?? O, [R, B] = U("root", {
118
- ref: s,
117
+ }, z = G(m), u = v.input ?? S, [R, B] = U("root", {
118
+ ref: r,
119
119
  elementType: J,
120
- className: $(z.root, g),
120
+ className: $(z.root, O),
121
121
  shouldForwardComponentProp: !0,
122
122
  externalForwardedProps: {
123
123
  slots: C,
@@ -136,18 +136,18 @@ const b = j("MuiCheckbox", ["root", "checked", "disabled", "indeterminate", "col
136
136
  disableRipple: y,
137
137
  slots: C,
138
138
  slotProps: {
139
- input: D(typeof u == "function" ? u(m) : u, {
140
- "data-indeterminate": i
139
+ input: L(typeof u == "function" ? u(m) : u, {
140
+ "data-indeterminate": l
141
141
  })
142
142
  }
143
143
  }
144
144
  });
145
- return /* @__PURE__ */ r(R, {
145
+ return /* @__PURE__ */ s(R, {
146
146
  ...B,
147
147
  classes: z
148
148
  });
149
149
  });
150
- process.env.NODE_ENV !== "production" && (S.propTypes = {
150
+ process.env.NODE_ENV !== "production" && (g.propTypes = {
151
151
  // ┌────────────────────────────── Warning ──────────────────────────────┐
152
152
  // │ These PropTypes are generated from the TypeScript type definitions. │
153
153
  // │ To update them, edit the d.ts file and run `pnpm proptypes`. │
@@ -155,50 +155,50 @@ process.env.NODE_ENV !== "production" && (S.propTypes = {
155
155
  /**
156
156
  * If `true`, the component is checked.
157
157
  */
158
- checked: e.bool,
158
+ checked: o.bool,
159
159
  /**
160
160
  * The icon to display when the component is checked.
161
161
  * @default <CheckBoxIcon />
162
162
  */
163
- checkedIcon: e.node,
163
+ checkedIcon: o.node,
164
164
  /**
165
165
  * Override or extend the styles applied to the component.
166
166
  */
167
- classes: e.object,
167
+ classes: o.object,
168
168
  /**
169
169
  * @ignore
170
170
  */
171
- className: e.string,
171
+ className: o.string,
172
172
  /**
173
173
  * The color of the component.
174
174
  * It supports both default and custom theme colors, which can be added as shown in the
175
175
  * [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors).
176
176
  * @default 'primary'
177
177
  */
178
- color: e.oneOfType([e.oneOf(["default", "primary", "secondary", "error", "info", "success", "warning"]), e.string]),
178
+ color: o.oneOfType([o.oneOf(["default", "primary", "secondary", "error", "info", "success", "warning"]), o.string]),
179
179
  /**
180
180
  * The default checked state. Use when the component is not controlled.
181
181
  */
182
- defaultChecked: e.bool,
182
+ defaultChecked: o.bool,
183
183
  /**
184
184
  * If `true`, the component is disabled.
185
185
  * @default false
186
186
  */
187
- disabled: e.bool,
187
+ disabled: o.bool,
188
188
  /**
189
189
  * If `true`, the ripple effect is disabled.
190
190
  * @default false
191
191
  */
192
- disableRipple: e.bool,
192
+ disableRipple: o.bool,
193
193
  /**
194
194
  * The icon to display when the component is unchecked.
195
195
  * @default <CheckBoxOutlineBlankIcon />
196
196
  */
197
- icon: e.node,
197
+ icon: o.node,
198
198
  /**
199
199
  * The id of the `input` element.
200
200
  */
201
- id: e.string,
201
+ id: o.string,
202
202
  /**
203
203
  * If `true`, the component appears indeterminate.
204
204
  * This does not set the native input element to indeterminate due
@@ -206,75 +206,86 @@ process.env.NODE_ENV !== "production" && (S.propTypes = {
206
206
  * However, we set a `data-indeterminate` attribute on the `input`.
207
207
  * @default false
208
208
  */
209
- indeterminate: e.bool,
209
+ indeterminate: o.bool,
210
210
  /**
211
211
  * The icon to display when the component is indeterminate.
212
212
  * @default <IndeterminateCheckBoxIcon />
213
213
  */
214
- indeterminateIcon: e.node,
214
+ indeterminateIcon: o.node,
215
215
  /**
216
216
  * [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#attributes) applied to the `input` element.
217
217
  * @deprecated Use `slotProps.input` instead. This prop will be removed in a future major release. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
218
218
  */
219
- inputProps: e.object,
219
+ inputProps: o.object,
220
220
  /**
221
221
  * Callback fired when the state is changed.
222
222
  *
223
223
  * @param {React.ChangeEvent<HTMLInputElement>} event The event source of the callback.
224
224
  * You can pull out the new checked state by accessing `event.target.checked` (boolean).
225
225
  */
226
- onChange: e.func,
226
+ onChange: o.func,
227
227
  /**
228
228
  * If `true`, the `input` element is required.
229
229
  * @default false
230
230
  */
231
- required: e.bool,
231
+ required: o.bool,
232
232
  /**
233
233
  * The size of the component.
234
234
  * `small` is equivalent to the dense checkbox styling.
235
235
  * @default 'medium'
236
236
  */
237
- size: e.oneOfType([e.oneOf(["medium", "small"]), e.string]),
237
+ size: o.oneOfType([o.oneOf(["medium", "small"]), o.string]),
238
238
  /**
239
239
  * The props used for each slot inside.
240
240
  * @default {}
241
241
  */
242
- slotProps: e.shape({
243
- input: e.oneOfType([e.func, e.object]),
244
- root: e.oneOfType([e.func, e.object])
242
+ slotProps: o.shape({
243
+ input: o.oneOfType([o.func, o.object]),
244
+ root: o.oneOfType([o.func, o.object])
245
245
  }),
246
246
  /**
247
247
  * The components used for each slot inside.
248
248
  * @default {}
249
249
  */
250
- slots: e.shape({
251
- input: e.elementType,
252
- root: e.elementType
250
+ slots: o.shape({
251
+ input: o.elementType,
252
+ root: o.elementType
253
253
  }),
254
254
  /**
255
255
  * The system prop that allows defining system overrides as well as additional CSS styles.
256
256
  */
257
- sx: e.oneOfType([e.arrayOf(e.oneOfType([e.func, e.object, e.bool])), e.func, e.object]),
257
+ sx: o.oneOfType([o.arrayOf(o.oneOfType([o.func, o.object, o.bool])), o.func, o.object]),
258
258
  /**
259
259
  * The value of the component. The DOM API casts this to a string.
260
260
  * The browser uses "on" as the default value.
261
261
  */
262
- value: e.any
262
+ value: o.any
263
263
  });
264
- function ne(o) {
265
- const { className: t, sx: s, disabled: n, color: c = "blue", ...a } = o;
266
- return /* @__PURE__ */ r(
267
- S,
264
+ function no(e) {
265
+ const { className: t, sx: r, disabled: n, color: c = "primary", forceError: a = !1, ...i } = e;
266
+ return /* @__PURE__ */ s(
267
+ g,
268
268
  {
269
269
  className: t,
270
270
  disabled: n,
271
- ...a,
271
+ color: a ? "error" : c,
272
+ ...i,
272
273
  sx: {
273
- ...s
274
+ ...a && {
275
+ color: "error.main",
276
+ "&.Mui-checked": {
277
+ color: "error.main"
278
+ }
279
+ },
280
+ "& + .MuiFormHelperText-root": {
281
+ marginLeft: 0,
282
+ marginTop: 0
283
+ },
284
+ ...r
274
285
  }
275
286
  }
276
287
  );
277
288
  }
278
289
  export {
279
- ne as CheckBox
290
+ no as CheckBox
280
291
  };
@@ -13,5 +13,6 @@ export interface CheckboxGroupProps {
13
13
  helperText?: string;
14
14
  onChange?: (checkedValues: string[]) => void;
15
15
  sx?: any;
16
+ forceError?: boolean;
16
17
  }
17
- export declare function CheckboxGroup({ options, required, minChecked, maxChecked, errorMessage, helperText, onChange, sx, }: CheckboxGroupProps): import("react/jsx-runtime").JSX.Element;
18
+ export declare function CheckboxGroup({ options, required, minChecked, maxChecked, errorMessage, helperText, onChange, sx, forceError, }: CheckboxGroupProps): import("react/jsx-runtime").JSX.Element;
@@ -1,38 +1,39 @@
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";
1
+ import { jsxs as x, jsx as l } from "react/jsx-runtime";
2
+ import { FormControl as G, FormGroup as I, FormControlLabel as y, Checkbox as B, FormHelperText as f } from "@mui/material";
3
3
  import { useState as d } from "react";
4
4
  function P({
5
- options: s,
6
- required: b = !1,
7
- minChecked: o,
8
- maxChecked: r,
9
- errorMessage: c,
10
- helperText: m,
11
- onChange: i,
12
- sx: p
5
+ options: c,
6
+ required: p = !1,
7
+ minChecked: r,
8
+ maxChecked: o,
9
+ errorMessage: m,
10
+ helperText: i,
11
+ onChange: u,
12
+ sx: b,
13
+ forceError: h = !1
13
14
  }) {
14
- const [a, h] = d(
15
- s.reduce((e, t) => ({
15
+ const [n, g] = d(
16
+ c.reduce((e, t) => ({
16
17
  ...e,
17
18
  [t.name]: t.defaultChecked || !1
18
19
  }), {})
19
- ), [g, F] = d(!1), v = (e) => {
20
- F(!0);
20
+ ), [F, v] = d(!1), j = (e) => {
21
+ v(!0);
21
22
  const t = {
22
- ...a,
23
+ ...n,
23
24
  [e.target.name]: e.target.checked
24
25
  };
25
- h(t);
26
- const L = Object.keys(t).filter(
27
- (M) => t[M]
26
+ g(t);
27
+ const M = Object.keys(t).filter(
28
+ ($) => t[$]
28
29
  );
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,
30
+ u && u(M);
31
+ }, a = Object.values(n).filter(Boolean).length, s = h || F && (r !== void 0 && a < r || o !== void 0 && a > o), L = () => m || (r !== void 0 && a < r ? `Please select at least ${r} option${r > 1 ? "s" : ""}` : o !== void 0 && a > o ? `Please select no more than ${o} option${o > 1 ? "s" : ""}` : "");
32
+ return /* @__PURE__ */ x(
33
+ G,
33
34
  {
34
- required: b,
35
- error: u,
35
+ required: p,
36
+ error: s,
36
37
  component: "fieldset",
37
38
  sx: {
38
39
  m: 0,
@@ -46,12 +47,12 @@ function P({
46
47
  "& .MuiFormControlLabel-label": {
47
48
  margin: "0 !important"
48
49
  },
49
- ...p
50
+ ...b
50
51
  },
51
52
  variant: "standard",
52
53
  children: [
53
- /* @__PURE__ */ l(G, { children: s.map((e) => /* @__PURE__ */ l(
54
- I,
54
+ /* @__PURE__ */ l(I, { children: c.map((e) => /* @__PURE__ */ l(
55
+ y,
55
56
  {
56
57
  sx: {
57
58
  color: "#404A58",
@@ -62,16 +63,17 @@ function P({
62
63
  control: /* @__PURE__ */ l(
63
64
  B,
64
65
  {
65
- checked: a[e.name] || !1,
66
- onChange: v,
67
- name: e.name
66
+ checked: n[e.name] || !1,
67
+ onChange: j,
68
+ name: e.name,
69
+ color: s ? "error" : "primary"
68
70
  }
69
71
  ),
70
72
  label: e.label
71
73
  },
72
74
  e.name
73
75
  )) }),
74
- u ? /* @__PURE__ */ l(f, { children: j() }) : m ? /* @__PURE__ */ l(f, { children: m }) : null
76
+ s ? /* @__PURE__ */ l(f, { children: L() }) : i ? /* @__PURE__ */ l(f, { children: i }) : null
75
77
  ]
76
78
  }
77
79
  );
@@ -11,5 +11,6 @@ export interface TextFieldInputProps {
11
11
  multiline?: boolean;
12
12
  rows?: number;
13
13
  sx?: any;
14
+ forceError?: boolean;
14
15
  }
15
- export declare function TextFieldInput({ label, placeholder, required, errorMessage, helperText, variant, onChange, defaultValue, type, multiline, rows, sx, }: TextFieldInputProps): import("react/jsx-runtime").JSX.Element;
16
+ export declare function TextFieldInput({ label, placeholder, required, errorMessage, helperText, variant, onChange, defaultValue, type, multiline, rows, sx, forceError, }: TextFieldInputProps): import("react/jsx-runtime").JSX.Element;