@matreshka/bff 0.34.0 → 0.35.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.
@@ -1,4 +1,5 @@
1
1
  import { ServerComponentClass } from "@matreshka/client-bff-protocol/enums/server-component-class";
2
+ import type { ComponentResizePayload } from "@matreshka/client-bff-protocol/messages/client-to-bff/components/component-resize-message";
2
3
  import type { ComponentScrollPayload } from "@matreshka/client-bff-protocol/messages/client-to-bff/components/component-scroll-message";
3
4
  import type { PageConfig } from "@matreshka/client-bff-protocol/types/page-config";
4
5
  import { Componentable, ComponentTreeNode, MixedWithCallbacksArray, Pageable } from "../core";
@@ -28,7 +29,7 @@ type DefaultInitConfigType = PageInitConfig<Page>;
28
29
  */
29
30
  export declare abstract class Page<InitConfigType extends PageInitConfig<any> = DefaultInitConfigType, PropertiesType extends PageProperties = PageProperties> extends EntryComponent<InitConfigType, PropertiesType, PageConfig> implements Pageable {
30
31
  constructor();
31
- /** Добавляет `scroll` к стандартным enter/leave (см. {@link EntryComponent.entryInteractions}). */
32
+ /** Добавляет `scroll` и `resize` к стандартным enter/leave (см. {@link EntryComponent.entryInteractions}). */
32
33
  protected entryInteractions(): ReturnType<EntryComponent["entryInteractions"]>;
33
34
  /**
34
35
  * Возвращает HTTP-статус страницы.
@@ -61,10 +62,15 @@ export declare abstract class Page<InitConfigType extends PageInitConfig<any> =
61
62
  */
62
63
  protected overlays(): Overlay[];
63
64
  /**
64
- * Обработчики прокрутки корня страницы (хост `app-page`), с троттлингом на клиенте.
65
+ * Обработчики прокрутки корня страницы (`window`), с троттлингом на клиенте.
65
66
  * Переопредели в наследнике для дозагрузки списков и т.п.
66
67
  */
67
68
  protected onScroll(): ServerComponentAction<Page, ComponentScrollPayload> | ServerComponentAction<Page, ComponentScrollPayload>[] | undefined;
69
+ /**
70
+ * Обработчики изменения размера корня страницы (`ResizeObserver` на `documentElement`).
71
+ * Payload — тот же снимок оси, что у {@link onScroll}.
72
+ */
73
+ protected onResize(): ServerComponentAction<Page, ComponentResizePayload> | ServerComponentAction<Page, ComponentResizePayload>[] | undefined;
68
74
  /**
69
75
  * Инициализирует свойства страницы.
70
76
  *
@@ -15,9 +15,13 @@ class Page extends entry_component_1.EntryComponent {
15
15
  // @ts-expect-error Page задаёт content в boot(), а не через конфиг конструктора Component.
16
16
  super({});
17
17
  }
18
- /** Добавляет `scroll` к стандартным enter/leave (см. {@link EntryComponent.entryInteractions}). */
18
+ /** Добавляет `scroll` и `resize` к стандартным enter/leave (см. {@link EntryComponent.entryInteractions}). */
19
19
  entryInteractions() {
20
- return { ...super.entryInteractions(), scroll: this.onScroll() };
20
+ return {
21
+ ...super.entryInteractions(),
22
+ scroll: this.onScroll(),
23
+ resize: this.onResize(),
24
+ };
21
25
  }
22
26
  /**
23
27
  * Возвращает HTTP-статус страницы.
@@ -42,12 +46,19 @@ class Page extends entry_component_1.EntryComponent {
42
46
  return [];
43
47
  }
44
48
  /**
45
- * Обработчики прокрутки корня страницы (хост `app-page`), с троттлингом на клиенте.
49
+ * Обработчики прокрутки корня страницы (`window`), с троттлингом на клиенте.
46
50
  * Переопредели в наследнике для дозагрузки списков и т.п.
47
51
  */
48
52
  onScroll() {
49
53
  return undefined;
50
54
  }
55
+ /**
56
+ * Обработчики изменения размера корня страницы (`ResizeObserver` на `documentElement`).
57
+ * Payload — тот же снимок оси, что у {@link onScroll}.
58
+ */
59
+ onResize() {
60
+ return undefined;
61
+ }
51
62
  /**
52
63
  * Инициализирует свойства страницы.
53
64
  *
@@ -6,6 +6,7 @@ import { ScrollToPosition } from "@matreshka/client-bff-protocol/enums/scroll-to
6
6
  import { ServerComponentClass } from "@matreshka/client-bff-protocol/enums/server-component-class";
7
7
  import { StackCrossAxisAlign, StackMainAxisAlign } from "@matreshka/client-bff-protocol/enums/stack-align";
8
8
  import { StackDirection } from "@matreshka/client-bff-protocol/enums/stack-direction";
9
+ import type { ComponentResizePayload } from "@matreshka/client-bff-protocol/messages/client-to-bff/components/component-resize-message";
9
10
  import type { ComponentScrollPayload } from "@matreshka/client-bff-protocol/messages/client-to-bff/components/component-scroll-message";
10
11
  import { type FlexItemSpec } from "@matreshka/client-bff-protocol/types/flex-item";
11
12
  import type { PaddingPx } from "@matreshka/client-bff-protocol/types/padding-px";
@@ -22,6 +23,7 @@ export { SafeAreaSide } from "@matreshka/client-bff-protocol/enums/safe-area-sid
22
23
  export { ScrollToPosition } from "@matreshka/client-bff-protocol/enums/scroll-to-position";
23
24
  export { StackCrossAxisAlign, StackMainAxisAlign, } from "@matreshka/client-bff-protocol/enums/stack-align";
24
25
  export { StackDirection } from "@matreshka/client-bff-protocol/enums/stack-direction";
26
+ export type { ComponentResizePayload } from "@matreshka/client-bff-protocol/messages/client-to-bff/components/component-resize-message";
25
27
  export type { ComponentScrollPayload } from "@matreshka/client-bff-protocol/messages/client-to-bff/components/component-scroll-message";
26
28
  export type { DimensionalValue } from "@matreshka/client-bff-protocol/types/dimensional-value";
27
29
  export type { FlexItemSpec } from "@matreshka/client-bff-protocol/types/flex-item";
@@ -83,6 +85,7 @@ export type StackProperties = {
83
85
  * @property onClick Обработчики клика по контейнеру.
84
86
  * @property onKeyDown Обработчики нажатия клавиши, когда фокус находится на элементе.
85
87
  * @property onScroll Обработчики прокрутки по главной оси (`offset`, `viewportSize`, `contentSize`), с троттлингом на клиенте.
88
+ * @property onResize Обработчики изменения размера контейнера. Payload тот же, что у `onScroll`.
86
89
  * @property overlays Наложения поверх контейнера.
87
90
  * @property surface Фон контейнера (`--background-color`).
88
91
  * @property outline Стиль внешней границы контейнера.
@@ -97,6 +100,7 @@ export type StackInitConfig<ComponentType extends Componentable = Stack, Propert
97
100
  key: string;
98
101
  }>[];
99
102
  onScroll?: ServerComponentAction<ComponentType, ComponentScrollPayload> | ServerComponentAction<ComponentType, ComponentScrollPayload>[];
103
+ onResize?: ServerComponentAction<ComponentType, ComponentResizePayload> | ServerComponentAction<ComponentType, ComponentResizePayload>[];
100
104
  align?: {
101
105
  main?: StackMainAxisAlign;
102
106
  cross?: StackCrossAxisAlign;
@@ -57,6 +57,9 @@ class Stack extends component_1.Component {
57
57
  if (config.onScroll) {
58
58
  this.bindActions("scroll", config.onScroll);
59
59
  }
60
+ if (config.onResize) {
61
+ this.bindActions("resize", config.onResize);
62
+ }
60
63
  }
61
64
  /**
62
65
  * Возвращает флаг, указывающий, что компонент является самостоятельным.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matreshka/bff",
3
- "version": "0.34.0",
3
+ "version": "0.35.0",
4
4
  "description": "Matreshka BFF: server-driven UI runtime — routing, pages, context, component DSL, and platform APIs",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",