oip-common 0.6.2 → 0.6.3

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/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { OnDestroy, OnInit, DestroyRef, WritableSignal, OnChanges, SimpleChanges, Type, Provider, InjectionToken, EventEmitter, Renderer2, EnvironmentProviders } from '@angular/core';
2
+ import { OnDestroy, OnInit, DestroyRef, WritableSignal, OnChanges, SimpleChanges, Type, InjectionToken, Provider, EventEmitter, Renderer2, EnvironmentProviders } from '@angular/core';
3
3
  import * as rxjs from 'rxjs';
4
4
  import { Observable, BehaviorSubject, Subscription, Subject } from 'rxjs';
5
5
  import { MessageService, ToastMessageOptions, ConfirmationService, MenuItem, FilterMetadata } from 'primeng/api';
@@ -197,8 +197,9 @@ declare class L10nService {
197
197
  */
198
198
  get(key: string): Observable<any>;
199
199
  /**
200
- * Internal method to load translations from JSON files
201
- * @param component - Component or translation namespace
200
+ * Internal method to merge a namespace's statically-registered translations
201
+ * (see <c>registerTranslations</c>) into the active language dictionary.
202
+ * @param component - Translation namespace
202
203
  * @param lang - Language code to load translations for
203
204
  */
204
205
  private loadTranslations;
@@ -422,18 +423,8 @@ declare abstract class BaseModuleComponent<TBackendStoreSettings, TLocalStoreSet
422
423
  * @type {string}
423
424
  */
424
425
  title: string;
425
- /**
426
- * Translations bundled with the component, grouped by language code.
427
- * Declare it in a derived component to load translations from the component folder
428
- * instead of `assets/i18n`:
429
- *
430
- * ```ts
431
- * static override readonly translations = { en, ru };
432
- * ```
433
- */
434
- static readonly translations: TranslationsByLang | undefined;
426
+ private readonly baseTranslations;
435
427
  l10nService: L10nService;
436
- l10n$: Observable<Translation | TranslationObject>;
437
428
  canRead: boolean;
438
429
  canEdit: boolean;
439
430
  canDelete: boolean;
@@ -541,6 +532,7 @@ declare abstract class BaseModuleComponent<TBackendStoreSettings, TLocalStoreSet
541
532
  }
542
533
 
543
534
  declare class SecurityComponent implements OnChanges, OnInit, OnDestroy {
535
+ private readonly translations;
544
536
  private readonly msgService;
545
537
  private readonly translateService;
546
538
  private readonly httpClient;
@@ -550,7 +542,6 @@ declare class SecurityComponent implements OnChanges, OnInit, OnDestroy {
550
542
  id?: number;
551
543
  controller?: string;
552
544
  roles: string[];
553
- constructor(l10nService: L10nService);
554
545
  ngOnDestroy(): void;
555
546
  ngOnChanges(changes: SimpleChanges): void;
556
547
  ngOnInit(): void;
@@ -616,6 +607,7 @@ declare class LogoService {
616
607
  }
617
608
 
618
609
  declare class AppTopbar {
610
+ private readonly translations;
619
611
  securityService: SecurityService;
620
612
  topBarService: TopBarService;
621
613
  userService: UserService;
@@ -848,6 +840,7 @@ declare class MenuItemEditDialogComponent {
848
840
  }
849
841
 
850
842
  declare class MenuComponent implements OnInit {
843
+ private readonly translations;
851
844
  readonly menuService: MenuService;
852
845
  readonly securityService: SecurityService;
853
846
  readonly translateService: TranslateService;
@@ -900,12 +893,13 @@ declare class LogoComponent {
900
893
  }
901
894
 
902
895
  declare class NotfoundComponent {
903
- constructor(l10nService: L10nService);
896
+ private readonly translations;
904
897
  static ɵfac: i0.ɵɵFactoryDeclaration<NotfoundComponent, never>;
905
898
  static ɵcmp: i0.ɵɵComponentDeclaration<NotfoundComponent, "app-notfound", never, {}, {}, never, never, true, never>;
906
899
  }
907
900
 
908
901
  declare class UnauthorizedComponent implements OnInit {
902
+ private readonly translations;
909
903
  protected readonly securityService: SecurityService;
910
904
  private readonly route;
911
905
  ngOnInit(): void;
@@ -915,11 +909,13 @@ declare class UnauthorizedComponent implements OnInit {
915
909
  }
916
910
 
917
911
  declare class AccessComponent {
912
+ private readonly translations;
918
913
  static ɵfac: i0.ɵɵFactoryDeclaration<AccessComponent, never>;
919
914
  static ɵcmp: i0.ɵɵComponentDeclaration<AccessComponent, "app-access", never, {}, {}, never, never, true, never>;
920
915
  }
921
916
 
922
917
  declare class ErrorComponent {
918
+ private readonly translations;
923
919
  static ɵfac: i0.ɵɵFactoryDeclaration<ErrorComponent, never>;
924
920
  static ɵcmp: i0.ɵɵComponentDeclaration<ErrorComponent, "app-error", never, {}, {}, never, never, true, never>;
925
921
  }
@@ -954,12 +950,12 @@ declare class UserProfileApi<SecurityDataType = unknown> extends HttpClient<Secu
954
950
  }
955
951
 
956
952
  declare class UserProfileComponent {
953
+ private readonly translations;
957
954
  readonly userService: UserService;
958
955
  readonly msgService: MsgService;
959
956
  readonly translateService: TranslateService;
960
957
  readonly userProfileApi: UserProfileApi<any>;
961
958
  private readonly confirmationService;
962
- constructor(l10nService: L10nService);
963
959
  uploadPhoto(event: any): Promise<void>;
964
960
  confirmDeletePhoto(event: Event): void;
965
961
  private deletePhoto;
@@ -968,6 +964,7 @@ declare class UserProfileComponent {
968
964
  }
969
965
 
970
966
  declare class ConfigComponent {
967
+ private readonly translations;
971
968
  private readonly layoutService;
972
969
  protected readonly l10nService: L10nService;
973
970
  protected readonly userService: UserService;
@@ -1003,46 +1000,7 @@ interface MigrationDto {
1003
1000
  exist: boolean;
1004
1001
  }
1005
1002
  declare class DbMigrationComponent extends BaseModuleComponent<NoSettingsDto, NoSettingsDto> implements OnInit, OnDestroy {
1006
- static readonly translations: {
1007
- en: {
1008
- "db-migration": {
1009
- migrationManager: string;
1010
- actions: {
1011
- refresh: string;
1012
- cleanFilter: string;
1013
- applyMigration: string;
1014
- };
1015
- columns: {
1016
- name: string;
1017
- applied: string;
1018
- exist: string;
1019
- pending: string;
1020
- };
1021
- messages: {
1022
- errorRefreshing: string;
1023
- };
1024
- };
1025
- };
1026
- ru: {
1027
- "db-migration": {
1028
- migrationManager: string;
1029
- actions: {
1030
- refresh: string;
1031
- cleanFilter: string;
1032
- applyMigration: string;
1033
- };
1034
- columns: {
1035
- name: string;
1036
- applied: string;
1037
- exist: string;
1038
- pending: string;
1039
- };
1040
- messages: {
1041
- errorRefreshing: string;
1042
- };
1043
- };
1044
- };
1045
- };
1003
+ private readonly translations;
1046
1004
  data: MigrationDto[];
1047
1005
  ngOnInit(): Promise<void>;
1048
1006
  refreshAction(): Promise<void>;
@@ -1159,6 +1117,7 @@ declare type SurfacesType = {
1159
1117
  palette?: PaletteDesignToken;
1160
1118
  };
1161
1119
  declare class AppConfiguratorComponent implements OnInit {
1120
+ private readonly translations;
1162
1121
  router: Router;
1163
1122
  config: PrimeNG;
1164
1123
  layoutService: LayoutService;
@@ -1179,7 +1138,6 @@ declare class AppConfiguratorComponent implements OnInit {
1179
1138
  label: string;
1180
1139
  value: string;
1181
1140
  }[];
1182
- constructor(l10nService: L10nService);
1183
1141
  ngOnInit(): void;
1184
1142
  surfaces: SurfacesType[];
1185
1143
  selectedPrimaryColor: i0.Signal<string>;
@@ -1321,6 +1279,7 @@ type DiscussionComment = Omit<CommentDto, 'attachments' | 'reactions' | 'mention
1321
1279
  type DiscussionHistoryItem = Required<CommentHistoryDto>;
1322
1280
  declare class DiscussionComponent implements OnChanges, OnDestroy, OnInit {
1323
1281
  private readonly msgService;
1282
+ private readonly translations;
1324
1283
  private readonly discussionApi;
1325
1284
  private readonly sanitizer;
1326
1285
  private readonly translateService;
@@ -1341,7 +1300,6 @@ declare class DiscussionComponent implements OnChanges, OnDestroy, OnInit {
1341
1300
  historyByComment: Record<number, HistoryState>;
1342
1301
  emojiPalette: string[];
1343
1302
  private mentionSearchTimer;
1344
- constructor(l10nService: L10nService);
1345
1303
  ngOnChanges(changes: SimpleChanges): void;
1346
1304
  ngOnInit(): Promise<void>;
1347
1305
  ngOnDestroy(): void;
@@ -1382,28 +1340,7 @@ declare class DiscussionComponent implements OnChanges, OnDestroy, OnInit {
1382
1340
  }
1383
1341
 
1384
1342
  declare class IframeModuleComponent extends BaseModuleComponent<IframeModuleSettings, IframeModuleSettings> implements OnInit, OnDestroy {
1385
- static readonly translations: {
1386
- en: {
1387
- "iframe-module": {
1388
- iframeModule: {
1389
- urlPlaceholder: string;
1390
- settingSaveButtonLabel: string;
1391
- emptyUrlMessage: string;
1392
- siteLoadingMessage: string;
1393
- };
1394
- };
1395
- };
1396
- ru: {
1397
- "iframe-module": {
1398
- iframeModule: {
1399
- urlPlaceholder: string;
1400
- settingSaveButtonLabel: string;
1401
- emptyUrlMessage: string;
1402
- siteLoadingMessage: string;
1403
- };
1404
- };
1405
- };
1406
- };
1343
+ private readonly translations;
1407
1344
  private iframe?;
1408
1345
  private readonly renderer;
1409
1346
  private readonly translate;
@@ -1494,6 +1431,7 @@ interface GetNotificationByIdParams {
1494
1431
  }
1495
1432
 
1496
1433
  declare class UserNotificationsComponent {
1434
+ private readonly translations;
1497
1435
  private popover?;
1498
1436
  protected notifications: UserNotificationDto[];
1499
1437
  protected totalCount: number;
@@ -1507,7 +1445,6 @@ declare class UserNotificationsComponent {
1507
1445
  private readonly translateService;
1508
1446
  protected readonly unreadNotificationCount: i0.Signal<number>;
1509
1447
  protected readonly unreadNotificationBadge: i0.Signal<string>;
1510
- constructor(l10nService: L10nService);
1511
1448
  protected toggle(event: Event): Promise<void>;
1512
1449
  loadNotifications(): Promise<void>;
1513
1450
  onPageChange(event: PaginatorState): Promise<void>;
@@ -1782,6 +1719,27 @@ declare class ApplicationsApi<SecurityDataType = unknown> extends HttpClient<Sec
1782
1719
 
1783
1720
  declare function convertToPrimeNgDateFormat(dateformat: string): string;
1784
1721
 
1722
+ /**
1723
+ * Registers a component's co-located translations and merges them into the
1724
+ * active language. The namespace is derived from the JSON's own root key,
1725
+ * so callers never repeat it as a string literal.
1726
+ *
1727
+ * Must be called from an injection context - as a field initializer, or as
1728
+ * the first statement in a constructor - the same requirement as `inject()`
1729
+ * itself, which it uses internally.
1730
+ *
1731
+ * ```ts
1732
+ * import en from './l10n/menu.en.json';
1733
+ * import ru from './l10n/menu.ru.json';
1734
+ *
1735
+ * @Component({ ... })
1736
+ * export class MenuComponent {
1737
+ * private readonly translations = provideTranslations({ en, ru });
1738
+ * }
1739
+ * ```
1740
+ */
1741
+ declare function provideTranslations(byLang: TranslationsByLang): Observable<Translation | TranslationObject>;
1742
+
1785
1743
  declare class NotificationApi<SecurityDataType = unknown> extends HttpClient<SecurityDataType> {
1786
1744
  getNotificationByUser: (query: GetNotificationByUserParams, params?: RequestParams) => Promise<UserNotificationListResponse>;
1787
1745
  getNotificationCountByUser: (params?: RequestParams) => Promise<UserNotificationCountResponse>;
@@ -1833,5 +1791,5 @@ declare class CustomElementExtensionModuleHostComponent extends BaseModuleCompon
1833
1791
  static ɵcmp: i0.ɵɵComponentDeclaration<CustomElementExtensionModuleHostComponent, "ng-component", never, {}, {}, never, never, true, never>;
1834
1792
  }
1835
1793
 
1836
- export { APP_THEME_PRESETS, APP_THEME_PRESETS_MERGE_MODE, AccessComponent, AppConfiguratorComponent, AppFloatingConfiguratorComponent, AppLayoutComponent, AppModulesComponent, AppTopbar, AppTopbarApplicationSwitcherComponent, ApplicationRegistryService, ApplicationsApi, ApplicationsComponent, AuthGuardService, BaseModuleComponent, BffSecurityService, ConfigComponent, ContentType, CustomElementExtensionModuleHostComponent, DbMigrationComponent, DiscussionComponent, ErrorComponent, ExtensionLoaderService, ExtensionModuleHostComponent, FolderModuleApi, FooterComponent, HttpClient, IframeModuleApi, IframeModuleComponent, L10nService, LOGO_COMPONENT_TOKEN, LayoutService, LogoComponent, LogoService, MenuComponent, MenuService, ModuleInstanceRightsService, MsgService, NotfoundComponent, NotificationApi, NotificationService, OIP_EXTENSION_EVENTS, SecurityApi, SecurityComponent, SecurityService, SidebarComponent, TableFilterService, TopBarService, UnauthorizedComponent, UserNotificationsComponent, UserProfileApi, UserProfileComponent, UserService, convertToPrimeNgDateFormat, defaultTheme, emitOipContextChange, emitOipError, emitOipNavigate, emitOipNotify, emitOipSettingsChange, emitOipTitleChange, langIntercept, mergeWithDefaults, moduleAccessGuard, provideAppThemes, provideLogoComponent, provideOip, replaceDefaults };
1794
+ export { APP_THEME_PRESETS, APP_THEME_PRESETS_MERGE_MODE, AccessComponent, AppConfiguratorComponent, AppFloatingConfiguratorComponent, AppLayoutComponent, AppModulesComponent, AppTopbar, AppTopbarApplicationSwitcherComponent, ApplicationRegistryService, ApplicationsApi, ApplicationsComponent, AuthGuardService, BaseModuleComponent, BffSecurityService, ConfigComponent, ContentType, CustomElementExtensionModuleHostComponent, DbMigrationComponent, DiscussionComponent, ErrorComponent, ExtensionLoaderService, ExtensionModuleHostComponent, FolderModuleApi, FooterComponent, HttpClient, IframeModuleApi, IframeModuleComponent, L10nService, LOGO_COMPONENT_TOKEN, LayoutService, LogoComponent, LogoService, MenuComponent, MenuService, ModuleInstanceRightsService, MsgService, NotfoundComponent, NotificationApi, NotificationService, OIP_EXTENSION_EVENTS, SecurityApi, SecurityComponent, SecurityService, SidebarComponent, TableFilterService, TopBarService, UnauthorizedComponent, UserNotificationsComponent, UserProfileApi, UserProfileComponent, UserService, convertToPrimeNgDateFormat, defaultTheme, emitOipContextChange, emitOipError, emitOipNavigate, emitOipNotify, emitOipSettingsChange, emitOipTitleChange, langIntercept, mergeWithDefaults, moduleAccessGuard, provideAppThemes, provideLogoComponent, provideOip, provideTranslations, replaceDefaults };
1837
1795
  export type { AppConfig, AppThemePreset, AppThemePresetMergeMode, AuthCsrfToken, LanguageDto, MenuChangeEvent, ModuleAccessRouteData, NoSettingsDto, OipExtensionHostContext, OipExtensionLoadType, OipExtensionManifest, OipExtensionModuleMetadata, OipExtensionNavigateEvent, OipExtensionNotifyEvent, PutSecurityDto, RequestParams, SecurityDto, TopBarDto };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oip-common",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "description": "A template for cross-platform web applications based on sakai-ng and primeNG",
5
5
  "main": "index.js",
6
6
  "keywords": [