aa-geuthur-react 0.0.0-stage → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +234 -2
  3. package/dist/Api/Api.d.ts +9 -0
  4. package/dist/Api/basePaths.d.ts +34 -0
  5. package/dist/Api/calls.d.ts +10 -0
  6. package/dist/Api/index.d.ts +5 -0
  7. package/dist/Api/query.d.ts +6 -0
  8. package/dist/Api/types.d.ts +45 -0
  9. package/dist/Components/Base/BaseHeader.d.ts +7 -0
  10. package/dist/Components/Base/BaseModal/BaseModal.d.ts +11 -0
  11. package/dist/Components/Base/BaseModal/BaseModalProps.d.ts +101 -0
  12. package/dist/Components/Base/BaseModal/BaseModalQuery.d.ts +10 -0
  13. package/dist/Components/Base/BaseModal/index.d.ts +3 -0
  14. package/dist/Components/Base/BaseModal/useModalState.d.ts +7 -0
  15. package/dist/Components/Base/BaseTable/BaseTable.d.ts +63 -0
  16. package/dist/Components/Base/BaseTable/BaseTableFilter.d.ts +25 -0
  17. package/dist/Components/Base/BaseTable/BaseTableForm.d.ts +6 -0
  18. package/dist/Components/Base/BaseTable/BaseTableHeader.d.ts +8 -0
  19. package/dist/Components/Base/BaseTable/BaseTablePages.d.ts +11 -0
  20. package/dist/Components/Base/BaseTable/BaseTableToolbar.d.ts +6 -0
  21. package/dist/Components/Base/BaseTable/index.d.ts +8 -0
  22. package/dist/Components/Base/BaseTable/tableFeatures.d.ts +89 -0
  23. package/dist/Components/Base/BaseTable/tableHelper.d.ts +8 -0
  24. package/dist/Components/Base/Loader/ErrorBoundary.d.ts +9 -0
  25. package/dist/Components/Base/Loader/ErrorLoader.d.ts +11 -0
  26. package/dist/Components/Base/Loader/FetchingLoader.d.ts +10 -0
  27. package/dist/Components/Base/Loader/index.d.ts +4 -0
  28. package/dist/Components/Base/index.d.ts +11 -0
  29. package/dist/Hooks/index.d.ts +3 -0
  30. package/dist/Hooks/useCooldown.d.ts +16 -0
  31. package/dist/Hooks/useFeedback.d.ts +13 -0
  32. package/dist/Hooks/useUserData.d.ts +4 -0
  33. package/dist/Menu/AuthLeftMenu.d.ts +4 -0
  34. package/dist/Menu/AuthLeftMenuAsync.d.ts +3 -0
  35. package/dist/Menu/AuthRightMenu.d.ts +4 -0
  36. package/dist/Menu/AuthRightMenuAsync.d.ts +3 -0
  37. package/dist/Menu/BaseMenu.d.ts +26 -0
  38. package/dist/Menu/Hooks/index.d.ts +1 -0
  39. package/dist/Menu/Hooks/useMenu.d.ts +2 -0
  40. package/dist/Menu/index.d.ts +6 -0
  41. package/dist/Pages/404.d.ts +1 -0
  42. package/dist/Pages/Base.d.ts +13 -0
  43. package/dist/Pages/index.d.ts +3 -0
  44. package/dist/Provider.d.ts +13 -0
  45. package/dist/Utils/bootsTrap.d.ts +14 -0
  46. package/dist/Utils/eveOnline.d.ts +66 -0
  47. package/dist/Utils/format.d.ts +44 -0
  48. package/dist/Utils/general.d.ts +27 -0
  49. package/dist/Utils/index.d.ts +4 -0
  50. package/dist/aa-geuthur-react.css +2 -0
  51. package/dist/i18n.d.ts +4 -0
  52. package/dist/index.d.ts +8 -0
  53. package/dist/index.js +1183 -0
  54. package/dist/index.js.map +1 -0
  55. package/eslint-rules/import-headings.js +167 -0
  56. package/i18n/de/aa-geuthur-react.json +34 -0
  57. package/i18n/en/aa-geuthur-react.json +34 -0
  58. package/i18n/es/aa-geuthur-react.json +35 -0
  59. package/i18n/fr-FR/aa-geuthur-react.json +35 -0
  60. package/i18n/it-IT/aa-geuthur-react.json +35 -0
  61. package/i18n/ja/aa-geuthur-react.json +33 -0
  62. package/i18n/ko-KR/aa-geuthur-react.json +33 -0
  63. package/i18n/nl-NL/aa-geuthur-react.json +34 -0
  64. package/i18n/pl-PL/aa-geuthur-react.json +36 -0
  65. package/i18n/ru/aa-geuthur-react.json +36 -0
  66. package/i18n/uk/aa-geuthur-react.json +36 -0
  67. package/i18n/zh-Hans/aa-geuthur-react.json +33 -0
  68. package/package.json +106 -4
package/README.md CHANGED
@@ -1,3 +1,235 @@
1
- # Temporary Holding Version
1
+ # AA Geuthur React<a name="aa-geuthur-react"></a>
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm](https://img.shields.io/npm/v/aa-geuthur-react)](https://www.npmjs.com/package/aa-geuthur-react)
4
+ [![Checks](https://github.com/Geuthur/aa-geuthur-react/actions/workflows/checks.yml/badge.svg)](https://github.com/Geuthur/aa-geuthur-react/actions/workflows/checks.yml)
5
+ [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
6
+
7
+ Shared React base for the [Alliance Auth](https://gitlab.com/allianceauth/allianceauth) apps by Geuthur: the table and modal components, loaders, the navigation menu, hooks, the page layout and the API client that every app with a React frontend uses. The apps install the package and extend it instead of copying the files.
8
+
9
+ ______________________________________________________________________
10
+
11
+ <!-- mdformat-toc start --slug=github --maxlevel=6 --minlevel=1 -->
12
+
13
+ - [AA Geuthur React](#aa-geuthur-react)
14
+ - [Installation](#installation)
15
+ - [Setup](#setup)
16
+ - [Provider and routing](#provider-and-routing)
17
+ - [Styles](#styles)
18
+ - [Translations](#translations)
19
+ - [API client](#api-client)
20
+ - [ESLint rule](#eslint-rule)
21
+ - [Components](#components)
22
+ - [BaseTable](#basetable)
23
+ - [BaseModal](#basemodal)
24
+ - [Loaders](#loaders)
25
+ - [BaseSectionHeader](#basesectionheader)
26
+ - [Menu](#menu)
27
+ - [Pages](#pages)
28
+ - [Hooks](#hooks)
29
+ - [Utils](#utils)
30
+ - [Types of the API contract](#types-of-the-api-contract)
31
+ - [Extending instead of copying](#extending-instead-of-copying)
32
+ - [Development](#development)
33
+ - [Release](#release)
34
+ - [Contributing](#contributing)
35
+
36
+ <!-- mdformat-toc end -->
37
+
38
+ ## Installation<a name="installation"></a>
39
+
40
+ ```shell
41
+ npm install aa-geuthur-react
42
+ ```
43
+
44
+ The package is built only at build time of the app, the users of the app get the compiled frontend inside the Python package. It ships ESM with type declarations and expects these peer dependencies in the app: `react`, `react-dom`, `react-bootstrap`, `react-router-dom`, `@tanstack/react-query`, `@tanstack/react-table`, `react-i18next`, `i18next`, `lucide-react`, `js-cookie`, `nuqs` and `openapi-fetch`.
45
+
46
+ ## Setup<a name="setup"></a>
47
+
48
+ ### Provider and routing<a name="provider-and-routing"></a>
49
+
50
+ The menus, hooks and pages need the names of the app. Wrap the routing with `AaReactProvider`:
51
+
52
+ ```tsx
53
+ import { AaReactProvider, AuthBase, ErrorPage } from "aa-geuthur-react";
54
+
55
+ <AaReactProvider projectName="example" appName="aa-example">
56
+ <QueryClientProvider client={queryClient}>
57
+ <BrowserRouter>
58
+ <Routes>
59
+ <Route path="/example/" element={<AuthBase />}>
60
+ <Route index element={<MainPage />} />
61
+ <Route path="*" element={<ErrorPage />} />
62
+ </Route>
63
+ </Routes>
64
+ </BrowserRouter>
65
+ </QueryClientProvider>
66
+ </AaReactProvider>;
67
+ ```
68
+
69
+ - `projectName` is the URL prefix of the app (`/example/api/menu/`).
70
+ - `appName` is the name of the package (`aa-example`).
71
+ - `useAaReact()` returns both inside the provider and throws outside of it.
72
+
73
+ ### Styles<a name="styles"></a>
74
+
75
+ The components use Bootstrap utilities and a few global classes (`aa-table-*`, `aa-react.container`, `aa-shake`, `aa-menu-badge-pulse`, `aa-nav-danger`, `aa-tooltip`). Import the stylesheet once, before the stylesheet of the app so the app can override it:
76
+
77
+ ```ts
78
+ import "aa-geuthur-react/styles.css";
79
+ import "@/Styles/index.css";
80
+ ```
81
+
82
+ ### Translations<a name="translations"></a>
83
+
84
+ Every text of the package lives in the i18next namespace `aa-geuthur-react`. The package ships `i18n/<lng>/aa-geuthur-react.json` for 12 languages (`en`, `de`, `es`, `fr-FR`, `it-IT`, `ja`, `ko-KR`, `nl-NL`, `pl-PL`, `ru`, `uk`, `zh-Hans`). The app copies the file next to its own `translation.json` into the static directory and loads namespaces by name:
85
+
86
+ ```ts
87
+ i18n.use(Backend).use(initReactI18next).init({
88
+ ns: ["translation", "aa-geuthur-react"],
89
+ defaultNS: "translation",
90
+ backend: {
91
+ loadPath: `/static/${ProjectName}/i18n/{{lng}}/{{ns}}.json`,
92
+ },
93
+ });
94
+ ```
95
+
96
+ The constants `I18N_NAMESPACE` (`aa-geuthur-react`) and `I18N_FALLBACK_NAMESPACE` (`translation`) are exported. Menu link names come from the app, so the menu tries the package namespace first and the namespace of the app second.
97
+
98
+ ### API client<a name="api-client"></a>
99
+
100
+ `createApiClient<paths>()` creates an [openapi-fetch](https://openapi-ts.dev/openapi-fetch/) client with `baseUrl: "/"`, `credentials: "same-origin"` and the Django CSRF token (`csrftoken` cookie) as `X-CSRFToken` header. The app passes the `paths` type generated from its OpenAPI schema:
101
+
102
+ ```ts
103
+ import { createApiClient } from "aa-geuthur-react";
104
+ import type { paths } from "@/Api/OpenApi";
105
+
106
+ export const apiClient = createApiClient<paths>();
107
+ ```
108
+
109
+ `loadMenu(projectName)` and `loadUserData(projectName)` call the endpoints every app provides (`<project>/api/menu/` and `<project>/api/user/`) and are used by `useMenu` and `useUserData`. `queryKeys` holds the query keys `Menu`, `User` and `UserSettings`.
110
+
111
+ ### ESLint rule<a name="eslint-rule"></a>
112
+
113
+ The rule `import-headings` groups imports under heading comments like isort does. In `eslint.config.js` of the app:
114
+
115
+ ```js
116
+ import importHeadingsRule from "aa-geuthur-react/eslint-rules/import-headings";
117
+
118
+ const importHeadingsPlugin = { rules: { "import-headings": importHeadingsRule } };
119
+ // plugins: { "import-headings": importHeadingsPlugin }
120
+ // rules: { "import-headings/import-headings": ["error", { groups: [{ heading: "// React", pattern: "^react($|/)" }, ...] }] }
121
+ ```
122
+
123
+ ## Components<a name="components"></a>
124
+
125
+ ### BaseTable<a name="basetable"></a>
126
+
127
+ Sortable, filterable and paginated table on [TanStack Table v9](https://tanstack.com/table/v9) with CSV export.
128
+
129
+ ```tsx
130
+ import { BaseTable, createBaseColumnHelper } from "aa-geuthur-react";
131
+
132
+ const columnHelper = createBaseColumnHelper<Row>();
133
+ const columns = [columnHelper.accessor("name", { header: "Name" })];
134
+
135
+ <BaseTable columns={columns} data={rows} />;
136
+ ```
137
+
138
+ | Prop | Description |
139
+ | :-------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------ |
140
+ | `columns`, `data` | Column definitions (`BaseColumnDef`) and rows |
141
+ | `isLoading`, `loadingText`, `isFetching`, `isError` | Loading state (dims the rows and locks the controls), refresh indicator and error row |
142
+ | `serverPagination` | `{ page, pageSize, total, onPageChange, onPageSizeChange, totalText? }`: the server pages the rows; sorting, filters and CSV export are off |
143
+ | `initialState`, `pageSizeOptions`, `enableFilters`, `striped`, `hover`, `variant` (`default`, `light`), `debugTable` | Table options |
144
+ | `rowSelection`, `onRowSelectionChange`, `enableRowSelection`, `getRowId`, `onRowClick`, `getRowClassName` | Row selection and row handlers |
145
+ | `emptyText`, `emptyState`, `toolbar`, `footer`, `showFooter` | Empty row text or element, slot above the table, slot below the page controls, column `footer` definitions as summary row |
146
+ | `className`, `tableClassName`, `headerClassName`, `bodyClassName`, `rowClassName`, `footClassName`, `footerClassName` | Extra classes for the shell, `<table>`, `<thead>`, `<tbody>`, every row, the `<tfoot>` summary row and the footer with page size, status and pagination |
147
+ | `exportFileName` | File name of the CSV export |
148
+
149
+ Column `meta` supports `align` (`left`, `right`, `center`) and `filterOptionLabel` for the select filter. Also exported: `BaseTableHeader`, `BaseTablePages`, `BaseTableForm`, `BaseToolbar`, the filters (`Filter`, `TextFilter`, `SelectFilter`, `NumberFilter`, `BoolFilter`), `baseTableFeatures`, `exportToCSV`.
150
+
151
+ ### BaseModal<a name="basemodal"></a>
152
+
153
+ Bootstrap modal in two variants. Both share `size` (`ModalSize`), `centered`, `scrollable`, `backdrop`, `restoreFocus`, `closeButton`, `closeText`, `closeVariant`, `className`, `bodyClassName`, `titleClassName`, `onShow`, `onEnter`, `onExited`.
154
+
155
+ - Default: `show`, `onHide`, `title`, `children`, `footer` (replaces the close button), `hideFooter`.
156
+ - Confirm (`variant="confirm"`): `data` (`ModalData`), `showModal`, `setShowModal`, `onApprove({ url, formData })`, `isPending`, `validate`, `initialFormData`, `title`, `confirmText`, `confirmVariant`; `children` may be a render function `({ formData, onChange }) => ...` for a form.
157
+
158
+ `useApproveMutation(queryKey)` and `useFormApproveMutation(queryKey)` post to the modal URL and invalidate the given queries. `useModalQueryState(modalKey, entityKey)` keeps the open modal and entity id in the URL with [nuqs](https://nuqs.dev/).
159
+
160
+ ### Loaders<a name="loaders"></a>
161
+
162
+ - `FetchingLoader`: centered spinner; `message`, `className`, `spinnerClassName`.
163
+ - `ErrorLoader`: warning icon; `title`, `message`, `className`, `iconClassName`.
164
+ - `ErrorBoundary`: catches render errors of its children and shows error and component stack; `traceClassName`.
165
+
166
+ ### BaseSectionHeader<a name="basesectionheader"></a>
167
+
168
+ Card header with a title (`name`) and buttons or badges as `children`.
169
+
170
+ ### Menu<a name="menu"></a>
171
+
172
+ - `AuthLeftMenuAsync` and `AuthRightMenuAsync` load the menu with `useMenu` and render the links into the `nav-left` and `nav-right` elements of the Alliance Auth template.
173
+ - `AuthLeftMenu` and `AuthRightMenu` render given links (`data`, `isLoading`, `error`).
174
+ - `MenuItem` renders one link: internal links as router links below the project prefix, external links as `href`, a `badge` count in red (pulsing while `has_errors` is set). A link to `administration` renders as `AdministrationMenuItem` with a shield icon.
175
+ - `toProjectPath(projectName, link)` builds the route of a link.
176
+
177
+ ### Pages<a name="pages"></a>
178
+
179
+ - `AuthBase`: layout of a page; renders the menus and the routed page (`Outlet`, or `children`) inside the `aa-react container` wrapper (640px to 1280px wide) with an `ErrorBoundary`. `className` adds classes to the wrapper.
180
+ - `ErrorPage`: 404 page.
181
+
182
+ ## Hooks<a name="hooks"></a>
183
+
184
+ - `useUserData()`: the current user (`{ user: UserData }`), cached for 5 minutes.
185
+ - `useMenu()`: the menu links (`MenuSchema`), one retry.
186
+ - `useCooldown()`: `{ seconds, start(duration) }`, counts down once per second.
187
+ - `useOwnerCooldowns()`: `{ cooldowns, start(ownerId, duration) }`, one cooldown per owner id.
188
+ - `useFeedback(timeoutMs)`: `{ feedback, showFeedback(variant, text), clearFeedback() }`, clears itself after the timeout.
189
+
190
+ ## Utils<a name="utils"></a>
191
+
192
+ - `format`: `formatDate`, `formatRelativeTime`, `formatEta`, `formatNumber`, `formatCompactNumber`, `formatIsk` (locale from i18next, `en` fallback).
193
+ - `eveOnline`: `shipImageUrl`, `characterImageUrl`, `corporationImageUrl`, `allianceImageUrl`, `itemImageUrl`, `getSecColor`, `formatEveTime`, `zKillboardLink`, `renderCharacterPortrait`.
194
+ - `bootsTrap`: `renderTooltip(message, children)`, `toolTipContainer(message)`.
195
+ - `general`: `renderLink`, `renderShipImage`, `renderHtml`.
196
+
197
+ ## Types of the API contract<a name="types-of-the-api-contract"></a>
198
+
199
+ The package defines the types of the endpoints every app provides and does not use the generated OpenAPI types of an app: `MenuLink`, `MenuSchema`, `UserData`, `UserSettings`, `UserSettingsUpdateRequest`, `ModalSchema` (`ModalData`), `ErrorSchema`, `ActionResponse`. The Ninja schemas of the apps follow these types; both change together.
200
+
201
+ ## Extending instead of copying<a name="extending-instead-of-copying"></a>
202
+
203
+ 1. The files of this package are never changed in an app. What an app needs differently is built in the app by wrapping or composing: `const LedgerTable = (props) => <BaseTable showFooter {...props} />`.
204
+ 1. Overrides come from outside: every component takes `className` props per area and slots (`toolbar`, `footer`, `emptyState`). Bootstrap classes of the app override the look without touching the package.
205
+ 1. A new capability comes into this package as a pull request, as an opt-in prop with the current behaviour as default. Then a release and a Dependabot bump in every app. No app runs a special version.
206
+ 1. Contracts are types: the package defines `MenuLink`, `MenuSchema`, `UserData` and `UserSettings`; the Python side delivers matching schemas.
207
+
208
+ ## Development<a name="development"></a>
209
+
210
+ ```shell
211
+ npm ci
212
+ make lint # ESLint and Stylelint
213
+ make test # Vitest
214
+ make build # types and ESM bundle into dist/
215
+ make translations
216
+ ```
217
+
218
+ `make` lists every target. The tests live in `src/__tests__/`, the test of the ESLint rule in `eslint-rules/`.
219
+
220
+ ## Release<a name="release"></a>
221
+
222
+ 1. `make prepare-release`: scans the translations, moves the changelog entries into a version section and sets the version in `package.json` and `package-lock.json`.
223
+ 1. Merge the `[RELEASE]` pull request.
224
+ 1. Create the tag `v<version>` and a GitHub release. The `Release` workflow checks that the version matches the tag, runs lint, tests and build, attaches the tarball to the release and publishes to npm with [trusted publishing](https://docs.npmjs.com/trusted-publishers) (OIDC from GitHub Actions, no token). The trusted publisher on npmjs.com is this repository with the workflow `release.yml` and the environment `npm-release`.
225
+
226
+ Translations: [![Translations](https://weblate.geuthur.de/widget/allianceauth/aa-geuthur-react/multi-auto.svg)](https://weblate.geuthur.de/engage/allianceauth/)
227
+
228
+ ## Contributing<a name="contributing"></a>
229
+
230
+ You want to improve the project?
231
+ Please ensure you read the [Contribution Guidelines]
232
+
233
+ <!-- MD Links -->
234
+
235
+ [contribution guidelines]: https://github.com/Geuthur/aa-geuthur-react/blob/master/CONTRIBUTING.md "Contribution Guidelines"
@@ -0,0 +1,9 @@
1
+ import { ClientOptions } from 'openapi-fetch';
2
+ /**
3
+ * Creates an `openapi-fetch` client for the API of the app that sends the Django CSRF token
4
+ * (`csrftoken` cookie) as `X-CSRFToken` header with every request.
5
+ *
6
+ * The app passes the `paths` type generated from its OpenAPI schema:
7
+ * `export const apiClient = createApiClient<paths>();`
8
+ */
9
+ export declare function createApiClient<Paths extends object>(options?: ClientOptions): import('openapi-fetch').Client<Paths, `${string}/${string}`>;
@@ -0,0 +1,34 @@
1
+ import { ErrorSchema, MenuSchema, UserData } from './types';
2
+ type JsonResponse<T> = {
3
+ headers: {
4
+ [name: string]: unknown;
5
+ };
6
+ content: {
7
+ "application/json": T;
8
+ };
9
+ };
10
+ type ProjectGet<T> = {
11
+ parameters: {
12
+ query?: never;
13
+ header?: never;
14
+ path: {
15
+ project: string;
16
+ };
17
+ cookie?: never;
18
+ };
19
+ requestBody?: never;
20
+ responses: {
21
+ 200: JsonResponse<T>;
22
+ 403: JsonResponse<ErrorSchema>;
23
+ };
24
+ };
25
+ /** The endpoints every app provides, with the app's URL prefix as path parameter. */
26
+ export interface BasePaths {
27
+ "/{project}/api/menu/": {
28
+ get: ProjectGet<MenuSchema>;
29
+ };
30
+ "/{project}/api/user/": {
31
+ get: ProjectGet<UserData>;
32
+ };
33
+ }
34
+ export {};
@@ -0,0 +1,10 @@
1
+ import { BasePaths } from './basePaths';
2
+ import { MenuSchema, UserData } from './types';
3
+ /** Client for the endpoints every app provides (`menu/`, `user/`). */
4
+ export declare const baseApiClient: import('openapi-fetch').Client<BasePaths, `${string}/${string}`>;
5
+ /** Loads the menu links of the app. */
6
+ export declare function loadMenu(projectName: string): Promise<MenuSchema>;
7
+ /** Loads the current user of the app. */
8
+ export declare function loadUserData(projectName: string): Promise<{
9
+ user: UserData;
10
+ }>;
@@ -0,0 +1,5 @@
1
+ export * from './Api';
2
+ export * from './calls';
3
+ export * from './query';
4
+ export type * from './basePaths';
5
+ export type * from './types';
@@ -0,0 +1,6 @@
1
+ /** Query keys of the endpoints every app provides. Apps add their own keys next to them. */
2
+ export declare const queryKeys: {
3
+ Menu: readonly ["Menu"];
4
+ User: readonly ["User"];
5
+ UserSettings: readonly ["UserSettings"];
6
+ };
@@ -0,0 +1,45 @@
1
+ import { ModalData } from '../Components/Base/BaseModal/BaseModalProps';
2
+ /** A link in the Alliance Auth menu, delivered by the `menu/` endpoint of the app. */
3
+ export interface MenuLink {
4
+ name: string;
5
+ link?: string;
6
+ is_external?: boolean;
7
+ /** Number of issues shown as badge next to the link. */
8
+ badge?: number | null;
9
+ /** Whether the badge pulses because of active errors. */
10
+ has_errors?: boolean;
11
+ }
12
+ /** The menu of the app: links left and right of the navigation bar. */
13
+ export interface MenuSchema {
14
+ left_links: MenuLink[];
15
+ right_links: MenuLink[];
16
+ }
17
+ /** The current user as delivered by the `user/` endpoint of the app. */
18
+ export interface UserData {
19
+ user_id: number;
20
+ character_id: number;
21
+ character_name: string;
22
+ corporation_id: number;
23
+ corporation_name: string;
24
+ alliance_id?: number | null;
25
+ alliance_name?: string | null;
26
+ portrait?: string | null;
27
+ is_admin: boolean;
28
+ }
29
+ /** The settings of the current user as delivered by the `settings/` endpoint of the app. */
30
+ export interface UserSettings {
31
+ disable_notifications: boolean;
32
+ }
33
+ /** Request body of `PUT settings/`. */
34
+ export type UserSettingsUpdateRequest = UserSettings;
35
+ /** Data of a modal dialog delivered by the API (`ModalSchema` of the app). */
36
+ export type ModalSchema = ModalData;
37
+ /** Error body of the API endpoints. */
38
+ export interface ErrorSchema {
39
+ error: string;
40
+ }
41
+ /** Response of an action endpoint. */
42
+ export interface ActionResponse {
43
+ success: boolean;
44
+ message: string;
45
+ }
@@ -0,0 +1,7 @@
1
+ import { ReactNode } from 'react';
2
+ export interface BaseSectionHeaderProps {
3
+ name?: string;
4
+ children?: ReactNode;
5
+ }
6
+ declare function BaseSectionHeader({ name, children }: BaseSectionHeaderProps): import('react').JSX.Element;
7
+ export default BaseSectionHeader;
@@ -0,0 +1,11 @@
1
+ import { BaseModalProps } from './BaseModalProps';
2
+ /**
3
+ * BaseModal mit zwei Varianten:
4
+ * - `variant="default"` (Standard): normales Modal, Body = `children`, Footer = Schließen-Button.
5
+ * - `variant="confirm"`: Bestätigungs-Modal mit `onApprove`, optional Formular via Render-Children.
6
+ *
7
+ * Alle Darstellungs-Werte (size, centered, backdrop, ...) sind optional und
8
+ * fallen auf `MODAL_DEFAULTS` zurück.
9
+ */
10
+ declare function BaseModal(props: BaseModalProps): import('react').JSX.Element;
11
+ export default BaseModal;
@@ -0,0 +1,101 @@
1
+ import { ReactNode } from 'react';
2
+ import { ModalProps } from 'react-bootstrap';
3
+ export declare const ModalSize: {
4
+ readonly small: "sm";
5
+ readonly medium: any;
6
+ readonly large: "lg";
7
+ readonly extraLarge: "xl";
8
+ };
9
+ export type ModalSize = (typeof ModalSize)[keyof typeof ModalSize];
10
+ export type ModalData = {
11
+ title: string;
12
+ text: string;
13
+ icon: string;
14
+ modal_id: string;
15
+ url: string;
16
+ color?: string | null;
17
+ buttonText?: string | null;
18
+ };
19
+ export type ModalFormData = Record<string, string | boolean>;
20
+ /**
21
+ * Optionale Werte, die beide Varianten teilen.
22
+ * Alles, was nicht gesetzt wird, fällt auf `MODAL_DEFAULTS` zurück.
23
+ */
24
+ export interface BaseModalSharedProps {
25
+ /** Modal-Größe (Standard: `ModalSize.large`) */
26
+ size?: ModalSize;
27
+ /** Vertikal zentriert (Standard: `true`) */
28
+ centered?: boolean;
29
+ /** Body scrollbar statt ganzes Modal (Standard: `false`) */
30
+ scrollable?: boolean;
31
+ /** Backdrop-Verhalten, z.B. `"static"` (Standard: `true`) */
32
+ backdrop?: ModalProps["backdrop"];
33
+ /** Fokus beim Schließen zurückgeben (Standard: `false`) */
34
+ restoreFocus?: boolean;
35
+ /** "X" im Header anzeigen (Standard: `true`) */
36
+ closeButton?: boolean;
37
+ /** Text des Schließen-Buttons (Standard: `t("Close")`) */
38
+ closeText?: string;
39
+ /** Bootstrap-Variante des Schließen-Buttons (Standard: `"primary"`) */
40
+ closeVariant?: string;
41
+ /** Zusätzliche Klasse für das Modal-Dialog-Element */
42
+ className?: string;
43
+ /** Zusätzliche Klasse für den Modal-Body */
44
+ bodyClassName?: string;
45
+ /** Zusätzliche Klasse für den Modal-Titel (z.B. Icon + Text) */
46
+ titleClassName?: string;
47
+ /** Wird aufgerufen, sobald das Modal angezeigt wird */
48
+ onShow?: () => void;
49
+ /** Wird aufgerufen, kurz bevor das Modal eingeblendet wird */
50
+ onEnter?: () => void;
51
+ /** Wird aufgerufen, nachdem das Modal komplett ausgeblendet wurde */
52
+ onExited?: () => void;
53
+ }
54
+ /** Normales Modal: Titel + beliebige React-Children + Schließen-Button. */
55
+ export interface DefaultModalProps extends BaseModalSharedProps {
56
+ variant?: "default";
57
+ show: boolean;
58
+ onHide: () => void;
59
+ title: ReactNode;
60
+ children?: ReactNode;
61
+ /** Ersetzt den Standard-Footer (Schließen-Button) */
62
+ footer?: ReactNode;
63
+ /** Footer komplett ausblenden */
64
+ hideFooter?: boolean;
65
+ }
66
+ export type ConfirmModalChildren = ReactNode | ((props: {
67
+ formData: ModalFormData;
68
+ onChange: (data: ModalFormData) => void;
69
+ }) => ReactNode);
70
+ /** Bestätigungs-Modal: verarbeitet Daten (optional Formular) über `onApprove`. */
71
+ export interface ConfirmModalProps extends BaseModalSharedProps {
72
+ variant: "confirm";
73
+ data: ModalData;
74
+ showModal: boolean;
75
+ setShowModal: (show: boolean) => void;
76
+ onApprove: (data: {
77
+ url: string;
78
+ formData?: ModalFormData;
79
+ }) => Promise<unknown>;
80
+ isPending?: boolean;
81
+ validate?: (formData: ModalFormData) => boolean;
82
+ initialFormData?: ModalFormData;
83
+ /** Überschreibt `data.title` */
84
+ title?: ReactNode;
85
+ /** Überschreibt `data.buttonText` (Standard: `t("Confirm")`) */
86
+ confirmText?: string;
87
+ /** Überschreibt `data.color` (Standard: `"success"`) */
88
+ confirmVariant?: string;
89
+ children?: ConfirmModalChildren;
90
+ }
91
+ export type BaseModalProps = DefaultModalProps | ConfirmModalProps;
92
+ export declare const MODAL_DEFAULTS: {
93
+ readonly size: "lg";
94
+ readonly centered: true;
95
+ readonly scrollable: false;
96
+ readonly backdrop: true;
97
+ readonly restoreFocus: false;
98
+ readonly closeButton: true;
99
+ readonly closeVariant: "primary";
100
+ readonly confirmVariant: "success";
101
+ };
@@ -0,0 +1,10 @@
1
+ import { QueryKey } from '@tanstack/react-query';
2
+ type FormData = Record<string, string | boolean>;
3
+ /** Mutation für Delete / Update / Bestätigungen (ohne Body) */
4
+ export declare function useApproveMutation(queryKey?: QueryKey | QueryKey[]): import('@tanstack/react-query').UseMutationResult<any, Error, string, unknown>;
5
+ /** Mutation für Formulare (mit Formulardaten als URLSearchParams) */
6
+ export declare function useFormApproveMutation(queryKey?: QueryKey | QueryKey[]): import('@tanstack/react-query').UseMutationResult<any, Error, {
7
+ url: string;
8
+ formData?: FormData;
9
+ }, unknown>;
10
+ export {};
@@ -0,0 +1,3 @@
1
+ export { default as BaseModal } from './BaseModal';
2
+ export { default } from './BaseModal';
3
+ export * from './BaseModalProps';
@@ -0,0 +1,7 @@
1
+ export declare function useModalQueryState(modalKey?: string, entityKey?: string): {
2
+ activeModal: string;
3
+ activeEntityId: string;
4
+ openModal: (modalId: string, entityId?: string) => void;
5
+ closeModal: () => void;
6
+ setActiveModal: (value: string | ((old: string) => string), options?: import('nuqs').Options) => Promise<URLSearchParams>;
7
+ };
@@ -0,0 +1,63 @@
1
+ import { ReactNode } from 'react';
2
+ import { OnChangeFn, Row, RowData, RowSelectionState, TableState } from '@tanstack/react-table';
3
+ import { BaseColumnDef, BaseTableFeatures } from './tableFeatures';
4
+ export type BaseTableInitialState = {
5
+ [K in keyof TableState<BaseTableFeatures>]?: Partial<TableState<BaseTableFeatures>[K]>;
6
+ };
7
+ export interface BaseTableServerPagination {
8
+ page: number;
9
+ pageSize: number;
10
+ total: number;
11
+ onPageChange: (page: number) => void;
12
+ onPageSizeChange: (pageSize: number) => void;
13
+ totalText?: string;
14
+ }
15
+ export interface BaseTableProps<TData extends RowData, TValue = unknown> {
16
+ isFetching?: boolean;
17
+ isLoading?: boolean;
18
+ loadingText?: string;
19
+ serverPagination?: BaseTableServerPagination;
20
+ isError?: boolean;
21
+ debugTable?: boolean;
22
+ striped?: boolean;
23
+ hover?: boolean;
24
+ data?: TData[];
25
+ columns: BaseColumnDef<TData, TValue>[];
26
+ initialState?: BaseTableInitialState;
27
+ exportFileName?: string;
28
+ variant?: "default" | "light";
29
+ emptyText?: string;
30
+ /** Replaces `emptyText` with custom content when there are no rows. */
31
+ emptyState?: ReactNode;
32
+ /** Rendered above the table inside the shell, e.g. buttons or extra filters. */
33
+ toolbar?: ReactNode;
34
+ /** Rendered below the page controls inside the table footer. */
35
+ footer?: ReactNode;
36
+ /** Renders the `footer` of the column definitions as a summary row. */
37
+ showFooter?: boolean;
38
+ /** Extra classes for the shell around table and footer. */
39
+ className?: string;
40
+ /** Extra classes for the `<table>`. */
41
+ tableClassName?: string;
42
+ /** Extra classes for the `<thead>`. */
43
+ headerClassName?: string;
44
+ /** Extra classes for the `<tbody>`. */
45
+ bodyClassName?: string;
46
+ /** Extra classes for every data row; `getRowClassName` adds per-row classes. */
47
+ rowClassName?: string;
48
+ /** Extra classes for the `<tfoot>` summary row (`showFooter`). */
49
+ footClassName?: string;
50
+ /** Extra classes for the footer with page size, status and pagination. */
51
+ footerClassName?: string;
52
+ pageSizeOptions?: number[];
53
+ itemLabel?: string;
54
+ getRowClassName?: (row: Row<BaseTableFeatures, TData>) => string;
55
+ enableFilters?: boolean;
56
+ rowSelection?: RowSelectionState;
57
+ onRowSelectionChange?: OnChangeFn<RowSelectionState>;
58
+ enableRowSelection?: boolean | ((row: Row<BaseTableFeatures, TData>) => boolean);
59
+ getRowId?: (originalRow: TData, index: number, parent?: Row<BaseTableFeatures, TData>) => string;
60
+ onRowClick?: (row: Row<BaseTableFeatures, TData>) => void;
61
+ }
62
+ declare const BaseTable: <TData extends RowData, TValue = unknown>({ isFetching, isLoading, loadingText, serverPagination, isError, debugTable, data, columns, initialState, exportFileName, variant, emptyText, emptyState, toolbar, footer, showFooter, className, tableClassName, headerClassName, bodyClassName, rowClassName, footClassName, footerClassName, pageSizeOptions, getRowClassName, enableFilters, rowSelection, onRowSelectionChange, enableRowSelection, getRowId, onRowClick, }: BaseTableProps<TData, TValue>) => import('react').JSX.Element;
63
+ export default BaseTable;
@@ -0,0 +1,25 @@
1
+ import { CellData, Column, RowData, Table as ReactTable, TableFeatures } from '@tanstack/react-table';
2
+ import { BaseTableFeatures } from './tableFeatures';
3
+ declare module "@tanstack/react-table" {
4
+ interface ColumnMeta<TFeatures extends TableFeatures, TData extends RowData, TValue extends CellData = CellData> {
5
+ filterOptionLabel?: (value: string) => string;
6
+ align?: "left" | "right" | "center";
7
+ }
8
+ }
9
+ export declare const NumberFilter: <TData extends RowData>({ column }: {
10
+ column: Column<BaseTableFeatures, TData, unknown>;
11
+ }) => import('react').JSX.Element;
12
+ export declare const BoolFilter: <TData extends RowData>({ column }: {
13
+ column: Column<BaseTableFeatures, TData, unknown>;
14
+ }) => import('react').JSX.Element;
15
+ export declare const TextFilter: <TData extends RowData>({ column }: {
16
+ column: Column<BaseTableFeatures, TData, unknown>;
17
+ }) => import('react').JSX.Element;
18
+ export declare const SelectFilter: <TData extends RowData>({ column }: {
19
+ column: Column<BaseTableFeatures, TData, unknown>;
20
+ }) => import('react').JSX.Element;
21
+ export declare const Filter: <TData extends RowData>({ column, table, }: {
22
+ column: Column<BaseTableFeatures, TData, unknown>;
23
+ table: ReactTable<BaseTableFeatures, TData>;
24
+ }) => import('react').JSX.Element;
25
+ export default Filter;
@@ -0,0 +1,6 @@
1
+ import { RowData, Table as TanStackTable } from '@tanstack/react-table';
2
+ import { BaseTableFeatures } from './tableFeatures';
3
+ export interface BaseTableFormProps<TData extends RowData> {
4
+ table: TanStackTable<BaseTableFeatures, TData>;
5
+ }
6
+ export declare function BaseTableForm<TData extends RowData>({ table }: BaseTableFormProps<TData>): import('react').JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { RowData, Table as TanStackTable } from '@tanstack/react-table';
2
+ import { BaseTableFeatures } from './tableFeatures';
3
+ export interface TableHeaderProps<TData extends RowData> {
4
+ table: TanStackTable<BaseTableFeatures, TData>;
5
+ enableFilters?: boolean;
6
+ }
7
+ declare function BaseHeader<TData extends RowData>({ table, enableFilters }: TableHeaderProps<TData>): import('react').JSX.Element;
8
+ export default BaseHeader;
@@ -0,0 +1,11 @@
1
+ import { RowData, Table as TanStackTable } from '@tanstack/react-table';
2
+ import { BaseTableFeatures } from './tableFeatures';
3
+ export interface TablePagesProps<TData extends RowData> {
4
+ table: TanStackTable<BaseTableFeatures, TData>;
5
+ isFetching?: boolean;
6
+ fileName?: string;
7
+ showPageNumber?: boolean;
8
+ showExport?: boolean;
9
+ }
10
+ declare const BasePages: <TData extends RowData>({ table, isFetching, fileName, showPageNumber, showExport, }: TablePagesProps<TData>) => import('react').JSX.Element;
11
+ export default BasePages;
@@ -0,0 +1,6 @@
1
+ import { RowData, Table as TanStackTable } from '@tanstack/react-table';
2
+ import { BaseTableFeatures } from './tableFeatures';
3
+ export interface TableToolbarProps<TData extends RowData> {
4
+ table: TanStackTable<BaseTableFeatures, TData>;
5
+ }
6
+ export declare const BaseToolbar: <TData extends RowData>({ table }: TableToolbarProps<TData>) => import('react').JSX.Element;
@@ -0,0 +1,8 @@
1
+ export { default as BaseTable } from './BaseTable';
2
+ export { default } from './BaseTable';
3
+ export * from './BaseTable';
4
+ export { default as BaseTableHeader } from './BaseTableHeader';
5
+ export { default as BaseTablePages } from './BaseTablePages';
6
+ export * from './BaseTablePages';
7
+ export * from './BaseTableForm';
8
+ export * from './BaseTableFilter';