jcicl 1.0.31 → 1.0.33
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/FormContext/createFormContext.js +67 -59
- package/Pill/Pill.js +15 -14
- package/package.json +1 -1
|
@@ -1,74 +1,82 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { formatPhoneNumber as
|
|
4
|
-
function
|
|
5
|
-
const { name:
|
|
6
|
-
onFormInputChange: () => console.error(`Failed to update form input. ${
|
|
1
|
+
import { jsx as w } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as E, useState as P, useCallback as C, useEffect as $, useMemo as k } from "react";
|
|
3
|
+
import { formatPhoneNumber as D } from "../utils.js";
|
|
4
|
+
function M(g) {
|
|
5
|
+
const { name: e, defaultValues: s = {}, onInputChangeExtensions: u = [], submit: o, debug: r = !1 } = g, c = E({
|
|
6
|
+
onFormInputChange: () => console.error(`Failed to update form input. ${e}FormContext not initialized`),
|
|
7
7
|
formData: s,
|
|
8
|
-
setFormData: () => console.error(`Failed to set form data. ${
|
|
9
|
-
resetForm: () => console.error(`Failed to reset form. ${
|
|
8
|
+
setFormData: () => console.error(`Failed to set form data. ${e}FormContext not initialized`),
|
|
9
|
+
resetForm: () => console.error(`Failed to reset form. ${e}FormContext not initialized`)
|
|
10
10
|
});
|
|
11
|
-
return { Context:
|
|
12
|
-
const [
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
11
|
+
return { Context: c, Provider: ({ children: F }) => {
|
|
12
|
+
const [t, l] = P(s), d = C(
|
|
13
|
+
(n, a, f) => {
|
|
14
|
+
l((m) => {
|
|
15
|
+
let i;
|
|
16
|
+
if (f === "checkbox")
|
|
17
|
+
i = a.target.checked;
|
|
18
|
+
else if (f === "multiDropdown") {
|
|
19
|
+
const v = a.target.value;
|
|
20
|
+
Array.isArray(v) ? i = v.map((N) => N.value) : i = [];
|
|
21
|
+
} else if (f === "phone") {
|
|
22
|
+
const [, v] = D(a.target.value);
|
|
23
|
+
i = v;
|
|
24
|
+
} else
|
|
25
|
+
i = a.target.value;
|
|
26
|
+
return i === "undefined" && (i = void 0), { ...m, [n]: i };
|
|
27
|
+
});
|
|
28
|
+
let b;
|
|
29
|
+
if (f === "checkbox")
|
|
30
|
+
b = a.target.checked;
|
|
31
|
+
else if (f === "phone") {
|
|
32
|
+
const [, m] = D(a.target.value);
|
|
33
|
+
b = m;
|
|
23
34
|
} else
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
u.forEach((l) => {
|
|
36
|
-
l(g, p, r);
|
|
37
|
-
});
|
|
38
|
-
}, v = () => r(s);
|
|
39
|
-
P(() => {
|
|
40
|
-
a && console.log(`[${n}Form] Updated form data:`, e);
|
|
41
|
-
}, [e]);
|
|
42
|
-
const f = $(
|
|
35
|
+
b = a.target.value === "undefined" ? void 0 : a.target.value;
|
|
36
|
+
u.forEach((m) => {
|
|
37
|
+
m(n, b, l);
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
[u]
|
|
41
|
+
), p = C(() => l(s), [s]);
|
|
42
|
+
$(() => {
|
|
43
|
+
r && console.log(`[${e}Form] Updated form data:`, t);
|
|
44
|
+
}, [t]);
|
|
45
|
+
const h = k(
|
|
43
46
|
() => ({
|
|
44
47
|
onFormInputChange: d,
|
|
45
|
-
formData:
|
|
46
|
-
setFormData:
|
|
47
|
-
resetForm:
|
|
48
|
-
...
|
|
48
|
+
formData: t,
|
|
49
|
+
setFormData: l,
|
|
50
|
+
resetForm: p,
|
|
51
|
+
...o ? { submit: () => o(t) } : {}
|
|
49
52
|
}),
|
|
50
|
-
[
|
|
53
|
+
[t, d, p, o]
|
|
51
54
|
);
|
|
52
|
-
return /* @__PURE__ */
|
|
55
|
+
return /* @__PURE__ */ w(c.Provider, { value: h, children: F });
|
|
53
56
|
} };
|
|
54
57
|
}
|
|
55
|
-
function
|
|
56
|
-
return (s, u,
|
|
57
|
-
if (s ===
|
|
58
|
-
const
|
|
59
|
-
if (
|
|
60
|
-
|
|
61
|
-
if (i > r || i < 1900)
|
|
58
|
+
function S(g = "dateOfBirth", e = "age") {
|
|
59
|
+
return (s, u, o) => {
|
|
60
|
+
if (s === g && u && typeof u == "string") {
|
|
61
|
+
const r = u.split("-");
|
|
62
|
+
if (r.length !== 3) {
|
|
63
|
+
o((n) => ({ ...n, [e]: void 0 }));
|
|
62
64
|
return;
|
|
63
|
-
|
|
64
|
-
(
|
|
65
|
-
|
|
66
|
-
[
|
|
65
|
+
}
|
|
66
|
+
const c = Number(r[0]), x = Number(r[1]), F = Number(r[2]), t = /* @__PURE__ */ new Date(), l = t.getFullYear(), d = t.getMonth() + 1, p = t.getDate();
|
|
67
|
+
if (c > l || c < 1900) {
|
|
68
|
+
o((n) => ({ ...n, [e]: void 0 }));
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
let h = l - c;
|
|
72
|
+
(x > d || x === d && F > p) && (h -= 1), o((n) => ({
|
|
73
|
+
...n,
|
|
74
|
+
[e]: String(h)
|
|
67
75
|
}));
|
|
68
|
-
}
|
|
76
|
+
} else s === g && o((r) => ({ ...r, [e]: void 0 }));
|
|
69
77
|
};
|
|
70
78
|
}
|
|
71
79
|
export {
|
|
72
|
-
|
|
73
|
-
|
|
80
|
+
S as createDobToAgeExtension,
|
|
81
|
+
M as createFormContext
|
|
74
82
|
};
|
package/Pill/Pill.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { n as
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { n as m } from "../.chunks/emotion-styled.browser.esm.js";
|
|
3
3
|
import { c as p } from "../.chunks/emotion-react.browser.esm.js";
|
|
4
4
|
import t from "../theme.js";
|
|
5
5
|
import { useThemeColors as d } from "../ThemeContext.js";
|
|
6
|
-
const
|
|
6
|
+
const n = m("span")(
|
|
7
7
|
({ backgroundColor: e = t.colors.whiteGreen, textColor: o = t.colors.white, squared: r = !1 }) => ({
|
|
8
8
|
...p`
|
|
9
9
|
font-family: ${t.fonts.roboto};
|
|
@@ -17,23 +17,24 @@ const a = i("span")(
|
|
|
17
17
|
`
|
|
18
18
|
})
|
|
19
19
|
), C = (e) => {
|
|
20
|
-
const o = d(), { backgroundColor: r, textColor:
|
|
21
|
-
return
|
|
22
|
-
|
|
20
|
+
const o = d(), { backgroundColor: r, textColor: l, type: i = "primary", squared: c = !1, children: s } = e;
|
|
21
|
+
return i == "secondary" ? /* @__PURE__ */ a(
|
|
22
|
+
n,
|
|
23
23
|
{
|
|
24
24
|
backgroundColor: r || o.themeIconBackgroundB,
|
|
25
|
-
textColor:
|
|
26
|
-
squared:
|
|
27
|
-
|
|
25
|
+
textColor: l || o.themeIconColorB,
|
|
26
|
+
squared: c,
|
|
27
|
+
className: "jciclPillWrapper",
|
|
28
|
+
children: s
|
|
28
29
|
}
|
|
29
|
-
) : /* @__PURE__ */
|
|
30
|
-
|
|
30
|
+
) : /* @__PURE__ */ a(
|
|
31
|
+
n,
|
|
31
32
|
{
|
|
32
33
|
backgroundColor: r || o.themeIconBackgroundA,
|
|
33
|
-
textColor:
|
|
34
|
-
squared:
|
|
34
|
+
textColor: l,
|
|
35
|
+
squared: c,
|
|
35
36
|
className: "jciclPillWrapper",
|
|
36
|
-
children:
|
|
37
|
+
children: s
|
|
37
38
|
}
|
|
38
39
|
);
|
|
39
40
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jcicl",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.33",
|
|
5
5
|
"description": "Component library for the websites of Johnson County Iowa",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://devops.jc.net/JCIT/Business%20Solutions%20Delivery/_git/JCComponentLibrary?path=%2FREADME.md&version=GBmaster",
|