@vnejs/plugins.views.settings 0.2.4 → 0.2.5
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.js +4 -4
- package/dist/modules/{arrows.d.ts → fields.controller.arrows.d.ts} +1 -1
- package/dist/modules/{arrows.js → fields.controller.arrows.js} +2 -2
- package/dist/modules/{controller.d.ts → fields.controller.d.ts} +9 -9
- package/dist/modules/{controller.js → fields.controller.js} +9 -9
- package/dist/modules/{view.d.ts → fields.view.d.ts} +4 -5
- package/dist/modules/fields.view.js +9 -0
- package/package.json +1 -1
- package/src/index.ts +4 -4
- package/src/modules/{arrows.ts → fields.controller.arrows.ts} +2 -2
- package/src/modules/{controller.ts → fields.controller.ts} +10 -10
- package/src/modules/{view.ts → fields.view.ts} +6 -5
- package/src/tests/arrows.test.ts +11 -11
- package/src/tests/controller.test.ts +25 -25
- package/dist/modules/view.js +0 -10
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "@vnejs/contracts.views.settings";
|
|
2
2
|
import { regPlugin } from "@vnejs/shared";
|
|
3
3
|
import { PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.views.settings";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, params: PARAMS }, [
|
|
4
|
+
import { SettingsFieldsController } from "./modules/fields.controller.js";
|
|
5
|
+
import { SettingsFieldsControllerArrows } from "./modules/fields.controller.arrows.js";
|
|
6
|
+
import { SettingsFieldsView } from "./modules/fields.view.js";
|
|
7
|
+
regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, params: PARAMS }, [SettingsFieldsController, SettingsFieldsControllerArrows, SettingsFieldsView]);
|
|
@@ -2,7 +2,7 @@ import type { SettingsField } from "@vnejs/contracts.views.settings";
|
|
|
2
2
|
import { ModuleControllerArrowsVertical } from "@vnejs/module.controller.arrows.vertical";
|
|
3
3
|
import type { SettingsViewPluginConstants, SettingsViewPluginEvents, SettingsViewPluginParams, SettingsViewPluginSettings } from "../types.js";
|
|
4
4
|
import type { SettingsViewTabPayload } from "../utils/settings.js";
|
|
5
|
-
export declare class
|
|
5
|
+
export declare class SettingsFieldsControllerArrows extends ModuleControllerArrowsVertical<SettingsViewPluginEvents, SettingsViewPluginConstants, SettingsViewPluginSettings, SettingsViewPluginParams> {
|
|
6
6
|
name: string;
|
|
7
7
|
EVENT_SHOW: "vne:settings_view:show";
|
|
8
8
|
EVENT_HIDE: "vne:settings_view:hide";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ModuleControllerArrowsVertical } from "@vnejs/module.controller.arrows.vertical";
|
|
2
|
-
export class
|
|
2
|
+
export class SettingsFieldsControllerArrows extends ModuleControllerArrowsVertical {
|
|
3
3
|
name = "settings.fields.controller.arrows";
|
|
4
4
|
EVENT_SHOW = this.EVENTS.SETTINGS_VIEW.SHOW;
|
|
5
5
|
EVENT_HIDE = this.EVENTS.SETTINGS_VIEW.HIDE;
|
|
@@ -17,7 +17,7 @@ export class SettingsViewArrows extends ModuleControllerArrowsVertical {
|
|
|
17
17
|
this.currentItem = null;
|
|
18
18
|
return this.emit(this.EVENTS.CONTROLS.PUSH, {
|
|
19
19
|
key: this.name,
|
|
20
|
-
controls: this.
|
|
20
|
+
controls: this.CONTROLS,
|
|
21
21
|
index: this.CONTROLS_ZINDEX + 1,
|
|
22
22
|
checkNext: true,
|
|
23
23
|
});
|
|
@@ -2,10 +2,16 @@ import { ModuleController } from "@vnejs/module.components";
|
|
|
2
2
|
import type { SettingsField } from "@vnejs/contracts.views.settings";
|
|
3
3
|
import type { SettingsViewPluginConstants, SettingsViewPluginEvents, SettingsViewPluginParams, SettingsViewPluginSettings } from "../types.js";
|
|
4
4
|
import type { SettingsViewPluginState, SettingsViewTabContent, SettingsViewTabPayload } from "../utils/settings.js";
|
|
5
|
-
export declare class
|
|
5
|
+
export declare class SettingsFieldsController extends ModuleController<SettingsViewPluginEvents, SettingsViewPluginConstants, SettingsViewPluginSettings, SettingsViewPluginParams, SettingsViewPluginState> {
|
|
6
6
|
name: string;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
EVENT_UPDATE_VIEW: "vne:settings_view:update";
|
|
8
|
+
CONTROLS: {
|
|
9
|
+
abstract_interact: () => undefined;
|
|
10
|
+
abstract_arrow_left: () => undefined;
|
|
11
|
+
abstract_arrow_right: () => undefined;
|
|
12
|
+
};
|
|
13
|
+
CONTROLS_INDEX: number;
|
|
14
|
+
CONTROLS_CHECK_NEXT: boolean;
|
|
9
15
|
tabKeyOf: ({ tabKey, tab }?: SettingsViewTabPayload) => string;
|
|
10
16
|
tabContentOf: (tab: SettingsViewTabPayload["tab"], locs?: Record<string, string>) => SettingsViewTabContent;
|
|
11
17
|
applyTab: (payload?: SettingsViewTabPayload) => {
|
|
@@ -29,12 +35,6 @@ export declare class SettingsViewController extends ModuleController<SettingsVie
|
|
|
29
35
|
onArrowLeft: () => void | false;
|
|
30
36
|
onArrowRight: () => void | false;
|
|
31
37
|
onInteract: () => void;
|
|
32
|
-
controls: {
|
|
33
|
-
abstract_interact: () => undefined;
|
|
34
|
-
abstract_arrow_left: () => undefined;
|
|
35
|
-
abstract_arrow_right: () => undefined;
|
|
36
|
-
};
|
|
37
|
-
controlsCheckNext: boolean;
|
|
38
38
|
subscribe: () => void;
|
|
39
39
|
beforeShow: (payload?: SettingsViewTabPayload) => Promise<void>;
|
|
40
40
|
afterHide: () => void;
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { ModuleController } from "@vnejs/module.components";
|
|
2
|
-
export class
|
|
2
|
+
export class SettingsFieldsController extends ModuleController {
|
|
3
3
|
name = "settings.fields.controller";
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
EVENT_UPDATE_VIEW = this.EVENTS.SETTINGS_VIEW.UPDATE;
|
|
5
|
+
CONTROLS = {
|
|
6
|
+
[this.CONST.CONTROLS.BUTTONS.INTERACT]: () => void this.onInteract(),
|
|
7
|
+
[this.CONST.CONTROLS.BUTTONS.ARROW_LEFT]: () => void this.onArrowLeft(),
|
|
8
|
+
[this.CONST.CONTROLS.BUTTONS.ARROW_RIGHT]: () => void this.onArrowRight(),
|
|
9
|
+
};
|
|
10
|
+
CONTROLS_INDEX = this.PARAMS.SETTINGS_VIEW.ZINDEX;
|
|
11
|
+
CONTROLS_CHECK_NEXT = true;
|
|
6
12
|
tabKeyOf = ({ tabKey, tab } = {}) => tabKey || tab?.titleLocKey || "default";
|
|
7
13
|
tabContentOf = (tab, locs) => ({
|
|
8
14
|
fields: tab?.fields ?? [],
|
|
@@ -137,12 +143,6 @@ export class SettingsViewController extends ModuleController {
|
|
|
137
143
|
if (type === "toggle")
|
|
138
144
|
return void this.emit(this.EVENTS.SETTINGS.SET, { name: settingKey, value: !this.shared.settings[settingKey] });
|
|
139
145
|
};
|
|
140
|
-
controls = {
|
|
141
|
-
[this.CONST.CONTROLS.BUTTONS.INTERACT]: () => void this.onInteract(),
|
|
142
|
-
[this.CONST.CONTROLS.BUTTONS.ARROW_LEFT]: () => void this.onArrowLeft(),
|
|
143
|
-
[this.CONST.CONTROLS.BUTTONS.ARROW_RIGHT]: () => void this.onArrowRight(),
|
|
144
|
-
};
|
|
145
|
-
controlsCheckNext = true;
|
|
146
146
|
subscribe = () => {
|
|
147
147
|
this.on(this.EVENTS.SETTINGS_VIEW.SHOW, this.onShowFields);
|
|
148
148
|
this.on(this.EVENTS.SETTINGS_VIEW.HIDE, this.onHide);
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { ModuleView } from "@vnejs/module.components";
|
|
2
2
|
import type { SettingsViewPluginConstants, SettingsViewPluginEvents, SettingsViewPluginParams, SettingsViewPluginSettings } from "../types.js";
|
|
3
3
|
import type { SettingsViewPluginState } from "../utils/settings.js";
|
|
4
|
-
export declare class
|
|
4
|
+
export declare class SettingsFieldsView extends ModuleView<SettingsViewPluginEvents, SettingsViewPluginConstants, SettingsViewPluginSettings, SettingsViewPluginParams, SettingsViewPluginState> {
|
|
5
5
|
name: string;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
EVENT_UPDATE_VIEW: "vne:settings_view:update";
|
|
7
|
+
LOC_LABEL: string;
|
|
8
|
+
TRANSITION: number;
|
|
9
9
|
renderFunc: import("@vnejs/module.components").ViewRenderFunc<SettingsViewPluginState>;
|
|
10
|
-
updateHandler: (state?: SettingsViewPluginState | undefined) => Promise<void>;
|
|
11
10
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ModuleView } from "@vnejs/module.components";
|
|
2
|
+
import { render } from "../view/index.js";
|
|
3
|
+
export class SettingsFieldsView extends ModuleView {
|
|
4
|
+
name = "settings.fields.view";
|
|
5
|
+
EVENT_UPDATE_VIEW = this.EVENTS.SETTINGS_VIEW.UPDATE;
|
|
6
|
+
LOC_LABEL = this.PARAMS.SETTINGS_VIEW.LOC_LABEL;
|
|
7
|
+
TRANSITION = this.PARAMS.SETTINGS_VIEW.TRANSITION;
|
|
8
|
+
renderFunc = render;
|
|
9
|
+
}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -3,8 +3,8 @@ import "@vnejs/contracts.views.settings";
|
|
|
3
3
|
import { regPlugin } from "@vnejs/shared";
|
|
4
4
|
import { PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.views.settings";
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { SettingsFieldsController } from "./modules/fields.controller.js";
|
|
7
|
+
import { SettingsFieldsControllerArrows } from "./modules/fields.controller.arrows.js";
|
|
8
|
+
import { SettingsFieldsView } from "./modules/fields.view.js";
|
|
9
9
|
|
|
10
|
-
regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, params: PARAMS }, [
|
|
10
|
+
regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, params: PARAMS }, [SettingsFieldsController, SettingsFieldsControllerArrows, SettingsFieldsView]);
|
|
@@ -5,7 +5,7 @@ import { ModuleControllerArrowsVertical } from "@vnejs/module.controller.arrows.
|
|
|
5
5
|
import type { SettingsViewPluginConstants, SettingsViewPluginEvents, SettingsViewPluginParams, SettingsViewPluginSettings } from "../types.js";
|
|
6
6
|
import type { SettingsViewTabPayload } from "../utils/settings.js";
|
|
7
7
|
|
|
8
|
-
export class
|
|
8
|
+
export class SettingsFieldsControllerArrows extends ModuleControllerArrowsVertical<
|
|
9
9
|
SettingsViewPluginEvents,
|
|
10
10
|
SettingsViewPluginConstants,
|
|
11
11
|
SettingsViewPluginSettings,
|
|
@@ -34,7 +34,7 @@ export class SettingsViewArrows extends ModuleControllerArrowsVertical<
|
|
|
34
34
|
|
|
35
35
|
return this.emit(this.EVENTS.CONTROLS.PUSH, {
|
|
36
36
|
key: this.name,
|
|
37
|
-
controls: this.
|
|
37
|
+
controls: this.CONTROLS,
|
|
38
38
|
index: this.CONTROLS_ZINDEX + 1,
|
|
39
39
|
checkNext: true,
|
|
40
40
|
} satisfies ControlsPushPayload);
|
|
@@ -4,7 +4,7 @@ import type { SettingsField } from "@vnejs/contracts.views.settings";
|
|
|
4
4
|
import type { SettingsViewPluginConstants, SettingsViewPluginEvents, SettingsViewPluginParams, SettingsViewPluginSettings } from "../types.js";
|
|
5
5
|
import type { SettingsViewPluginState, SettingsViewTabContent, SettingsViewTabPayload } from "../utils/settings.js";
|
|
6
6
|
|
|
7
|
-
export class
|
|
7
|
+
export class SettingsFieldsController extends ModuleController<
|
|
8
8
|
SettingsViewPluginEvents,
|
|
9
9
|
SettingsViewPluginConstants,
|
|
10
10
|
SettingsViewPluginSettings,
|
|
@@ -13,8 +13,15 @@ export class SettingsViewController extends ModuleController<
|
|
|
13
13
|
> {
|
|
14
14
|
name = "settings.fields.controller";
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
EVENT_UPDATE_VIEW = this.EVENTS.SETTINGS_VIEW.UPDATE;
|
|
17
|
+
|
|
18
|
+
CONTROLS = {
|
|
19
|
+
[this.CONST.CONTROLS.BUTTONS.INTERACT]: () => void this.onInteract(),
|
|
20
|
+
[this.CONST.CONTROLS.BUTTONS.ARROW_LEFT]: () => void this.onArrowLeft(),
|
|
21
|
+
[this.CONST.CONTROLS.BUTTONS.ARROW_RIGHT]: () => void this.onArrowRight(),
|
|
22
|
+
};
|
|
23
|
+
CONTROLS_INDEX = this.PARAMS.SETTINGS_VIEW.ZINDEX;
|
|
24
|
+
CONTROLS_CHECK_NEXT = true;
|
|
18
25
|
|
|
19
26
|
tabKeyOf = ({ tabKey, tab }: SettingsViewTabPayload = {}) => tabKey || tab?.titleLocKey || "default";
|
|
20
27
|
|
|
@@ -183,13 +190,6 @@ export class SettingsViewController extends ModuleController<
|
|
|
183
190
|
if (type === "toggle") return void this.emit(this.EVENTS.SETTINGS.SET, { name: settingKey, value: !this.shared.settings[settingKey] });
|
|
184
191
|
};
|
|
185
192
|
|
|
186
|
-
controls = {
|
|
187
|
-
[this.CONST.CONTROLS.BUTTONS.INTERACT]: () => void this.onInteract(),
|
|
188
|
-
[this.CONST.CONTROLS.BUTTONS.ARROW_LEFT]: () => void this.onArrowLeft(),
|
|
189
|
-
[this.CONST.CONTROLS.BUTTONS.ARROW_RIGHT]: () => void this.onArrowRight(),
|
|
190
|
-
};
|
|
191
|
-
controlsCheckNext = true;
|
|
192
|
-
|
|
193
193
|
subscribe = () => {
|
|
194
194
|
this.on(this.EVENTS.SETTINGS_VIEW.SHOW, this.onShowFields);
|
|
195
195
|
this.on(this.EVENTS.SETTINGS_VIEW.HIDE, this.onHide);
|
|
@@ -4,7 +4,7 @@ import { render } from "../view/index.js";
|
|
|
4
4
|
import type { SettingsViewPluginConstants, SettingsViewPluginEvents, SettingsViewPluginParams, SettingsViewPluginSettings } from "../types.js";
|
|
5
5
|
import type { SettingsViewPluginState } from "../utils/settings.js";
|
|
6
6
|
|
|
7
|
-
export class
|
|
7
|
+
export class SettingsFieldsView extends ModuleView<
|
|
8
8
|
SettingsViewPluginEvents,
|
|
9
9
|
SettingsViewPluginConstants,
|
|
10
10
|
SettingsViewPluginSettings,
|
|
@@ -13,10 +13,11 @@ export class SettingsView extends ModuleView<
|
|
|
13
13
|
> {
|
|
14
14
|
name = "settings.fields.view";
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
EVENT_UPDATE_VIEW = this.EVENTS.SETTINGS_VIEW.UPDATE;
|
|
17
|
+
|
|
18
|
+
LOC_LABEL = this.PARAMS.SETTINGS_VIEW.LOC_LABEL;
|
|
19
|
+
|
|
20
|
+
TRANSITION = this.PARAMS.SETTINGS_VIEW.TRANSITION;
|
|
19
21
|
|
|
20
22
|
renderFunc = render;
|
|
21
|
-
updateHandler = this.onUpdateStoreComponent;
|
|
22
23
|
}
|
package/src/tests/arrows.test.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { beforeEach, describe, expect, it } from "vitest";
|
|
|
2
2
|
|
|
3
3
|
import { spyEvent } from "@vnejs/test-utils";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { SettingsFieldsControllerArrows } from "../modules/fields.controller.arrows.js";
|
|
6
6
|
import { CONTROLS_EVENTS, createSettingsViewTestModule, registerSettingsViewPluginVne, SUBSCRIBE_EVENTS } from "./setup.js";
|
|
7
7
|
|
|
8
8
|
const generalTab = {
|
|
@@ -13,14 +13,14 @@ const generalTab = {
|
|
|
13
13
|
],
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
describe("
|
|
16
|
+
describe("SettingsFieldsControllerArrows", () => {
|
|
17
17
|
beforeEach(() => {
|
|
18
18
|
registerSettingsViewPluginVne();
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
it("SHOW pushes arrow controls above the controller layer", async () => {
|
|
22
|
-
const { module, observer } = createSettingsViewTestModule(
|
|
23
|
-
const arrows = module as
|
|
22
|
+
const { module, observer } = createSettingsViewTestModule(SettingsFieldsControllerArrows);
|
|
23
|
+
const arrows = module as SettingsFieldsControllerArrows;
|
|
24
24
|
const push = spyEvent(observer, CONTROLS_EVENTS.PUSH);
|
|
25
25
|
|
|
26
26
|
await observer.emit(SUBSCRIBE_EVENTS.SHOW, { tab: generalTab });
|
|
@@ -37,7 +37,7 @@ describe("SettingsViewArrows", () => {
|
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
it("HIDE pops arrow controls", async () => {
|
|
40
|
-
const { observer } = createSettingsViewTestModule(
|
|
40
|
+
const { observer } = createSettingsViewTestModule(SettingsFieldsControllerArrows);
|
|
41
41
|
const pop = spyEvent(observer, CONTROLS_EVENTS.POP);
|
|
42
42
|
|
|
43
43
|
await observer.emit(SUBSCRIBE_EVENTS.HIDE);
|
|
@@ -46,8 +46,8 @@ describe("SettingsViewArrows", () => {
|
|
|
46
46
|
});
|
|
47
47
|
|
|
48
48
|
it("first ARROW_BOTTOM selects 0 and emits STATE_UPDATE plus UPDATE_FAST", async () => {
|
|
49
|
-
const { module, observer } = createSettingsViewTestModule(
|
|
50
|
-
const arrows = module as
|
|
49
|
+
const { module, observer } = createSettingsViewTestModule(SettingsFieldsControllerArrows);
|
|
50
|
+
const arrows = module as SettingsFieldsControllerArrows;
|
|
51
51
|
const stateUpdate = spyEvent(observer, SUBSCRIBE_EVENTS.STATE_UPDATE);
|
|
52
52
|
const updateFast = spyEvent(observer, SUBSCRIBE_EVENTS.UPDATE_FAST);
|
|
53
53
|
|
|
@@ -60,8 +60,8 @@ describe("SettingsViewArrows", () => {
|
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
it("arrow wrap cycles fields", async () => {
|
|
63
|
-
const { module, observer } = createSettingsViewTestModule(
|
|
64
|
-
const arrows = module as
|
|
63
|
+
const { module, observer } = createSettingsViewTestModule(SettingsFieldsControllerArrows);
|
|
64
|
+
const arrows = module as SettingsFieldsControllerArrows;
|
|
65
65
|
const stateUpdate = spyEvent(observer, SUBSCRIBE_EVENTS.STATE_UPDATE);
|
|
66
66
|
|
|
67
67
|
await observer.emit(SUBSCRIBE_EVENTS.SHOW, { tab: generalTab });
|
|
@@ -78,8 +78,8 @@ describe("SettingsViewArrows", () => {
|
|
|
78
78
|
});
|
|
79
79
|
|
|
80
80
|
it("TAB_SET resets currentItem and syncs fields", async () => {
|
|
81
|
-
const { module, observer } = createSettingsViewTestModule(
|
|
82
|
-
const arrows = module as
|
|
81
|
+
const { module, observer } = createSettingsViewTestModule(SettingsFieldsControllerArrows);
|
|
82
|
+
const arrows = module as SettingsFieldsControllerArrows;
|
|
83
83
|
const stateUpdate = spyEvent(observer, SUBSCRIBE_EVENTS.STATE_UPDATE);
|
|
84
84
|
|
|
85
85
|
await observer.emit(SUBSCRIBE_EVENTS.SHOW, { tab: generalTab });
|
|
@@ -3,16 +3,16 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
3
3
|
import { spyEvent } from "@vnejs/test-utils";
|
|
4
4
|
import { SUBSCRIBE_EVENTS as SETTINGS_EVENTS } from "@vnejs/contracts.core.settings";
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { SettingsFieldsController } from "../modules/fields.controller.js";
|
|
7
7
|
import { createSettingsViewTestModule, registerSettingsViewPluginVne, SUBSCRIBE_EVENTS } from "./setup.js";
|
|
8
8
|
|
|
9
|
-
describe("
|
|
9
|
+
describe("SettingsFieldsController", () => {
|
|
10
10
|
beforeEach(() => {
|
|
11
11
|
registerSettingsViewPluginVne();
|
|
12
12
|
});
|
|
13
13
|
|
|
14
14
|
it("SHOW stores fields from tab", async () => {
|
|
15
|
-
const { module, observer } = createSettingsViewTestModule(
|
|
15
|
+
const { module, observer } = createSettingsViewTestModule(SettingsFieldsController);
|
|
16
16
|
|
|
17
17
|
await observer.emit(SUBSCRIBE_EVENTS.SHOW, {
|
|
18
18
|
tabKey: "general",
|
|
@@ -25,14 +25,14 @@ describe("SettingsViewController", () => {
|
|
|
25
25
|
},
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
expect((module as
|
|
29
|
-
expect((module as
|
|
30
|
-
expect((module as
|
|
31
|
-
expect(Object.keys((module as
|
|
28
|
+
expect((module as SettingsFieldsController).state.fields).toHaveLength(2);
|
|
29
|
+
expect((module as SettingsFieldsController).state.isShow).toBe(true);
|
|
30
|
+
expect((module as SettingsFieldsController).state.tabKey).toBe("general");
|
|
31
|
+
expect(Object.keys((module as SettingsFieldsController).state.tabsContent ?? {})).toEqual(["general"]);
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
it("ARROW_RIGHT toggles setting when focused", async () => {
|
|
35
|
-
const { module, observer } = createSettingsViewTestModule(
|
|
35
|
+
const { module, observer } = createSettingsViewTestModule(SettingsFieldsController, {
|
|
36
36
|
shared: { settings: { "test.toggle": false } },
|
|
37
37
|
});
|
|
38
38
|
|
|
@@ -40,17 +40,17 @@ describe("SettingsViewController", () => {
|
|
|
40
40
|
tab: { titleLocKey: "general", fields: [{ settingKey: "test.toggle", type: "toggle" }] },
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
(module as
|
|
43
|
+
(module as SettingsFieldsController).updateState({ currentArrowVerticalItem: 0 });
|
|
44
44
|
|
|
45
45
|
const settingsSet = spyEvent(observer, SETTINGS_EVENTS.SET);
|
|
46
46
|
|
|
47
|
-
(module as
|
|
47
|
+
(module as SettingsFieldsController).onArrowRight();
|
|
48
48
|
|
|
49
49
|
expect(settingsSet).toHaveBeenCalledExactlyOnceWith({ name: "test.toggle", value: true });
|
|
50
50
|
});
|
|
51
51
|
|
|
52
52
|
it("TAB_SET while visible replaces fields with fade", async () => {
|
|
53
|
-
const { module, observer } = createSettingsViewTestModule(
|
|
53
|
+
const { module, observer } = createSettingsViewTestModule(SettingsFieldsController);
|
|
54
54
|
|
|
55
55
|
await observer.emit(SUBSCRIBE_EVENTS.SHOW, {
|
|
56
56
|
tabKey: "general",
|
|
@@ -81,16 +81,16 @@ describe("SettingsViewController", () => {
|
|
|
81
81
|
},
|
|
82
82
|
});
|
|
83
83
|
|
|
84
|
-
expect((module as
|
|
85
|
-
expect((module as
|
|
86
|
-
expect((module as
|
|
87
|
-
expect((module as
|
|
88
|
-
expect((module as
|
|
89
|
-
expect(Object.keys((module as
|
|
84
|
+
expect((module as SettingsFieldsController).state.fields).toHaveLength(2);
|
|
85
|
+
expect((module as SettingsFieldsController).state.showTextExample).toBe(true);
|
|
86
|
+
expect((module as SettingsFieldsController).state.currentItemInner).toBe(0);
|
|
87
|
+
expect((module as SettingsFieldsController).state.currentArrowVerticalItem).toBeNull();
|
|
88
|
+
expect((module as SettingsFieldsController).state.tabKey).toBe("audio");
|
|
89
|
+
expect(Object.keys((module as SettingsFieldsController).state.tabsContent ?? {}).sort()).toEqual(["audio", "general"]);
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
it("ARROW_RIGHT on selector_texts cycles inner and SET", async () => {
|
|
93
|
-
const { module, observer } = createSettingsViewTestModule(
|
|
93
|
+
const { module, observer } = createSettingsViewTestModule(SettingsFieldsController, {
|
|
94
94
|
shared: { settings: { "test.lang": "ru" } },
|
|
95
95
|
});
|
|
96
96
|
|
|
@@ -111,7 +111,7 @@ describe("SettingsViewController", () => {
|
|
|
111
111
|
},
|
|
112
112
|
});
|
|
113
113
|
|
|
114
|
-
const controller = module as
|
|
114
|
+
const controller = module as SettingsFieldsController;
|
|
115
115
|
|
|
116
116
|
controller.updateState({ currentArrowVerticalItem: 0, currentItemInner: 0 });
|
|
117
117
|
|
|
@@ -124,7 +124,7 @@ describe("SettingsViewController", () => {
|
|
|
124
124
|
});
|
|
125
125
|
|
|
126
126
|
it("ARROW_LEFT on selector_texts wraps inner and SET", async () => {
|
|
127
|
-
const { module, observer } = createSettingsViewTestModule(
|
|
127
|
+
const { module, observer } = createSettingsViewTestModule(SettingsFieldsController, {
|
|
128
128
|
shared: { settings: { "test.lang": "ru" } },
|
|
129
129
|
});
|
|
130
130
|
|
|
@@ -145,7 +145,7 @@ describe("SettingsViewController", () => {
|
|
|
145
145
|
},
|
|
146
146
|
});
|
|
147
147
|
|
|
148
|
-
const controller = module as
|
|
148
|
+
const controller = module as SettingsFieldsController;
|
|
149
149
|
|
|
150
150
|
controller.updateState({ currentArrowVerticalItem: 0, currentItemInner: 0 });
|
|
151
151
|
|
|
@@ -158,8 +158,8 @@ describe("SettingsViewController", () => {
|
|
|
158
158
|
});
|
|
159
159
|
|
|
160
160
|
it("ARROW_* on actions without settingKey only moves inner", async () => {
|
|
161
|
-
const { module, observer } = createSettingsViewTestModule(
|
|
162
|
-
const controller = module as
|
|
161
|
+
const { module, observer } = createSettingsViewTestModule(SettingsFieldsController);
|
|
162
|
+
const controller = module as SettingsFieldsController;
|
|
163
163
|
const doA = vi.fn();
|
|
164
164
|
const doB = vi.fn();
|
|
165
165
|
|
|
@@ -199,7 +199,7 @@ describe("SettingsViewController", () => {
|
|
|
199
199
|
});
|
|
200
200
|
|
|
201
201
|
it("STATE_UPDATE syncs currentItemInner to the current option", async () => {
|
|
202
|
-
const { module, observer } = createSettingsViewTestModule(
|
|
202
|
+
const { module, observer } = createSettingsViewTestModule(SettingsFieldsController, {
|
|
203
203
|
shared: { settings: { "test.lang": "en" } },
|
|
204
204
|
});
|
|
205
205
|
|
|
@@ -221,7 +221,7 @@ describe("SettingsViewController", () => {
|
|
|
221
221
|
},
|
|
222
222
|
});
|
|
223
223
|
|
|
224
|
-
const controller = module as
|
|
224
|
+
const controller = module as SettingsFieldsController;
|
|
225
225
|
|
|
226
226
|
controller.updateState({ currentArrowVerticalItem: 0, currentItemInner: 99 });
|
|
227
227
|
|
package/dist/modules/view.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ModuleView } from "@vnejs/module.components";
|
|
2
|
-
import { render } from "../view/index.js";
|
|
3
|
-
export class SettingsView extends ModuleView {
|
|
4
|
-
name = "settings.fields.view";
|
|
5
|
-
locLabel = this.PARAMS.SETTINGS_VIEW.LOC_LABEL;
|
|
6
|
-
animationTime = this.PARAMS.SETTINGS_VIEW.TRANSITION;
|
|
7
|
-
updateEvent = this.EVENTS.SETTINGS_VIEW.UPDATE;
|
|
8
|
-
renderFunc = render;
|
|
9
|
-
updateHandler = this.onUpdateStoreComponent;
|
|
10
|
-
}
|