@fangzsx/component-library 0.0.27 → 0.0.28

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,6 +1,7 @@
1
1
  export interface RadioOption {
2
2
  value: string;
3
3
  label: string;
4
+ disabled?: boolean;
4
5
  }
5
6
  export interface RadioGroupProps {
6
7
  label?: string;
@@ -12,6 +13,7 @@ export interface RadioGroupProps {
12
13
  onChange?: (value: string) => void;
13
14
  row?: boolean;
14
15
  direction?: 'row' | 'column';
16
+ disabled?: boolean;
15
17
  sx?: any;
16
18
  }
17
- export declare function RadioButtonGroup({ label, options, defaultValue, required, errorMessage, helperText, onChange, row, direction, sx, }: RadioGroupProps): import("react/jsx-runtime").JSX.Element;
19
+ export declare function RadioButtonGroup({ label, options, defaultValue, required, errorMessage, helperText, onChange, row, direction, disabled, sx, }: RadioGroupProps): import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,5 @@
1
- import { jsx as l, jsxs as I } from "react/jsx-runtime";
2
- import * as u from "react";
1
+ import { jsx as n, jsxs as I } from "react/jsx-runtime";
2
+ import * as m from "react";
3
3
  import { useState as Z } from "react";
4
4
  import { f as X, c as lo, F as io, a as co, b as po } from "../../FormLabel-D4ON51Wt.js";
5
5
  import { a as $, g as B, c as M, P as o } from "../../generateUtilityClasses-BCID9NF1.js";
@@ -21,13 +21,13 @@ const E = $("MuiFormControlLabel", ["root", "labelPlacementStart", "labelPlaceme
21
21
  disabled: t,
22
22
  labelPlacement: s,
23
23
  error: a,
24
- required: i
25
- } = e, p = {
26
- root: ["root", t && "disabled", `labelPlacement${M(s)}`, a && "error", i && "required"],
24
+ required: c
25
+ } = e, d = {
26
+ root: ["root", t && "disabled", `labelPlacement${M(s)}`, a && "error", c && "required"],
27
27
  label: ["label", t && "disabled"],
28
28
  asterisk: ["asterisk", a && "error"]
29
29
  };
30
- return L(p, yo, r);
30
+ return L(d, yo, r);
31
31
  }, go = N("label", {
32
32
  name: "MuiFormControlLabel",
33
33
  slot: "Root",
@@ -99,74 +99,74 @@ const E = $("MuiFormControlLabel", ["root", "labelPlacementStart", "labelPlaceme
99
99
  [`&.${E.error}`]: {
100
100
  color: (e.vars || e).palette.error.main
101
101
  }
102
- }))), to = /* @__PURE__ */ u.forwardRef(function(r, t) {
102
+ }))), to = /* @__PURE__ */ m.forwardRef(function(r, t) {
103
103
  const s = _({
104
104
  props: r,
105
105
  name: "MuiFormControlLabel"
106
106
  }), {
107
107
  checked: a,
108
- className: i,
109
- componentsProps: p = {},
110
- control: c,
111
- disabled: d,
112
- disableTypography: m,
113
- inputRef: f,
114
- label: h,
115
- labelPlacement: P = "end",
116
- name: S,
117
- onChange: R,
118
- required: w,
119
- slots: b = {},
120
- slotProps: F = {},
121
- value: n,
122
- ...y
123
- } = s, x = A(), j = d ?? c.props.disabled ?? x?.disabled, g = w ?? c.props.required, O = {
108
+ className: c,
109
+ componentsProps: d = {},
110
+ control: p,
111
+ disabled: u,
112
+ disableTypography: f,
113
+ inputRef: b,
114
+ label: y,
115
+ labelPlacement: w = "end",
116
+ name: F,
117
+ onChange: v,
118
+ required: P,
119
+ slots: T = {},
120
+ slotProps: h = {},
121
+ value: i,
122
+ ...l
123
+ } = s, g = A(), j = u ?? p.props.disabled ?? g?.disabled, C = P ?? p.props.required, O = {
124
124
  disabled: j,
125
- required: g
125
+ required: C
126
126
  };
127
- ["checked", "name", "onChange", "value", "inputRef"].forEach((k) => {
128
- typeof c.props[k] > "u" && typeof s[k] < "u" && (O[k] = s[k]);
127
+ ["checked", "name", "onChange", "value", "inputRef"].forEach((x) => {
128
+ typeof p.props[x] > "u" && typeof s[x] < "u" && (O[x] = s[x]);
129
129
  });
130
130
  const D = X({
131
131
  props: s,
132
- muiFormControl: x,
132
+ muiFormControl: g,
133
133
  states: ["error"]
134
- }), v = {
134
+ }), S = {
135
135
  ...s,
136
136
  disabled: j,
137
- labelPlacement: P,
138
- required: g,
137
+ labelPlacement: w,
138
+ required: C,
139
139
  error: D.error
140
- }, T = ho(v), q = {
141
- slots: b,
140
+ }, k = ho(S), q = {
141
+ slots: T,
142
142
  slotProps: {
143
- ...p,
144
- ...F
143
+ ...d,
144
+ ...h
145
145
  }
146
146
  }, [U, z] = oo("typography", {
147
147
  elementType: J,
148
148
  externalForwardedProps: q,
149
- ownerState: v
149
+ ownerState: S
150
150
  });
151
- let C = h;
152
- return C != null && C.type !== J && !m && (C = /* @__PURE__ */ l(U, {
151
+ let R = y;
152
+ return R != null && R.type !== J && !f && (R = /* @__PURE__ */ n(U, {
153
153
  component: "span",
154
154
  ...z,
155
- className: G(T.label, z?.className),
156
- children: C
155
+ className: G(k.label, z?.className),
156
+ children: R
157
157
  })), /* @__PURE__ */ I(go, {
158
- className: G(T.root, i),
159
- ownerState: v,
158
+ className: G(k.root, c),
159
+ ownerState: S,
160
160
  ref: t,
161
- ...y,
162
- children: [/* @__PURE__ */ u.cloneElement(c, O), g ? /* @__PURE__ */ I("div", {
163
- children: [C, /* @__PURE__ */ I(Co, {
164
- ownerState: v,
161
+ ...l,
162
+ children: [/* @__PURE__ */ m.cloneElement(p, O), C ? /* @__PURE__ */ I("div", {
163
+ children: [R, /* @__PURE__ */ I(Co, {
164
+ ownerState: S,
165
165
  "aria-hidden": !0,
166
- className: T.asterisk,
166
+ className: k.asterisk,
167
167
  children: [" ", "*"]
168
168
  })]
169
- }) : C]
169
+ }) : R]
170
170
  });
171
171
  });
172
172
  process.env.NODE_ENV !== "production" && (to.propTypes = {
@@ -257,9 +257,9 @@ process.env.NODE_ENV !== "production" && (to.propTypes = {
257
257
  */
258
258
  value: o.any
259
259
  });
260
- const Ro = ro(/* @__PURE__ */ l("path", {
260
+ const Ro = ro(/* @__PURE__ */ n("path", {
261
261
  d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"
262
- }), "RadioButtonUnchecked"), vo = ro(/* @__PURE__ */ l("path", {
262
+ }), "RadioButtonUnchecked"), vo = ro(/* @__PURE__ */ n("path", {
263
263
  d: "M8.465 8.465C9.37 7.56 10.62 7 12 7C14.76 7 17 9.24 17 12C17 13.38 16.44 14.63 15.535 15.535C14.63 16.44 13.38 17 12 17C9.24 17 7 14.76 7 12C7 10.62 7.56 9.37 8.465 8.465Z"
264
264
  }), "RadioButtonChecked"), Po = N("span", {
265
265
  name: "MuiRadioButtonIcon",
@@ -309,11 +309,11 @@ function H(e) {
309
309
  return /* @__PURE__ */ I(Po, {
310
310
  className: t.root,
311
311
  ownerState: a,
312
- children: [/* @__PURE__ */ l(So, {
312
+ children: [/* @__PURE__ */ n(So, {
313
313
  fontSize: s,
314
314
  className: t.background,
315
315
  ownerState: a
316
- }), /* @__PURE__ */ l(wo, {
316
+ }), /* @__PURE__ */ n(wo, {
317
317
  fontSize: s,
318
318
  className: t.dot,
319
319
  ownerState: a
@@ -335,10 +335,10 @@ process.env.NODE_ENV !== "production" && (H.propTypes = {
335
335
  */
336
336
  fontSize: o.oneOf(["small", "medium"])
337
337
  });
338
- const W = /* @__PURE__ */ u.createContext(void 0);
338
+ const W = /* @__PURE__ */ m.createContext(void 0);
339
339
  process.env.NODE_ENV !== "production" && (W.displayName = "RadioGroupContext");
340
340
  function Fo() {
341
- return u.useContext(W);
341
+ return m.useContext(W);
342
342
  }
343
343
  function To(e) {
344
344
  return B("MuiRadio", e);
@@ -355,7 +355,7 @@ const Q = $("MuiRadio", ["root", "checked", "disabled", "colorPrimary", "colorSe
355
355
  ...r,
356
356
  ...L(a, To, r)
357
357
  };
358
- }, No = N(bo, {
358
+ }, xo = N(bo, {
359
359
  shouldForwardProp: (e) => Y(e) || e === "classes",
360
360
  name: "MuiRadio",
361
361
  slot: "Root",
@@ -419,80 +419,80 @@ const Q = $("MuiRadio", ["root", "checked", "disabled", "colorPrimary", "colorSe
419
419
  }
420
420
  }]
421
421
  })));
422
- function xo(e, r) {
422
+ function No(e, r) {
423
423
  return typeof r == "object" && r !== null ? e === r : String(e) === String(r);
424
424
  }
425
- const Oo = /* @__PURE__ */ l(H, {
425
+ const Oo = /* @__PURE__ */ n(H, {
426
426
  checked: !0
427
- }), Mo = /* @__PURE__ */ l(H, {}), so = /* @__PURE__ */ u.forwardRef(function(r, t) {
427
+ }), Mo = /* @__PURE__ */ n(H, {}), so = /* @__PURE__ */ m.forwardRef(function(r, t) {
428
428
  const s = _({
429
429
  props: r,
430
430
  name: "MuiRadio"
431
431
  }), {
432
432
  checked: a,
433
- checkedIcon: i = Oo,
434
- color: p = "primary",
435
- icon: c = Mo,
436
- name: d,
437
- onChange: m,
438
- size: f = "medium",
439
- className: h,
440
- disabled: P,
441
- disableRipple: S = !1,
442
- slots: R = {},
443
- slotProps: w = {},
444
- inputProps: b,
445
- ...F
446
- } = s, n = A();
447
- let y = P;
448
- n && typeof y > "u" && (y = n.disabled), y ??= !1;
449
- const x = {
433
+ checkedIcon: c = Oo,
434
+ color: d = "primary",
435
+ icon: p = Mo,
436
+ name: u,
437
+ onChange: f,
438
+ size: b = "medium",
439
+ className: y,
440
+ disabled: w,
441
+ disableRipple: F = !1,
442
+ slots: v = {},
443
+ slotProps: P = {},
444
+ inputProps: T,
445
+ ...h
446
+ } = s, i = A();
447
+ let l = w;
448
+ i && typeof l > "u" && (l = i.disabled), l ??= !1;
449
+ const g = {
450
450
  ...s,
451
- disabled: y,
452
- disableRipple: S,
453
- color: p,
454
- size: f
455
- }, j = ko(x), g = Fo();
451
+ disabled: l,
452
+ disableRipple: F,
453
+ color: d,
454
+ size: b
455
+ }, j = ko(g), C = Fo();
456
456
  let O = a;
457
- const D = lo(m, g && g.onChange);
458
- let v = d;
459
- g && (typeof O > "u" && (O = xo(g.value, s.value)), typeof v > "u" && (v = g.name));
460
- const T = w.input ?? b, [q, U] = oo("root", {
457
+ const D = lo(f, C && C.onChange);
458
+ let S = u;
459
+ C && (typeof O > "u" && (O = No(C.value, s.value)), typeof S > "u" && (S = C.name));
460
+ const k = P.input ?? T, [q, U] = oo("root", {
461
461
  ref: t,
462
- elementType: No,
463
- className: G(j.root, h),
462
+ elementType: xo,
463
+ className: G(j.root, y),
464
464
  shouldForwardComponentProp: !0,
465
465
  externalForwardedProps: {
466
- slots: R,
467
- slotProps: w,
468
- ...F
466
+ slots: v,
467
+ slotProps: P,
468
+ ...h
469
469
  },
470
470
  getSlotProps: (z) => ({
471
471
  ...z,
472
- onChange: (C, ...k) => {
473
- z.onChange?.(C, ...k), D(C, ...k);
472
+ onChange: (R, ...x) => {
473
+ z.onChange?.(R, ...x), D(R, ...x);
474
474
  }
475
475
  }),
476
- ownerState: x,
476
+ ownerState: g,
477
477
  additionalProps: {
478
478
  type: "radio",
479
- icon: /* @__PURE__ */ u.cloneElement(c, {
480
- fontSize: c.props.fontSize ?? f
479
+ icon: /* @__PURE__ */ m.cloneElement(p, {
480
+ fontSize: p.props.fontSize ?? b
481
481
  }),
482
- checkedIcon: /* @__PURE__ */ u.cloneElement(i, {
483
- fontSize: i.props.fontSize ?? f
482
+ checkedIcon: /* @__PURE__ */ m.cloneElement(c, {
483
+ fontSize: c.props.fontSize ?? b
484
484
  }),
485
- disabled: y,
486
- name: v,
485
+ disabled: l,
486
+ name: S,
487
487
  checked: O,
488
- slots: R,
488
+ slots: v,
489
489
  slotProps: {
490
490
  // Do not forward `slotProps.root` again because it's already handled by the `RootSlot` in this file.
491
- input: typeof T == "function" ? T(x) : T
491
+ input: typeof k == "function" ? k(g) : k
492
492
  }
493
493
  }
494
494
  });
495
- return /* @__PURE__ */ l(q, {
495
+ return /* @__PURE__ */ n(q, {
496
496
  ...U,
497
497
  classes: j
498
498
  });
@@ -636,28 +636,28 @@ const zo = (e) => {
636
636
  flexDirection: "row"
637
637
  }
638
638
  }]
639
- }), ao = /* @__PURE__ */ u.forwardRef(function(r, t) {
639
+ }), ao = /* @__PURE__ */ m.forwardRef(function(r, t) {
640
640
  const s = _({
641
641
  props: r,
642
642
  name: "MuiFormGroup"
643
643
  }), {
644
644
  className: a,
645
- row: i = !1,
646
- ...p
647
- } = s, c = A(), d = X({
645
+ row: c = !1,
646
+ ...d
647
+ } = s, p = A(), u = X({
648
648
  props: s,
649
- muiFormControl: c,
649
+ muiFormControl: p,
650
650
  states: ["error"]
651
- }), m = {
651
+ }), f = {
652
652
  ...s,
653
- row: i,
654
- error: d.error
655
- }, f = zo(m);
656
- return /* @__PURE__ */ l(Eo, {
657
- className: G(f.root, a),
658
- ownerState: m,
653
+ row: c,
654
+ error: u.error
655
+ }, b = zo(f);
656
+ return /* @__PURE__ */ n(Eo, {
657
+ className: G(b.root, a),
658
+ ownerState: f,
659
659
  ref: t,
660
- ...p
660
+ ...d
661
661
  });
662
662
  });
663
663
  process.env.NODE_ENV !== "production" && (ao.propTypes = {
@@ -700,43 +700,43 @@ const Go = (e) => {
700
700
  return L({
701
701
  root: ["root", t && "row", s && "error"]
702
702
  }, Io, r);
703
- }, no = /* @__PURE__ */ u.forwardRef(function(r, t) {
703
+ }, no = /* @__PURE__ */ m.forwardRef(function(r, t) {
704
704
  const {
705
705
  // private
706
706
  // eslint-disable-next-line react/prop-types
707
707
  actions: s,
708
708
  children: a,
709
- className: i,
710
- defaultValue: p,
711
- name: c,
712
- onChange: d,
713
- value: m,
714
- ...f
715
- } = r, h = u.useRef(null), P = Go(r), [S, R] = uo({
716
- controlled: m,
717
- default: p,
709
+ className: c,
710
+ defaultValue: d,
711
+ name: p,
712
+ onChange: u,
713
+ value: f,
714
+ ...b
715
+ } = r, y = m.useRef(null), w = Go(r), [F, v] = uo({
716
+ controlled: f,
717
+ default: d,
718
718
  name: "RadioGroup"
719
719
  });
720
- u.useImperativeHandle(s, () => ({
720
+ m.useImperativeHandle(s, () => ({
721
721
  focus: () => {
722
- let n = h.current.querySelector("input:not(:disabled):checked");
723
- n || (n = h.current.querySelector("input:not(:disabled)")), n && n.focus();
722
+ let i = y.current.querySelector("input:not(:disabled):checked");
723
+ i || (i = y.current.querySelector("input:not(:disabled)")), i && i.focus();
724
724
  }
725
725
  }), []);
726
- const w = fo(t, h), b = mo(c), F = u.useMemo(() => ({
727
- name: b,
728
- onChange(n) {
729
- R(n.target.value), d && d(n, n.target.value);
726
+ const P = fo(t, y), T = mo(p), h = m.useMemo(() => ({
727
+ name: T,
728
+ onChange(i) {
729
+ v(i.target.value), u && u(i, i.target.value);
730
730
  },
731
- value: S
732
- }), [b, d, R, S]);
733
- return /* @__PURE__ */ l(W.Provider, {
734
- value: F,
735
- children: /* @__PURE__ */ l(ao, {
731
+ value: F
732
+ }), [T, u, v, F]);
733
+ return /* @__PURE__ */ n(W.Provider, {
734
+ value: h,
735
+ children: /* @__PURE__ */ n(ao, {
736
736
  role: "radiogroup",
737
- ref: w,
738
- className: G(P.root, i),
739
- ...f,
737
+ ref: P,
738
+ className: G(w.root, c),
739
+ ...b,
740
740
  children: a
741
741
  })
742
742
  });
@@ -782,54 +782,57 @@ function Ko({
782
782
  defaultValue: t,
783
783
  required: s = !1,
784
784
  errorMessage: a = "Please select an option",
785
- helperText: i,
786
- onChange: p,
787
- row: c = !1,
788
- direction: d,
789
- sx: m
785
+ helperText: c,
786
+ onChange: d,
787
+ row: p = !1,
788
+ direction: u,
789
+ disabled: f = !1,
790
+ sx: b
790
791
  }) {
791
- const [f, h] = Z(t || ""), [P, S] = Z(!1), R = (n) => {
792
- const y = n.target.value;
793
- h(y), S(!0), p && p(y);
794
- }, b = P && s && f === "", F = d ? d === "row" : c;
792
+ const [y, w] = Z(t || ""), [F, v] = Z(!1), P = (l) => {
793
+ const g = l.target.value;
794
+ w(g), v(!0), d && d(g);
795
+ }, h = F && s && y === "", i = u ? u === "row" : p;
795
796
  return /* @__PURE__ */ I(
796
797
  io,
797
798
  {
798
- error: b,
799
+ error: h,
799
800
  required: s,
801
+ disabled: f,
800
802
  sx: {
801
803
  "& .MuiFormHelperText-root": {
802
804
  marginLeft: 0,
803
805
  marginRight: 0
804
806
  },
805
- ...m
807
+ ...b
806
808
  },
807
809
  children: [
808
- e && /* @__PURE__ */ l(co, { children: e }),
809
- /* @__PURE__ */ l(
810
+ e && /* @__PURE__ */ n(co, { children: e }),
811
+ /* @__PURE__ */ n(
810
812
  no,
811
813
  {
812
- value: f,
813
- onChange: R,
814
- row: F,
815
- children: r.map((n) => /* @__PURE__ */ l(
814
+ value: y,
815
+ onChange: P,
816
+ row: i,
817
+ children: r.map((l) => /* @__PURE__ */ n(
816
818
  to,
817
819
  {
818
- value: n.value,
819
- control: /* @__PURE__ */ l(so, {}),
820
- label: n.label,
820
+ value: l.value,
821
+ disabled: f || l.disabled,
822
+ control: /* @__PURE__ */ n(so, {}),
823
+ label: l.label,
821
824
  sx: {
822
825
  "& .MuiFormControlLabel-label": {
823
- color: "#404A58",
826
+ color: f || l.disabled ? "text.disabled" : "#404A58",
824
827
  fontSize: "16px"
825
828
  }
826
829
  }
827
830
  },
828
- n.value
831
+ l.value
829
832
  ))
830
833
  }
831
834
  ),
832
- (b || i) && /* @__PURE__ */ l(po, { children: b ? a : i || " " })
835
+ (h || c) && /* @__PURE__ */ n(po, { children: h ? a : c || " " })
833
836
  ]
834
837
  }
835
838
  );
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@fangzsx/component-library",
3
3
  "author": "Jay Gilbert Garzon",
4
4
  "private": false,
5
- "version": "0.0.27",
5
+ "version": "0.0.28",
6
6
  "type": "module",
7
7
  "main": "dist/main.js",
8
8
  "types": "dist/main.d.ts",