sass-cms-template-common 0.0.2 → 0.0.4

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