jcicl 1.0.76 → 1.0.78

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 (76) hide show
  1. package/.chunks/Button.js +7 -6
  2. package/.chunks/ButtonBase.js +2 -1
  3. package/.chunks/CircularProgress.js +9 -8
  4. package/.chunks/DefaultPropsProvider.js +322 -336
  5. package/.chunks/Paper.js +6 -5
  6. package/.chunks/Popper.js +1 -1
  7. package/.chunks/Portal.js +13 -13
  8. package/.chunks/SwitchBase.js +14 -13
  9. package/.chunks/TextField.js +2 -1
  10. package/.chunks/clsx.js +16 -0
  11. package/.chunks/createSvgIcon.js +14 -13
  12. package/.chunks/eye.js +45 -0
  13. package/.chunks/index.js +19 -18
  14. package/AppContainer/AppContainer.js +323 -319
  15. package/Button/Button.js +80 -82
  16. package/Divider/Divider.js +13 -12
  17. package/EditableDetailItemWithIcon/EditableDetailItemWithIcon.d.ts +3 -2
  18. package/EditableDetailItemWithIcon/EditableDetailItemWithIcon.js +39 -39
  19. package/EditableInfoCard/EditableInfoCard.d.ts +1 -1
  20. package/EditableInfoCard/EditableInfoCard.js +25 -25
  21. package/ErrorBoundary/ErrorBoundary.d.ts +5 -5
  22. package/ErrorBoundary/ErrorBoundary.js +21 -19
  23. package/FormComponents/FormComponents.d.ts +1 -2
  24. package/FormContext/createFormContext.js +70 -62
  25. package/FormFields/FormFields.d.ts +1 -1
  26. package/FormFields/FormFields.js +31 -31
  27. package/FormInput/FormInput.d.ts +5 -3
  28. package/FormInput/FormInput.js +10 -8
  29. package/Input/Input.d.ts +6 -1
  30. package/Input/Input.js +35 -100
  31. package/LabeledCheckbox/LabeledCheckbox.js +7 -6
  32. package/LabeledDropdown/LabeledDropdown.d.ts +3 -0
  33. package/LabeledDropdown/LabeledDropdown.js +720 -795
  34. package/LabeledFormattedInput/LabeledFormattedInput.d.ts +23 -0
  35. package/LabeledFormattedInput/LabeledFormattedInput.js +95 -0
  36. package/LabeledFormattedInput/index.d.ts +1 -0
  37. package/LabeledFormattedInput/index.js +4 -0
  38. package/LabeledInput/LabeledInput.js +39 -51
  39. package/LabeledRadio/LabeledRadio.js +7 -6
  40. package/Memo/Memo.js +6 -5
  41. package/Nav/Nav.d.ts +1 -1
  42. package/Pagination/Pagination.d.ts +1 -2
  43. package/Pagination/Pagination.js +25 -24
  44. package/README.md +11 -6
  45. package/Stepper/Stepper.js +4 -3
  46. package/Table/Table.d.ts +7 -5
  47. package/Table/Table.js +5575 -5633
  48. package/Timer/Timer.js +26 -26
  49. package/Toast/Toaster.js +9 -9
  50. package/Tooltip/Tooltip.js +5 -4
  51. package/WelcomeCard/WelcomeCard.d.ts +1 -5
  52. package/WelcomeCard/WelcomeCard.js +45 -101
  53. package/assets/style.css +1 -1
  54. package/assets/tailwind.css +2 -2
  55. package/cn.d.ts +2 -0
  56. package/cn.js +2990 -0
  57. package/constants.d.ts +6 -0
  58. package/constants.js +55 -0
  59. package/cursorPositioning.d.ts +7 -0
  60. package/cursorPositioning.js +13 -0
  61. package/formatters.d.ts +17 -0
  62. package/formatters.js +83 -0
  63. package/inputTypes.d.ts +1 -0
  64. package/inputTypes.js +1 -0
  65. package/logger.d.ts +13 -0
  66. package/logger.js +9 -0
  67. package/maskers.d.ts +6 -0
  68. package/maskers.js +15 -0
  69. package/package.json +2 -1
  70. package/theme.d.ts +1 -0
  71. package/theme.js +9 -8
  72. package/themeUtils.js +58 -79
  73. package/utils.d.ts +8 -18
  74. package/utils.js +39 -89
  75. package/validators.d.ts +5 -0
  76. package/validators.js +12 -0
package/constants.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export declare const states: {
2
+ label: string;
3
+ value: string;
4
+ abbreviation: string;
5
+ number: number;
6
+ }[];
package/constants.js ADDED
@@ -0,0 +1,55 @@
1
+ const a = [
2
+ { label: "Alabama", value: "Alabama", abbreviation: "AL", number: 1 },
3
+ { label: "Alaska", value: "Alaska", abbreviation: "AK", number: 2 },
4
+ { label: "Arizona", value: "Arizona", abbreviation: "AZ", number: 3 },
5
+ { label: "Arkansas", value: "Arkansas", abbreviation: "AR", number: 4 },
6
+ { label: "California", value: "California", abbreviation: "CA", number: 5 },
7
+ { label: "Colorado", value: "Colorado", abbreviation: "CO", number: 6 },
8
+ { label: "Connecticut", value: "Connecticut", abbreviation: "CT", number: 7 },
9
+ { label: "Delaware", value: "Delaware", abbreviation: "DE", number: 8 },
10
+ { label: "Florida", value: "Florida", abbreviation: "FL", number: 9 },
11
+ { label: "Georgia", value: "Georgia", abbreviation: "GA", number: 10 },
12
+ { label: "Hawaii", value: "Hawaii", abbreviation: "HI", number: 11 },
13
+ { label: "Idaho", value: "Idaho", abbreviation: "ID", number: 12 },
14
+ { label: "Illinois", value: "Illinois", abbreviation: "IL", number: 13 },
15
+ { label: "Indiana", value: "Indiana", abbreviation: "IN", number: 14 },
16
+ { label: "Iowa", value: "Iowa", abbreviation: "IA", number: 15 },
17
+ { label: "Kansas", value: "Kansas", abbreviation: "KS", number: 16 },
18
+ { label: "Kentucky", value: "Kentucky", abbreviation: "KY", number: 17 },
19
+ { label: "Louisiana", value: "Louisiana", abbreviation: "LA", number: 18 },
20
+ { label: "Maine", value: "Maine", abbreviation: "ME", number: 19 },
21
+ { label: "Maryland", value: "Maryland", abbreviation: "MD", number: 20 },
22
+ { label: "Massachusetts", value: "Massachusetts", abbreviation: "MA", number: 21 },
23
+ { label: "Michigan", value: "Michigan", abbreviation: "MI", number: 22 },
24
+ { label: "Minnesota", value: "Minnesota", abbreviation: "MN", number: 23 },
25
+ { label: "Mississippi", value: "Mississippi", abbreviation: "MS", number: 24 },
26
+ { label: "Missouri", value: "Missouri", abbreviation: "MO", number: 25 },
27
+ { label: "Montana", value: "Montana", abbreviation: "MT", number: 26 },
28
+ { label: "Nebraska", value: "Nebraska", abbreviation: "NE", number: 27 },
29
+ { label: "Nevada", value: "Nevada", abbreviation: "NV", number: 28 },
30
+ { label: "New Hampshire", value: "New Hampshire", abbreviation: "NH", number: 29 },
31
+ { label: "New Jersey", value: "New Jersey", abbreviation: "NJ", number: 30 },
32
+ { label: "New Mexico", value: "New Mexico", abbreviation: "NM", number: 31 },
33
+ { label: "New York", value: "New York", abbreviation: "NY", number: 32 },
34
+ { label: "North Carolina", value: "North Carolina", abbreviation: "NC", number: 33 },
35
+ { label: "North Dakota", value: "North Dakota", abbreviation: "ND", number: 34 },
36
+ { label: "Ohio", value: "Ohio", abbreviation: "OH", number: 35 },
37
+ { label: "Oklahoma", value: "Oklahoma", abbreviation: "OK", number: 36 },
38
+ { label: "Oregon", value: "Oregon", abbreviation: "OR", number: 37 },
39
+ { label: "Pennsylvania", value: "Pennsylvania", abbreviation: "PA", number: 38 },
40
+ { label: "Rhode Island", value: "Rhode Island", abbreviation: "RI", number: 39 },
41
+ { label: "South Carolina", value: "South Carolina", abbreviation: "SC", number: 40 },
42
+ { label: "South Dakota", value: "South Dakota", abbreviation: "SD", number: 41 },
43
+ { label: "Tennessee", value: "Tennessee", abbreviation: "TN", number: 42 },
44
+ { label: "Texas", value: "Texas", abbreviation: "TX", number: 43 },
45
+ { label: "Utah", value: "Utah", abbreviation: "UT", number: 44 },
46
+ { label: "Vermont", value: "Vermont", abbreviation: "VT", number: 45 },
47
+ { label: "Virginia", value: "Virginia", abbreviation: "VA", number: 46 },
48
+ { label: "Washington", value: "Washington", abbreviation: "WA", number: 47 },
49
+ { label: "West Virginia", value: "West Virginia", abbreviation: "WV", number: 48 },
50
+ { label: "Wisconsin", value: "Wisconsin", abbreviation: "WI", number: 49 },
51
+ { label: "Wyoming", value: "Wyoming", abbreviation: "WY", number: 50 }
52
+ ];
53
+ export {
54
+ a as states
55
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Given a formatted string and a digit-index (count of digits seen so far),
3
+ * return the cursor position that should be placed between digits in the
4
+ * formatted output. Used by formatted-input variants to preserve cursor
5
+ * position across re-formatting (e.g. typing into a phone-number mask).
6
+ */
7
+ export declare const findCursorFromDigitIndex: (formatted: string, digitIndex: number) => number;
@@ -0,0 +1,13 @@
1
+ const i = (r, n) => {
2
+ let t = 0;
3
+ for (let e = 0; e < r.length; e++)
4
+ if (/\d/.test(r[e])) {
5
+ if (n === 0) return e;
6
+ if (t++, t === n)
7
+ return e + 1;
8
+ }
9
+ return r.length;
10
+ };
11
+ export {
12
+ i as findCursorFromDigitIndex
13
+ };
@@ -0,0 +1,17 @@
1
+ import { FormInputType } from './inputTypes';
2
+ export declare const formatDate: (date: string, style?: "mmddyyyy") => string;
3
+ export declare const formatDateTime: (dateTime: string) => string;
4
+ export declare const formatAddress: (address: {
5
+ line1: string;
6
+ line2?: string | null;
7
+ city?: string | null;
8
+ state?: string | null;
9
+ zip?: string | null;
10
+ }) => string;
11
+ export declare const formatTimestamp: (timestamp: string) => string;
12
+ export declare const formatPhoneNumber: FormatterFunction;
13
+ export declare const formatZipCode: FormatterFunction;
14
+ export declare const formatSSN: FormatterFunction;
15
+ export type FormatterFunction = (value: string | undefined) => [string, string | undefined];
16
+ /** Formatters that are automatically applied to LabeledFormattedInput based on the type */
17
+ export declare const formattersByType: Partial<Record<FormInputType, FormatterFunction>>;
package/formatters.js ADDED
@@ -0,0 +1,83 @@
1
+ const D = (t, e = "mmddyyyy") => e === "mmddyyyy" ? (/* @__PURE__ */ new Date(t.replace(" ", "T").replace("Z", "") + "Z")).toLocaleDateString("en-US", {
2
+ timeZone: "America/Chicago",
3
+ month: "numeric",
4
+ day: "numeric",
5
+ year: "numeric"
6
+ }) : t, Z = (t) => {
7
+ try {
8
+ return (/* @__PURE__ */ new Date(t.replace(" ", "T").replace("Z", "") + "Z")).toLocaleString("en-US", {
9
+ timeZone: "America/Chicago",
10
+ month: "short",
11
+ day: "numeric",
12
+ year: "numeric",
13
+ hour: "numeric",
14
+ minute: "2-digit",
15
+ hour12: !0
16
+ });
17
+ } catch {
18
+ return t;
19
+ }
20
+ }, S = (t) => {
21
+ const { line1: e, line2: i, city: c, state: n, zip: o } = t;
22
+ let r = e || "";
23
+ return i && (r.length > 0 && (r += ", "), r += i), c && (r.length > 0 && (r += ", "), r += c), n && (r.length > 0 && (r += ", "), r += n), o && (r += ` ${a(o)[0]}`), r;
24
+ }, g = (t) => {
25
+ if (t > 3 && t < 21) return "th";
26
+ switch (t % 10) {
27
+ case 1:
28
+ return "st";
29
+ case 2:
30
+ return "nd";
31
+ case 3:
32
+ return "rd";
33
+ default:
34
+ return "th";
35
+ }
36
+ }, T = (t) => {
37
+ try {
38
+ const e = /* @__PURE__ */ new Date(t.replace(" ", "T").replace("Z", "") + "Z"), c = new Intl.DateTimeFormat("en-US", {
39
+ timeZone: "America/Chicago",
40
+ month: "short",
41
+ day: "numeric",
42
+ year: "numeric",
43
+ hour: "numeric",
44
+ minute: "2-digit",
45
+ hour12: !0
46
+ }).formatToParts(e), n = (h) => {
47
+ var s;
48
+ return ((s = c.find((y) => y.type === h)) == null ? void 0 : s.value) ?? "";
49
+ }, o = n("month") + ".", r = Number(n("day")), l = n("year"), u = n("hour"), m = n("minute"), f = n("dayPeriod").toLowerCase(), d = g(r);
50
+ return `${o} ${r}${d}, ${l}, ${u}:${m}${f}`;
51
+ } catch {
52
+ return t;
53
+ }
54
+ }, $ = (t) => {
55
+ if (t == null) return ["", void 0];
56
+ let e = t.replace(/\D/g, "") || "";
57
+ e.at(0) == "1" && (e = e.slice(1));
58
+ const i = e.slice(0, 3), c = e.slice(3, 6), n = e.slice(6, 10), o = e.slice(10, 16);
59
+ let r = e;
60
+ return e.length >= 4 && (r = `(${i}) ${e.slice(3)}`), e.length >= 7 && (r = `(${i}) ${c}-${e.slice(6)}`), e.length > 10 && (r = `(${i}) ${c}-${n} ext. ${o}`), [r, e.slice(0, 16)];
61
+ }, a = (t) => {
62
+ if (!t) return ["", void 0];
63
+ const e = t.replace(/\D/g, "");
64
+ return e.length <= 5 ? [e, e] : [`${e.slice(0, 5)}-${e.slice(5, 9)}`, e.slice(0, 9)];
65
+ }, p = (t) => {
66
+ if (!t) return ["", void 0];
67
+ const e = t.replace(/\D/g, "");
68
+ return e.length <= 3 ? [e, e] : e.length <= 5 ? [`${e.slice(0, 3)}-${e.slice(3)}`, e] : [`${e.slice(0, 3)}-${e.slice(3, 5)}-${e.slice(5, 9)}`, e.slice(0, 9)];
69
+ }, w = {
70
+ phone: $,
71
+ zip: a,
72
+ ssn: p
73
+ };
74
+ export {
75
+ S as formatAddress,
76
+ D as formatDate,
77
+ Z as formatDateTime,
78
+ $ as formatPhoneNumber,
79
+ p as formatSSN,
80
+ T as formatTimestamp,
81
+ a as formatZipCode,
82
+ w as formattersByType
83
+ };
@@ -0,0 +1 @@
1
+ export type FormInputType = 'checkbox' | 'currency' | 'date' | 'dropdown' | 'email' | 'multiDropdown' | 'number' | 'phone' | 'radio' | 'text' | 'textarea' | 'url' | 'zip' | 'ssn';
package/inputTypes.js ADDED
@@ -0,0 +1 @@
1
+
package/logger.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Lightweight logger for the library. Wraps `console.*` in a single place
3
+ * so the `no-console` ESLint rule can stay enforced at call sites; modules
4
+ * with legitimate logging needs import `logger` instead of calling `console`
5
+ * directly. Keep the surface minimal — add log levels, formatters, or
6
+ * transports only when there's a concrete need.
7
+ */
8
+ export declare const logger: {
9
+ error: (...args: unknown[]) => void;
10
+ warn: (...args: unknown[]) => void;
11
+ info: (...args: unknown[]) => void;
12
+ log: (...args: unknown[]) => void;
13
+ };
package/logger.js ADDED
@@ -0,0 +1,9 @@
1
+ const r = {
2
+ error: (...o) => console.error(...o),
3
+ warn: (...o) => console.warn(...o),
4
+ info: (...o) => console.info(...o),
5
+ log: (...o) => console.log(...o)
6
+ };
7
+ export {
8
+ r as logger
9
+ };
package/maskers.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { FormInputType } from './inputTypes';
2
+ export declare const maskSSN: MaskerFunction;
3
+ export declare const defaultMasker: MaskerFunction;
4
+ export type MaskerFunction = (value: string | undefined) => string;
5
+ /** Maskers that are automatically applied to LabeledFormattedInput based on the type when masked prop is true */
6
+ export declare const maskersByType: Partial<Record<FormInputType, MaskerFunction>>;
package/maskers.js ADDED
@@ -0,0 +1,15 @@
1
+ const r = (t) => {
2
+ const e = String(t ?? "").replace(/\D/g, "").slice(0, 9);
3
+ return e ? e.length <= 4 ? e : e.length < 9 ? `${"*".repeat(Math.max(0, e.length - 4))}${e.slice(-4)}` : `XXX-XX-${e.slice(-4)}` : "";
4
+ }, s = (t) => {
5
+ if (t == null) return "";
6
+ const e = String(t);
7
+ return "●".repeat(e.length);
8
+ }, a = {
9
+ ssn: r
10
+ };
11
+ export {
12
+ s as defaultMasker,
13
+ r as maskSSN,
14
+ a as maskersByType
15
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jcicl",
3
3
  "private": false,
4
- "version": "1.0.76",
4
+ "version": "1.0.78",
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",
@@ -30,6 +30,7 @@
30
30
  "lucide-react": "^0.525.0",
31
31
  "overlayscrollbars-react": "^0.5.6",
32
32
  "react-device-detect": "^2.2.3",
33
+ "tailwind-merge": "^3.6.0",
33
34
  "tailwindcss": "^4.2.2"
34
35
  }
35
36
  }
package/theme.d.ts CHANGED
@@ -17,6 +17,7 @@ export interface ThemeColors {
17
17
  darkGreenO99: string;
18
18
  darkRed: string;
19
19
  emerald: string;
20
+ error: string;
20
21
  gold: string;
21
22
  goldBrown: string;
22
23
  goldHover: string;
package/theme.js CHANGED
@@ -22,6 +22,7 @@ const e = {
22
22
  darkGreenO99: "#005c0099",
23
23
  darkRed: "#800000",
24
24
  emerald: "#004d24",
25
+ error: "#d32f2f",
25
26
  // formBorder: 'rgb(114,114,114)', // shouldn't need this anymore, same as gray: '#727272'
26
27
  gold: "#fab62d",
27
28
  goldBrown: "#85611b",
@@ -86,21 +87,21 @@ const e = {
86
87
  };
87
88
  e.boxShadows = {
88
89
  ...Object.fromEntries(
89
- Object.keys(e.colors).map((o) => [
90
- o,
91
- `0 0 8px -2px ${e.colors[o]}`
90
+ Object.keys(e.colors).map((r) => [
91
+ r,
92
+ `0 0 8px -2px ${e.colors[r]}`
92
93
  ])
93
94
  ),
94
95
  ...Object.fromEntries(
95
- Object.keys(e.colors).map((o) => [
96
- `${o}Thick`,
97
- `0 0 2px 1px ${e.colors[o]}`
96
+ Object.keys(e.colors).map((r) => [
97
+ `${r}Thick`,
98
+ `0 0 2px 1px ${e.colors[r]}`
98
99
  ])
99
100
  ),
100
101
  black63: "0px 0px 2px 1px rgba(0, 0, 0, 0.63)",
101
102
  gray63: "0px 0px 2px 1px rgba(100, 100, 100, 0.63)"
102
103
  };
103
- const r = {
104
+ const o = {
104
105
  themeColor: e.colors.green,
105
106
  themeDark: e.colors.darkGreen,
106
107
  themeMediumA: e.colors.mint,
@@ -140,5 +141,5 @@ const r = {
140
141
  };
141
142
  export {
142
143
  e as default,
143
- r as defaultTheme
144
+ o as defaultTheme
144
145
  };
package/themeUtils.js CHANGED
@@ -1,100 +1,79 @@
1
- import n, { defaultTheme as C } from "./theme.js";
2
- function a(o) {
1
+ import n, { defaultTheme as d } from "./theme.js";
2
+ function g(o) {
3
3
  const r = parseInt(o.substring(1, 3), 16), t = parseInt(o.substring(3, 5), 16), e = parseInt(o.substring(5, 7), 16);
4
4
  return [r, t, e];
5
5
  }
6
- function d(o, r, t) {
6
+ function a(o, r, t) {
7
7
  o /= 255, r /= 255, t /= 255;
8
- const e = Math.max(o, r, t), h = Math.min(o, r, t), c = (e + h) / 2;
9
- if (e === h)
10
- return [0, 0, c];
11
- const i = e - h;
12
- let l = c > 0.5 ? i / (2 - e - h) : i / (e + h), m;
13
- return e === o ? m = (r - t) / i + (r < t ? 6 : 0) : e === r ? m = (t - o) / i + 2 : m = (o - r) / i + 4, m /= 6, [m, l, c];
8
+ const e = Math.max(o, r, t), s = Math.min(o, r, t), h = (e + s) / 2;
9
+ if (e === s)
10
+ return [0, 0, h];
11
+ const i = e - s, l = h > 0.5 ? i / (2 - e - s) : i / (e + s);
12
+ let m;
13
+ return e === o ? m = (r - t) / i + (r < t ? 6 : 0) : e === r ? m = (t - o) / i + 2 : m = (o - r) / i + 4, m /= 6, [m, l, h];
14
14
  }
15
- function I(o, r, t) {
16
- let e, h, c;
15
+ function T(o, r, t) {
16
+ let e, s, h;
17
17
  if (r === 0)
18
- e = h = c = t;
18
+ e = s = h = t;
19
19
  else {
20
20
  const i = t < 0.5 ? t * (1 + r) : t + r - t * r, l = 2 * t - i;
21
- e = g(l, i, o + 1 / 3), h = g(l, i, o), c = g(l, i, o - 1 / 3);
21
+ e = u(l, i, o + 1 / 3), s = u(l, i, o), h = u(l, i, o - 1 / 3);
22
22
  }
23
- return [Math.round(e * 255), Math.round(h * 255), Math.round(c * 255)];
23
+ return [Math.round(e * 255), Math.round(s * 255), Math.round(h * 255)];
24
24
  }
25
- function g(o, r, t) {
25
+ function u(o, r, t) {
26
26
  return t < 0 && (t += 1), t > 1 && (t -= 1), t < 1 / 6 ? o + (r - o) * 6 * t : t < 1 / 2 ? r : t < 2 / 3 ? o + (r - o) * (2 / 3 - t) * 6 : o;
27
27
  }
28
- function T(o, r, t) {
29
- var e = o.toString(16).length == 1 ? "0" + o.toString(16) : o.toString(16), h = r.toString(16).length == 1 ? "0" + r.toString(16) : r.toString(16), c = t.toString(16).length == 1 ? "0" + t.toString(16) : t.toString(16);
30
- return "#" + e + h + c;
28
+ function w(o, r, t) {
29
+ const e = o.toString(16).length == 1 ? "0" + o.toString(16) : o.toString(16), s = r.toString(16).length == 1 ? "0" + r.toString(16) : r.toString(16), h = t.toString(16).length == 1 ? "0" + t.toString(16) : t.toString(16);
30
+ return "#" + e + s + h;
31
31
  }
32
- const k = (o) => {
33
- const [r, t, e] = a(o), [h, c, i] = d(r, t, e);
34
- return h;
35
- }, _ = (o) => {
36
- const [r, t, e] = a(o), [h, c, i] = d(r, t, e);
37
- return c;
38
- }, s = (o, r) => {
39
- const [t, e, h] = a(o), [c, i, l] = d(t, e, h);
40
- let m = i + 0.1;
41
- m >= 1 && (m = 0.99);
42
- let u = l;
43
- u > 0.5 && (u -= 0.08), u > 0.8 && (m = 1, u += 0.03), r < 0 && (m = 0);
44
- const [f, S, B] = I(r, m, u);
45
- return T(f, S, B);
46
- }, F = (o) => {
47
- const r = localStorage.getItem("theme") || "green", t = localStorage.getItem("hue") || k(n.themeOptions.green).toString();
48
- if (r == "green") return C;
49
- var e = parseFloat(t);
50
- o != null && (e = o);
51
- const {
52
- themeColor: h,
53
- themeDark: c,
54
- themeMediumA: i,
55
- themeMediumB: l,
56
- themeMediumC: m,
57
- themeLight: u,
58
- themeLightA: f,
59
- themeLightB: S,
60
- themeLightC: B,
61
- themeLightD: w,
62
- themeShadowA: A,
63
- themeShadowB: p,
64
- themeShadowC: M,
65
- themeIconBackgroundA: L,
66
- themeIconBackgroundB: b,
67
- themeIconColorA: x,
68
- themeIconColorB: v,
69
- ...G
70
- } = C;
71
- return {
72
- themeColor: s(n.colors.green, e),
73
- themeDark: s(n.colors.darkGreen, e),
74
- themeMediumA: s(n.colors.whiteGreenB, e),
32
+ const p = (o) => {
33
+ const [r, t, e] = g(o), [s] = a(r, t, e);
34
+ return s;
35
+ }, b = (o) => {
36
+ const [r, t, e] = g(o), [, s] = a(r, t, e);
37
+ return s;
38
+ }, c = (o, r) => {
39
+ const [t, e, s] = g(o), [, h, i] = a(t, e, s);
40
+ let l = h + 0.1;
41
+ l >= 1 && (l = 0.99);
42
+ let m = i;
43
+ m > 0.5 && (m -= 0.08), m > 0.8 && (l = 1, m += 0.03), r < 0 && (l = 0);
44
+ const [f, S, G] = T(r, l, m);
45
+ return w(f, S, G);
46
+ }, k = (o) => {
47
+ const r = localStorage.getItem("theme") || "green", t = localStorage.getItem("hue") || p(n.themeOptions.green).toString();
48
+ if (r == "green") return d;
49
+ let e = parseFloat(t);
50
+ return o != null && (e = o), {
51
+ ...d,
52
+ themeColor: c(n.colors.green, e),
53
+ themeDark: c(n.colors.darkGreen, e),
54
+ themeMediumA: c(n.colors.whiteGreenB, e),
75
55
  // mint
76
- themeMediumB: s(n.colors.moss, e),
77
- themeMediumC: s(n.colors.sage, e),
78
- themeLight: s(n.colors.whiteGreenB, e),
56
+ themeMediumB: c(n.colors.moss, e),
57
+ themeMediumC: c(n.colors.sage, e),
58
+ themeLight: c(n.colors.whiteGreenB, e),
79
59
  // whiteGreen
80
- themeLightA: s(n.colors.moss, e),
60
+ themeLightA: c(n.colors.moss, e),
81
61
  // whiteGreenA
82
- themeLightB: s(n.colors.whiteGreenB, e),
83
- themeLightC: s(n.colors.whiteGreenC, e),
84
- themeLightD: s(n.colors.whiteGreenD, e),
85
- themeShadowA: s(n.colors.darkGreenO99, e) + "99",
86
- themeShadowB: "0 0 8px -2px " + s(n.colors.darkGreen, e),
87
- themeShadowC: "0 0 2px 1px " + s(n.colors.darkGreen, e),
88
- themeIconBackgroundA: e < 0 ? n.colors.green : s(n.colors.green, e),
89
- themeIconBackgroundB: e < 0 ? n.colors.whiteGreenA : s(n.colors.whiteGreenA, e),
62
+ themeLightB: c(n.colors.whiteGreenB, e),
63
+ themeLightC: c(n.colors.whiteGreenC, e),
64
+ themeLightD: c(n.colors.whiteGreenD, e),
65
+ themeShadowA: c(n.colors.darkGreenO99, e) + "99",
66
+ themeShadowB: "0 0 8px -2px " + c(n.colors.darkGreen, e),
67
+ themeShadowC: "0 0 2px 1px " + c(n.colors.darkGreen, e),
68
+ themeIconBackgroundA: e < 0 ? n.colors.green : c(n.colors.green, e),
69
+ themeIconBackgroundB: e < 0 ? n.colors.whiteGreenA : c(n.colors.whiteGreenA, e),
90
70
  themeIconColorA: n.colors.white,
91
- themeIconColorB: e < 0 ? n.colors.darkGreen : s(n.colors.darkGreen, e),
92
- ...G
71
+ themeIconColorB: e < 0 ? n.colors.darkGreen : c(n.colors.darkGreen, e)
93
72
  };
94
73
  };
95
74
  export {
96
- k as getHueFromHex,
97
- _ as getSaturationFromHex,
98
- s as substituteHue,
99
- F as updateTheme
75
+ p as getHueFromHex,
76
+ b as getSaturationFromHex,
77
+ c as substituteHue,
78
+ k as updateTheme
100
79
  };
package/utils.d.ts CHANGED
@@ -1,19 +1,9 @@
1
- export declare const isMobile: () => boolean;
2
- export declare const isTablet: () => boolean;
3
- export declare const isValidEmail: (email: string) => boolean;
4
- export declare const isValidPhoneNumber: (phone: string) => boolean;
5
- export declare const isValidZipCode: (zip: string) => boolean;
6
- export declare const isValidCityName: (city: string) => boolean;
7
- export declare const formatDate: (date: string, style?: "mmddyyyy") => string;
8
- export declare const formatDateTime: (dateTime: string) => string;
1
+ export { states } from './constants';
2
+ export { isValidEmail, isValidPhoneNumber, isValidZipCode, isValidCityName, isValidSSN } from './validators';
3
+ export { formatDate, formatDateTime, formatPhoneNumber, formatZipCode, formatSSN, formatAddress, formatTimestamp, formattersByType, type FormatterFunction, } from './formatters';
4
+ export { maskSSN, defaultMasker, maskersByType, type MaskerFunction } from './maskers';
5
+ /** A collection of input types that can be either formatted or masked, 'text' is also included so that custom maskers/formatters can be applied */
6
+ export declare const formattedOrMaskedTypes: Set<string>;
7
+ export declare const useIsMobile: () => boolean;
8
+ export declare const useIsTablet: () => boolean;
9
9
  export declare const calculateAge: (birthDateString: string) => number;
10
- export declare const formatAddress: (address: {
11
- line1: string;
12
- line2?: string | null;
13
- city?: string | null;
14
- state?: string | null;
15
- zip?: string | null;
16
- }) => string;
17
- export declare const formatTimestamp: (timestamp: string) => string;
18
- export declare const formatPhoneNumber: (number: string | undefined) => [string, string | undefined];
19
- export declare const formatZipCode: (zip: string | undefined) => [string, string | undefined];
package/utils.js CHANGED
@@ -1,92 +1,42 @@
1
- import a from "./theme.js";
2
- import { u as l } from "./.chunks/useMediaQuery.js";
3
- const Z = () => l(`(max-width: ${a.screenSizes.mobile})`), w = () => l(`(max-width: ${a.screenSizes.tablet})`), R = (t) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.trim()), T = (t) => {
4
- if (!t) return !1;
5
- const e = t.replace(/\D/g, "");
6
- return !!(t.trim() == e && e.length >= 10 && e.length <= 16 || /^\s*(?:\+?1\s*(?:[-\s]\s*)?)?(?:\(\s*\d{3}\s*\)|\d{3})(?:\s*[-\s]\s*)?\d{3}(?:\s*[-\s]\s*)?\d{4}(?:\s*(?:#|x\.?|ext\.?|extension)\s*\d{1,6})?\s*$/.test(t.trim()));
7
- }, C = (t) => /^\d{5}(?:\s*-?\s*\d{4})?$/.test(t), S = (t) => /^[a-zA-Z\s'.-]+$/.test(t), b = (t, e = "mmddyyyy") => e === "mmddyyyy" ? (/* @__PURE__ */ new Date(t.replace(" ", "T").replace("Z", "") + "Z")).toLocaleDateString("en-US", {
8
- timeZone: "America/Chicago",
9
- month: "numeric",
10
- day: "numeric",
11
- year: "numeric"
12
- }) : t, A = (t) => {
13
- try {
14
- return (/* @__PURE__ */ new Date(t.replace(" ", "T").replace("Z", "") + "Z")).toLocaleString("en-US", {
15
- timeZone: "America/Chicago",
16
- month: "short",
17
- day: "numeric",
18
- year: "numeric",
19
- hour: "numeric",
20
- minute: "2-digit",
21
- hour12: !0
22
- });
23
- } catch {
24
- return t;
25
- }
26
- }, z = (t) => {
27
- t = t.slice(0, 10) + "T00:00:00";
28
- const e = /* @__PURE__ */ new Date(), i = new Date(t);
29
- let s = e.getFullYear() - i.getFullYear();
30
- const n = e.getMonth() - i.getMonth();
31
- return (n < 0 || n === 0 && e.getDate() < i.getDate()) && s--, s;
32
- }, N = (t) => {
33
- const { line1: e, line2: i, city: s, state: n, zip: o } = t;
34
- let r = e || "";
35
- return i && (r.length > 0 && (r += ", "), r += i), s && (r.length > 0 && (r += ", "), r += s), n && (r.length > 0 && (r += ", "), r += n), o && (r += ` ${p(o)[0]}`), r;
36
- }, $ = (t) => {
37
- if (t > 3 && t < 21) return "th";
38
- switch (t % 10) {
39
- case 1:
40
- return "st";
41
- case 2:
42
- return "nd";
43
- case 3:
44
- return "rd";
45
- default:
46
- return "th";
47
- }
48
- }, P = (t) => {
49
- try {
50
- const e = /* @__PURE__ */ new Date(t.replace(" ", "T").replace("Z", "") + "Z"), s = new Intl.DateTimeFormat("en-US", {
51
- timeZone: "America/Chicago",
52
- month: "short",
53
- day: "numeric",
54
- year: "numeric",
55
- hour: "numeric",
56
- minute: "2-digit",
57
- hour12: !0
58
- }).formatToParts(e), n = (h) => {
59
- var c;
60
- return ((c = s.find((y) => y.type === h)) == null ? void 0 : c.value) ?? "";
61
- }, o = n("month") + ".", r = Number(n("day")), u = n("year"), m = n("hour"), d = n("minute"), f = n("dayPeriod").toLowerCase(), g = $(r);
62
- return `${o} ${r}${g}, ${u}, ${m}:${d}${f}`;
63
- } catch {
64
- return t;
65
- }
66
- }, v = (t) => {
67
- if (t == null) return ["", void 0];
68
- let e = t.replace(/\D/g, "") || "";
69
- e.at(0) == "1" && (e = e.slice(1));
70
- const i = e.slice(0, 3), s = e.slice(3, 6), n = e.slice(6, 10), o = e.slice(10, 16);
71
- let r = e;
72
- return e.length >= 4 && (r = `(${i}) ${e.slice(3)}`), e.length >= 7 && (r = `(${i}) ${s}-${e.slice(6)}`), e.length > 10 && (r = `(${i}) ${s}-${n} ext. ${o}`), [r, e.slice(0, 16)];
73
- }, p = (t) => {
74
- if (!t) return ["", void 0];
75
- const e = t.replace(/\D/g, "");
76
- return e.length <= 5 ? [e, e] : [`${e.slice(0, 5)}-${e.slice(5, 9)}`, e.slice(0, 9)];
1
+ import s from "./theme.js";
2
+ import { formattersByType as i } from "./formatters.js";
3
+ import { formatAddress as S, formatDate as T, formatDateTime as g, formatPhoneNumber as k, formatSSN as D, formatTimestamp as M, formatZipCode as N } from "./formatters.js";
4
+ import { maskersByType as f } from "./maskers.js";
5
+ import { defaultMasker as V, maskSSN as C } from "./maskers.js";
6
+ import { states as j } from "./constants.js";
7
+ import { isValidCityName as A, isValidEmail as B, isValidPhoneNumber as F, isValidSSN as I, isValidZipCode as P } from "./validators.js";
8
+ import { u as m } from "./.chunks/useMediaQuery.js";
9
+ const c = /* @__PURE__ */ new Set([
10
+ ...Object.keys(i),
11
+ ...Object.keys(f),
12
+ "text"
13
+ ]), u = () => m(`(max-width: ${s.screenSizes.mobile})`), y = () => m(`(max-width: ${s.screenSizes.tablet})`), x = (e) => {
14
+ e = e.slice(0, 10) + "T00:00:00";
15
+ const t = /* @__PURE__ */ new Date(), o = new Date(e);
16
+ let r = t.getFullYear() - o.getFullYear();
17
+ const a = t.getMonth() - o.getMonth();
18
+ return (a < 0 || a === 0 && t.getDate() < o.getDate()) && r--, r;
77
19
  };
78
20
  export {
79
- z as calculateAge,
80
- N as formatAddress,
81
- b as formatDate,
82
- A as formatDateTime,
83
- v as formatPhoneNumber,
84
- P as formatTimestamp,
85
- p as formatZipCode,
86
- Z as isMobile,
87
- w as isTablet,
88
- S as isValidCityName,
89
- R as isValidEmail,
90
- T as isValidPhoneNumber,
91
- C as isValidZipCode
21
+ x as calculateAge,
22
+ V as defaultMasker,
23
+ S as formatAddress,
24
+ T as formatDate,
25
+ g as formatDateTime,
26
+ k as formatPhoneNumber,
27
+ D as formatSSN,
28
+ M as formatTimestamp,
29
+ N as formatZipCode,
30
+ c as formattedOrMaskedTypes,
31
+ i as formattersByType,
32
+ A as isValidCityName,
33
+ B as isValidEmail,
34
+ F as isValidPhoneNumber,
35
+ I as isValidSSN,
36
+ P as isValidZipCode,
37
+ C as maskSSN,
38
+ f as maskersByType,
39
+ j as states,
40
+ u as useIsMobile,
41
+ y as useIsTablet
92
42
  };
@@ -0,0 +1,5 @@
1
+ export declare const isValidEmail: (email: string) => boolean;
2
+ export declare const isValidPhoneNumber: (phone: string) => boolean;
3
+ export declare const isValidZipCode: (zip: string) => boolean;
4
+ export declare const isValidCityName: (city: string) => boolean;
5
+ export declare const isValidSSN: (ssn: string) => boolean;