@matreshka/bff 0.9.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.
Files changed (275) hide show
  1. package/LICENSE +32 -0
  2. package/README.md +35 -0
  3. package/dist/components/actions/server-action.d.ts +30 -0
  4. package/dist/components/actions/server-action.js +23 -0
  5. package/dist/components/aliases/button.d.ts +17 -0
  6. package/dist/components/aliases/button.js +54 -0
  7. package/dist/components/aliases/column.d.ts +11 -0
  8. package/dist/components/aliases/column.js +31 -0
  9. package/dist/components/aliases/row.d.ts +11 -0
  10. package/dist/components/aliases/row.js +31 -0
  11. package/dist/components/aliases/surface.d.ts +11 -0
  12. package/dist/components/aliases/surface.js +30 -0
  13. package/dist/components/app.d.ts +5 -0
  14. package/dist/components/app.js +12 -0
  15. package/dist/components/board.d.ts +58 -0
  16. package/dist/components/board.js +152 -0
  17. package/dist/components/boot.d.ts +2 -0
  18. package/dist/components/boot.js +39 -0
  19. package/dist/components/camera.d.ts +77 -0
  20. package/dist/components/camera.js +116 -0
  21. package/dist/components/charts/bar-chart.d.ts +14 -0
  22. package/dist/components/charts/bar-chart.js +27 -0
  23. package/dist/components/charts/chart.d.ts +69 -0
  24. package/dist/components/charts/chart.js +42 -0
  25. package/dist/components/charts/doughnut-chart.d.ts +14 -0
  26. package/dist/components/charts/doughnut-chart.js +27 -0
  27. package/dist/components/charts/line-chart.d.ts +14 -0
  28. package/dist/components/charts/line-chart.js +27 -0
  29. package/dist/components/charts/pie-chart.d.ts +14 -0
  30. package/dist/components/charts/pie-chart.js +27 -0
  31. package/dist/components/charts/polar-area-chart.d.ts +14 -0
  32. package/dist/components/charts/polar-area-chart.js +27 -0
  33. package/dist/components/charts/radar-chart.d.ts +14 -0
  34. package/dist/components/charts/radar-chart.js +27 -0
  35. package/dist/components/component.d.ts +159 -0
  36. package/dist/components/component.js +380 -0
  37. package/dist/components/container.d.ts +48 -0
  38. package/dist/components/container.js +80 -0
  39. package/dist/components/dialog.d.ts +83 -0
  40. package/dist/components/dialog.js +120 -0
  41. package/dist/components/entry-component.d.ts +34 -0
  42. package/dist/components/entry-component.js +74 -0
  43. package/dist/components/enum/password-input-kind.d.ts +1 -0
  44. package/dist/components/enum/password-input-kind.js +5 -0
  45. package/dist/components/enum/popover-position-area.d.ts +1 -0
  46. package/dist/components/enum/popover-position-area.js +5 -0
  47. package/dist/components/enum/text-input-kind.d.ts +1 -0
  48. package/dist/components/enum/text-input-kind.js +5 -0
  49. package/dist/components/enum/textarea-resize.d.ts +1 -0
  50. package/dist/components/enum/textarea-resize.js +5 -0
  51. package/dist/components/file-upload-area.d.ts +79 -0
  52. package/dist/components/file-upload-area.js +138 -0
  53. package/dist/components/for-each.d.ts +188 -0
  54. package/dist/components/for-each.js +362 -0
  55. package/dist/components/form.d.ts +62 -0
  56. package/dist/components/form.js +92 -0
  57. package/dist/components/grid.d.ts +80 -0
  58. package/dist/components/grid.js +79 -0
  59. package/dist/components/index.d.ts +55 -0
  60. package/dist/components/index.js +76 -0
  61. package/dist/components/inputs/input-component.d.ts +37 -0
  62. package/dist/components/inputs/input-component.js +30 -0
  63. package/dist/components/inputs/number-input.d.ts +45 -0
  64. package/dist/components/inputs/number-input.js +43 -0
  65. package/dist/components/inputs/password-input.d.ts +28 -0
  66. package/dist/components/inputs/password-input.js +42 -0
  67. package/dist/components/inputs/text-editor.d.ts +91 -0
  68. package/dist/components/inputs/text-editor.js +282 -0
  69. package/dist/components/inputs/text-input.d.ts +48 -0
  70. package/dist/components/inputs/text-input.js +40 -0
  71. package/dist/components/inputs/textarea.d.ts +36 -0
  72. package/dist/components/inputs/textarea.js +42 -0
  73. package/dist/components/item-list/flatten-nested-items.d.ts +11 -0
  74. package/dist/components/item-list/flatten-nested-items.js +100 -0
  75. package/dist/components/item-list/index.d.ts +5 -0
  76. package/dist/components/item-list/index.js +21 -0
  77. package/dist/components/item-list/item-list-host.d.ts +10 -0
  78. package/dist/components/item-list/item-list-host.js +2 -0
  79. package/dist/components/item-list/item-list.d.ts +68 -0
  80. package/dist/components/item-list/item-list.js +206 -0
  81. package/dist/components/item-list/list-from-ref-context.d.ts +11 -0
  82. package/dist/components/item-list/list-from-ref-context.js +27 -0
  83. package/dist/components/item-list/nested-items-host-support.d.ts +36 -0
  84. package/dist/components/item-list/nested-items-host-support.js +109 -0
  85. package/dist/components/item-list/types.d.ts +40 -0
  86. package/dist/components/item-list/types.js +13 -0
  87. package/dist/components/line.d.ts +43 -0
  88. package/dist/components/line.js +35 -0
  89. package/dist/components/map.d.ts +83 -0
  90. package/dist/components/map.js +146 -0
  91. package/dist/components/outputs/currency.d.ts +63 -0
  92. package/dist/components/outputs/currency.js +42 -0
  93. package/dist/components/outputs/datetime.d.ts +69 -0
  94. package/dist/components/outputs/datetime.js +49 -0
  95. package/dist/components/outputs/icon.d.ts +43 -0
  96. package/dist/components/outputs/icon.js +38 -0
  97. package/dist/components/outputs/iframe.d.ts +48 -0
  98. package/dist/components/outputs/iframe.js +44 -0
  99. package/dist/components/outputs/image.d.ts +73 -0
  100. package/dist/components/outputs/image.js +63 -0
  101. package/dist/components/outputs/number.d.ts +39 -0
  102. package/dist/components/outputs/number.js +47 -0
  103. package/dist/components/outputs/output-component.d.ts +58 -0
  104. package/dist/components/outputs/output-component.js +50 -0
  105. package/dist/components/outputs/progress-bar.d.ts +33 -0
  106. package/dist/components/outputs/progress-bar.js +42 -0
  107. package/dist/components/outputs/progress-spinner.d.ts +37 -0
  108. package/dist/components/outputs/progress-spinner.js +43 -0
  109. package/dist/components/outputs/qr-code.d.ts +28 -0
  110. package/dist/components/outputs/qr-code.js +40 -0
  111. package/dist/components/outputs/text.d.ts +57 -0
  112. package/dist/components/outputs/text.js +78 -0
  113. package/dist/components/outputs/vector.d.ts +47 -0
  114. package/dist/components/outputs/vector.js +53 -0
  115. package/dist/components/page.d.ts +96 -0
  116. package/dist/components/page.js +127 -0
  117. package/dist/components/popover.d.ts +63 -0
  118. package/dist/components/popover.js +96 -0
  119. package/dist/components/stack.d.ts +158 -0
  120. package/dist/components/stack.js +146 -0
  121. package/dist/components/types/component-sequence.d.ts +3 -0
  122. package/dist/components/types/component-sequence.js +2 -0
  123. package/dist/components/types/container-overlay.d.ts +3 -0
  124. package/dist/components/types/container-overlay.js +2 -0
  125. package/dist/components/utils/component-factory-shared.d.ts +4 -0
  126. package/dist/components/utils/component-factory-shared.js +12 -0
  127. package/dist/core/actions/action.d.ts +35 -0
  128. package/dist/core/actions/action.js +45 -0
  129. package/dist/core/actions/animate-component.d.ts +58 -0
  130. package/dist/core/actions/animate-component.js +57 -0
  131. package/dist/core/actions/local-action.d.ts +8 -0
  132. package/dist/core/actions/local-action.js +12 -0
  133. package/dist/core/actions/set-context-value.d.ts +18 -0
  134. package/dist/core/actions/set-context-value.js +32 -0
  135. package/dist/core/actions/set-context-values.d.ts +34 -0
  136. package/dist/core/actions/set-context-values.js +30 -0
  137. package/dist/core/actions/toggle-context-value.d.ts +21 -0
  138. package/dist/core/actions/toggle-context-value.js +30 -0
  139. package/dist/core/actions/write-text-to-clipboard.d.ts +30 -0
  140. package/dist/core/actions/write-text-to-clipboard.js +44 -0
  141. package/dist/core/boot.d.ts +2 -0
  142. package/dist/core/boot.js +8 -0
  143. package/dist/core/client-context.d.ts +7 -0
  144. package/dist/core/client-context.js +20 -0
  145. package/dist/core/client.d.ts +133 -0
  146. package/dist/core/client.js +292 -0
  147. package/dist/core/conditions/condition-group.d.ts +14 -0
  148. package/dist/core/conditions/condition-group.js +30 -0
  149. package/dist/core/conditions/condition-operand.d.ts +27 -0
  150. package/dist/core/conditions/condition-operand.js +15 -0
  151. package/dist/core/conditions/condition.d.ts +27 -0
  152. package/dist/core/conditions/condition.js +35 -0
  153. package/dist/core/conditions/context-array-includes.d.ts +32 -0
  154. package/dist/core/conditions/context-array-includes.js +52 -0
  155. package/dist/core/conditions/context-array-length.d.ts +86 -0
  156. package/dist/core/conditions/context-array-length.js +155 -0
  157. package/dist/core/conditions/context-value-defined.d.ts +12 -0
  158. package/dist/core/conditions/context-value-defined.js +21 -0
  159. package/dist/core/conditions/context-value-equal.d.ts +14 -0
  160. package/dist/core/conditions/context-value-equal.js +26 -0
  161. package/dist/core/conditions/context-value-in.d.ts +17 -0
  162. package/dist/core/conditions/context-value-in.js +26 -0
  163. package/dist/core/conditions/context-value-not-equal.d.ts +14 -0
  164. package/dist/core/conditions/context-value-not-equal.js +26 -0
  165. package/dist/core/conditions/context-value-undefined.d.ts +12 -0
  166. package/dist/core/conditions/context-value-undefined.js +21 -0
  167. package/dist/core/conditions/desktop-device.d.ts +11 -0
  168. package/dist/core/conditions/desktop-device.js +21 -0
  169. package/dist/core/conditions/groups.d.ts +71 -0
  170. package/dist/core/conditions/groups.js +74 -0
  171. package/dist/core/conditions/index.d.ts +17 -0
  172. package/dist/core/conditions/index.js +33 -0
  173. package/dist/core/conditions/mobile-device.d.ts +11 -0
  174. package/dist/core/conditions/mobile-device.js +21 -0
  175. package/dist/core/conditions/not-desktop-device.d.ts +11 -0
  176. package/dist/core/conditions/not-desktop-device.js +21 -0
  177. package/dist/core/conditions/not-mobile-device.d.ts +11 -0
  178. package/dist/core/conditions/not-mobile-device.js +21 -0
  179. package/dist/core/conditions/not-tablet-device.d.ts +11 -0
  180. package/dist/core/conditions/not-tablet-device.js +21 -0
  181. package/dist/core/conditions/tablet-device.d.ts +11 -0
  182. package/dist/core/conditions/tablet-device.js +21 -0
  183. package/dist/core/context/context-ref.d.ts +48 -0
  184. package/dist/core/context/context-ref.js +58 -0
  185. package/dist/core/context/context.d.ts +121 -0
  186. package/dist/core/context/context.js +353 -0
  187. package/dist/core/entry-context.d.ts +14 -0
  188. package/dist/core/entry-context.js +31 -0
  189. package/dist/core/gateway-connection.d.ts +29 -0
  190. package/dist/core/gateway-connection.js +146 -0
  191. package/dist/core/index.d.ts +30 -0
  192. package/dist/core/index.js +46 -0
  193. package/dist/core/matreshka.d.ts +61 -0
  194. package/dist/core/matreshka.js +186 -0
  195. package/dist/core/router.d.ts +38 -0
  196. package/dist/core/router.js +116 -0
  197. package/dist/core/types/client-settings.d.ts +31 -0
  198. package/dist/core/types/client-settings.js +2 -0
  199. package/dist/core/types/component-instance.d.ts +25 -0
  200. package/dist/core/types/component-instance.js +42 -0
  201. package/dist/core/types/component-tree-node.d.ts +11 -0
  202. package/dist/core/types/component-tree-node.js +18 -0
  203. package/dist/core/types/componentable.d.ts +21 -0
  204. package/dist/core/types/componentable.js +2 -0
  205. package/dist/core/types/context-ref-primitive-value.d.ts +5 -0
  206. package/dist/core/types/context-ref-primitive-value.js +2 -0
  207. package/dist/core/types/message.d.ts +15 -0
  208. package/dist/core/types/message.js +2 -0
  209. package/dist/core/types/mixed-with-callbacks-array.d.ts +9 -0
  210. package/dist/core/types/mixed-with-callbacks-array.js +2 -0
  211. package/dist/core/types/native-picker-context-ref.d.ts +7 -0
  212. package/dist/core/types/native-picker-context-ref.js +2 -0
  213. package/dist/core/types/pageable.d.ts +15 -0
  214. package/dist/core/types/pageable.js +2 -0
  215. package/dist/core/types/standalone-component.d.ts +9 -0
  216. package/dist/core/types/standalone-component.js +2 -0
  217. package/dist/core/types/status-code.d.ts +319 -0
  218. package/dist/core/types/status-code.js +322 -0
  219. package/dist/core/utils/calculate-components.d.ts +13 -0
  220. package/dist/core/utils/calculate-components.js +40 -0
  221. package/dist/core/utils/color-token-id.d.ts +11 -0
  222. package/dist/core/utils/color-token-id.js +24 -0
  223. package/dist/core/utils/deep-pick.d.ts +2 -0
  224. package/dist/core/utils/deep-pick.js +54 -0
  225. package/dist/core/utils/hex-to-hsl.d.ts +14 -0
  226. package/dist/core/utils/hex-to-hsl.js +49 -0
  227. package/dist/core/utils/incoming-message-observer.d.ts +9 -0
  228. package/dist/core/utils/incoming-message-observer.js +23 -0
  229. package/dist/core/utils/merge-deep.d.ts +8 -0
  230. package/dist/core/utils/merge-deep.js +39 -0
  231. package/dist/core/utils/objects-diff.d.ts +13 -0
  232. package/dist/core/utils/objects-diff.js +56 -0
  233. package/dist/core/utils/parse-context-path.d.ts +4 -0
  234. package/dist/core/utils/parse-context-path.js +16 -0
  235. package/dist/core/utils/replace-context-keys.d.ts +12 -0
  236. package/dist/core/utils/replace-context-keys.js +90 -0
  237. package/dist/core/utils/serialize-component-tree.d.ts +9 -0
  238. package/dist/core/utils/serialize-component-tree.js +24 -0
  239. package/dist/core/utils/set-object-property.d.ts +2 -0
  240. package/dist/core/utils/set-object-property.js +29 -0
  241. package/dist/core/utils/track-created-instances.d.ts +10 -0
  242. package/dist/core/utils/track-created-instances.js +18 -0
  243. package/dist/core/version.d.ts +1 -0
  244. package/dist/core/version.js +21 -0
  245. package/dist/index.d.ts +3 -0
  246. package/dist/index.js +19 -0
  247. package/dist/platforms/android-platform.d.ts +6 -0
  248. package/dist/platforms/android-platform.js +10 -0
  249. package/dist/platforms/browser-platform.d.ts +79 -0
  250. package/dist/platforms/browser-platform.js +143 -0
  251. package/dist/platforms/client-platform.d.ts +6 -0
  252. package/dist/platforms/client-platform.js +10 -0
  253. package/dist/platforms/index.d.ts +12 -0
  254. package/dist/platforms/index.js +28 -0
  255. package/dist/platforms/ios-platform.d.ts +6 -0
  256. package/dist/platforms/ios-platform.js +10 -0
  257. package/dist/platforms/max-mini-app-platform.d.ts +45 -0
  258. package/dist/platforms/max-mini-app-platform.js +87 -0
  259. package/dist/platforms/mobile-platform.d.ts +117 -0
  260. package/dist/platforms/mobile-platform.js +316 -0
  261. package/dist/platforms/platform.d.ts +109 -0
  262. package/dist/platforms/platform.js +224 -0
  263. package/dist/platforms/pwa-platform.d.ts +6 -0
  264. package/dist/platforms/pwa-platform.js +10 -0
  265. package/dist/platforms/server-platform.d.ts +6 -0
  266. package/dist/platforms/server-platform.js +10 -0
  267. package/dist/platforms/telegram-mini-app-platform.d.ts +87 -0
  268. package/dist/platforms/telegram-mini-app-platform.js +166 -0
  269. package/dist/platforms/utils/client-platform.d.ts +4 -0
  270. package/dist/platforms/utils/client-platform.js +38 -0
  271. package/dist/platforms/utils/mobile-ble-services.d.ts +3 -0
  272. package/dist/platforms/utils/mobile-ble-services.js +31 -0
  273. package/dist/platforms/web-platform.d.ts +9 -0
  274. package/dist/platforms/web-platform.js +13 -0
  275. package/package.json +109 -0
@@ -0,0 +1,158 @@
1
+ import { ComponentOutline } from "@matreshka/shared/enums/outline-type";
2
+ import { FlexWrap } from "@matreshka/shared/enums/flex-wrap";
3
+ import { Overflow } from "@matreshka/shared/enums/overflow";
4
+ import { SafeAreaSide } from "@matreshka/shared/enums/safe-area-side";
5
+ import { ServerComponentClass } from "@matreshka/shared/enums/server-component-class";
6
+ import { StackCrossAxisAlign, StackMainAxisAlign } from "@matreshka/shared/enums/stack-align";
7
+ import { StackDirection } from "@matreshka/shared/enums/stack-direction";
8
+ import type { ComponentScrollPayload } from "@matreshka/shared/messages/client-to-bff/components/component-scroll-message";
9
+ import type { PaddingPx } from "@matreshka/shared/types/padding-px";
10
+ import type { RadiusPx } from "@matreshka/shared/types/radius-px";
11
+ import type { StackConfig } from "@matreshka/shared/types/stack-config";
12
+ import { type FlexItemSpec } from "@matreshka/shared/types/flex-item";
13
+ import { Componentable, ComponentInstance, ComponentTreeNode, MixedWithCallbacksArray, StandaloneComponent } from "../core";
14
+ import { Component, ComponentInitConfig, ComponentProperties, ServerComponentAction } from "./component";
15
+ import { Overlay } from "./types/container-overlay";
16
+ export { DimensionalUnit } from "@matreshka/shared/enums/dimensional-unit";
17
+ export { FlexWrap } from "@matreshka/shared/enums/flex-wrap";
18
+ export { Overflow } from "@matreshka/shared/enums/overflow";
19
+ export { SafeAreaSide } from "@matreshka/shared/enums/safe-area-side";
20
+ export { StackCrossAxisAlign, StackMainAxisAlign, } from "@matreshka/shared/enums/stack-align";
21
+ export { StackDirection } from "@matreshka/shared/enums/stack-direction";
22
+ export type { ComponentScrollPayload } from "@matreshka/shared/messages/client-to-bff/components/component-scroll-message";
23
+ export type { DimensionalValue } from "@matreshka/shared/types/dimensional-value";
24
+ export type { FlexItemSpec } from "@matreshka/shared/types/flex-item";
25
+ export type StackProperties = {
26
+ content: ComponentTreeNode[];
27
+ align?: {
28
+ main?: StackMainAxisAlign;
29
+ cross?: StackCrossAxisAlign;
30
+ };
31
+ direction?: StackDirection;
32
+ gap?: number;
33
+ /**
34
+ * Поведение при переполнении содержимого (CSS `overflow`).
35
+ * Если не задано, клиент по умолчанию использует `auto`.
36
+ */
37
+ overflow?: Overflow;
38
+ /**
39
+ * Перенос flex-элементов на новые строки (CSS `flex-wrap`).
40
+ */
41
+ wrap?: FlexWrap;
42
+ /**
43
+ * Поведение flex-item внутри родительского stack: `{ grow }`, `{ basis }`
44
+ * (число > 1 — логические px) или явные `basis` / `grow` / `shrink`.
45
+ */
46
+ flexItem?: FlexItemSpec;
47
+ /**
48
+ * Скругление углов в логических пикселях; на клиенте — в rem.
49
+ */
50
+ radius?: RadiusPx;
51
+ padding?: PaddingPx;
52
+ safeArea?: SafeAreaSide[];
53
+ overlays?: Overlay[];
54
+ surface?: boolean;
55
+ outline?: ComponentOutline[];
56
+ focusWithinStyle?: boolean;
57
+ /**
58
+ * Если true — как у неактивной HTML-кнопки: без активации по клику/клавиатуре и без фокуса с таба.
59
+ * Если не передано — на клиенте обрабатывается как неотключённый контейнер.
60
+ */
61
+ disabled?: boolean;
62
+ } & ComponentProperties;
63
+ /**
64
+ * Конфигурация инициализации для компонента Stack.
65
+ *
66
+ * @property align Выравнивание содержимого по главной и поперечной осям.
67
+ * @property overflow Поведение при переполнении содержимого (CSS `overflow`: `visible`, `hidden`, `clip`, `scroll`, `auto`). Если не задано, клиент по умолчанию использует `auto`.
68
+ * @property wrap Перенос flex-элементов на новые строки (CSS `flex-wrap`: `nowrap`, `wrap`, `wrap-reverse`, `balance` и комбинации с `balance`).
69
+ * @property gap Промежуток между элементами.
70
+ * @property flexItem Поведение flex-item внутри родителя-stack: `{ grow }`, `{ basis }` (число > 1 — `{ value, unit: px }`) или явные поля.
71
+ * @property content Список вложенных компонентов.
72
+ * @property radius Скругление углов (логические px).
73
+ * @property padding Внутренние отступы (логические px).
74
+ * @property safeArea Стороны, для которых клиент добавляет системный safe area к padding.
75
+ * @property onClick Обработчики клика по контейнеру.
76
+ * @property onKeyDown Обработчики нажатия клавиши, когда фокус находится на элементе.
77
+ * @property onScroll Обработчики прокрутки по главной оси (`offset`, `viewportSize`, `contentSize`), с троттлингом на клиенте.
78
+ * @property overlays Наложения поверх контейнера.
79
+ * @property surface Фон контейнера (`--background-color`).
80
+ * @property outline Стиль внешней границы контейнера.
81
+ * @property focusWithinStyle Использовать active-цвета, когда фокус находится на потомках.
82
+ * @property disabled Неинтерактивное состояние (как у HTML button disabled). Без поля — значение по умолчанию задаётся на клиенте.
83
+ */
84
+ export type StackInitConfig<ComponentType extends Componentable = Stack, PropertiesType extends StackProperties = StackProperties> = {
85
+ onClick?: ServerComponentAction<ComponentType> | ServerComponentAction<ComponentType>[];
86
+ onKeyDown?: ServerComponentAction<ComponentType, {
87
+ key: string;
88
+ }> | ServerComponentAction<ComponentType, {
89
+ key: string;
90
+ }>[];
91
+ onScroll?: ServerComponentAction<ComponentType, ComponentScrollPayload> | ServerComponentAction<ComponentType, ComponentScrollPayload>[];
92
+ align?: {
93
+ main?: StackMainAxisAlign;
94
+ cross?: StackCrossAxisAlign;
95
+ };
96
+ direction?: StackDirection;
97
+ gap?: number;
98
+ /**
99
+ * Поведение при переполнении содержимого (CSS `overflow`).
100
+ * Если не задано, клиент по умолчанию использует `auto`.
101
+ */
102
+ overflow?: Overflow;
103
+ /**
104
+ * Перенос flex-элементов на новые строки (CSS `flex-wrap`).
105
+ */
106
+ wrap?: FlexWrap;
107
+ /**
108
+ * Поведение flex-item внутри родительского stack: `{ grow }`, `{ basis }`
109
+ * (число > 1 — логические px) или явные `basis` / `grow` / `shrink`.
110
+ */
111
+ flexItem?: FlexItemSpec;
112
+ radius?: RadiusPx;
113
+ content: MixedWithCallbacksArray<ComponentTreeNode>;
114
+ padding?: PaddingPx;
115
+ safeArea?: SafeAreaSide[];
116
+ overlays?: Overlay[];
117
+ surface?: boolean;
118
+ outline?: ComponentOutline[];
119
+ focusWithinStyle?: boolean;
120
+ disabled?: boolean;
121
+ } & ComponentInitConfig<ComponentType, PropertiesType>;
122
+ type DefaultInitConfigType = StackInitConfig<Stack>;
123
+ type StackContent = DefaultInitConfigType["content"];
124
+ type StackOptions = Omit<DefaultInitConfigType, "content">;
125
+ export declare function stack(content: StackContent): Stack;
126
+ export declare function stack(options: StackOptions, content: StackContent): Stack;
127
+ export declare function stack(config: DefaultInitConfigType): Stack;
128
+ /**
129
+ * Компонент Stack, отображающий вложенные элементы в колонку или строку (`direction`) с возможностью настройки выравнивания, отступов и прокрутки.
130
+ */
131
+ export declare class Stack<InitConfigType extends StackInitConfig<any> = DefaultInitConfigType, PropertiesType extends StackProperties = StackProperties> extends Component<InitConfigType, PropertiesType> implements StandaloneComponent {
132
+ constructor(config: InitConfigType);
133
+ /**
134
+ * Возвращает флаг, указывающий, что компонент является самостоятельным.
135
+ * @returns Всегда true.
136
+ */
137
+ standalone(): true;
138
+ /**
139
+ * Инициализирует свойства компонента на основе конфигурации.
140
+ *
141
+ * @param initValues Конфигурация инициализации.
142
+ * @returns Объект с инициализированными свойствами.
143
+ */
144
+ protected initProperties(initValues: InitConfigType): PropertiesType;
145
+ /**
146
+ * Возвращает уникальный идентификатор класса компонента.
147
+ * @returns Строка `"stack"`.
148
+ */
149
+ protected class(): ServerComponentClass;
150
+ /**
151
+ * Отправляет на клиент команду прокрутки контейнера до указанного значения.
152
+ *
153
+ * `value` интерпретируется на клиенте по направлению контейнера: при `direction: vertical` — `scrollTop`, при `horizontal` — `scrollLeft`.
154
+ */
155
+ scrollTo(value: number, smooth?: boolean, instances?: ComponentInstance[]): this;
156
+ protected serializeRuleOverrides(overrides: Partial<PropertiesType>): Record<string, unknown>;
157
+ serialize(instance?: ComponentInstance<this>): StackConfig;
158
+ }
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Stack = exports.StackDirection = exports.StackMainAxisAlign = exports.StackCrossAxisAlign = exports.SafeAreaSide = exports.Overflow = exports.FlexWrap = exports.DimensionalUnit = void 0;
4
+ exports.stack = stack;
5
+ const server_component_class_1 = require("@matreshka/shared/enums/server-component-class");
6
+ const component_scroll_to_message_1 = require("@matreshka/shared/messages/bff-to-client/components/component-scroll-to-message");
7
+ const flex_item_1 = require("@matreshka/shared/types/flex-item");
8
+ const core_1 = require("../core");
9
+ const component_1 = require("./component");
10
+ var dimensional_unit_1 = require("@matreshka/shared/enums/dimensional-unit");
11
+ Object.defineProperty(exports, "DimensionalUnit", { enumerable: true, get: function () { return dimensional_unit_1.DimensionalUnit; } });
12
+ var flex_wrap_1 = require("@matreshka/shared/enums/flex-wrap");
13
+ Object.defineProperty(exports, "FlexWrap", { enumerable: true, get: function () { return flex_wrap_1.FlexWrap; } });
14
+ var overflow_1 = require("@matreshka/shared/enums/overflow");
15
+ Object.defineProperty(exports, "Overflow", { enumerable: true, get: function () { return overflow_1.Overflow; } });
16
+ var safe_area_side_1 = require("@matreshka/shared/enums/safe-area-side");
17
+ Object.defineProperty(exports, "SafeAreaSide", { enumerable: true, get: function () { return safe_area_side_1.SafeAreaSide; } });
18
+ var stack_align_1 = require("@matreshka/shared/enums/stack-align");
19
+ Object.defineProperty(exports, "StackCrossAxisAlign", { enumerable: true, get: function () { return stack_align_1.StackCrossAxisAlign; } });
20
+ Object.defineProperty(exports, "StackMainAxisAlign", { enumerable: true, get: function () { return stack_align_1.StackMainAxisAlign; } });
21
+ var stack_direction_1 = require("@matreshka/shared/enums/stack-direction");
22
+ Object.defineProperty(exports, "StackDirection", { enumerable: true, get: function () { return stack_direction_1.StackDirection; } });
23
+ function stack(arg0, arg1) {
24
+ if (arg1 !== undefined) {
25
+ return new Stack({
26
+ ...arg0,
27
+ content: arg1,
28
+ });
29
+ }
30
+ const single = arg0;
31
+ if (typeof single === "object" &&
32
+ single !== null &&
33
+ !Array.isArray(single) &&
34
+ "content" in single) {
35
+ return new Stack(single);
36
+ }
37
+ return new Stack({ content: single });
38
+ }
39
+ /**
40
+ * Компонент Stack, отображающий вложенные элементы в колонку или строку (`direction`) с возможностью настройки выравнивания, отступов и прокрутки.
41
+ */
42
+ class Stack extends component_1.Component {
43
+ constructor(config) {
44
+ super(config);
45
+ if (config.onClick) {
46
+ this.bindActions("click", config.onClick);
47
+ }
48
+ if (config.onKeyDown) {
49
+ this.bindActions("keydown", config.onKeyDown);
50
+ }
51
+ if (config.onScroll) {
52
+ this.bindActions("scroll", config.onScroll);
53
+ }
54
+ }
55
+ /**
56
+ * Возвращает флаг, указывающий, что компонент является самостоятельным.
57
+ * @returns Всегда true.
58
+ */
59
+ standalone() {
60
+ return true;
61
+ }
62
+ /**
63
+ * Инициализирует свойства компонента на основе конфигурации.
64
+ *
65
+ * @param initValues Конфигурация инициализации.
66
+ * @returns Объект с инициализированными свойствами.
67
+ */
68
+ initProperties(initValues) {
69
+ return {
70
+ ...super.initProperties(initValues),
71
+ direction: initValues.direction,
72
+ align: initValues.align,
73
+ gap: initValues.gap,
74
+ overflow: initValues.overflow,
75
+ wrap: initValues.wrap,
76
+ flexItem: (0, flex_item_1.normalizeFlexItem)(initValues.flexItem),
77
+ radius: initValues.radius,
78
+ content: (0, core_1.calculateComponents)(initValues.content),
79
+ padding: initValues.padding,
80
+ safeArea: initValues.safeArea,
81
+ overlays: initValues.overlays,
82
+ surface: initValues.surface,
83
+ outline: initValues.outline,
84
+ focusWithinStyle: initValues.focusWithinStyle,
85
+ disabled: initValues.disabled,
86
+ };
87
+ }
88
+ /**
89
+ * Возвращает уникальный идентификатор класса компонента.
90
+ * @returns Строка `"stack"`.
91
+ */
92
+ class() {
93
+ return server_component_class_1.ServerComponentClass.Stack;
94
+ }
95
+ /**
96
+ * Отправляет на клиент команду прокрутки контейнера до указанного значения.
97
+ *
98
+ * `value` интерпретируется на клиенте по направлению контейнера: при `direction: vertical` — `scrollTop`, при `horizontal` — `scrollLeft`.
99
+ */
100
+ scrollTo(value, smooth = false, instances) {
101
+ if (instances) {
102
+ instances
103
+ .filter((instance) => instance.client)
104
+ .forEach((instance) => {
105
+ instance.client.outcomingMessage$.next(new component_scroll_to_message_1.ComponentScrollToMessage(instance.id, {
106
+ value,
107
+ smooth,
108
+ }));
109
+ });
110
+ }
111
+ else {
112
+ this.broadcast(new component_scroll_to_message_1.ComponentScrollToMessage(this.id, {
113
+ value,
114
+ smooth,
115
+ }));
116
+ }
117
+ return this;
118
+ }
119
+ serializeRuleOverrides(overrides) {
120
+ const out = { ...overrides };
121
+ if (overrides.content !== undefined) {
122
+ out.content = (0, core_1.serializeComponentList)(overrides.content);
123
+ }
124
+ if (overrides.overlays !== undefined) {
125
+ out.overlays = (0, core_1.serializeOverlays)(overrides.overlays);
126
+ }
127
+ if (overrides.flexItem !== undefined) {
128
+ out.flexItem = (0, flex_item_1.normalizeFlexItem)(overrides.flexItem);
129
+ }
130
+ return out;
131
+ }
132
+ serialize(instance) {
133
+ const result = super.serialize(instance);
134
+ const p = this.properties;
135
+ return {
136
+ ...result,
137
+ class: server_component_class_1.ServerComponentClass.Stack,
138
+ properties: {
139
+ ...p,
140
+ content: (0, core_1.serializeComponentList)(p.content),
141
+ overlays: p.overlays ? (0, core_1.serializeOverlays)(p.overlays) : [],
142
+ },
143
+ };
144
+ }
145
+ }
146
+ exports.Stack = Stack;
@@ -0,0 +1,3 @@
1
+ import { ForEach, ForEachDataRef } from "@matreshka/bff/components/for-each";
2
+ import type { ComponentTreeNode } from "@matreshka/bff/core";
3
+ export type ComponentSequence<DataType, T extends ComponentTreeNode = ComponentTreeNode> = (T | ForEach<ForEachDataRef<DataType>, T>)[];
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ import type { ComponentTreeNode } from "@matreshka/bff/core";
2
+ import type { Overlay as OverlayShape } from "@matreshka/shared/types/container-overlay";
3
+ export type Overlay = OverlayShape<ComponentTreeNode>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Эвристика для фабрики кнопки: передан самостоятельный компонент, а не объект InitConfig.
3
+ */
4
+ export declare function isStandaloneComponentLike(x: unknown): boolean;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isStandaloneComponentLike = isStandaloneComponentLike;
4
+ /**
5
+ * Эвристика для фабрики кнопки: передан самостоятельный компонент, а не объект InitConfig.
6
+ */
7
+ function isStandaloneComponentLike(x) {
8
+ return (typeof x === "object" &&
9
+ x !== null &&
10
+ "standalone" in x &&
11
+ typeof x.standalone === "function");
12
+ }
@@ -0,0 +1,35 @@
1
+ import type { Condition as SerializedCondition } from "@matreshka/shared/types/condition";
2
+ import type { Client } from "../client";
3
+ import { Condition } from "../conditions/condition";
4
+ export type ActionConditions = Condition[] | (() => Condition[]);
5
+ export type ActionConfig = {
6
+ conditions?: ActionConditions;
7
+ };
8
+ /**
9
+ * Абстрактный класс действия, которое может быть сериализовано для клиента.
10
+ */
11
+ export declare abstract class Action {
12
+ private readonly conditions?;
13
+ constructor(conditions?: ActionConditions | undefined);
14
+ /**
15
+ * Возвращает уникальный идентификатор класса действия.
16
+ */
17
+ abstract class(): string;
18
+ /**
19
+ * Возвращает полезную нагрузку действия.
20
+ */
21
+ abstract payload(): object;
22
+ /**
23
+ * Сериализует действие в объект с ключами `class` и `payload`.
24
+ *
25
+ * @returns Сериализованное представление действия.
26
+ */
27
+ toJSON(): {
28
+ class: string;
29
+ payload: object;
30
+ conditions?: SerializedCondition[];
31
+ };
32
+ canExecute(client: Client): boolean;
33
+ private resolveConditions;
34
+ private serializeConditions;
35
+ }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Action = void 0;
4
+ const shared_1 = require("@matreshka/shared");
5
+ /**
6
+ * Абстрактный класс действия, которое может быть сериализовано для клиента.
7
+ */
8
+ class Action {
9
+ constructor(conditions) {
10
+ this.conditions = conditions;
11
+ }
12
+ /**
13
+ * Сериализует действие в объект с ключами `class` и `payload`.
14
+ *
15
+ * @returns Сериализованное представление действия.
16
+ */
17
+ toJSON() {
18
+ const conditions = this.serializeConditions();
19
+ const result = {
20
+ class: this.class(),
21
+ payload: this.payload(),
22
+ };
23
+ if (conditions.length > 0) {
24
+ result.conditions = conditions;
25
+ }
26
+ return result;
27
+ }
28
+ canExecute(client) {
29
+ const conditions = this.resolveConditions().map((condition) => condition.toJSON());
30
+ const evaluateActionConditions = shared_1.evaluateConditions;
31
+ return evaluateActionConditions(conditions, {
32
+ getContextValue: (ref) => ref.value(),
33
+ getDeviceType: () => client.deviceType(),
34
+ });
35
+ }
36
+ resolveConditions() {
37
+ return typeof this.conditions === "function"
38
+ ? this.conditions()
39
+ : (this.conditions ?? []);
40
+ }
41
+ serializeConditions() {
42
+ return this.resolveConditions().map((condition) => condition.toJSON());
43
+ }
44
+ }
45
+ exports.Action = Action;
@@ -0,0 +1,58 @@
1
+ import { ComponentAnimationEffect } from "@matreshka/shared/enums/component-animation-effect";
2
+ import { TimingFunction } from "@matreshka/shared/enums/timing-function";
3
+ import type { ComponentAnimationEffects } from "@matreshka/shared/types/component-animation";
4
+ import { ActionConditions } from "./action";
5
+ import { LocalAction } from "./local-action";
6
+ export { DimensionalUnit } from "@matreshka/shared/enums/dimensional-unit";
7
+ export type { ComponentAnimationEffects, DimensionalKeyframeStops, OpacityKeyframeStops, } from "@matreshka/shared/types/component-animation";
8
+ export type { DimensionalValue } from "@matreshka/shared/types/dimensional-value";
9
+ export { ComponentAnimationEffect, TimingFunction };
10
+ /**
11
+ * Конфигурация действия анимации компонента.
12
+ */
13
+ export interface AnimateComponentConfig {
14
+ /**
15
+ * Целевой элемент по id: базовый id BFF-`Component` (анимация всех instance на клиенте)
16
+ * или instance id (`uuid-0`, … — один конкретный DOM-инстанс).
17
+ * Если не задано — анимируется тот же инстанс, у которого произошло событие (`interact`).
18
+ */
19
+ componentId?: string;
20
+ /** Длительность анимации (мс). */
21
+ duration: number;
22
+ /** Карты keyframe по типам эффектов. */
23
+ effects: ComponentAnimationEffects;
24
+ /** Функция сглаживания по CSS; если не задана — на клиенте берётся значение по умолчанию. */
25
+ timingFunction?: TimingFunction;
26
+ /** Задержка перед стартом (мс). */
27
+ delay?: number;
28
+ /** Условия, при выполнении которых действие будет запущено на клиенте. */
29
+ conditions?: ActionConditions;
30
+ }
31
+ /**
32
+ * Локальное действие: анимация над компонентом на клиенте.
33
+ *
34
+ * @internal Используйте {@link animate}.
35
+ */
36
+ export declare class AnimateComponent extends LocalAction {
37
+ private readonly componentId;
38
+ private readonly duration;
39
+ private readonly timingFunction;
40
+ private readonly delay;
41
+ private readonly effects;
42
+ /**
43
+ * @param config Параметры анимации.
44
+ */
45
+ constructor(config: AnimateComponentConfig);
46
+ class(): string;
47
+ payload(): object;
48
+ }
49
+ /**
50
+ * Локальное действие: анимация над компонентом на клиенте.
51
+ */
52
+ export declare function animate(config: AnimateComponentConfig): AnimateComponent;
53
+ /**
54
+ * Функциональная форма {@link AnimateComponent}.
55
+ *
56
+ * @deprecated Используйте {@link animate}.
57
+ */
58
+ export declare function animateComponent(config: AnimateComponentConfig): AnimateComponent;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AnimateComponent = exports.TimingFunction = exports.ComponentAnimationEffect = exports.DimensionalUnit = void 0;
4
+ exports.animate = animate;
5
+ exports.animateComponent = animateComponent;
6
+ const component_animation_effect_1 = require("@matreshka/shared/enums/component-animation-effect");
7
+ Object.defineProperty(exports, "ComponentAnimationEffect", { enumerable: true, get: function () { return component_animation_effect_1.ComponentAnimationEffect; } });
8
+ const timing_function_1 = require("@matreshka/shared/enums/timing-function");
9
+ Object.defineProperty(exports, "TimingFunction", { enumerable: true, get: function () { return timing_function_1.TimingFunction; } });
10
+ const local_action_1 = require("./local-action");
11
+ var dimensional_unit_1 = require("@matreshka/shared/enums/dimensional-unit");
12
+ Object.defineProperty(exports, "DimensionalUnit", { enumerable: true, get: function () { return dimensional_unit_1.DimensionalUnit; } });
13
+ /**
14
+ * Локальное действие: анимация над компонентом на клиенте.
15
+ *
16
+ * @internal Используйте {@link animate}.
17
+ */
18
+ class AnimateComponent extends local_action_1.LocalAction {
19
+ /**
20
+ * @param config Параметры анимации.
21
+ */
22
+ constructor(config) {
23
+ super(config.conditions);
24
+ this.componentId = config.componentId;
25
+ this.duration = config.duration;
26
+ this.effects = config.effects;
27
+ this.timingFunction = config.timingFunction;
28
+ this.delay = config.delay;
29
+ }
30
+ class() {
31
+ return "animate-component";
32
+ }
33
+ payload() {
34
+ return {
35
+ componentId: this.componentId,
36
+ duration: this.duration,
37
+ timingFunction: this.timingFunction,
38
+ effects: this.effects,
39
+ delay: this.delay,
40
+ };
41
+ }
42
+ }
43
+ exports.AnimateComponent = AnimateComponent;
44
+ /**
45
+ * Локальное действие: анимация над компонентом на клиенте.
46
+ */
47
+ function animate(config) {
48
+ return new AnimateComponent(config);
49
+ }
50
+ /**
51
+ * Функциональная форма {@link AnimateComponent}.
52
+ *
53
+ * @deprecated Используйте {@link animate}.
54
+ */
55
+ function animateComponent(config) {
56
+ return animate(config);
57
+ }
@@ -0,0 +1,8 @@
1
+ import { Action } from "./action";
2
+ /**
3
+ * Абстрактный класс локального действия, выполняемого на клиенте.
4
+ *
5
+ * Наследники должны реализовать методы `class` и `payload` для сериализации.
6
+ */
7
+ export declare abstract class LocalAction extends Action {
8
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LocalAction = void 0;
4
+ const action_1 = require("./action");
5
+ /**
6
+ * Абстрактный класс локального действия, выполняемого на клиенте.
7
+ *
8
+ * Наследники должны реализовать методы `class` и `payload` для сериализации.
9
+ */
10
+ class LocalAction extends action_1.Action {
11
+ }
12
+ exports.LocalAction = LocalAction;
@@ -0,0 +1,18 @@
1
+ import { ContextRef, ContextRefValue } from "../context/context-ref";
2
+ import { ActionConfig } from "./action";
3
+ import { LocalAction } from "./local-action";
4
+ /**
5
+ * Запись одного значения в Context на клиенте (с sync на BFF через `context-values`).
6
+ */
7
+ export declare class SetContextValue extends LocalAction {
8
+ private readonly ref;
9
+ private readonly value;
10
+ constructor(ref: ContextRef<any, any>, value: unknown, config?: ActionConfig);
11
+ class(): string;
12
+ payload(): object;
13
+ }
14
+ /**
15
+ * Функциональная форма {@link SetContextValue}.
16
+ * Тип `value` должен совпадать с типом значения по `ref`.
17
+ */
18
+ export declare function setContextValue<R extends ContextRef<any, any>>(ref: R, value: ContextRefValue<R>, config?: ActionConfig): SetContextValue;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SetContextValue = void 0;
4
+ exports.setContextValue = setContextValue;
5
+ const local_action_1 = require("./local-action");
6
+ /**
7
+ * Запись одного значения в Context на клиенте (с sync на BFF через `context-values`).
8
+ */
9
+ class SetContextValue extends local_action_1.LocalAction {
10
+ constructor(ref, value, config = {}) {
11
+ super(config.conditions);
12
+ this.ref = ref;
13
+ this.value = value;
14
+ }
15
+ class() {
16
+ return "set-context-value";
17
+ }
18
+ payload() {
19
+ return {
20
+ ref: this.ref,
21
+ value: this.value,
22
+ };
23
+ }
24
+ }
25
+ exports.SetContextValue = SetContextValue;
26
+ /**
27
+ * Функциональная форма {@link SetContextValue}.
28
+ * Тип `value` должен совпадать с типом значения по `ref`.
29
+ */
30
+ function setContextValue(ref, value, config = {}) {
31
+ return new SetContextValue(ref, value, config);
32
+ }
@@ -0,0 +1,34 @@
1
+ import { ContextRef, ContextRefValue } from "../context/context-ref";
2
+ import { ActionConfig } from "./action";
3
+ import { LocalAction } from "./local-action";
4
+ /**
5
+ * Пара ref + value для batch-записи в Context.
6
+ * Тип `value` выводится из конкретного `ref`.
7
+ */
8
+ export type ContextValueAssignment<R extends ContextRef<any, any> = ContextRef<any, any>> = {
9
+ ref: R;
10
+ value: ContextRefValue<R>;
11
+ };
12
+ type AssertContextValueAssignments<T extends readonly unknown[]> = {
13
+ [K in keyof T]: T[K] extends {
14
+ ref: infer R extends ContextRef<any, any>;
15
+ } ? ContextValueAssignment<R> : never;
16
+ };
17
+ /**
18
+ * Batch-запись значений в Context на клиенте (с sync на BFF через `context-values`).
19
+ */
20
+ export declare class SetContextValues extends LocalAction {
21
+ private readonly values;
22
+ constructor(values: readonly ContextValueAssignment[], config?: ActionConfig);
23
+ class(): string;
24
+ payload(): object;
25
+ }
26
+ /**
27
+ * Функциональная форма {@link SetContextValues}.
28
+ * У каждого элемента массива тип `value` должен совпадать с типом значения по `ref`.
29
+ */
30
+ export declare function setContextValues<const T extends readonly [
31
+ ContextValueAssignment,
32
+ ...ContextValueAssignment[]
33
+ ]>(values: AssertContextValueAssignments<T> & T, config?: ActionConfig): SetContextValues;
34
+ export {};