@vnejs/plugins.controllers.scenario.interface.controls 0.0.0-stage → 0.2.11
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/index.d.ts +1 -0
- package/dist/index.js +6 -0
- package/dist/modules/controller.d.ts +40 -0
- package/dist/modules/controller.js +69 -0
- package/dist/modules/view.d.ts +9 -0
- package/dist/modules/view.js +8 -0
- package/dist/types.d.ts +17 -0
- package/dist/types.js +1 -0
- package/dist/utils/interface.controls.d.ts +3 -0
- package/dist/utils/interface.controls.js +1 -0
- package/dist/view/index.d.ts +3 -0
- package/dist/view/index.js +14 -0
- package/package.json +57 -4
- package/src/index.ts +10 -0
- package/src/modules/controller.ts +115 -0
- package/src/modules/view.ts +26 -0
- package/src/tests/controller.test.ts +71 -0
- package/src/tests/setup.ts +45 -0
- package/src/types.ts +31 -0
- package/src/utils/interface.controls.ts +17 -0
- package/src/view/index.tsx +65 -0
- package/tsconfig.json +10 -0
- package/README.md +0 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@vnejs/contracts.controllers.scenario.interface.controls";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import "@vnejs/contracts.controllers.scenario.interface.controls";
|
|
2
|
+
import { regPlugin } from "@vnejs/registry";
|
|
3
|
+
import { PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.controllers.scenario.interface.controls";
|
|
4
|
+
import { InterfaceControlsViewController } from "./modules/controller.js";
|
|
5
|
+
import { InterfaceControlsView } from "./modules/view.js";
|
|
6
|
+
regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, params: PARAMS }, [InterfaceControlsViewController, InterfaceControlsView]);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ModuleController } from "@vnejs/module.components";
|
|
2
|
+
import type { InterfaceControlsIconItem } from "@vnejs/contracts.controllers.scenario.interface.controls";
|
|
3
|
+
import type { InterfaceControlsClickPayload, InterfaceControlsForcePayload, InterfaceControlsIconSrc } from "@vnejs/contracts.controllers.scenario.interface.controls";
|
|
4
|
+
import type { InterfaceControlsPluginConstants, InterfaceControlsPluginEvents, InterfaceControlsPluginParams, InterfaceControlsPluginSettings } from "../types.js";
|
|
5
|
+
import type { InterfaceControlsPluginState } from "../types.js";
|
|
6
|
+
export declare class InterfaceControlsViewController extends ModuleController<InterfaceControlsPluginEvents, InterfaceControlsPluginConstants, InterfaceControlsPluginSettings, InterfaceControlsPluginParams, InterfaceControlsPluginState> {
|
|
7
|
+
name: string;
|
|
8
|
+
EVENT_UPDATE_VIEW: "vne:interface_controls:update";
|
|
9
|
+
EVENT_UPDATE_STATE: "vne:interface_controls:update_state";
|
|
10
|
+
EVENT_UPDATE_FAST: "vne:interface_controls:update_fast";
|
|
11
|
+
EVENT_UPDATE_FORCE: "vne:interface_controls:update_force";
|
|
12
|
+
EVENT_SHOW: "vne:interface_controls:show";
|
|
13
|
+
EVENT_HIDE: "vne:interface_controls:hide";
|
|
14
|
+
SHOULD_CLEAR_STATE_ON_CLEANUP: boolean;
|
|
15
|
+
CONTROLS: {
|
|
16
|
+
abstract_interface_hide: () => undefined;
|
|
17
|
+
abstract_arrow_right: () => undefined;
|
|
18
|
+
abstract_arrow_bottom: () => undefined;
|
|
19
|
+
};
|
|
20
|
+
CONTROLS_UNVISIBLE: {
|
|
21
|
+
abstract_any: () => undefined;
|
|
22
|
+
};
|
|
23
|
+
CONTROLS_EXTENSIONS: {
|
|
24
|
+
[x: string]: (controls: unknown) => void | Promise<void>;
|
|
25
|
+
};
|
|
26
|
+
CONTROLS_INDEX: number;
|
|
27
|
+
CONTROLS_CHECK_NEXT: boolean;
|
|
28
|
+
subscribe: () => void;
|
|
29
|
+
onClick: ({ index }?: InterfaceControlsClickPayload) => void | undefined;
|
|
30
|
+
onIcons: () => Promise<InterfaceControlsIconSrc[]>;
|
|
31
|
+
onShowChanged: ({ isForce }?: InterfaceControlsForcePayload) => false | Promise<import("@vnejs/registry").EmitResults<"vne:interface_controls:hide" | "vne:interface_controls:show">> | undefined;
|
|
32
|
+
onViewChanged: ({ isForce }?: InterfaceControlsForcePayload) => false | Promise<import("@vnejs/registry").EmitResults<string>> | undefined;
|
|
33
|
+
onStateChanged: () => Promise<import("@vnejs/registry").EmitResults<string>> | undefined;
|
|
34
|
+
onVisibleChanged: ({ isForce }?: InterfaceControlsForcePayload) => Promise<false | import("@vnejs/registry").EmitResults<string> | undefined>;
|
|
35
|
+
onMemoryCleared: () => Promise<import("@vnejs/registry").EmitResults<string> | undefined>;
|
|
36
|
+
getDefaultState: () => InterfaceControlsPluginState;
|
|
37
|
+
onShowBefore: () => Promise<void>;
|
|
38
|
+
toggleUnvisibleControls: (isVisible: boolean) => Promise<import("@vnejs/registry").EmitResults<"vne:controls:pop" | "vne:controls:push">> | undefined;
|
|
39
|
+
getOneIconSrcs: ({ icon, iconHover }?: InterfaceControlsIconItem) => Promise<InterfaceControlsIconSrc>;
|
|
40
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { ModuleController } from "@vnejs/module.components";
|
|
2
|
+
export class InterfaceControlsViewController extends ModuleController {
|
|
3
|
+
name = "interface.controls.view.controller";
|
|
4
|
+
EVENT_UPDATE_VIEW = this.EVENTS.INTERFACE_CONTROLS_VIEW.UPDATE;
|
|
5
|
+
EVENT_UPDATE_STATE = this.EVENTS.INTERFACE_CONTROLS_VIEW.UPDATE_STATE;
|
|
6
|
+
EVENT_UPDATE_FAST = this.EVENTS.INTERFACE_CONTROLS_VIEW.UPDATE_FAST;
|
|
7
|
+
EVENT_UPDATE_FORCE = this.EVENTS.INTERFACE_CONTROLS_VIEW.UPDATE_FORCE;
|
|
8
|
+
EVENT_SHOW = this.EVENTS.INTERFACE_CONTROLS_VIEW.SHOW;
|
|
9
|
+
EVENT_HIDE = this.EVENTS.INTERFACE_CONTROLS_VIEW.HIDE;
|
|
10
|
+
SHOULD_CLEAR_STATE_ON_CLEANUP = false;
|
|
11
|
+
CONTROLS = {
|
|
12
|
+
[this.CONST.CONTROLS.BUTTONS.INTERFACE_HIDE]: () => void this.emit(this.EVENTS.INTERFACE.VISIBLE),
|
|
13
|
+
[this.CONST.CONTROLS.BUTTONS.ARROW_RIGHT]: () => void this.emit(this.EVENTS.INTERFACE.INTERACT),
|
|
14
|
+
[this.CONST.CONTROLS.BUTTONS.ARROW_BOTTOM]: () => void this.emit(this.EVENTS.INTERFACE.VISIBLE),
|
|
15
|
+
};
|
|
16
|
+
CONTROLS_UNVISIBLE = { [this.CONST.CONTROLS.BUTTONS.ANY]: () => void this.emit(this.EVENTS.INTERFACE.VISIBLE) };
|
|
17
|
+
CONTROLS_EXTENSIONS = this.PARAMS.INTERFACE_CONTROLS_VIEW.CONTROLS_EXTENSIONS;
|
|
18
|
+
CONTROLS_INDEX = this.PARAMS.INTERFACE.ZINDEX + 100;
|
|
19
|
+
CONTROLS_CHECK_NEXT = true;
|
|
20
|
+
subscribe = () => {
|
|
21
|
+
super.subscribe();
|
|
22
|
+
this.on(this.EVENTS.INTERFACE_CONTROLS_VIEW.CLICK, this.onClick);
|
|
23
|
+
this.on(this.EVENTS.INTERFACE_CONTROLS_VIEW.ICONS, this.onIcons);
|
|
24
|
+
this.on(this.EVENTS.INTERFACE.SHOW_CHANGED, this.onShowChanged);
|
|
25
|
+
this.on(this.EVENTS.INTERFACE.VIEW_CHANGED, this.onViewChanged);
|
|
26
|
+
this.on(this.EVENTS.INTERFACE.STATE_CHANGED, this.onStateChanged);
|
|
27
|
+
this.on(this.EVENTS.INTERFACE.VISIBLE_CHANGED, this.onVisibleChanged);
|
|
28
|
+
this.on(this.EVENTS.MEMORY.CLEARED, this.onMemoryCleared);
|
|
29
|
+
};
|
|
30
|
+
onClick = ({ index = 0 } = {}) => this.PARAMS.INTERFACE_CONTROLS_VIEW.ITEMS[index]?.onClick?.(this);
|
|
31
|
+
onIcons = () => Promise.all(this.PARAMS.INTERFACE_CONTROLS_VIEW.ITEMS.map(this.getOneIconSrcs));
|
|
32
|
+
onShowChanged = ({ isForce = false } = {}) => {
|
|
33
|
+
const { isShow = false } = this.globalState.interface;
|
|
34
|
+
const event = isShow ? this.EVENTS.INTERFACE_CONTROLS_VIEW.SHOW : this.EVENTS.INTERFACE_CONTROLS_VIEW.HIDE;
|
|
35
|
+
return this.state.isShow !== isShow && this.emit(event, { isForce });
|
|
36
|
+
};
|
|
37
|
+
onViewChanged = ({ isForce = false } = {}) => {
|
|
38
|
+
const { view = "" } = this.globalState.interface;
|
|
39
|
+
return this.state.view !== view && this.updateStateAndView({ view }, isForce, !isForce);
|
|
40
|
+
};
|
|
41
|
+
onStateChanged = () => {
|
|
42
|
+
const { isShow = false, isVisible = false, view = "" } = this.globalState.interface;
|
|
43
|
+
this.toggleUnvisibleControls(isVisible);
|
|
44
|
+
return this.updateStateAndViewForce({ isVisible, isShow, view });
|
|
45
|
+
};
|
|
46
|
+
onVisibleChanged = async ({ isForce = false } = {}) => {
|
|
47
|
+
const { isVisible = false } = this.globalState.interface;
|
|
48
|
+
this.toggleUnvisibleControls(isVisible);
|
|
49
|
+
return this.state.isVisible !== isVisible && this.updateStateAndView({ isVisible }, isForce, !isForce);
|
|
50
|
+
};
|
|
51
|
+
onMemoryCleared = async () => this.updateStateAndViewFast({ icons: (await this.emitOne(this.EVENTS.INTERFACE_CONTROLS_VIEW.ICONS)) });
|
|
52
|
+
getDefaultState = () => ({ isShow: false, isVisible: false, isForce: false, view: "" });
|
|
53
|
+
onShowBefore = async () => {
|
|
54
|
+
return this.updateState({ icons: (await this.emitOne(this.EVENTS.INTERFACE_CONTROLS_VIEW.ICONS)) });
|
|
55
|
+
};
|
|
56
|
+
toggleUnvisibleControls = (isVisible) => {
|
|
57
|
+
const args = { key: `${this.name}-unvisible`, controls: this.CONTROLS_UNVISIBLE, index: this.CONTROLS_INDEX + 500 };
|
|
58
|
+
return this.emit(isVisible ? this.EVENTS.CONTROLS.POP : this.EVENTS.CONTROLS.PUSH, args);
|
|
59
|
+
};
|
|
60
|
+
getOneIconSrcs = async ({ icon = "", iconHover = "" } = {}) => {
|
|
61
|
+
const result = {};
|
|
62
|
+
const quality = this.shared.settings[this.SETTINGS.LAYER.QUALITY];
|
|
63
|
+
if (icon)
|
|
64
|
+
result.src = (await this.loadImageMedia(`interface/${icon}`, "icons", quality)).src;
|
|
65
|
+
if (iconHover)
|
|
66
|
+
result.srcHover = (await this.loadImageMedia(`interface/${iconHover}`, "icons", quality)).src;
|
|
67
|
+
return result;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ModuleView } from "@vnejs/module.components";
|
|
2
|
+
import type { InterfaceControlsPluginConstants, InterfaceControlsPluginEvents, InterfaceControlsPluginParams, InterfaceControlsPluginSettings } from "../types.js";
|
|
3
|
+
import type { InterfaceControlsPluginState } from "../types.js";
|
|
4
|
+
export declare class InterfaceControlsView extends ModuleView<InterfaceControlsPluginEvents, InterfaceControlsPluginConstants, InterfaceControlsPluginSettings, InterfaceControlsPluginParams, InterfaceControlsPluginState> {
|
|
5
|
+
name: string;
|
|
6
|
+
EVENT_UPDATE_VIEW: "vne:interface_controls:update";
|
|
7
|
+
TRANSITION: number;
|
|
8
|
+
renderFunc: import("@vnejs/module.components").ViewRenderFunc<InterfaceControlsPluginState>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ModuleView } from "@vnejs/module.components";
|
|
2
|
+
import { render } from "../view/index.js";
|
|
3
|
+
export class InterfaceControlsView extends ModuleView {
|
|
4
|
+
name = "interface.controls.view";
|
|
5
|
+
EVENT_UPDATE_VIEW = this.EVENTS.INTERFACE_CONTROLS_VIEW.UPDATE;
|
|
6
|
+
TRANSITION = this.PARAMS.INTERFACE.TRANSITION;
|
|
7
|
+
renderFunc = render;
|
|
8
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ModuleComponentsConstants, ModuleComponentsEvents, ModuleComponentsParams, ModuleComponentsSettings } from "@vnejs/module.components";
|
|
2
|
+
import type { SettingsKeys as LayerSettingsKeys, PluginName as LayerPluginName } from "@vnejs/contracts.canvas.layer";
|
|
3
|
+
import type { Params as InterfaceParams, PluginName as InterfacePluginName, SubscribeEvents as InterfaceSubscribeEvents } from "@vnejs/contracts.controllers.scenario.interface";
|
|
4
|
+
import type { InterfaceControlsIconSrc, Params, PluginName, SubscribeEvents } from "@vnejs/contracts.controllers.scenario.interface.controls";
|
|
5
|
+
import type { Constants as ControlsConstants, PluginName as ControlsPluginName, SubscribeEvents as ControlsSubscribeEvents } from "@vnejs/contracts.controls";
|
|
6
|
+
import type { PluginName as MemoryPluginName, SubscribeEvents as MemorySubscribeEvents } from "@vnejs/contracts.core.memory";
|
|
7
|
+
export type InterfaceControlsPluginEvents = ModuleComponentsEvents & Record<PluginName, SubscribeEvents> & Record<InterfacePluginName, InterfaceSubscribeEvents> & Record<ControlsPluginName, ControlsSubscribeEvents> & Record<MemoryPluginName, MemorySubscribeEvents>;
|
|
8
|
+
export type InterfaceControlsPluginConstants = ModuleComponentsConstants & Record<ControlsPluginName, ControlsConstants>;
|
|
9
|
+
export type InterfaceControlsPluginSettings = ModuleComponentsSettings & Record<LayerPluginName, LayerSettingsKeys>;
|
|
10
|
+
export type InterfaceControlsPluginParams = ModuleComponentsParams & Record<PluginName, Params> & Record<InterfacePluginName, InterfaceParams>;
|
|
11
|
+
export type InterfaceControlsPluginState = {
|
|
12
|
+
isShow: boolean;
|
|
13
|
+
isVisible: boolean;
|
|
14
|
+
isForce: boolean;
|
|
15
|
+
view: string;
|
|
16
|
+
icons?: InterfaceControlsIconSrc[];
|
|
17
|
+
};
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ModuleController } from "@vnejs/module.components";
|
|
2
|
+
import type { InterfaceControlsPluginConstants, InterfaceControlsPluginEvents, InterfaceControlsPluginParams, InterfaceControlsPluginSettings, InterfaceControlsPluginState } from "../types.js";
|
|
3
|
+
export type InterfaceControlsViewController = ModuleController<InterfaceControlsPluginEvents, InterfaceControlsPluginConstants, InterfaceControlsPluginSettings, InterfaceControlsPluginParams, InterfaceControlsPluginState>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createElement as _createElement } from "react";
|
|
3
|
+
import { Flex, Icon, View, createRenderFunc, useIsForceHook, useStoreState } from "@vnejs/uis.react";
|
|
4
|
+
const renderIcon = ({ src, srcHover, props }, i) => (_createElement(Icon, { ...props, srcHover: srcHover, src: src, value: i, key: src }));
|
|
5
|
+
const InterfaceControls = ({ store, onMount, emit, EVENTS, PARAMS }) => {
|
|
6
|
+
const { isShow = false, isVisible = false, isForce = false, view = "", icons = [] } = useStoreState(store, onMount);
|
|
7
|
+
const isRealForce = useIsForceHook(isForce);
|
|
8
|
+
const onClick = (index = 0) => emit(EVENTS.INTERFACE_CONTROLS_VIEW.CLICK, { index });
|
|
9
|
+
const transition = isRealForce ? 0 : PARAMS.INTERFACE.TRANSITION;
|
|
10
|
+
const propsByView = PARAMS.INTERFACE_CONTROLS_VIEW.VIEW_PROPS[view] || {};
|
|
11
|
+
const propsIcon = { ...propsByView.icon, transition, onClick };
|
|
12
|
+
return (_jsx(View, { ...propsByView.view, isShow: isShow, isForce: isRealForce, transition: transition, isHidden: !isVisible, zIndex: PARAMS.INTERFACE.ZINDEX + 100, children: _jsx(Flex, { ...propsByView.flex, children: icons.map(({ src, srcHover }, i) => renderIcon({ src, srcHover, props: propsIcon }, i)) }) }));
|
|
13
|
+
};
|
|
14
|
+
export const render = createRenderFunc(InterfaceControls);
|
package/package.json
CHANGED
|
@@ -1,6 +1,59 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vnejs/plugins.controllers.scenario.interface.controls",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.11",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"src",
|
|
18
|
+
"tsconfig.json"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"test": "npx @vnejs/monorepo test",
|
|
22
|
+
"build": "npx @vnejs/monorepo package",
|
|
23
|
+
"publish:major:plugin": "npm run publish:major",
|
|
24
|
+
"publish:minor:plugin": "npm run publish:minor",
|
|
25
|
+
"publish:patch:plugin": "npm run publish:patch",
|
|
26
|
+
"publish:major": "npx @vnejs/monorepo publish major --access public",
|
|
27
|
+
"publish:minor": "npx @vnejs/monorepo publish minor --access public",
|
|
28
|
+
"publish:patch": "npx @vnejs/monorepo publish patch --access public"
|
|
29
|
+
},
|
|
30
|
+
"author": "",
|
|
31
|
+
"license": "ISC",
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@vnejs/contracts.controllers.scenario.interface.controls": "~0.2.0",
|
|
34
|
+
"@vnejs/contracts.controllers.scenario.interface": "~0.2.0"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"@vnejs/helpers": "~0.2.0",
|
|
38
|
+
"@vnejs/module.core": "~0.2.0",
|
|
39
|
+
"@vnejs/module.components": "~0.2.0",
|
|
40
|
+
"@vnejs/contracts.canvas.layer": "~0.2.0",
|
|
41
|
+
"@vnejs/contracts.controls": "~0.2.0",
|
|
42
|
+
"@vnejs/registry": "~0.2.0",
|
|
43
|
+
"@vnejs/uis.react": "~0.2.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@vnejs/configs.ts-common": "~0.2.0",
|
|
47
|
+
"@vnejs/configs.vitest": "~0.2.0",
|
|
48
|
+
"@vnejs/test-utils": "~0.2.0",
|
|
49
|
+
"@vnejs/contracts.canvas.layer": "~0.2.0",
|
|
50
|
+
"@vnejs/contracts.controls": "~0.2.0",
|
|
51
|
+
"@vnejs/helpers": "~0.2.0",
|
|
52
|
+
"@vnejs/module.core": "~0.2.0",
|
|
53
|
+
"@vnejs/module.components": "~0.2.0",
|
|
54
|
+
"@vnejs/registry": "~0.2.0",
|
|
55
|
+
"@vnejs/uis.react": "~0.2.0",
|
|
56
|
+
"@vnejs/contracts.controllers.scenario.interface.controls": "~0.2.0",
|
|
57
|
+
"@vnejs/contracts.controllers.scenario.interface": "~0.2.0"
|
|
58
|
+
}
|
|
59
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "@vnejs/contracts.controllers.scenario.interface.controls";
|
|
2
|
+
|
|
3
|
+
import { regPlugin } from "@vnejs/registry";
|
|
4
|
+
|
|
5
|
+
import { PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.controllers.scenario.interface.controls";
|
|
6
|
+
|
|
7
|
+
import { InterfaceControlsViewController } from "./modules/controller.js";
|
|
8
|
+
import { InterfaceControlsView } from "./modules/view.js";
|
|
9
|
+
|
|
10
|
+
regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, params: PARAMS }, [InterfaceControlsViewController, InterfaceControlsView]);
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { ModuleController } from "@vnejs/module.components";
|
|
2
|
+
|
|
3
|
+
import type { InterfaceControlsIconItem } from "@vnejs/contracts.controllers.scenario.interface.controls";
|
|
4
|
+
import type {
|
|
5
|
+
InterfaceControlsClickPayload,
|
|
6
|
+
InterfaceControlsForcePayload,
|
|
7
|
+
InterfaceControlsIconSrc,
|
|
8
|
+
} from "@vnejs/contracts.controllers.scenario.interface.controls";
|
|
9
|
+
|
|
10
|
+
import type {
|
|
11
|
+
InterfaceControlsPluginConstants,
|
|
12
|
+
InterfaceControlsPluginEvents,
|
|
13
|
+
InterfaceControlsPluginParams,
|
|
14
|
+
InterfaceControlsPluginSettings,
|
|
15
|
+
} from "../types.js";
|
|
16
|
+
import type { InterfaceControlsPluginState } from "../types.js";
|
|
17
|
+
|
|
18
|
+
export class InterfaceControlsViewController extends ModuleController<
|
|
19
|
+
InterfaceControlsPluginEvents,
|
|
20
|
+
InterfaceControlsPluginConstants,
|
|
21
|
+
InterfaceControlsPluginSettings,
|
|
22
|
+
InterfaceControlsPluginParams,
|
|
23
|
+
InterfaceControlsPluginState
|
|
24
|
+
> {
|
|
25
|
+
name = "interface.controls.view.controller";
|
|
26
|
+
|
|
27
|
+
EVENT_UPDATE_VIEW = this.EVENTS.INTERFACE_CONTROLS_VIEW.UPDATE;
|
|
28
|
+
EVENT_UPDATE_STATE = this.EVENTS.INTERFACE_CONTROLS_VIEW.UPDATE_STATE;
|
|
29
|
+
EVENT_UPDATE_FAST = this.EVENTS.INTERFACE_CONTROLS_VIEW.UPDATE_FAST;
|
|
30
|
+
EVENT_UPDATE_FORCE = this.EVENTS.INTERFACE_CONTROLS_VIEW.UPDATE_FORCE;
|
|
31
|
+
EVENT_SHOW = this.EVENTS.INTERFACE_CONTROLS_VIEW.SHOW;
|
|
32
|
+
EVENT_HIDE = this.EVENTS.INTERFACE_CONTROLS_VIEW.HIDE;
|
|
33
|
+
|
|
34
|
+
SHOULD_CLEAR_STATE_ON_CLEANUP = false;
|
|
35
|
+
|
|
36
|
+
CONTROLS = {
|
|
37
|
+
[this.CONST.CONTROLS.BUTTONS.INTERFACE_HIDE]: () => void this.emit(this.EVENTS.INTERFACE.VISIBLE),
|
|
38
|
+
[this.CONST.CONTROLS.BUTTONS.ARROW_RIGHT]: () => void this.emit(this.EVENTS.INTERFACE.INTERACT),
|
|
39
|
+
[this.CONST.CONTROLS.BUTTONS.ARROW_BOTTOM]: () => void this.emit(this.EVENTS.INTERFACE.VISIBLE),
|
|
40
|
+
};
|
|
41
|
+
CONTROLS_UNVISIBLE = { [this.CONST.CONTROLS.BUTTONS.ANY]: () => void this.emit(this.EVENTS.INTERFACE.VISIBLE) };
|
|
42
|
+
CONTROLS_EXTENSIONS = this.PARAMS.INTERFACE_CONTROLS_VIEW.CONTROLS_EXTENSIONS;
|
|
43
|
+
CONTROLS_INDEX = this.PARAMS.INTERFACE.ZINDEX + 100;
|
|
44
|
+
CONTROLS_CHECK_NEXT = true;
|
|
45
|
+
|
|
46
|
+
subscribe = () => {
|
|
47
|
+
super.subscribe();
|
|
48
|
+
|
|
49
|
+
this.on(this.EVENTS.INTERFACE_CONTROLS_VIEW.CLICK, this.onClick);
|
|
50
|
+
this.on(this.EVENTS.INTERFACE_CONTROLS_VIEW.ICONS, this.onIcons);
|
|
51
|
+
|
|
52
|
+
this.on(this.EVENTS.INTERFACE.SHOW_CHANGED, this.onShowChanged);
|
|
53
|
+
this.on(this.EVENTS.INTERFACE.VIEW_CHANGED, this.onViewChanged);
|
|
54
|
+
this.on(this.EVENTS.INTERFACE.STATE_CHANGED, this.onStateChanged);
|
|
55
|
+
this.on(this.EVENTS.INTERFACE.VISIBLE_CHANGED, this.onVisibleChanged);
|
|
56
|
+
|
|
57
|
+
this.on(this.EVENTS.MEMORY.CLEARED, this.onMemoryCleared);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
onClick = ({ index = 0 }: InterfaceControlsClickPayload = {}) => this.PARAMS.INTERFACE_CONTROLS_VIEW.ITEMS[index]?.onClick?.(this);
|
|
61
|
+
|
|
62
|
+
onIcons = () => Promise.all(this.PARAMS.INTERFACE_CONTROLS_VIEW.ITEMS.map(this.getOneIconSrcs));
|
|
63
|
+
|
|
64
|
+
onShowChanged = ({ isForce = false }: InterfaceControlsForcePayload = {}) => {
|
|
65
|
+
const { isShow = false } = this.globalState.interface;
|
|
66
|
+
const event = isShow ? this.EVENTS.INTERFACE_CONTROLS_VIEW.SHOW : this.EVENTS.INTERFACE_CONTROLS_VIEW.HIDE;
|
|
67
|
+
|
|
68
|
+
return this.state.isShow !== isShow && this.emit(event, { isForce });
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
onViewChanged = ({ isForce = false }: InterfaceControlsForcePayload = {}) => {
|
|
72
|
+
const { view = "" } = this.globalState.interface;
|
|
73
|
+
|
|
74
|
+
return this.state.view !== view && this.updateStateAndView({ view }, isForce, !isForce);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
onStateChanged = () => {
|
|
78
|
+
const { isShow = false, isVisible = false, view = "" } = this.globalState.interface;
|
|
79
|
+
|
|
80
|
+
this.toggleUnvisibleControls(isVisible);
|
|
81
|
+
|
|
82
|
+
return this.updateStateAndViewForce({ isVisible, isShow, view });
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
onVisibleChanged = async ({ isForce = false }: InterfaceControlsForcePayload = {}) => {
|
|
86
|
+
const { isVisible = false } = this.globalState.interface;
|
|
87
|
+
|
|
88
|
+
this.toggleUnvisibleControls(isVisible);
|
|
89
|
+
|
|
90
|
+
return this.state.isVisible !== isVisible && this.updateStateAndView({ isVisible }, isForce, !isForce);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
onMemoryCleared = async () =>
|
|
94
|
+
this.updateStateAndViewFast({ icons: (await this.emitOne(this.EVENTS.INTERFACE_CONTROLS_VIEW.ICONS)) as InterfaceControlsIconSrc[] });
|
|
95
|
+
|
|
96
|
+
getDefaultState = (): InterfaceControlsPluginState => ({ isShow: false, isVisible: false, isForce: false, view: "" });
|
|
97
|
+
|
|
98
|
+
onShowBefore = async () => {
|
|
99
|
+
return this.updateState({ icons: (await this.emitOne(this.EVENTS.INTERFACE_CONTROLS_VIEW.ICONS)) as InterfaceControlsIconSrc[] });
|
|
100
|
+
};
|
|
101
|
+
toggleUnvisibleControls = (isVisible: boolean) => {
|
|
102
|
+
const args = { key: `${this.name}-unvisible`, controls: this.CONTROLS_UNVISIBLE, index: this.CONTROLS_INDEX + 500 };
|
|
103
|
+
|
|
104
|
+
return this.emit(isVisible ? this.EVENTS.CONTROLS.POP : this.EVENTS.CONTROLS.PUSH, args);
|
|
105
|
+
};
|
|
106
|
+
getOneIconSrcs = async ({ icon = "", iconHover = "" }: InterfaceControlsIconItem = {}): Promise<InterfaceControlsIconSrc> => {
|
|
107
|
+
const result: InterfaceControlsIconSrc = {};
|
|
108
|
+
const quality = this.shared.settings[this.SETTINGS.LAYER.QUALITY];
|
|
109
|
+
|
|
110
|
+
if (icon) result.src = (await this.loadImageMedia(`interface/${icon}`, "icons", quality)).src;
|
|
111
|
+
if (iconHover) result.srcHover = (await this.loadImageMedia(`interface/${iconHover}`, "icons", quality)).src;
|
|
112
|
+
|
|
113
|
+
return result;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ModuleView } from "@vnejs/module.components";
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
InterfaceControlsPluginConstants,
|
|
5
|
+
InterfaceControlsPluginEvents,
|
|
6
|
+
InterfaceControlsPluginParams,
|
|
7
|
+
InterfaceControlsPluginSettings,
|
|
8
|
+
} from "../types.js";
|
|
9
|
+
import type { InterfaceControlsPluginState } from "../types.js";
|
|
10
|
+
|
|
11
|
+
import { render } from "../view/index.js";
|
|
12
|
+
export class InterfaceControlsView extends ModuleView<
|
|
13
|
+
InterfaceControlsPluginEvents,
|
|
14
|
+
InterfaceControlsPluginConstants,
|
|
15
|
+
InterfaceControlsPluginSettings,
|
|
16
|
+
InterfaceControlsPluginParams,
|
|
17
|
+
InterfaceControlsPluginState
|
|
18
|
+
> {
|
|
19
|
+
name = "interface.controls.view";
|
|
20
|
+
|
|
21
|
+
EVENT_UPDATE_VIEW = this.EVENTS.INTERFACE_CONTROLS_VIEW.UPDATE;
|
|
22
|
+
|
|
23
|
+
TRANSITION = this.PARAMS.INTERFACE.TRANSITION;
|
|
24
|
+
|
|
25
|
+
renderFunc = render;
|
|
26
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { spyEvent } from "@vnejs/test-utils";
|
|
4
|
+
|
|
5
|
+
import { InterfaceControlsViewController } from "../modules/controller.js";
|
|
6
|
+
|
|
7
|
+
import { createInterfaceControlsTestModule, INTERFACE_EVENTS, registerInterfaceControlsPluginVne, SUBSCRIBE_EVENTS } from "./setup.js";
|
|
8
|
+
|
|
9
|
+
describe("InterfaceControlsViewController", () => {
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
registerInterfaceControlsPluginVne();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("onShowChanged emits view SHOW when interface opens", async () => {
|
|
15
|
+
const { module, observer } = createInterfaceControlsTestModule(InterfaceControlsViewController, {
|
|
16
|
+
state: { interface: { view: "line", isShow: true, isVisible: true } },
|
|
17
|
+
});
|
|
18
|
+
const show = spyEvent(observer, SUBSCRIBE_EVENTS.SHOW);
|
|
19
|
+
|
|
20
|
+
await observer.emit(INTERFACE_EVENTS.SHOW_CHANGED, {});
|
|
21
|
+
|
|
22
|
+
expect(show).toHaveBeenCalledOnce();
|
|
23
|
+
expect((module as InterfaceControlsViewController).state.isShow).toBe(true);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("onShowChanged emits view HIDE when interface closes", async () => {
|
|
27
|
+
const { module, observer } = createInterfaceControlsTestModule(InterfaceControlsViewController, {
|
|
28
|
+
state: { interface: { view: "line", isShow: false, isVisible: true } },
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
(module as InterfaceControlsViewController).state.isShow = true;
|
|
32
|
+
|
|
33
|
+
const hide = spyEvent(observer, SUBSCRIBE_EVENTS.HIDE);
|
|
34
|
+
|
|
35
|
+
await observer.emit(INTERFACE_EVENTS.SHOW_CHANGED, {});
|
|
36
|
+
|
|
37
|
+
expect(hide).toHaveBeenCalledOnce();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("HIDE keeps isVisible and view for the next SHOW", async () => {
|
|
41
|
+
const { module, observer } = createInterfaceControlsTestModule(InterfaceControlsViewController, {
|
|
42
|
+
state: { interface: { view: "adv", isShow: false, isVisible: true } },
|
|
43
|
+
});
|
|
44
|
+
const controller = module as InterfaceControlsViewController;
|
|
45
|
+
|
|
46
|
+
controller.updateState({ isShow: true, isVisible: true, view: "adv" });
|
|
47
|
+
|
|
48
|
+
await observer.emit(INTERFACE_EVENTS.SHOW_CHANGED, {});
|
|
49
|
+
|
|
50
|
+
expect(controller.state.isShow).toBe(false);
|
|
51
|
+
expect(controller.state.isVisible).toBe(true);
|
|
52
|
+
expect(controller.state.view).toBe("adv");
|
|
53
|
+
|
|
54
|
+
module.globalState.interface.isShow = true;
|
|
55
|
+
|
|
56
|
+
await observer.emit(INTERFACE_EVENTS.SHOW_CHANGED, {});
|
|
57
|
+
|
|
58
|
+
expect(controller.state.isShow).toBe(true);
|
|
59
|
+
expect(controller.state.isVisible).toBe(true);
|
|
60
|
+
expect(controller.state.view).toBe("adv");
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("INTERFACE_HIDE control emits INTERFACE.VISIBLE", () => {
|
|
64
|
+
const { module, observer } = createInterfaceControlsTestModule(InterfaceControlsViewController);
|
|
65
|
+
const visible = spyEvent(observer, INTERFACE_EVENTS.VISIBLE);
|
|
66
|
+
|
|
67
|
+
(module as InterfaceControlsViewController).CONTROLS[(module as InterfaceControlsViewController).CONST.CONTROLS.BUTTONS.INTERFACE_HIDE]();
|
|
68
|
+
|
|
69
|
+
expect(visible).toHaveBeenCalledOnce();
|
|
70
|
+
});
|
|
71
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { SourcesSet } from "@vnejs/sources-set";
|
|
2
|
+
import { createTestModule as baseCreateTestModule, registerCoreVne, registerVnePlugin, stubEvent, stubSilentEvent } from "@vnejs/test-utils";
|
|
3
|
+
|
|
4
|
+
import { CONSTANTS as LAYER_CONST, PLUGIN_NAME as LAYER, SETTINGS_KEYS as LAYER_SETTINGS } from "@vnejs/contracts.canvas.layer";
|
|
5
|
+
import { PARAMS as INTERFACE_PARAMS, PLUGIN_NAME as INTERFACE, SUBSCRIBE_EVENTS as INTERFACE_EVENTS } from "@vnejs/contracts.controllers.scenario.interface";
|
|
6
|
+
import { PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.controllers.scenario.interface.controls";
|
|
7
|
+
import { CONSTANTS as CONTROLS_CONST, PLUGIN_NAME as CONTROLS, SUBSCRIBE_EVENTS as CONTROLS_EVENTS } from "@vnejs/contracts.controls";
|
|
8
|
+
import { SUBSCRIBE_EVENTS as MEDIA_EVENTS } from "@vnejs/contracts.core.media";
|
|
9
|
+
|
|
10
|
+
export const registerInterfaceControlsPluginVne = () => {
|
|
11
|
+
registerCoreVne();
|
|
12
|
+
registerVnePlugin(CONTROLS, { constants: CONTROLS_CONST, events: CONTROLS_EVENTS });
|
|
13
|
+
registerVnePlugin(LAYER, { constants: LAYER_CONST, settings: LAYER_SETTINGS });
|
|
14
|
+
registerVnePlugin(INTERFACE, { events: INTERFACE_EVENTS, params: INTERFACE_PARAMS });
|
|
15
|
+
registerVnePlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, params: PARAMS });
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const createInterfaceControlsTestModule = <T extends Parameters<typeof baseCreateTestModule>[0]>(
|
|
19
|
+
ModuleClass: T,
|
|
20
|
+
options: Parameters<typeof baseCreateTestModule>[1] = {},
|
|
21
|
+
) => {
|
|
22
|
+
const result = baseCreateTestModule(ModuleClass, {
|
|
23
|
+
state: {
|
|
24
|
+
interface: { view: INTERFACE_PARAMS.DEFAULT_VIEW, isShow: false, isVisible: true },
|
|
25
|
+
...(options.state ?? {}),
|
|
26
|
+
},
|
|
27
|
+
shared: {
|
|
28
|
+
settings: { [LAYER_SETTINGS.QUALITY]: LAYER_CONST.QUALITIES.FHD },
|
|
29
|
+
viewForceAnimationSources: new SourcesSet(),
|
|
30
|
+
...(options.shared ?? {}),
|
|
31
|
+
},
|
|
32
|
+
...options,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
stubEvent(result.observer, MEDIA_EVENTS.LOAD, () => ({ src: "icon.png" }));
|
|
36
|
+
stubEvent(result.observer, SUBSCRIBE_EVENTS.ICONS, () => []);
|
|
37
|
+
stubSilentEvent(result.observer, SUBSCRIBE_EVENTS.UPDATE);
|
|
38
|
+
stubSilentEvent(result.observer, INTERFACE_EVENTS.VISIBLE);
|
|
39
|
+
stubSilentEvent(result.observer, CONTROLS_EVENTS.PUSH);
|
|
40
|
+
stubSilentEvent(result.observer, CONTROLS_EVENTS.POP);
|
|
41
|
+
|
|
42
|
+
return result;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export { SUBSCRIBE_EVENTS, PARAMS, PLUGIN_NAME, INTERFACE_EVENTS, INTERFACE_PARAMS };
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ModuleComponentsConstants, ModuleComponentsEvents, ModuleComponentsParams, ModuleComponentsSettings } from "@vnejs/module.components";
|
|
2
|
+
|
|
3
|
+
import type { SettingsKeys as LayerSettingsKeys, PluginName as LayerPluginName } from "@vnejs/contracts.canvas.layer";
|
|
4
|
+
import type {
|
|
5
|
+
Params as InterfaceParams,
|
|
6
|
+
PluginName as InterfacePluginName,
|
|
7
|
+
SubscribeEvents as InterfaceSubscribeEvents,
|
|
8
|
+
} from "@vnejs/contracts.controllers.scenario.interface";
|
|
9
|
+
import type { InterfaceControlsIconSrc, Params, PluginName, SubscribeEvents } from "@vnejs/contracts.controllers.scenario.interface.controls";
|
|
10
|
+
import type { Constants as ControlsConstants, PluginName as ControlsPluginName, SubscribeEvents as ControlsSubscribeEvents } from "@vnejs/contracts.controls";
|
|
11
|
+
import type { PluginName as MemoryPluginName, SubscribeEvents as MemorySubscribeEvents } from "@vnejs/contracts.core.memory";
|
|
12
|
+
|
|
13
|
+
export type InterfaceControlsPluginEvents = ModuleComponentsEvents &
|
|
14
|
+
Record<PluginName, SubscribeEvents> &
|
|
15
|
+
Record<InterfacePluginName, InterfaceSubscribeEvents> &
|
|
16
|
+
Record<ControlsPluginName, ControlsSubscribeEvents> &
|
|
17
|
+
Record<MemoryPluginName, MemorySubscribeEvents>;
|
|
18
|
+
|
|
19
|
+
export type InterfaceControlsPluginConstants = ModuleComponentsConstants & Record<ControlsPluginName, ControlsConstants>;
|
|
20
|
+
|
|
21
|
+
export type InterfaceControlsPluginSettings = ModuleComponentsSettings & Record<LayerPluginName, LayerSettingsKeys>;
|
|
22
|
+
|
|
23
|
+
export type InterfaceControlsPluginParams = ModuleComponentsParams & Record<PluginName, Params> & Record<InterfacePluginName, InterfaceParams>;
|
|
24
|
+
|
|
25
|
+
export type InterfaceControlsPluginState = {
|
|
26
|
+
isShow: boolean;
|
|
27
|
+
isVisible: boolean;
|
|
28
|
+
isForce: boolean;
|
|
29
|
+
view: string;
|
|
30
|
+
icons?: InterfaceControlsIconSrc[];
|
|
31
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ModuleController } from "@vnejs/module.components";
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
InterfaceControlsPluginConstants,
|
|
5
|
+
InterfaceControlsPluginEvents,
|
|
6
|
+
InterfaceControlsPluginParams,
|
|
7
|
+
InterfaceControlsPluginSettings,
|
|
8
|
+
InterfaceControlsPluginState,
|
|
9
|
+
} from "../types.js";
|
|
10
|
+
|
|
11
|
+
export type InterfaceControlsViewController = ModuleController<
|
|
12
|
+
InterfaceControlsPluginEvents,
|
|
13
|
+
InterfaceControlsPluginConstants,
|
|
14
|
+
InterfaceControlsPluginSettings,
|
|
15
|
+
InterfaceControlsPluginParams,
|
|
16
|
+
InterfaceControlsPluginState
|
|
17
|
+
>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { ViewRenderFunc } from "@vnejs/module.components";
|
|
2
|
+
|
|
3
|
+
import { Flex, Icon, View, createRenderFunc, useIsForceHook, useStoreState } from "@vnejs/uis.react";
|
|
4
|
+
|
|
5
|
+
import type { ReactComponentProps } from "@vnejs/uis.react";
|
|
6
|
+
|
|
7
|
+
import type { InterfaceControlsIconSrc } from "@vnejs/contracts.controllers.scenario.interface.controls";
|
|
8
|
+
|
|
9
|
+
import type {
|
|
10
|
+
InterfaceControlsPluginConstants,
|
|
11
|
+
InterfaceControlsPluginEvents,
|
|
12
|
+
InterfaceControlsPluginParams,
|
|
13
|
+
InterfaceControlsPluginSettings,
|
|
14
|
+
} from "../types.js";
|
|
15
|
+
import type { InterfaceControlsPluginState } from "../types.js";
|
|
16
|
+
|
|
17
|
+
type InterfaceControlsComponentProps = ReactComponentProps<
|
|
18
|
+
InterfaceControlsPluginEvents,
|
|
19
|
+
InterfaceControlsPluginConstants,
|
|
20
|
+
InterfaceControlsPluginSettings,
|
|
21
|
+
InterfaceControlsPluginParams,
|
|
22
|
+
InterfaceControlsPluginState
|
|
23
|
+
>;
|
|
24
|
+
|
|
25
|
+
type IconWithProps = InterfaceControlsIconSrc & {
|
|
26
|
+
props: Record<string, unknown>;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const renderIcon = ({ src, srcHover, props }: IconWithProps, i: number) => (
|
|
30
|
+
<Icon
|
|
31
|
+
{...props}
|
|
32
|
+
srcHover={srcHover}
|
|
33
|
+
src={src}
|
|
34
|
+
value={i}
|
|
35
|
+
key={src}
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const InterfaceControls = ({ store, onMount, emit, EVENTS, PARAMS }: InterfaceControlsComponentProps) => {
|
|
40
|
+
const { isShow = false, isVisible = false, isForce = false, view = "", icons = [] } = useStoreState<InterfaceControlsPluginState>(store, onMount);
|
|
41
|
+
|
|
42
|
+
const isRealForce = useIsForceHook(isForce);
|
|
43
|
+
|
|
44
|
+
const onClick = (index = 0) => emit(EVENTS.INTERFACE_CONTROLS_VIEW.CLICK, { index });
|
|
45
|
+
|
|
46
|
+
const transition = isRealForce ? 0 : PARAMS.INTERFACE.TRANSITION;
|
|
47
|
+
|
|
48
|
+
const propsByView = PARAMS.INTERFACE_CONTROLS_VIEW.VIEW_PROPS[view as keyof typeof PARAMS.INTERFACE_CONTROLS_VIEW.VIEW_PROPS] || {};
|
|
49
|
+
const propsIcon = { ...propsByView.icon, transition, onClick };
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<View
|
|
53
|
+
{...propsByView.view}
|
|
54
|
+
isShow={isShow}
|
|
55
|
+
isForce={isRealForce}
|
|
56
|
+
transition={transition}
|
|
57
|
+
isHidden={!isVisible}
|
|
58
|
+
zIndex={PARAMS.INTERFACE.ZINDEX + 100}
|
|
59
|
+
>
|
|
60
|
+
<Flex {...propsByView.flex}>{icons.map(({ src, srcHover }, i) => renderIcon({ src, srcHover, props: propsIcon }, i))}</Flex>
|
|
61
|
+
</View>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const render: ViewRenderFunc<InterfaceControlsPluginState> = createRenderFunc(InterfaceControls);
|
package/tsconfig.json
ADDED
package/README.md
DELETED