sass-cms-template-common 0.0.1 → 0.0.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/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { AnchorHTMLAttributes } from 'react';
2
+ import { AxiosInstance } from 'axios';
2
3
  import { ElementType } from 'react';
3
4
  import { ForwardRefExoticComponent } from 'react';
4
5
  import { JSX } from 'react';
@@ -8,11 +9,12 @@ import { Theme } from '@mui/material/styles';
8
9
 
9
10
  /**
10
11
  * Navegación lateral por defecto.
11
- * `module` debe coincidir exactamente con `module` en POST /auth/modulesAvailable.
12
+ * `module` debe coincidir exactamente con `module` en POST /auth/modulesAvailable
13
+ * y con las claves en `messages.navigation`.
12
14
  */
13
15
  export declare const ACCOUNT_NAV_BLOCKS: NavBlock[];
14
16
 
15
- export declare function AppShell({ pathname, sites, children, notificationUnreadCount, notifications, profile, primaryLogo, brandLogo, selectedPublicationId, getPublicationHref, resolvePublicationImageUrl, profileAvatarOptions, LinkComponent, permissions, }: AppShellProps): JSX.Element;
17
+ export declare function AppShell({ pathname, sites, children, notificationUnreadCount, notifications, profile, primaryLogo, brandLogo, selectedPublicationId, getPublicationHref, resolvePublicationImageUrl, profileAvatarOptions, LinkComponent, permissions, locale, language, messages, }: AppShellProps): JSX.Element;
16
18
 
17
19
  export declare type AppShellProps = {
18
20
  pathname: string;
@@ -29,6 +31,41 @@ export declare type AppShellProps = {
29
31
  profileAvatarOptions?: ProfileAvatarOptions;
30
32
  LinkComponent?: CmsLinkComponent;
31
33
  permissions: Array<NavItemPermissions>;
34
+ locale?: Locale | string;
35
+ /** Alias de `locale`. */
36
+ language?: Locale | string;
37
+ messages?: CmsMessagesOverride;
38
+ };
39
+
40
+ /** Credenciales de sesión CMS usadas por los servicios HTTP. */
41
+ export declare type Authentication = {
42
+ browserId: string;
43
+ project: string;
44
+ publication: number;
45
+ siteName: string;
46
+ token: string;
47
+ };
48
+
49
+ export declare class CmsCommonServices {
50
+ protected props: ICommonServices;
51
+ protected authentication: Authentication;
52
+ constructor(props: ICommonServices);
53
+ getDefaultPublication: () => Promise<Publication>;
54
+ getProfile: () => Promise<ProfileGetResponse>;
55
+ getCountNotifications: () => Promise<CountNotificationsResponse>;
56
+ getNotifications: () => Promise<NotificationsListResponse>;
57
+ getSitesAndPublications: () => Promise<SitesAndPublicationsResult>;
58
+ }
59
+
60
+ export declare function CmsI18nProvider({ locale, language, messages, catalog, children, }: CmsI18nProviderProps): JSX.Element;
61
+
62
+ export declare type CmsI18nProviderProps = {
63
+ locale?: Locale | string;
64
+ /** Alias de `locale` (p. ej. consumidores que pasan `language="es"`). */
65
+ language?: Locale | string;
66
+ messages?: CmsMessagesOverride;
67
+ catalog?: LocaleCatalog;
68
+ children: ReactNode;
32
69
  };
33
70
 
34
71
  export declare type CmsLinkComponent = ElementType<CmsLinkProps & RefAttributes<HTMLAnchorElement>>;
@@ -38,6 +75,14 @@ export declare type CmsLinkProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
38
75
  children?: ReactNode;
39
76
  };
40
77
 
78
+ /** Message tree shape; values are strings, keys are inferred from `enMessages`. */
79
+ export declare type CmsMessages = DeepStringMap<typeof enMessages>;
80
+
81
+ /** Partial override tree; missing keys fall back to the active locale, then `en`. */
82
+ export declare type CmsMessagesOverride = {
83
+ [Namespace in keyof CmsMessages]?: Partial<CmsMessages[Namespace]>;
84
+ };
85
+
41
86
  /** Provider MUI sin integración Next.js (playground Vite u otros frameworks). */
42
87
  export declare function CmsMuiProvider({ children }: CmsMuiProviderProps): JSX.Element;
43
88
 
@@ -45,15 +90,28 @@ export declare type CmsMuiProviderProps = {
45
90
  children: ReactNode;
46
91
  };
47
92
 
93
+ export declare type CmsTranslator = {
94
+ messages: CmsMessages;
95
+ navigation: (module: NavigationModule | string) => string;
96
+ sidebar: (key: SidebarMessageKey) => string;
97
+ topBar: (key: TopBarMessageKey) => string;
98
+ profileMenu: (key: ProfileMenuMessageKey) => string;
99
+ notificationsMenu: (key: NotificationsMenuMessageKey, params?: {
100
+ count?: number;
101
+ }) => string;
102
+ };
103
+
48
104
  /** POST /dashboard/countNotificatio */
49
105
  export declare interface CountNotificationsResponse {
50
106
  status: string;
51
107
  count: number;
52
- unread?: number;
108
+ unreadNotifications?: number;
53
109
  }
54
110
 
55
111
  export declare function createAppTheme(): Theme;
56
112
 
113
+ export declare function createTranslator(messages: CmsMessages): CmsTranslator;
114
+
57
115
  export declare interface DashboardNotification {
58
116
  id: string;
59
117
  title: string;
@@ -64,6 +122,14 @@ export declare interface DashboardNotification {
64
122
  href?: string;
65
123
  }
66
124
 
125
+ declare type DeepStringMap<T> = {
126
+ [K in keyof T]: T[K] extends Record<string, unknown> ? {
127
+ [K2 in keyof T[K]]: string;
128
+ } : string;
129
+ };
130
+
131
+ export declare const DEFAULT_LOCALE: Locale;
132
+
67
133
  export declare const DEFAULT_SITE_ID = "bluestack-es";
68
134
 
69
135
  export declare const DefaultCmsLink: ForwardRefExoticComponent<AnchorHTMLAttributes<HTMLAnchorElement> & {
@@ -71,6 +137,144 @@ href: string;
71
137
  children?: ReactNode;
72
138
  } & RefAttributes<HTMLAnchorElement>>;
73
139
 
140
+ export declare const defaultLocaleCatalog: LocaleCatalog;
141
+
142
+ export declare const enMessages: {
143
+ readonly navigation: {
144
+ readonly COMMENTS: "Comments";
145
+ readonly POLLS: "Polls";
146
+ readonly MEDIA: "Media";
147
+ readonly AUDIOS: "Audio";
148
+ readonly IMAGES: "Images";
149
+ readonly PLAYLISTS: "Playlist";
150
+ readonly VIDEOS: "Videos";
151
+ readonly NEWS: "News";
152
+ readonly PLANNING: "Planning";
153
+ readonly ANALYTICS: "Analytics";
154
+ readonly TAGS: "Tags";
155
+ readonly TRIVIAS: "Trivia";
156
+ readonly OTHER: "Other";
157
+ readonly NEWSWIRES: "News Wires";
158
+ readonly EVENTS: "Events";
159
+ readonly PAGES: "Pages";
160
+ readonly FEEDS: "Feed";
161
+ readonly PERSONS: "People";
162
+ readonly CONTRIBUTIONS: "Contributions";
163
+ readonly RECIPES: "Recipes";
164
+ readonly POSTS: "Posts";
165
+ readonly BANNERS: "Banners";
166
+ readonly BLOCKS: "Blocks";
167
+ readonly MENUS: "Menu";
168
+ readonly TOPICS: "Topics";
169
+ readonly ADVANCEDQUERYS: "Advanced search";
170
+ readonly IMPORTS: "Imports";
171
+ readonly NEWSLETTERS: "Newsletters";
172
+ readonly NOTIFICATIONS: "Notifications";
173
+ readonly PAYMENTS: "Payments";
174
+ readonly PLANS: "Plans";
175
+ readonly REPORTS: "Reports";
176
+ readonly SECTIONS: "Sections";
177
+ readonly TWITTERS: "Twitter Feeds";
178
+ readonly USERS: "Users";
179
+ readonly ZONES: "Zones";
180
+ readonly IA: "IA";
181
+ };
182
+ readonly sidebar: {
183
+ readonly navAriaLabel: "Main navigation";
184
+ readonly collapse: "Collapse";
185
+ readonly expand: "Expand";
186
+ readonly newBadge: "New";
187
+ };
188
+ readonly topBar: {
189
+ readonly openSidebar: "Open sidebar menu";
190
+ readonly closeSidebar: "Close sidebar menu";
191
+ readonly new: "New";
192
+ readonly language: "Language";
193
+ readonly analytics: "Analytics";
194
+ readonly help: "Help";
195
+ };
196
+ readonly profileMenu: {
197
+ readonly ariaLabel: "My profile";
198
+ readonly myProfile: "My Profile";
199
+ readonly webmasterView: "Webmaster View";
200
+ readonly signOff: "Sign off";
201
+ };
202
+ readonly notificationsMenu: {
203
+ readonly title: "Notifications";
204
+ readonly unreadCount: "{count} unread";
205
+ readonly empty: "No notifications";
206
+ readonly ariaLabel: "Notifications";
207
+ };
208
+ };
209
+
210
+ export declare const esMessages: {
211
+ navigation: {
212
+ COMMENTS: string;
213
+ POLLS: string;
214
+ MEDIA: string;
215
+ AUDIOS: string;
216
+ IMAGES: string;
217
+ PLAYLISTS: string;
218
+ VIDEOS: string;
219
+ NEWS: string;
220
+ PLANNING: string;
221
+ ANALYTICS: string;
222
+ TAGS: string;
223
+ TRIVIAS: string;
224
+ OTHER: string;
225
+ NEWSWIRES: string;
226
+ EVENTS: string;
227
+ PAGES: string;
228
+ FEEDS: string;
229
+ PERSONS: string;
230
+ CONTRIBUTIONS: string;
231
+ RECIPES: string;
232
+ POSTS: string;
233
+ BANNERS: string;
234
+ BLOCKS: string;
235
+ MENUS: string;
236
+ TOPICS: string;
237
+ ADVANCEDQUERYS: string;
238
+ IMPORTS: string;
239
+ NEWSLETTERS: string;
240
+ NOTIFICATIONS: string;
241
+ PAYMENTS: string;
242
+ PLANS: string;
243
+ REPORTS: string;
244
+ SECTIONS: string;
245
+ TWITTERS: string;
246
+ USERS: string;
247
+ ZONES: string;
248
+ IA: string;
249
+ };
250
+ sidebar: {
251
+ navAriaLabel: string;
252
+ collapse: string;
253
+ expand: string;
254
+ newBadge: string;
255
+ };
256
+ topBar: {
257
+ openSidebar: string;
258
+ closeSidebar: string;
259
+ new: string;
260
+ language: string;
261
+ analytics: string;
262
+ help: string;
263
+ };
264
+ profileMenu: {
265
+ ariaLabel: string;
266
+ myProfile: string;
267
+ webmasterView: string;
268
+ signOff: string;
269
+ };
270
+ notificationsMenu: {
271
+ title: string;
272
+ unreadCount: string;
273
+ empty: string;
274
+ ariaLabel: string;
275
+ };
276
+ };
277
+
74
278
  export declare function findPublicationBySlug(sites: SiteSection[], slug: string): Publication | undefined;
75
279
 
76
280
  export declare function findPublicationLabel(sites: SiteSection[], publicationId: string): string;
@@ -79,31 +283,54 @@ export declare function getAllPublications(sites: SiteSection[]): Publication[];
79
283
 
80
284
  export declare function getDefaultPublicationSlug(sites: SiteSection[]): string;
81
285
 
286
+ /** BCP 47 tag for `Intl` / `toLocaleString` formatting. */
287
+ export declare function getIntlLocaleTag(locale: Locale): string;
288
+
82
289
  export declare function getProfileAvatarSrc(profile: ProfileGetResponse, options?: ProfileAvatarOptions): string;
83
290
 
84
291
  export declare function getProfileDisplayName(profile: ProfileGetResponse): string;
85
292
 
293
+ declare interface ICommonServices {
294
+ axiosApi: AxiosInstance;
295
+ authentication: Authentication;
296
+ }
297
+
86
298
  export declare const ITEM_DEFAULT_BG = "#FFFFFF";
87
299
 
88
300
  export declare const ITEM_HOVER_BG = "#D8E2FF";
89
301
 
90
302
  export declare const LIB_VERSION: "0.0.0";
91
303
 
304
+ export declare type Locale = (typeof SUPPORTED_LOCALES)[number];
305
+
306
+ export declare type LocaleCatalog = Record<Locale, CmsMessages>;
307
+
92
308
  export declare const MENU_BG = "#ECEDF6";
93
309
 
310
+ /** Deep-merge custom overrides on top of the locale catalog entry. */
311
+ export declare function mergeMessages(locale: Locale, catalog: LocaleCatalog, overrides?: CmsMessagesOverride): CmsMessages;
312
+
313
+ /** Cuerpo de la respuesta de POST /auth/modulesAvailable */
314
+ export declare interface ModulesAvailableResponse {
315
+ modules: NavItemPermissions[];
316
+ }
317
+
94
318
  export declare type NavBlock = NavLinkItem;
95
319
 
320
+ export declare type NavigationModule = keyof CmsMessages['navigation'];
321
+
96
322
  export declare type NavItemPermissions = {
97
323
  module: string;
98
- isNew: boolean;
324
+ isnew: boolean;
99
325
  };
100
326
 
101
327
  export declare type NavLinkItem = {
102
- label: string;
103
328
  href: string;
104
329
  icon: ElementType;
105
330
  /** Clave de POST /auth/modulesAvailable (p. ej. `NEWSWIRES`, `MENUS`) */
106
331
  module: string;
332
+ /** Override opcional del label traducido vía i18n (`navigation.{module}`). */
333
+ label?: string;
107
334
  badge?: string;
108
335
  children?: NavLinkItem[];
109
336
  defaultOpen?: boolean;
@@ -115,6 +342,9 @@ export declare type NextCmsMuiProviderProps = {
115
342
  children: ReactNode;
116
343
  };
117
344
 
345
+ /** Normaliza códigos BCP 47 o variantes (`es-MX`, `pt_BR`) al `Locale` soportado. */
346
+ export declare function normalizeLocale(value?: string | null): Locale;
347
+
118
348
  export declare type NotificationSeverity = 'info' | 'warning' | 'error' | 'success';
119
349
 
120
350
  /** POST /dashboard/notification */
@@ -126,6 +356,8 @@ export declare interface NotificationsListResponse {
126
356
 
127
357
  export declare function NotificationsMenu({ unreadCount, notifications, }: NotificationsMenuProps): JSX.Element;
128
358
 
359
+ export declare type NotificationsMenuMessageKey = keyof CmsMessages['notificationsMenu'];
360
+
129
361
  export declare type NotificationsMenuProps = {
130
362
  unreadCount: number;
131
363
  notifications: DashboardNotification[];
@@ -171,11 +403,82 @@ export declare interface ProfileGetResponse {
171
403
 
172
404
  export declare function ProfileMenu({ profile, avatarOptions }: ProfileMenuProps): JSX.Element;
173
405
 
406
+ export declare type ProfileMenuMessageKey = keyof CmsMessages['profileMenu'];
407
+
174
408
  export declare type ProfileMenuProps = {
175
409
  profile: ProfileGetResponse;
176
410
  avatarOptions?: ProfileAvatarOptions;
177
411
  };
178
412
 
413
+ export declare const ptMessages: {
414
+ navigation: {
415
+ COMMENTS: string;
416
+ POLLS: string;
417
+ MEDIA: string;
418
+ AUDIOS: string;
419
+ IMAGES: string;
420
+ PLAYLISTS: string;
421
+ VIDEOS: string;
422
+ NEWS: string;
423
+ PLANNING: string;
424
+ ANALYTICS: string;
425
+ TAGS: string;
426
+ TRIVIAS: string;
427
+ OTHER: string;
428
+ NEWSWIRES: string;
429
+ EVENTS: string;
430
+ PAGES: string;
431
+ FEEDS: string;
432
+ PERSONS: string;
433
+ CONTRIBUTIONS: string;
434
+ RECIPES: string;
435
+ POSTS: string;
436
+ BANNERS: string;
437
+ BLOCKS: string;
438
+ MENUS: string;
439
+ TOPICS: string;
440
+ ADVANCEDQUERYS: string;
441
+ IMPORTS: string;
442
+ NEWSLETTERS: string;
443
+ NOTIFICATIONS: string;
444
+ PAYMENTS: string;
445
+ PLANS: string;
446
+ REPORTS: string;
447
+ SECTIONS: string;
448
+ TWITTERS: string;
449
+ USERS: string;
450
+ ZONES: string;
451
+ IA: string;
452
+ };
453
+ sidebar: {
454
+ navAriaLabel: string;
455
+ collapse: string;
456
+ expand: string;
457
+ newBadge: string;
458
+ };
459
+ topBar: {
460
+ openSidebar: string;
461
+ closeSidebar: string;
462
+ new: string;
463
+ language: string;
464
+ analytics: string;
465
+ help: string;
466
+ };
467
+ profileMenu: {
468
+ ariaLabel: string;
469
+ myProfile: string;
470
+ webmasterView: string;
471
+ signOff: string;
472
+ };
473
+ notificationsMenu: {
474
+ title: string;
475
+ unreadCount: string;
476
+ empty: string;
477
+ ariaLabel: string;
478
+ };
479
+ };
480
+
481
+ /** Publicación devuelta por POST /publications/get y POST /publications/default */
179
482
  export declare interface Publication {
180
483
  baseURL: string;
181
484
  ckeditor: string;
@@ -194,6 +497,7 @@ export declare interface Publication {
194
497
  hasZoneJson: PublicationZoneConfig;
195
498
  id: number;
196
499
  imagePath: string;
500
+ /** Nombre del campo tal como viene del API */
197
501
  languaje: string;
198
502
  mercado: string;
199
503
  name: string;
@@ -208,6 +512,7 @@ export declare interface Publication {
208
512
  updateAdmin: PublicationUpdateAdmin;
209
513
  }
210
514
 
515
+ /** Permisos de la publicación en el CMS */
211
516
  export declare interface PublicationPermissions {
212
517
  hasAccess: boolean;
213
518
  NEWS_EDIT: boolean;
@@ -215,11 +520,13 @@ export declare interface PublicationPermissions {
215
520
  [key: string]: boolean;
216
521
  }
217
522
 
523
+ /** Cuerpo de la respuesta de POST /publications/get */
218
524
  export declare interface PublicationsGetResponse {
219
525
  status: string;
220
526
  publications: Publication[];
221
527
  }
222
528
 
529
+ /** Banner / actualizaciones de administración */
223
530
  export declare interface PublicationUpdateAdmin {
224
531
  rebootBannerDate: string;
225
532
  rebootBannerDurationMin: string;
@@ -229,6 +536,7 @@ export declare interface PublicationUpdateAdmin {
229
536
  updateBannerVFSLink: boolean;
230
537
  }
231
538
 
539
+ /** Zonas por publicación (hasZoneJson) */
232
540
  export declare interface PublicationZoneConfig {
233
541
  home: boolean;
234
542
  section: boolean;
@@ -243,6 +551,8 @@ export declare function resolveCmsOrigin(cmsOrigin?: string): string;
243
551
 
244
552
  export declare function Sidebar({ open, pathname, permissions, LinkComponent, }: SidebarProps): JSX.Element;
245
553
 
554
+ export declare type SidebarMessageKey = keyof CmsMessages['sidebar'];
555
+
246
556
  export declare type SidebarProps = {
247
557
  open: boolean;
248
558
  pathname: string;
@@ -250,6 +560,20 @@ export declare type SidebarProps = {
250
560
  permissions: Array<NavItemPermissions>;
251
561
  };
252
562
 
563
+ /** Entrada de sitio devuelta por POST /sites/get */
564
+ export declare interface Site {
565
+ /** Slug del sitio; cadena vacía para la raíz */
566
+ name: string;
567
+ /** Etiqueta visible (p. ej. "Generic Site 1", "Laboratorio") */
568
+ title: string;
569
+ }
570
+
571
+ /** Resultado de combinar sitios, publicaciones y módulos disponibles */
572
+ export declare interface SitesAndPublicationsResult {
573
+ sites: SiteSection[];
574
+ modules: NavItemPermissions[];
575
+ }
576
+
253
577
  export declare type SiteSection = {
254
578
  title: string;
255
579
  publications: Publication[];
@@ -265,8 +589,22 @@ export declare type SiteSelectorMenuProps = {
265
589
  resolvePublicationImageUrl?: (imagePath: string) => string;
266
590
  };
267
591
 
592
+ /** Cuerpo de la respuesta de POST /sites/get */
593
+ export declare interface SitesGetResponse {
594
+ /** Ruta del sitio activo (p. ej. "/sites/generic1") */
595
+ root: string;
596
+ /** Misma ruta que `root`; el API la repite con esta clave */
597
+ 'root.': string;
598
+ status: string;
599
+ sites: Site[];
600
+ }
601
+
602
+ export declare const SUPPORTED_LOCALES: readonly ["es", "en", "pt"];
603
+
268
604
  export declare function TopBar({ sites, sidebarOpen, onToggleSidebar, notificationUnreadCount, notifications, profile, primaryLogo, brandLogo, selectedPublicationId, getPublicationHref, resolvePublicationImageUrl, profileAvatarOptions, }: TopBarProps): JSX.Element;
269
605
 
606
+ export declare type TopBarMessageKey = keyof CmsMessages['topBar'];
607
+
270
608
  export declare type TopBarProps = {
271
609
  sites: SiteSection[];
272
610
  sidebarOpen: boolean;
@@ -282,4 +620,15 @@ export declare type TopBarProps = {
282
620
  profileAvatarOptions?: ProfileAvatarOptions;
283
621
  };
284
622
 
623
+ export declare function useCmsTranslation(options?: UseCmsTranslationOptions): {
624
+ locale: "es" | "en" | "pt";
625
+ t: CmsTranslator;
626
+ };
627
+
628
+ export declare type UseCmsTranslationOptions = {
629
+ locale?: Locale;
630
+ messages?: CmsMessagesOverride;
631
+ catalog?: LocaleCatalog;
632
+ };
633
+
285
634
  export { }