jcicl 1.1.5 → 1.2.2

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.
Files changed (49) hide show
  1. package/Button/Button.d.ts +1 -0
  2. package/Button/Button.js +73 -70
  3. package/DesktopStepper/DesktopStepper.d.ts +24 -0
  4. package/DesktopStepper/DesktopStepper.js +204 -0
  5. package/DesktopStepper/index.d.ts +1 -0
  6. package/DesktopStepper/index.js +5 -0
  7. package/FieldGroup/FieldGroup.js +15 -12
  8. package/FieldVisibilityWrapper/FieldVisibilityWrapper.d.ts +11 -0
  9. package/FieldVisibilityWrapper/FieldVisibilityWrapper.js +48 -0
  10. package/FieldVisibilityWrapper/index.d.ts +1 -0
  11. package/FieldVisibilityWrapper/index.js +4 -0
  12. package/FormContext/createFormContext.js +91 -72
  13. package/FormContext/types.d.ts +8 -0
  14. package/FormFields/FormFields.d.ts +2 -2
  15. package/FormFields/FormFields.js +18 -18
  16. package/FormInput/FormInput.d.ts +4 -0
  17. package/FormInput/FormInput.js +39 -14
  18. package/LabeledCheckbox/LabeledCheckbox.js +4 -4
  19. package/LabeledCurrencyInput/LabeledCurrencyInput.js +33 -33
  20. package/LabeledInput/LabeledInput.d.ts +2 -0
  21. package/LabeledInput/LabeledInput.js +16 -14
  22. package/LabeledRadio/LabeledRadio.js +12 -12
  23. package/Nav/Nav.js +174 -151
  24. package/SelectableItemCard/SelectableItemCard.d.ts +9 -0
  25. package/SelectableItemCard/SelectableItemCard.js +24 -0
  26. package/SelectableItemCard/index.d.ts +1 -0
  27. package/SelectableItemCard/index.js +4 -0
  28. package/Stepper/Stepper.js +184 -226
  29. package/Table/Table.js +236 -234
  30. package/Tabs/Tabs.d.ts +42 -0
  31. package/Tabs/Tabs.js +121 -0
  32. package/Tabs/index.d.ts +1 -0
  33. package/Tabs/index.js +4 -0
  34. package/api.d.ts +16 -5
  35. package/api.js +42 -28
  36. package/assets/style.css +1 -1
  37. package/assets/tailwind.css +2 -2
  38. package/constants.js +1 -1
  39. package/formatters.d.ts +1 -0
  40. package/formatters.js +30 -17
  41. package/index.d.ts +2 -0
  42. package/index.js +64 -62
  43. package/package.json +1 -1
  44. package/problemDetails.d.ts +20 -0
  45. package/problemDetails.js +19 -0
  46. package/utils.d.ts +2 -2
  47. package/utils.js +35 -29
  48. package/validators.d.ts +8 -0
  49. package/validators.js +19 -9
@@ -1,96 +1,115 @@
1
- import { jsx as w } from "react/jsx-runtime";
2
- import { createContext as E, useState as P, useCallback as N, useEffect as $, useMemo as k } from "react";
1
+ import { jsx as I } from "react/jsx-runtime";
2
+ import { createContext as M, useState as S, useCallback as E, useEffect as V, useMemo as Z } from "react";
3
3
  import "../utils.js";
4
- import { logger as x } from "../logger.js";
5
- import { formatPhoneNumber as S, formatZipCode as D, formatSSN as A } from "../formatters.js";
6
- function j(v) {
7
- const { name: o, defaultValues: c = {}, onInputChangeExtensions: m = [], submit: l, debug: n = !1 } = v, d = E({
8
- onFormInputChange: () => x.error(`Failed to update form input. ${o}FormContext not initialized`),
9
- formData: c,
10
- setFormData: () => x.error(`Failed to set form data. ${o}FormContext not initialized`),
11
- resetForm: () => x.error(`Failed to reset form. ${o}FormContext not initialized`)
4
+ import { logger as h } from "../logger.js";
5
+ import { formatPhoneNumber as z, formatZipCode as D, formatSSN as $, formatCurrency as w } from "../formatters.js";
6
+ function T(F) {
7
+ const { name: n, defaultValues: f = {}, onInputChangeExtensions: p = [], submit: u, debug: a = !1 } = F, m = M({
8
+ onFormInputChange: () => h.error(`Failed to update form input. ${n}FormContext not initialized`),
9
+ formData: f,
10
+ setFormData: () => h.error(`Failed to set form data. ${n}FormContext not initialized`),
11
+ resetForm: () => h.error(`Failed to reset form. ${n}FormContext not initialized`),
12
+ fieldErrors: {},
13
+ setFieldErrors: () => h.error(`Failed to set field errors. ${n}FormContext not initialized`)
12
14
  });
13
- return { Context: d, Provider: ({ children: C }) => {
14
- const [r, u] = P(c), p = N(
15
- (i, t, a) => {
16
- u((f) => {
17
- let e;
18
- if (a === "checkbox")
19
- e = t.target.checked;
20
- else if (a === "multiDropdown") {
21
- const s = t.target.value;
22
- Array.isArray(s) ? e = s.map((z) => z.value) : e = [];
23
- } else if (a === "phone") {
24
- const [, s] = S(t.target.value);
25
- e = s;
26
- } else if (a === "zip") {
27
- const [, s] = D(t.target.value);
28
- e = s;
29
- } else if (a === "ssn") {
30
- const [, s] = A(t.target.value);
31
- e = s;
15
+ return { Context: m, Provider: ({ children: N }) => {
16
+ const [s, d] = S(f), [g, v] = S({}), b = E(
17
+ (x, t, o) => {
18
+ d((e) => {
19
+ let r;
20
+ if (o === "checkbox")
21
+ r = t.target.checked;
22
+ else if (o === "multiDropdown") {
23
+ const i = t.target.value;
24
+ Array.isArray(i) ? r = i.map((A) => A.value) : r = [];
25
+ } else if (o === "phone") {
26
+ const [, i] = z(t.target.value);
27
+ r = i;
28
+ } else if (o === "zip") {
29
+ const [, i] = D(t.target.value);
30
+ r = i;
31
+ } else if (o === "ssn") {
32
+ const [, i] = $(t.target.value);
33
+ r = i;
34
+ } else if (o === "currency") {
35
+ const [, i] = w(t.target.value);
36
+ r = i;
32
37
  } else
33
- e = t.target.value;
34
- return e === "undefined" && (e = void 0), { ...f, [i]: e };
38
+ r = t.target.value;
39
+ return r === "undefined" && (r = void 0), { ...e, [x]: r };
40
+ }), v((e) => {
41
+ if (!e[x]) return e;
42
+ const r = { ...e };
43
+ return delete r[x], r;
35
44
  });
36
- let g;
37
- if (a === "checkbox")
38
- g = t.target.checked;
39
- else if (a === "phone") {
40
- const [, f] = S(t.target.value);
41
- g = f;
42
- } else if (a === "zip") {
43
- const [, f] = D(t.target.value);
44
- g = f;
45
+ let c;
46
+ if (o === "checkbox")
47
+ c = t.target.checked;
48
+ else if (o === "phone") {
49
+ const [, e] = z(t.target.value);
50
+ c = e;
51
+ } else if (o === "zip") {
52
+ const [, e] = D(t.target.value);
53
+ c = e;
54
+ } else if (o === "ssn") {
55
+ const [, e] = $(t.target.value);
56
+ c = e;
57
+ } else if (o === "currency") {
58
+ const [, e] = w(t.target.value);
59
+ c = e;
45
60
  } else
46
- g = t.target.value === "undefined" ? void 0 : t.target.value;
47
- m.forEach((f) => {
48
- f(i, g, u);
61
+ c = t.target.value === "undefined" ? void 0 : t.target.value;
62
+ p.forEach((e) => {
63
+ e(x, c, d);
49
64
  });
50
65
  },
51
66
  // onInputChangeExtensions is captured from the factory closure (not React state/props);
52
67
  // it can never change for the lifetime of this Provider, so it's not a valid dep.
53
68
  []
54
- ), h = N(() => u(c), []);
55
- $(() => {
56
- n && x.log(`[${o}Form] Updated form data:`, r);
57
- }, [r]);
58
- const b = k(
69
+ ), l = E(() => {
70
+ d(f), v({});
71
+ }, []);
72
+ V(() => {
73
+ a && h.log(`[${n}Form] Updated form data:`, s);
74
+ }, [s]);
75
+ const P = Z(
59
76
  () => ({
60
- onFormInputChange: p,
61
- formData: r,
62
- setFormData: u,
63
- resetForm: h,
64
- ...l ? { submit: () => l(r) } : {}
77
+ onFormInputChange: b,
78
+ formData: s,
79
+ setFormData: d,
80
+ resetForm: l,
81
+ fieldErrors: g,
82
+ setFieldErrors: v,
83
+ ...u ? { submit: () => u(s) } : {}
65
84
  }),
66
- // submit is factory-closure-stable; only formData and the memoized callbacks can change.
67
- [r, p, h]
85
+ // submit is factory-closure-stable; only formData/fieldErrors and the memoized callbacks change.
86
+ [s, g, b, l]
68
87
  );
69
- return /* @__PURE__ */ w(d.Provider, { value: b, children: C });
88
+ return /* @__PURE__ */ I(m.Provider, { value: P, children: N });
70
89
  } };
71
90
  }
72
- function B(v = "dateOfBirth", o = "age") {
73
- return (c, m, l) => {
74
- if (c === v && m && typeof m == "string") {
75
- const n = m.split("-");
76
- if (n.length !== 3) {
77
- l((i) => ({ ...i, [o]: void 0 }));
91
+ function U(F = "dateOfBirth", n = "age") {
92
+ return (f, p, u) => {
93
+ if (f === F && p && typeof p == "string") {
94
+ const a = p.split("-");
95
+ if (a.length !== 3) {
96
+ u((l) => ({ ...l, [n]: void 0 }));
78
97
  return;
79
98
  }
80
- const d = Number(n[0]), F = Number(n[1]), C = Number(n[2]), r = /* @__PURE__ */ new Date(), u = r.getFullYear(), p = r.getMonth() + 1, h = r.getDate();
81
- if (d > u || d < 1900) {
82
- l((i) => ({ ...i, [o]: void 0 }));
99
+ const m = Number(a[0]), C = Number(a[1]), N = Number(a[2]), s = /* @__PURE__ */ new Date(), d = s.getFullYear(), g = s.getMonth() + 1, v = s.getDate();
100
+ if (m > d || m < 1900) {
101
+ u((l) => ({ ...l, [n]: void 0 }));
83
102
  return;
84
103
  }
85
- let b = u - d;
86
- (F > p || F === p && C > h) && (b -= 1), l((i) => ({
87
- ...i,
88
- [o]: String(b)
104
+ let b = d - m;
105
+ (C > g || C === g && N > v) && (b -= 1), u((l) => ({
106
+ ...l,
107
+ [n]: String(b)
89
108
  }));
90
- } else c === v && l((n) => ({ ...n, [o]: void 0 }));
109
+ } else f === F && u((a) => ({ ...a, [n]: void 0 }));
91
110
  };
92
111
  }
93
112
  export {
94
- B as createDobToAgeExtension,
95
- j as createFormContext
113
+ U as createDobToAgeExtension,
114
+ T as createFormContext
96
115
  };
@@ -18,6 +18,14 @@ export interface FormContextProps<T extends Record<string, unknown>> {
18
18
  resetForm: () => void;
19
19
  /** Optional submit handler (if configured in factory) */
20
20
  submit?: () => void;
21
+ /**
22
+ * Server-supplied per-field error messages (field key → message), e.g. mapped from an
23
+ * RFC 7807 ValidationProblemDetails `errors` map. FieldGroup surfaces these on the matching
24
+ * inputs; they are cleared per-field as the user edits and fully on resetForm.
25
+ */
26
+ fieldErrors?: Record<string, string>;
27
+ /** Replace the current set of server field errors (e.g. after a failed submit). */
28
+ setFieldErrors?: (errors: Record<string, string>) => void;
21
29
  }
22
30
  /**
23
31
  * Extension function called after each input change.
@@ -1,6 +1,6 @@
1
1
  import { FormInputType } from '../FormInput';
2
2
  import { DropdownOption } from '../LabeledDropdown';
3
- import { AllInputProps } from '../FormInput/FormInput';
3
+ import { AllInputProps, FormInputProps } from '../FormInput/FormInput';
4
4
  export type FormField = {
5
5
  key: string;
6
6
  label?: string;
@@ -9,7 +9,7 @@ export type FormField = {
9
9
  options?: DropdownOption[];
10
10
  limit?: number;
11
11
  defaultValue?: string | number;
12
- } & Partial<AllInputProps>;
12
+ } & Partial<AllInputProps> & Pick<FormInputProps, 'showError' | 'customValidation' | 'overrideValidation'>;
13
13
  export type FormFieldsProps = {
14
14
  title?: string;
15
15
  fields: FormField[];
@@ -4,7 +4,7 @@ import { FormSectionTitle as g, FormFieldGrid as j, FormTextLine as I, FormField
4
4
  import "../AvatarWithImage/AvatarWithImage.js";
5
5
  import "../Button/Button.js";
6
6
  import "../Divider/Divider.js";
7
- import { Flex as V } from "../Flex/Flex.js";
7
+ import { Flex as G } from "../Flex/Flex.js";
8
8
  import "../Grid/Grid.js";
9
9
  import "../Icon/Icon.js";
10
10
  import "../Input/Input.js";
@@ -14,7 +14,7 @@ import "../Loading/Loading.js";
14
14
  import "react";
15
15
  import "../ScrollContainer/ScrollContainer.js";
16
16
  import "../ThemeContext.js";
17
- import { useIsTablet as G } from "../utils.js";
17
+ import { useIsTablet as S } from "../utils.js";
18
18
  import "../CustomAlert/CustomAlert.js";
19
19
  import "react-dom";
20
20
  import "../Accordion/Accordion.js";
@@ -38,24 +38,24 @@ import "../AuthContext/AuthProvider.js";
38
38
  import "../AppContainer/AppContainer.js";
39
39
  import "../DefaultTemplate/DefaultTemplate.js";
40
40
  const vo = ({
41
- title: a,
42
- fields: h,
43
- columns: f,
44
- columnsOverride: w,
41
+ title: h,
42
+ fields: a,
43
+ columns: w,
44
+ columnsOverride: f,
45
45
  gap: C = 21,
46
46
  noLabel: x = !1,
47
47
  checkboxContainer: F = !1,
48
48
  compact: v = !1,
49
- formDefaults: l,
49
+ formDefaults: n,
50
50
  onChange: d
51
51
  }) => {
52
- const D = G();
52
+ const D = S();
53
53
  return /* @__PURE__ */ b(T, { children: [
54
- a && /* @__PURE__ */ m(g, { children: a }),
55
- !F && /* @__PURE__ */ m(j, { columns: f ?? (D ? 2 : 3), columnsOverride: w, gap: C, children: h.map(({ key: r, label: n, type: o, limit: c, options: e, defaultValue: t, ...u }) => {
56
- const i = l[r] !== void 0 ? l[r] : t !== void 0 ? t : o === "multiDropdown" ? [] : o === "checkbox" ? !1 : "";
57
- return v ? /* @__PURE__ */ b(V, { column: !0, gap: "21px", children: [
58
- /* @__PURE__ */ m(I, { children: n }),
54
+ h && /* @__PURE__ */ m(g, { children: h }),
55
+ !F && /* @__PURE__ */ m(j, { columns: w ?? (D ? 2 : 3), columnsOverride: f, gap: C, children: a.map(({ key: r, label: l, type: o, limit: c, options: e, defaultValue: t, ...u }) => {
56
+ const i = n[r] !== void 0 ? n[r] : t !== void 0 ? t : o === "multiDropdown" ? [] : o === "checkbox" ? !1 : "";
57
+ return v ? /* @__PURE__ */ b(G, { column: !0, gap: "21px", children: [
58
+ /* @__PURE__ */ m(I, { children: l }),
59
59
  /* @__PURE__ */ m(
60
60
  s,
61
61
  {
@@ -73,7 +73,7 @@ const vo = ({
73
73
  s,
74
74
  {
75
75
  onChange: (p) => d(r, p, o),
76
- label: n,
76
+ label: l,
77
77
  type: o,
78
78
  limit: c,
79
79
  ...o === "checkbox" ? { checked: !!i } : { value: i },
@@ -85,16 +85,16 @@ const vo = ({
85
85
  r
86
86
  );
87
87
  }) }),
88
- F && /* @__PURE__ */ m(L, { children: h.map(({ key: r, label: n, type: o, limit: c, options: e, defaultValue: t, ...u }) => {
89
- const i = l[r] !== void 0 ? l[r] : t !== void 0 ? t : o === "multiDropdown" ? [] : o === "checkbox" ? !1 : "";
88
+ F && /* @__PURE__ */ m(L, { children: a.map(({ key: r, label: l, type: o, limit: c, options: e, defaultValue: t, ...u }) => {
89
+ const i = n[r] !== void 0 ? n[r] : t !== void 0 ? t : o === "multiDropdown" ? [] : o === "checkbox" ? !1 : "";
90
90
  return /* @__PURE__ */ m(
91
91
  s,
92
92
  {
93
93
  onChange: (p) => d(r, p, o),
94
- label: n,
94
+ label: l,
95
95
  type: o,
96
96
  limit: c,
97
- ...o === "checkbox" ? { checked: !!i } : { defaultValue: i },
97
+ ...o === "checkbox" ? { checked: !!i } : { value: i },
98
98
  noLabel: x,
99
99
  options: e,
100
100
  multiple: o === "multiDropdown",
@@ -5,6 +5,7 @@ import { LabeledRadioProps } from '../LabeledRadio';
5
5
  import { LabeledDropdownProps, DropdownOption } from '../LabeledDropdown';
6
6
  import { LabeledTextAreaProps } from '../LabeledTextArea/LabeledTextArea';
7
7
  import { LabeledFormattedInputProps } from '../LabeledFormattedInput';
8
+ import { InputValidationFunction } from '../utils';
8
9
  import { FormInputType } from '../inputTypes';
9
10
  export type AllInputProps = LabeledInputProps & LabeledCheckboxProps & LabeledRadioProps & LabeledDropdownProps & LabeledCurrencyInputProps & LabeledTextAreaProps & LabeledFormattedInputProps;
10
11
  export { type FormInputType } from '../inputTypes';
@@ -17,6 +18,9 @@ export type FormInputProps = Partial<Omit<AllInputProps, ConflictingKeys | 'type
17
18
  checked?: boolean;
18
19
  defaultValue?: unknown;
19
20
  label?: string;
21
+ showError?: boolean;
22
+ overrideValidation?: boolean;
23
+ customValidation?: InputValidationFunction;
20
24
  };
21
25
  export declare const FormInput: React.FC<FormInputProps>;
22
26
  export default FormInput;
@@ -1,17 +1,42 @@
1
- import { jsx as t } from "react/jsx-runtime";
2
- import { LabeledInput as o } from "../LabeledInput/LabeledInput.js";
3
- import { LabeledCurrencyInput as m } from "../LabeledCurrencyInput/LabeledCurrencyInput.js";
4
- import { LabeledCheckbox as a } from "../LabeledCheckbox/LabeledCheckbox.js";
5
- import { LabeledRadio as d } from "../LabeledRadio/LabeledRadio.js";
6
- import { LabeledDropdown as f } from "../LabeledDropdown/LabeledDropdown.js";
7
- import { LabeledTextArea as i } from "../LabeledTextArea/LabeledTextArea.js";
8
- import { LabeledFormattedInput as n } from "../LabeledFormattedInput/LabeledFormattedInput.js";
9
- import { formattedOrMaskedTypes as b } from "../utils.js";
10
- const k = (e) => {
11
- const { type: r = "text" } = e;
12
- return r === "dropdown" || r === "multiDropdown" ? /* @__PURE__ */ t(f, { ...e }) : r === "checkbox" ? /* @__PURE__ */ t(a, { ...e }) : r === "radio" ? /* @__PURE__ */ t(d, { ...e }) : r === "currency" ? /* @__PURE__ */ t(m, { ...e }) : r === "textarea" ? /* @__PURE__ */ t(i, { ...e }) : b.has(r) ? /* @__PURE__ */ t(n, { ...e, type: r }) : /* @__PURE__ */ t(o, { ...e, type: r });
1
+ import { jsx as o } from "react/jsx-runtime";
2
+ import { useState as v, useEffect as E } from "react";
3
+ import { LabeledInput as k } from "../LabeledInput/LabeledInput.js";
4
+ import { LabeledCurrencyInput as w } from "../LabeledCurrencyInput/LabeledCurrencyInput.js";
5
+ import { LabeledCheckbox as I } from "../LabeledCheckbox/LabeledCheckbox.js";
6
+ import { LabeledRadio as V } from "../LabeledRadio/LabeledRadio.js";
7
+ import { LabeledDropdown as q } from "../LabeledDropdown/LabeledDropdown.js";
8
+ import { LabeledTextArea as C } from "../LabeledTextArea/LabeledTextArea.js";
9
+ import { LabeledFormattedInput as D } from "../LabeledFormattedInput/LabeledFormattedInput.js";
10
+ import { formattedOrMaskedTypes as F } from "../utils.js";
11
+ import { inputValidatorsByType as T } from "../validators.js";
12
+ const G = (a) => {
13
+ const { type: r = "text", required: m, label: l, value: d } = a, { customValidation: s, showError: p, overrideValidation: f = !1, ...e } = a, [y, u] = v(!1), [L, c] = v(void 0), h = r !== "checkbox" && r !== "radio";
14
+ E(() => {
15
+ if (!p || !h) {
16
+ u(!1), c(void 0);
17
+ return;
18
+ }
19
+ const x = d === void 0 || d === "", n = [];
20
+ m && !f && n.push(
21
+ (t) => t === void 0 || t === "" ? `${l ?? "This field"} is required.` : void 0
22
+ ), !f && T[r] && !x && n.push(T[r]), s && !x && n.push(s);
23
+ const b = n.map((t) => t(d)).find((t) => t !== void 0);
24
+ u(!!b), c(b);
25
+ }, [p, d, r, m, l, s, f, h]);
26
+ const i = {
27
+ error: y || a.error,
28
+ helperText: L ?? a.helperText
29
+ };
30
+ return r === "dropdown" || r === "multiDropdown" ? /* @__PURE__ */ o(q, { ...e, ...i }) : r === "checkbox" ? /* @__PURE__ */ o(I, { ...e }) : r === "radio" ? /* @__PURE__ */ o(V, { ...e }) : r === "currency" ? /* @__PURE__ */ o(w, { ...e, ...i }) : r === "textarea" ? /* @__PURE__ */ o(C, { ...e, ...i }) : F.has(r) ? /* @__PURE__ */ o(
31
+ D,
32
+ {
33
+ ...e,
34
+ type: r,
35
+ ...i
36
+ }
37
+ ) : /* @__PURE__ */ o(k, { ...e, type: r, ...i });
13
38
  };
14
39
  export {
15
- k as FormInput,
16
- k as default
40
+ G as FormInput,
41
+ G as default
17
42
  };
@@ -3,7 +3,7 @@ import { n as B } from "../.chunks/emotion-styled.browser.esm.js";
3
3
  import { c as g } from "../.chunks/emotion-react.browser.esm.js";
4
4
  import { useThemeColors as P } from "../ThemeContext.js";
5
5
  import * as f from "react";
6
- import { a as R, g as T, s as M, r as N, c as p, d as z, u as L, P as o, b as V } from "../.chunks/DefaultPropsProvider.js";
6
+ import { a as R, g as M, s as T, r as N, c as p, d as z, u as L, P as o, b as V } from "../.chunks/DefaultPropsProvider.js";
7
7
  import { c as H } from "../.chunks/clsx.js";
8
8
  import { S as E } from "../.chunks/SwitchBase.js";
9
9
  import { c as b } from "../.chunks/createSvgIcon.js";
@@ -18,7 +18,7 @@ const D = b(/* @__PURE__ */ r("path", {
18
18
  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"
19
19
  }), "IndeterminateCheckBox");
20
20
  function W(e) {
21
- return T("MuiCheckbox", e);
21
+ return M("MuiCheckbox", e);
22
22
  }
23
23
  const u = R("MuiCheckbox", ["root", "checked", "disabled", "indeterminate", "colorPrimary", "colorSecondary", "sizeSmall", "sizeMedium"]), _ = (e) => {
24
24
  const {
@@ -34,7 +34,7 @@ const u = R("MuiCheckbox", ["root", "checked", "disabled", "indeterminate", "col
34
34
  // forward the disabled and checked classes to the SwitchBase
35
35
  ...c
36
36
  };
37
- }, G = M(E, {
37
+ }, G = T(E, {
38
38
  shouldForwardProp: (e) => N(e) || e === "classes",
39
39
  name: "MuiCheckbox",
40
40
  slot: "Root",
@@ -236,7 +236,7 @@ process.env.NODE_ENV !== "production" && (h.propTypes = {
236
236
  */
237
237
  value: o.any
238
238
  });
239
- const w = B("div", { shouldForwardProp: (e) => !["customTheme"].includes(e) })(({ displayMode: e, customTheme: t }) => ({
239
+ const w = B("div", { shouldForwardProp: (e) => !["customTheme", "displayMode"].includes(e) })(({ displayMode: e, customTheme: t }) => ({
240
240
  ...g`
241
241
  display: flex;
242
242
  flex-wrap: nowrap;
@@ -1,10 +1,12 @@
1
- import { jsxs as l, jsx as y } from "react/jsx-runtime";
2
- import { useState as b } from "react";
3
- import { n as h } from "../.chunks/emotion-styled.browser.esm.js";
4
- import { c } from "../.chunks/emotion-react.browser.esm.js";
5
- import { Input as w } from "../Input/Input.js";
6
- const x = h("div")(({ grid: r, displayMode: n }) => ({
7
- ...c`
1
+ import { jsxs as c, jsx as b } from "react/jsx-runtime";
2
+ import { useState as w } from "react";
3
+ import { n as x } from "../.chunks/emotion-styled.browser.esm.js";
4
+ import { c as m } from "../.chunks/emotion-react.browser.esm.js";
5
+ import { Input as I } from "../Input/Input.js";
6
+ import "../utils.js";
7
+ import { formatCurrency as C } from "../formatters.js";
8
+ const V = x("div")(({ grid: n, displayMode: o }) => ({
9
+ ...m`
8
10
  display: flex;
9
11
  flex-wrap: nowrap;
10
12
  gap: 9px;
@@ -20,10 +22,10 @@ const x = h("div")(({ grid: r, displayMode: n }) => ({
20
22
  }
21
23
 
22
24
  .MuiCurrencyInputBase-root {
23
- width: ${r && "100%"};
25
+ width: ${n && "100%"};
24
26
  }
25
27
 
26
- ${n && c`
28
+ ${o && m`
27
29
  .Mui-disabled {
28
30
  color: inherit !important;
29
31
  -webkit-text-fill-color: inherit !important;
@@ -33,36 +35,34 @@ const x = h("div")(({ grid: r, displayMode: n }) => ({
33
35
  }
34
36
  `}
35
37
  `
36
- })), L = ({
37
- label: r,
38
- grid: n = !0,
39
- displayMode: m = !1,
40
- noLabel: u = !1,
41
- onChange: i,
42
- defaultValue: o,
43
- ...f
38
+ })), B = ({
39
+ label: n,
40
+ grid: o = !0,
41
+ displayMode: f = !1,
42
+ noLabel: d = !1,
43
+ onChange: a,
44
+ defaultValue: g,
45
+ ...s
44
46
  }) => {
45
- let e = (o == null ? void 0 : o.replace(/[^0-9.-]+/g, "")) ?? "";
46
- e && (e = new Intl.NumberFormat("en-US", {
47
- style: "decimal",
48
- maximumFractionDigits: 2
49
- }).format(Number(e)));
50
- const [d, a] = b(e);
51
- return /* @__PURE__ */ l(x, { ...{ grid: n, displayMode: m }, className: "jcLabeledCurrencyInput", children: [
52
- !u && /* @__PURE__ */ l("span", { children: [
53
- r,
47
+ const p = String(g ?? s.value ?? "");
48
+ let l = p.replace(/[^0-9.-]+/g, "");
49
+ l && (l = C(p)[0]);
50
+ const [y, t] = w(l);
51
+ return /* @__PURE__ */ c(V, { ...{ grid: o, displayMode: f }, className: "jcLabeledCurrencyInput", children: [
52
+ !d && /* @__PURE__ */ c("span", { children: [
53
+ n,
54
54
  ":"
55
55
  ] }),
56
- /* @__PURE__ */ y(w, { ...f, onChange: (s) => {
57
- const { value: g } = s.target, t = g.replace(/[^0-9.-]+/g, ""), p = new Intl.NumberFormat("en-US", {
56
+ /* @__PURE__ */ b(I, { ...s, onChange: (u) => {
57
+ const { value: h } = u.target, e = h.replace(/[^0-9.-]+/g, ""), i = e.includes(".") ? e.split(".")[0] + "." + e.split(".")[1].slice(0, 2) : e, r = new Intl.NumberFormat("en-US", {
58
58
  style: "decimal",
59
59
  maximumFractionDigits: 2
60
- }).format(Number(t) || 0);
61
- t && t.length > 1 && t[t.length - 1] === "." ? a(p + ".") : a(t ? p : ""), i && i(s);
62
- }, value: `$${d}` })
60
+ }).format(Number(i) || 0);
61
+ e && e.length > 1 && e[e.length - 1] === "." ? t(r + ".") : e && e.length > 1 && i.includes(".0") || r.includes(".") ? t(r.split(".")[0] + "." + i.split(".")[1]) : t(e ? r : ""), a && a(u);
62
+ }, value: `$${y}` })
63
63
  ] });
64
64
  };
65
65
  export {
66
- L as LabeledCurrencyInput,
67
- L as default
66
+ B as LabeledCurrencyInput,
67
+ B as default
68
68
  };
@@ -7,6 +7,8 @@ export type LabeledInputProps = InputProps & StyleProps & {
7
7
  label?: string;
8
8
  noLabel?: boolean;
9
9
  limit?: number;
10
+ minLimit?: number;
11
+ maxLimit?: number;
10
12
  };
11
13
  export declare const LabeledInput: React.FC<LabeledInputProps>;
12
14
  export default LabeledInput;
@@ -1,42 +1,44 @@
1
1
  import { jsxs as s, jsx as t } from "react/jsx-runtime";
2
2
  import { cn as r } from "../cn.js";
3
- import { Input as u } from "../Input/Input.js";
4
- import p from "../theme.js";
5
- const c = "flex flex-nowrap gap-[9px] font-['Roboto',sans-serif]", b = "[&_span]:whitespace-nowrap [&_span]:font-bold", m = "[&_.required]:mx-[2px] [&_.required]:text-[var(--required-color)]", f = "[&_.MuiTextField-root]:flex-grow", x = "[&_.MuiInputBase-root]:width-[var(--input-base-width)]", h = "[&_.Mui-disabled]:!cursor-default [&_.Mui-disabled]:!color-inherit [&_.Mui-disabled]:!-webkit-text-fill-color-inherit [&_.Mui-disabled]:!background-transparent [&_.Mui-disabled]:!opacity-100", _ = r(
6
- c,
3
+ import { Input as c } from "../Input/Input.js";
4
+ import m from "../theme.js";
5
+ const b = "flex flex-nowrap gap-[9px] font-['Roboto',sans-serif]", f = "[&_span]:whitespace-nowrap [&_span]:font-bold", x = "[&_.required]:mx-[2px] [&_.required]:text-[var(--required-color)]", h = "[&_.MuiTextField-root]:flex-grow", _ = "[&_.MuiInputBase-root]:width-[var(--input-base-width)]", w = "[&_.Mui-disabled]:!cursor-default [&_.Mui-disabled]:!color-inherit [&_.Mui-disabled]:!-webkit-text-fill-color-inherit [&_.Mui-disabled]:!background-transparent [&_.Mui-disabled]:!opacity-100", q = r(
7
6
  b,
8
- m,
9
7
  f,
10
- x
11
- ), M = ({
8
+ x,
9
+ h,
10
+ _
11
+ ), y = ({
12
12
  label: o,
13
13
  grid: a = !0,
14
14
  displayMode: i = !1,
15
15
  noLabel: l = !1,
16
16
  limit: n,
17
+ minLimit: d,
18
+ maxLimit: u,
17
19
  ...e
18
20
  }) => {
19
- const d = {
20
- "--required-color": p.colors.gray,
21
+ const p = {
22
+ "--required-color": m.colors.gray,
21
23
  "--input-base-width": a ? "100%" : "auto"
22
24
  };
23
25
  return /* @__PURE__ */ s(
24
26
  "div",
25
27
  {
26
- className: r("jcLabeledInput", _, i && h),
27
- style: d,
28
+ className: r("jcLabeledInput", q, i && w),
29
+ style: p,
28
30
  children: [
29
31
  !l && /* @__PURE__ */ s("span", { children: [
30
32
  o,
31
33
  e.required && /* @__PURE__ */ t("span", { className: "required", children: "*" }),
32
34
  ":"
33
35
  ] }),
34
- /* @__PURE__ */ t(u, { ...e, slotProps: { htmlInput: { limit: n } } })
36
+ /* @__PURE__ */ t(c, { ...e, slotProps: { htmlInput: { limit: n, min: d, max: u } } })
35
37
  ]
36
38
  }
37
39
  );
38
40
  };
39
41
  export {
40
- M as LabeledInput,
41
- M as default
42
+ y as LabeledInput,
43
+ y as default
42
44
  };