aa-geuthur-react 1.4.0 → 1.6.0

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 (43) hide show
  1. package/README.md +30 -13
  2. package/dist/Api/basePaths.d.ts +28 -2
  3. package/dist/Api/calls.d.ts +22 -4
  4. package/dist/Api/errors.d.ts +14 -0
  5. package/dist/Api/index.d.ts +1 -0
  6. package/dist/Api/types.d.ts +13 -2
  7. package/dist/Components/Base/Badges/LiveStatusIndicator.d.ts +35 -0
  8. package/dist/Components/Base/Badges/SecurityBadge.d.ts +10 -0
  9. package/dist/Components/Base/Badges/index.d.ts +3 -0
  10. package/dist/Components/Base/Badges/liveStatusHelper.d.ts +12 -0
  11. package/dist/Components/Base/OwnerPortrait/OwnerPortrait.d.ts +21 -0
  12. package/dist/Components/Base/OwnerPortrait/index.d.ts +1 -0
  13. package/dist/Components/Base/OwnerSettings/BaseOwnerCard.d.ts +6 -0
  14. package/dist/Components/Base/OwnerSettings/BaseOwnerSettingsSection.d.ts +7 -0
  15. package/dist/Components/Base/OwnerSettings/MissingOwnerCard.d.ts +3 -0
  16. package/dist/Components/Base/OwnerSettings/OwnerFilterBar.d.ts +14 -0
  17. package/dist/Components/Base/OwnerSettings/UnregisteredModal.d.ts +21 -0
  18. package/dist/Components/Base/OwnerSettings/index.d.ts +6 -0
  19. package/dist/Components/Base/OwnerSettings/types.d.ts +100 -0
  20. package/dist/Components/Base/index.d.ts +3 -0
  21. package/dist/Hooks/index.d.ts +1 -0
  22. package/dist/Hooks/useUserSettings.d.ts +185 -0
  23. package/dist/Menu/Hooks/useMenu.d.ts +8 -2
  24. package/dist/aa-geuthur-react.css +1 -1
  25. package/dist/i18nInit.d.ts +15 -0
  26. package/dist/index.d.ts +1 -0
  27. package/dist/index.js +1503 -413
  28. package/dist/index.js.map +1 -1
  29. package/i18n/cs/aa-geuthur-react.json +31 -1
  30. package/i18n/de/aa-geuthur-react.json +76 -32
  31. package/i18n/en/aa-geuthur-react.json +48 -1
  32. package/i18n/es/aa-geuthur-react.json +33 -1
  33. package/i18n/fr-FR/aa-geuthur-react.json +29 -1
  34. package/i18n/it-IT/aa-geuthur-react.json +30 -1
  35. package/i18n/ja/aa-geuthur-react.json +31 -1
  36. package/i18n/ko-KR/aa-geuthur-react.json +31 -1
  37. package/i18n/nl-NL/aa-geuthur-react.json +29 -1
  38. package/i18n/pl-PL/aa-geuthur-react.json +32 -1
  39. package/i18n/ru/aa-geuthur-react.json +33 -1
  40. package/i18n/sk/aa-geuthur-react.json +31 -1
  41. package/i18n/uk/aa-geuthur-react.json +33 -1
  42. package/i18n/zh-Hans/aa-geuthur-react.json +31 -1
  43. package/package.json +8 -1
package/README.md CHANGED
@@ -41,7 +41,7 @@ ______________________________________________________________________
41
41
  npm install aa-geuthur-react
42
42
  ```
43
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`.
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`, `i18next-http-backend`, `lucide-react`, `js-cookie`, `nuqs` and `openapi-fetch`.
45
45
 
46
46
  ## Setup<a name="setup"></a>
47
47
 
@@ -80,22 +80,38 @@ import "aa-geuthur-react/styles.css";
80
80
  import "@/Styles/index.css";
81
81
  ```
82
82
 
83
+ The stylesheet also holds the shared design tokens (`--aa-*`, `--font-hud`, `--font-mono`) for the dark default and the light and dark themes (`data-theme="flatly"`/`"darkly"`, `data-bs-theme="light"`/`"dark"`), the classes of the status indicator (`aa-status-*`) and the keyframes `aa-pending-ping`, `aa-pending-glow` and `aa-danger-glow`. The token selectors are wrapped in `:where()` and have no specificity, so any `:root` or `html[data-theme=…]` rule of the app overrides a value:
84
+
85
+ ```css
86
+ @import url("aa-geuthur-react/styles.css");
87
+
88
+ :root {
89
+ --font-mono: ui-monospace, monospace;
90
+ }
91
+ ```
92
+
83
93
  ### Translations<a name="translations"></a>
84
94
 
85
- Every text of the package lives in the i18next namespace `aa-geuthur-react` and is bundled into the package. `AaReactProvider` registers the translations with the i18next instance of the app when it mounts (`addResourceBundle`, texts the app already has for the namespace are kept), so the app lists only its own namespace and copies nothing. Untranslated texts are missing from the language files, so i18next falls back to English through `fallbackLng`:
95
+ Every text of the package lives in the i18next namespace `aa-geuthur-react` and is bundled into the package. `AaReactProvider` registers the translations with the i18next instance of the app when it mounts (`addResourceBundle`, texts the app already has for the namespace are kept), so the app lists only its own namespace and copies nothing. Untranslated texts are missing from the language files, so i18next falls back to English through `fallbackLng`.
86
96
 
87
- ```ts
88
- i18n.use(Backend).use(initReactI18next).init({
89
- lng: djangoLanguage,
90
- fallbackLng: "en",
91
- ns: ["translation"],
92
- defaultNS: "translation",
93
- backend: {
94
- loadPath: `/static/${ProjectName}/i18n/{{lng}}/{{ns}}.json`,
95
- },
96
- });
97
+ `initI18n(projectName, rootElementId)` initializes i18next for the app. Call it in `Main.tsx` before rendering; finding the container and `createRoot(...).render(...)` stay in the app:
98
+
99
+ ```tsx
100
+ import { initI18n } from "aa-geuthur-react";
101
+
102
+ initI18n(ProjectName, `${AppName}-root`);
103
+
104
+ const container = document.getElementById(`${AppName}-root`);
105
+ if (container) {
106
+ ReactDOM.createRoot(container).render(<Routing />);
107
+ }
97
108
  ```
98
109
 
110
+ - The language is the `lang` attribute of the root element (Django's `LANGUAGE_CODE`), `en` without the attribute or the element.
111
+ - The texts of the app are loaded with `i18next-http-backend` from `/static/<projectName>/i18n/<lng>/translation.json`.
112
+ - Fixed options: `fallbackLng: "en"`, `ns: ["translation"]`, `defaultNS: "translation"`, `returnEmptyString: false` (Weblate writes empty plural forms for untranslated texts, they fall back to English), `keySeparator: false`, `nsSeparator: false`, `interpolation.escapeValue: false`, `react.useSuspense: false`.
113
+ - It returns the promise of `i18n.init`; rendering does not have to wait for it.
114
+
99
115
  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. `registerI18nResources(i18n)` adds the translations to an instance outside of the provider, e.g. in a test.
100
116
 
101
117
  The source files `i18n/<lng>/aa-geuthur-react.json` (12 languages: `en`, `de`, `es`, `fr-FR`, `it-IT`, `ja`, `ko-KR`, `nl-NL`, `pl-PL`, `ru`, `uk`, `zh-Hans`) are translated in [Weblate](https://weblate.geuthur.de/projects/allianceauth/aa-geuthur-react/); `en` is the template with key equal value and the only file `make translations` maintains. The other languages hold real translations only, Weblate leaves untranslated texts out. They stay exported as `aa-geuthur-react/i18n/<lng>/aa-geuthur-react.json`.
@@ -111,7 +127,7 @@ import type { paths } from "@/Api/OpenApi";
111
127
  export const apiClient = createApiClient<paths>();
112
128
  ```
113
129
 
114
- `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`.
130
+ `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`. `loadUserSettings(projectName)` and `updateUserSettings(projectName, settings)` call `GET` and `PUT <project>/api/settings/` of an app with user settings and are used by `useUserSettings`. `apiErrorMessage(error, fallback)` returns the message the API sent with a failed request: the string below `error` (`ErrorSchema` of the apps), otherwise the string below `detail` (Django Ninja), otherwise `fallback`. The four calls use it, so a failed request throws the message of the API and only without one the fixed text (`Failed to load menu`, `Failed to load user data`, `Failed to load user settings`, `Failed to update user settings`). Apps use it the same way: `throw new Error(apiErrorMessage(error, "Failed to load items"))`. `queryKeys` holds the query keys `Menu`, `User` and `UserSettings`.
115
131
 
116
132
  ### ESLint rule<a name="eslint-rule"></a>
117
133
 
@@ -187,6 +203,7 @@ Card header with a title (`name`) and buttons or badges as `children`.
187
203
  ## Hooks<a name="hooks"></a>
188
204
 
189
205
  - `useUserData()`: the current user (`{ user: UserData }`), cached for 5 minutes.
206
+ - `useUserSettings()`: the settings of the current user (`UserSettings`) as query result plus `updateMutation`. `updateMutation.mutate(settings)` shows the new values at once, restores the previous settings when the request fails and stores the answer of the API when it succeeds. An app with more fields passes its types: `useUserSettings<AppSettings>()`, or `useUserSettings<AppSettings, AppSettingsUpdate>()` when `PUT settings/` takes single fields; the sent fields are merged into the loaded settings.
190
207
  - `useMenu()`: the menu links (`MenuSchema`), one retry.
191
208
  - `useCooldown()`: `{ seconds, start(duration) }`, counts down once per second.
192
209
  - `useOwnerCooldowns()`: `{ cooldowns, start(ownerId, duration) }`, one cooldown per owner id.
@@ -1,4 +1,4 @@
1
- import { ErrorSchema, MenuSchema, UserData } from './types';
1
+ import { ErrorSchema, MenuSchema, UserData, UserSettings, UserSettingsUpdateRequest } from './types';
2
2
  type JsonResponse<T> = {
3
3
  headers: {
4
4
  [name: string]: unknown;
@@ -22,7 +22,29 @@ type ProjectGet<T> = {
22
22
  403: JsonResponse<ErrorSchema>;
23
23
  };
24
24
  };
25
- /** The endpoints every app provides, with the app's URL prefix as path parameter. */
25
+ type ProjectPut<Body, T> = {
26
+ parameters: {
27
+ query?: never;
28
+ header?: never;
29
+ path: {
30
+ project: string;
31
+ };
32
+ cookie?: never;
33
+ };
34
+ requestBody: {
35
+ content: {
36
+ "application/json": Body;
37
+ };
38
+ };
39
+ responses: {
40
+ 200: JsonResponse<T>;
41
+ 403: JsonResponse<ErrorSchema>;
42
+ };
43
+ };
44
+ /**
45
+ * The endpoints every app provides, with the app's URL prefix as path parameter. `settings/` is
46
+ * optional in an app; only apps with user settings call it.
47
+ */
26
48
  export interface BasePaths {
27
49
  "/{project}/api/menu/": {
28
50
  get: ProjectGet<MenuSchema>;
@@ -30,5 +52,9 @@ export interface BasePaths {
30
52
  "/{project}/api/user/": {
31
53
  get: ProjectGet<UserData>;
32
54
  };
55
+ "/{project}/api/settings/": {
56
+ get: ProjectGet<UserSettings>;
57
+ put: ProjectPut<UserSettingsUpdateRequest, UserSettings>;
58
+ };
33
59
  }
34
60
  export {};
@@ -1,9 +1,13 @@
1
1
  import { BasePaths } from './basePaths';
2
- import { MenuSchema, UserData } from './types';
3
- /** Client for the endpoints every app provides (`menu/`, `user/`). */
2
+ import { MenuModals, MenuSchema, UserData, UserSettings } from './types';
3
+ /** Client for the endpoints every app provides (`menu/`, `user/`) and the optional `settings/`. */
4
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>;
5
+ /**
6
+ * Loads the menu links and, if the app sends them, the menu modals.
7
+ *
8
+ * An app with its own menu modals passes their type: `loadMenu<{ create_session?: AppModal | null }>("beltradar")`.
9
+ */
10
+ export declare function loadMenu<TModals extends object = MenuModals>(projectName: string): Promise<MenuSchema<TModals>>;
7
11
  /**
8
12
  * Loads the current user of the app.
9
13
  *
@@ -13,3 +17,17 @@ export declare function loadMenu(projectName: string): Promise<MenuSchema>;
13
17
  export declare function loadUserData<T extends UserData = UserData>(projectName: string): Promise<{
14
18
  user: T;
15
19
  }>;
20
+ /**
21
+ * Loads the settings of the current user (`GET settings/`).
22
+ *
23
+ * An app whose `settings/` endpoint delivers more than the `UserSettings` contract passes its own type:
24
+ * `loadUserSettings<UserSettings & { quick_select_presets: number[] }>("example")`.
25
+ */
26
+ export declare function loadUserSettings<T extends UserSettings = UserSettings>(projectName: string): Promise<T>;
27
+ /**
28
+ * Saves the settings of the current user (`PUT settings/`) and returns the saved settings.
29
+ *
30
+ * `T` is the type the endpoint answers with, `Body` the request body when it differs from `T`
31
+ * (e.g. an endpoint that takes single fields).
32
+ */
33
+ export declare function updateUserSettings<T extends UserSettings = UserSettings, Body extends object = T>(projectName: string, settings: Body): Promise<T>;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Returns the message the API sent with a failed request, or `fallback` when there is none.
3
+ *
4
+ * `error` is the `error` of an `openapi-fetch` call. The message is the string below `error`
5
+ * (the `ErrorSchema` of the apps, `{"error": "…"}`), otherwise the string below `detail` (answers
6
+ * of Django Ninja itself). Everything else gives `fallback`, also the list Django Ninja sends
7
+ * below `detail` for a validation error.
8
+ *
9
+ * ```ts
10
+ * const { data, error } = await apiClient.GET("/example/api/items/");
11
+ * if (error || !data) throw new Error(apiErrorMessage(error, "Failed to load items"));
12
+ * ```
13
+ */
14
+ export declare function apiErrorMessage(error: unknown, fallback: string): string;
@@ -1,5 +1,6 @@
1
1
  export * from './Api';
2
2
  export * from './calls';
3
+ export * from './errors';
3
4
  export * from './query';
4
5
  export type * from './basePaths';
5
6
  export type * from './types';
@@ -9,10 +9,21 @@ export interface MenuLink {
9
9
  /** Whether the badge pulses because of active errors. */
10
10
  has_errors?: boolean;
11
11
  }
12
- /** The menu of the app: links left and right of the navigation bar. */
13
- export interface MenuSchema {
12
+ /**
13
+ * Modals the menu offers, keyed by the app (e.g. `create_example`, `create_session`).
14
+ * Each app has its own keys and may deliver its own modal shape, so this default stays open.
15
+ */
16
+ export type MenuModals = Record<string, ModalSchema | null | undefined>;
17
+ /**
18
+ * The menu of the app: links left and right of the navigation bar and, for apps that send them, its modals.
19
+ *
20
+ * An app with its own `MenuModalSchema` passes it as type: `MenuSchema<{ create_session?: AppModal | null }>`.
21
+ */
22
+ export interface MenuSchema<TModals extends object = MenuModals> {
14
23
  left_links: MenuLink[];
15
24
  right_links: MenuLink[];
25
+ /** Modals of the menu (`MenuModalSchema` of the app); missing or `null` for apps without menu modals. */
26
+ modals?: TModals | null;
16
27
  }
17
28
  /** The current user as delivered by the `user/` endpoint of the app. */
18
29
  export interface UserData {
@@ -0,0 +1,35 @@
1
+ import { default as React } from 'react';
2
+ export interface LiveStatusProps {
3
+ /** Whether a query or operation encountered an error */
4
+ isError?: boolean;
5
+ /** Optional error object or message for the tooltip */
6
+ error?: unknown;
7
+ /** Whether a query or operation is currently loading */
8
+ isLoading?: boolean;
9
+ /** Whether a query is actively fetching (including background refetches) */
10
+ isFetching?: boolean;
11
+ /** Timestamp in ms of the last successful data update */
12
+ dataUpdatedAt?: number;
13
+ /** Whether to display the formatted last fetch timestamp beside the dot */
14
+ showTimestamp?: boolean;
15
+ /** Prefix before the timestamp (default: "↻") */
16
+ timestampPrefix?: string;
17
+ /** Duration in ms of the ping animation on fresh data (default: 2000) */
18
+ pingDuration?: number;
19
+ /** Wrapper class (default: "aa-status-indicator") */
20
+ className?: string;
21
+ /** Additional class of the dot */
22
+ dotClassName?: string;
23
+ /** Class of the timestamp text (default: "aa-status-text") */
24
+ textClassName?: string;
25
+ /** Optional children rendered beside the dot */
26
+ children?: React.ReactNode;
27
+ }
28
+ /**
29
+ * Live status of a query:
30
+ * - red dot when an error occurred (`isError`)
31
+ * - amber pulsing dot while loading or fetching (`isLoading` / `isFetching`)
32
+ * - green dot when ready, with a short ping when new data arrived
33
+ * - optional text ("↻ 19:10:24 EVE", "Loading…", "Error")
34
+ */
35
+ export declare function LiveStatusIndicator({ isError, error, isLoading, isFetching, dataUpdatedAt, showTimestamp, timestampPrefix, pingDuration, className, dotClassName, textClassName, children, }: LiveStatusProps): React.JSX.Element;
@@ -0,0 +1,10 @@
1
+ export interface SecurityBadgeProps {
2
+ /** Security status of the system, shown with one decimal. */
3
+ sec: number;
4
+ className?: string;
5
+ }
6
+ /**
7
+ * Security status of a system. The colour comes from `getSecColor` (`aa-badge-hisec`,
8
+ * `aa-badge-lowsec`, `aa-badge-nullsec`); the app defines these classes.
9
+ */
10
+ export declare function SecurityBadge({ sec, className }: SecurityBadgeProps): import('react').JSX.Element;
@@ -0,0 +1,3 @@
1
+ export * from './LiveStatusIndicator';
2
+ export * from './liveStatusHelper';
3
+ export * from './SecurityBadge';
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Formats a timestamp in milliseconds as EVE time (`HH:MM:SS EVE`), empty without a timestamp.
3
+ */
4
+ export declare function formatLastFetch(date?: number): string;
5
+ /**
6
+ * Short ping animation whenever `dataUpdatedAt` changes. Both timers are cleared when the inputs
7
+ * change or the component unmounts, so no state update happens after unmount.
8
+ * @param dataUpdatedAt Timestamp of the last query fetch
9
+ * @param isBusy True while the query is loading or refetching (no ping then)
10
+ * @param duration Duration of the ping animation in milliseconds (default: 2000)
11
+ */
12
+ export declare function useLivePing(dataUpdatedAt?: number, isBusy?: boolean, duration?: number): boolean;
@@ -0,0 +1,21 @@
1
+ import { default as React } from 'react';
2
+ export type OwnerPortraitSize = "sm" | "md" | "lg";
3
+ export interface OwnerPortraitProps {
4
+ /** Image URL. Without it the owner type icon is shown instead. */
5
+ src?: string | null;
6
+ alt?: string;
7
+ /** Owner type, selects the fallback icon. */
8
+ type?: string;
9
+ /** `sm` = 32 px, `md` = 40 px, `lg` = 48 px (default). */
10
+ size?: OwnerPortraitSize;
11
+ /** `circle` (default) or `rounded` (square with rounded corners). */
12
+ shape?: "circle" | "rounded";
13
+ /** Adds a border around the portrait. */
14
+ bordered?: boolean;
15
+ className?: string;
16
+ }
17
+ /**
18
+ * Portrait of a character, corporation or alliance.
19
+ * Shows the image, or the matching type icon when no image URL is available.
20
+ */
21
+ export declare const OwnerPortrait: React.FC<OwnerPortraitProps>;
@@ -0,0 +1 @@
1
+ export * from './OwnerPortrait';
@@ -0,0 +1,6 @@
1
+ import { BaseOwner, BaseOwnerCardProps } from './types';
2
+ /**
3
+ * Card of a registered owner: status badge, update sections and action buttons.
4
+ * The pulsing dot of the error states uses the `aa-pending-dot-*` / `aa-danger-dot-*` classes of the app.
5
+ */
6
+ export declare function BaseOwnerCard<T extends BaseOwner = BaseOwner>({ owner, isUpdating, cooldown, onTriggerUpdate, onDeleteClick, className, renderCustomContent, renderActions, }: BaseOwnerCardProps<T>): import('react').JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { BaseMissingOwner, BaseOwner, BaseOwnerSettingsSectionProps } from './types';
2
+ /**
3
+ * Owner overview for the settings page: header with "Update All", feedback alert, optional
4
+ * type filter and search, owner grid, missing (unregistered) owners and the delete confirmation.
5
+ * Project specific parts are injected via `renderCustomCardContent` / `renderCardActions`.
6
+ */
7
+ export declare function BaseOwnerSettingsSection<T extends BaseOwner = BaseOwner, M extends BaseMissingOwner = BaseMissingOwner>({ title, description, icon, owners, missingOwners, isLoading, isError, errorMessage, emptyMessage, appName, className, bodyClassName, enableFilters, searchPlaceholder, onUpdateAll, isUpdatingAll, globalCooldown, feedbackMessage, onDismissFeedback, onTriggerSingleUpdate, isUpdatable, isDeletable, updatingOwnerId, ownerCooldowns, onDeleteOwner, isDeleting, deleteModalTitle, deleteModalDescription, deleteModalBodyClassName, cardClassName, renderCustomCardContent, renderCardActions, missingSectionTitle, missingSectionDescription, missingActionUrl, missingActionLabel, }: BaseOwnerSettingsSectionProps<T, M>): import('react').JSX.Element;
@@ -0,0 +1,3 @@
1
+ import { BaseMissingOwner, MissingOwnerCardProps } from './types';
2
+ /** Card for an entity (e.g. an alt) that belongs to the user but is not registered in the app. */
3
+ export declare function MissingOwnerCard<M extends BaseMissingOwner = BaseMissingOwner>({ missing, appName, actionUrl, actionLabel, }: MissingOwnerCardProps<M>): import('react').JSX.Element;
@@ -0,0 +1,14 @@
1
+ export type OwnerTypeFilter = "all" | "character" | "corporation" | "alliance";
2
+ export interface OwnerFilterBarProps {
3
+ search: string;
4
+ onSearchChange: (value: string) => void;
5
+ typeFilter: OwnerTypeFilter;
6
+ onTypeChange: (value: OwnerTypeFilter) => void;
7
+ counts: Record<OwnerTypeFilter, number>;
8
+ searchPlaceholder?: string;
9
+ }
10
+ /**
11
+ * Type filter (All / Characters / Corporations / Alliances) and name search for owner lists.
12
+ * Only types that actually exist (count > 0) are shown, "All" and the active type are always visible.
13
+ */
14
+ export declare function OwnerFilterBar({ search, onSearchChange, typeFilter, onTypeChange, counts, searchPlaceholder, }: OwnerFilterBarProps): import('react').JSX.Element;
@@ -0,0 +1,21 @@
1
+ import { BaseMissingOwner } from './types';
2
+ export interface UnregisteredModalProps<M extends BaseMissingOwner = BaseMissingOwner> {
3
+ show: boolean;
4
+ onHide: () => void;
5
+ title: string;
6
+ description?: string;
7
+ /** Entries to list; the app loads them (e.g. with its own query hook). */
8
+ items?: M[];
9
+ isLoading?: boolean;
10
+ isError?: boolean;
11
+ errorMessage?: string;
12
+ emptyMessage?: string;
13
+ /** Placeholder of the search field (default: "Search owners…"). */
14
+ searchPlaceholder?: string;
15
+ /** Accessible label of the search field (default: "Search owners"). */
16
+ searchLabel?: string;
17
+ /** Text when the search matches nothing (default: "No matching owners found."). */
18
+ noMatchMessage?: string;
19
+ }
20
+ /** Modal listing entities (members or corporations) that are not registered in the app. */
21
+ export declare function UnregisteredModal<M extends BaseMissingOwner = BaseMissingOwner>({ show, onHide, title, description, items, isLoading, isError, errorMessage, emptyMessage, searchPlaceholder, searchLabel, noMatchMessage, }: UnregisteredModalProps<M>): import('react').JSX.Element;
@@ -0,0 +1,6 @@
1
+ export * from './types';
2
+ export * from './BaseOwnerCard';
3
+ export * from './MissingOwnerCard';
4
+ export * from './OwnerFilterBar';
5
+ export * from './BaseOwnerSettingsSection';
6
+ export * from './UnregisteredModal';
@@ -0,0 +1,100 @@
1
+ import { default as React } from 'react';
2
+ /** One update section of an owner (e.g. "Wallet Journal") with its last run. */
3
+ export interface BaseOwnerSection {
4
+ section: string;
5
+ section_name: string;
6
+ is_success?: boolean | null;
7
+ has_token_error?: boolean | null;
8
+ error_message?: string | null;
9
+ last_run_at?: string | null;
10
+ last_run_finished_at?: string | null;
11
+ }
12
+ /** Registered owner (character, corporation or alliance) as the settings page shows it. */
13
+ export interface BaseOwner {
14
+ id: number;
15
+ name: string;
16
+ owner_type?: "character" | "corporation" | "alliance" | string;
17
+ avatar_url?: string | null;
18
+ subtitle?: string | null;
19
+ status: string;
20
+ has_error?: boolean;
21
+ error_message?: string | null;
22
+ last_sync?: string | null;
23
+ sections?: BaseOwnerSection[] | null;
24
+ }
25
+ /** Entity that belongs to the user but is not registered in the app (e.g. an alt). */
26
+ export interface BaseMissingOwner {
27
+ id: number;
28
+ name: string;
29
+ /** Defaults to "character" when filtering. */
30
+ owner_type?: "character" | "corporation" | "alliance" | string;
31
+ avatar_url?: string | null;
32
+ subtitle?: string | null;
33
+ }
34
+ export interface BaseOwnerCardProps<T extends BaseOwner = BaseOwner> {
35
+ owner: T;
36
+ isUpdating?: boolean;
37
+ cooldown?: number;
38
+ onTriggerUpdate?: (ownerId: number) => void;
39
+ onDeleteClick?: (owner: T) => void;
40
+ /** Additional class of the card, e.g. `"bg-dark"`. */
41
+ className?: string;
42
+ /** Slot for project specific content (switches, statistics, ...). */
43
+ renderCustomContent?: (owner: T) => React.ReactNode;
44
+ /** Slot for additional action buttons on the left side of the footer. */
45
+ renderActions?: (owner: T) => React.ReactNode;
46
+ }
47
+ export interface MissingOwnerCardProps<M extends BaseMissingOwner = BaseMissingOwner> {
48
+ missing: M;
49
+ appName?: string;
50
+ actionUrl?: string;
51
+ actionLabel?: string;
52
+ }
53
+ export interface BaseOwnerSettingsSectionProps<T extends BaseOwner = BaseOwner, M extends BaseMissingOwner = BaseMissingOwner> {
54
+ title?: string;
55
+ description?: string;
56
+ icon?: React.ReactNode;
57
+ owners?: T[];
58
+ missingOwners?: M[];
59
+ isLoading?: boolean;
60
+ isError?: boolean;
61
+ errorMessage?: string;
62
+ emptyMessage?: string;
63
+ appName?: string;
64
+ /** Additional class of the outer card. */
65
+ className?: string;
66
+ /** Class of the card body (default: `"bg-dark text-light"`). */
67
+ bodyClassName?: string;
68
+ /** Show type filter and search field (default: false). */
69
+ enableFilters?: boolean;
70
+ searchPlaceholder?: string;
71
+ onUpdateAll?: () => void;
72
+ isUpdatingAll?: boolean;
73
+ globalCooldown?: number;
74
+ feedbackMessage?: {
75
+ variant: "success" | "danger";
76
+ text: string;
77
+ } | null;
78
+ onDismissFeedback?: () => void;
79
+ onTriggerSingleUpdate?: (ownerId: number) => void;
80
+ /** Hide the update button for owners where this returns false (default: all updatable). */
81
+ isUpdatable?: (owner: T) => boolean;
82
+ /** Hide the delete button for owners where this returns false (default: all deletable). */
83
+ isDeletable?: (owner: T) => boolean;
84
+ updatingOwnerId?: number | null;
85
+ ownerCooldowns?: Record<number, number>;
86
+ onDeleteOwner?: (owner: T) => void | Promise<unknown>;
87
+ isDeleting?: boolean;
88
+ deleteModalTitle?: string;
89
+ deleteModalDescription?: (owner: T) => React.ReactNode;
90
+ /** Class of the body of the delete modal, e.g. `"aa-panel"`. */
91
+ deleteModalBodyClassName?: string;
92
+ /** Additional class of every owner card, e.g. `"bg-dark"`. */
93
+ cardClassName?: string;
94
+ renderCustomCardContent?: (owner: T) => React.ReactNode;
95
+ renderCardActions?: (owner: T) => React.ReactNode;
96
+ missingSectionTitle?: string;
97
+ missingSectionDescription?: string;
98
+ missingActionUrl?: string;
99
+ missingActionLabel?: string;
100
+ }
@@ -10,3 +10,6 @@ export * from './Loader';
10
10
  export { default as BaseSectionHeader } from './BaseHeader';
11
11
  export type { BaseSectionHeaderProps } from './BaseHeader';
12
12
  export * from './FilterButtonGroup';
13
+ export * from './OwnerPortrait';
14
+ export * from './OwnerSettings';
15
+ export * from './Badges';
@@ -1,3 +1,4 @@
1
1
  export * from './useCooldown';
2
2
  export * from './useFeedback';
3
3
  export * from './useUserData';
4
+ export * from './useUserSettings';