@eifi1/ui-kit 0.40.1 → 0.42.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.
- package/README.md +19 -6
- package/dist/admin/admin-area-labels.d.ts +55 -0
- package/dist/admin/admin-area-labels.js +33 -0
- package/dist/admin/admin-area-labels.js.map +1 -0
- package/dist/admin/admin-forbidden.d.ts +35 -0
- package/dist/admin/admin-forbidden.js +36 -0
- package/dist/admin/admin-forbidden.js.map +1 -0
- package/dist/admin/admin-overview.d.ts +93 -0
- package/dist/admin/admin-overview.js +69 -0
- package/dist/admin/admin-overview.js.map +1 -0
- package/dist/admin/admin-sections.d.ts +63 -0
- package/dist/admin/admin-sections.js +64 -0
- package/dist/admin/admin-sections.js.map +1 -0
- package/dist/admin/admin-tool-links.d.ts +48 -0
- package/dist/admin/admin-tool-links.js +31 -0
- package/dist/admin/admin-tool-links.js.map +1 -0
- package/dist/billing/billing-banner.d.ts +25 -2
- package/dist/billing/billing-banner.js +5 -2
- package/dist/billing/billing-banner.js.map +1 -1
- package/dist/billing/billing-labels.d.ts +32 -0
- package/dist/billing/billing-labels.js +9 -0
- package/dist/billing/billing-labels.js.map +1 -1
- package/dist/billing/billing-overview.d.ts +33 -0
- package/dist/billing/billing-overview.js +6 -0
- package/dist/billing/billing-overview.js.map +1 -1
- package/dist/billing/billing-standing.d.ts +8 -0
- package/dist/billing/billing-standing.js.map +1 -1
- package/dist/billing/cancel-subscription.d.ts +46 -0
- package/dist/billing/cancel-subscription.js +57 -0
- package/dist/billing/cancel-subscription.js.map +1 -0
- package/dist/billing/plan-card.d.ts +45 -1
- package/dist/billing/plan-card.js +53 -2
- package/dist/billing/plan-card.js.map +1 -1
- package/dist/billing/plan-switch.d.ts +10 -1
- package/dist/billing/plan-switch.js +22 -13
- package/dist/billing/plan-switch.js.map +1 -1
- package/dist/billing/subscription-actions.d.ts +37 -4
- package/dist/billing/subscription-actions.js +10 -3
- package/dist/billing/subscription-actions.js.map +1 -1
- package/dist/components/account-chips.d.ts +42 -1
- package/dist/components/account-chips.js +33 -0
- package/dist/components/account-chips.js.map +1 -1
- package/dist/components/empty-state.d.ts +2 -1
- package/dist/components/empty-state.js.map +1 -1
- package/dist/components/nav-pills.d.ts +2 -2
- package/dist/components/nav-pills.js.map +1 -1
- package/dist/components/tabs.d.ts +4 -32
- package/dist/components/tabs.js +30 -66
- package/dist/components/tabs.js.map +1 -1
- package/dist/components/translation-review-parts.d.ts +2 -2
- package/dist/components/translation-review-parts.js.map +1 -1
- package/dist/eslint/index.js +1 -1
- package/dist/feedback/feedback-menu-labels.js +0 -2
- package/dist/feedback/feedback-menu-labels.js.map +1 -1
- package/dist/feedback/feedback-menu.d.ts +0 -6
- package/dist/feedback/feedback-menu.js.map +1 -1
- package/dist/i18n/defaults.js +5 -1
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/german.js +79 -2
- package/dist/i18n/german.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +9 -0
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/locales/en.js +93 -3
- package/dist/i18n/locales/en.js.map +3 -3
- package/dist/i18n/locales/es.js +76 -2
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.js +75 -2
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.js +76 -2
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.js +76 -2
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.js +75 -2
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/i18n/review.js +20 -1
- package/dist/i18n/review.js.map +1 -1
- package/dist/index.d.ts +18 -2
- package/dist/index.js +23 -1
- package/dist/index.js.map +1 -1
- package/dist/settings/settings-layout.d.ts +7 -1
- package/dist/settings/settings-layout.js +35 -27
- package/dist/settings/settings-layout.js.map +1 -1
- package/dist/shell/account-menu-language.d.ts +46 -0
- package/dist/shell/account-menu-language.js +64 -0
- package/dist/shell/account-menu-language.js.map +1 -0
- package/dist/shell/admin-menu.d.ts +46 -0
- package/dist/shell/admin-menu.js +60 -0
- package/dist/shell/admin-menu.js.map +1 -0
- package/dist/shell/app-shell.d.ts +10 -0
- package/dist/shell/app-shell.js +22 -4
- package/dist/shell/app-shell.js.map +1 -1
- package/dist/shell/dev-switchers.d.ts +53 -0
- package/dist/shell/dev-switchers.js +102 -0
- package/dist/shell/dev-switchers.js.map +1 -0
- package/dist/shell/sync-status-indicator.d.ts +86 -0
- package/dist/shell/sync-status-indicator.js +170 -0
- package/dist/shell/sync-status-indicator.js.map +1 -0
- package/dist/shell/top-bar-actions.d.ts +49 -0
- package/dist/shell/top-bar-actions.js +31 -0
- package/dist/shell/top-bar-actions.js.map +1 -0
- package/dist/shell/top-bar-parts-labels.d.ts +84 -0
- package/dist/shell/top-bar-parts-labels.js +48 -0
- package/dist/shell/top-bar-parts-labels.js.map +1 -0
- package/dist/shell/topbar-action-menu.d.ts +13 -1
- package/dist/shell/topbar-action-menu.js +5 -2
- package/dist/shell/topbar-action-menu.js.map +1 -1
- package/dist/shell/topbar-controls.d.ts +16 -3
- package/dist/shell/topbar-controls.js +5 -1
- package/dist/shell/topbar-controls.js.map +1 -1
- package/dist/shell/tour-menu.d.ts +58 -0
- package/dist/shell/tour-menu.js +73 -0
- package/dist/shell/tour-menu.js.map +1 -0
- package/dist/shell.d.ts +14 -0
- package/dist/shell.js +19 -0
- package/dist/shell.js.map +1 -1
- package/package.json +1 -1
- package/src/admin/admin-area-labels.ts +85 -0
- package/src/admin/admin-forbidden.tsx +75 -0
- package/src/admin/admin-overview.tsx +166 -0
- package/src/admin/admin-sections.tsx +137 -0
- package/src/admin/admin-tool-links.tsx +84 -0
- package/src/billing/billing-banner.tsx +32 -4
- package/src/billing/billing-labels.ts +53 -0
- package/src/billing/billing-overview.ts +37 -0
- package/src/billing/billing-standing.ts +8 -0
- package/src/billing/cancel-subscription.tsx +102 -0
- package/src/billing/plan-card.tsx +97 -1
- package/src/billing/plan-switch.tsx +16 -0
- package/src/billing/subscription-actions.tsx +64 -15
- package/src/components/account-chips.tsx +81 -1
- package/src/components/empty-state.tsx +2 -1
- package/src/components/nav-pills.tsx +2 -2
- package/src/components/tabs.tsx +19 -110
- package/src/components/translation-review-parts.tsx +2 -2
- package/src/feedback/feedback-menu-labels.ts +0 -2
- package/src/feedback/feedback-menu.tsx +0 -6
- package/src/i18n/defaults.ts +4 -0
- package/src/i18n/german.ts +92 -2
- package/src/i18n/kit-labels.tsx +9 -0
- package/src/i18n/locales/en.ts +19 -0
- package/src/i18n/locales/es.ts +86 -2
- package/src/i18n/locales/fr.ts +86 -2
- package/src/i18n/locales/hu.ts +84 -2
- package/src/i18n/locales/it.ts +87 -2
- package/src/i18n/locales/zh.ts +79 -2
- package/src/i18n/review.ts +19 -0
- package/src/index.ts +30 -2
- package/src/settings/settings-layout.tsx +58 -34
- package/src/shell/account-menu-language.tsx +116 -0
- package/src/shell/admin-menu.tsx +117 -0
- package/src/shell/app-shell.tsx +44 -3
- package/src/shell/dev-switchers.tsx +171 -0
- package/src/shell/sync-status-indicator.tsx +301 -0
- package/src/shell/top-bar-actions.tsx +79 -0
- package/src/shell/top-bar-parts-labels.ts +133 -0
- package/src/shell/topbar-action-menu.tsx +15 -2
- package/src/shell/topbar-controls.tsx +20 -3
- package/src/shell/tour-menu.tsx +144 -0
- package/src/shell.ts +24 -0
package/README.md
CHANGED
|
@@ -556,16 +556,16 @@ columns, strings and permissions (see the note at the top of `src/feedback/feedb
|
|
|
556
556
|
|
|
557
557
|
<!-- BEGIN GENERATED: exports — node scripts/gen-export-inventory.mjs -->
|
|
558
558
|
|
|
559
|
-
**
|
|
559
|
+
**2042 names from 335 modules** — 942 values and 1100 types. _Italic_ is a type-only export.
|
|
560
560
|
|
|
561
561
|
Generated from `dist/index.d.ts` by `node scripts/gen-export-inventory.mjs`; the count
|
|
562
562
|
is pinned by `src/__tests__/public-surface.test.ts`. Do not edit between the markers.
|
|
563
563
|
|
|
564
564
|
| Entry point | Names |
|
|
565
565
|
|---|---|
|
|
566
|
-
| `@eifi1/ui-kit` |
|
|
566
|
+
| `@eifi1/ui-kit` | 2042 |
|
|
567
567
|
| `@eifi1/ui-kit/chart` | 92 |
|
|
568
|
-
| `@eifi1/ui-kit/shell` |
|
|
568
|
+
| `@eifi1/ui-kit/shell` | 108 |
|
|
569
569
|
| `@eifi1/ui-kit/data-table` | 51 |
|
|
570
570
|
| `@eifi1/ui-kit/wizard` | 24 |
|
|
571
571
|
| `@eifi1/ui-kit/tour` | 7 |
|
|
@@ -746,7 +746,7 @@ re-slicing of it, never a second API.
|
|
|
746
746
|
| `components/description-list` | `DEFAULT_DESCRIPTION_LIST_LABELS`, `DescriptionItem`, `DescriptionList`, _`DescriptionItemProps`_, _`DescriptionListColumns`_, _`DescriptionListDensity`_, _`DescriptionListLabels`_, _`DescriptionListLayout`_, _`DescriptionListProps`_ |
|
|
747
747
|
| `components/form-actions` | `DEFAULT_FORM_ACTIONS_LABELS`, `FormActions`, _`FormActionsAlign`_, _`FormActionsDestructive`_, _`FormActionsLabels`_, _`FormActionsPlacement`_, _`FormActionsProps`_, _`FormActionsStack`_, _`FormActionsStickyWithin`_, _`FormActionsSubmitProps`_, _`FormActionsSubmitShortcut`_, _`ResponsiveFormActionsPlacement`_ |
|
|
748
748
|
| `components/write-lock` | `COMMIT_EXCEPT_BILLING`, `DEFAULT_WRITE_LOCK_LABELS`, `useWriteLock`, `writeLockFor`, `WriteLockProvider`, _`CommitScope`_, _`WriteLock`_, _`WriteLockHold`_, _`WriteLockKind`_, _`WriteLockLabels`_, _`WriteLockProviderProps`_ |
|
|
749
|
-
| `components/account-chips` | `ACCOUNT_STATE_TONES`, `AccountStateChip`, `dateColumn`, `DateMark`, `DEFAULT_ACCOUNT_STATE_LABELS`, `RoleChip`, _`AccountState`_, _`AccountStateChipProps`_, _`AccountStateLabels`_, _`DateColumnOptions`_, _`DateMarkProps`_, _`RoleChipProps`_, _`RoleDefinition`_, _`RoleVocabulary`_ |
|
|
749
|
+
| `components/account-chips` | `ACCOUNT_STATE_TONES`, `AccountRoleChip`, `AccountStateChip`, `dateColumn`, `DateMark`, `DEFAULT_ACCOUNT_STATE_LABELS`, `RoleChip`, _`AccountRoleChipProps`_, _`AccountState`_, _`AccountStateChipProps`_, _`AccountStateLabels`_, _`DateColumnOptions`_, _`DateMarkProps`_, _`RoleChipProps`_, _`RoleDefinition`_, _`RoleVocabulary`_ |
|
|
750
750
|
| `components/server-wake` | `DEFAULT_SERVER_WAKE_LABELS`, `ServerWakeNotice`, `useServerWakeStage`, _`ServerWakeLabels`_, _`ServerWakeNoticeProps`_ |
|
|
751
751
|
| `components/share-card` | `DEFAULT_SHARE_CARD_LABELS`, `ShareCard`, `ShareDialog`, `SharePanel`, _`ShareAddRequest`_, _`ShareCandidate`_, _`ShareCardLabels`_, _`ShareCardProps`_, _`ShareDialogProps`_, _`ShareGrantee`_, _`SharePanelProps`_, _`SharePendingGrant`_, _`ShareRole`_ |
|
|
752
752
|
| `components/line-items` | `DEFAULT_LINE_ITEMS_LABELS`, `LineItems`, _`LineItemCellContext`_, _`LineItemsColumn`_, _`LineItemsFieldLabels`_, _`LineItemsLabels`_, _`LineItemsProps`_, _`LineItemsRemoveAlign`_, _`LineItemsRemovePlacement`_, _`LineItemsRowProps`_, _`LineItemsSummary`_, _`LineItemsSummaryTone`_ |
|
|
@@ -819,6 +819,13 @@ re-slicing of it, never a second API.
|
|
|
819
819
|
| `shell/top-bar-brand` | `TopBarBrand`, _`TopBarBrandProps`_ |
|
|
820
820
|
| `shell/auth-layout` | `AuthLayout`, _`AuthLayoutProps`_ |
|
|
821
821
|
| `shell/fill-height` | `FILL_HEIGHT_CLASS`, `FillHeight`, _`FillHeightProps`_ |
|
|
822
|
+
| `shell/admin-menu` | `adminMenuEntry`, `AdminMenuRow`, _`AdminMenuEntryOptions`_, _`AdminMenuRowProps`_ |
|
|
823
|
+
| `shell/top-bar-actions` | `TOP_BAR_ACTION_ORDER`, `TopBarActions`, _`TopBarActionsProps`_ |
|
|
824
|
+
| `shell/account-menu-language` | `AccountMenuLanguage`, _`AccountMenuLanguageOption`_, _`AccountMenuLanguageProps`_ |
|
|
825
|
+
| `shell/tour-menu` | `TourMenu`, _`TourMenuProps`_, _`TourMenuTour`_ |
|
|
826
|
+
| `shell/sync-status-indicator` | `syncState`, `SyncStatusIndicator`, _`SyncState`_, _`SyncStatus`_, _`SyncStatusIndicatorProps`_, _`SyncStatusScope`_ |
|
|
827
|
+
| `shell/dev-switchers` | `DEV_ORIGINAL_ROLE_KEY`, `DevSwitchers`, _`DevSwitchersProps`_ |
|
|
828
|
+
| `shell/top-bar-parts-labels` | `DEFAULT_TOP_BAR_PARTS_LABELS`, `useTopBarPartsLabels`, _`DevSwitchersLabels`_, _`SyncStatusLabels`_, _`TopBarPartsLabels`_, _`TourMenuLabels`_ |
|
|
822
829
|
| `shell/company-switcher` | `CompanySwitcher`, `DEFAULT_COMPANY_SWITCHER_LABELS`, _`CompanySwitcherCompany`_, _`CompanySwitcherLabels`_, _`CompanySwitcherProps`_ |
|
|
823
830
|
|
|
824
831
|
### settings
|
|
@@ -943,6 +950,11 @@ re-slicing of it, never a second API.
|
|
|
943
950
|
| `admin/transfer-ownership-dialog` | `DEFAULT_TRANSFER_OWNERSHIP_LABELS`, `TransferOwnershipDialog`, _`TransferCandidate`_, _`TransferOwnershipDialogProps`_, _`TransferOwnershipLabels`_, _`TransferUnavailable`_, _`TransferValues`_ |
|
|
944
951
|
| `admin/invitations-panel` | `DEFAULT_INVITATIONS_LABELS`, `InvitationsPanel`, _`InvitationDraft`_, _`InvitationRow`_, _`InvitationScope`_, _`InvitationSentAnswer`_, _`InvitationsLabels`_, _`InvitationsPanelProps`_, _`InvitationStatus`_ |
|
|
945
952
|
| `admin/admin-parts` | _`AdminPerson`_ |
|
|
953
|
+
| `admin/admin-area-labels` | `DEFAULT_ADMIN_AREA_LABELS`, `useAdminAreaLabels`, _`AdminAreaLabels`_, _`AdminSharedSection`_, _`AdminTileLabels`_ |
|
|
954
|
+
| `admin/admin-sections` | `ADMIN_SECTIONS`, `adminSections`, _`AdminOwnSection`_, _`AdminSectionDefinition`_, _`AdminSectionsOptions`_ |
|
|
955
|
+
| `admin/admin-forbidden` | `AdminForbidden`, _`AdminForbiddenProps`_ |
|
|
956
|
+
| `admin/admin-overview` | `AdminOverview`, `adminWaitingCount`, `AttentionTile`, `DEFAULT_ADMIN_ATTENTION_HREFS`, _`AdminAttention`_, _`AdminAttentionTile`_, _`AdminExtraTile`_, _`AdminOverviewProps`_, _`AttentionTileProps`_ |
|
|
957
|
+
| `admin/admin-tool-links` | `AdminToolLinks`, _`AdminToolLink`_, _`AdminToolLinksProps`_ |
|
|
946
958
|
| `admin/plan-change` | `DEFAULT_PLAN_CHANGE_LABELS`, `PlanChangeConfirm`, `planColumn`, `usePlanChangeResult`, `usePlanColumn`, _`PlanChange`_, _`PlanChangeConfirmProps`_, _`PlanChangeLabels`_, _`PlanChangeLine`_, _`PlanChangeOutcome`_, _`PlanChangeResultOptions`_, _`PlanChangeTone`_, _`PlanColumnOptions`_, _`PlanColumnUsage`_ |
|
|
947
959
|
|
|
948
960
|
### billing
|
|
@@ -951,7 +963,7 @@ re-slicing of it, never a second API.
|
|
|
951
963
|
|---|---|
|
|
952
964
|
| `billing/billing-labels` | `DEFAULT_BILLING_LABELS`, `SUBSCRIPTION_STATUSES`, `useBillingLabels`, _`BillingLabels`_, _`SubscriptionStatus`_ |
|
|
953
965
|
| `billing/plan-price` | `BILLING_INTERVALS`, `billingCurrencyFor`, `formatPlanPrice`, `minorToMajor`, `planPrice`, _`BillingCurrency`_, _`BillingInterval`_, _`PlanIntervalPrices`_, _`PlanPriceAnswer`_, _`PlanPrices`_ |
|
|
954
|
-
| `billing/plan-card` | `PlanCard`, `PlanPicker`, `planRelation`, _`BillingPlan`_, _`PlanCardProps`_, _`PlanChoice`_, _`PlanPickerProps`_, _`PlanRelation`_ |
|
|
966
|
+
| `billing/plan-card` | `GrantWarningConfirm`, `PlanCard`, `PlanPicker`, `planRelation`, _`BillingPlan`_, _`GrantWarningConfirmProps`_, _`PlanCardProps`_, _`PlanChoice`_, _`PlanPickerProps`_, _`PlanRelation`_ |
|
|
955
967
|
| `billing/subscription-status-chip` | `SUBSCRIPTION_STATUS_TONES`, `SubscriptionStatusChip`, _`SubscriptionStatusChipProps`_ |
|
|
956
968
|
| `billing/billing-banner` | `BillingBanner`, _`BillingBannerKind`_, _`BillingBannerProps`_ |
|
|
957
969
|
| `billing/plan-limit-notice` | `planLimitMailto`, `PlanLimitNotice`, _`PlanLimitNoticeProps`_ |
|
|
@@ -962,9 +974,10 @@ re-slicing of it, never a second API.
|
|
|
962
974
|
| `billing/checkout-return` | `CHECKOUT_RETURN_PARAM`, `CHECKOUT_RETURN_VALUE`, `checkoutReturnUrl`, `isCheckoutReturn`, `withoutCheckoutReturn` |
|
|
963
975
|
| `billing/checkout-processing` | `checkoutFingerprint`, `checkoutLanded`, `noteCheckoutStarted`, `useCheckoutProcessing`, _`CheckoutOverview`_, _`CheckoutProcessingOptions`_ |
|
|
964
976
|
| `billing/pay-page` | `paddleLocale`, `PAY_PAGE_APPS`, `PAY_PAGE_LANG_PARAM`, `payPageUrl`, _`PaddleEnvironment`_, _`PayPageApp`_ |
|
|
965
|
-
| `billing/billing-overview` | _`BillingOverview`_, _`PaidPrice`_, _`PlanSwitchPreview`_, _`PlanSwitchRequest`_, _`PortalRequest`_, _`PortalTarget`_, _`SubscriptionSource`_ |
|
|
977
|
+
| `billing/billing-overview` | `isPermanentGrant`, _`BillingOverview`_, _`BillingPortalAccess`_, _`PaidPrice`_, _`PlanSwitchPreview`_, _`PlanSwitchRequest`_, _`PortalRequest`_, _`PortalTarget`_, _`SubscriptionSource`_ |
|
|
966
978
|
| `billing/plan-limit-toast` | `usePlanLimitToast`, _`PlanLimitToastOptions`_ |
|
|
967
979
|
| `billing/plan-switch` | `PlanSwitchConfirm`, _`PlanSwitchConfirmProps`_, _`PlanSwitchSide`_ |
|
|
980
|
+
| `billing/cancel-subscription` | `CancelSubscriptionConfirm`, _`CancelSubscriptionConfirmProps`_ |
|
|
968
981
|
|
|
969
982
|
### notifications
|
|
970
983
|
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type LabelOverride } from "../i18n/kit-labels.js";
|
|
2
|
+
import type { SettingsGroupLabels } from "../settings/settings-labels.js";
|
|
3
|
+
/**
|
|
4
|
+
* The `adminArea` namespace (0.42, docs/admin-harmonization.md §3.1): the kit's words of
|
|
5
|
+
* the admin area every app shares — the account menu's "Administration" row, the 403
|
|
6
|
+
* page, the shared sections' names and help lines, the overview's tiles and the Tools
|
|
7
|
+
* list. A module of words with no component code, like every `*-labels.ts` (0.34, KS U8).
|
|
8
|
+
* An app's own sections and tiles bring their own words.
|
|
9
|
+
*/
|
|
10
|
+
/** The sections every app's admin area shares, in the template's order (§2.3). */
|
|
11
|
+
export type AdminSharedSection = "overview" | "users" | "invitations" | "billing" | "activity";
|
|
12
|
+
/** The overview's shared tiles (§2.4, §6.1). */
|
|
13
|
+
export interface AdminTileLabels {
|
|
14
|
+
/** `feedback_waiting`: OPEN reports, crash reports included (§6.1). */
|
|
15
|
+
feedbackWaiting: string;
|
|
16
|
+
/** `deletion_requests`. */
|
|
17
|
+
deletionRequests: string;
|
|
18
|
+
/** `invitations_pending`. */
|
|
19
|
+
invitationsPending: string;
|
|
20
|
+
/** `users_total`. */
|
|
21
|
+
users: string;
|
|
22
|
+
/** `users_new_7d`, the line under the users tile. */
|
|
23
|
+
usersNew: (count: number) => string;
|
|
24
|
+
}
|
|
25
|
+
export interface AdminAreaLabels {
|
|
26
|
+
/** "Administration": the account menu's row, and the admin page's heading. */
|
|
27
|
+
title: string;
|
|
28
|
+
/** The row's waiting count, for a reader ("Administration, 3 waiting"); the eye sees
|
|
29
|
+
* the number in the badge. */
|
|
30
|
+
waiting: (count: number) => string;
|
|
31
|
+
/** The 403 page's heading (§2.2 decision 8). */
|
|
32
|
+
forbiddenTitle: string;
|
|
33
|
+
/**
|
|
34
|
+
* Under it. Says only that THIS area is closed to the account — never that the person
|
|
35
|
+
* administers nothing anywhere (§6.7: a kastlan superuser who isn't ADMIN in the acting
|
|
36
|
+
* company gets this page).
|
|
37
|
+
*/
|
|
38
|
+
forbiddenBody: (appName: string) => string;
|
|
39
|
+
/** The button back to the app's start, unless the app names its own (`homeLabel`). */
|
|
40
|
+
forbiddenHome: string;
|
|
41
|
+
/** A reviewer's second way out, to the translations review. */
|
|
42
|
+
forbiddenReviewer: string;
|
|
43
|
+
/** The shared sections' names and help lines (§2.3 decision 11). */
|
|
44
|
+
sections: Record<AdminSharedSection, SettingsGroupLabels>;
|
|
45
|
+
/** The overview's tiles. */
|
|
46
|
+
tiles: AdminTileLabels;
|
|
47
|
+
/** The Tools list's heading and name (§2.5 decision 16). */
|
|
48
|
+
tools: string;
|
|
49
|
+
}
|
|
50
|
+
export declare const DEFAULT_ADMIN_AREA_LABELS: AdminAreaLabels;
|
|
51
|
+
/**
|
|
52
|
+
* The `adminArea` namespace, resolved — English, then the provider, then `labels`. What
|
|
53
|
+
* an app reads to hand {@link adminSections} its words from inside a component.
|
|
54
|
+
*/
|
|
55
|
+
export declare function useAdminAreaLabels(labels?: LabelOverride<AdminAreaLabels>): AdminAreaLabels;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useKitLabels } from "../i18n/kit-labels.js";
|
|
3
|
+
const DEFAULT_ADMIN_AREA_LABELS = {
|
|
4
|
+
title: "Administration",
|
|
5
|
+
waiting: (count) => `${count} waiting`,
|
|
6
|
+
forbiddenTitle: "Only for administrators",
|
|
7
|
+
forbiddenBody: (appName) => `This is where administrators run ${appName}. Your account cannot open this page.`,
|
|
8
|
+
forbiddenHome: "Go to the start page",
|
|
9
|
+
forbiddenReviewer: "Review translations",
|
|
10
|
+
sections: {
|
|
11
|
+
overview: { title: "Overview", help: "What is waiting, at a glance." },
|
|
12
|
+
users: { title: "Users", help: "Who has an account, and what each may do." },
|
|
13
|
+
invitations: { title: "Invitations", help: "The links that let a new person in." },
|
|
14
|
+
billing: { title: "Billing", help: "The plan, the payment and the invoices." },
|
|
15
|
+
activity: { title: "Activity", help: "What the admins did, newest first." }
|
|
16
|
+
},
|
|
17
|
+
tiles: {
|
|
18
|
+
feedbackWaiting: "To triage",
|
|
19
|
+
deletionRequests: "Deletion requests",
|
|
20
|
+
invitationsPending: "Pending invitations",
|
|
21
|
+
users: "Users",
|
|
22
|
+
usersNew: (count) => `${count} new in 7 days`
|
|
23
|
+
},
|
|
24
|
+
tools: "Tools"
|
|
25
|
+
};
|
|
26
|
+
function useAdminAreaLabels(labels) {
|
|
27
|
+
return useKitLabels("adminArea", DEFAULT_ADMIN_AREA_LABELS, labels);
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
DEFAULT_ADMIN_AREA_LABELS,
|
|
31
|
+
useAdminAreaLabels
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=admin-area-labels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/admin/admin-area-labels.ts"],"sourcesContent":["import { useKitLabels, type LabelOverride } from \"../i18n/kit-labels\";\nimport type { SettingsGroupLabels } from \"../settings/settings-labels\";\n\n/**\n * The `adminArea` namespace (0.42, docs/admin-harmonization.md §3.1): the kit's words of\n * the admin area every app shares — the account menu's \"Administration\" row, the 403\n * page, the shared sections' names and help lines, the overview's tiles and the Tools\n * list. A module of words with no component code, like every `*-labels.ts` (0.34, KS U8).\n * An app's own sections and tiles bring their own words.\n */\n\n/** The sections every app's admin area shares, in the template's order (§2.3). */\nexport type AdminSharedSection = \"overview\" | \"users\" | \"invitations\" | \"billing\" | \"activity\";\n\n/** The overview's shared tiles (§2.4, §6.1). */\nexport interface AdminTileLabels {\n /** `feedback_waiting`: OPEN reports, crash reports included (§6.1). */\n feedbackWaiting: string;\n /** `deletion_requests`. */\n deletionRequests: string;\n /** `invitations_pending`. */\n invitationsPending: string;\n /** `users_total`. */\n users: string;\n /** `users_new_7d`, the line under the users tile. */\n usersNew: (count: number) => string;\n}\n\nexport interface AdminAreaLabels {\n /** \"Administration\": the account menu's row, and the admin page's heading. */\n title: string;\n /** The row's waiting count, for a reader (\"Administration, 3 waiting\"); the eye sees\n * the number in the badge. */\n waiting: (count: number) => string;\n /** The 403 page's heading (§2.2 decision 8). */\n forbiddenTitle: string;\n /**\n * Under it. Says only that THIS area is closed to the account — never that the person\n * administers nothing anywhere (§6.7: a kastlan superuser who isn't ADMIN in the acting\n * company gets this page).\n */\n forbiddenBody: (appName: string) => string;\n /** The button back to the app's start, unless the app names its own (`homeLabel`). */\n forbiddenHome: string;\n /** A reviewer's second way out, to the translations review. */\n forbiddenReviewer: string;\n /** The shared sections' names and help lines (§2.3 decision 11). */\n sections: Record<AdminSharedSection, SettingsGroupLabels>;\n /** The overview's tiles. */\n tiles: AdminTileLabels;\n /** The Tools list's heading and name (§2.5 decision 16). */\n tools: string;\n}\n\nexport const DEFAULT_ADMIN_AREA_LABELS: AdminAreaLabels = {\n title: \"Administration\",\n waiting: (count) => `${count} waiting`,\n forbiddenTitle: \"Only for administrators\",\n forbiddenBody: (appName) => `This is where administrators run ${appName}. Your account cannot open this page.`,\n forbiddenHome: \"Go to the start page\",\n forbiddenReviewer: \"Review translations\",\n sections: {\n overview: { title: \"Overview\", help: \"What is waiting, at a glance.\" },\n users: { title: \"Users\", help: \"Who has an account, and what each may do.\" },\n invitations: { title: \"Invitations\", help: \"The links that let a new person in.\" },\n billing: { title: \"Billing\", help: \"The plan, the payment and the invoices.\" },\n activity: { title: \"Activity\", help: \"What the admins did, newest first.\" },\n },\n tiles: {\n feedbackWaiting: \"To triage\",\n deletionRequests: \"Deletion requests\",\n invitationsPending: \"Pending invitations\",\n users: \"Users\",\n usersNew: (count) => `${count} new in 7 days`,\n },\n tools: \"Tools\",\n};\n\n/**\n * The `adminArea` namespace, resolved — English, then the provider, then `labels`. What\n * an app reads to hand {@link adminSections} its words from inside a component.\n */\nexport function useAdminAreaLabels(labels?: LabelOverride<AdminAreaLabels>): AdminAreaLabels {\n return useKitLabels(\"adminArea\", DEFAULT_ADMIN_AREA_LABELS, labels);\n}\n"],"mappings":";AAAA,SAAS,oBAAwC;AAsD1C,MAAM,4BAA6C;AAAA,EACxD,OAAO;AAAA,EACP,SAAS,CAAC,UAAU,GAAG,KAAK;AAAA,EAC5B,gBAAgB;AAAA,EAChB,eAAe,CAAC,YAAY,oCAAoC,OAAO;AAAA,EACvE,eAAe;AAAA,EACf,mBAAmB;AAAA,EACnB,UAAU;AAAA,IACR,UAAU,EAAE,OAAO,YAAY,MAAM,gCAAgC;AAAA,IACrE,OAAO,EAAE,OAAO,SAAS,MAAM,4CAA4C;AAAA,IAC3E,aAAa,EAAE,OAAO,eAAe,MAAM,sCAAsC;AAAA,IACjF,SAAS,EAAE,OAAO,WAAW,MAAM,0CAA0C;AAAA,IAC7E,UAAU,EAAE,OAAO,YAAY,MAAM,qCAAqC;AAAA,EAC5E;AAAA,EACA,OAAO;AAAA,IACL,iBAAiB;AAAA,IACjB,kBAAkB;AAAA,IAClB,oBAAoB;AAAA,IACpB,OAAO;AAAA,IACP,UAAU,CAAC,UAAU,GAAG,KAAK;AAAA,EAC/B;AAAA,EACA,OAAO;AACT;AAMO,SAAS,mBAAmB,QAA0D;AAC3F,SAAO,aAAa,aAAa,2BAA2B,MAAM;AACpE;","names":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ComponentPropsWithRef } from "react";
|
|
2
|
+
import type { LabelOverride } from "../i18n/kit-labels.js";
|
|
3
|
+
import type { AdminAreaLabels } from "./admin-area-labels.js";
|
|
4
|
+
export interface AdminForbiddenProps extends Omit<ComponentPropsWithRef<"div">, "children" | "title"> {
|
|
5
|
+
/** The app's name, in the sentence: "This is where administrators run Kastlan." */
|
|
6
|
+
appName: string;
|
|
7
|
+
/** The button's target: the app's start page (keksdose `/budget`, kastlan `/dashboard`). */
|
|
8
|
+
homeHref: string;
|
|
9
|
+
/** The button's words, where the app names its start ("Back to the budget"). Default
|
|
10
|
+
* `adminArea.forbiddenHome`, "Go to the start page". */
|
|
11
|
+
homeLabel?: string;
|
|
12
|
+
/** Pass it to a translation reviewer: a second button, "Review translations", to the
|
|
13
|
+
* tool their role does have (§2.2 decision 8). */
|
|
14
|
+
reviewerHref?: string;
|
|
15
|
+
/** The heading's level. Default `h1`: the page stands alone inside the app shell. */
|
|
16
|
+
headingAs?: "h1" | "h2" | "h3";
|
|
17
|
+
/** Prop > `<UiKitProvider labels={{ adminArea }}>` > English. */
|
|
18
|
+
labels?: LabelOverride<AdminAreaLabels>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The admin area's 403 page (0.42.0, docs/admin-harmonization.md §2.2 decision 8, §6.7),
|
|
22
|
+
* keksdose's `AdminForbidden`: "Only for administrators" / "This is where administrators
|
|
23
|
+
* run {app}. Your account cannot open this page.", and a button back to the app's start.
|
|
24
|
+
*
|
|
25
|
+
* It RENDERS, it does not redirect: the app's client gate shows it in place of the admin
|
|
26
|
+
* page, on the same admin check the account menu uses, inside the lazy route — so a
|
|
27
|
+
* bookmark keeps its address, and signing in as an admin opens the page that was asked
|
|
28
|
+
* for. The server's gate stays the rule. kastlan shows it on its admin tools (`/admin`,
|
|
29
|
+
* `/import`, `/feedback`); its work pages keep their generic 403.
|
|
30
|
+
*
|
|
31
|
+
* The words say only that this area is closed to this account, never that the person
|
|
32
|
+
* administers nothing anywhere: a kastlan superuser who isn't ADMIN in the acting company
|
|
33
|
+
* gets this page too.
|
|
34
|
+
*/
|
|
35
|
+
export declare function AdminForbidden({ appName, homeHref, homeLabel, reviewerHref, headingAs, labels: labelsProp, className, ...rest }: AdminForbiddenProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { ShieldAlert } from "lucide-react";
|
|
4
|
+
import { cn } from "../lib/cn.js";
|
|
5
|
+
import { Button } from "../components/button.js";
|
|
6
|
+
import { EmptyState } from "../components/empty-state.js";
|
|
7
|
+
import { useAdminAreaLabels } from "./admin-area-labels.js";
|
|
8
|
+
function AdminForbidden({
|
|
9
|
+
appName,
|
|
10
|
+
homeHref,
|
|
11
|
+
homeLabel,
|
|
12
|
+
reviewerHref,
|
|
13
|
+
headingAs = "h1",
|
|
14
|
+
labels: labelsProp,
|
|
15
|
+
className,
|
|
16
|
+
...rest
|
|
17
|
+
}) {
|
|
18
|
+
const labels = useAdminAreaLabels(labelsProp);
|
|
19
|
+
return /* @__PURE__ */ jsx("div", { ...rest, "data-slot": "admin-forbidden", className: cn("mx-auto w-full max-w-xl p-4 md:p-6", className), children: /* @__PURE__ */ jsx(
|
|
20
|
+
EmptyState,
|
|
21
|
+
{
|
|
22
|
+
icon: /* @__PURE__ */ jsx(ShieldAlert, {}),
|
|
23
|
+
headingAs,
|
|
24
|
+
title: labels.forbiddenTitle,
|
|
25
|
+
hint: labels.forbiddenBody(appName),
|
|
26
|
+
action: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
27
|
+
/* @__PURE__ */ jsx(Button, { href: homeHref, variant: "secondary", children: homeLabel ?? labels.forbiddenHome }),
|
|
28
|
+
reviewerHref !== void 0 && /* @__PURE__ */ jsx(Button, { href: reviewerHref, variant: "secondary", children: labels.forbiddenReviewer })
|
|
29
|
+
] })
|
|
30
|
+
}
|
|
31
|
+
) });
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
AdminForbidden
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=admin-forbidden.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/admin/admin-forbidden.tsx"],"sourcesContent":["import type { ComponentPropsWithRef } from \"react\";\nimport { ShieldAlert } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { Button } from \"../components/button\";\nimport { EmptyState } from \"../components/empty-state\";\nimport type { LabelOverride } from \"../i18n/kit-labels\";\nimport { useAdminAreaLabels } from \"./admin-area-labels\";\nimport type { AdminAreaLabels } from \"./admin-area-labels\";\n\nexport interface AdminForbiddenProps extends Omit<ComponentPropsWithRef<\"div\">, \"children\" | \"title\"> {\n /** The app's name, in the sentence: \"This is where administrators run Kastlan.\" */\n appName: string;\n /** The button's target: the app's start page (keksdose `/budget`, kastlan `/dashboard`). */\n homeHref: string;\n /** The button's words, where the app names its start (\"Back to the budget\"). Default\n * `adminArea.forbiddenHome`, \"Go to the start page\". */\n homeLabel?: string;\n /** Pass it to a translation reviewer: a second button, \"Review translations\", to the\n * tool their role does have (§2.2 decision 8). */\n reviewerHref?: string;\n /** The heading's level. Default `h1`: the page stands alone inside the app shell. */\n headingAs?: \"h1\" | \"h2\" | \"h3\";\n /** Prop > `<UiKitProvider labels={{ adminArea }}>` > English. */\n labels?: LabelOverride<AdminAreaLabels>;\n}\n\n/**\n * The admin area's 403 page (0.42.0, docs/admin-harmonization.md §2.2 decision 8, §6.7),\n * keksdose's `AdminForbidden`: \"Only for administrators\" / \"This is where administrators\n * run {app}. Your account cannot open this page.\", and a button back to the app's start.\n *\n * It RENDERS, it does not redirect: the app's client gate shows it in place of the admin\n * page, on the same admin check the account menu uses, inside the lazy route — so a\n * bookmark keeps its address, and signing in as an admin opens the page that was asked\n * for. The server's gate stays the rule. kastlan shows it on its admin tools (`/admin`,\n * `/import`, `/feedback`); its work pages keep their generic 403.\n *\n * The words say only that this area is closed to this account, never that the person\n * administers nothing anywhere: a kastlan superuser who isn't ADMIN in the acting company\n * gets this page too.\n */\nexport function AdminForbidden({\n appName,\n homeHref,\n homeLabel,\n reviewerHref,\n headingAs = \"h1\",\n labels: labelsProp,\n className,\n ...rest\n}: AdminForbiddenProps) {\n const labels = useAdminAreaLabels(labelsProp);\n return (\n <div {...rest} data-slot=\"admin-forbidden\" className={cn(\"mx-auto w-full max-w-xl p-4 md:p-6\", className)}>\n <EmptyState\n icon={<ShieldAlert />}\n headingAs={headingAs}\n title={labels.forbiddenTitle}\n hint={labels.forbiddenBody(appName)}\n action={\n <>\n <Button href={homeHref} variant=\"secondary\">\n {homeLabel ?? labels.forbiddenHome}\n </Button>\n {reviewerHref !== undefined && (\n <Button href={reviewerHref} variant=\"secondary\">\n {labels.forbiddenReviewer}\n </Button>\n )}\n </>\n }\n />\n </div>\n );\n}\n"],"mappings":";AAuDc,SAKJ,UALI,KAKJ,YALI;AAtDd,SAAS,mBAAmB;AAC5B,SAAS,UAAU;AACnB,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAE3B,SAAS,0BAA0B;AAmC5B,SAAS,eAAe;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR;AAAA,EACA,GAAG;AACL,GAAwB;AACtB,QAAM,SAAS,mBAAmB,UAAU;AAC5C,SACE,oBAAC,SAAK,GAAG,MAAM,aAAU,mBAAkB,WAAW,GAAG,sCAAsC,SAAS,GACtG;AAAA,IAAC;AAAA;AAAA,MACC,MAAM,oBAAC,eAAY;AAAA,MACnB;AAAA,MACA,OAAO,OAAO;AAAA,MACd,MAAM,OAAO,cAAc,OAAO;AAAA,MAClC,QACE,iCACE;AAAA,4BAAC,UAAO,MAAM,UAAU,SAAQ,aAC7B,uBAAa,OAAO,eACvB;AAAA,QACC,iBAAiB,UAChB,oBAAC,UAAO,MAAM,cAAc,SAAQ,aACjC,iBAAO,mBACV;AAAA,SAEJ;AAAA;AAAA,EAEJ,GACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { StatTileProps } from "../components/stat-tile.js";
|
|
3
|
+
import type { LabelOverride } from "../i18n/kit-labels.js";
|
|
4
|
+
import type { AdminAreaLabels } from "./admin-area-labels.js";
|
|
5
|
+
/**
|
|
6
|
+
* The admin's start page (0.42.0, docs/admin-harmonization.md §2.4, §6.1–§6.5): a grid
|
|
7
|
+
* of tiles, each a count of what is waiting and a link to where the work is, fed by one
|
|
8
|
+
* server answer.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* `GET /admin/attention` (§2.4 decision 14, §6.4) — server-kit's `AdminAttention`
|
|
12
|
+
* (`eifi1_server_kit.user_admin.attention`), as the API sends it.
|
|
13
|
+
*
|
|
14
|
+
* Each count is `null` where the app has no such thing or this viewer cannot act on it,
|
|
15
|
+
* and every count is `null` in a demo session. Demo accounts never count. `extra` holds
|
|
16
|
+
* the app's own counts, keyed as its overview names them (keksdose `support_waiting`,
|
|
17
|
+
* Kurvenschmiede `released_for_work`).
|
|
18
|
+
*/
|
|
19
|
+
export interface AdminAttention {
|
|
20
|
+
/** "To triage": OPEN reports, crash reports included (§6.1). */
|
|
21
|
+
feedback_waiting: number | null;
|
|
22
|
+
/** Accounts that asked to be deleted — only where this viewer acts on them (§6.2). */
|
|
23
|
+
deletion_requests: number | null;
|
|
24
|
+
invitations_pending: number | null;
|
|
25
|
+
users_total: number | null;
|
|
26
|
+
/** Accounts made in the last seven days. */
|
|
27
|
+
users_new_7d: number | null;
|
|
28
|
+
extra: Record<string, number | null>;
|
|
29
|
+
}
|
|
30
|
+
/** The shared counts that are a tile of their own (`users_new_7d` is the users tile's line). */
|
|
31
|
+
export type AdminAttentionTile = "feedback_waiting" | "deletion_requests" | "invitations_pending" | "users_total";
|
|
32
|
+
/** Where each shared tile links when the app names nothing else (§2.4 decision 13). */
|
|
33
|
+
export declare const DEFAULT_ADMIN_ATTENTION_HREFS: Readonly<Record<AdminAttentionTile, string>>;
|
|
34
|
+
/**
|
|
35
|
+
* The account menu's badge (§2.4 decision 15, §6.3): the sum of the counts that are work
|
|
36
|
+
* waiting on THIS admin — each app names its own (keksdose `["feedback_waiting",
|
|
37
|
+
* "support_waiting", "awaiting_verdict"]`, kastlan `["feedback_waiting"]`, Kurvenschmiede
|
|
38
|
+
* `["feedback_waiting", "deletion_requests"]`). A name is a shared count or an `extra`
|
|
39
|
+
* key; a `null` or missing count adds nothing. Invitations and users never belong in it.
|
|
40
|
+
* `null` while there is no answer yet, so the badge shows nothing rather than a 0.
|
|
41
|
+
*/
|
|
42
|
+
export declare function adminWaitingCount(attention: AdminAttention | null | undefined, counts: readonly (AdminAttentionTile | (string & {}))[]): number | null;
|
|
43
|
+
export interface AttentionTileProps extends Omit<StatTileProps, "href" | "onClick" | "value"> {
|
|
44
|
+
/** The count. `null` shows the tile's dash; {@link AdminOverview} leaves such a tile out. */
|
|
45
|
+
count: number | null | undefined;
|
|
46
|
+
/** Where the work is — the tile is a link to it. */
|
|
47
|
+
href: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* One tile of the overview: a {@link StatTile} that is a LINK to where the work is, its
|
|
51
|
+
* count the headline. The whole tile is the link, named by its label; route it through
|
|
52
|
+
* `renderLink` or the provider's link component, as any StatTile.
|
|
53
|
+
*/
|
|
54
|
+
export declare function AttentionTile({ count, href, ...tile }: AttentionTileProps): import("react").JSX.Element;
|
|
55
|
+
/** One of the app's own tiles (§2.4 decision 13: keksdose's "Support waiting"). */
|
|
56
|
+
export interface AdminExtraTile {
|
|
57
|
+
/** Unique among the tiles; usually the `extra` key it shows. */
|
|
58
|
+
key: string;
|
|
59
|
+
label: ReactNode;
|
|
60
|
+
/** `null` or `undefined` leaves the tile out, as for a shared one. */
|
|
61
|
+
count: number | null | undefined;
|
|
62
|
+
href: string;
|
|
63
|
+
/** A line under the count. */
|
|
64
|
+
description?: ReactNode;
|
|
65
|
+
}
|
|
66
|
+
export interface AdminOverviewProps {
|
|
67
|
+
/** The server's answer; `undefined` while it loads (the grid shows its skeletons). */
|
|
68
|
+
attention: AdminAttention | null | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Where the shared tiles link, over {@link DEFAULT_ADMIN_ATTENTION_HREFS} — the
|
|
71
|
+
* inbox's address filtered to OPEN (§6.1) is the app's own:
|
|
72
|
+
* `{ feedback_waiting: "/feedback?status=OPEN" }`.
|
|
73
|
+
*/
|
|
74
|
+
hrefs?: Partial<Record<AdminAttentionTile, string>>;
|
|
75
|
+
/** The app's own tiles, after the shared ones, in this order. */
|
|
76
|
+
extraTiles?: readonly AdminExtraTile[];
|
|
77
|
+
/** Passed to every tile — `renderLink` for the router, `size`, `variant`. */
|
|
78
|
+
tileProps?: Pick<StatTileProps, "renderLink" | "size" | "variant" | "locale">;
|
|
79
|
+
/** Prop > `<UiKitProvider labels={{ adminArea }}>` > English. */
|
|
80
|
+
labels?: LabelOverride<AdminAreaLabels>;
|
|
81
|
+
className?: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The overview section (§2.4): the shared tiles in their order — To triage, Deletion
|
|
85
|
+
* requests, Pending invitations, Users (with the new accounts of the last 7 days under
|
|
86
|
+
* the total) — then the app's `extraTiles`. A tile whose count is `null` is left out,
|
|
87
|
+
* so each app shows only what it has; a `0` is a quiet tile, "nothing waiting".
|
|
88
|
+
*
|
|
89
|
+
* Put it in the `overview` section's `SettingsSection` (titled by the sidebar, so
|
|
90
|
+
* `titleVisible={false}`). keksdose links its metrics from here with at most two tiles
|
|
91
|
+
* (§6.5).
|
|
92
|
+
*/
|
|
93
|
+
export declare function AdminOverview({ attention, hrefs, extraTiles, tileProps, labels: labelsProp, className, }: AdminOverviewProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { StatTile, StatTileGrid } from "../components/stat-tile.js";
|
|
4
|
+
import { useAdminAreaLabels } from "./admin-area-labels.js";
|
|
5
|
+
const DEFAULT_ADMIN_ATTENTION_HREFS = Object.freeze({
|
|
6
|
+
feedback_waiting: "/feedback",
|
|
7
|
+
deletion_requests: "/admin/users?state=deletion_requested",
|
|
8
|
+
invitations_pending: "/admin/invitations",
|
|
9
|
+
users_total: "/admin/users"
|
|
10
|
+
});
|
|
11
|
+
function adminWaitingCount(attention, counts) {
|
|
12
|
+
if (!attention) return null;
|
|
13
|
+
let sum = 0;
|
|
14
|
+
for (const key of counts) {
|
|
15
|
+
const shared = attention[key];
|
|
16
|
+
const value = typeof shared === "number" ? shared : attention.extra?.[key];
|
|
17
|
+
if (typeof value === "number" && value > 0) sum += value;
|
|
18
|
+
}
|
|
19
|
+
return sum;
|
|
20
|
+
}
|
|
21
|
+
function AttentionTile({ count, href, ...tile }) {
|
|
22
|
+
return /* @__PURE__ */ jsx(StatTile, { "data-slot": "attention-tile", ...tile, value: count ?? null, href });
|
|
23
|
+
}
|
|
24
|
+
function AdminOverview({
|
|
25
|
+
attention,
|
|
26
|
+
hrefs,
|
|
27
|
+
extraTiles = [],
|
|
28
|
+
tileProps,
|
|
29
|
+
labels: labelsProp,
|
|
30
|
+
className
|
|
31
|
+
}) {
|
|
32
|
+
const labels = useAdminAreaLabels(labelsProp);
|
|
33
|
+
const href = { ...DEFAULT_ADMIN_ATTENTION_HREFS, ...hrefs };
|
|
34
|
+
const loading = attention === void 0;
|
|
35
|
+
const shared = [
|
|
36
|
+
{ key: "feedback_waiting", label: labels.tiles.feedbackWaiting },
|
|
37
|
+
{ key: "deletion_requests", label: labels.tiles.deletionRequests },
|
|
38
|
+
{ key: "invitations_pending", label: labels.tiles.invitationsPending },
|
|
39
|
+
{
|
|
40
|
+
key: "users_total",
|
|
41
|
+
label: labels.tiles.users,
|
|
42
|
+
description: attention && typeof attention.users_new_7d === "number" ? labels.tiles.usersNew(attention.users_new_7d) : void 0
|
|
43
|
+
}
|
|
44
|
+
];
|
|
45
|
+
const tiles = [
|
|
46
|
+
...shared.map((t) => ({ ...t, count: attention ? attention[t.key] : void 0, href: href[t.key] })),
|
|
47
|
+
...extraTiles
|
|
48
|
+
].filter((t) => loading || t.count !== null && t.count !== void 0);
|
|
49
|
+
if (!loading && tiles.length === 0) return null;
|
|
50
|
+
return /* @__PURE__ */ jsx(StatTileGrid, { "data-slot": "admin-overview", loading, className, children: tiles.map((t) => /* @__PURE__ */ jsx(
|
|
51
|
+
AttentionTile,
|
|
52
|
+
{
|
|
53
|
+
...tileProps,
|
|
54
|
+
"data-attention": t.key,
|
|
55
|
+
label: t.label,
|
|
56
|
+
count: t.count,
|
|
57
|
+
href: t.href,
|
|
58
|
+
description: t.description
|
|
59
|
+
},
|
|
60
|
+
t.key
|
|
61
|
+
)) });
|
|
62
|
+
}
|
|
63
|
+
export {
|
|
64
|
+
AdminOverview,
|
|
65
|
+
AttentionTile,
|
|
66
|
+
DEFAULT_ADMIN_ATTENTION_HREFS,
|
|
67
|
+
adminWaitingCount
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=admin-overview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/admin/admin-overview.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { StatTile, StatTileGrid } from \"../components/stat-tile\";\nimport type { StatTileProps } from \"../components/stat-tile\";\nimport type { LabelOverride } from \"../i18n/kit-labels\";\nimport { useAdminAreaLabels } from \"./admin-area-labels\";\nimport type { AdminAreaLabels } from \"./admin-area-labels\";\n\n/**\n * The admin's start page (0.42.0, docs/admin-harmonization.md §2.4, §6.1–§6.5): a grid\n * of tiles, each a count of what is waiting and a link to where the work is, fed by one\n * server answer.\n */\n\n/**\n * `GET /admin/attention` (§2.4 decision 14, §6.4) — server-kit's `AdminAttention`\n * (`eifi1_server_kit.user_admin.attention`), as the API sends it.\n *\n * Each count is `null` where the app has no such thing or this viewer cannot act on it,\n * and every count is `null` in a demo session. Demo accounts never count. `extra` holds\n * the app's own counts, keyed as its overview names them (keksdose `support_waiting`,\n * Kurvenschmiede `released_for_work`).\n */\nexport interface AdminAttention {\n /** \"To triage\": OPEN reports, crash reports included (§6.1). */\n feedback_waiting: number | null;\n /** Accounts that asked to be deleted — only where this viewer acts on them (§6.2). */\n deletion_requests: number | null;\n invitations_pending: number | null;\n users_total: number | null;\n /** Accounts made in the last seven days. */\n users_new_7d: number | null;\n extra: Record<string, number | null>;\n}\n\n/** The shared counts that are a tile of their own (`users_new_7d` is the users tile's line). */\nexport type AdminAttentionTile = \"feedback_waiting\" | \"deletion_requests\" | \"invitations_pending\" | \"users_total\";\n\n/** Where each shared tile links when the app names nothing else (§2.4 decision 13). */\nexport const DEFAULT_ADMIN_ATTENTION_HREFS: Readonly<Record<AdminAttentionTile, string>> = Object.freeze({\n feedback_waiting: \"/feedback\",\n deletion_requests: \"/admin/users?state=deletion_requested\",\n invitations_pending: \"/admin/invitations\",\n users_total: \"/admin/users\",\n});\n\n/**\n * The account menu's badge (§2.4 decision 15, §6.3): the sum of the counts that are work\n * waiting on THIS admin — each app names its own (keksdose `[\"feedback_waiting\",\n * \"support_waiting\", \"awaiting_verdict\"]`, kastlan `[\"feedback_waiting\"]`, Kurvenschmiede\n * `[\"feedback_waiting\", \"deletion_requests\"]`). A name is a shared count or an `extra`\n * key; a `null` or missing count adds nothing. Invitations and users never belong in it.\n * `null` while there is no answer yet, so the badge shows nothing rather than a 0.\n */\nexport function adminWaitingCount(\n attention: AdminAttention | null | undefined,\n counts: readonly (AdminAttentionTile | (string & {}))[],\n): number | null {\n if (!attention) return null;\n let sum = 0;\n for (const key of counts) {\n const shared = (attention as unknown as Record<string, unknown>)[key];\n const value = typeof shared === \"number\" ? shared : attention.extra?.[key];\n if (typeof value === \"number\" && value > 0) sum += value;\n }\n return sum;\n}\n\nexport interface AttentionTileProps extends Omit<StatTileProps, \"href\" | \"onClick\" | \"value\"> {\n /** The count. `null` shows the tile's dash; {@link AdminOverview} leaves such a tile out. */\n count: number | null | undefined;\n /** Where the work is — the tile is a link to it. */\n href: string;\n}\n\n/**\n * One tile of the overview: a {@link StatTile} that is a LINK to where the work is, its\n * count the headline. The whole tile is the link, named by its label; route it through\n * `renderLink` or the provider's link component, as any StatTile.\n */\nexport function AttentionTile({ count, href, ...tile }: AttentionTileProps) {\n return <StatTile data-slot=\"attention-tile\" {...tile} value={count ?? null} href={href} />;\n}\n\n/** One of the app's own tiles (§2.4 decision 13: keksdose's \"Support waiting\"). */\nexport interface AdminExtraTile {\n /** Unique among the tiles; usually the `extra` key it shows. */\n key: string;\n label: ReactNode;\n /** `null` or `undefined` leaves the tile out, as for a shared one. */\n count: number | null | undefined;\n href: string;\n /** A line under the count. */\n description?: ReactNode;\n}\n\nexport interface AdminOverviewProps {\n /** The server's answer; `undefined` while it loads (the grid shows its skeletons). */\n attention: AdminAttention | null | undefined;\n /**\n * Where the shared tiles link, over {@link DEFAULT_ADMIN_ATTENTION_HREFS} — the\n * inbox's address filtered to OPEN (§6.1) is the app's own:\n * `{ feedback_waiting: \"/feedback?status=OPEN\" }`.\n */\n hrefs?: Partial<Record<AdminAttentionTile, string>>;\n /** The app's own tiles, after the shared ones, in this order. */\n extraTiles?: readonly AdminExtraTile[];\n /** Passed to every tile — `renderLink` for the router, `size`, `variant`. */\n tileProps?: Pick<StatTileProps, \"renderLink\" | \"size\" | \"variant\" | \"locale\">;\n /** Prop > `<UiKitProvider labels={{ adminArea }}>` > English. */\n labels?: LabelOverride<AdminAreaLabels>;\n className?: string;\n}\n\n/**\n * The overview section (§2.4): the shared tiles in their order — To triage, Deletion\n * requests, Pending invitations, Users (with the new accounts of the last 7 days under\n * the total) — then the app's `extraTiles`. A tile whose count is `null` is left out,\n * so each app shows only what it has; a `0` is a quiet tile, \"nothing waiting\".\n *\n * Put it in the `overview` section's `SettingsSection` (titled by the sidebar, so\n * `titleVisible={false}`). keksdose links its metrics from here with at most two tiles\n * (§6.5).\n */\nexport function AdminOverview({\n attention,\n hrefs,\n extraTiles = [],\n tileProps,\n labels: labelsProp,\n className,\n}: AdminOverviewProps) {\n const labels = useAdminAreaLabels(labelsProp);\n const href = { ...DEFAULT_ADMIN_ATTENTION_HREFS, ...hrefs };\n const loading = attention === undefined;\n const shared: { key: AdminAttentionTile; label: string; description?: ReactNode }[] = [\n { key: \"feedback_waiting\", label: labels.tiles.feedbackWaiting },\n { key: \"deletion_requests\", label: labels.tiles.deletionRequests },\n { key: \"invitations_pending\", label: labels.tiles.invitationsPending },\n {\n key: \"users_total\",\n label: labels.tiles.users,\n description:\n attention && typeof attention.users_new_7d === \"number\" ? labels.tiles.usersNew(attention.users_new_7d) : undefined,\n },\n ];\n const tiles = [\n ...shared.map((t) => ({ ...t, count: attention ? attention[t.key] : undefined, href: href[t.key] })),\n ...extraTiles,\n ].filter((t) => loading || (t.count !== null && t.count !== undefined));\n if (!loading && tiles.length === 0) return null;\n return (\n <StatTileGrid data-slot=\"admin-overview\" loading={loading} className={className}>\n {tiles.map((t) => (\n <AttentionTile\n key={t.key}\n {...tileProps}\n data-attention={t.key}\n label={t.label}\n count={t.count}\n href={t.href}\n description={t.description}\n />\n ))}\n </StatTileGrid>\n );\n}\n"],"mappings":";AAgFS;AA/ET,SAAS,UAAU,oBAAoB;AAGvC,SAAS,0BAA0B;AAkC5B,MAAM,gCAA8E,OAAO,OAAO;AAAA,EACvG,kBAAkB;AAAA,EAClB,mBAAmB;AAAA,EACnB,qBAAqB;AAAA,EACrB,aAAa;AACf,CAAC;AAUM,SAAS,kBACd,WACA,QACe;AACf,MAAI,CAAC,UAAW,QAAO;AACvB,MAAI,MAAM;AACV,aAAW,OAAO,QAAQ;AACxB,UAAM,SAAU,UAAiD,GAAG;AACpE,UAAM,QAAQ,OAAO,WAAW,WAAW,SAAS,UAAU,QAAQ,GAAG;AACzE,QAAI,OAAO,UAAU,YAAY,QAAQ,EAAG,QAAO;AAAA,EACrD;AACA,SAAO;AACT;AAcO,SAAS,cAAc,EAAE,OAAO,MAAM,GAAG,KAAK,GAAuB;AAC1E,SAAO,oBAAC,YAAS,aAAU,kBAAkB,GAAG,MAAM,OAAO,SAAS,MAAM,MAAY;AAC1F;AA0CO,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA;AAAA,EACA,aAAa,CAAC;AAAA,EACd;AAAA,EACA,QAAQ;AAAA,EACR;AACF,GAAuB;AACrB,QAAM,SAAS,mBAAmB,UAAU;AAC5C,QAAM,OAAO,EAAE,GAAG,+BAA+B,GAAG,MAAM;AAC1D,QAAM,UAAU,cAAc;AAC9B,QAAM,SAAgF;AAAA,IACpF,EAAE,KAAK,oBAAoB,OAAO,OAAO,MAAM,gBAAgB;AAAA,IAC/D,EAAE,KAAK,qBAAqB,OAAO,OAAO,MAAM,iBAAiB;AAAA,IACjE,EAAE,KAAK,uBAAuB,OAAO,OAAO,MAAM,mBAAmB;AAAA,IACrE;AAAA,MACE,KAAK;AAAA,MACL,OAAO,OAAO,MAAM;AAAA,MACpB,aACE,aAAa,OAAO,UAAU,iBAAiB,WAAW,OAAO,MAAM,SAAS,UAAU,YAAY,IAAI;AAAA,IAC9G;AAAA,EACF;AACA,QAAM,QAAQ;AAAA,IACZ,GAAG,OAAO,IAAI,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,YAAY,UAAU,EAAE,GAAG,IAAI,QAAW,MAAM,KAAK,EAAE,GAAG,EAAE,EAAE;AAAA,IACnG,GAAG;AAAA,EACL,EAAE,OAAO,CAAC,MAAM,WAAY,EAAE,UAAU,QAAQ,EAAE,UAAU,MAAU;AACtE,MAAI,CAAC,WAAW,MAAM,WAAW,EAAG,QAAO;AAC3C,SACE,oBAAC,gBAAa,aAAU,kBAAiB,SAAkB,WACxD,gBAAM,IAAI,CAAC,MACV;AAAA,IAAC;AAAA;AAAA,MAEE,GAAG;AAAA,MACJ,kBAAgB,EAAE;AAAA,MAClB,OAAO,EAAE;AAAA,MACT,OAAO,EAAE;AAAA,MACT,MAAM,EAAE;AAAA,MACR,aAAa,EAAE;AAAA;AAAA,IANV,EAAE;AAAA,EAOT,CACD,GACH;AAEJ;","names":[]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { LucideIcon } from "lucide-react";
|
|
2
|
+
import type { SettingsGroup } from "../settings/settings-catalogue.js";
|
|
3
|
+
import type { AdminAreaLabels, AdminSharedSection } from "./admin-area-labels.js";
|
|
4
|
+
/**
|
|
5
|
+
* The admin area's sections (0.42.0, docs/admin-harmonization.md §2.3, §6.8): the five
|
|
6
|
+
* every app shares, in the template's order, and the helper that builds an app's
|
|
7
|
+
* `SettingsLayout` catalogue groups from them and the app's own.
|
|
8
|
+
*/
|
|
9
|
+
/** One shared section: its path segment and its icon. The words are `adminArea.sections`. */
|
|
10
|
+
export interface AdminSectionDefinition {
|
|
11
|
+
id: AdminSharedSection;
|
|
12
|
+
icon: LucideIcon;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The shared sections in the template's order (§2.3 decision 10, §6.13): Overview, Users,
|
|
16
|
+
* Invitations, Billing, Activity. An app's own sections go between them
|
|
17
|
+
* ({@link adminSections}).
|
|
18
|
+
*/
|
|
19
|
+
export declare const ADMIN_SECTIONS: readonly AdminSectionDefinition[];
|
|
20
|
+
/**
|
|
21
|
+
* One of the app's own sections: a catalogue group with its words, plus where it goes.
|
|
22
|
+
* `after` names the section it follows — a shared one or another of the app's own. Left
|
|
23
|
+
* out, it goes where the template puts an app's sections, after Invitations and before
|
|
24
|
+
* Billing, in the order given.
|
|
25
|
+
*/
|
|
26
|
+
export interface AdminOwnSection<G extends string = string> extends SettingsGroup<G> {
|
|
27
|
+
after?: AdminSharedSection | G;
|
|
28
|
+
}
|
|
29
|
+
export interface AdminSectionsOptions {
|
|
30
|
+
/**
|
|
31
|
+
* Shared sections this app does not have — keksdose and Kurvenschmiede have no billing
|
|
32
|
+
* view (`["billing"]`). Left out, every shared section is in the catalogue.
|
|
33
|
+
*/
|
|
34
|
+
leaveOut?: readonly AdminSharedSection[];
|
|
35
|
+
/**
|
|
36
|
+
* A shared section that is in the catalogue but hidden for now, as
|
|
37
|
+
* {@link SettingsGroup.visible}: kastlan's `{ billing: billingEnabled }` (settings §5),
|
|
38
|
+
* whose path then acts as an unknown one.
|
|
39
|
+
*/
|
|
40
|
+
visible?: Partial<Record<AdminSharedSection, boolean>>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* An app's admin catalogue groups, in the template's order (§2.3 decision 10, §6.8): the
|
|
44
|
+
* shared sections with the kit's icons and words, and the app's own at the places they
|
|
45
|
+
* name. The result is `SettingsLayout`'s `groups`; the entries stay the app's (a group
|
|
46
|
+
* with no visible entry is hidden, as on any settings page).
|
|
47
|
+
*
|
|
48
|
+
* const groups = adminSections(useAdminAreaLabels(), [
|
|
49
|
+
* { id: "metrics", icon: <BarChart3 />, title: t("…"), help: t("…"), after: "overview" },
|
|
50
|
+
* { id: "messaging", icon: <MessageSquare />, title: t("…"), help: t("…") },
|
|
51
|
+
* { id: "health", icon: <HeartPulse />, title: t("…"), help: t("…"), after: "billing" },
|
|
52
|
+
* ], { leaveOut: ["billing"] });
|
|
53
|
+
*
|
|
54
|
+
* gives keksdose's overview, metrics, users, invitations, messaging, health, activity.
|
|
55
|
+
* An `after` that names a left-out section takes that section's place. Kurvenschmiede's
|
|
56
|
+
* Teams needs no `after`: between Invitations and Activity is the default.
|
|
57
|
+
*
|
|
58
|
+
* `labels` is the `adminArea` namespace, resolved — {@link useAdminAreaLabels} inside a
|
|
59
|
+
* component, or the app's catalogue for the language; `undefined` is English. Throws for
|
|
60
|
+
* an own section whose id is a shared one, an id given twice, or an `after` that names no
|
|
61
|
+
* section: the catalogue is built once, and a section quietly missing from it is worse.
|
|
62
|
+
*/
|
|
63
|
+
export declare function adminSections<G extends string = never>(labels: AdminAreaLabels | undefined, own?: readonly AdminOwnSection<G>[], options?: AdminSectionsOptions): SettingsGroup<AdminSharedSection | G>[];
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createElement } from "react";
|
|
3
|
+
import { History, LayoutDashboard, Mail, Receipt, Users } from "lucide-react";
|
|
4
|
+
import { DEFAULT_ADMIN_AREA_LABELS } from "./admin-area-labels.js";
|
|
5
|
+
const ADMIN_SECTIONS = Object.freeze([
|
|
6
|
+
{ id: "overview", icon: LayoutDashboard },
|
|
7
|
+
{ id: "users", icon: Users },
|
|
8
|
+
{ id: "invitations", icon: Mail },
|
|
9
|
+
{ id: "billing", icon: Receipt },
|
|
10
|
+
{ id: "activity", icon: History }
|
|
11
|
+
]);
|
|
12
|
+
const OWN_DEFAULT_AFTER = "invitations";
|
|
13
|
+
function adminSections(labels, own = [], options = {}) {
|
|
14
|
+
const words = labels ?? DEFAULT_ADMIN_AREA_LABELS;
|
|
15
|
+
const leaveOut = new Set(options.leaveOut ?? []);
|
|
16
|
+
const shared = new Set(ADMIN_SECTIONS.map((s) => s.id));
|
|
17
|
+
const ownIds = /* @__PURE__ */ new Set();
|
|
18
|
+
for (const section of own) {
|
|
19
|
+
if (shared.has(section.id)) throw new Error(`adminSections: "${section.id}" is a shared section's id`);
|
|
20
|
+
if (ownIds.has(section.id)) throw new Error(`adminSections: "${section.id}" is given twice`);
|
|
21
|
+
ownIds.add(section.id);
|
|
22
|
+
}
|
|
23
|
+
for (const section of own) {
|
|
24
|
+
const after = section.after;
|
|
25
|
+
if (after !== void 0 && !shared.has(after) && !ownIds.has(after)) {
|
|
26
|
+
throw new Error(`adminSections: "${section.id}" goes after "${after}", which is no section`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const followers = /* @__PURE__ */ new Map();
|
|
30
|
+
for (const section of own) {
|
|
31
|
+
const after = section.after ?? OWN_DEFAULT_AFTER;
|
|
32
|
+
followers.set(after, [...followers.get(after) ?? [], section]);
|
|
33
|
+
}
|
|
34
|
+
const out = [];
|
|
35
|
+
const placeAfter = (id) => {
|
|
36
|
+
for (const section of followers.get(id) ?? []) {
|
|
37
|
+
const { after: _after, ...group } = section;
|
|
38
|
+
out.push(group);
|
|
39
|
+
placeAfter(section.id);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
for (const { id, icon } of ADMIN_SECTIONS) {
|
|
43
|
+
if (!leaveOut.has(id)) {
|
|
44
|
+
const visible = options.visible?.[id];
|
|
45
|
+
out.push({
|
|
46
|
+
id,
|
|
47
|
+
icon: createElement(icon, { "aria-hidden": true }),
|
|
48
|
+
title: words.sections[id].title,
|
|
49
|
+
help: words.sections[id].help,
|
|
50
|
+
...visible === void 0 ? null : { visible }
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
placeAfter(id);
|
|
54
|
+
}
|
|
55
|
+
const placed = new Set(out.map((g) => g.id));
|
|
56
|
+
const stuck = own.filter((s) => !placed.has(s.id)).map((s) => s.id);
|
|
57
|
+
if (stuck.length) throw new Error(`adminSections: ${stuck.join(", ")} follow each other in a circle`);
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
export {
|
|
61
|
+
ADMIN_SECTIONS,
|
|
62
|
+
adminSections
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=admin-sections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/admin/admin-sections.tsx"],"sourcesContent":["import { createElement } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { History, LayoutDashboard, Mail, Receipt, Users } from \"lucide-react\";\nimport type { LucideIcon } from \"lucide-react\";\nimport type { SettingsGroup } from \"../settings/settings-catalogue\";\nimport { DEFAULT_ADMIN_AREA_LABELS } from \"./admin-area-labels\";\nimport type { AdminAreaLabels, AdminSharedSection } from \"./admin-area-labels\";\n\n/**\n * The admin area's sections (0.42.0, docs/admin-harmonization.md §2.3, §6.8): the five\n * every app shares, in the template's order, and the helper that builds an app's\n * `SettingsLayout` catalogue groups from them and the app's own.\n */\n\n/** One shared section: its path segment and its icon. The words are `adminArea.sections`. */\nexport interface AdminSectionDefinition {\n id: AdminSharedSection;\n icon: LucideIcon;\n}\n\n/**\n * The shared sections in the template's order (§2.3 decision 10, §6.13): Overview, Users,\n * Invitations, Billing, Activity. An app's own sections go between them\n * ({@link adminSections}).\n */\nexport const ADMIN_SECTIONS: readonly AdminSectionDefinition[] = Object.freeze([\n { id: \"overview\", icon: LayoutDashboard },\n { id: \"users\", icon: Users },\n { id: \"invitations\", icon: Mail },\n { id: \"billing\", icon: Receipt },\n { id: \"activity\", icon: History },\n]);\n\n/**\n * One of the app's own sections: a catalogue group with its words, plus where it goes.\n * `after` names the section it follows — a shared one or another of the app's own. Left\n * out, it goes where the template puts an app's sections, after Invitations and before\n * Billing, in the order given.\n */\nexport interface AdminOwnSection<G extends string = string> extends SettingsGroup<G> {\n after?: AdminSharedSection | G;\n}\n\nexport interface AdminSectionsOptions {\n /**\n * Shared sections this app does not have — keksdose and Kurvenschmiede have no billing\n * view (`[\"billing\"]`). Left out, every shared section is in the catalogue.\n */\n leaveOut?: readonly AdminSharedSection[];\n /**\n * A shared section that is in the catalogue but hidden for now, as\n * {@link SettingsGroup.visible}: kastlan's `{ billing: billingEnabled }` (settings §5),\n * whose path then acts as an unknown one.\n */\n visible?: Partial<Record<AdminSharedSection, boolean>>;\n}\n\n/** The shared section after which the app's sections go when they name no place. */\nconst OWN_DEFAULT_AFTER: AdminSharedSection = \"invitations\";\n\n/**\n * An app's admin catalogue groups, in the template's order (§2.3 decision 10, §6.8): the\n * shared sections with the kit's icons and words, and the app's own at the places they\n * name. The result is `SettingsLayout`'s `groups`; the entries stay the app's (a group\n * with no visible entry is hidden, as on any settings page).\n *\n * const groups = adminSections(useAdminAreaLabels(), [\n * { id: \"metrics\", icon: <BarChart3 />, title: t(\"…\"), help: t(\"…\"), after: \"overview\" },\n * { id: \"messaging\", icon: <MessageSquare />, title: t(\"…\"), help: t(\"…\") },\n * { id: \"health\", icon: <HeartPulse />, title: t(\"…\"), help: t(\"…\"), after: \"billing\" },\n * ], { leaveOut: [\"billing\"] });\n *\n * gives keksdose's overview, metrics, users, invitations, messaging, health, activity.\n * An `after` that names a left-out section takes that section's place. Kurvenschmiede's\n * Teams needs no `after`: between Invitations and Activity is the default.\n *\n * `labels` is the `adminArea` namespace, resolved — {@link useAdminAreaLabels} inside a\n * component, or the app's catalogue for the language; `undefined` is English. Throws for\n * an own section whose id is a shared one, an id given twice, or an `after` that names no\n * section: the catalogue is built once, and a section quietly missing from it is worse.\n */\nexport function adminSections<G extends string = never>(\n labels: AdminAreaLabels | undefined,\n own: readonly AdminOwnSection<G>[] = [],\n options: AdminSectionsOptions = {},\n): SettingsGroup<AdminSharedSection | G>[] {\n const words = labels ?? DEFAULT_ADMIN_AREA_LABELS;\n const leaveOut = new Set<string>(options.leaveOut ?? []);\n const shared = new Set<string>(ADMIN_SECTIONS.map((s) => s.id));\n const ownIds = new Set<string>();\n for (const section of own) {\n if (shared.has(section.id)) throw new Error(`adminSections: \"${section.id}\" is a shared section's id`);\n if (ownIds.has(section.id)) throw new Error(`adminSections: \"${section.id}\" is given twice`);\n ownIds.add(section.id);\n }\n for (const section of own) {\n const after = section.after;\n if (after !== undefined && !shared.has(after) && !ownIds.has(after)) {\n throw new Error(`adminSections: \"${section.id}\" goes after \"${after}\", which is no section`);\n }\n }\n\n // Each section's followers, in the order given: the shared ones, then the own ones\n // under their `after`, recursively, so an own section may follow another own one.\n const followers = new Map<string, AdminOwnSection<G>[]>();\n for (const section of own) {\n const after = section.after ?? OWN_DEFAULT_AFTER;\n followers.set(after, [...(followers.get(after) ?? []), section]);\n }\n\n const out: SettingsGroup<AdminSharedSection | G>[] = [];\n const placeAfter = (id: string) => {\n for (const section of followers.get(id) ?? []) {\n const { after: _after, ...group } = section;\n out.push(group);\n placeAfter(section.id);\n }\n };\n for (const { id, icon } of ADMIN_SECTIONS) {\n if (!leaveOut.has(id)) {\n const visible = options.visible?.[id];\n out.push({\n id,\n icon: createElement(icon, { \"aria-hidden\": true }) as ReactNode,\n title: words.sections[id].title,\n help: words.sections[id].help,\n ...(visible === undefined ? null : { visible }),\n });\n }\n // A left-out section's followers keep its place.\n placeAfter(id);\n }\n const placed = new Set<string>(out.map((g) => g.id));\n const stuck = own.filter((s) => !placed.has(s.id)).map((s) => s.id);\n if (stuck.length) throw new Error(`adminSections: ${stuck.join(\", \")} follow each other in a circle`);\n return out;\n}\n"],"mappings":";AAAA,SAAS,qBAAqB;AAE9B,SAAS,SAAS,iBAAiB,MAAM,SAAS,aAAa;AAG/D,SAAS,iCAAiC;AAoBnC,MAAM,iBAAoD,OAAO,OAAO;AAAA,EAC7E,EAAE,IAAI,YAAY,MAAM,gBAAgB;AAAA,EACxC,EAAE,IAAI,SAAS,MAAM,MAAM;AAAA,EAC3B,EAAE,IAAI,eAAe,MAAM,KAAK;AAAA,EAChC,EAAE,IAAI,WAAW,MAAM,QAAQ;AAAA,EAC/B,EAAE,IAAI,YAAY,MAAM,QAAQ;AAClC,CAAC;AA2BD,MAAM,oBAAwC;AAuBvC,SAAS,cACd,QACA,MAAqC,CAAC,GACtC,UAAgC,CAAC,GACQ;AACzC,QAAM,QAAQ,UAAU;AACxB,QAAM,WAAW,IAAI,IAAY,QAAQ,YAAY,CAAC,CAAC;AACvD,QAAM,SAAS,IAAI,IAAY,eAAe,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;AAC9D,QAAM,SAAS,oBAAI,IAAY;AAC/B,aAAW,WAAW,KAAK;AACzB,QAAI,OAAO,IAAI,QAAQ,EAAE,EAAG,OAAM,IAAI,MAAM,mBAAmB,QAAQ,EAAE,4BAA4B;AACrG,QAAI,OAAO,IAAI,QAAQ,EAAE,EAAG,OAAM,IAAI,MAAM,mBAAmB,QAAQ,EAAE,kBAAkB;AAC3F,WAAO,IAAI,QAAQ,EAAE;AAAA,EACvB;AACA,aAAW,WAAW,KAAK;AACzB,UAAM,QAAQ,QAAQ;AACtB,QAAI,UAAU,UAAa,CAAC,OAAO,IAAI,KAAK,KAAK,CAAC,OAAO,IAAI,KAAK,GAAG;AACnE,YAAM,IAAI,MAAM,mBAAmB,QAAQ,EAAE,iBAAiB,KAAK,wBAAwB;AAAA,IAC7F;AAAA,EACF;AAIA,QAAM,YAAY,oBAAI,IAAkC;AACxD,aAAW,WAAW,KAAK;AACzB,UAAM,QAAQ,QAAQ,SAAS;AAC/B,cAAU,IAAI,OAAO,CAAC,GAAI,UAAU,IAAI,KAAK,KAAK,CAAC,GAAI,OAAO,CAAC;AAAA,EACjE;AAEA,QAAM,MAA+C,CAAC;AACtD,QAAM,aAAa,CAAC,OAAe;AACjC,eAAW,WAAW,UAAU,IAAI,EAAE,KAAK,CAAC,GAAG;AAC7C,YAAM,EAAE,OAAO,QAAQ,GAAG,MAAM,IAAI;AACpC,UAAI,KAAK,KAAK;AACd,iBAAW,QAAQ,EAAE;AAAA,IACvB;AAAA,EACF;AACA,aAAW,EAAE,IAAI,KAAK,KAAK,gBAAgB;AACzC,QAAI,CAAC,SAAS,IAAI,EAAE,GAAG;AACrB,YAAM,UAAU,QAAQ,UAAU,EAAE;AACpC,UAAI,KAAK;AAAA,QACP;AAAA,QACA,MAAM,cAAc,MAAM,EAAE,eAAe,KAAK,CAAC;AAAA,QACjD,OAAO,MAAM,SAAS,EAAE,EAAE;AAAA,QAC1B,MAAM,MAAM,SAAS,EAAE,EAAE;AAAA,QACzB,GAAI,YAAY,SAAY,OAAO,EAAE,QAAQ;AAAA,MAC/C,CAAC;AAAA,IACH;AAEA,eAAW,EAAE;AAAA,EACf;AACA,QAAM,SAAS,IAAI,IAAY,IAAI,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;AACnD,QAAM,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE;AAClE,MAAI,MAAM,OAAQ,OAAM,IAAI,MAAM,kBAAkB,MAAM,KAAK,IAAI,CAAC,gCAAgC;AACpG,SAAO;AACT;","names":[]}
|