@matreshka/bff 0.20.0 → 0.22.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/dist/components/board.d.ts +7 -0
- package/dist/components/board.js +7 -0
- package/dist/components/camera.d.ts +4 -0
- package/dist/components/camera.js +4 -0
- package/dist/components/component.d.ts +2 -1
- package/dist/components/dialog.d.ts +5 -0
- package/dist/components/dialog.js +8 -0
- package/dist/components/for-each.d.ts +3 -3
- package/dist/components/for-each.js +18 -26
- package/dist/components/inputs/text-editor.d.ts +17 -0
- package/dist/components/inputs/text-editor.js +17 -0
- package/dist/components/item-list/item-list.js +11 -11
- package/dist/components/item-list/list-from-ref-context.d.ts +4 -1
- package/dist/components/item-list/list-from-ref-context.js +6 -4
- package/dist/components/item-list/types.d.ts +5 -5
- package/dist/components/item-list/types.js +1 -1
- package/dist/components/map.d.ts +11 -0
- package/dist/components/map.js +7 -0
- package/dist/components/popover.d.ts +5 -0
- package/dist/components/popover.js +8 -0
- package/dist/components/stack.d.ts +4 -0
- package/dist/components/stack.js +4 -0
- package/dist/core/actions/close-entry.d.ts +15 -0
- package/dist/core/actions/close-entry.js +28 -0
- package/dist/core/actions/component-local-actions.d.ts +113 -0
- package/dist/core/actions/component-local-actions.js +274 -0
- package/dist/core/actions/dec-context-value.d.ts +21 -0
- package/dist/core/actions/dec-context-value.js +35 -0
- package/dist/core/actions/inc-context-value.d.ts +22 -0
- package/dist/core/actions/inc-context-value.js +35 -0
- package/dist/core/actions/local-action.d.ts +4 -0
- package/dist/core/actions/local-action.js +43 -0
- package/dist/core/actions/set-context.d.ts +20 -0
- package/dist/core/actions/set-context.js +33 -0
- package/dist/core/conditions/condition-operand.d.ts +5 -3
- package/dist/core/context/context-ref.d.ts +26 -4
- package/dist/core/context/context-ref.js +25 -8
- package/dist/core/context/context.d.ts +52 -10
- package/dist/core/context/context.js +87 -13
- package/dist/core/index.d.ts +3 -6
- package/dist/core/index.js +6 -6
- package/dist/core/local/index.d.ts +14 -0
- package/dist/core/local/index.js +18 -0
- package/dist/core/types/component-instance.d.ts +7 -0
- package/dist/core/types/component-instance.js +4 -0
- package/dist/core/types/context-value-ref.d.ts +5 -3
- package/dist/core/utils/replace-context-keys.js +1 -2
- package/package.json +2 -2
- package/dist/core/actions/set-context-value.d.ts +0 -21
- package/dist/core/actions/set-context-value.js +0 -34
- package/dist/core/actions/set-context-values.d.ts +0 -35
- package/dist/core/actions/set-context-values.js +0 -30
|
@@ -3,6 +3,7 @@ import type { BoardConfig, BoardPoint } from "@matreshka/shared/types/board-conf
|
|
|
3
3
|
import { type FlexItemSpec } from "@matreshka/shared/types/flex-item";
|
|
4
4
|
import type { NestedItemBase } from "@matreshka/shared/types/nested-item-base";
|
|
5
5
|
import { Componentable, ComponentInstance, ComponentTreeNode, StandaloneComponent } from "../core";
|
|
6
|
+
import type { ActionConfig } from "../core/actions/action";
|
|
6
7
|
import { Component, ComponentInitConfig, ComponentProperties, ServerComponentAction } from "./component";
|
|
7
8
|
import type { ItemList } from "./item-list/item-list";
|
|
8
9
|
import type { ItemListHost } from "./item-list/item-list-host";
|
|
@@ -36,6 +37,12 @@ type DefaultInitConfigType = BoardInitConfig<Board>;
|
|
|
36
37
|
export declare class Board<InitConfigType extends BoardInitConfig<any> = DefaultInitConfigType, PropertiesType extends BoardProperties = BoardProperties> extends Component<InitConfigType, PropertiesType> implements StandaloneComponent, ItemListHost {
|
|
37
38
|
private readonly itemsSlot;
|
|
38
39
|
private readonly itemListHostAdapter;
|
|
40
|
+
readonly local: {
|
|
41
|
+
setCenter: (center: BoardPoint, config?: ActionConfig) => import("../core/actions/component-local-actions").BoardSetCenterLocalAction;
|
|
42
|
+
setZoom: (zoom: number, config?: ActionConfig) => import("../core/actions/component-local-actions").BoardSetZoomLocalAction;
|
|
43
|
+
zoomIn: (config?: ActionConfig) => import("../core/actions/component-local-actions").BoardZoomInLocalAction;
|
|
44
|
+
zoomOut: (config?: ActionConfig) => import("../core/actions/component-local-actions").BoardZoomOutLocalAction;
|
|
45
|
+
};
|
|
39
46
|
setCenter(center: BoardPoint, instances?: ComponentInstance[]): import("rxjs").Observable<void>;
|
|
40
47
|
setZoom(zoom: number, instances?: ComponentInstance[]): import("rxjs").Observable<void>;
|
|
41
48
|
zoomIn(instances?: ComponentInstance[]): import("rxjs").Observable<void>;
|
package/dist/components/board.js
CHANGED
|
@@ -7,6 +7,7 @@ const board_set_zoom_message_1 = require("@matreshka/shared/messages/bff-to-clie
|
|
|
7
7
|
const board_zoom_in_message_1 = require("@matreshka/shared/messages/bff-to-client/components/board/board-zoom-in-message");
|
|
8
8
|
const board_zoom_out_message_1 = require("@matreshka/shared/messages/bff-to-client/components/board/board-zoom-out-message");
|
|
9
9
|
const flex_item_1 = require("@matreshka/shared/types/flex-item");
|
|
10
|
+
const component_local_actions_1 = require("../core/actions/component-local-actions");
|
|
10
11
|
const component_1 = require("./component");
|
|
11
12
|
const item_list_1 = require("./item-list");
|
|
12
13
|
const flatten_nested_items_1 = require("./item-list/flatten-nested-items");
|
|
@@ -38,6 +39,12 @@ class Board extends component_1.Component {
|
|
|
38
39
|
source: [],
|
|
39
40
|
itemLists: [],
|
|
40
41
|
};
|
|
42
|
+
this.local = {
|
|
43
|
+
setCenter: (center, config) => (0, component_local_actions_1.boardSetCenterLocal)(this, center, config),
|
|
44
|
+
setZoom: (zoom, config) => (0, component_local_actions_1.boardSetZoomLocal)(this, zoom, config),
|
|
45
|
+
zoomIn: (config) => (0, component_local_actions_1.boardZoomInLocal)(this, config),
|
|
46
|
+
zoomOut: (config) => (0, component_local_actions_1.boardZoomOutLocal)(this, config),
|
|
47
|
+
};
|
|
41
48
|
this.itemsSlot.source = itemsSlot.source;
|
|
42
49
|
this.itemsSlot.itemLists = itemsSlot.itemLists;
|
|
43
50
|
(0, item_list_1.attachItemListsToHost)(this, "items", this.itemsSlot);
|
|
@@ -3,6 +3,7 @@ import { VideoFacingMode } from "@matreshka/shared/enums/video-facing-mode";
|
|
|
3
3
|
import { ErrorMessagePayload } from "@matreshka/shared/messages/client-to-bff/error-message";
|
|
4
4
|
import type { CameraConfig } from "@matreshka/shared/types/camera-config";
|
|
5
5
|
import { Componentable, ComponentInstance, ComponentTreeNode, MixedWithCallbacksArray, StandaloneComponent } from "../core";
|
|
6
|
+
import type { ActionConfig } from "../core/actions/action";
|
|
6
7
|
import { VideoInputDevice } from "../platforms/platform";
|
|
7
8
|
import { Component, ComponentInitConfig, ComponentProperties, ServerComponentAction } from "./component";
|
|
8
9
|
export { VideoFacingMode } from "@matreshka/shared/enums/video-facing-mode";
|
|
@@ -53,6 +54,9 @@ export declare function camera<ContentType extends ComponentTreeNode = Component
|
|
|
53
54
|
* Компонент камеры (контейнер), на клиенте отображает видео с веб-камеры устройства.
|
|
54
55
|
*/
|
|
55
56
|
export declare class Camera<ContentType extends ComponentTreeNode = ComponentTreeNode, InitConfigType extends CameraInitConfig<ContentType, any> = DefaultInitConfigType<ContentType>, PropertiesType extends CameraProperties = CameraProperties> extends Component<InitConfigType, PropertiesType> implements StandaloneComponent {
|
|
57
|
+
readonly local: {
|
|
58
|
+
switchCamera: (device: VideoInputDevice, config?: ActionConfig) => import("../core/actions/component-local-actions").CameraSwitchLocalAction;
|
|
59
|
+
};
|
|
56
60
|
constructor(config: InitConfigType);
|
|
57
61
|
/**
|
|
58
62
|
* Возвращает уникальный идентификатор класса компонента.
|
|
@@ -5,6 +5,7 @@ exports.camera = camera;
|
|
|
5
5
|
const server_component_class_1 = require("@matreshka/shared/enums/server-component-class");
|
|
6
6
|
const camera_switch_message_1 = require("@matreshka/shared/messages/bff-to-client/components/camera/camera-switch-message");
|
|
7
7
|
const core_1 = require("../core");
|
|
8
|
+
const component_local_actions_1 = require("../core/actions/component-local-actions");
|
|
8
9
|
const component_1 = require("./component");
|
|
9
10
|
var video_facing_mode_1 = require("@matreshka/shared/enums/video-facing-mode");
|
|
10
11
|
Object.defineProperty(exports, "VideoFacingMode", { enumerable: true, get: function () { return video_facing_mode_1.VideoFacingMode; } });
|
|
@@ -32,6 +33,9 @@ function camera(arg0, arg1) {
|
|
|
32
33
|
class Camera extends component_1.Component {
|
|
33
34
|
constructor(config) {
|
|
34
35
|
super(config);
|
|
36
|
+
this.local = {
|
|
37
|
+
switchCamera: (device, config) => (0, component_local_actions_1.cameraSwitchLocal)(this, device, config),
|
|
38
|
+
};
|
|
35
39
|
if (config.onQrCode) {
|
|
36
40
|
// bindActions в базовом Component типизирован под payload=unknown.
|
|
37
41
|
// Здесь payload всегда строка QR-кода, поэтому безопасно расширяем тип.
|
|
@@ -9,7 +9,8 @@ import type { FontStackToken } from "@matreshka/shared/types/fonts";
|
|
|
9
9
|
import type { GridItem } from "@matreshka/shared/types/grid-item";
|
|
10
10
|
import type { ServerComponentConfig } from "@matreshka/shared/types/server-component-config";
|
|
11
11
|
import { Observable, Subscription } from "rxjs";
|
|
12
|
-
import { Client, Componentable, ComponentInstance
|
|
12
|
+
import { Client, Componentable, ComponentInstance } from "../core";
|
|
13
|
+
import { LocalAction } from "../core/actions/local-action";
|
|
13
14
|
import { Condition } from "../core/conditions";
|
|
14
15
|
import { ServerAction, ServerActionHandler } from "./actions/server-action";
|
|
15
16
|
import type { EntryComponent } from "./entry-component";
|
|
@@ -3,6 +3,7 @@ import { OverlayAnchor } from "@matreshka/shared/types/container-overlay";
|
|
|
3
3
|
import type { DialogBackdropConfig } from "@matreshka/shared/types/dialog-backdrop-config";
|
|
4
4
|
import type { DialogConfig } from "@matreshka/shared/types/dialog-config";
|
|
5
5
|
import { Componentable, ComponentInstance, ComponentTreeNode, MixedWithCallbacksArray } from "../core";
|
|
6
|
+
import type { ActionConfig } from "../core/actions/action";
|
|
6
7
|
import type { AnimateComponent } from "../core/actions/animate-component";
|
|
7
8
|
import { EntryComponent, EntryComponentInitConfig, EntryComponentProperties } from "./entry-component";
|
|
8
9
|
/** Анимации подложки модального диалога при инициализации. */
|
|
@@ -57,6 +58,10 @@ export declare function dialog(config: DefaultInitConfigType): Dialog;
|
|
|
57
58
|
* @template InitConfigType Тип конфигурации инициализации.
|
|
58
59
|
*/
|
|
59
60
|
export declare class Dialog<InitConfigType extends DialogInitConfig<any> = DefaultInitConfigType, PropertiesType extends DialogProperties = DialogProperties> extends EntryComponent<InitConfigType, PropertiesType> implements Componentable {
|
|
61
|
+
/** Локальные (client-only) действия entry-диалога. */
|
|
62
|
+
readonly local: {
|
|
63
|
+
close: (config?: ActionConfig) => import("../core/actions/close-entry").CloseEntry;
|
|
64
|
+
};
|
|
60
65
|
/**
|
|
61
66
|
* Возвращает уникальный идентификатор класса компонента.
|
|
62
67
|
* @returns Строка "dialog".
|
|
@@ -5,6 +5,7 @@ exports.dialog = dialog;
|
|
|
5
5
|
const server_component_class_1 = require("@matreshka/shared/enums/server-component-class");
|
|
6
6
|
const dialog_close_message_1 = require("@matreshka/shared/messages/bff-to-client/components/dialog/dialog-close-message");
|
|
7
7
|
const core_1 = require("../core");
|
|
8
|
+
const close_entry_1 = require("../core/actions/close-entry");
|
|
8
9
|
const entry_component_1 = require("./entry-component");
|
|
9
10
|
function serializeLocalActions(actions) {
|
|
10
11
|
if (!actions) {
|
|
@@ -52,6 +53,13 @@ function dialog(arg0, arg1) {
|
|
|
52
53
|
* @template InitConfigType Тип конфигурации инициализации.
|
|
53
54
|
*/
|
|
54
55
|
class Dialog extends entry_component_1.EntryComponent {
|
|
56
|
+
constructor() {
|
|
57
|
+
super(...arguments);
|
|
58
|
+
/** Локальные (client-only) действия entry-диалога. */
|
|
59
|
+
this.local = {
|
|
60
|
+
close: (config) => (0, close_entry_1.closeEntry)(this, config),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
55
63
|
/**
|
|
56
64
|
* Возвращает уникальный идентификатор класса компонента.
|
|
57
65
|
* @returns Строка "dialog".
|
|
@@ -9,12 +9,12 @@ export type CompatibleForEachRef<RefType extends ContextRef<any, any>> = [
|
|
|
9
9
|
ForEachItemArray<RefType>
|
|
10
10
|
] extends [never] ? never : RefType;
|
|
11
11
|
type ForEachItemData<RefType extends ContextRef<any, any>> = ForEachItemArray<RefType>[number];
|
|
12
|
-
type ForEachTypedItemRef<ContextType extends JsonObject, PathType extends string, ValueType> = Omit<ContextRef<any, any>, "context" | "path" | "ref" | "
|
|
12
|
+
type ForEachTypedItemRef<ContextType extends JsonObject, PathType extends string, ValueType> = Omit<ContextRef<any, any>, "context" | "path" | "ref" | "get"> & {
|
|
13
13
|
readonly context: Context<ContextType>;
|
|
14
14
|
readonly path: PathType;
|
|
15
15
|
readonly __valueType?: ValueType;
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
get(): ValueType;
|
|
17
|
+
get(): JsonObject;
|
|
18
18
|
ref<K extends Paths<ValueType>>(path: K): ForEachTypedItemRef<ContextType, `${PathType}.${K & string}`, PathValue<ValueType, K>>;
|
|
19
19
|
ref<P2 extends string>(path: ContextRef<ContextType, P2>): ContextRef<ContextType, `${PathType}.${P2}`>;
|
|
20
20
|
};
|
|
@@ -11,14 +11,14 @@ const track_created_instances_1 = require("../core/utils/track-created-instances
|
|
|
11
11
|
const component_1 = require("./component");
|
|
12
12
|
/** Возвращает массив элементов списка из ref; не-массив даёт пустой массив. */
|
|
13
13
|
function getForEachValue(ref) {
|
|
14
|
-
const rawValue = ref.
|
|
14
|
+
const rawValue = ref.get();
|
|
15
15
|
return Array.isArray(rawValue)
|
|
16
16
|
? rawValue
|
|
17
17
|
: [];
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Связывает ref элемента списка с ref индекса в {@link ForEachContext},
|
|
21
|
-
* чтобы генератор мог читать `ref.
|
|
21
|
+
* чтобы генератор мог читать `ref.get()` и вложенные поля элемента.
|
|
22
22
|
*/
|
|
23
23
|
function createForEachItemLink(ref, indexRef) {
|
|
24
24
|
return ref.strictRef(indexRef);
|
|
@@ -27,22 +27,16 @@ const forEach = (config) => new ForEach(config);
|
|
|
27
27
|
exports.forEach = forEach;
|
|
28
28
|
class ForEachContext extends core_1.Context {
|
|
29
29
|
/**
|
|
30
|
-
* Синхронно поднимает
|
|
30
|
+
* Синхронно поднимает хранилище до async {@link init} (preload-сериализация индексов).
|
|
31
31
|
* @returns Тот же экземпляр контекста.
|
|
32
32
|
*/
|
|
33
33
|
initSync() {
|
|
34
|
-
|
|
35
|
-
if (this.inited())
|
|
34
|
+
if (this.inited()) {
|
|
36
35
|
return this;
|
|
36
|
+
}
|
|
37
37
|
this.data$ = new rxjs_1.BehaviorSubject({});
|
|
38
38
|
this.subscribeToDataChanges();
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* После in-place обновления карты индексов в `data$` — одна синхронизация с клиентом.
|
|
42
|
-
* @see Context.emitAfterInPlaceMutation
|
|
43
|
-
*/
|
|
44
|
-
syncIndexStoreFromMutations() {
|
|
45
|
-
super.emitAfterInPlaceMutation();
|
|
39
|
+
return this;
|
|
46
40
|
}
|
|
47
41
|
/**
|
|
48
42
|
* Контекст индексов элементов ForEach; данные не загружаются снаружи (`schema` пустой).
|
|
@@ -173,15 +167,14 @@ class ForEach extends component_1.Component {
|
|
|
173
167
|
const value = getForEachValue(this.config.ref);
|
|
174
168
|
const itemsCheckSum = value.map(this.config.track).join("|");
|
|
175
169
|
this.lastItemsCheckSum = itemsCheckSum;
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
delete store[key];
|
|
170
|
+
const items = Array.isArray(value) ? value : [];
|
|
171
|
+
const store = {};
|
|
172
|
+
for (let index = 0; index < items.length; index++) {
|
|
173
|
+
store[this.itemId(items[index])] = { index: `${index}` };
|
|
181
174
|
}
|
|
182
|
-
|
|
175
|
+
this.componentContext.replace(store);
|
|
176
|
+
return items.map((item) => {
|
|
183
177
|
const itemId = this.itemId(item);
|
|
184
|
-
store[itemId] = { index: `${index}` };
|
|
185
178
|
if (cache.has(itemId)) {
|
|
186
179
|
return cache.get(itemId);
|
|
187
180
|
}
|
|
@@ -192,8 +185,6 @@ class ForEach extends component_1.Component {
|
|
|
192
185
|
cache.set(itemId, result);
|
|
193
186
|
return result;
|
|
194
187
|
});
|
|
195
|
-
this.componentContext.syncIndexStoreFromMutations();
|
|
196
|
-
return components;
|
|
197
188
|
}
|
|
198
189
|
/**
|
|
199
190
|
* Синхронизирует элементы списка с клиентом для одного instance ForEach.
|
|
@@ -249,10 +240,11 @@ class ForEach extends component_1.Component {
|
|
|
249
240
|
if (this.instanceCount === 1) {
|
|
250
241
|
const contextSubscription = new rxjs_1.Subscription();
|
|
251
242
|
this.contextSubscription = contextSubscription;
|
|
252
|
-
contextSubscription.add(this.config.ref.context
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
243
|
+
contextSubscription.add(this.config.ref.context
|
|
244
|
+
.watch()
|
|
245
|
+
.pipe((0, rxjs_1.skip)(1))
|
|
246
|
+
.subscribe(() => {
|
|
247
|
+
void this.syncComponents(true);
|
|
256
248
|
}));
|
|
257
249
|
}
|
|
258
250
|
});
|
|
@@ -289,7 +281,7 @@ class ForEach extends component_1.Component {
|
|
|
289
281
|
this.stopUsing$.subscribe(() => {
|
|
290
282
|
this.instanceStates.clear();
|
|
291
283
|
});
|
|
292
|
-
// Инициализируем контекст сразу, чтобы при ранней сериализации
|
|
284
|
+
// Инициализируем контекст сразу, чтобы при ранней сериализации хранилище уже существовало.
|
|
293
285
|
void this.componentContext.initSync();
|
|
294
286
|
}
|
|
295
287
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ServerComponentClass } from "@matreshka/shared/enums/server-component-class";
|
|
2
2
|
import { Componentable, ComponentInstance } from "../../core";
|
|
3
|
+
import type { ActionConfig } from "../../core/actions/action";
|
|
3
4
|
import { ServerComponentAction } from "../component";
|
|
4
5
|
import { InputComponent, InputInitConfig, InputProperties, StringInputContextRef } from "./input-component";
|
|
5
6
|
/**
|
|
@@ -25,6 +26,22 @@ export declare function textEditor<RefType extends StringInputContextRef = Strin
|
|
|
25
26
|
* Поддерживает панель инструментов, вложенные компоненты и команды форматирования.
|
|
26
27
|
*/
|
|
27
28
|
export declare class TextEditor<RefType extends StringInputContextRef = StringInputContextRef, InitConfigType extends TextEditorInitConfig<any, RefType> = DefaultInitConfigType<RefType>, PropertiesType extends TextEditorProperties = TextEditorProperties> extends InputComponent<InitConfigType, PropertiesType> {
|
|
29
|
+
readonly local: {
|
|
30
|
+
insertHTML: (value: string, config?: ActionConfig) => import("../../core/actions/component-local-actions").TextEditorInsertHtmlLocalAction;
|
|
31
|
+
toggleItalic: (config?: ActionConfig) => import("../../core/actions/local-action").LocalAction;
|
|
32
|
+
toggleBold: (config?: ActionConfig) => import("../../core/actions/local-action").LocalAction;
|
|
33
|
+
toggleUnderline: (config?: ActionConfig) => import("../../core/actions/local-action").LocalAction;
|
|
34
|
+
undo: (config?: ActionConfig) => import("../../core/actions/local-action").LocalAction;
|
|
35
|
+
redo: (config?: ActionConfig) => import("../../core/actions/local-action").LocalAction;
|
|
36
|
+
superscript: (config?: ActionConfig) => import("../../core/actions/local-action").LocalAction;
|
|
37
|
+
insertOrderedList: (config?: ActionConfig) => import("../../core/actions/local-action").LocalAction;
|
|
38
|
+
insertUnorderedList: (config?: ActionConfig) => import("../../core/actions/local-action").LocalAction;
|
|
39
|
+
justifyLeft: (config?: ActionConfig) => import("../../core/actions/local-action").LocalAction;
|
|
40
|
+
justifyCenter: (config?: ActionConfig) => import("../../core/actions/local-action").LocalAction;
|
|
41
|
+
justifyRight: (config?: ActionConfig) => import("../../core/actions/local-action").LocalAction;
|
|
42
|
+
justifyFull: (config?: ActionConfig) => import("../../core/actions/local-action").LocalAction;
|
|
43
|
+
formatBlock: (tag: string, config?: ActionConfig) => import("../../core/actions/component-local-actions").TextEditorFormatBlockLocalAction;
|
|
44
|
+
};
|
|
28
45
|
constructor(config: TextEditorInitConfig<any, RefType>);
|
|
29
46
|
protected class(): ServerComponentClass;
|
|
30
47
|
/**
|
|
@@ -18,6 +18,7 @@ const text_editor_toggle_italic_message_1 = require("@matreshka/shared/messages/
|
|
|
18
18
|
const text_editor_toggle_underline_message_1 = require("@matreshka/shared/messages/bff-to-client/components/text-editor/text-editor-toggle-underline-message");
|
|
19
19
|
const text_editor_undo_message_1 = require("@matreshka/shared/messages/bff-to-client/components/text-editor/text-editor-undo-message");
|
|
20
20
|
const core_1 = require("../../core");
|
|
21
|
+
const component_local_actions_1 = require("../../core/actions/component-local-actions");
|
|
21
22
|
const input_component_1 = require("./input-component");
|
|
22
23
|
function textEditor(arg0, arg1) {
|
|
23
24
|
if (arg1 !== undefined) {
|
|
@@ -40,6 +41,22 @@ function textEditor(arg0, arg1) {
|
|
|
40
41
|
class TextEditor extends input_component_1.InputComponent {
|
|
41
42
|
constructor(config) {
|
|
42
43
|
super(config);
|
|
44
|
+
this.local = {
|
|
45
|
+
insertHTML: (value, config) => (0, component_local_actions_1.textEditorInsertHtmlLocal)(this, value, config),
|
|
46
|
+
toggleItalic: (config) => (0, component_local_actions_1.textEditorToggleItalicLocal)(this, config),
|
|
47
|
+
toggleBold: (config) => (0, component_local_actions_1.textEditorToggleBoldLocal)(this, config),
|
|
48
|
+
toggleUnderline: (config) => (0, component_local_actions_1.textEditorToggleUnderlineLocal)(this, config),
|
|
49
|
+
undo: (config) => (0, component_local_actions_1.textEditorUndoLocal)(this, config),
|
|
50
|
+
redo: (config) => (0, component_local_actions_1.textEditorRedoLocal)(this, config),
|
|
51
|
+
superscript: (config) => (0, component_local_actions_1.textEditorSuperscriptLocal)(this, config),
|
|
52
|
+
insertOrderedList: (config) => (0, component_local_actions_1.textEditorInsertOrderedListLocal)(this, config),
|
|
53
|
+
insertUnorderedList: (config) => (0, component_local_actions_1.textEditorInsertUnorderedListLocal)(this, config),
|
|
54
|
+
justifyLeft: (config) => (0, component_local_actions_1.textEditorJustifyLeftLocal)(this, config),
|
|
55
|
+
justifyCenter: (config) => (0, component_local_actions_1.textEditorJustifyCenterLocal)(this, config),
|
|
56
|
+
justifyRight: (config) => (0, component_local_actions_1.textEditorJustifyRightLocal)(this, config),
|
|
57
|
+
justifyFull: (config) => (0, component_local_actions_1.textEditorJustifyFullLocal)(this, config),
|
|
58
|
+
formatBlock: (tag, config) => (0, component_local_actions_1.textEditorFormatBlockLocal)(this, tag, config),
|
|
59
|
+
};
|
|
43
60
|
if (config.onSelectionChange) {
|
|
44
61
|
const actions = config.onSelectionChange;
|
|
45
62
|
this.bindActions("selection-change", actions);
|
|
@@ -106,10 +106,11 @@ class ItemList {
|
|
|
106
106
|
}
|
|
107
107
|
const contextSubscription = new rxjs_1.Subscription();
|
|
108
108
|
this.contextSubscription = contextSubscription;
|
|
109
|
-
contextSubscription.add(this.config.ref.context
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
109
|
+
contextSubscription.add(this.config.ref.context
|
|
110
|
+
.watch()
|
|
111
|
+
.pipe((0, rxjs_1.skip)(1))
|
|
112
|
+
.subscribe(() => {
|
|
113
|
+
this.syncToHost(true);
|
|
113
114
|
}));
|
|
114
115
|
}
|
|
115
116
|
/**
|
|
@@ -179,13 +180,14 @@ class ItemList {
|
|
|
179
180
|
generateItems(instance) {
|
|
180
181
|
const cache = this.getInstanceState(instance).itemsCache;
|
|
181
182
|
const value = (0, types_1.getItemListValue)(this.config.ref);
|
|
182
|
-
const store =
|
|
183
|
-
for (
|
|
184
|
-
|
|
183
|
+
const store = {};
|
|
184
|
+
for (let index = 0; index < value.length; index++) {
|
|
185
|
+
const cacheKey = this.itemCacheKey(value[index]);
|
|
186
|
+
store[cacheKey] = { index: `${index}` };
|
|
185
187
|
}
|
|
186
|
-
|
|
188
|
+
this.indexContext.replace(store);
|
|
189
|
+
return value.map((data) => {
|
|
187
190
|
const cacheKey = this.itemCacheKey(data);
|
|
188
|
-
store[cacheKey] = { index: `${index}` };
|
|
189
191
|
let item = cache.get(cacheKey);
|
|
190
192
|
if (!item) {
|
|
191
193
|
item = this.config.generator({
|
|
@@ -196,8 +198,6 @@ class ItemList {
|
|
|
196
198
|
}
|
|
197
199
|
return { id: this.trackId(data), item };
|
|
198
200
|
});
|
|
199
|
-
this.indexContext.syncIndexStoreFromMutations();
|
|
200
|
-
return items;
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
exports.ItemList = ItemList;
|
|
@@ -4,8 +4,11 @@ type ItemListIndexContext = Record<string, {
|
|
|
4
4
|
}>;
|
|
5
5
|
/** Контекст индексов элементов ItemList; данные не загружаются снаружи. */
|
|
6
6
|
export declare class ItemListIndexStore<T extends JsonObject = ItemListIndexContext> extends Context<T> {
|
|
7
|
+
/**
|
|
8
|
+
* Синхронно поднимает хранилище до async {@link init}, чтобы `replace` в serialize
|
|
9
|
+
* не перезаписывался пустым `{}` из `initDataCallback`.
|
|
10
|
+
*/
|
|
7
11
|
initSync(): this;
|
|
8
|
-
syncIndexStoreFromMutations(): void;
|
|
9
12
|
constructor(preload: boolean);
|
|
10
13
|
}
|
|
11
14
|
export {};
|
|
@@ -6,16 +6,18 @@ const v4_1 = require("zod/v4");
|
|
|
6
6
|
const core_1 = require("../../core");
|
|
7
7
|
/** Контекст индексов элементов ItemList; данные не загружаются снаружи. */
|
|
8
8
|
class ItemListIndexStore extends core_1.Context {
|
|
9
|
+
/**
|
|
10
|
+
* Синхронно поднимает хранилище до async {@link init}, чтобы `replace` в serialize
|
|
11
|
+
* не перезаписывался пустым `{}` из `initDataCallback`.
|
|
12
|
+
*/
|
|
9
13
|
initSync() {
|
|
10
|
-
if (this.inited())
|
|
14
|
+
if (this.inited()) {
|
|
11
15
|
return this;
|
|
16
|
+
}
|
|
12
17
|
this.data$ = new rxjs_1.BehaviorSubject({});
|
|
13
18
|
this.subscribeToDataChanges();
|
|
14
19
|
return this;
|
|
15
20
|
}
|
|
16
|
-
syncIndexStoreFromMutations() {
|
|
17
|
-
super.emitAfterInPlaceMutation();
|
|
18
|
-
}
|
|
19
21
|
constructor(preload) {
|
|
20
22
|
super({
|
|
21
23
|
data: async () => ({}),
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import type { Paths, PathValue } from "ts-essentials";
|
|
2
2
|
import type { ComponentTreeNode, ContextRef, JsonObject } from "../../core";
|
|
3
3
|
export type ListArrayValue = readonly unknown[] | unknown[];
|
|
4
|
-
type ItemArray<RefType extends ContextRef<any, any>> = Extract<ReturnType<RefType["
|
|
4
|
+
type ItemArray<RefType extends ContextRef<any, any>> = Extract<ReturnType<RefType["get"]>, ListArrayValue>;
|
|
5
5
|
export type CompatibleItemListRef<RefType extends ContextRef<any, any>> = [
|
|
6
6
|
ItemArray<RefType>
|
|
7
7
|
] extends [never] ? never : RefType;
|
|
8
8
|
export type ItemListItemData<RefType extends ContextRef<any, any>> = ItemArray<RefType>[number];
|
|
9
|
-
export type ItemListTypedItemRef<ContextType extends JsonObject, PathType extends string, ValueType> = Omit<ContextRef<any, any>, "path" | "ref" | "
|
|
9
|
+
export type ItemListTypedItemRef<ContextType extends JsonObject, PathType extends string, ValueType> = Omit<ContextRef<any, any>, "path" | "ref" | "get"> & {
|
|
10
10
|
readonly path: PathType;
|
|
11
11
|
readonly __valueType?: ValueType;
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
get(): ValueType;
|
|
13
|
+
get(): JsonObject;
|
|
14
14
|
ref<K extends Paths<ValueType>>(path: K): ItemListTypedItemRef<ContextType, `${PathType}.${K & string}`, PathValue<ValueType, K>>;
|
|
15
15
|
ref<P2 extends string>(path: ContextRef<ContextType, P2>): ContextRef<ContextType, `${PathType}.${P2}`>;
|
|
16
16
|
};
|
|
@@ -35,6 +35,6 @@ type ItemListIndexContextRecord = Record<string, {
|
|
|
35
35
|
index: `${number}`;
|
|
36
36
|
}>;
|
|
37
37
|
export declare function createItemListItemLink<ContextType extends JsonObject, PathType extends string, RefType extends ContextRef<ContextType, PathType> & {
|
|
38
|
-
|
|
38
|
+
get(): ListArrayValue | undefined;
|
|
39
39
|
}>(ref: RefType, indexRef: ContextRef<ItemListIndexContextRecord, `${string}.index`>): ItemListItemLink<RefType>;
|
|
40
40
|
export {};
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getItemListValue = getItemListValue;
|
|
4
4
|
exports.createItemListItemLink = createItemListItemLink;
|
|
5
5
|
function getItemListValue(ref) {
|
|
6
|
-
const rawValue = ref.
|
|
6
|
+
const rawValue = ref.get();
|
|
7
7
|
return Array.isArray(rawValue)
|
|
8
8
|
? rawValue
|
|
9
9
|
: [];
|
package/dist/components/map.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { type FlexItemSpec } from "@matreshka/shared/types/flex-item";
|
|
|
5
5
|
import type { MapConfig } from "@matreshka/shared/types/map-config";
|
|
6
6
|
import type { NestedItemBase } from "@matreshka/shared/types/nested-item-base";
|
|
7
7
|
import { Componentable, ComponentInstance, ComponentTreeNode, StandaloneComponent } from "../core";
|
|
8
|
+
import type { ActionConfig } from "../core/actions/action";
|
|
8
9
|
import { Component, ComponentInitConfig, ComponentProperties, ServerComponentAction } from "./component";
|
|
9
10
|
import type { ItemList } from "./item-list/item-list";
|
|
10
11
|
import type { ItemListHost } from "./item-list/item-list-host";
|
|
@@ -57,6 +58,16 @@ type DefaultInitConfigType = MapInitConfig<Map>;
|
|
|
57
58
|
export declare class Map<InitConfigType extends MapInitConfig<any> = DefaultInitConfigType, PropertiesType extends MapProperties = MapProperties> extends Component<InitConfigType, PropertiesType> implements StandaloneComponent, ItemListHost {
|
|
58
59
|
private readonly markersSlot;
|
|
59
60
|
private readonly itemListHostAdapter;
|
|
61
|
+
readonly local: {
|
|
62
|
+
setCenter: (center: {
|
|
63
|
+
latitude: number;
|
|
64
|
+
longitude: number;
|
|
65
|
+
altitude?: number;
|
|
66
|
+
}, config?: ActionConfig) => import("../core/actions/component-local-actions").MapSetCenterLocalAction;
|
|
67
|
+
setZoom: (zoom: number, config?: ActionConfig) => import("../core/actions/component-local-actions").MapSetZoomLocalAction;
|
|
68
|
+
zoomIn: (config?: ActionConfig) => import("../core/actions/component-local-actions").MapZoomInLocalAction;
|
|
69
|
+
zoomOut: (config?: ActionConfig) => import("../core/actions/component-local-actions").MapZoomOutLocalAction;
|
|
70
|
+
};
|
|
60
71
|
setCenter(center: {
|
|
61
72
|
latitude: number;
|
|
62
73
|
longitude: number;
|
package/dist/components/map.js
CHANGED
|
@@ -7,6 +7,7 @@ const map_set_zoom_message_1 = require("@matreshka/shared/messages/bff-to-client
|
|
|
7
7
|
const map_zoom_in_message_1 = require("@matreshka/shared/messages/bff-to-client/components/map/map-zoom-in-message");
|
|
8
8
|
const map_zoom_out_message_1 = require("@matreshka/shared/messages/bff-to-client/components/map/map-zoom-out-message");
|
|
9
9
|
const flex_item_1 = require("@matreshka/shared/types/flex-item");
|
|
10
|
+
const component_local_actions_1 = require("../core/actions/component-local-actions");
|
|
10
11
|
const component_1 = require("./component");
|
|
11
12
|
const item_list_1 = require("./item-list");
|
|
12
13
|
const flatten_nested_items_1 = require("./item-list/flatten-nested-items");
|
|
@@ -34,6 +35,12 @@ class Map extends component_1.Component {
|
|
|
34
35
|
source: [],
|
|
35
36
|
itemLists: [],
|
|
36
37
|
};
|
|
38
|
+
this.local = {
|
|
39
|
+
setCenter: (center, config) => (0, component_local_actions_1.mapSetCenterLocal)(this, center, config),
|
|
40
|
+
setZoom: (zoom, config) => (0, component_local_actions_1.mapSetZoomLocal)(this, zoom, config),
|
|
41
|
+
zoomIn: (config) => (0, component_local_actions_1.mapZoomInLocal)(this, config),
|
|
42
|
+
zoomOut: (config) => (0, component_local_actions_1.mapZoomOutLocal)(this, config),
|
|
43
|
+
};
|
|
37
44
|
this.markersSlot.source = markersSlot.source;
|
|
38
45
|
this.markersSlot.itemLists = markersSlot.itemLists;
|
|
39
46
|
(0, item_list_1.attachItemListsToHost)(this, "markers", this.markersSlot);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ServerComponentClass } from "@matreshka/shared/enums/server-component-class";
|
|
2
2
|
import type { PopoverConfig } from "@matreshka/shared/types/popover-config";
|
|
3
3
|
import { Componentable, ComponentInstance, ComponentTreeNode, MixedWithCallbacksArray } from "../core";
|
|
4
|
+
import type { ActionConfig } from "../core/actions/action";
|
|
4
5
|
import { EntryComponent, EntryComponentInitConfig, EntryComponentProperties } from "./entry-component";
|
|
5
6
|
import { PopoverPositionArea } from "./enum/popover-position-area";
|
|
6
7
|
export type PopoverProperties = {
|
|
@@ -36,6 +37,10 @@ export declare function popover(config: DefaultInitConfigType): Popover;
|
|
|
36
37
|
* На клиенте рендерится через [Popover API](https://doka.guide/html/popover/) (`popover="auto"`).
|
|
37
38
|
*/
|
|
38
39
|
export declare class Popover<InitConfigType extends PopoverInitConfig<any> = DefaultInitConfigType, PropertiesType extends PopoverProperties = PopoverProperties> extends EntryComponent<InitConfigType, PropertiesType> {
|
|
40
|
+
/** Локальные (client-only) действия entry-popover. */
|
|
41
|
+
readonly local: {
|
|
42
|
+
close: (config?: ActionConfig) => import("../core/actions/close-entry").CloseEntry;
|
|
43
|
+
};
|
|
39
44
|
/**
|
|
40
45
|
* Возвращает уникальный идентификатор класса компонента.
|
|
41
46
|
*
|
|
@@ -5,6 +5,7 @@ exports.popover = popover;
|
|
|
5
5
|
const server_component_class_1 = require("@matreshka/shared/enums/server-component-class");
|
|
6
6
|
const popover_close_message_1 = require("@matreshka/shared/messages/bff-to-client/components/popover/popover-close-message");
|
|
7
7
|
const core_1 = require("../core");
|
|
8
|
+
const close_entry_1 = require("../core/actions/close-entry");
|
|
8
9
|
const entry_component_1 = require("./entry-component");
|
|
9
10
|
function popover(arg0, arg1) {
|
|
10
11
|
if (arg1 !== undefined) {
|
|
@@ -28,6 +29,13 @@ function popover(arg0, arg1) {
|
|
|
28
29
|
* На клиенте рендерится через [Popover API](https://doka.guide/html/popover/) (`popover="auto"`).
|
|
29
30
|
*/
|
|
30
31
|
class Popover extends entry_component_1.EntryComponent {
|
|
32
|
+
constructor() {
|
|
33
|
+
super(...arguments);
|
|
34
|
+
/** Локальные (client-only) действия entry-popover. */
|
|
35
|
+
this.local = {
|
|
36
|
+
close: (config) => (0, close_entry_1.closeEntry)(this, config),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
31
39
|
/**
|
|
32
40
|
* Возвращает уникальный идентификатор класса компонента.
|
|
33
41
|
*
|
|
@@ -13,6 +13,7 @@ import type { RadiusPx } from "@matreshka/shared/types/radius-px";
|
|
|
13
13
|
import type { StackConfig } from "@matreshka/shared/types/stack-config";
|
|
14
14
|
import type { StackScroll } from "@matreshka/shared/types/stack-scroll";
|
|
15
15
|
import { Componentable, ComponentInstance, ComponentTreeNode, MixedWithCallbacksArray, StandaloneComponent } from "../core";
|
|
16
|
+
import type { ActionConfig } from "../core/actions/action";
|
|
16
17
|
import { Component, ComponentInitConfig, ComponentProperties, ServerComponentAction } from "./component";
|
|
17
18
|
export { DimensionalUnit } from "@matreshka/shared/enums/dimensional-unit";
|
|
18
19
|
export { FlexWrap } from "@matreshka/shared/enums/flex-wrap";
|
|
@@ -136,6 +137,9 @@ export declare function stack(config: DefaultInitConfigType): Stack;
|
|
|
136
137
|
* Компонент Stack, отображающий вложенные элементы в колонку или строку (`direction`) с возможностью настройки выравнивания, отступов и прокрутки.
|
|
137
138
|
*/
|
|
138
139
|
export declare class Stack<InitConfigType extends StackInitConfig<any> = DefaultInitConfigType, PropertiesType extends StackProperties = StackProperties> extends Component<InitConfigType, PropertiesType> implements StandaloneComponent {
|
|
140
|
+
readonly local: {
|
|
141
|
+
scrollTo: (value: number | ScrollToPosition, smooth?: boolean, config?: ActionConfig) => import("../core/actions/component-local-actions").ScrollToLocalAction;
|
|
142
|
+
};
|
|
139
143
|
constructor(config: InitConfigType);
|
|
140
144
|
/**
|
|
141
145
|
* Возвращает флаг, указывающий, что компонент является самостоятельным.
|
package/dist/components/stack.js
CHANGED
|
@@ -6,6 +6,7 @@ const server_component_class_1 = require("@matreshka/shared/enums/server-compone
|
|
|
6
6
|
const component_scroll_to_message_1 = require("@matreshka/shared/messages/bff-to-client/components/component-scroll-to-message");
|
|
7
7
|
const flex_item_1 = require("@matreshka/shared/types/flex-item");
|
|
8
8
|
const core_1 = require("../core");
|
|
9
|
+
const component_local_actions_1 = require("../core/actions/component-local-actions");
|
|
9
10
|
const component_1 = require("./component");
|
|
10
11
|
var dimensional_unit_1 = require("@matreshka/shared/enums/dimensional-unit");
|
|
11
12
|
Object.defineProperty(exports, "DimensionalUnit", { enumerable: true, get: function () { return dimensional_unit_1.DimensionalUnit; } });
|
|
@@ -44,6 +45,9 @@ function stack(arg0, arg1) {
|
|
|
44
45
|
class Stack extends component_1.Component {
|
|
45
46
|
constructor(config) {
|
|
46
47
|
super(config);
|
|
48
|
+
this.local = {
|
|
49
|
+
scrollTo: (value, smooth = false, config) => (0, component_local_actions_1.scrollToLocal)(this, value, smooth, config),
|
|
50
|
+
};
|
|
47
51
|
if (config.onClick) {
|
|
48
52
|
this.bindActions("click", config.onClick);
|
|
49
53
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Componentable } from "../types/componentable";
|
|
2
|
+
import { ActionConfig } from "./action";
|
|
3
|
+
import { LocalAction } from "./local-action";
|
|
4
|
+
/**
|
|
5
|
+
* Локальное закрытие entry (dialog / popover) на клиенте без round-trip на BFF.
|
|
6
|
+
* {@link target} в payload — явный instance id или базовый id компонента.
|
|
7
|
+
*/
|
|
8
|
+
export declare class CloseEntry extends LocalAction {
|
|
9
|
+
private readonly entry;
|
|
10
|
+
private readonly target;
|
|
11
|
+
constructor(entry: Componentable, config?: ActionConfig, target?: string);
|
|
12
|
+
class(): string;
|
|
13
|
+
payload(): object;
|
|
14
|
+
}
|
|
15
|
+
export declare function closeEntry(entry: Componentable, config?: ActionConfig, target?: string): CloseEntry;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CloseEntry = void 0;
|
|
4
|
+
exports.closeEntry = closeEntry;
|
|
5
|
+
const local_action_1 = require("./local-action");
|
|
6
|
+
/**
|
|
7
|
+
* Локальное закрытие entry (dialog / popover) на клиенте без round-trip на BFF.
|
|
8
|
+
* {@link target} в payload — явный instance id или базовый id компонента.
|
|
9
|
+
*/
|
|
10
|
+
class CloseEntry extends local_action_1.LocalAction {
|
|
11
|
+
constructor(entry, config = {}, target = entry.id) {
|
|
12
|
+
super(config.conditions);
|
|
13
|
+
this.entry = entry;
|
|
14
|
+
this.target = target;
|
|
15
|
+
}
|
|
16
|
+
class() {
|
|
17
|
+
return "close-entry";
|
|
18
|
+
}
|
|
19
|
+
payload() {
|
|
20
|
+
return {
|
|
21
|
+
target: this.target,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.CloseEntry = CloseEntry;
|
|
26
|
+
function closeEntry(entry, config = {}, target = entry.id) {
|
|
27
|
+
return new CloseEntry(entry, config, target);
|
|
28
|
+
}
|