@easygov/react-components 0.8.0 → 0.10.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 CHANGED
@@ -187,6 +187,34 @@ defines.
187
187
  the language now — read it with `useEasygovDisplayLanguage()`, set it with
188
188
  `setEasygovDisplayLanguage()`.
189
189
 
190
+ ### Publishing the business module's version
191
+
192
+ A business module frontend embedding `EasygovHeader` can publish its own version number so it
193
+ appears in the environment badge's tooltip alongside the library and backend versions:
194
+
195
+ ```ts
196
+ import { setEasygovBusinessModuleVersion } from '@easygov/react-components';
197
+
198
+ setEasygovBusinessModuleVersion('2.4.1');
199
+ ```
200
+
201
+ Call it whenever your app knows its own version — at startup is typical. It can be called
202
+ before or after any `EasygovHeader` has mounted, and calling it again later (e.g. after a
203
+ version changes) simply updates the tooltip. Until it is called, the tooltip shows only the
204
+ existing `UI-Version` and `Backend-Version` lines, exactly as it did before this API existed.
205
+
206
+ Outside React — including `<eg-easygov-header>` — call the same setter on the web-components
207
+ global instead:
208
+
209
+ ```js
210
+ window.easygov.setBusinessModuleVersion('2.4.1');
211
+ ```
212
+
213
+ **A page using `<eg-easygov-header>` must call `window.easygov.setBusinessModuleVersion`, not
214
+ the npm function.** That bundle inlines its own copy of this library, so the npm function
215
+ would write into a different store instance than the one the element reads from — the same
216
+ caveat that already applies to `useEasygovDisplayLanguage` in that context (see above).
217
+
190
218
  ## License
191
219
 
192
220
  MIT
@@ -441,6 +441,32 @@ interface EasygovHeaderContext {
441
441
  claims: HeaderContextClaims | null;
442
442
  }
443
443
 
444
+ interface EasygovVersionInfo {
445
+ /** This package's own version, from package.json — known synchronously, never null. */
446
+ libraryVersion: string;
447
+ /**
448
+ * The core-backend API version reported by GET /external/api/v1/version. Null until the
449
+ * first fetch resolves, and stays null forever on any failure (non-2xx, network error,
450
+ * unresolved origin, malformed body) — there is no retry.
451
+ */
452
+ backendVersion: string | null;
453
+ /**
454
+ * The embedding business module's own version, published via `setEasygovFunctionModuleVersion`.
455
+ * Null until a consumer calls the setter — EasygovHeader itself never sets this and has no
456
+ * way to discover it on its own, unlike backendVersion.
457
+ */
458
+ businessModuleVersion: string | null;
459
+ }
460
+ /**
461
+ * Publishes the embedding business module's own version into the store, so EasygovHeader's version
462
+ * tooltip can show it alongside the library and backend versions. Safe to call at any time —
463
+ * before or after any EasygovHeader mounts — and safe to call more than once; each call
464
+ * overwrites the previous value and notifies subscribers. There is no corresponding fetch:
465
+ * EasygovHeader has no way to discover a business module's version on its own, so this is the only
466
+ * way the field is ever set.
467
+ */
468
+ declare function setEasygovBusinessModuleVersion(version: string): void;
469
+
444
470
  declare const dictionaries: {
445
471
  de: {
446
472
  readonly login: "Anmelden";
@@ -564,6 +590,14 @@ declare function useEasygovHeaderContext(): EasygovHeaderContext;
564
590
  * call, so a module can read it before any header has mounted.
565
591
  */
566
592
  declare function useEasygovDisplayLanguage(): Locale;
593
+ /**
594
+ * The current version info: this package's own version (always known) and the core-backend
595
+ * API version (null until EasygovHeader's mount effect fetches it, or on fetch failure — see
596
+ * version-store.ts). Unlike useEasygovHeaderContext, no header needs to be mounted for
597
+ * `libraryVersion` to resolve; only `backendVersion` requires a mounted EasygovHeader to
598
+ * trigger the fetch.
599
+ */
600
+ declare function useEasygovVersionInfo(): EasygovVersionInfo;
567
601
  interface EasygovHeaderProps {
568
602
  readonly onLanguageChange?: (locale: Locale) => void;
569
603
  readonly onNavigate?: (path: string) => void;
@@ -631,4 +665,4 @@ declare function getEasygovDisplayLanguage(): Locale;
631
665
  declare function setEasygovDisplayLanguage(locale: Locale): void;
632
666
  declare function subscribeEasygovDisplayLanguage(listener: () => void): () => void;
633
667
 
634
- export { type AuthStatus, BrandBase, BrandEasygov, BrandFacebook, BrandKdk, BrandLinkedin, type BrandProps, BrandSeg, BrandSgv, BrandSsv, BrandSwiss, BrandXing, BrandYoutube, Button, type ButtonProps, type DesktopSpan, Dropdown, DropdownChip, DropdownChipsOverflow, type DropdownChipsOverflowProps, DropdownChipsTrigger, type DropdownChipsTriggerProps, DropdownCollection, DropdownEmpty, DropdownGroup, DropdownGroupLabel, DropdownHelperText, type DropdownHelperTextProps, DropdownInput, DropdownItem, type DropdownItemProps, DropdownItemText, DropdownLabel, type DropdownLabelProps, DropdownList, DropdownPopup, type DropdownPopupProps, DropdownSeparator, DropdownToggle, DropdownTrigger, type DropdownTriggerProps, DropdownValue, EasygovFooter, EasygovHeader, type EasygovHeaderContext, type EasygovHeaderProps, type EasygovSession, ErrorDialog, type ErrorDialogProps, Grid, GridItem, type GridItemProps, type GridProps, type AccountVerificationStatus as HeaderContextAccountVerificationStatus, type HeaderContextClaims, type IndividualAccount as HeaderContextIndividualAccount, type ManagementRole as HeaderContextManagementRole, type ManagementRoleStatus as HeaderContextManagementRoleStatus, type ManagementRoleType as HeaderContextManagementRoleType, type OrganizationAccount as HeaderContextOrganizationAccount, type ProcessStatus as HeaderContextProcessStatus, type UserProfile as HeaderContextUserProfile, Heading, type HeadingProps, Input, type InputProps, type Locale, type MobileSpan, NavigationMenu, NavigationMenuAnchor, type NavigationMenuAnchorProps, NavigationMenuContent, type NavigationMenuContentProps, NavigationMenuItem, type NavigationMenuItemProps, NavigationMenuLink, type NavigationMenuLinkProps, NavigationMenuList, type NavigationMenuListProps, type NavigationMenuProps, NavigationMenuTrigger, type NavigationMenuTriggerProps, RequireCustomerAccount, type RequireCustomerAccountProps, RequireSession, type RequireSessionProps, Select, SelectContent, type SelectContentProps, SelectGroup, SelectGroupLabel, type SelectGroupLabelProps, SelectHelperText, type SelectHelperTextProps, SelectItem, type SelectItemProps, SelectLabel, type SelectLabelProps, SelectSeparator, type SelectSeparatorProps, SelectTrigger, type SelectTriggerProps, type SelectedCustomerAccount, type SelectedProcess, type SessionUser, type TabletSpan, Text, TextLink, type TextLinkProps, type TextProps, buttonVariants, getAuthStatus, getEasygovDisplayLanguage, headingVariants, requireSession, setEasygovDisplayLanguage, subscribeEasygovDisplayLanguage, textLinkVariants, textVariants, useEasygovAuthStatus, useEasygovDisplayLanguage, useEasygovHeaderContext, useEasygovSession, useRequireCustomerAccount };
668
+ export { type AuthStatus, BrandBase, BrandEasygov, BrandFacebook, BrandKdk, BrandLinkedin, type BrandProps, BrandSeg, BrandSgv, BrandSsv, BrandSwiss, BrandXing, BrandYoutube, Button, type ButtonProps, type DesktopSpan, Dropdown, DropdownChip, DropdownChipsOverflow, type DropdownChipsOverflowProps, DropdownChipsTrigger, type DropdownChipsTriggerProps, DropdownCollection, DropdownEmpty, DropdownGroup, DropdownGroupLabel, DropdownHelperText, type DropdownHelperTextProps, DropdownInput, DropdownItem, type DropdownItemProps, DropdownItemText, DropdownLabel, type DropdownLabelProps, DropdownList, DropdownPopup, type DropdownPopupProps, DropdownSeparator, DropdownToggle, DropdownTrigger, type DropdownTriggerProps, DropdownValue, EasygovFooter, EasygovHeader, type EasygovHeaderContext, type EasygovHeaderProps, type EasygovSession, type EasygovVersionInfo, ErrorDialog, type ErrorDialogProps, Grid, GridItem, type GridItemProps, type GridProps, type AccountVerificationStatus as HeaderContextAccountVerificationStatus, type HeaderContextClaims, type IndividualAccount as HeaderContextIndividualAccount, type ManagementRole as HeaderContextManagementRole, type ManagementRoleStatus as HeaderContextManagementRoleStatus, type ManagementRoleType as HeaderContextManagementRoleType, type OrganizationAccount as HeaderContextOrganizationAccount, type ProcessStatus as HeaderContextProcessStatus, type UserProfile as HeaderContextUserProfile, Heading, type HeadingProps, Input, type InputProps, type Locale, type MobileSpan, NavigationMenu, NavigationMenuAnchor, type NavigationMenuAnchorProps, NavigationMenuContent, type NavigationMenuContentProps, NavigationMenuItem, type NavigationMenuItemProps, NavigationMenuLink, type NavigationMenuLinkProps, NavigationMenuList, type NavigationMenuListProps, type NavigationMenuProps, NavigationMenuTrigger, type NavigationMenuTriggerProps, RequireCustomerAccount, type RequireCustomerAccountProps, RequireSession, type RequireSessionProps, Select, SelectContent, type SelectContentProps, SelectGroup, SelectGroupLabel, type SelectGroupLabelProps, SelectHelperText, type SelectHelperTextProps, SelectItem, type SelectItemProps, SelectLabel, type SelectLabelProps, SelectSeparator, type SelectSeparatorProps, SelectTrigger, type SelectTriggerProps, type SelectedCustomerAccount, type SelectedProcess, type SessionUser, type TabletSpan, Text, TextLink, type TextLinkProps, type TextProps, buttonVariants, getAuthStatus, getEasygovDisplayLanguage, headingVariants, requireSession, setEasygovBusinessModuleVersion, setEasygovDisplayLanguage, subscribeEasygovDisplayLanguage, textLinkVariants, textVariants, useEasygovAuthStatus, useEasygovDisplayLanguage, useEasygovHeaderContext, useEasygovSession, useEasygovVersionInfo, useRequireCustomerAccount };