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.
@@ -1,74 +1,82 @@
1
- import { jsx as N } from "react/jsx-runtime";
2
- import { createContext as w, useState as E, useEffect as P, useMemo as $ } from "react";
3
- import { formatPhoneNumber as C } from "../utils.js";
4
- function I(b) {
5
- const { name: n, defaultValues: s = {}, onInputChangeExtensions: u = [], submit: m, debug: a = !1 } = b, i = w({
6
- onFormInputChange: () => console.error(`Failed to update form input. ${n}FormContext not initialized`),
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. ${n}FormContext not initialized`),
9
- resetForm: () => console.error(`Failed to reset form. ${n}FormContext not initialized`)
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: i, Provider: ({ children: x }) => {
12
- const [e, r] = E(s), d = (g, t, c) => {
13
- r((l) => {
14
- let o;
15
- if (c === "checkbox")
16
- o = t.target.checked;
17
- else if (c === "multiDropdown") {
18
- const h = t.target.value;
19
- Array.isArray(h) ? o = h.map((D) => D.value) : o = [];
20
- } else if (c === "phone") {
21
- const [, h] = C(t.target.value);
22
- o = h;
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
- o = t.target.value;
25
- return o === "undefined" && (o = void 0), { ...l, [g]: o };
26
- });
27
- let p;
28
- if (c === "checkbox")
29
- p = t.target.checked;
30
- else if (c === "phone") {
31
- const [, l] = C(t.target.value);
32
- p = l;
33
- } else
34
- p = t.target.value === "undefined" ? void 0 : t.target.value;
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: e,
46
- setFormData: r,
47
- resetForm: v,
48
- ...m ? { submit: () => m(e) } : {}
48
+ formData: t,
49
+ setFormData: l,
50
+ resetForm: p,
51
+ ...o ? { submit: () => o(t) } : {}
49
52
  }),
50
- [e]
53
+ [t, d, p, o]
51
54
  );
52
- return /* @__PURE__ */ N(i.Provider, { value: f, children: x });
55
+ return /* @__PURE__ */ w(c.Provider, { value: h, children: F });
53
56
  } };
54
57
  }
55
- function M(b = "dateOfBirth", n = "age") {
56
- return (s, u, m) => {
57
- if (s === b && u && typeof u == "string") {
58
- const a = u.split("-");
59
- if (a.length !== 3) return;
60
- const i = Number(a[0]), F = Number(a[1]), x = Number(a[2]), e = /* @__PURE__ */ new Date(), r = e.getFullYear(), d = e.getMonth() + 1, v = e.getDate();
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
- let f = r - i;
64
- (F > d || F === d && x > v) && (f -= 1), m((g) => ({
65
- ...g,
66
- [n]: String(f)
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
- M as createDobToAgeExtension,
73
- I as createFormContext
80
+ S as createDobToAgeExtension,
81
+ M as createFormContext
74
82
  };
package/Pill/Pill.js CHANGED
@@ -1,9 +1,9 @@
1
- import { jsx as s } from "react/jsx-runtime";
2
- import { n as i } from "../.chunks/emotion-styled.browser.esm.js";
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 a = i("span")(
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: c, type: m = "primary", squared: l = !1, children: n } = e;
21
- return m == "secondary" ? /* @__PURE__ */ s(
22
- a,
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: c || o.themeIconColorB,
26
- squared: l,
27
- children: n
25
+ textColor: l || o.themeIconColorB,
26
+ squared: c,
27
+ className: "jciclPillWrapper",
28
+ children: s
28
29
  }
29
- ) : /* @__PURE__ */ s(
30
- a,
30
+ ) : /* @__PURE__ */ a(
31
+ n,
31
32
  {
32
33
  backgroundColor: r || o.themeIconBackgroundA,
33
- textColor: c,
34
- squared: l,
34
+ textColor: l,
35
+ squared: c,
35
36
  className: "jciclPillWrapper",
36
- children: n
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.31",
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",