sass-cms-template-common 0.0.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 +129 -0
- package/dist/index.d.ts +274 -0
- package/dist/index.js +1698 -0
- package/dist/index.js.map +1 -0
- package/package.json +69 -0
package/README.md
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# React + TypeScript + Vite
|
|
2
|
+
|
|
3
|
+
## Requisitos
|
|
4
|
+
|
|
5
|
+
Este proyecto usa **Vite 8**, que necesita **Node.js 20.19+** o **22.12+**. Con versiones anteriores (por ejemplo 20.18) falla el arranque por bindings nativos de `rolldown`.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
nvm use # lee .nvmrc (Node 22)
|
|
9
|
+
rm -rf node_modules package-lock.json
|
|
10
|
+
npm install
|
|
11
|
+
npm run dev
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Modo librería
|
|
15
|
+
|
|
16
|
+
Paquete ESM para compartir código entre apps CMS. El código público vive en `src/lib/` y se exporta desde `src/index.ts`. `src/App.tsx` y `src/main.tsx` son solo playground de desarrollo.
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm run build # genera dist/ (JS + tipos)
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Contenido compartido (`src/lib`)
|
|
23
|
+
|
|
24
|
+
| Área | Descripción |
|
|
25
|
+
|------|-------------|
|
|
26
|
+
| `components/shell` | `AppShell` (layout sidebar + topbar) |
|
|
27
|
+
| `components/sidebar` | `Sidebar` genérico (recibe `navBlocks`) |
|
|
28
|
+
| `components/top-bar` | `TopBar`, `NotificationsMenu`, `ProfileMenu` |
|
|
29
|
+
| `components/site-selector-menu` | Selector de publicación |
|
|
30
|
+
| `components/mui-provider` | `CmsMuiProvider`, `NextCmsMuiProvider` |
|
|
31
|
+
| `theme/` | `createAppTheme` + tokens Material |
|
|
32
|
+
| `types/` | Contratos API/UI (publicación, perfil, notificaciones, navegación) |
|
|
33
|
+
| `utils/` | URLs CMS, avatar, utilidades de sitios/publicaciones |
|
|
34
|
+
|
|
35
|
+
Lo **específico de cada app** (rutas del sidebar, logos Next/Image, acciones server) queda en el proyecto consumidor.
|
|
36
|
+
|
|
37
|
+
### Consumir en otro proyecto (monorepo)
|
|
38
|
+
|
|
39
|
+
En `package.json` del consumidor:
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"sass-cms-template-common": "file:../sass-cms-template-common"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Luego instala y importa:
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import { LIB_VERSION } from 'sass-cms-template-common'
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
`react` y `react-dom` son **peer dependencies**; el proyecto host debe proveerlas.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
|
60
|
+
|
|
61
|
+
Currently, two official plugins are available:
|
|
62
|
+
|
|
63
|
+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs)
|
|
64
|
+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/)
|
|
65
|
+
|
|
66
|
+
## React Compiler
|
|
67
|
+
|
|
68
|
+
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
|
|
69
|
+
|
|
70
|
+
## Expanding the ESLint configuration
|
|
71
|
+
|
|
72
|
+
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
|
73
|
+
|
|
74
|
+
```js
|
|
75
|
+
export default defineConfig([
|
|
76
|
+
globalIgnores(['dist']),
|
|
77
|
+
{
|
|
78
|
+
files: ['**/*.{ts,tsx}'],
|
|
79
|
+
extends: [
|
|
80
|
+
// Other configs...
|
|
81
|
+
|
|
82
|
+
// Remove tseslint.configs.recommended and replace with this
|
|
83
|
+
tseslint.configs.recommendedTypeChecked,
|
|
84
|
+
// Alternatively, use this for stricter rules
|
|
85
|
+
tseslint.configs.strictTypeChecked,
|
|
86
|
+
// Optionally, add this for stylistic rules
|
|
87
|
+
tseslint.configs.stylisticTypeChecked,
|
|
88
|
+
|
|
89
|
+
// Other configs...
|
|
90
|
+
],
|
|
91
|
+
languageOptions: {
|
|
92
|
+
parserOptions: {
|
|
93
|
+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
94
|
+
tsconfigRootDir: import.meta.dirname,
|
|
95
|
+
},
|
|
96
|
+
// other options...
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
])
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
|
103
|
+
|
|
104
|
+
```js
|
|
105
|
+
// eslint.config.js
|
|
106
|
+
import reactX from 'eslint-plugin-react-x'
|
|
107
|
+
import reactDom from 'eslint-plugin-react-dom'
|
|
108
|
+
|
|
109
|
+
export default defineConfig([
|
|
110
|
+
globalIgnores(['dist']),
|
|
111
|
+
{
|
|
112
|
+
files: ['**/*.{ts,tsx}'],
|
|
113
|
+
extends: [
|
|
114
|
+
// Other configs...
|
|
115
|
+
// Enable lint rules for React
|
|
116
|
+
reactX.configs['recommended-typescript'],
|
|
117
|
+
// Enable lint rules for React DOM
|
|
118
|
+
reactDom.configs.recommended,
|
|
119
|
+
],
|
|
120
|
+
languageOptions: {
|
|
121
|
+
parserOptions: {
|
|
122
|
+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
123
|
+
tsconfigRootDir: import.meta.dirname,
|
|
124
|
+
},
|
|
125
|
+
// other options...
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
])
|
|
129
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { AnchorHTMLAttributes } from 'react';
|
|
2
|
+
import { ElementType } from 'react';
|
|
3
|
+
import { ForwardRefExoticComponent } from 'react';
|
|
4
|
+
import { JSX } from 'react';
|
|
5
|
+
import { ReactNode } from 'react';
|
|
6
|
+
import { RefAttributes } from 'react';
|
|
7
|
+
import { Theme } from '@mui/material/styles';
|
|
8
|
+
|
|
9
|
+
export declare function AppShell({ pathname, sites, children, notificationUnreadCount, notifications, profile, navBlocks, primaryLogo, brandLogo, selectedPublicationId, getPublicationHref, resolvePublicationImageUrl, profileAvatarOptions, LinkComponent, }: AppShellProps): JSX.Element;
|
|
10
|
+
|
|
11
|
+
export declare type AppShellProps = {
|
|
12
|
+
pathname: string;
|
|
13
|
+
sites: SiteSection[];
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
notificationUnreadCount: number;
|
|
16
|
+
notifications: DashboardNotification[];
|
|
17
|
+
profile: ProfileGetResponse;
|
|
18
|
+
navBlocks: NavBlock[];
|
|
19
|
+
primaryLogo: ReactNode;
|
|
20
|
+
brandLogo?: ReactNode;
|
|
21
|
+
selectedPublicationId?: string;
|
|
22
|
+
getPublicationHref: (publication: Publication) => string;
|
|
23
|
+
resolvePublicationImageUrl?: (imagePath: string) => string;
|
|
24
|
+
profileAvatarOptions?: ProfileAvatarOptions;
|
|
25
|
+
LinkComponent?: CmsLinkComponent;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export declare type CmsLinkComponent = ElementType<CmsLinkProps & RefAttributes<HTMLAnchorElement>>;
|
|
29
|
+
|
|
30
|
+
export declare type CmsLinkProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|
31
|
+
href: string;
|
|
32
|
+
children?: ReactNode;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/** Provider MUI sin integración Next.js (playground Vite u otros frameworks). */
|
|
36
|
+
export declare function CmsMuiProvider({ children }: CmsMuiProviderProps): JSX.Element;
|
|
37
|
+
|
|
38
|
+
export declare type CmsMuiProviderProps = {
|
|
39
|
+
children: ReactNode;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/** POST /dashboard/countNotificatio */
|
|
43
|
+
export declare interface CountNotificationsResponse {
|
|
44
|
+
status: string;
|
|
45
|
+
count: number;
|
|
46
|
+
unread?: number;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export declare function createAppTheme(): Theme;
|
|
50
|
+
|
|
51
|
+
export declare interface DashboardNotification {
|
|
52
|
+
id: string;
|
|
53
|
+
title: string;
|
|
54
|
+
message: string;
|
|
55
|
+
severity: NotificationSeverity;
|
|
56
|
+
read: boolean;
|
|
57
|
+
createdAt: string;
|
|
58
|
+
href?: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export declare const DEFAULT_SITE_ID = "bluestack-es";
|
|
62
|
+
|
|
63
|
+
export declare const DefaultCmsLink: ForwardRefExoticComponent<AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|
64
|
+
href: string;
|
|
65
|
+
children?: ReactNode;
|
|
66
|
+
} & RefAttributes<HTMLAnchorElement>>;
|
|
67
|
+
|
|
68
|
+
export declare function findPublicationBySlug(sites: SiteSection[], slug: string): Publication | undefined;
|
|
69
|
+
|
|
70
|
+
export declare function findPublicationLabel(sites: SiteSection[], publicationId: string): string;
|
|
71
|
+
|
|
72
|
+
export declare function getAllPublications(sites: SiteSection[]): Publication[];
|
|
73
|
+
|
|
74
|
+
export declare function getDefaultPublicationSlug(sites: SiteSection[]): string;
|
|
75
|
+
|
|
76
|
+
export declare function getProfileAvatarSrc(profile: ProfileGetResponse, options?: ProfileAvatarOptions): string;
|
|
77
|
+
|
|
78
|
+
export declare function getProfileDisplayName(profile: ProfileGetResponse): string;
|
|
79
|
+
|
|
80
|
+
export declare const ITEM_DEFAULT_BG = "#FFFFFF";
|
|
81
|
+
|
|
82
|
+
export declare const ITEM_HOVER_BG = "#D8E2FF";
|
|
83
|
+
|
|
84
|
+
export declare const LIB_VERSION: "0.0.0";
|
|
85
|
+
|
|
86
|
+
export declare const MENU_BG = "#ECEDF6";
|
|
87
|
+
|
|
88
|
+
export declare type NavBlock = NavLinkItem[] | {
|
|
89
|
+
divider: true;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export declare type NavLinkItem = {
|
|
93
|
+
label: string;
|
|
94
|
+
href: string;
|
|
95
|
+
icon: ElementType;
|
|
96
|
+
badge?: string;
|
|
97
|
+
children?: NavLinkItem[];
|
|
98
|
+
defaultOpen?: boolean;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export declare function NextCmsMuiProvider({ children }: NextCmsMuiProviderProps): JSX.Element;
|
|
102
|
+
|
|
103
|
+
export declare type NextCmsMuiProviderProps = {
|
|
104
|
+
children: ReactNode;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export declare type NotificationSeverity = 'info' | 'warning' | 'error' | 'success';
|
|
108
|
+
|
|
109
|
+
/** POST /dashboard/notification */
|
|
110
|
+
export declare interface NotificationsListResponse {
|
|
111
|
+
status: string;
|
|
112
|
+
notifications: DashboardNotification[];
|
|
113
|
+
total?: number;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export declare function NotificationsMenu({ unreadCount, notifications, }: NotificationsMenuProps): JSX.Element;
|
|
117
|
+
|
|
118
|
+
export declare type NotificationsMenuProps = {
|
|
119
|
+
unreadCount: number;
|
|
120
|
+
notifications: DashboardNotification[];
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export declare function parsePublicationSlug(slug: string): number;
|
|
124
|
+
|
|
125
|
+
export declare interface ProfileAdditionalInfoField {
|
|
126
|
+
name: string;
|
|
127
|
+
type: ProfileFieldType;
|
|
128
|
+
options: string[];
|
|
129
|
+
categoryPath: string;
|
|
130
|
+
depends: string;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export declare type ProfileAvatarOptions = {
|
|
134
|
+
cmsOrigin?: string;
|
|
135
|
+
fallbackAvatar?: string;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export declare type ProfileFieldType = 'string' | 'textarea' | 'date' | 'option' | 'category';
|
|
139
|
+
|
|
140
|
+
/** POST /profile/get */
|
|
141
|
+
export declare interface ProfileGetResponse {
|
|
142
|
+
status: string;
|
|
143
|
+
creationDate: string;
|
|
144
|
+
defaultPublication: string;
|
|
145
|
+
defaultSite: string;
|
|
146
|
+
email: string;
|
|
147
|
+
firstName: string;
|
|
148
|
+
fullName: string;
|
|
149
|
+
image: string;
|
|
150
|
+
lastName: string;
|
|
151
|
+
locale: string;
|
|
152
|
+
userName: string;
|
|
153
|
+
userStatus: string;
|
|
154
|
+
viewNews: string;
|
|
155
|
+
viewPins: string;
|
|
156
|
+
imageAllowedFileTypes: string;
|
|
157
|
+
additionalInfo: ProfileAdditionalInfoField[];
|
|
158
|
+
documentation: unknown[];
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export declare function ProfileMenu({ profile, avatarOptions }: ProfileMenuProps): JSX.Element;
|
|
162
|
+
|
|
163
|
+
export declare type ProfileMenuProps = {
|
|
164
|
+
profile: ProfileGetResponse;
|
|
165
|
+
avatarOptions?: ProfileAvatarOptions;
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
export declare interface Publication {
|
|
169
|
+
baseURL: string;
|
|
170
|
+
ckeditor: string;
|
|
171
|
+
customDomain?: string;
|
|
172
|
+
dateFormat: string;
|
|
173
|
+
description: string;
|
|
174
|
+
gmtRedaction: string;
|
|
175
|
+
gmtRedactionName: string;
|
|
176
|
+
gmtServer: string;
|
|
177
|
+
gmtServerName: string;
|
|
178
|
+
googleApiKey: string;
|
|
179
|
+
hasCategory: boolean;
|
|
180
|
+
hasCategoryData: string;
|
|
181
|
+
hasComplianceActive: boolean;
|
|
182
|
+
hasZone: boolean;
|
|
183
|
+
hasZoneJson: PublicationZoneConfig;
|
|
184
|
+
id: number;
|
|
185
|
+
imagePath: string;
|
|
186
|
+
languaje: string;
|
|
187
|
+
mercado: string;
|
|
188
|
+
name: string;
|
|
189
|
+
newsFormTarget: string;
|
|
190
|
+
permitions: PublicationPermissions;
|
|
191
|
+
pinedMax: string;
|
|
192
|
+
publication: number;
|
|
193
|
+
site: string;
|
|
194
|
+
sitio: string;
|
|
195
|
+
timeFormat: string;
|
|
196
|
+
type: string;
|
|
197
|
+
updateAdmin: PublicationUpdateAdmin;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export declare interface PublicationPermissions {
|
|
201
|
+
hasAccess: boolean;
|
|
202
|
+
NEWS_EDIT: boolean;
|
|
203
|
+
NEWS_SHARE: boolean;
|
|
204
|
+
[key: string]: boolean;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export declare interface PublicationsGetResponse {
|
|
208
|
+
status: string;
|
|
209
|
+
publications: Publication[];
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export declare interface PublicationUpdateAdmin {
|
|
213
|
+
rebootBannerDate: string;
|
|
214
|
+
rebootBannerDurationMin: string;
|
|
215
|
+
rebootBannerEnable: boolean;
|
|
216
|
+
updateBannerEnable: boolean;
|
|
217
|
+
updateBannerLink: string;
|
|
218
|
+
updateBannerVFSLink: boolean;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export declare interface PublicationZoneConfig {
|
|
222
|
+
home: boolean;
|
|
223
|
+
section: boolean;
|
|
224
|
+
defaultPublication: string;
|
|
225
|
+
entro: number;
|
|
226
|
+
zones: unknown[];
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export declare function resolveCmsAssetUrl(path: string, cmsOrigin?: string): string;
|
|
230
|
+
|
|
231
|
+
export declare function resolveCmsOrigin(cmsOrigin?: string): string;
|
|
232
|
+
|
|
233
|
+
export declare function Sidebar({ open, pathname, navBlocks, LinkComponent, }: SidebarProps): JSX.Element;
|
|
234
|
+
|
|
235
|
+
export declare type SidebarProps = {
|
|
236
|
+
open: boolean;
|
|
237
|
+
pathname: string;
|
|
238
|
+
navBlocks: NavBlock[];
|
|
239
|
+
LinkComponent?: CmsLinkComponent;
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
export declare type SiteSection = {
|
|
243
|
+
title: string;
|
|
244
|
+
publications: Publication[];
|
|
245
|
+
fullWidth?: boolean;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
export declare function SiteSelectorMenu({ sites, selectedPublicationId, getPublicationHref, resolvePublicationImageUrl, }: SiteSelectorMenuProps): JSX.Element;
|
|
249
|
+
|
|
250
|
+
export declare type SiteSelectorMenuProps = {
|
|
251
|
+
sites: SiteSection[];
|
|
252
|
+
selectedPublicationId?: string;
|
|
253
|
+
getPublicationHref: (publication: Publication) => string;
|
|
254
|
+
resolvePublicationImageUrl?: (imagePath: string) => string;
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
export declare function TopBar({ sites, sidebarOpen, onToggleSidebar, notificationUnreadCount, notifications, profile, primaryLogo, brandLogo, selectedPublicationId, getPublicationHref, resolvePublicationImageUrl, profileAvatarOptions, }: TopBarProps): JSX.Element;
|
|
258
|
+
|
|
259
|
+
export declare type TopBarProps = {
|
|
260
|
+
sites: SiteSection[];
|
|
261
|
+
sidebarOpen: boolean;
|
|
262
|
+
onToggleSidebar: () => void;
|
|
263
|
+
notificationUnreadCount: number;
|
|
264
|
+
notifications: DashboardNotification[];
|
|
265
|
+
profile: ProfileGetResponse;
|
|
266
|
+
primaryLogo: ReactNode;
|
|
267
|
+
brandLogo?: ReactNode;
|
|
268
|
+
selectedPublicationId?: string;
|
|
269
|
+
getPublicationHref: (publication: Publication) => string;
|
|
270
|
+
resolvePublicationImageUrl?: (imagePath: string) => string;
|
|
271
|
+
profileAvatarOptions?: ProfileAvatarOptions;
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
export { }
|