jcicl 1.0.61 → 1.0.63
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/AppContainer/AppContainer.js +4 -0
- package/DataPage/useDataPage.js +35 -27
- package/DefaultTemplate/DefaultTemplate.d.ts +2 -0
- package/DefaultTemplate/DefaultTemplate.js +55 -46
- package/SiteBanner/SiteBanner.d.ts +2 -0
- package/SiteBanner/SiteBanner.js +9 -9
- package/api.d.ts +41 -0
- package/api.js +79 -0
- package/package.json +1 -1
package/DataPage/useDataPage.js
CHANGED
|
@@ -1,38 +1,46 @@
|
|
|
1
|
-
import { useState as
|
|
1
|
+
import { useState as r, useRef as R, useEffect as F, useCallback as d } from "react";
|
|
2
2
|
const g = Symbol("DataPageResult");
|
|
3
|
-
function
|
|
4
|
-
return { [g]: !0, data:
|
|
3
|
+
function P(t, u) {
|
|
4
|
+
return { [g]: !0, data: t, warnings: u };
|
|
5
5
|
}
|
|
6
|
-
const
|
|
7
|
-
function
|
|
8
|
-
const [
|
|
9
|
-
|
|
10
|
-
let
|
|
11
|
-
return
|
|
6
|
+
const S = (t) => t == null ? !0 : Array.isArray(t) ? t.length === 0 : !1;
|
|
7
|
+
function W({ fetchFn: t, deps: u = [] }) {
|
|
8
|
+
const [h, c] = r(null), [y, i] = r(!0), [w, a] = r(null), [m, f] = r([]), [A, E] = r(0), l = R(t);
|
|
9
|
+
l.current = t, F(() => {
|
|
10
|
+
let n = !1;
|
|
11
|
+
return i(!0), a(null), f([]), (async () => {
|
|
12
12
|
try {
|
|
13
|
-
const
|
|
14
|
-
if (
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
const e = await l.current();
|
|
14
|
+
if (n) return;
|
|
15
|
+
if (e === void 0) {
|
|
16
|
+
a("fetchFn returned undefined — did you forget a return statement?");
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (e && typeof e == "object" && g in e) {
|
|
20
|
+
const o = e;
|
|
21
|
+
if (o.data === void 0) {
|
|
22
|
+
a("fetchFn returned undefined data inside withWarnings()");
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
c(o.data), f(o.warnings);
|
|
18
26
|
} else
|
|
19
|
-
c(
|
|
20
|
-
} catch (
|
|
21
|
-
|
|
27
|
+
c(e);
|
|
28
|
+
} catch (e) {
|
|
29
|
+
n || a(e instanceof Error ? e.message : "An unexpected error occurred");
|
|
22
30
|
} finally {
|
|
23
|
-
|
|
31
|
+
n || i(!1);
|
|
24
32
|
}
|
|
25
33
|
})(), () => {
|
|
26
|
-
|
|
34
|
+
n = !0;
|
|
27
35
|
};
|
|
28
|
-
}, [...
|
|
29
|
-
const p = d((
|
|
30
|
-
c((s) => s !== null ?
|
|
31
|
-
}, []), D = d(() =>
|
|
32
|
-
return { data:
|
|
36
|
+
}, [...u, A]);
|
|
37
|
+
const p = d((n) => {
|
|
38
|
+
c((s) => s !== null ? n(s) : s);
|
|
39
|
+
}, []), D = d(() => E((n) => n + 1), []);
|
|
40
|
+
return { data: h, loading: y, error: w, warnings: m, setData: p, refetch: D };
|
|
33
41
|
}
|
|
34
42
|
export {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
43
|
+
W as default,
|
|
44
|
+
S as defaultIsEmpty,
|
|
45
|
+
P as withWarnings
|
|
38
46
|
};
|
|
@@ -19,6 +19,8 @@ export type DefaultTemplateProps = AppContainerProps & {
|
|
|
19
19
|
hasPagination?: boolean;
|
|
20
20
|
fade?: boolean;
|
|
21
21
|
siteBannerText?: string;
|
|
22
|
+
siteBannerBackgroundColor?: string;
|
|
23
|
+
siteBannerTextColor?: string;
|
|
22
24
|
};
|
|
23
25
|
declare const DefaultTemplate: React.FC<PropsWithChildren<DefaultTemplateProps>>;
|
|
24
26
|
export default DefaultTemplate;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { jsx as r, jsxs as g, Fragment as
|
|
2
|
-
import { useState as
|
|
1
|
+
import { jsx as r, jsxs as g, Fragment as O } from "react/jsx-runtime";
|
|
2
|
+
import { useState as b, useMemo as A } from "react";
|
|
3
3
|
import { n as y } from "../.chunks/emotion-styled.browser.esm.js";
|
|
4
4
|
import { c as C } from "../.chunks/emotion-react.browser.esm.js";
|
|
5
|
-
import
|
|
5
|
+
import o, { defaultTheme as T } from "../theme.js";
|
|
6
6
|
import { getHueFromHex as u, updateTheme as p } from "../themeUtils.js";
|
|
7
|
-
import { ThemeContext as
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { TopFade as
|
|
11
|
-
import { SiteBanner as
|
|
12
|
-
import { P as
|
|
13
|
-
import { u as
|
|
14
|
-
const
|
|
7
|
+
import { ThemeContext as L } from "../ThemeContext.js";
|
|
8
|
+
import j from "../AppContainer/AppContainer.js";
|
|
9
|
+
import D from "../WithLoading/WithLoading.js";
|
|
10
|
+
import { TopFade as W, BottomFade as B } from "../Overlays/Overlays.js";
|
|
11
|
+
import { SiteBanner as H } from "../SiteBanner/SiteBanner.js";
|
|
12
|
+
import { P as G } from "../.chunks/AppHeader.js";
|
|
13
|
+
import { u as S } from "../.chunks/useMediaQuery.js";
|
|
14
|
+
const Q = ["loading", "hasPagination", "loadingColor", "hasFade", "isTablet"], N = y("div", { shouldForwardProp: (t) => !Q.includes(t) })(({ loading: t, hasPagination: i, hasFade: m, loadingColor: l = o.colors.green }) => ({
|
|
15
15
|
...C`
|
|
16
|
-
color: ${
|
|
17
|
-
height: ${
|
|
16
|
+
color: ${o.colors.midnight};
|
|
17
|
+
height: ${t ? "100%" : "auto"};
|
|
18
18
|
padding: 19px;
|
|
19
19
|
padding-top: 36px;
|
|
20
20
|
display: flex;
|
|
21
21
|
flex-direction: column;
|
|
22
|
-
justify-content: ${
|
|
22
|
+
justify-content: ${t ? "center" : "start"};
|
|
23
23
|
align-items: center;
|
|
24
24
|
width: 100%;
|
|
25
25
|
min-height: 100%;
|
|
@@ -33,7 +33,7 @@ const H = ["loading", "hasPagination", "loadingColor", "hasFade", "isTablet"], G
|
|
|
33
33
|
color: ${l};
|
|
34
34
|
}
|
|
35
35
|
`
|
|
36
|
-
})),
|
|
36
|
+
})), q = y("div")(() => ({
|
|
37
37
|
...C`
|
|
38
38
|
border-radius: 8px;
|
|
39
39
|
padding: 0;
|
|
@@ -47,25 +47,27 @@ const H = ["loading", "hasPagination", "loadingColor", "hasFade", "isTablet"], G
|
|
|
47
47
|
box-sizing: border-box;
|
|
48
48
|
`
|
|
49
49
|
}));
|
|
50
|
-
function
|
|
51
|
-
return
|
|
50
|
+
function E(t, i) {
|
|
51
|
+
return t == "green" ? T : p(i);
|
|
52
52
|
}
|
|
53
|
-
const
|
|
54
|
-
children:
|
|
53
|
+
const ie = ({
|
|
54
|
+
children: t,
|
|
55
55
|
loading: i = !1,
|
|
56
56
|
hasPagination: m = !1,
|
|
57
57
|
fade: l = !0,
|
|
58
58
|
siteBannerText: n,
|
|
59
|
-
|
|
59
|
+
siteBannerBackgroundColor: w,
|
|
60
|
+
siteBannerTextColor: k,
|
|
61
|
+
userProfileMenuItems: I,
|
|
60
62
|
...s
|
|
61
63
|
}) => {
|
|
62
|
-
const
|
|
63
|
-
() =>
|
|
64
|
-
), [
|
|
64
|
+
const M = localStorage.getItem("theme") || "green", f = localStorage.getItem("hue") || u(o.themeOptions.green).toString(), x = S(`(max-width: ${o.screenSizes.mobile})`), P = S(`(max-width: ${o.screenSizes.tablet})`), [e, d] = b(
|
|
65
|
+
() => E(M, parseFloat(f))
|
|
66
|
+
), [v, c] = b({ h: Math.max(parseFloat(f), 0) * 360, s: 0, v: 68, a: 1 }), F = [
|
|
65
67
|
{
|
|
66
68
|
label: "Default Theme",
|
|
67
69
|
onClick: () => {
|
|
68
|
-
localStorage.setItem("theme", "green"), localStorage.setItem("hue", u(
|
|
70
|
+
localStorage.setItem("theme", "green"), localStorage.setItem("hue", u(o.themeOptions.green).toString()), c((h) => ({ ...h, h: u(o.themeOptions.green) * 360 })), d(T);
|
|
69
71
|
}
|
|
70
72
|
},
|
|
71
73
|
{
|
|
@@ -78,15 +80,15 @@ const oe = ({
|
|
|
78
80
|
},
|
|
79
81
|
{
|
|
80
82
|
label: "Hue",
|
|
81
|
-
hue:
|
|
83
|
+
hue: v.h,
|
|
82
84
|
onChange: (a) => {
|
|
83
|
-
localStorage.setItem("theme", "custom"), localStorage.setItem("hue", (a.h / 360).toString()), c((
|
|
85
|
+
localStorage.setItem("theme", "custom"), localStorage.setItem("hue", (a.h / 360).toString()), c((z) => ({ ...z, h: a.h }));
|
|
84
86
|
const h = p(a.h / 360);
|
|
85
87
|
d(h);
|
|
86
88
|
}
|
|
87
89
|
},
|
|
88
|
-
...
|
|
89
|
-
],
|
|
90
|
+
...I || []
|
|
91
|
+
], $ = A(
|
|
90
92
|
() => ({
|
|
91
93
|
backgroundPrimary: e.themeLight,
|
|
92
94
|
backgroundSecondary: e.themeLightA,
|
|
@@ -100,9 +102,9 @@ const oe = ({
|
|
|
100
102
|
scrollColor: e.themeShadowA,
|
|
101
103
|
loadingColor: e.themeColor,
|
|
102
104
|
iconColors: {
|
|
103
|
-
icon: /* @__PURE__ */ r(
|
|
104
|
-
iconColor: e.themeDark ??
|
|
105
|
-
backgroundColor: e.themeMediumA ??
|
|
105
|
+
icon: /* @__PURE__ */ r(G, {}),
|
|
106
|
+
iconColor: e.themeDark ?? o.colors.darkGreen,
|
|
107
|
+
backgroundColor: e.themeMediumA ?? o.colors.mint
|
|
106
108
|
},
|
|
107
109
|
highlightPrimary: e.highlightPrimary,
|
|
108
110
|
highlightSecondary: e.highlightSecondary,
|
|
@@ -110,30 +112,37 @@ const oe = ({
|
|
|
110
112
|
}),
|
|
111
113
|
[e]
|
|
112
114
|
);
|
|
113
|
-
return /* @__PURE__ */ g(
|
|
114
|
-
n && /* @__PURE__ */ r(
|
|
115
|
+
return /* @__PURE__ */ g(L.Provider, { value: e, children: [
|
|
116
|
+
n && /* @__PURE__ */ r(
|
|
117
|
+
H,
|
|
118
|
+
{
|
|
119
|
+
text: n,
|
|
120
|
+
backgroundColor: w,
|
|
121
|
+
textColor: k
|
|
122
|
+
}
|
|
123
|
+
),
|
|
115
124
|
/* @__PURE__ */ r(
|
|
116
|
-
|
|
125
|
+
j,
|
|
117
126
|
{
|
|
118
127
|
...s,
|
|
119
|
-
userProfileMenuItems:
|
|
120
|
-
themeColors:
|
|
128
|
+
userProfileMenuItems: F,
|
|
129
|
+
themeColors: $ ?? (s == null ? void 0 : s.themeColors),
|
|
121
130
|
hasSiteBanner: !!n,
|
|
122
131
|
children: /* @__PURE__ */ r(
|
|
123
|
-
|
|
132
|
+
N,
|
|
124
133
|
{
|
|
125
134
|
className: "jcPageWrapper",
|
|
126
135
|
loading: i,
|
|
127
136
|
loadingColor: e.themeColor,
|
|
128
137
|
hasPagination: m,
|
|
129
138
|
hasFade: l,
|
|
130
|
-
isTablet:
|
|
131
|
-
children: /* @__PURE__ */ g(
|
|
132
|
-
l && /* @__PURE__ */ g(
|
|
133
|
-
/* @__PURE__ */ r(
|
|
134
|
-
/* @__PURE__ */ r(
|
|
139
|
+
isTablet: P,
|
|
140
|
+
children: /* @__PURE__ */ g(D, { loading: i, size: x ? 114 : 201, children: [
|
|
141
|
+
l && /* @__PURE__ */ g(O, { children: [
|
|
142
|
+
/* @__PURE__ */ r(W, { color: e.themeLight, hasSiteBanner: !!n }),
|
|
143
|
+
/* @__PURE__ */ r(B, { hasPagination: m, isMobile: x, color: e.themeLight })
|
|
135
144
|
] }),
|
|
136
|
-
/* @__PURE__ */ r(
|
|
145
|
+
/* @__PURE__ */ r(q, { children: t })
|
|
137
146
|
] })
|
|
138
147
|
}
|
|
139
148
|
)
|
|
@@ -142,7 +151,7 @@ const oe = ({
|
|
|
142
151
|
] });
|
|
143
152
|
};
|
|
144
153
|
export {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
154
|
+
q as MainContentContainer,
|
|
155
|
+
N as PageWrapper,
|
|
156
|
+
ie as default
|
|
148
157
|
};
|
package/SiteBanner/SiteBanner.js
CHANGED
|
@@ -2,8 +2,8 @@ import { jsx as e } from "react/jsx-runtime";
|
|
|
2
2
|
import { n as t } from "../.chunks/emotion-styled.browser.esm.js";
|
|
3
3
|
import { c as r } from "../.chunks/emotion-react.browser.esm.js";
|
|
4
4
|
import n from "../theme.js";
|
|
5
|
-
import { useThemeColors as
|
|
6
|
-
const
|
|
5
|
+
import { useThemeColors as c } from "../ThemeContext.js";
|
|
6
|
+
const m = t("div")(({ $backgroundColor: o }) => ({
|
|
7
7
|
...r`
|
|
8
8
|
width: 100%;
|
|
9
9
|
height: 54px;
|
|
@@ -14,20 +14,20 @@ const a = t("div")(({ backgroundColor: o }) => ({
|
|
|
14
14
|
justify-content: center;
|
|
15
15
|
box-sizing: border-box;
|
|
16
16
|
`
|
|
17
|
-
})),
|
|
17
|
+
})), l = t("span")(({ $textColor: o }) => ({
|
|
18
18
|
...r`
|
|
19
|
-
color: ${
|
|
19
|
+
color: ${o};
|
|
20
20
|
font-family: Roboto, sans-serif;
|
|
21
21
|
font-size: 19px;
|
|
22
22
|
font-weight: 500;
|
|
23
23
|
text-align: center;
|
|
24
24
|
text-shadow: 0px 0px 5px rgba(0, 0, 0, 0.5);
|
|
25
25
|
`
|
|
26
|
-
})),
|
|
27
|
-
const
|
|
28
|
-
return /* @__PURE__ */ e(
|
|
26
|
+
})), b = ({ text: o, backgroundColor: s, textColor: i }) => {
|
|
27
|
+
const a = c();
|
|
28
|
+
return /* @__PURE__ */ e(m, { $backgroundColor: s ?? a.themeColor, children: /* @__PURE__ */ e(l, { $textColor: i ?? n.colors.white, children: o }) });
|
|
29
29
|
};
|
|
30
30
|
export {
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
b as SiteBanner,
|
|
32
|
+
b as default
|
|
33
33
|
};
|
package/api.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface ApiResponse<T> {
|
|
2
|
+
success: boolean;
|
|
3
|
+
data?: T | null;
|
|
4
|
+
error?: {
|
|
5
|
+
status: number;
|
|
6
|
+
statusText: string;
|
|
7
|
+
message: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Base API client for JCIT applications.
|
|
12
|
+
*
|
|
13
|
+
* Provides a generic `request<T>()` method with timeout, JSON parsing,
|
|
14
|
+
* and standardized error wrapping into `ApiResponse<T>`.
|
|
15
|
+
*
|
|
16
|
+
* Consumers extend this class, pass the base URL via `super()`, and
|
|
17
|
+
* add app-specific endpoint methods:
|
|
18
|
+
*
|
|
19
|
+
* ```typescript
|
|
20
|
+
* import { BaseApiClient } from 'jcicl/api';
|
|
21
|
+
*
|
|
22
|
+
* class MyAppApi extends BaseApiClient {
|
|
23
|
+
* constructor() {
|
|
24
|
+
* super(import.meta.env.VITE_API_BASE_URL);
|
|
25
|
+
* }
|
|
26
|
+
* async getItems() {
|
|
27
|
+
* return this.request<Item[]>('/api/Items/GetItems');
|
|
28
|
+
* }
|
|
29
|
+
* }
|
|
30
|
+
*
|
|
31
|
+
* export const api = new MyAppApi();
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare class BaseApiClient {
|
|
35
|
+
protected baseUrl: string;
|
|
36
|
+
constructor(baseUrl: string);
|
|
37
|
+
protected request<T>(endpoint: string, method?: 'GET' | 'POST' | 'PUT' | 'DELETE', body?: unknown, options?: {
|
|
38
|
+
timeoutMs?: number;
|
|
39
|
+
headers?: Record<string, string>;
|
|
40
|
+
}): Promise<ApiResponse<T>>;
|
|
41
|
+
}
|
package/api.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
var T = Object.defineProperty;
|
|
2
|
+
var h = (s, e, r) => e in s ? T(s, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : s[e] = r;
|
|
3
|
+
var m = (s, e, r) => h(s, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
+
class x {
|
|
5
|
+
constructor(e) {
|
|
6
|
+
m(this, "baseUrl");
|
|
7
|
+
if (!e)
|
|
8
|
+
throw new Error(
|
|
9
|
+
"BaseApiClient: baseUrl is required. Pass import.meta.env.VITE_API_BASE_URL or equivalent."
|
|
10
|
+
);
|
|
11
|
+
this.baseUrl = e.endsWith("/") ? e.slice(0, -1) : e;
|
|
12
|
+
}
|
|
13
|
+
async request(e, r = "GET", n, a) {
|
|
14
|
+
const o = (a == null ? void 0 : a.timeoutMs) ?? 3e4, l = new AbortController(), d = setTimeout(() => l.abort(), o);
|
|
15
|
+
try {
|
|
16
|
+
const f = {
|
|
17
|
+
method: r,
|
|
18
|
+
headers: {
|
|
19
|
+
...n !== void 0 ? { "Content-Type": "application/json" } : {},
|
|
20
|
+
...a == null ? void 0 : a.headers
|
|
21
|
+
},
|
|
22
|
+
credentials: "include",
|
|
23
|
+
// Required for Windows Authentication with CORS
|
|
24
|
+
signal: l.signal
|
|
25
|
+
};
|
|
26
|
+
n !== void 0 && (f.body = JSON.stringify(n));
|
|
27
|
+
const t = await fetch(`${this.baseUrl}${e}`, f);
|
|
28
|
+
if (clearTimeout(d), !t.ok)
|
|
29
|
+
return {
|
|
30
|
+
success: !1,
|
|
31
|
+
error: {
|
|
32
|
+
status: t.status,
|
|
33
|
+
statusText: t.statusText,
|
|
34
|
+
message: `HTTP ${t.status}: ${t.statusText}`
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
if (t.status === 204)
|
|
38
|
+
return {
|
|
39
|
+
success: !0,
|
|
40
|
+
data: void 0
|
|
41
|
+
};
|
|
42
|
+
const c = await t.text();
|
|
43
|
+
if (!c || c === "null")
|
|
44
|
+
return {
|
|
45
|
+
success: !0,
|
|
46
|
+
data: null
|
|
47
|
+
};
|
|
48
|
+
let i;
|
|
49
|
+
try {
|
|
50
|
+
i = JSON.parse(c);
|
|
51
|
+
} catch {
|
|
52
|
+
i = c;
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
success: !0,
|
|
56
|
+
data: i
|
|
57
|
+
};
|
|
58
|
+
} catch (u) {
|
|
59
|
+
return clearTimeout(d), u instanceof Error && u.name === "AbortError" ? {
|
|
60
|
+
success: !1,
|
|
61
|
+
error: {
|
|
62
|
+
status: 0,
|
|
63
|
+
statusText: "Timeout",
|
|
64
|
+
message: `Request timed out after ${o}ms`
|
|
65
|
+
}
|
|
66
|
+
} : {
|
|
67
|
+
success: !1,
|
|
68
|
+
error: {
|
|
69
|
+
status: 0,
|
|
70
|
+
statusText: "Network Error",
|
|
71
|
+
message: u instanceof Error ? u.message : "Unknown error occurred"
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export {
|
|
78
|
+
x as BaseApiClient
|
|
79
|
+
};
|
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.63",
|
|
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",
|