@eifi1/ui-kit 0.42.0 → 0.43.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 (130) hide show
  1. package/README.md +12 -6
  2. package/dist/admin/admin-area-labels.d.ts +4 -0
  3. package/dist/admin/admin-area-labels.js +3 -1
  4. package/dist/admin/admin-area-labels.js.map +1 -1
  5. package/dist/admin/admin-overview.d.ts +25 -8
  6. package/dist/admin/admin-overview.js +26 -3
  7. package/dist/admin/admin-overview.js.map +1 -1
  8. package/dist/admin/admin-sections.d.ts +36 -5
  9. package/dist/admin/admin-sections.js +35 -18
  10. package/dist/admin/admin-sections.js.map +1 -1
  11. package/dist/billing/billing-banner.d.ts +8 -0
  12. package/dist/billing/billing-banner.js +25 -2
  13. package/dist/billing/billing-banner.js.map +1 -1
  14. package/dist/billing/billing-labels.d.ts +4 -0
  15. package/dist/billing/billing-labels.js +1 -0
  16. package/dist/billing/billing-labels.js.map +1 -1
  17. package/dist/billing/cancel-request.d.ts +53 -0
  18. package/dist/billing/cancel-request.js +21 -0
  19. package/dist/billing/cancel-request.js.map +1 -0
  20. package/dist/billing/provider-page.d.ts +40 -0
  21. package/dist/billing/provider-page.js +33 -0
  22. package/dist/billing/provider-page.js.map +1 -0
  23. package/dist/billing/subscription-actions.d.ts +32 -1
  24. package/dist/billing/subscription-actions.js +57 -4
  25. package/dist/billing/subscription-actions.js.map +1 -1
  26. package/dist/components/account-chips.d.ts +8 -1
  27. package/dist/components/account-chips.js.map +1 -1
  28. package/dist/eslint/index.js +1 -1
  29. package/dist/feedback/feedback-menu.d.ts +7 -4
  30. package/dist/feedback/feedback-menu.js +4 -2
  31. package/dist/feedback/feedback-menu.js.map +1 -1
  32. package/dist/hooks/use-search-param-state.js +4 -1
  33. package/dist/hooks/use-search-param-state.js.map +1 -1
  34. package/dist/i18n/defaults.js +2 -0
  35. package/dist/i18n/defaults.js.map +1 -1
  36. package/dist/i18n/german.js +36 -2
  37. package/dist/i18n/german.js.map +1 -1
  38. package/dist/i18n/kit-labels.d.ts +3 -0
  39. package/dist/i18n/kit-labels.js.map +1 -1
  40. package/dist/i18n/locales/en.js +51 -2
  41. package/dist/i18n/locales/en.js.map +3 -3
  42. package/dist/i18n/locales/es.js +36 -2
  43. package/dist/i18n/locales/es.js.map +1 -1
  44. package/dist/i18n/locales/fr.js +36 -2
  45. package/dist/i18n/locales/fr.js.map +1 -1
  46. package/dist/i18n/locales/hu.js +36 -2
  47. package/dist/i18n/locales/hu.js.map +1 -1
  48. package/dist/i18n/locales/it.js +36 -2
  49. package/dist/i18n/locales/it.js.map +1 -1
  50. package/dist/i18n/locales/zh.js +36 -2
  51. package/dist/i18n/locales/zh.js.map +1 -1
  52. package/dist/i18n/review.js +15 -1
  53. package/dist/i18n/review.js.map +1 -1
  54. package/dist/index.d.ts +6 -0
  55. package/dist/index.js +6 -0
  56. package/dist/index.js.map +1 -1
  57. package/dist/search/global-search.d.ts +3 -0
  58. package/dist/search/global-search.js +3 -1
  59. package/dist/search/global-search.js.map +1 -1
  60. package/dist/settings/settings-catalogue.d.ts +9 -1
  61. package/dist/settings/settings-catalogue.js +1 -1
  62. package/dist/settings/settings-catalogue.js.map +1 -1
  63. package/dist/shell/admin-menu.d.ts +26 -3
  64. package/dist/shell/admin-menu.js +8 -4
  65. package/dist/shell/admin-menu.js.map +1 -1
  66. package/dist/shell/dev-switchers.js +5 -0
  67. package/dist/shell/dev-switchers.js.map +1 -1
  68. package/dist/shell/top-bar-parts-labels.d.ts +6 -0
  69. package/dist/shell/top-bar-parts-labels.js +4 -1
  70. package/dist/shell/top-bar-parts-labels.js.map +1 -1
  71. package/dist/shell/tour-menu.d.ts +19 -10
  72. package/dist/shell/tour-menu.js +20 -6
  73. package/dist/shell/tour-menu.js.map +1 -1
  74. package/dist/shell.d.ts +2 -0
  75. package/dist/shell.js +2 -0
  76. package/dist/shell.js.map +1 -1
  77. package/dist/tour/tour-catalogue-labels.d.ts +44 -0
  78. package/dist/tour/tour-catalogue-labels.js +32 -0
  79. package/dist/tour/tour-catalogue-labels.js.map +1 -0
  80. package/dist/tour/tour-catalogue.d.ts +68 -0
  81. package/dist/tour/tour-catalogue.js +189 -0
  82. package/dist/tour/tour-catalogue.js.map +1 -0
  83. package/dist/tour/tour-info.d.ts +112 -0
  84. package/dist/tour/tour-info.js +36 -0
  85. package/dist/tour/tour-info.js.map +1 -0
  86. package/dist/tour/use-tour-progress.d.ts +61 -0
  87. package/dist/tour/use-tour-progress.js +116 -0
  88. package/dist/tour/use-tour-progress.js.map +1 -0
  89. package/dist/tour/use-tour-url-sync.d.ts +58 -0
  90. package/dist/tour/use-tour-url-sync.js +110 -0
  91. package/dist/tour/use-tour-url-sync.js.map +1 -0
  92. package/dist/tour.d.ts +8 -0
  93. package/dist/tour.js +18 -0
  94. package/dist/tour.js.map +1 -1
  95. package/package.json +1 -1
  96. package/src/admin/admin-area-labels.ts +7 -1
  97. package/src/admin/admin-overview.tsx +61 -10
  98. package/src/admin/admin-sections.tsx +109 -48
  99. package/src/billing/billing-banner.tsx +25 -2
  100. package/src/billing/billing-labels.ts +6 -0
  101. package/src/billing/cancel-request.ts +75 -0
  102. package/src/billing/provider-page.ts +75 -0
  103. package/src/billing/subscription-actions.tsx +97 -11
  104. package/src/components/account-chips.tsx +8 -1
  105. package/src/feedback/feedback-menu.tsx +8 -3
  106. package/src/hooks/use-search-param-state.ts +6 -1
  107. package/src/i18n/defaults.ts +2 -0
  108. package/src/i18n/german.ts +36 -1
  109. package/src/i18n/kit-labels.tsx +3 -0
  110. package/src/i18n/locales/en.ts +13 -0
  111. package/src/i18n/locales/es.ts +36 -1
  112. package/src/i18n/locales/fr.ts +36 -1
  113. package/src/i18n/locales/hu.ts +36 -1
  114. package/src/i18n/locales/it.ts +36 -1
  115. package/src/i18n/locales/zh.ts +36 -1
  116. package/src/i18n/review.ts +14 -0
  117. package/src/index.ts +8 -0
  118. package/src/search/global-search.tsx +5 -0
  119. package/src/settings/settings-catalogue.ts +10 -2
  120. package/src/shell/admin-menu.tsx +34 -5
  121. package/src/shell/dev-switchers.tsx +8 -0
  122. package/src/shell/top-bar-parts-labels.ts +9 -0
  123. package/src/shell/tour-menu.tsx +50 -15
  124. package/src/shell.ts +3 -0
  125. package/src/tour/tour-catalogue-labels.ts +75 -0
  126. package/src/tour/tour-catalogue.tsx +316 -0
  127. package/src/tour/tour-info.ts +144 -0
  128. package/src/tour/use-tour-progress.ts +198 -0
  129. package/src/tour/use-tour-url-sync.ts +221 -0
  130. package/src/tour.ts +11 -0
package/README.md CHANGED
@@ -556,19 +556,19 @@ 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
- **2042 names from 335 modules** — 942 values and 1100 types. _Italic_ is a type-only export.
559
+ **2079 names from 341 modules** — 958 values and 1121 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` | 2042 |
566
+ | `@eifi1/ui-kit` | 2079 |
567
567
  | `@eifi1/ui-kit/chart` | 92 |
568
- | `@eifi1/ui-kit/shell` | 108 |
568
+ | `@eifi1/ui-kit/shell` | 110 |
569
569
  | `@eifi1/ui-kit/data-table` | 51 |
570
570
  | `@eifi1/ui-kit/wizard` | 24 |
571
- | `@eifi1/ui-kit/tour` | 7 |
571
+ | `@eifi1/ui-kit/tour` | 31 |
572
572
  | `@eifi1/ui-kit/feedback` | 205 |
573
573
  | `@eifi1/ui-kit/search` | 23 |
574
574
  | `@eifi1/ui-kit/dates` | 22 |
@@ -819,7 +819,7 @@ 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`_ |
822
+ | `shell/admin-menu` | `adminMenuEntry`, `AdminMenuRow`, `useAdminMenuEntry`, _`AdminMenuEntryOptions`_, _`AdminMenuRowProps`_, _`UseAdminMenuEntryOptions`_ |
823
823
  | `shell/top-bar-actions` | `TOP_BAR_ACTION_ORDER`, `TopBarActions`, _`TopBarActionsProps`_ |
824
824
  | `shell/account-menu-language` | `AccountMenuLanguage`, _`AccountMenuLanguageOption`_, _`AccountMenuLanguageProps`_ |
825
825
  | `shell/tour-menu` | `TourMenu`, _`TourMenuProps`_, _`TourMenuTour`_ |
@@ -900,6 +900,10 @@ re-slicing of it, never a second API.
900
900
  | Module | Exports |
901
901
  |---|---|
902
902
  | `tour/tour` | `DEFAULT_TOUR_LABELS`, `TourProvider`, `useTour`, `useTourOptional`, _`TourLabels`_, _`TourPlacement`_, _`TourStep`_ |
903
+ | `tour/tour-catalogue` | `DEFAULT_TOUR_CATALOGUE_LABELS`, `TourCatalogue`, `TourCatalogueCard`, _`TourCatalogueCardProps`_, _`TourCatalogueLabels`_, _`TourCatalogueProps`_ |
904
+ | `tour/tour-info` | `doneCount`, `earnedPoints`, `isTourDone`, `isTourNew`, `isTourReset`, _`TourCompletions`_, _`TourGroup`_, _`TourInfo`_, _`TourUpdate`_ |
905
+ | `tour/use-tour-progress` | `resetTourProgress`, `useTourProgress`, _`TourProgress`_, _`UseTourProgressOptions`_ |
906
+ | `tour/use-tour-url-sync` | `useTourCatalogueUrlState`, `useTourUrlSync`, _`TourCatalogueFilter`_, _`TourStateFilter`_, _`UseTourUrlSyncOptions`_ |
903
907
 
904
908
  ### search
905
909
 
@@ -951,7 +955,7 @@ re-slicing of it, never a second API.
951
955
  | `admin/invitations-panel` | `DEFAULT_INVITATIONS_LABELS`, `InvitationsPanel`, _`InvitationDraft`_, _`InvitationRow`_, _`InvitationScope`_, _`InvitationSentAnswer`_, _`InvitationsLabels`_, _`InvitationsPanelProps`_, _`InvitationStatus`_ |
952
956
  | `admin/admin-parts` | _`AdminPerson`_ |
953
957
  | `admin/admin-area-labels` | `DEFAULT_ADMIN_AREA_LABELS`, `useAdminAreaLabels`, _`AdminAreaLabels`_, _`AdminSharedSection`_, _`AdminTileLabels`_ |
954
- | `admin/admin-sections` | `ADMIN_SECTIONS`, `adminSections`, _`AdminOwnSection`_, _`AdminSectionDefinition`_, _`AdminSectionsOptions`_ |
958
+ | `admin/admin-sections` | `ADMIN_SECTIONS`, `adminSectionOrder`, `adminSections`, _`AdminKeptSection`_, _`AdminOwnSection`_, _`AdminSectionDefinition`_, _`AdminSectionOrderOptions`_, _`AdminSectionPlace`_, _`AdminSectionsOptions`_ |
955
959
  | `admin/admin-forbidden` | `AdminForbidden`, _`AdminForbiddenProps`_ |
956
960
  | `admin/admin-overview` | `AdminOverview`, `adminWaitingCount`, `AttentionTile`, `DEFAULT_ADMIN_ATTENTION_HREFS`, _`AdminAttention`_, _`AdminAttentionTile`_, _`AdminExtraTile`_, _`AdminOverviewProps`_, _`AttentionTileProps`_ |
957
961
  | `admin/admin-tool-links` | `AdminToolLinks`, _`AdminToolLink`_, _`AdminToolLinksProps`_ |
@@ -978,6 +982,8 @@ re-slicing of it, never a second API.
978
982
  | `billing/plan-limit-toast` | `usePlanLimitToast`, _`PlanLimitToastOptions`_ |
979
983
  | `billing/plan-switch` | `PlanSwitchConfirm`, _`PlanSwitchConfirmProps`_, _`PlanSwitchSide`_ |
980
984
  | `billing/cancel-subscription` | `CancelSubscriptionConfirm`, _`CancelSubscriptionConfirmProps`_ |
985
+ | `billing/provider-page` | `openProviderPage`, _`OpenProviderPageOptions`_, _`ProviderPageWay`_ |
986
+ | `billing/cancel-request` | `useCancelRequest`, _`CancelRequest`_, _`CancelRequested`_, _`CancelRequestView`_ |
981
987
 
982
988
  ### notifications
983
989
 
@@ -44,6 +44,10 @@ export interface AdminAreaLabels {
44
44
  sections: Record<AdminSharedSection, SettingsGroupLabels>;
45
45
  /** The overview's tiles. */
46
46
  tiles: AdminTileLabels;
47
+ /** 0.43: `AdminOverview`'s `error` — the counts could not be loaded. */
48
+ overviewError: string;
49
+ /** 0.43: its button, which calls `onRetry`. */
50
+ retry: string;
47
51
  /** The Tools list's heading and name (§2.5 decision 16). */
48
52
  tools: string;
49
53
  }
@@ -10,7 +10,7 @@ const DEFAULT_ADMIN_AREA_LABELS = {
10
10
  sections: {
11
11
  overview: { title: "Overview", help: "What is waiting, at a glance." },
12
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." },
13
+ invitations: { title: "Invitations", help: "Invite people by e-mail in their language; resend or revoke what\u2019s still open." },
14
14
  billing: { title: "Billing", help: "The plan, the payment and the invoices." },
15
15
  activity: { title: "Activity", help: "What the admins did, newest first." }
16
16
  },
@@ -21,6 +21,8 @@ const DEFAULT_ADMIN_AREA_LABELS = {
21
21
  users: "Users",
22
22
  usersNew: (count) => `${count} new in 7 days`
23
23
  },
24
+ overviewError: "The overview couldn\u2019t be loaded.",
25
+ retry: "Try again",
24
26
  tools: "Tools"
25
27
  };
26
28
  function useAdminAreaLabels(labels) {
@@ -1 +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":[]}
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 /** 0.43: `AdminOverview`'s `error` — the counts could not be loaded. */\n overviewError: string;\n /** 0.43: its button, which calls `onRetry`. */\n retry: string;\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: \"Invite people by e-mail in their language; resend or revoke what’s still open.\" },\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 overviewError: \"The overview couldn’t be loaded.\",\n retry: \"Try again\",\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;AA0D1C,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,sFAAiF;AAAA,IAC5H,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,eAAe;AAAA,EACf,OAAO;AAAA,EACP,OAAO;AACT;AAMO,SAAS,mBAAmB,QAA0D;AAC3F,SAAO,aAAa,aAAa,2BAA2B,MAAM;AACpE;","names":[]}
@@ -43,13 +43,15 @@ export declare function adminWaitingCount(attention: AdminAttention | null | und
43
43
  export interface AttentionTileProps extends Omit<StatTileProps, "href" | "onClick" | "value"> {
44
44
  /** The count. `null` shows the tile's dash; {@link AdminOverview} leaves such a tile out. */
45
45
  count: number | null | undefined;
46
- /** Where the work is — the tile is a link to it. */
47
- href: string;
46
+ /** Where the work is — the tile is a link to it. Since 0.43 it may be left out: a
47
+ * quiet count, no link (Kurvenschmiede). */
48
+ href?: string;
48
49
  }
49
50
  /**
50
51
  * One tile of the overview: a {@link StatTile} that is a LINK to where the work is, its
51
52
  * 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
+ * `renderLink` or the provider's link component, as any StatTile. Without `href` (0.43) it
54
+ * is a quiet count, no link.
53
55
  */
54
56
  export declare function AttentionTile({ count, href, ...tile }: AttentionTileProps): import("react").JSX.Element;
55
57
  /** One of the app's own tiles (§2.4 decision 13: keksdose's "Support waiting"). */
@@ -59,7 +61,9 @@ export interface AdminExtraTile {
59
61
  label: ReactNode;
60
62
  /** `null` or `undefined` leaves the tile out, as for a shared one. */
61
63
  count: number | null | undefined;
62
- href: string;
64
+ /** Where the work is. Left out (0.43, Kurvenschmiede): a quiet count with no link —
65
+ * a number worth seeing that has no page of its own. */
66
+ href?: string;
63
67
  /** A line under the count. */
64
68
  description?: ReactNode;
65
69
  }
@@ -76,6 +80,18 @@ export interface AdminOverviewProps {
76
80
  extraTiles?: readonly AdminExtraTile[];
77
81
  /** Passed to every tile — `renderLink` for the router, `size`, `variant`. */
78
82
  tileProps?: Pick<StatTileProps, "renderLink" | "size" | "variant" | "locale">;
83
+ /**
84
+ * 0.43 (keksdose): the answer failed — the query's `error`, or `true`. Anything truthy
85
+ * shows `adminArea.overviewError` in a danger box, with "Try again" when
86
+ * {@link onRetry} is given. A failed poll keeps the last good tiles: with `attention`
87
+ * still there (a query keeps its last data), the box shows ALONGSIDE them, above, not
88
+ * instead (build review 0.43, keksdose N7) — pass `attention.data` as it is. Without
89
+ * an answer yet, the box alone. Without `error`: `undefined` is the skeletons and
90
+ * `null` nothing, as before.
91
+ */
92
+ error?: unknown;
93
+ /** "Try again" in the error box — the query's `refetch`. */
94
+ onRetry?: () => void;
79
95
  /** Prop > `<UiKitProvider labels={{ adminArea }}>` > English. */
80
96
  labels?: LabelOverride<AdminAreaLabels>;
81
97
  className?: string;
@@ -86,8 +102,9 @@ export interface AdminOverviewProps {
86
102
  * the total) — then the app's `extraTiles`. A tile whose count is `null` is left out,
87
103
  * so each app shows only what it has; a `0` is a quiet tile, "nothing waiting".
88
104
  *
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).
105
+ * The overview is the admin area's landing page, standalone: it is NOT wrapped in a
106
+ * `SettingsSection` (`adminSections` gives it no entry; render it as the page's body, as
107
+ * Kurvenschmiede's `OverviewPanel` does). keksdose links its metrics from here with at
108
+ * most two tiles (§6.5).
92
109
  */
93
- export declare function AdminOverview({ attention, hrefs, extraTiles, tileProps, labels: labelsProp, className, }: AdminOverviewProps): import("react").JSX.Element | null;
110
+ export declare function AdminOverview({ attention, hrefs, extraTiles, tileProps, error, onRetry, labels: labelsProp, className, }: AdminOverviewProps): import("react").JSX.Element | null;
@@ -1,6 +1,9 @@
1
1
  "use client";
2
- import { jsx } from "react/jsx-runtime";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { AlertBanner } from "../components/alert-banner.js";
4
+ import { Button } from "../components/button.js";
3
5
  import { StatTile, StatTileGrid } from "../components/stat-tile.js";
6
+ import { cn } from "../lib/cn.js";
4
7
  import { useAdminAreaLabels } from "./admin-area-labels.js";
5
8
  const DEFAULT_ADMIN_ATTENTION_HREFS = Object.freeze({
6
9
  feedback_waiting: "/feedback",
@@ -26,10 +29,25 @@ function AdminOverview({
26
29
  hrefs,
27
30
  extraTiles = [],
28
31
  tileProps,
32
+ error,
33
+ onRetry,
29
34
  labels: labelsProp,
30
35
  className
31
36
  }) {
32
37
  const labels = useAdminAreaLabels(labelsProp);
38
+ const errorBox = (alone) => /* @__PURE__ */ jsx(
39
+ AlertBanner,
40
+ {
41
+ "data-slot": alone ? "admin-overview" : void 0,
42
+ "data-state": alone ? "error" : void 0,
43
+ variant: "box",
44
+ tone: "danger",
45
+ className: alone ? className : void 0,
46
+ action: onRetry ? /* @__PURE__ */ jsx(Button, { type: "button", variant: "secondary", size: "sm", onClick: () => onRetry(), children: labels.retry }) : void 0,
47
+ children: labels.overviewError
48
+ }
49
+ );
50
+ if (error && !attention) return errorBox(true);
33
51
  const href = { ...DEFAULT_ADMIN_ATTENTION_HREFS, ...hrefs };
34
52
  const loading = attention === void 0;
35
53
  const shared = [
@@ -46,8 +64,8 @@ function AdminOverview({
46
64
  ...shared.map((t) => ({ ...t, count: attention ? attention[t.key] : void 0, href: href[t.key] })),
47
65
  ...extraTiles
48
66
  ].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(
67
+ if (!loading && tiles.length === 0) return error ? errorBox(true) : null;
68
+ const grid = /* @__PURE__ */ jsx(StatTileGrid, { "data-slot": error ? void 0 : "admin-overview", loading, className: error ? void 0 : className, children: tiles.map((t) => /* @__PURE__ */ jsx(
51
69
  AttentionTile,
52
70
  {
53
71
  ...tileProps,
@@ -59,6 +77,11 @@ function AdminOverview({
59
77
  },
60
78
  t.key
61
79
  )) });
80
+ if (!error) return grid;
81
+ return /* @__PURE__ */ jsxs("div", { "data-slot": "admin-overview", "data-state": "error", className: cn("space-y-4", className), children: [
82
+ errorBox(false),
83
+ grid
84
+ ] });
62
85
  }
63
86
  export {
64
87
  AdminOverview,
@@ -1 +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":[]}
1
+ {"version":3,"sources":["../../src/admin/admin-overview.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { AlertBanner } from \"../components/alert-banner\";\nimport { Button } from \"../components/button\";\nimport { StatTile, StatTileGrid } from \"../components/stat-tile\";\nimport type { StatTileProps } from \"../components/stat-tile\";\nimport type { LabelOverride } from \"../i18n/kit-labels\";\nimport { cn } from \"../lib/cn\";\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. Since 0.43 it may be left out: a\n * quiet count, no link (Kurvenschmiede). */\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. Without `href` (0.43) it\n * is a quiet count, no link.\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 /** Where the work is. Left out (0.43, Kurvenschmiede): a quiet count with no link —\n * a number worth seeing that has no page of its own. */\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 /**\n * 0.43 (keksdose): the answer failed — the query's `error`, or `true`. Anything truthy\n * shows `adminArea.overviewError` in a danger box, with \"Try again\" when\n * {@link onRetry} is given. A failed poll keeps the last good tiles: with `attention`\n * still there (a query keeps its last data), the box shows ALONGSIDE them, above, not\n * instead (build review 0.43, keksdose N7) — pass `attention.data` as it is. Without\n * an answer yet, the box alone. Without `error`: `undefined` is the skeletons and\n * `null` nothing, as before.\n */\n error?: unknown;\n /** \"Try again\" in the error box — the query's `refetch`. */\n onRetry?: () => void;\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 * The overview is the admin area's landing page, standalone: it is NOT wrapped in a\n * `SettingsSection` (`adminSections` gives it no entry; render it as the page's body, as\n * Kurvenschmiede's `OverviewPanel` does). keksdose links its metrics from here with at\n * most two tiles (§6.5).\n */\nexport function AdminOverview({\n attention,\n hrefs,\n extraTiles = [],\n tileProps,\n error,\n onRetry,\n labels: labelsProp,\n className,\n}: AdminOverviewProps) {\n const labels = useAdminAreaLabels(labelsProp);\n /** The error box: on its own (`alone`) it is the overview's root. */\n const errorBox = (alone: boolean) => (\n <AlertBanner\n data-slot={alone ? \"admin-overview\" : undefined}\n data-state={alone ? \"error\" : undefined}\n variant=\"box\"\n tone=\"danger\"\n className={alone ? className : undefined}\n action={\n onRetry ? (\n <Button type=\"button\" variant=\"secondary\" size=\"sm\" onClick={() => onRetry()}>\n {labels.retry}\n </Button>\n ) : undefined\n }\n >\n {labels.overviewError}\n </AlertBanner>\n );\n // Nothing good to keep: the box alone.\n if (error && !attention) return errorBox(true);\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 error ? errorBox(true) : null;\n const grid = (\n <StatTileGrid data-slot={error ? undefined : \"admin-overview\"} loading={loading} className={error ? undefined : 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 if (!error) return grid;\n // A failed poll: the error above the last good tiles.\n return (\n <div data-slot=\"admin-overview\" data-state=\"error\" className={cn(\"space-y-4\", className)}>\n {errorBox(false)}\n {grid}\n </div>\n );\n}\n"],"mappings":"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","names":[]}
@@ -26,12 +26,25 @@ export declare const ADMIN_SECTIONS: readonly AdminSectionDefinition[];
26
26
  export interface AdminOwnSection<G extends string = string> extends SettingsGroup<G> {
27
27
  after?: AdminSharedSection | G;
28
28
  }
29
- export interface AdminSectionsOptions {
29
+ /** Where one section goes, without its words — what {@link adminSectionOrder} takes. An
30
+ * {@link AdminOwnSection} is one. */
31
+ export interface AdminSectionPlace<G extends string = string> {
32
+ id: G;
33
+ after?: AdminSharedSection | G;
34
+ }
35
+ /** The order's options: the shared sections an app does not have. */
36
+ export interface AdminSectionOrderOptions<L extends AdminSharedSection = AdminSharedSection> {
30
37
  /**
31
38
  * 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.
39
+ * view (`["billing"]`). Left out, every shared section is in the catalogue. Since 0.43
40
+ * the result's type leaves them out too, so no cast is needed to drop `"billing"` —
41
+ * when TypeScript infers the type arguments. With them written out, name the left-out
42
+ * ones as the second (`adminSections<Own, "billing">(…)`); `adminSections<Own>(…)`
43
+ * keeps every shared id in the type, as before.
33
44
  */
34
- leaveOut?: readonly AdminSharedSection[];
45
+ leaveOut?: readonly L[];
46
+ }
47
+ export interface AdminSectionsOptions<L extends AdminSharedSection = AdminSharedSection> extends AdminSectionOrderOptions<L> {
35
48
  /**
36
49
  * A shared section that is in the catalogue but hidden for now, as
37
50
  * {@link SettingsGroup.visible}: kastlan's `{ billing: billingEnabled }` (settings §5),
@@ -39,11 +52,29 @@ export interface AdminSectionsOptions {
39
52
  */
40
53
  visible?: Partial<Record<AdminSharedSection, boolean>>;
41
54
  }
55
+ /** The shared sections an app keeps when it leaves out `L`. A `leaveOut` typed as the
56
+ * whole union (a variable of `AdminSharedSection[]`) says nothing about which, so it
57
+ * narrows nothing. */
58
+ export type AdminKeptSection<L extends AdminSharedSection = AdminSharedSection> = [AdminSharedSection] extends [L] ? AdminSharedSection : Exclude<AdminSharedSection, L>;
59
+ /**
60
+ * The admin area's section ids in the template's order (0.43, keksdose) — what
61
+ * {@link adminSections} builds its groups in, without the words: for an app that needs the
62
+ * ORDER only (a router's list of paths, a test), outside a component, with no labels.
63
+ *
64
+ * adminSectionOrder([{ id: "metrics", after: "overview" }], { leaveOut: ["billing"] })
65
+ * // ["overview", "metrics", "users", "invitations", "activity"]
66
+ *
67
+ * Throws as {@link adminSections} does.
68
+ */
69
+ export declare function adminSectionOrder<G extends string = never, L extends AdminSharedSection = AdminSharedSection>(own?: readonly AdminSectionPlace<G>[], options?: AdminSectionOrderOptions<L>): (AdminKeptSection<L> | G)[];
42
70
  /**
43
71
  * An app's admin catalogue groups, in the template's order (§2.3 decision 10, §6.8): the
44
72
  * shared sections with the kit's icons and words, and the app's own at the places they
45
73
  * 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).
74
+ * with no visible entry is hidden, as on any settings page — except, since 0.43, the
75
+ * Overview, a page of tiles that needs no entry: it is `standalone`). Since 0.43 the
76
+ * result's type leaves out the `leaveOut` sections, and {@link adminSectionOrder} gives
77
+ * the same order as ids, without words.
47
78
  *
48
79
  * const groups = adminSections(useAdminAreaLabels(), [
49
80
  * { id: "metrics", icon: <BarChart3 />, title: t("…"), help: t("…"), after: "overview" },
@@ -60,4 +91,4 @@ export interface AdminSectionsOptions {
60
91
  * an own section whose id is a shared one, an id given twice, or an `after` that names no
61
92
  * section: the catalogue is built once, and a section quietly missing from it is worse.
62
93
  */
63
- export declare function adminSections<G extends string = never>(labels: AdminAreaLabels | undefined, own?: readonly AdminOwnSection<G>[], options?: AdminSectionsOptions): SettingsGroup<AdminSharedSection | G>[];
94
+ export declare function adminSections<G extends string = never, L extends AdminSharedSection = AdminSharedSection>(labels: AdminAreaLabels | undefined, own?: readonly AdminOwnSection<G>[], options?: AdminSectionsOptions<L>): SettingsGroup<AdminKeptSection<L> | G>[];
@@ -10,9 +10,8 @@ const ADMIN_SECTIONS = Object.freeze([
10
10
  { id: "activity", icon: History }
11
11
  ]);
12
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 ?? []);
13
+ function orderSections(own, leaveOutIds) {
14
+ const leaveOut = new Set(leaveOutIds ?? []);
16
15
  const shared = new Set(ADMIN_SECTIONS.map((s) => s.id));
17
16
  const ownIds = /* @__PURE__ */ new Set();
18
17
  for (const section of own) {
@@ -32,33 +31,51 @@ function adminSections(labels, own = [], options = {}) {
32
31
  followers.set(after, [...followers.get(after) ?? [], section]);
33
32
  }
34
33
  const out = [];
34
+ const placed = /* @__PURE__ */ new Set();
35
35
  const placeAfter = (id) => {
36
36
  for (const section of followers.get(id) ?? []) {
37
- const { after: _after, ...group } = section;
38
- out.push(group);
37
+ out.push({ own: section });
38
+ placed.add(section.id);
39
39
  placeAfter(section.id);
40
40
  }
41
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);
42
+ for (const definition of ADMIN_SECTIONS) {
43
+ if (!leaveOut.has(definition.id)) out.push({ shared: definition });
44
+ placeAfter(definition.id);
54
45
  }
55
- const placed = new Set(out.map((g) => g.id));
56
46
  const stuck = own.filter((s) => !placed.has(s.id)).map((s) => s.id);
57
47
  if (stuck.length) throw new Error(`adminSections: ${stuck.join(", ")} follow each other in a circle`);
58
48
  return out;
59
49
  }
50
+ function adminSectionOrder(own = [], options = {}) {
51
+ return orderSections(own, options.leaveOut).map(
52
+ (s) => "shared" in s ? s.shared.id : s.own.id
53
+ );
54
+ }
55
+ function adminSections(labels, own = [], options = {}) {
56
+ const words = labels ?? DEFAULT_ADMIN_AREA_LABELS;
57
+ return orderSections(own, options.leaveOut).map((s) => {
58
+ if ("own" in s) {
59
+ const { after: _after, ...group } = s.own;
60
+ return group;
61
+ }
62
+ const { id, icon } = s.shared;
63
+ const visible = options.visible?.[id];
64
+ return {
65
+ id,
66
+ icon: createElement(icon, { "aria-hidden": true }),
67
+ title: words.sections[id].title,
68
+ help: words.sections[id].help,
69
+ // 0.43 (kastlan): the overview is a page of tiles, not of setting cards — it shows
70
+ // with no entry of its own.
71
+ ...id === "overview" ? { standalone: true } : null,
72
+ ...visible === void 0 ? null : { visible }
73
+ };
74
+ });
75
+ }
60
76
  export {
61
77
  ADMIN_SECTIONS,
78
+ adminSectionOrder,
62
79
  adminSections
63
80
  };
64
81
  //# sourceMappingURL=admin-sections.js.map
@@ -1 +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":[]}
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\n/** Where one section goes, without its words — what {@link adminSectionOrder} takes. An\n * {@link AdminOwnSection} is one. */\nexport interface AdminSectionPlace<G extends string = string> {\n id: G;\n after?: AdminSharedSection | G;\n}\n\n/** The order's options: the shared sections an app does not have. */\nexport interface AdminSectionOrderOptions<L extends AdminSharedSection = AdminSharedSection> {\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. Since 0.43\n * the result's type leaves them out too, so no cast is needed to drop `\"billing\"` —\n * when TypeScript infers the type arguments. With them written out, name the left-out\n * ones as the second (`adminSections<Own, \"billing\">(…)`); `adminSections<Own>(…)`\n * keeps every shared id in the type, as before.\n */\n leaveOut?: readonly L[];\n}\n\nexport interface AdminSectionsOptions<L extends AdminSharedSection = AdminSharedSection> extends AdminSectionOrderOptions<L> {\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 sections an app keeps when it leaves out `L`. A `leaveOut` typed as the\n * whole union (a variable of `AdminSharedSection[]`) says nothing about which, so it\n * narrows nothing. */\nexport type AdminKeptSection<L extends AdminSharedSection = AdminSharedSection> = [AdminSharedSection] extends [L]\n ? AdminSharedSection\n : Exclude<AdminSharedSection, L>;\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/** The shared and own sections in their order — a shared one as its definition, an own\n * one as given. Throws as {@link adminSections} documents. */\nfunction orderSections<S extends AdminSectionPlace<string>>(\n own: readonly S[],\n leaveOutIds: readonly AdminSharedSection[] | undefined,\n): ({ shared: AdminSectionDefinition } | { own: S })[] {\n const leaveOut = new Set<string>(leaveOutIds ?? []);\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, S[]>();\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: ({ shared: AdminSectionDefinition } | { own: S })[] = [];\n const placed = new Set<string>();\n const placeAfter = (id: string) => {\n for (const section of followers.get(id) ?? []) {\n out.push({ own: section });\n placed.add(section.id);\n placeAfter(section.id);\n }\n };\n for (const definition of ADMIN_SECTIONS) {\n if (!leaveOut.has(definition.id)) out.push({ shared: definition });\n // A left-out section's followers keep its place.\n placeAfter(definition.id);\n }\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\n/**\n * The admin area's section ids in the template's order (0.43, keksdose) — what\n * {@link adminSections} builds its groups in, without the words: for an app that needs the\n * ORDER only (a router's list of paths, a test), outside a component, with no labels.\n *\n * adminSectionOrder([{ id: \"metrics\", after: \"overview\" }], { leaveOut: [\"billing\"] })\n * // [\"overview\", \"metrics\", \"users\", \"invitations\", \"activity\"]\n *\n * Throws as {@link adminSections} does.\n */\nexport function adminSectionOrder<G extends string = never, L extends AdminSharedSection = AdminSharedSection>(\n own: readonly AdminSectionPlace<G>[] = [],\n options: AdminSectionOrderOptions<L> = {},\n): (AdminKeptSection<L> | G)[] {\n return orderSections(own, options.leaveOut).map((s) =>\n \"shared\" in s ? (s.shared.id as AdminKeptSection<L>) : s.own.id,\n );\n}\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 — except, since 0.43, the\n * Overview, a page of tiles that needs no entry: it is `standalone`). Since 0.43 the\n * result's type leaves out the `leaveOut` sections, and {@link adminSectionOrder} gives\n * the same order as ids, without words.\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, L extends AdminSharedSection = AdminSharedSection>(\n labels: AdminAreaLabels | undefined,\n own: readonly AdminOwnSection<G>[] = [],\n options: AdminSectionsOptions<L> = {},\n): SettingsGroup<AdminKeptSection<L> | G>[] {\n const words = labels ?? DEFAULT_ADMIN_AREA_LABELS;\n return orderSections(own, options.leaveOut).map((s): SettingsGroup<AdminKeptSection<L> | G> => {\n if (\"own\" in s) {\n const { after: _after, ...group } = s.own;\n return group;\n }\n const { id, icon } = s.shared;\n const visible = options.visible?.[id];\n return {\n id: id as AdminKeptSection<L>,\n icon: createElement(icon, { \"aria-hidden\": true }) as ReactNode,\n title: words.sections[id].title,\n help: words.sections[id].help,\n // 0.43 (kastlan): the overview is a page of tiles, not of setting cards — it shows\n // with no entry of its own.\n ...(id === \"overview\" ? { standalone: true } : null),\n ...(visible === undefined ? null : { visible }),\n };\n });\n}\n"],"mappings":"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","names":[]}
@@ -52,6 +52,14 @@ interface BillingBannerBaseProps extends Omit<ComponentPropsWithRef<"div">, "chi
52
52
  actionLabel?: string;
53
53
  /** The action is under way: the button's spinner, no second press. */
54
54
  actionPending?: boolean;
55
+ /**
56
+ * 0.43 (§17): the action opens the provider's portal in a NEW TAB (`openProviderPage`
57
+ * in {@link onAction}): the external-link mark, "(opens in a new tab)" for a reader,
58
+ * and `target="_blank"` on an {@link actionHref}. Default: true for `payment-failed`
59
+ * with `onAction` (the portal's card page), false otherwise — an `actionHref` is
60
+ * usually the app's own subscription page.
61
+ */
62
+ actionNewTab?: boolean;
55
63
  /** An × that calls this; the app removes the banner and remembers that it did. */
56
64
  onDismiss?: () => void;
57
65
  dismissLabel?: string;
@@ -1,10 +1,12 @@
1
1
  "use client";
2
- import { jsx } from "react/jsx-runtime";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { CreditCard, Hourglass, PencilOff } from "lucide-react";
4
+ import { DEFAULT_COMMON_LABELS, useKitLabels } from "../i18n/kit-labels.js";
4
5
  import { AlertBanner } from "../components/alert-banner.js";
5
6
  import { Button } from "../components/button.js";
6
7
  import { Spinner } from "../components/spinner.js";
7
8
  import { useBillingLabels } from "./billing-labels.js";
9
+ import { ExternalMark } from "./subscription-actions.js";
8
10
  const LAST_DAYS = 3;
9
11
  function defaultTone(kind, daysLeft) {
10
12
  switch (kind) {
@@ -33,6 +35,7 @@ function BillingBanner(props) {
33
35
  onAction,
34
36
  actionLabel,
35
37
  actionPending,
38
+ actionNewTab,
36
39
  onDismiss,
37
40
  dismissLabel,
38
41
  labels: labelsProp,
@@ -40,6 +43,7 @@ function BillingBanner(props) {
40
43
  ...rest
41
44
  } = props;
42
45
  const labels = useBillingLabels(labelsProp);
46
+ const common = useKitLabels("common", DEFAULT_COMMON_LABELS);
43
47
  const days = Math.max(0, Math.floor(daysLeft ?? 0));
44
48
  let text;
45
49
  let icon;
@@ -78,7 +82,26 @@ function BillingBanner(props) {
78
82
  break;
79
83
  }
80
84
  const words = actionLabel ?? ownAction;
81
- const action = askBuyer || words === void 0 || actionHref === void 0 && onAction === void 0 ? void 0 : actionHref !== void 0 ? /* @__PURE__ */ jsx(Button, { href: actionHref, variant: "secondary", size: "sm", children: words }) : /* @__PURE__ */ jsx(Button, { type: "button", variant: "secondary", size: "sm", onClick: onAction, pending: actionPending, children: words });
85
+ const newTab = actionNewTab ?? (kind === "payment-failed" && actionHref === void 0 && onAction !== void 0);
86
+ const action = askBuyer || words === void 0 || actionHref === void 0 && onAction === void 0 ? void 0 : actionHref !== void 0 ? /* @__PURE__ */ jsxs(Button, { href: actionHref, variant: "secondary", size: "sm", external: newTab || void 0, children: [
87
+ words,
88
+ newTab && /* @__PURE__ */ jsx(ExternalMark, {})
89
+ ] }) : /* @__PURE__ */ jsxs(
90
+ Button,
91
+ {
92
+ type: "button",
93
+ variant: "secondary",
94
+ size: "sm",
95
+ onClick: onAction,
96
+ pending: actionPending,
97
+ className: newTab ? "relative" : void 0,
98
+ "data-portal-action": newTab ? "payment_method" : void 0,
99
+ children: [
100
+ words,
101
+ newTab && /* @__PURE__ */ jsx(ExternalMark, { reader: common.opensInNewTab })
102
+ ]
103
+ }
104
+ );
82
105
  return /* @__PURE__ */ jsx(
83
106
  AlertBanner,
84
107
  {