@tramvai/module-render 2.59.4 → 2.61.1
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 +2 -187
- package/lib/browser.js +2 -1
- package/lib/server.es.js +2 -1
- package/lib/server.js +1 -0
- package/package.json +16 -16
package/README.md
CHANGED
|
@@ -143,194 +143,9 @@ To speed up data loading, we've added a preloading system for resources and asyn
|
|
|
143
143
|
- Next we add all the CSS to the **preload** tag and add onload event on them. We need to load the blocking resources as quickly as possible.
|
|
144
144
|
- When loading any CSS file, onload event will be fired (only once time) and add all **preload** tags to the necessary JS files
|
|
145
145
|
|
|
146
|
-
###
|
|
146
|
+
### Layouts
|
|
147
147
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
[Read more about layout on the library page](references/libs/tinkoff-layout.md)
|
|
151
|
-
|
|
152
|
-
#### Adding a default header and footer
|
|
153
|
-
|
|
154
|
-
The module allows you to add header and footer components, which will be rendered by default for all pages
|
|
155
|
-
|
|
156
|
-
##### Via provider
|
|
157
|
-
|
|
158
|
-
Register header and footer components through providers:
|
|
159
|
-
|
|
160
|
-
```tsx
|
|
161
|
-
import { DEFAULT_HEADER_COMPONENT, DEFAULT_FOOTER_COMPONENT } from '@tramvai/tokens-render';
|
|
162
|
-
import { provide } from '@tramvai/core';
|
|
163
|
-
|
|
164
|
-
createApp({
|
|
165
|
-
providers: [
|
|
166
|
-
provide({
|
|
167
|
-
provide: DEFAULT_HEADER_COMPONENT,
|
|
168
|
-
useValue: DefaultHeader,
|
|
169
|
-
}),
|
|
170
|
-
provide({
|
|
171
|
-
provide: DEFAULT_FOOTER_COMPONENT,
|
|
172
|
-
useValue: DefaultFooter,
|
|
173
|
-
}),
|
|
174
|
-
],
|
|
175
|
-
});
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
##### Via bundle
|
|
179
|
-
|
|
180
|
-
You can register a `headerDefault` and `footerDefault` component in the bundle, which will be rendered for all routes that do not have `headerComponent` and `footerComponent` redefined in configuration:
|
|
181
|
-
|
|
182
|
-
```tsx
|
|
183
|
-
createBundle({
|
|
184
|
-
name: 'common-bundle',
|
|
185
|
-
components: {
|
|
186
|
-
headerDefault: CustomHeader,
|
|
187
|
-
footerDefault: CustomFooter,
|
|
188
|
-
},
|
|
189
|
-
});
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
#### Adding components and wrappers
|
|
193
|
-
|
|
194
|
-
You can add custom components and wrappers for layout via the token `LAYOUT_OPTIONS`, this wrappers will be applied on every application page:
|
|
195
|
-
|
|
196
|
-
```tsx
|
|
197
|
-
import { provide } from '@tramvai/core';
|
|
198
|
-
@Module({
|
|
199
|
-
providers: [
|
|
200
|
-
provide({
|
|
201
|
-
provide: 'LAYOUT_OPTIONS',
|
|
202
|
-
multi: true,
|
|
203
|
-
useValue: {
|
|
204
|
-
// React components
|
|
205
|
-
components: {
|
|
206
|
-
// content component, this component wraps the header, page and footer
|
|
207
|
-
content: Content,
|
|
208
|
-
// page component
|
|
209
|
-
page: Page,
|
|
210
|
-
|
|
211
|
-
// any global components
|
|
212
|
-
alerts: Alerts,
|
|
213
|
-
feedback: Feedback,
|
|
214
|
-
},
|
|
215
|
-
// HOC's for components
|
|
216
|
-
wrappers: {
|
|
217
|
-
layout: layoutWrapper,
|
|
218
|
-
alerts: [alertWrapper1, alertWrapper2],
|
|
219
|
-
},
|
|
220
|
-
},
|
|
221
|
-
}),
|
|
222
|
-
],
|
|
223
|
-
})
|
|
224
|
-
export class MyLayoutModule {}
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
More details about the `components` and `wrappers` options can be found in [@tinkoff/layout-factory](references/libs/tinkoff-layout.md)
|
|
228
|
-
|
|
229
|
-
#### Replacing the root layout
|
|
230
|
-
|
|
231
|
-
:::warning
|
|
232
|
-
|
|
233
|
-
Not recommended, because a lot of dependant features can be broken!
|
|
234
|
-
|
|
235
|
-
:::
|
|
236
|
-
|
|
237
|
-
If the basic layout doesn't work for you, you can replace it with any other React component.
|
|
238
|
-
In doing so, you need to implement all the wrappers yourself and plug in global components if you need them.
|
|
239
|
-
|
|
240
|
-
You can replace it in two ways:
|
|
241
|
-
|
|
242
|
-
##### Add layoutComponent to route
|
|
243
|
-
|
|
244
|
-
You can add a `layoutComponent` property to route `config` and register component in `bundle`.
|
|
245
|
-
This layout will be rendered when you go to the corresponding route.
|
|
246
|
-
|
|
247
|
-
```tsx
|
|
248
|
-
createBundle({
|
|
249
|
-
name: 'common-bundle',
|
|
250
|
-
components: {
|
|
251
|
-
myCustomLayout: CustomLayout,
|
|
252
|
-
},
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
const route = {
|
|
256
|
-
name: 'main',
|
|
257
|
-
path: '/',
|
|
258
|
-
config: {
|
|
259
|
-
layoutComponent: 'myCustomLayout',
|
|
260
|
-
},
|
|
261
|
-
};
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
##### Replace layoutDefault
|
|
265
|
-
|
|
266
|
-
You can register a `layoutDefault` component in `bundle`, which will be automatically rendered for all routes that do not have an `layoutComponent` in `config` property.
|
|
267
|
-
|
|
268
|
-
```tsx
|
|
269
|
-
createBundle({
|
|
270
|
-
name: 'common-bundle',
|
|
271
|
-
components: {
|
|
272
|
-
layoutDefault: CustomLayout,
|
|
273
|
-
},
|
|
274
|
-
});
|
|
275
|
-
```
|
|
276
|
-
|
|
277
|
-
### Nested layout
|
|
278
|
-
|
|
279
|
-
For every page, nested layout can be applied. It is useful when you need to wrap group of pages in the same block, or add the same actions.
|
|
280
|
-
|
|
281
|
-
:::note
|
|
282
|
-
|
|
283
|
-
For now, only one level of layout nesting supported, and simplified component structure will look like this:
|
|
284
|
-
|
|
285
|
-
```tsx
|
|
286
|
-
<RootLayout>
|
|
287
|
-
<NestedLayout>
|
|
288
|
-
<Page />
|
|
289
|
-
</NestedLayout>
|
|
290
|
-
</RootLayout>
|
|
291
|
-
```
|
|
292
|
-
|
|
293
|
-
:::
|
|
294
|
-
|
|
295
|
-
Nested layout it is a simple React component with `children` property, and static properties `actions` and `reducers` are supported:
|
|
296
|
-
|
|
297
|
-
```tsx
|
|
298
|
-
import type { NestedLayoutComponent } from '@tramvai/react';
|
|
299
|
-
|
|
300
|
-
const Layout: NestedLayoutComponent = ({ children }) => {
|
|
301
|
-
return <div>{children}</div>;
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
Layout.actions = [actionFoo, actionBar];
|
|
305
|
-
|
|
306
|
-
Layout.reducers = [StoreBaz];
|
|
307
|
-
```
|
|
308
|
-
|
|
309
|
-
Actions will be registered as current page component actions and reducers will be registered in global store.
|
|
310
|
-
|
|
311
|
-
#### Adding a nested layout
|
|
312
|
-
|
|
313
|
-
You can add a `nestedLayoutComponent` property to route `config` property and register component in `bundle`.
|
|
314
|
-
This layout will be rendered when you go to the corresponding route.
|
|
315
|
-
|
|
316
|
-
```tsx
|
|
317
|
-
createBundle({
|
|
318
|
-
name: 'common-bundle',
|
|
319
|
-
components: {
|
|
320
|
-
myNestedLayout: NestedLayout,
|
|
321
|
-
},
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
const route = {
|
|
325
|
-
name: 'main',
|
|
326
|
-
path: '/',
|
|
327
|
-
config: {
|
|
328
|
-
nestedLayoutComponent: 'myNestedLayout',
|
|
329
|
-
},
|
|
330
|
-
};
|
|
331
|
-
```
|
|
332
|
-
|
|
333
|
-
Also, this feature available for [File-System Pages and Routes](features/routing/file-system-pages.md)
|
|
148
|
+
[Actual documentation](03-features/04-layouts.md)
|
|
334
149
|
|
|
335
150
|
## How to
|
|
336
151
|
|
package/lib/browser.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate } from 'tslib';
|
|
2
2
|
import { Module, provide, commandLineListTokens, DI_TOKEN } from '@tramvai/core';
|
|
3
3
|
import { COMBINE_REDUCERS, STORE_TOKEN, LOGGER_TOKEN, CONTEXT_TOKEN } from '@tramvai/tokens-common';
|
|
4
|
-
import { DEFAULT_LAYOUT_COMPONENT, LAYOUT_OPTIONS, DEFAULT_FOOTER_COMPONENT, DEFAULT_HEADER_COMPONENT, TRAMVAI_RENDER_MODE, RESOURCES_REGISTRY, CUSTOM_RENDER, EXTEND_RENDER, RENDERER_CALLBACK, USE_REACT_STRICT_MODE, RENDER_MODE } from '@tramvai/tokens-render';
|
|
4
|
+
import { DEFAULT_LAYOUT_COMPONENT, LAYOUT_OPTIONS, DEFAULT_FOOTER_COMPONENT, DEFAULT_HEADER_COMPONENT, DEFAULT_ERROR_BOUNDARY_COMPONENT, TRAMVAI_RENDER_MODE, RESOURCES_REGISTRY, CUSTOM_RENDER, EXTEND_RENDER, RENDERER_CALLBACK, USE_REACT_STRICT_MODE, RENDER_MODE } from '@tramvai/tokens-render';
|
|
5
5
|
export * from '@tramvai/tokens-render';
|
|
6
6
|
import { PAGE_SERVICE_TOKEN, ROUTER_TOKEN } from '@tramvai/tokens-router';
|
|
7
7
|
import each from '@tinkoff/utils/array/each';
|
|
@@ -213,6 +213,7 @@ LayoutModule = __decorate([
|
|
|
213
213
|
layoutDefault: DEFAULT_LAYOUT_COMPONENT,
|
|
214
214
|
footerDefault: { token: DEFAULT_FOOTER_COMPONENT, optional: true },
|
|
215
215
|
headerDefault: { token: DEFAULT_HEADER_COMPONENT, optional: true },
|
|
216
|
+
errorBoundaryDefault: { token: DEFAULT_ERROR_BOUNDARY_COMPONENT, optional: true },
|
|
216
217
|
},
|
|
217
218
|
},
|
|
218
219
|
],
|
package/lib/server.es.js
CHANGED
|
@@ -5,7 +5,7 @@ import { Module, provide, commandLineListTokens, DI_TOKEN } from '@tramvai/core'
|
|
|
5
5
|
import { COMBINE_REDUCERS, CREATE_CACHE_TOKEN, LOGGER_TOKEN, REQUEST_MANAGER_TOKEN, RESPONSE_MANAGER_TOKEN, CONTEXT_TOKEN } from '@tramvai/tokens-common';
|
|
6
6
|
import { PAGE_SERVICE_TOKEN } from '@tramvai/tokens-router';
|
|
7
7
|
import { ClientHintsModule, USER_AGENT_TOKEN } from '@tramvai/module-client-hints';
|
|
8
|
-
import { ResourceType, ResourceSlot, DEFAULT_LAYOUT_COMPONENT, LAYOUT_OPTIONS, DEFAULT_FOOTER_COMPONENT, DEFAULT_HEADER_COMPONENT, TRAMVAI_RENDER_MODE, RESOURCES_REGISTRY, RESOURCE_INLINE_OPTIONS, RENDER_SLOTS, POLYFILL_CONDITION, HTML_ATTRS, MODERN_SATISFIES_TOKEN, RENDER_FLOW_AFTER_TOKEN, CUSTOM_RENDER, EXTEND_RENDER, REACT_SERVER_RENDER_MODE } from '@tramvai/tokens-render';
|
|
8
|
+
import { ResourceType, ResourceSlot, DEFAULT_LAYOUT_COMPONENT, LAYOUT_OPTIONS, DEFAULT_FOOTER_COMPONENT, DEFAULT_HEADER_COMPONENT, DEFAULT_ERROR_BOUNDARY_COMPONENT, TRAMVAI_RENDER_MODE, RESOURCES_REGISTRY, RESOURCE_INLINE_OPTIONS, RENDER_SLOTS, POLYFILL_CONDITION, HTML_ATTRS, MODERN_SATISFIES_TOKEN, RENDER_FLOW_AFTER_TOKEN, CUSTOM_RENDER, EXTEND_RENDER, REACT_SERVER_RENDER_MODE } from '@tramvai/tokens-render';
|
|
9
9
|
export * from '@tramvai/tokens-render';
|
|
10
10
|
import { createToken, Scope } from '@tinkoff/dippy';
|
|
11
11
|
import { WEB_FASTIFY_APP_BEFORE_ERROR_TOKEN } from '@tramvai/tokens-server-private';
|
|
@@ -842,6 +842,7 @@ LayoutModule = __decorate([
|
|
|
842
842
|
layoutDefault: DEFAULT_LAYOUT_COMPONENT,
|
|
843
843
|
footerDefault: { token: DEFAULT_FOOTER_COMPONENT, optional: true },
|
|
844
844
|
headerDefault: { token: DEFAULT_HEADER_COMPONENT, optional: true },
|
|
845
|
+
errorBoundaryDefault: { token: DEFAULT_ERROR_BOUNDARY_COMPONENT, optional: true },
|
|
845
846
|
},
|
|
846
847
|
},
|
|
847
848
|
],
|
package/lib/server.js
CHANGED
|
@@ -878,6 +878,7 @@ LayoutModule = tslib.__decorate([
|
|
|
878
878
|
layoutDefault: tokensRender.DEFAULT_LAYOUT_COMPONENT,
|
|
879
879
|
footerDefault: { token: tokensRender.DEFAULT_FOOTER_COMPONENT, optional: true },
|
|
880
880
|
headerDefault: { token: tokensRender.DEFAULT_HEADER_COMPONENT, optional: true },
|
|
881
|
+
errorBoundaryDefault: { token: tokensRender.DEFAULT_ERROR_BOUNDARY_COMPONENT, optional: true },
|
|
881
882
|
},
|
|
882
883
|
},
|
|
883
884
|
],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/module-render",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.61.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"browser": "lib/browser.js",
|
|
6
6
|
"main": "lib/server.js",
|
|
@@ -24,15 +24,15 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@loadable/server": "^5.15.0",
|
|
26
26
|
"@tinkoff/htmlpagebuilder": "0.5.5",
|
|
27
|
-
"@tinkoff/layout-factory": "0.3.
|
|
27
|
+
"@tinkoff/layout-factory": "0.3.6",
|
|
28
28
|
"@tinkoff/url": "0.8.4",
|
|
29
|
-
"@tinkoff/user-agent": "0.4.
|
|
30
|
-
"@tramvai/module-client-hints": "2.
|
|
31
|
-
"@tramvai/module-router": "2.
|
|
32
|
-
"@tramvai/react": "2.
|
|
29
|
+
"@tinkoff/user-agent": "0.4.148",
|
|
30
|
+
"@tramvai/module-client-hints": "2.61.1",
|
|
31
|
+
"@tramvai/module-router": "2.61.1",
|
|
32
|
+
"@tramvai/react": "2.61.1",
|
|
33
33
|
"@tramvai/safe-strings": "0.5.6",
|
|
34
|
-
"@tramvai/tokens-render": "2.
|
|
35
|
-
"@tramvai/experiments": "2.
|
|
34
|
+
"@tramvai/tokens-render": "2.61.1",
|
|
35
|
+
"@tramvai/experiments": "2.61.1",
|
|
36
36
|
"@types/loadable__server": "^5.12.6",
|
|
37
37
|
"node-fetch": "^2.6.1"
|
|
38
38
|
},
|
|
@@ -40,14 +40,14 @@
|
|
|
40
40
|
"@tinkoff/dippy": "0.8.11",
|
|
41
41
|
"@tinkoff/utils": "^2.1.2",
|
|
42
42
|
"@tinkoff/react-hooks": "0.1.4",
|
|
43
|
-
"@tramvai/cli": "2.
|
|
44
|
-
"@tramvai/core": "2.
|
|
45
|
-
"@tramvai/module-common": "2.
|
|
46
|
-
"@tramvai/state": "2.
|
|
47
|
-
"@tramvai/test-helpers": "2.
|
|
48
|
-
"@tramvai/tokens-common": "2.
|
|
49
|
-
"@tramvai/tokens-router": "2.
|
|
50
|
-
"@tramvai/tokens-server-private": "2.
|
|
43
|
+
"@tramvai/cli": "2.61.1",
|
|
44
|
+
"@tramvai/core": "2.61.1",
|
|
45
|
+
"@tramvai/module-common": "2.61.1",
|
|
46
|
+
"@tramvai/state": "2.61.1",
|
|
47
|
+
"@tramvai/test-helpers": "2.61.1",
|
|
48
|
+
"@tramvai/tokens-common": "2.61.1",
|
|
49
|
+
"@tramvai/tokens-router": "2.61.1",
|
|
50
|
+
"@tramvai/tokens-server-private": "2.61.1",
|
|
51
51
|
"express": "^4.17.1",
|
|
52
52
|
"prop-types": "^15.6.2",
|
|
53
53
|
"react": ">=16.14.0",
|