jcicl 1.1.4 → 1.2.1
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.
- package/Button/Button.d.ts +1 -0
- package/Button/Button.js +73 -70
- package/DesktopStepper/DesktopStepper.d.ts +24 -0
- package/DesktopStepper/DesktopStepper.js +204 -0
- package/DesktopStepper/index.d.ts +1 -0
- package/DesktopStepper/index.js +5 -0
- package/FieldGroup/FieldGroup.js +15 -12
- package/FieldVisibilityWrapper/FieldVisibilityWrapper.d.ts +11 -0
- package/FieldVisibilityWrapper/FieldVisibilityWrapper.js +48 -0
- package/FieldVisibilityWrapper/index.d.ts +1 -0
- package/FieldVisibilityWrapper/index.js +4 -0
- package/FormContext/createFormContext.js +91 -72
- package/FormContext/types.d.ts +8 -0
- package/FormFields/FormFields.d.ts +2 -2
- package/FormFields/FormFields.js +20 -20
- package/FormInput/FormInput.d.ts +4 -0
- package/FormInput/FormInput.js +39 -14
- package/LabeledCheckbox/LabeledCheckbox.js +4 -4
- package/LabeledCurrencyInput/LabeledCurrencyInput.js +33 -33
- package/LabeledInput/LabeledInput.d.ts +2 -0
- package/LabeledInput/LabeledInput.js +16 -14
- package/LabeledRadio/LabeledRadio.js +12 -12
- package/ScrollContainer/ScrollContainer.js +721 -704
- package/SelectableItemCard/SelectableItemCard.d.ts +9 -0
- package/SelectableItemCard/SelectableItemCard.js +24 -0
- package/SelectableItemCard/index.d.ts +1 -0
- package/SelectableItemCard/index.js +4 -0
- package/Stepper/Stepper.js +184 -226
- package/api.d.ts +16 -5
- package/api.js +42 -28
- package/assets/style.css +1 -1
- package/assets/tailwind.css +2 -2
- package/constants.js +1 -1
- package/formatters.d.ts +1 -0
- package/formatters.js +30 -17
- package/package.json +1 -1
- package/problemDetails.d.ts +20 -0
- package/problemDetails.js +19 -0
- package/utils.d.ts +2 -2
- package/utils.js +35 -29
- package/validators.d.ts +8 -0
- package/validators.js +19 -9
|
@@ -1,96 +1,115 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
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
|
|
5
|
-
import { formatPhoneNumber as
|
|
6
|
-
function
|
|
7
|
-
const { name:
|
|
8
|
-
onFormInputChange: () =>
|
|
9
|
-
formData:
|
|
10
|
-
setFormData: () =>
|
|
11
|
-
resetForm: () =>
|
|
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:
|
|
14
|
-
const [
|
|
15
|
-
(
|
|
16
|
-
|
|
17
|
-
let
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
else if (
|
|
21
|
-
const
|
|
22
|
-
Array.isArray(
|
|
23
|
-
} else if (
|
|
24
|
-
const [,
|
|
25
|
-
|
|
26
|
-
} else if (
|
|
27
|
-
const [,
|
|
28
|
-
|
|
29
|
-
} else if (
|
|
30
|
-
const [,
|
|
31
|
-
|
|
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
|
-
|
|
34
|
-
return
|
|
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
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
else if (
|
|
40
|
-
const [,
|
|
41
|
-
|
|
42
|
-
} else if (
|
|
43
|
-
const [,
|
|
44
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
),
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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:
|
|
61
|
-
formData:
|
|
62
|
-
setFormData:
|
|
63
|
-
resetForm:
|
|
64
|
-
|
|
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
|
|
67
|
-
[
|
|
85
|
+
// submit is factory-closure-stable; only formData/fieldErrors and the memoized callbacks change.
|
|
86
|
+
[s, g, b, l]
|
|
68
87
|
);
|
|
69
|
-
return /* @__PURE__ */
|
|
88
|
+
return /* @__PURE__ */ I(m.Provider, { value: P, children: N });
|
|
70
89
|
} };
|
|
71
90
|
}
|
|
72
|
-
function
|
|
73
|
-
return (
|
|
74
|
-
if (
|
|
75
|
-
const
|
|
76
|
-
if (
|
|
77
|
-
|
|
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
|
|
81
|
-
if (
|
|
82
|
-
|
|
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 =
|
|
86
|
-
(
|
|
87
|
-
...
|
|
88
|
-
[
|
|
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
|
|
109
|
+
} else f === F && u((a) => ({ ...a, [n]: void 0 }));
|
|
91
110
|
};
|
|
92
111
|
}
|
|
93
112
|
export {
|
|
94
|
-
|
|
95
|
-
|
|
113
|
+
U as createDobToAgeExtension,
|
|
114
|
+
T as createFormContext
|
|
96
115
|
};
|
package/FormContext/types.d.ts
CHANGED
|
@@ -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[];
|
package/FormFields/FormFields.js
CHANGED
|
@@ -4,16 +4,17 @@ 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
|
|
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";
|
|
11
11
|
import "../LabeledValue/LabeledValue.js";
|
|
12
12
|
import "../ListButton/ListButton.js";
|
|
13
13
|
import "../Loading/Loading.js";
|
|
14
|
-
import "../ScrollContainer/ScrollContainer.js";
|
|
15
14
|
import "react";
|
|
16
|
-
import
|
|
15
|
+
import "../ScrollContainer/ScrollContainer.js";
|
|
16
|
+
import "../ThemeContext.js";
|
|
17
|
+
import { useIsTablet as S } from "../utils.js";
|
|
17
18
|
import "../CustomAlert/CustomAlert.js";
|
|
18
19
|
import "react-dom";
|
|
19
20
|
import "../Accordion/Accordion.js";
|
|
@@ -28,7 +29,6 @@ import "../WithLabel/WithLabel.js";
|
|
|
28
29
|
import "../WithLoading/WithLoading.js";
|
|
29
30
|
import "../RecordCard/RecordCard.js";
|
|
30
31
|
import "../theme.js";
|
|
31
|
-
import "../ThemeContext.js";
|
|
32
32
|
import "../DetailPageComponents/DetailPageComponents.js";
|
|
33
33
|
import "../Toast/Toast.js";
|
|
34
34
|
import "../.chunks/AppHeader.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:
|
|
42
|
-
fields:
|
|
43
|
-
columns:
|
|
44
|
-
columnsOverride:
|
|
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:
|
|
49
|
+
formDefaults: n,
|
|
50
50
|
onChange: d
|
|
51
51
|
}) => {
|
|
52
|
-
const D =
|
|
52
|
+
const D = S();
|
|
53
53
|
return /* @__PURE__ */ b(T, { children: [
|
|
54
|
-
|
|
55
|
-
!F && /* @__PURE__ */ m(j, { columns:
|
|
56
|
-
const i =
|
|
57
|
-
return v ? /* @__PURE__ */ b(
|
|
58
|
-
/* @__PURE__ */ m(I, { children:
|
|
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:
|
|
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:
|
|
89
|
-
const i =
|
|
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:
|
|
94
|
+
label: l,
|
|
95
95
|
type: o,
|
|
96
96
|
limit: c,
|
|
97
|
-
...o === "checkbox" ? { checked: !!i } : {
|
|
97
|
+
...o === "checkbox" ? { checked: !!i } : { value: i },
|
|
98
98
|
noLabel: x,
|
|
99
99
|
options: e,
|
|
100
100
|
multiple: o === "multiDropdown",
|
package/FormInput/FormInput.d.ts
CHANGED
|
@@ -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;
|
package/FormInput/FormInput.js
CHANGED
|
@@ -1,17 +1,42 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
16
|
-
|
|
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
|
|
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
|
|
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 =
|
|
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
|
|
2
|
-
import { useState as
|
|
3
|
-
import { n as
|
|
4
|
-
import { c } from "../.chunks/emotion-react.browser.esm.js";
|
|
5
|
-
import { Input as
|
|
6
|
-
|
|
7
|
-
|
|
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: ${
|
|
25
|
+
width: ${n && "100%"};
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
${
|
|
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
|
-
})),
|
|
37
|
-
label:
|
|
38
|
-
grid:
|
|
39
|
-
displayMode:
|
|
40
|
-
noLabel:
|
|
41
|
-
onChange:
|
|
42
|
-
defaultValue:
|
|
43
|
-
...
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
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__ */
|
|
57
|
-
const { value:
|
|
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(
|
|
61
|
-
|
|
62
|
-
}, value: `$${
|
|
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
|
-
|
|
67
|
-
|
|
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
|
|
4
|
-
import
|
|
5
|
-
const
|
|
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
|
-
|
|
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
|
|
20
|
-
"--required-color":
|
|
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",
|
|
27
|
-
style:
|
|
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(
|
|
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
|
-
|
|
41
|
-
|
|
42
|
+
y as LabeledInput,
|
|
43
|
+
y as default
|
|
42
44
|
};
|