@pivotfinancialtechnologies/admin-frontend-blueprint-template 0.0.2-dev.9 → 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 +61 -60
- 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/{index.css → admin-frontend-blueprint-template.css} +1 -1
- package/dist/api-CzCTYMlh.js +81 -0
- package/dist/api-nTm6UPd6.cjs +1 -0
- package/dist/{utils → clipboard}/copy.d.ts +1 -1
- package/dist/clipboard/index.d.ts +1 -0
- package/dist/components/Data/BooleanTag/BooleanTag.d.ts +1 -1
- package/dist/components/Data/Datatable/Datatable.d.ts +1 -1
- package/dist/components/index.d.ts +2 -4
- package/dist/components.cjs +1 -0
- package/dist/components.d.ts +2 -0
- package/dist/components.js +14 -0
- package/dist/date-DxdnAP5U.js +13 -0
- package/dist/date-RB_2ERsI.cjs +1 -0
- package/dist/feedback/index.d.ts +1 -0
- package/dist/formatters/duration.d.ts +1 -0
- package/dist/formatters/index.d.ts +4 -0
- package/dist/formatters/money.d.ts +3 -0
- package/dist/formatters/phone.d.ts +1 -0
- package/dist/formatters.cjs +1 -0
- package/dist/formatters.d.ts +2 -0
- package/dist/formatters.js +12 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useSize.d.ts +5 -0
- package/dist/hooks/useUrlForm.d.ts +5 -0
- package/dist/hooks.cjs +1 -0
- package/dist/hooks.d.ts +2 -0
- package/dist/hooks.js +6 -0
- package/dist/http/api.d.ts +49 -0
- package/dist/http/index.d.ts +2 -0
- package/dist/http/query.d.ts +5 -0
- package/dist/http.cjs +1 -0
- package/dist/http.d.ts +2 -0
- package/dist/http.js +11 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +8 -2
- package/dist/index.js +49 -4535
- package/dist/layout/index.d.ts +4 -0
- package/dist/layout.cjs +1 -0
- package/dist/layout.d.ts +2 -0
- package/dist/layout.js +7 -0
- package/dist/phone-DmQ5SK-X.cjs +1 -0
- package/dist/phone-DtDgQ5qk.js +27 -0
- package/dist/query-Br3l_kxt.cjs +1 -0
- package/dist/query-CherHJOV.js +17 -0
- package/dist/{components/Security → security}/PermissionVisibility.d.ts +4 -2
- package/dist/security/index.d.ts +3 -0
- package/dist/security.cjs +1 -0
- package/dist/security.d.ts +2 -0
- package/dist/security.js +6 -0
- package/dist/toast-B3QUItIK.js +10 -0
- package/dist/toast-CCrs9yfw.cjs +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/{components/Data/Pagination.d.ts → types/pagination.d.ts} +2 -2
- package/dist/useSize-BLbsGFVL.cjs +1 -0
- package/dist/useSize-Ci0PbN9W.js +15 -0
- package/dist/useUrlForm-BYTOPBsx.js +26 -0
- package/dist/useUrlForm-CxnAS6tK.cjs +1 -0
- package/package.json +62 -9
- package/dist/components/Data/utils.d.ts +0 -5
- package/dist/index.umd.cjs +0 -14
- package/dist/layouts/index.d.ts +0 -3
- package/dist/utils/http.d.ts +0 -4
- package/dist/utils/index.d.ts +0 -6
- package/dist/utils/useUrlForm.d.ts +0 -4
- /package/dist/{utils → feedback}/toast.d.ts +0 -0
- /package/dist/{utils/formatters.d.ts → formatters/date.d.ts} +0 -0
- /package/dist/{layouts → layout}/ThemeSwitch/ThemeSwitch.d.ts +0 -0
- /package/dist/{layouts → layout}/TopBarNavLayout/TopBarNavLayout.d.ts +0 -0
- /package/dist/{layouts → layout}/Topbar/Topbar.d.ts +0 -0
- /package/dist/{utils → layout}/theme.d.ts +0 -0
- /package/dist/{components/Security → security}/AuthRoute.d.ts +0 -0
- /package/dist/{components/Security → security}/UnAuthRoute.d.ts +0 -0
package/README.md
CHANGED
|
@@ -1,73 +1,74 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Admin Frontend Blueprint Template
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A reusable React component and utility library for admin frontends built with Blueprint.js 6.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Requirements
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/)
|
|
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.
|
|
9
8
|
|
|
10
|
-
|
|
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.
|
|
11
10
|
|
|
12
|
-
|
|
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):
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
```css
|
|
14
|
+
@import "tailwindcss";
|
|
15
|
+
@source "../node_modules/@pivotfinancialtechnologies/admin-frontend-blueprint-template";
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Install and use
|
|
15
19
|
|
|
16
|
-
|
|
20
|
+
Install this package and its peer dependencies in the consuming app, then import the public API from the package root:
|
|
17
21
|
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
```tsx
|
|
23
|
+
import {
|
|
24
|
+
AuthRoute,
|
|
25
|
+
Datatable,
|
|
26
|
+
Topbar,
|
|
27
|
+
formatDateTime,
|
|
28
|
+
} from "@pivotfinancialtechnologies/admin-frontend-blueprint-template";
|
|
29
|
+
```
|
|
25
30
|
|
|
26
|
-
|
|
27
|
-
tseslint.configs.recommendedTypeChecked,
|
|
28
|
-
// Alternatively, use this for stricter rules
|
|
29
|
-
tseslint.configs.strictTypeChecked,
|
|
30
|
-
// Optionally, add this for stylistic rules
|
|
31
|
-
tseslint.configs.stylisticTypeChecked,
|
|
31
|
+
Import by domain when you want a smaller public surface:
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
// other options...
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
])
|
|
33
|
+
```ts
|
|
34
|
+
import { createHttpQueryParams, createApiBaseQuery } from "@pivotfinancialtechnologies/admin-frontend-blueprint-template/http";
|
|
35
|
+
import { formatDateTime, formatCurrency, formatPhone, formatDateDuration } from "@pivotfinancialtechnologies/admin-frontend-blueprint-template/formatters";
|
|
36
|
+
import { Datatable } from "@pivotfinancialtechnologies/admin-frontend-blueprint-template/components";
|
|
37
|
+
import { AuthRoute } from "@pivotfinancialtechnologies/admin-frontend-blueprint-template/security";
|
|
38
|
+
import { Topbar } from "@pivotfinancialtechnologies/admin-frontend-blueprint-template/layout";
|
|
39
|
+
import { useUrlForm } from "@pivotfinancialtechnologies/admin-frontend-blueprint-template/hooks";
|
|
44
40
|
```
|
|
45
41
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
{
|
|
56
|
-
files: ['**/*.{ts,tsx}'],
|
|
57
|
-
extends: [
|
|
58
|
-
// Other configs...
|
|
59
|
-
// Enable lint rules for React
|
|
60
|
-
reactX.configs['recommended-typescript'],
|
|
61
|
-
// Enable lint rules for React DOM
|
|
62
|
-
reactDom.configs.recommended,
|
|
63
|
-
],
|
|
64
|
-
languageOptions: {
|
|
65
|
-
parserOptions: {
|
|
66
|
-
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
67
|
-
tsconfigRootDir: import.meta.dirname,
|
|
68
|
-
},
|
|
69
|
-
// other options...
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
])
|
|
42
|
+
URL-synced forms and table sizing hooks live under `./hooks`. Toasts reuse a single OverlayToaster instance.
|
|
43
|
+
|
|
44
|
+
`createApiBaseQuery` is a fetch helper compatible with RTK Query `baseQuery`. Pass `getBaseUrl` and `onUnauthorized` from the host app instead of baking in env vars or auth slices:
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
const baseQuery = createApiBaseQuery({
|
|
48
|
+
getBaseUrl: () => import.meta.env.VITE_API_URL ?? "",
|
|
49
|
+
onUnauthorized: () => store.dispatch(logOut()),
|
|
50
|
+
});
|
|
73
51
|
```
|
|
52
|
+
|
|
53
|
+
`PermissionVisibility` matches any required permission by default; set `matchMode="all"` to require every listed permission. An empty required-permission list or missing granted permissions renders the fallback.
|
|
54
|
+
|
|
55
|
+
## Styles
|
|
56
|
+
|
|
57
|
+
Import Blueprint's styles and the stylesheet emitted by this package's library build once in the consuming app:
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import "@blueprintjs/core/lib/css/blueprint.css";
|
|
61
|
+
import "@blueprintjs/icons/lib/css/blueprint-icons.css";
|
|
62
|
+
import "@blueprintjs/select/lib/css/blueprint-select.css";
|
|
63
|
+
import "@blueprintjs/table/lib/css/table.css";
|
|
64
|
+
import "@pivotfinancialtechnologies/admin-frontend-blueprint-template/styles.css";
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`Topbar` and `TopBarNavLayout` keep the navigation bar in normal document flow; the title, navigation, and controls wrap on narrow screens.
|
|
68
|
+
|
|
69
|
+
## Development
|
|
70
|
+
|
|
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.
|
|
73
|
+
- `npm run lint` runs ESLint.
|
|
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;
|