@pivotfinancialtechnologies/admin-frontend-blueprint-template 0.0.3-dev.10 → 0.0.3-dev.11
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/README.md +6 -1
- package/dist/PermissionVisibility-DWlTcq5R.js +24 -0
- package/dist/PermissionVisibility-DcNQuqAD.cjs +1 -0
- package/dist/SettingsSectionBase-S_Y2d_vs.js +475 -0
- package/dist/SettingsSectionBase-Yx14wvkV.cjs +1 -0
- package/dist/TopBarNavLayout-BkDwDvQf.js +62 -0
- package/dist/TopBarNavLayout-DGP6BWzi.cjs +1 -0
- package/dist/admin-frontend-blueprint-template.css +1 -1
- package/dist/components.cjs +1 -1
- package/dist/components.js +1 -1
- package/dist/date-DxdnAP5U.js +13 -0
- package/dist/date-RB_2ERsI.cjs +1 -0
- package/dist/formatters.cjs +1 -1
- package/dist/formatters.js +1 -1
- package/dist/hooks.cjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +4 -4
- package/dist/layout.cjs +1 -1
- package/dist/layout.js +1 -1
- package/dist/security.cjs +1 -1
- package/dist/security.js +1 -1
- package/dist/useSize-BLbsGFVL.cjs +1 -0
- package/dist/useUrlForm-CxnAS6tK.cjs +1 -0
- package/package.json +3 -2
- package/dist/PermissionVisibility-CXHamZv5.cjs +0 -1
- package/dist/PermissionVisibility-DhDN-Z93.js +0 -24
- package/dist/SettingsSectionBase-CfT9p06Q.js +0 -475
- package/dist/SettingsSectionBase-PZs1Wgw1.cjs +0 -1
- package/dist/TopBarNavLayout-C0qRr2Lo.js +0 -62
- package/dist/TopBarNavLayout-CVxxYLc9.cjs +0 -1
- package/dist/date-1EP6oPlF.cjs +0 -1
- package/dist/date-BEtsfEKV.js +0 -389
- package/dist/jsx-runtime-DMhOxOJN.cjs +0 -14
- package/dist/jsx-runtime-gfdvceKf.js +0 -615
- package/dist/useSize-Dk1SOOLH.cjs +0 -1
- package/dist/useUrlForm-KA9CehKJ.cjs +0 -1
package/README.md
CHANGED
|
@@ -6,6 +6,8 @@ A reusable React component and utility library for admin frontends built with Bl
|
|
|
6
6
|
|
|
7
7
|
Consumers must provide React 18 and the Blueprint packages listed as peer dependencies: `@blueprintjs/core`, `@blueprintjs/icons`, `@blueprintjs/select`, and `@blueprintjs/table`, plus `react-router-dom` when using the security route components. The package includes `date-fns`, `date-fns-tz`, `@react-hook/resize-observer`, and `use-debounce` as runtime dependencies.
|
|
8
8
|
|
|
9
|
+
React, React DOM, and React Router are externalized from the library build, so the consuming app's React and router providers remain the shared instances.
|
|
10
|
+
|
|
9
11
|
Several components use Tailwind utility classes. Use Tailwind CSS 4 and ensure the package is included in source detection so its classes are generated. For example, in the host app's CSS entry (adjust the path relative to that file):
|
|
10
12
|
|
|
11
13
|
```css
|
|
@@ -62,8 +64,11 @@ import "@blueprintjs/table/lib/css/table.css";
|
|
|
62
64
|
import "@pivotfinancialtechnologies/admin-frontend-blueprint-template/styles.css";
|
|
63
65
|
```
|
|
64
66
|
|
|
67
|
+
`Topbar` and `TopBarNavLayout` keep the navigation bar in normal document flow; the title, navigation, and controls wrap on narrow screens.
|
|
68
|
+
|
|
65
69
|
## Development
|
|
66
70
|
|
|
67
|
-
- `npm run build` type-checks and builds the library.
|
|
71
|
+
- `npm run build` type-checks and builds the library, then checks the built security entry points against the consuming app's router context.
|
|
72
|
+
- `npm run check:built-package` reruns the package check against the current `dist/` output.
|
|
68
73
|
- `npm run lint` runs ESLint.
|
|
69
74
|
- `npm pack` creates the package archive for local inspection.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as u, Fragment as l } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as a, useEffect as f } from "react";
|
|
3
|
+
import { useNavigate as i, Outlet as o, Navigate as m } from "react-router-dom";
|
|
4
|
+
const v = ({ isAuthenticated: e, loginUrl: t, onBeforeNavigateLogin: n }) => {
|
|
5
|
+
const s = i(), r = a(!1);
|
|
6
|
+
return f(() => {
|
|
7
|
+
if (e) {
|
|
8
|
+
r.current = !1;
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
r.current || (r.current = !0, n?.(), s(t, { replace: !0 }));
|
|
12
|
+
}, [e, t, s, n]), e ? /* @__PURE__ */ u(o, {}) : null;
|
|
13
|
+
}, y = ({ isAuthenticated: e, homeUrl: t }) => e ? /* @__PURE__ */ u(m, { to: t }) : /* @__PURE__ */ u(o, {}), x = ({
|
|
14
|
+
requiredPermissions: e,
|
|
15
|
+
gainPermissions: t,
|
|
16
|
+
matchMode: n = "any",
|
|
17
|
+
children: s,
|
|
18
|
+
fallback: r = null
|
|
19
|
+
}) => !e.length || !t?.length ? /* @__PURE__ */ u(l, { children: r }) : (n === "all" ? e.every((c) => t.includes(c)) : e.some((c) => t.includes(c))) ? /* @__PURE__ */ u(l, { children: s }) : /* @__PURE__ */ u(l, { children: r });
|
|
20
|
+
export {
|
|
21
|
+
v as A,
|
|
22
|
+
x as P,
|
|
23
|
+
y as U
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),l=require("react"),c=require("react-router-dom"),o=({isAuthenticated:e,loginUrl:r,onBeforeNavigateLogin:n})=>{const s=c.useNavigate(),u=l.useRef(!1);return l.useEffect(()=>{if(e){u.current=!1;return}u.current||(u.current=!0,n?.(),s(r,{replace:!0}))},[e,r,s,n]),e?t.jsx(c.Outlet,{}):null},a=({isAuthenticated:e,homeUrl:r})=>e?t.jsx(c.Navigate,{to:r}):t.jsx(c.Outlet,{}),R=({requiredPermissions:e,gainPermissions:r,matchMode:n="any",children:s,fallback:u=null})=>!e.length||!r?.length?t.jsx(t.Fragment,{children:u}):(n==="all"?e.every(i=>r.includes(i)):e.some(i=>r.includes(i)))?t.jsx(t.Fragment,{children:s}):t.jsx(t.Fragment,{children:u});exports.AuthRoute=o;exports.PermissionVisibility=R;exports.UnAuthRoute=a;
|
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
import { jsx as t, jsxs as f, Fragment as G } from "react/jsx-runtime";
|
|
2
|
+
import { Tag as Y, Menu as $, MenuItem as y, Divider as re, PopoverNext as ie, Button as k, Intent as W, Spinner as oe, Alert as se, FormGroup as ae, H6 as ce, Section as de } from "@blueprintjs/core";
|
|
3
|
+
import ue, { useState as O, useRef as J, useMemo as D, useEffect as K, useCallback as V } from "react";
|
|
4
|
+
import { Select as U, MultiSelect as me } from "@blueprintjs/select";
|
|
5
|
+
import { Table as Q, TableLoadingOption as X, FocusMode as Z, SelectionModes as q, Column as ee, ColumnHeaderCell as pe, Cell as I } from "@blueprintjs/table";
|
|
6
|
+
import { u as te } from "./useSize-Ci0PbN9W.js";
|
|
7
|
+
import { a as j } from "./date-DxdnAP5U.js";
|
|
8
|
+
import { parseISO as he, isValid as fe } from "date-fns";
|
|
9
|
+
import { s as L } from "./toast-B3QUItIK.js";
|
|
10
|
+
const Me = ({ value: n, trueLabel: e = "Yes", falseLabel: l = "No" }) => {
|
|
11
|
+
if (n == null) return null;
|
|
12
|
+
const i = n === !0;
|
|
13
|
+
return /* @__PURE__ */ t(Y, { intent: i ? "success" : "danger", children: i ? e : l });
|
|
14
|
+
}, P = (n = 0, e = 10, l) => ({
|
|
15
|
+
sort: l,
|
|
16
|
+
page: n,
|
|
17
|
+
pageSize: e
|
|
18
|
+
}), B = (n) => {
|
|
19
|
+
if (n == null)
|
|
20
|
+
return "";
|
|
21
|
+
if (n instanceof Date)
|
|
22
|
+
return j(n);
|
|
23
|
+
const e = String(n);
|
|
24
|
+
if (/^\d{4}-\d{2}-\d{2}/.test(e)) {
|
|
25
|
+
const l = he(e);
|
|
26
|
+
if (fe(l))
|
|
27
|
+
return j(l);
|
|
28
|
+
}
|
|
29
|
+
return e;
|
|
30
|
+
}, ge = (n) => {
|
|
31
|
+
const e = document.createElement("textarea");
|
|
32
|
+
e.value = n, e.style.position = "fixed", e.style.top = "0", e.style.left = "0", e.style.opacity = "0", document.body.appendChild(e), e.select();
|
|
33
|
+
try {
|
|
34
|
+
return document.execCommand("copy");
|
|
35
|
+
} catch (l) {
|
|
36
|
+
return console.error("Fallback copy failed", l), !1;
|
|
37
|
+
} finally {
|
|
38
|
+
document.body.removeChild(e);
|
|
39
|
+
}
|
|
40
|
+
}, z = async (n) => {
|
|
41
|
+
if (!navigator.clipboard) {
|
|
42
|
+
ge(n);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
await navigator.clipboard.writeText(n);
|
|
46
|
+
}, ne = (n, e, l, i) => {
|
|
47
|
+
const s = n.getTarget(), a = s.rows?.[0] ?? -1, c = s.cols?.[0] ?? -1, d = e[c]?.name, g = l?.[a], m = g?.[e[c].key], C = a > -1 && c > -1 ? B(m) : "";
|
|
48
|
+
return /* @__PURE__ */ f($, { children: [
|
|
49
|
+
/* @__PURE__ */ t(
|
|
50
|
+
y,
|
|
51
|
+
{
|
|
52
|
+
text: d ? `Copy ${d} (Ctrl+C)` : "Copy (Ctrl+C)",
|
|
53
|
+
onClick: async () => {
|
|
54
|
+
a > -1 && c > -1 && (await z(C), L({ message: d ? `${d} Copied` : "Text Copied", intent: "success" }));
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
-1
|
|
58
|
+
),
|
|
59
|
+
i?.map((v, S) => /* @__PURE__ */ t(
|
|
60
|
+
y,
|
|
61
|
+
{
|
|
62
|
+
text: `Copy ${v.label}`,
|
|
63
|
+
onClick: async () => {
|
|
64
|
+
await z(v.copyContent(g)), L({ message: `${v.label} copied`, intent: "success" });
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
S
|
|
68
|
+
))
|
|
69
|
+
] });
|
|
70
|
+
}, be = [5, 15, 25, 50, 100], Pe = ({
|
|
71
|
+
columns: n,
|
|
72
|
+
request: e,
|
|
73
|
+
data: l,
|
|
74
|
+
isLoading: i,
|
|
75
|
+
onRequestChange: s,
|
|
76
|
+
actionButtons: a,
|
|
77
|
+
getIntent: c,
|
|
78
|
+
onDoubleClick: d,
|
|
79
|
+
resetKey: g
|
|
80
|
+
}) => {
|
|
81
|
+
const [m, C] = O(n), v = J(null), { width: S } = te(v), b = l?.content ?? [], u = (r) => {
|
|
82
|
+
s(P(0, e.pageSize, r));
|
|
83
|
+
}, x = () => {
|
|
84
|
+
l && !l.last && s(P(e.page + 1, e.pageSize, e.sort));
|
|
85
|
+
}, _ = () => {
|
|
86
|
+
l && !l.first && s(P(e.page - 1, e.pageSize, e.sort));
|
|
87
|
+
}, A = (r) => {
|
|
88
|
+
s(P(0, r, e.sort));
|
|
89
|
+
}, F = (r) => /* @__PURE__ */ f($, { children: [
|
|
90
|
+
/* @__PURE__ */ t(y, { text: "Sort Ascending", icon: "sort-asc", onClick: () => u([{ field: r, direction: "asc" }]) }),
|
|
91
|
+
/* @__PURE__ */ t(y, { text: "Sort Descending", icon: "sort-desc", onClick: () => u([{ field: r, direction: "desc" }]) }),
|
|
92
|
+
/* @__PURE__ */ t(y, { text: "Unsort", onClick: () => u(void 0) })
|
|
93
|
+
] }), E = (r, p, h) => r.customCellRenderer ? r.customCellRenderer(p) : /* @__PURE__ */ t(G, { children: h }), H = async (r, p) => {
|
|
94
|
+
const R = b[r]?.[n[p].key], T = B(R);
|
|
95
|
+
return navigator.clipboard || await z(T), T;
|
|
96
|
+
}, o = D(() => m.filter((r) => r.visible), [m]), w = (r) => {
|
|
97
|
+
const p = o.reduce((M, le) => M + (le.width ?? 0), 0), h = o.filter((M) => M.width !== void 0).length;
|
|
98
|
+
let T = (r - p - 38) / (o.length - h);
|
|
99
|
+
return T < 100 && (T = 100), o.map((M) => M.width ?? T);
|
|
100
|
+
}, N = D(() => w(S), [S, o]);
|
|
101
|
+
return K(() => {
|
|
102
|
+
g && e.page !== 0 && s(P(0, e.pageSize, e.sort));
|
|
103
|
+
}, [g]), /* @__PURE__ */ f("div", { children: [
|
|
104
|
+
/* @__PURE__ */ f("div", { className: "table-form-actions", children: [
|
|
105
|
+
/* @__PURE__ */ t("div", { className: "table-form" }),
|
|
106
|
+
/* @__PURE__ */ f("div", { className: "table-actions", children: [
|
|
107
|
+
a && a,
|
|
108
|
+
a && /* @__PURE__ */ t(re, { style: { height: "20px" } }),
|
|
109
|
+
/* @__PURE__ */ t(
|
|
110
|
+
ie,
|
|
111
|
+
{
|
|
112
|
+
placement: "bottom-start",
|
|
113
|
+
content: /* @__PURE__ */ t($, { children: m.map((r) => /* @__PURE__ */ t(
|
|
114
|
+
y,
|
|
115
|
+
{
|
|
116
|
+
shouldDismissPopover: !1,
|
|
117
|
+
onClick: (p) => {
|
|
118
|
+
p.preventDefault(), C(
|
|
119
|
+
(h) => h.map((R) => R.key === r.key ? { ...R, visible: !R.visible } : R)
|
|
120
|
+
);
|
|
121
|
+
},
|
|
122
|
+
text: /* @__PURE__ */ f("div", { className: "columns-visibility-menu", children: [
|
|
123
|
+
/* @__PURE__ */ t("input", { type: "checkbox", checked: r.visible, readOnly: !0, style: { pointerEvents: "none" } }),
|
|
124
|
+
r.name
|
|
125
|
+
] })
|
|
126
|
+
},
|
|
127
|
+
r.name
|
|
128
|
+
)) }),
|
|
129
|
+
renderTarget: ({ isOpen: r, ...p }) => /* @__PURE__ */ t(k, { ...p, text: "Columns Visibility", endIcon: "double-caret-vertical" })
|
|
130
|
+
}
|
|
131
|
+
)
|
|
132
|
+
] })
|
|
133
|
+
] }),
|
|
134
|
+
/* @__PURE__ */ t("div", { ref: v, children: /* @__PURE__ */ t(
|
|
135
|
+
Q,
|
|
136
|
+
{
|
|
137
|
+
cellRendererDependencies: [e, l, N],
|
|
138
|
+
columnWidths: N,
|
|
139
|
+
numRows: b?.length ?? 0,
|
|
140
|
+
getCellClipboardData: H,
|
|
141
|
+
defaultRowHeight: 25,
|
|
142
|
+
enableColumnResizing: !1,
|
|
143
|
+
enableRowResizing: !1,
|
|
144
|
+
enableMultipleSelection: !1,
|
|
145
|
+
selectionModes: q.ROWS_AND_CELLS,
|
|
146
|
+
focusMode: Z.ROW,
|
|
147
|
+
loadingOptions: i ? [X.COLUMN_HEADERS] : [],
|
|
148
|
+
bodyContextMenuRenderer: (r) => ne(r, n, b ?? []),
|
|
149
|
+
children: o.map((r) => /* @__PURE__ */ t(
|
|
150
|
+
ee,
|
|
151
|
+
{
|
|
152
|
+
name: r.name,
|
|
153
|
+
cellRenderer: (p) => {
|
|
154
|
+
if (!b)
|
|
155
|
+
return /* @__PURE__ */ t(I, {});
|
|
156
|
+
const h = b[p], R = c ? c(h) : W.NONE;
|
|
157
|
+
return /* @__PURE__ */ t(I, { intent: R, interactive: !0, className: "h-full", children: /* @__PURE__ */ t(
|
|
158
|
+
"div",
|
|
159
|
+
{
|
|
160
|
+
className: "absolute inset-0 px-2 py-1 flex items-center",
|
|
161
|
+
onDoubleClick: () => {
|
|
162
|
+
d && d(h);
|
|
163
|
+
},
|
|
164
|
+
children: E(r, h, h[r.key])
|
|
165
|
+
}
|
|
166
|
+
) });
|
|
167
|
+
},
|
|
168
|
+
columnHeaderCellRenderer: () => /* @__PURE__ */ t(pe, { name: r.name, menuRenderer: () => F(r.sortKey ?? r.key) })
|
|
169
|
+
},
|
|
170
|
+
r.key
|
|
171
|
+
))
|
|
172
|
+
}
|
|
173
|
+
) }),
|
|
174
|
+
/* @__PURE__ */ f("div", { className: "table-pagination", children: [
|
|
175
|
+
/* @__PURE__ */ f("div", { className: "rows-select-container", children: [
|
|
176
|
+
/* @__PURE__ */ t("span", { children: "Rows per page: " }),
|
|
177
|
+
/* @__PURE__ */ t(
|
|
178
|
+
U,
|
|
179
|
+
{
|
|
180
|
+
items: be,
|
|
181
|
+
itemRenderer: (r, { handleClick: p }) => /* @__PURE__ */ t(y, { text: r, onClick: p }, r),
|
|
182
|
+
onItemSelect: A,
|
|
183
|
+
filterable: !1,
|
|
184
|
+
disabled: i,
|
|
185
|
+
children: /* @__PURE__ */ t(k, { text: e.pageSize, endIcon: "double-caret-vertical" })
|
|
186
|
+
}
|
|
187
|
+
)
|
|
188
|
+
] }),
|
|
189
|
+
/* @__PURE__ */ f("div", { className: "flex flex-row items-center", children: [
|
|
190
|
+
i && /* @__PURE__ */ t(oe, { size: 20 }),
|
|
191
|
+
/* @__PURE__ */ t(k, { onClick: _, disabled: i || (l ? l.first : !0), children: "Previous" }),
|
|
192
|
+
/* @__PURE__ */ f("span", { className: "pagination-page-info", children: [
|
|
193
|
+
"Page ",
|
|
194
|
+
l ? l.number + 1 : 1,
|
|
195
|
+
" of ",
|
|
196
|
+
l ? l.totalPages : 1
|
|
197
|
+
] }),
|
|
198
|
+
/* @__PURE__ */ t(k, { onClick: x, disabled: i || (l ? l.last : i), children: "Next" })
|
|
199
|
+
] })
|
|
200
|
+
] })
|
|
201
|
+
] });
|
|
202
|
+
}, De = ({
|
|
203
|
+
value: n,
|
|
204
|
+
trueText: e = "Yes",
|
|
205
|
+
falseText: l = "No",
|
|
206
|
+
trueIntent: i,
|
|
207
|
+
falseIntent: s,
|
|
208
|
+
round: a = !0,
|
|
209
|
+
minimal: c = !0
|
|
210
|
+
}) => n == null ? null : /* @__PURE__ */ t(Y, { intent: n ? i : s, round: a, minimal: c, children: n ? e : l }), Ce = [5, 15, 25, 50, 100, 200], Ee = ({
|
|
211
|
+
columns: n,
|
|
212
|
+
data: e,
|
|
213
|
+
actionButtons: l,
|
|
214
|
+
isLoading: i,
|
|
215
|
+
getIntent: s,
|
|
216
|
+
pageSize: a,
|
|
217
|
+
extraCopyMenus: c
|
|
218
|
+
}) => {
|
|
219
|
+
const [d, g] = O(a), [m, C] = O(0), v = J(null), { width: S } = te(v), b = d != null, u = D(() => !b || !e ? 1 : Math.ceil(e.length / d) || 1, [e, d, b]), x = D(() => {
|
|
220
|
+
if (!e) return [];
|
|
221
|
+
if (!b) return e;
|
|
222
|
+
const o = m * d;
|
|
223
|
+
return e.slice(o, o + d);
|
|
224
|
+
}, [e, m, d, b]), _ = (e?.length ?? 0) > 23 && !b, A = (o) => {
|
|
225
|
+
g(o), C(0);
|
|
226
|
+
}, F = (o) => {
|
|
227
|
+
const w = n.reduce((h, R) => h + (R.width ?? 0), 0), N = n.filter((h) => h.width !== void 0).length;
|
|
228
|
+
let p = (o - w - 38) / (n.length - N);
|
|
229
|
+
return p < 150 && (p = 150), n.map((h) => h.width ?? p);
|
|
230
|
+
}, E = D(() => F(S), [S, n]), H = async (o, w) => {
|
|
231
|
+
const r = e?.[o]?.[n[w].key], p = B(r);
|
|
232
|
+
return navigator.clipboard || await z(p), p;
|
|
233
|
+
};
|
|
234
|
+
return ue.useEffect(() => {
|
|
235
|
+
C(0);
|
|
236
|
+
}, [e]), /* @__PURE__ */ f(
|
|
237
|
+
"div",
|
|
238
|
+
{
|
|
239
|
+
className: "simple-datatable",
|
|
240
|
+
style: _ ? { height: "70vh", overflow: "auto" } : void 0,
|
|
241
|
+
ref: v,
|
|
242
|
+
children: [
|
|
243
|
+
l && /* @__PURE__ */ t("div", { className: "flex justify-end mb-2", children: l }),
|
|
244
|
+
/* @__PURE__ */ t(
|
|
245
|
+
Q,
|
|
246
|
+
{
|
|
247
|
+
loadingOptions: i ? [X.COLUMN_HEADERS] : [],
|
|
248
|
+
getCellClipboardData: H,
|
|
249
|
+
cellRendererDependencies: [x, n, E, m],
|
|
250
|
+
numRows: x.length,
|
|
251
|
+
defaultRowHeight: 25,
|
|
252
|
+
enableColumnResizing: !1,
|
|
253
|
+
enableRowResizing: !1,
|
|
254
|
+
enableMultipleSelection: !1,
|
|
255
|
+
selectionModes: q.ROWS_AND_CELLS,
|
|
256
|
+
columnWidths: E,
|
|
257
|
+
focusMode: Z.ROW,
|
|
258
|
+
bodyContextMenuRenderer: (o) => ne(o, n, x, c),
|
|
259
|
+
children: n.map((o) => /* @__PURE__ */ t(
|
|
260
|
+
ee,
|
|
261
|
+
{
|
|
262
|
+
name: o.name,
|
|
263
|
+
cellRenderer: (w) => {
|
|
264
|
+
const N = x[w], r = s ? s(N) : W.NONE;
|
|
265
|
+
return N ? /* @__PURE__ */ t(I, { intent: r, children: o.customCellRenderer ? o.customCellRenderer(N) : /* @__PURE__ */ t(G, { children: N[o.key] }) }) : /* @__PURE__ */ t(I, { intent: r });
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
o.key
|
|
269
|
+
))
|
|
270
|
+
},
|
|
271
|
+
`table-page-${m}-${d ?? "all"}`
|
|
272
|
+
),
|
|
273
|
+
b && /* @__PURE__ */ f("div", { className: "table-pagination flex items-center justify-between mt-2", children: [
|
|
274
|
+
/* @__PURE__ */ f("div", { className: "rows-select-container flex items-center gap-2", children: [
|
|
275
|
+
/* @__PURE__ */ t("span", { children: "Rows per page: " }),
|
|
276
|
+
/* @__PURE__ */ t(
|
|
277
|
+
U,
|
|
278
|
+
{
|
|
279
|
+
items: Ce,
|
|
280
|
+
itemRenderer: (o, { handleClick: w }) => /* @__PURE__ */ t(y, { text: o, onClick: w }, o),
|
|
281
|
+
onItemSelect: A,
|
|
282
|
+
filterable: !1,
|
|
283
|
+
children: /* @__PURE__ */ t(k, { text: d, endIcon: "double-caret-vertical" })
|
|
284
|
+
}
|
|
285
|
+
)
|
|
286
|
+
] }),
|
|
287
|
+
/* @__PURE__ */ f("div", { className: "flex flex-row items-center gap-2", children: [
|
|
288
|
+
/* @__PURE__ */ t(k, { onClick: () => C((o) => Math.max(0, o - 1)), disabled: m === 0, children: "Previous" }),
|
|
289
|
+
/* @__PURE__ */ f("span", { className: "pagination-page-info px-2", children: [
|
|
290
|
+
"Page ",
|
|
291
|
+
m + 1,
|
|
292
|
+
" of ",
|
|
293
|
+
u
|
|
294
|
+
] }),
|
|
295
|
+
/* @__PURE__ */ t(
|
|
296
|
+
k,
|
|
297
|
+
{
|
|
298
|
+
onClick: () => C((o) => Math.min(u - 1, o + 1)),
|
|
299
|
+
disabled: m >= u - 1,
|
|
300
|
+
children: "Next"
|
|
301
|
+
}
|
|
302
|
+
)
|
|
303
|
+
] })
|
|
304
|
+
] })
|
|
305
|
+
]
|
|
306
|
+
}
|
|
307
|
+
);
|
|
308
|
+
}, We = ({ columns: n, data: e, getIntent: l }) => /* @__PURE__ */ f("table", { className: "bp6-html-table simple-html-datatable w-full", children: [
|
|
309
|
+
/* @__PURE__ */ t("thead", { children: /* @__PURE__ */ t("tr", { children: n.map((i, s) => /* @__PURE__ */ t("th", { style: { width: i.width }, children: i.name }, s)) }) }),
|
|
310
|
+
/* @__PURE__ */ t("tbody", { children: (e ?? []).map((i, s) => {
|
|
311
|
+
const a = l ? l(i) : W.NONE;
|
|
312
|
+
return /* @__PURE__ */ t("tr", { className: a !== W.NONE ? `bp6-intent-${a}` : "", children: n.map((c, d) => /* @__PURE__ */ t("td", { children: c.customCellRenderer ? c.customCellRenderer(i) : i[c.key] }, d)) }, s);
|
|
313
|
+
}) })
|
|
314
|
+
] }), Ie = () => {
|
|
315
|
+
const [n, e] = O(!1), [l, i] = O(null), [s, a] = O(null);
|
|
316
|
+
return [V((g) => (i(g), e(!0), new Promise((m) => {
|
|
317
|
+
a(() => m);
|
|
318
|
+
})), []), /* @__PURE__ */ t(
|
|
319
|
+
se,
|
|
320
|
+
{
|
|
321
|
+
isOpen: n,
|
|
322
|
+
intent: "primary",
|
|
323
|
+
confirmButtonText: "Yes",
|
|
324
|
+
cancelButtonText: "No",
|
|
325
|
+
onConfirm: () => {
|
|
326
|
+
e(!1), s?.(!0), a(null);
|
|
327
|
+
},
|
|
328
|
+
onClose: () => {
|
|
329
|
+
e(!1), s?.(!1), a(null);
|
|
330
|
+
},
|
|
331
|
+
children: l
|
|
332
|
+
}
|
|
333
|
+
)];
|
|
334
|
+
}, ze = ({
|
|
335
|
+
selectedValue: n,
|
|
336
|
+
items: e = [],
|
|
337
|
+
required: l = !1,
|
|
338
|
+
disabled: i,
|
|
339
|
+
onSelect: s,
|
|
340
|
+
renderSelected: a,
|
|
341
|
+
renderMenuText: c,
|
|
342
|
+
getValueByItem: d,
|
|
343
|
+
getItemByValue: g,
|
|
344
|
+
renderMenuLabel: m,
|
|
345
|
+
onBlur: C,
|
|
346
|
+
intent: v = "none"
|
|
347
|
+
}) => {
|
|
348
|
+
const S = l ? e : [null, ...e], b = n === void 0 ? void 0 : g(n);
|
|
349
|
+
return /* @__PURE__ */ t(
|
|
350
|
+
U,
|
|
351
|
+
{
|
|
352
|
+
items: S,
|
|
353
|
+
disabled: i,
|
|
354
|
+
onItemSelect: (u) => {
|
|
355
|
+
s(u ?? void 0);
|
|
356
|
+
},
|
|
357
|
+
filterable: !1,
|
|
358
|
+
popoverProps: {
|
|
359
|
+
onClose: () => {
|
|
360
|
+
C?.();
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
itemRenderer: (u, { handleClick: x }) => u ? /* @__PURE__ */ t(
|
|
364
|
+
y,
|
|
365
|
+
{
|
|
366
|
+
text: c(u),
|
|
367
|
+
onClick: x,
|
|
368
|
+
labelElement: m?.(u)
|
|
369
|
+
},
|
|
370
|
+
String(d(u))
|
|
371
|
+
) : /* @__PURE__ */ t(y, { text: "— None —", onClick: x }, "__none"),
|
|
372
|
+
noResults: /* @__PURE__ */ t(y, { disabled: !0, text: "No records." }),
|
|
373
|
+
children: /* @__PURE__ */ t(
|
|
374
|
+
k,
|
|
375
|
+
{
|
|
376
|
+
text: a(b) ?? "Select Value",
|
|
377
|
+
intent: v,
|
|
378
|
+
endIcon: "double-caret-vertical"
|
|
379
|
+
}
|
|
380
|
+
)
|
|
381
|
+
}
|
|
382
|
+
);
|
|
383
|
+
}, _e = ({
|
|
384
|
+
items: n = [],
|
|
385
|
+
selectedValues: e = [],
|
|
386
|
+
required: l = !1,
|
|
387
|
+
disabled: i,
|
|
388
|
+
getValueByItem: s,
|
|
389
|
+
getItemByValue: a,
|
|
390
|
+
renderSelected: c,
|
|
391
|
+
renderMenuText: d,
|
|
392
|
+
renderMenuLabel: g,
|
|
393
|
+
onBlur: m,
|
|
394
|
+
onSelect: C,
|
|
395
|
+
onRemove: v
|
|
396
|
+
}) => {
|
|
397
|
+
const S = e.map((u) => a(u));
|
|
398
|
+
return /* @__PURE__ */ t(
|
|
399
|
+
me,
|
|
400
|
+
{
|
|
401
|
+
disabled: i,
|
|
402
|
+
items: n,
|
|
403
|
+
selectedItems: S,
|
|
404
|
+
onItemSelect: C,
|
|
405
|
+
onRemove: (u) => {
|
|
406
|
+
l && S.length <= 1 || v(u);
|
|
407
|
+
},
|
|
408
|
+
popoverProps: {
|
|
409
|
+
onClose: () => {
|
|
410
|
+
m?.();
|
|
411
|
+
}
|
|
412
|
+
},
|
|
413
|
+
itemRenderer: (u, { handleClick: x }) => /* @__PURE__ */ t(
|
|
414
|
+
y,
|
|
415
|
+
{
|
|
416
|
+
text: d(u),
|
|
417
|
+
labelElement: g?.(u),
|
|
418
|
+
onClick: x
|
|
419
|
+
},
|
|
420
|
+
String(s(u))
|
|
421
|
+
),
|
|
422
|
+
noResults: /* @__PURE__ */ t(y, { disabled: !0, text: "No records." }),
|
|
423
|
+
tagRenderer: (u) => c(u)
|
|
424
|
+
}
|
|
425
|
+
);
|
|
426
|
+
}, Ae = ({ label: n, helpText: e, children: l }) => /* @__PURE__ */ t(
|
|
427
|
+
ae,
|
|
428
|
+
{
|
|
429
|
+
label: /* @__PURE__ */ t("div", { className: "flex flex-col items-start gap-1", children: /* @__PURE__ */ t(ce, { className: "m-0 whitespace-nowrap w-30", children: n }) }),
|
|
430
|
+
helperText: e,
|
|
431
|
+
inline: !0,
|
|
432
|
+
contentClassName: "w-full",
|
|
433
|
+
children: l
|
|
434
|
+
}
|
|
435
|
+
), ve = (n) => {
|
|
436
|
+
const [e, l] = O(n);
|
|
437
|
+
K(() => {
|
|
438
|
+
l(n);
|
|
439
|
+
}, [n]);
|
|
440
|
+
const i = V((a, c) => JSON.stringify(a) !== JSON.stringify(c), []), s = V(
|
|
441
|
+
(a, c) => l((d) => ({ ...d, [a]: c })),
|
|
442
|
+
[]
|
|
443
|
+
);
|
|
444
|
+
return { value: e, setField: s, setValue: l, hasChanges: i };
|
|
445
|
+
}, Fe = (n) => {
|
|
446
|
+
const { title: e, updatedAt: l, onChange: i, settings: s, getContent: a } = n, { value: c, setField: d, setValue: g, hasChanges: m } = ve(s), C = m(s, c);
|
|
447
|
+
return /* @__PURE__ */ t(
|
|
448
|
+
de,
|
|
449
|
+
{
|
|
450
|
+
title: e,
|
|
451
|
+
rightElement: /* @__PURE__ */ t(k, { type: "button", intent: "primary", disabled: !C, onClick: () => i(c), children: "Save" }),
|
|
452
|
+
subtitle: /* @__PURE__ */ f(G, { children: [
|
|
453
|
+
"Updated At: ",
|
|
454
|
+
j(l)
|
|
455
|
+
] }),
|
|
456
|
+
children: /* @__PURE__ */ t("div", { className: "m-4", children: a ? a(c, d, g) : null })
|
|
457
|
+
}
|
|
458
|
+
);
|
|
459
|
+
};
|
|
460
|
+
export {
|
|
461
|
+
Me as B,
|
|
462
|
+
Pe as D,
|
|
463
|
+
ze as S,
|
|
464
|
+
De as T,
|
|
465
|
+
_e as a,
|
|
466
|
+
Ae as b,
|
|
467
|
+
Fe as c,
|
|
468
|
+
Ee as d,
|
|
469
|
+
We as e,
|
|
470
|
+
ne as f,
|
|
471
|
+
z as g,
|
|
472
|
+
B as h,
|
|
473
|
+
P as i,
|
|
474
|
+
Ie as u
|
|
475
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),i=require("@blueprintjs/core"),h=require("react"),O=require("@blueprintjs/select"),g=require("@blueprintjs/table"),$=require("./useSize-BLbsGFVL.cjs"),B=require("./date-RB_2ERsI.cjs"),A=require("date-fns"),H=require("./toast-CCrs9yfw.cjs"),G=({value:n,trueLabel:t="Yes",falseLabel:s="No"})=>{if(n==null)return null;const o=n===!0;return e.jsx(i.Tag,{intent:o?"success":"danger",children:o?t:s})},T=(n=0,t=10,s)=>({sort:s,page:n,pageSize:t}),P=n=>{if(n==null)return"";if(n instanceof Date)return B.formatDateTime(n);const t=String(n);if(/^\d{4}-\d{2}-\d{2}/.test(t)){const s=A.parseISO(t);if(A.isValid(s))return B.formatDateTime(s)}return t},L=n=>{const t=document.createElement("textarea");t.value=n,t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.opacity="0",document.body.appendChild(t),t.select();try{return document.execCommand("copy")}catch(s){return console.error("Fallback copy failed",s),!1}finally{document.body.removeChild(t)}},k=async n=>{if(!navigator.clipboard){L(n);return}await navigator.clipboard.writeText(n)},F=(n,t,s,o)=>{const a=n.getTarget(),c=a.rows?.[0]??-1,d=a.cols?.[0]??-1,u=t[d]?.name,C=s?.[c],x=C?.[t[d].key],j=c>-1&&d>-1?P(x):"";return e.jsxs(i.Menu,{children:[e.jsx(i.MenuItem,{text:u?`Copy ${u} (Ctrl+C)`:"Copy (Ctrl+C)",onClick:async()=>{c>-1&&d>-1&&(await k(j),H.showToast({message:u?`${u} Copied`:"Text Copied",intent:"success"}))}},-1),o?.map((S,y)=>e.jsx(i.MenuItem,{text:`Copy ${S.label}`,onClick:async()=>{await k(S.copyContent(C)),H.showToast({message:`${S.label} copied`,intent:"success"})}},y))]})},U=[5,15,25,50,100],Y=({columns:n,request:t,data:s,isLoading:o,onRequestChange:a,actionButtons:c,getIntent:d,onDoubleClick:u,resetKey:C})=>{const[x,j]=h.useState(n),S=h.useRef(null),{width:y}=$.useSize(S),b=s?.content??[],m=l=>{a(T(0,t.pageSize,l))},v=()=>{s&&!s.last&&a(T(t.page+1,t.pageSize,t.sort))},E=()=>{s&&!s.first&&a(T(t.page-1,t.pageSize,t.sort))},W=l=>{a(T(0,l,t.sort))},z=l=>e.jsxs(i.Menu,{children:[e.jsx(i.MenuItem,{text:"Sort Ascending",icon:"sort-asc",onClick:()=>m([{field:l,direction:"asc"}])}),e.jsx(i.MenuItem,{text:"Sort Descending",icon:"sort-desc",onClick:()=>m([{field:l,direction:"desc"}])}),e.jsx(i.MenuItem,{text:"Unsort",onClick:()=>m(void 0)})]}),D=(l,p,f)=>l.customCellRenderer?l.customCellRenderer(p):e.jsx(e.Fragment,{children:f}),_=async(l,p)=>{const R=b[l]?.[n[p].key],w=P(R);return navigator.clipboard||await k(w),w},r=h.useMemo(()=>x.filter(l=>l.visible),[x]),M=l=>{const p=r.reduce((I,V)=>I+(V.width??0),0),f=r.filter(I=>I.width!==void 0).length;let w=(l-p-38)/(r.length-f);return w<100&&(w=100),r.map(I=>I.width??w)},N=h.useMemo(()=>M(y),[y,r]);return h.useEffect(()=>{C&&t.page!==0&&a(T(0,t.pageSize,t.sort))},[C]),e.jsxs("div",{children:[e.jsxs("div",{className:"table-form-actions",children:[e.jsx("div",{className:"table-form"}),e.jsxs("div",{className:"table-actions",children:[c&&c,c&&e.jsx(i.Divider,{style:{height:"20px"}}),e.jsx(i.PopoverNext,{placement:"bottom-start",content:e.jsx(i.Menu,{children:x.map(l=>e.jsx(i.MenuItem,{shouldDismissPopover:!1,onClick:p=>{p.preventDefault(),j(f=>f.map(R=>R.key===l.key?{...R,visible:!R.visible}:R))},text:e.jsxs("div",{className:"columns-visibility-menu",children:[e.jsx("input",{type:"checkbox",checked:l.visible,readOnly:!0,style:{pointerEvents:"none"}}),l.name]})},l.name))}),renderTarget:({isOpen:l,...p})=>e.jsx(i.Button,{...p,text:"Columns Visibility",endIcon:"double-caret-vertical"})})]})]}),e.jsx("div",{ref:S,children:e.jsx(g.Table,{cellRendererDependencies:[t,s,N],columnWidths:N,numRows:b?.length??0,getCellClipboardData:_,defaultRowHeight:25,enableColumnResizing:!1,enableRowResizing:!1,enableMultipleSelection:!1,selectionModes:g.SelectionModes.ROWS_AND_CELLS,focusMode:g.FocusMode.ROW,loadingOptions:o?[g.TableLoadingOption.COLUMN_HEADERS]:[],bodyContextMenuRenderer:l=>F(l,n,b??[]),children:r.map(l=>e.jsx(g.Column,{name:l.name,cellRenderer:p=>{if(!b)return e.jsx(g.Cell,{});const f=b[p],R=d?d(f):i.Intent.NONE;return e.jsx(g.Cell,{intent:R,interactive:!0,className:"h-full",children:e.jsx("div",{className:"absolute inset-0 px-2 py-1 flex items-center",onDoubleClick:()=>{u&&u(f)},children:D(l,f,f[l.key])})})},columnHeaderCellRenderer:()=>e.jsx(g.ColumnHeaderCell,{name:l.name,menuRenderer:()=>z(l.sortKey??l.key)})},l.key))})}),e.jsxs("div",{className:"table-pagination",children:[e.jsxs("div",{className:"rows-select-container",children:[e.jsx("span",{children:"Rows per page: "}),e.jsx(O.Select,{items:U,itemRenderer:(l,{handleClick:p})=>e.jsx(i.MenuItem,{text:l,onClick:p},l),onItemSelect:W,filterable:!1,disabled:o,children:e.jsx(i.Button,{text:t.pageSize,endIcon:"double-caret-vertical"})})]}),e.jsxs("div",{className:"flex flex-row items-center",children:[o&&e.jsx(i.Spinner,{size:20}),e.jsx(i.Button,{onClick:E,disabled:o||(s?s.first:!0),children:"Previous"}),e.jsxs("span",{className:"pagination-page-info",children:["Page ",s?s.number+1:1," of ",s?s.totalPages:1]}),e.jsx(i.Button,{onClick:v,disabled:o||(s?s.last:o),children:"Next"})]})]})]})},J=({value:n,trueText:t="Yes",falseText:s="No",trueIntent:o,falseIntent:a,round:c=!0,minimal:d=!0})=>n==null?null:e.jsx(i.Tag,{intent:n?o:a,round:c,minimal:d,children:n?t:s}),K=[5,15,25,50,100,200],Q=({columns:n,data:t,actionButtons:s,isLoading:o,getIntent:a,pageSize:c,extraCopyMenus:d})=>{const[u,C]=h.useState(c),[x,j]=h.useState(0),S=h.useRef(null),{width:y}=$.useSize(S),b=u!=null,m=h.useMemo(()=>!b||!t?1:Math.ceil(t.length/u)||1,[t,u,b]),v=h.useMemo(()=>{if(!t)return[];if(!b)return t;const r=x*u;return t.slice(r,r+u)},[t,x,u,b]),E=(t?.length??0)>23&&!b,W=r=>{C(r),j(0)},z=r=>{const M=n.reduce((f,R)=>f+(R.width??0),0),N=n.filter(f=>f.width!==void 0).length;let p=(r-M-38)/(n.length-N);return p<150&&(p=150),n.map(f=>f.width??p)},D=h.useMemo(()=>z(y),[y,n]),_=async(r,M)=>{const l=t?.[r]?.[n[M].key],p=P(l);return navigator.clipboard||await k(p),p};return h.useEffect(()=>{j(0)},[t]),e.jsxs("div",{className:"simple-datatable",style:E?{height:"70vh",overflow:"auto"}:void 0,ref:S,children:[s&&e.jsx("div",{className:"flex justify-end mb-2",children:s}),e.jsx(g.Table,{loadingOptions:o?[g.TableLoadingOption.COLUMN_HEADERS]:[],getCellClipboardData:_,cellRendererDependencies:[v,n,D,x],numRows:v.length,defaultRowHeight:25,enableColumnResizing:!1,enableRowResizing:!1,enableMultipleSelection:!1,selectionModes:g.SelectionModes.ROWS_AND_CELLS,columnWidths:D,focusMode:g.FocusMode.ROW,bodyContextMenuRenderer:r=>F(r,n,v,d),children:n.map(r=>e.jsx(g.Column,{name:r.name,cellRenderer:M=>{const N=v[M],l=a?a(N):i.Intent.NONE;return N?e.jsx(g.Cell,{intent:l,children:r.customCellRenderer?r.customCellRenderer(N):e.jsx(e.Fragment,{children:N[r.key]})}):e.jsx(g.Cell,{intent:l})}},r.key))},`table-page-${x}-${u??"all"}`),b&&e.jsxs("div",{className:"table-pagination flex items-center justify-between mt-2",children:[e.jsxs("div",{className:"rows-select-container flex items-center gap-2",children:[e.jsx("span",{children:"Rows per page: "}),e.jsx(O.Select,{items:K,itemRenderer:(r,{handleClick:M})=>e.jsx(i.MenuItem,{text:r,onClick:M},r),onItemSelect:W,filterable:!1,children:e.jsx(i.Button,{text:u,endIcon:"double-caret-vertical"})})]}),e.jsxs("div",{className:"flex flex-row items-center gap-2",children:[e.jsx(i.Button,{onClick:()=>j(r=>Math.max(0,r-1)),disabled:x===0,children:"Previous"}),e.jsxs("span",{className:"pagination-page-info px-2",children:["Page ",x+1," of ",m]}),e.jsx(i.Button,{onClick:()=>j(r=>Math.min(m-1,r+1)),disabled:x>=m-1,children:"Next"})]})]})]})},X=({columns:n,data:t,getIntent:s})=>e.jsxs("table",{className:"bp6-html-table simple-html-datatable w-full",children:[e.jsx("thead",{children:e.jsx("tr",{children:n.map((o,a)=>e.jsx("th",{style:{width:o.width},children:o.name},a))})}),e.jsx("tbody",{children:(t??[]).map((o,a)=>{const c=s?s(o):i.Intent.NONE;return e.jsx("tr",{className:c!==i.Intent.NONE?`bp6-intent-${c}`:"",children:n.map((d,u)=>e.jsx("td",{children:d.customCellRenderer?d.customCellRenderer(o):o[d.key]},u))},a)})})]}),Z=()=>{const[n,t]=h.useState(!1),[s,o]=h.useState(null),[a,c]=h.useState(null),d=h.useCallback(C=>(o(C),t(!0),new Promise(x=>{c(()=>x)})),[]),u=e.jsx(i.Alert,{isOpen:n,intent:"primary",confirmButtonText:"Yes",cancelButtonText:"No",onConfirm:()=>{t(!1),a?.(!0),c(null)},onClose:()=>{t(!1),a?.(!1),c(null)},children:s});return[d,u]},q=({selectedValue:n,items:t=[],required:s=!1,disabled:o,onSelect:a,renderSelected:c,renderMenuText:d,getValueByItem:u,getItemByValue:C,renderMenuLabel:x,onBlur:j,intent:S="none"})=>{const y=s?t:[null,...t],b=n===void 0?void 0:C(n);return e.jsx(O.Select,{items:y,disabled:o,onItemSelect:m=>{a(m??void 0)},filterable:!1,popoverProps:{onClose:()=>{j?.()}},itemRenderer:(m,{handleClick:v})=>m?e.jsx(i.MenuItem,{text:d(m),onClick:v,labelElement:x?.(m)},String(u(m))):e.jsx(i.MenuItem,{text:"— None —",onClick:v},"__none"),noResults:e.jsx(i.MenuItem,{disabled:!0,text:"No records."}),children:e.jsx(i.Button,{text:c(b)??"Select Value",intent:S,endIcon:"double-caret-vertical"})})},ee=({items:n=[],selectedValues:t=[],required:s=!1,disabled:o,getValueByItem:a,getItemByValue:c,renderSelected:d,renderMenuText:u,renderMenuLabel:C,onBlur:x,onSelect:j,onRemove:S})=>{const y=t.map(m=>c(m)),b=m=>{s&&y.length<=1||S(m)};return e.jsx(O.MultiSelect,{disabled:o,items:n,selectedItems:y,onItemSelect:j,onRemove:b,popoverProps:{onClose:()=>{x?.()}},itemRenderer:(m,{handleClick:v})=>e.jsx(i.MenuItem,{text:u(m),labelElement:C?.(m),onClick:v},String(a(m))),noResults:e.jsx(i.MenuItem,{disabled:!0,text:"No records."}),tagRenderer:m=>d(m)})},te=({label:n,helpText:t,children:s})=>e.jsx(i.FormGroup,{label:e.jsx("div",{className:"flex flex-col items-start gap-1",children:e.jsx(i.H6,{className:"m-0 whitespace-nowrap w-30",children:n})}),helperText:t,inline:!0,contentClassName:"w-full",children:s}),ne=n=>{const[t,s]=h.useState(n);h.useEffect(()=>{s(n)},[n]);const o=h.useCallback((c,d)=>JSON.stringify(c)!==JSON.stringify(d),[]),a=h.useCallback((c,d)=>s(u=>({...u,[c]:d})),[]);return{value:t,setField:a,setValue:s,hasChanges:o}},se=n=>{const{title:t,updatedAt:s,onChange:o,settings:a,getContent:c}=n,{value:d,setField:u,setValue:C,hasChanges:x}=ne(a),j=x(a,d);return e.jsx(i.Section,{title:t,rightElement:e.jsx(i.Button,{type:"button",intent:"primary",disabled:!j,onClick:()=>o(d),children:"Save"}),subtitle:e.jsxs(e.Fragment,{children:["Updated At: ",B.formatDateTime(s)]}),children:e.jsx("div",{className:"m-4",children:c?c(d,u,C):null})})};exports.BooleanTag=G;exports.Datatable=Y;exports.SelectItem=q;exports.SelectMultipleItems=ee;exports.SettingGroup=te;exports.SettingsSectionBase=se;exports.SimpleDatatable=Q;exports.SimpleHTMLDatatable=X;exports.TableCellTag=J;exports.copyTextToClipboard=k;exports.createCopyableText=P;exports.createPageRequest=T;exports.createTableCopyMenu=F;exports.useConfirmDialog=Z;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsx as e, jsxs as r } from "react/jsx-runtime";
|
|
2
|
+
import { useState as d, useEffect as u } from "react";
|
|
3
|
+
import { Classes as c, Colors as i, Switch as h, Navbar as b, NavbarGroup as s, NavbarHeading as g, PopoverNext as v, Button as p, Menu as y, MenuItem as l, MenuDivider as N } from "@blueprintjs/core";
|
|
4
|
+
const T = () => {
|
|
5
|
+
const [n, a] = d(() => {
|
|
6
|
+
if (typeof window > "u")
|
|
7
|
+
return !1;
|
|
8
|
+
try {
|
|
9
|
+
return window.localStorage.getItem("theme") === "dark";
|
|
10
|
+
} catch {
|
|
11
|
+
return !1;
|
|
12
|
+
}
|
|
13
|
+
}), o = (t) => {
|
|
14
|
+
document.body.classList.toggle(c.DARK, t), document.body.style.backgroundColor = t ? i.DARK_GRAY3 : i.LIGHT_GRAY5;
|
|
15
|
+
try {
|
|
16
|
+
window.localStorage.setItem("theme", t ? "dark" : "light");
|
|
17
|
+
} catch {
|
|
18
|
+
}
|
|
19
|
+
a(t);
|
|
20
|
+
};
|
|
21
|
+
return u(() => {
|
|
22
|
+
o(n);
|
|
23
|
+
const t = new MutationObserver(() => {
|
|
24
|
+
const m = document.body.classList.contains(c.DARK);
|
|
25
|
+
a(m);
|
|
26
|
+
});
|
|
27
|
+
return t.observe(document.body, { attributes: !0, attributeFilter: ["class"] }), () => t.disconnect();
|
|
28
|
+
}, [n]), {
|
|
29
|
+
isDarkTheme: n,
|
|
30
|
+
setTheme: o
|
|
31
|
+
};
|
|
32
|
+
}, f = (n) => {
|
|
33
|
+
const { isDarkTheme: a, setTheme: o } = T();
|
|
34
|
+
return /* @__PURE__ */ e(h, { ...n, checked: a, label: "Dark Mode", onChange: () => o(!a), alignIndicator: "right" });
|
|
35
|
+
}, w = ({ title: n, navigation: a, onProfileClick: o, onLogoutClick: t }) => /* @__PURE__ */ r(b, { className: "custom-navbar", children: [
|
|
36
|
+
/* @__PURE__ */ e(s, { align: "left", className: "custom-navbar__title", children: /* @__PURE__ */ e(g, { children: n }) }),
|
|
37
|
+
/* @__PURE__ */ e(s, { className: "custom-navbar__navigation", children: a }),
|
|
38
|
+
/* @__PURE__ */ r(s, { align: "end", className: "custom-navbar__actions", children: [
|
|
39
|
+
/* @__PURE__ */ e(f, { className: "mb-0!" }),
|
|
40
|
+
/* @__PURE__ */ e(
|
|
41
|
+
v,
|
|
42
|
+
{
|
|
43
|
+
placement: "bottom-end",
|
|
44
|
+
content: /* @__PURE__ */ r(y, { children: [
|
|
45
|
+
/* @__PURE__ */ e(l, { icon: "id-number", text: "My profile", onClick: o }),
|
|
46
|
+
/* @__PURE__ */ e(N, {}),
|
|
47
|
+
/* @__PURE__ */ e(l, { intent: "danger", icon: "log-out", text: "Sign out", onClick: t })
|
|
48
|
+
] }),
|
|
49
|
+
children: /* @__PURE__ */ e(p, { icon: "user" })
|
|
50
|
+
}
|
|
51
|
+
)
|
|
52
|
+
] })
|
|
53
|
+
] }), _ = ({ children: n, ...a }) => /* @__PURE__ */ r("div", { className: "main-layout", children: [
|
|
54
|
+
/* @__PURE__ */ e("div", { className: "topbar", children: /* @__PURE__ */ e(w, { ...a }) }),
|
|
55
|
+
/* @__PURE__ */ e("div", { className: "body", children: n })
|
|
56
|
+
] });
|
|
57
|
+
export {
|
|
58
|
+
f as T,
|
|
59
|
+
_ as a,
|
|
60
|
+
w as b,
|
|
61
|
+
T as u
|
|
62
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),o=require("react"),t=require("@blueprintjs/core"),c=()=>{const[n,a]=o.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem("theme")==="dark"}catch{return!1}}),r=s=>{document.body.classList.toggle(t.Classes.DARK,s),document.body.style.backgroundColor=s?t.Colors.DARK_GRAY3:t.Colors.LIGHT_GRAY5;try{window.localStorage.setItem("theme",s?"dark":"light")}catch{}a(s)};return o.useEffect(()=>{r(n);const s=new MutationObserver(()=>{const u=document.body.classList.contains(t.Classes.DARK);a(u)});return s.observe(document.body,{attributes:!0,attributeFilter:["class"]}),()=>s.disconnect()},[n]),{isDarkTheme:n,setTheme:r}},i=n=>{const{isDarkTheme:a,setTheme:r}=c(),s=()=>r(!a);return e.jsx(t.Switch,{...n,checked:a,label:"Dark Mode",onChange:s,alignIndicator:"right"})},l=({title:n,navigation:a,onProfileClick:r,onLogoutClick:s})=>e.jsxs(t.Navbar,{className:"custom-navbar",children:[e.jsx(t.NavbarGroup,{align:"left",className:"custom-navbar__title",children:e.jsx(t.NavbarHeading,{children:n})}),e.jsx(t.NavbarGroup,{className:"custom-navbar__navigation",children:a}),e.jsxs(t.NavbarGroup,{align:"end",className:"custom-navbar__actions",children:[e.jsx(i,{className:"mb-0!"}),e.jsx(t.PopoverNext,{placement:"bottom-end",content:e.jsxs(t.Menu,{children:[e.jsx(t.MenuItem,{icon:"id-number",text:"My profile",onClick:r}),e.jsx(t.MenuDivider,{}),e.jsx(t.MenuItem,{intent:"danger",icon:"log-out",text:"Sign out",onClick:s})]}),children:e.jsx(t.Button,{icon:"user"})})]})]}),m=({children:n,...a})=>e.jsxs("div",{className:"main-layout",children:[e.jsx("div",{className:"topbar",children:e.jsx(l,{...a})}),e.jsx("div",{className:"body",children:n})]});exports.ThemeSwitch=i;exports.TopBarNavLayout=m;exports.Topbar=l;exports.useTheme=c;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.table-form-actions{display:flex}.table-actions{flex-shrink:0;align-self:flex-end;align-items:center;padding:10px 0;gap:10px;display:flex}.columns-visibility-menu{gap:10px;display:flex}.table-form{flex:1}.table-content{height:520px;overflow-y:auto;overflow-x:hidden}.table-pagination{display:flex;justify-content:space-between;align-items:center;margin:10px;padding-top:20px}.rows-select-container{display:flex;align-items:center}.rows-select-container span{margin-right:10px}.pagination-page-info{margin:0 10px}.simple-html-datatable{--table-border-color: rgba(129, 129, 129, .45);font-size:12px;border-collapse:collapse;border:1px solid var(--table-border-color)}.simple-html-datatable th,.simple-html-datatable td{padding:4px 8px;border-bottom:1px solid var(--table-border-color);border-right:1px solid var(--table-border-color)}.bp6-intent-primary{background-color:#2d72d21a;color:#2d72d2}.bp6-intent-warning{background-color:#ffe5641a;color:#d9822b}.bp6-intent-danger{background-color:#ff4d4f1a;color:#f45e5e}.custom-navbar{display:flex;width:100%;justify-content:space-between}.nav-button{box-shadow:none!important}.nav-button:hover{background:#ffffff1a!important}
|
|
1
|
+
.table-form-actions{display:flex}.table-actions{flex-shrink:0;align-self:flex-end;align-items:center;padding:10px 0;gap:10px;display:flex}.columns-visibility-menu{gap:10px;display:flex}.table-form{flex:1}.table-content{height:520px;overflow-y:auto;overflow-x:hidden}.table-pagination{display:flex;justify-content:space-between;align-items:center;margin:10px;padding-top:20px}.rows-select-container{display:flex;align-items:center}.rows-select-container span{margin-right:10px}.pagination-page-info{margin:0 10px}.simple-html-datatable{--table-border-color: rgba(129, 129, 129, .45);font-size:12px;border-collapse:collapse;border:1px solid var(--table-border-color)}.simple-html-datatable th,.simple-html-datatable td{padding:4px 8px;border-bottom:1px solid var(--table-border-color);border-right:1px solid var(--table-border-color)}.bp6-intent-primary{background-color:#2d72d21a;color:#2d72d2}.bp6-intent-warning{background-color:#ffe5641a;color:#d9822b}.bp6-intent-danger{background-color:#ff4d4f1a;color:#f45e5e}.custom-navbar{display:flex;width:100%;height:auto;min-height:50px;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:.5rem 1rem;padding-block:.25rem}.custom-navbar>.bp6-navbar-group{height:auto;min-height:50px;flex-wrap:wrap;gap:.5rem}.custom-navbar__navigation{flex:1 1 auto;justify-content:center}.custom-navbar__actions{flex:0 1 auto}@media(max-width:640px){.custom-navbar>.bp6-navbar-group{flex:1 1 100%}.custom-navbar__navigation,.custom-navbar__actions{justify-content:flex-start}}.nav-button{box-shadow:none!important}.nav-button:hover{background:#ffffff1a!important}
|
package/dist/components.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./SettingsSectionBase-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./SettingsSectionBase-Yx14wvkV.cjs");exports.BooleanTag=e.BooleanTag;exports.Datatable=e.Datatable;exports.SelectItem=e.SelectItem;exports.SelectMultipleItems=e.SelectMultipleItems;exports.SettingGroup=e.SettingGroup;exports.SettingsSectionBase=e.SettingsSectionBase;exports.SimpleDatatable=e.SimpleDatatable;exports.SimpleHTMLDatatable=e.SimpleHTMLDatatable;exports.TableCellTag=e.TableCellTag;exports.createTableCopyMenu=e.createTableCopyMenu;exports.useConfirmDialog=e.useConfirmDialog;
|
package/dist/components.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as t, D as l, S as s, a as o, b as i, c as S, d as b, e as m, T as n, f as p, u as T } from "./SettingsSectionBase-
|
|
1
|
+
import { B as t, D as l, S as s, a as o, b as i, c as S, d as b, e as m, T as n, f as p, u as T } from "./SettingsSectionBase-S_Y2d_vs.js";
|
|
2
2
|
export {
|
|
3
3
|
t as BooleanTag,
|
|
4
4
|
l as Datatable,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { formatInTimeZone as l } from "date-fns-tz";
|
|
2
|
+
import { enUS as r } from "date-fns/locale";
|
|
3
|
+
const t = { enUS: r }, D = () => Promise.resolve(r), f = (e, n = "yyyy-MM-dd HH:mm:ss z", o = "enUS", s = "America/Los_Angeles") => {
|
|
4
|
+
if (!e)
|
|
5
|
+
return "";
|
|
6
|
+
const i = t[o] || t.enUS, c = typeof e == "string" ? e.endsWith("Z") || e.includes("+") ? new Date(e) : /* @__PURE__ */ new Date(e + "Z") : new Date(e);
|
|
7
|
+
return l(c, s, n, { locale: i });
|
|
8
|
+
}, u = (e, n = "en-US") => e ? (typeof e == "string" ? e.endsWith("Z") || e.includes("+") ? new Date(e) : /* @__PURE__ */ new Date(e + "Z") : new Date(e)).toLocaleDateString(n) : "";
|
|
9
|
+
export {
|
|
10
|
+
f as a,
|
|
11
|
+
u as f,
|
|
12
|
+
D as l
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const l=require("date-fns-tz"),r=require("date-fns/locale"),o={enUS:r.enUS},a=()=>Promise.resolve(r.enUS),D=(e,n="yyyy-MM-dd HH:mm:ss z",t="enUS",s="America/Los_Angeles")=>{if(!e)return"";const c=o[t]||o.enUS,i=typeof e=="string"?e.endsWith("Z")||e.includes("+")?new Date(e):new Date(e+"Z"):new Date(e);return l.formatInTimeZone(i,s,n,{locale:c})},m=(e,n="en-US")=>e?(typeof e=="string"?e.endsWith("Z")||e.includes("+")?new Date(e):new Date(e+"Z"):new Date(e)).toLocaleDateString(n):"";exports.formatDateOnly=m;exports.formatDateTime=D;exports.localeLoader=a;
|
package/dist/formatters.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./date-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./date-RB_2ERsI.cjs"),e=require("./phone-DmQ5SK-X.cjs");exports.formatDateOnly=r.formatDateOnly;exports.formatDateTime=r.formatDateTime;exports.localeLoader=r.localeLoader;exports.currencyFormatter=e.currencyFormatter;exports.formatCurrency=e.formatCurrency;exports.formatDateDuration=e.formatDateDuration;exports.formatPhone=e.formatPhone;exports.parseMoney=e.parseMoney;
|