@vnejs/plugins.views.settings 0.2.3 → 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 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 { SettingsViewController } from "./modules/controller.js";
5
- import { SettingsViewArrows } from "./modules/arrows.js";
6
- import { SettingsView } from "./modules/view.js";
7
- regPlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS, params: PARAMS }, [SettingsViewController, SettingsViewArrows, SettingsView]);
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 SettingsViewArrows extends ModuleControllerArrowsVertical<SettingsViewPluginEvents, SettingsViewPluginConstants, SettingsViewPluginSettings, SettingsViewPluginParams> {
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 SettingsViewArrows extends ModuleControllerArrowsVertical {
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.controls,
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 SettingsViewController extends ModuleController<SettingsViewPluginEvents, SettingsViewPluginConstants, SettingsViewPluginSettings, SettingsViewPluginParams, SettingsViewPluginState> {
5
+ export declare class SettingsFieldsController extends ModuleController<SettingsViewPluginEvents, SettingsViewPluginConstants, SettingsViewPluginSettings, SettingsViewPluginParams, SettingsViewPluginState> {
6
6
  name: string;
7
- updateEvent: "vne:settings_view:update";
8
- controlsIndex: number;
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 SettingsViewController extends ModuleController {
2
+ export class SettingsFieldsController extends ModuleController {
3
3
  name = "settings.fields.controller";
4
- updateEvent = this.EVENTS.SETTINGS_VIEW.UPDATE;
5
- controlsIndex = this.PARAMS.SETTINGS_VIEW.ZINDEX;
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 SettingsView extends ModuleView<SettingsViewPluginEvents, SettingsViewPluginConstants, SettingsViewPluginSettings, SettingsViewPluginParams, SettingsViewPluginState> {
4
+ export declare class SettingsFieldsView extends ModuleView<SettingsViewPluginEvents, SettingsViewPluginConstants, SettingsViewPluginSettings, SettingsViewPluginParams, SettingsViewPluginState> {
5
5
  name: string;
6
- locLabel: string;
7
- animationTime: number;
8
- updateEvent: "vne:settings_view:update";
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
+ }
@@ -18,8 +18,6 @@ export const SettingsExampleText = ({ isShow = false, locs = {}, PARAMS, shared,
18
18
  const tm = setTimeout(() => setTokens([]), PARAMS.SETTINGS_VIEW.TRANSITION);
19
19
  return () => clearTimeout(tm);
20
20
  }, [isShow, isForce, PARAMS.SETTINGS_VIEW.TRANSITION]);
21
- const charDelay = isForce
22
- ? 0
23
- : PARAMS.TEXT_SMOOTH.TOKEN_RENDER_DELAY / Number(shared.settings[SETTINGS.TEXT_SMOOTH.TOKEN_RENDER_SPEED]);
21
+ const charDelay = isForce ? 0 : PARAMS.TEXT_SMOOTH.TOKEN_RENDER_DELAY / Number(shared.settings[SETTINGS.TEXT_SMOOTH.TOKEN_RENDER_SPEED]);
24
22
  return (_jsx(SmoothText, { tokens: tokens, isForce: isForce, charDelay: charDelay, tokensVisibleForce: isForce ? tokens.length : null, transition: PARAMS.SETTINGS_VIEW.VIEW_PROPS.exampleText.transition, size: PARAMS.SETTINGS_VIEW.VIEW_PROPS.exampleText.size, color: PARAMS.SETTINGS_VIEW.VIEW_PROPS.exampleText.color, height: PARAMS.SETTINGS_VIEW.VIEW_PROPS.exampleText.height, scrollBarTextSize: Number(shared.settings[SETTINGS.TEXTSIZE.VALUE]) }));
25
23
  };
@@ -12,7 +12,20 @@ const SettingsViewComponent = ({ store, onMount, PARAMS, emit, EVENTS, shared, C
12
12
  isForce: isRealForce,
13
13
  transition: isRealForce ? 0 : PARAMS.SETTINGS_VIEW.TRANSITION,
14
14
  }), [isShow, isRealForce, propsByView.view, PARAMS.SETTINGS_VIEW.TRANSITION]);
15
- const propsTab = useMemo(() => ({ store, onMount, PARAMS, emit, EVENTS, shared, CONST, SETTINGS, isForce: isRealForce, currentItem: currentArrowVerticalItem, currentItemInner, locs }), [store, onMount, PARAMS, emit, EVENTS, shared, CONST, SETTINGS, isRealForce, currentArrowVerticalItem, currentItemInner, locs]);
15
+ const propsTab = useMemo(() => ({
16
+ store,
17
+ onMount,
18
+ PARAMS,
19
+ emit,
20
+ EVENTS,
21
+ shared,
22
+ CONST,
23
+ SETTINGS,
24
+ isForce: isRealForce,
25
+ currentItem: currentArrowVerticalItem,
26
+ currentItemInner,
27
+ locs,
28
+ }), [store, onMount, PARAMS, emit, EVENTS, shared, CONST, SETTINGS, isRealForce, currentArrowVerticalItem, currentItemInner, locs]);
16
29
  return (_jsx(View, { ...propsView, children: Object.entries(tabsContent).map(([key, content]) => (_createElement(SettingsTabContent, { ...propsTab, key: key, isShow: tabKey === key, fields: content.fields, showTextExample: content.showTextExample, locs: content.locs ?? locs }))) }));
17
30
  };
18
31
  export const render = createRenderFunc(SettingsViewComponent);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/plugins.views.settings",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
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 { SettingsViewController } from "./modules/controller.js";
7
- import { SettingsViewArrows } from "./modules/arrows.js";
8
- import { SettingsView } from "./modules/view.js";
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 }, [SettingsViewController, SettingsViewArrows, SettingsView]);
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 SettingsViewArrows extends ModuleControllerArrowsVertical<
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.controls,
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 SettingsViewController extends ModuleController<
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
- updateEvent = this.EVENTS.SETTINGS_VIEW.UPDATE;
17
- controlsIndex = this.PARAMS.SETTINGS_VIEW.ZINDEX;
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
 
@@ -30,9 +37,7 @@ export class SettingsViewController extends ModuleController<
30
37
  const key = this.tabKeyOf(payload);
31
38
 
32
39
  const tabsContent = payload.tabs
33
- ? Object.fromEntries(
34
- Object.entries(payload.tabs).map(([tabKey, settingsTab]) => [tabKey, this.tabContentOf(settingsTab, locs)]),
35
- )
40
+ ? Object.fromEntries(Object.entries(payload.tabs).map(([tabKey, settingsTab]) => [tabKey, this.tabContentOf(settingsTab, locs)]))
36
41
  : { ...(this.state.tabsContent ?? {}), [key]: this.tabContentOf(tab, locs) };
37
42
 
38
43
  return {
@@ -185,13 +190,6 @@ export class SettingsViewController extends ModuleController<
185
190
  if (type === "toggle") return void this.emit(this.EVENTS.SETTINGS.SET, { name: settingKey, value: !this.shared.settings[settingKey] });
186
191
  };
187
192
 
188
- controls = {
189
- [this.CONST.CONTROLS.BUTTONS.INTERACT]: () => void this.onInteract(),
190
- [this.CONST.CONTROLS.BUTTONS.ARROW_LEFT]: () => void this.onArrowLeft(),
191
- [this.CONST.CONTROLS.BUTTONS.ARROW_RIGHT]: () => void this.onArrowRight(),
192
- };
193
- controlsCheckNext = true;
194
-
195
193
  subscribe = () => {
196
194
  this.on(this.EVENTS.SETTINGS_VIEW.SHOW, this.onShowFields);
197
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 SettingsView extends ModuleView<
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
- locLabel = this.PARAMS.SETTINGS_VIEW.LOC_LABEL;
17
- animationTime = this.PARAMS.SETTINGS_VIEW.TRANSITION;
18
- updateEvent = this.EVENTS.SETTINGS_VIEW.UPDATE;
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
  }
@@ -2,22 +2,25 @@ import { beforeEach, describe, expect, it } from "vitest";
2
2
 
3
3
  import { spyEvent } from "@vnejs/test-utils";
4
4
 
5
- import { SettingsViewArrows } from "../modules/arrows.js";
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 = {
9
9
  titleLocKey: "general",
10
- fields: [{ settingKey: "a", type: "toggle" }, { settingKey: "b", type: "toggle" }],
10
+ fields: [
11
+ { settingKey: "a", type: "toggle" },
12
+ { settingKey: "b", type: "toggle" },
13
+ ],
11
14
  };
12
15
 
13
- describe("SettingsViewArrows", () => {
16
+ describe("SettingsFieldsControllerArrows", () => {
14
17
  beforeEach(() => {
15
18
  registerSettingsViewPluginVne();
16
19
  });
17
20
 
18
21
  it("SHOW pushes arrow controls above the controller layer", async () => {
19
- const { module, observer } = createSettingsViewTestModule(SettingsViewArrows);
20
- const arrows = module as SettingsViewArrows;
22
+ const { module, observer } = createSettingsViewTestModule(SettingsFieldsControllerArrows);
23
+ const arrows = module as SettingsFieldsControllerArrows;
21
24
  const push = spyEvent(observer, CONTROLS_EVENTS.PUSH);
22
25
 
23
26
  await observer.emit(SUBSCRIBE_EVENTS.SHOW, { tab: generalTab });
@@ -34,7 +37,7 @@ describe("SettingsViewArrows", () => {
34
37
  });
35
38
 
36
39
  it("HIDE pops arrow controls", async () => {
37
- const { observer } = createSettingsViewTestModule(SettingsViewArrows);
40
+ const { observer } = createSettingsViewTestModule(SettingsFieldsControllerArrows);
38
41
  const pop = spyEvent(observer, CONTROLS_EVENTS.POP);
39
42
 
40
43
  await observer.emit(SUBSCRIBE_EVENTS.HIDE);
@@ -43,8 +46,8 @@ describe("SettingsViewArrows", () => {
43
46
  });
44
47
 
45
48
  it("first ARROW_BOTTOM selects 0 and emits STATE_UPDATE plus UPDATE_FAST", async () => {
46
- const { module, observer } = createSettingsViewTestModule(SettingsViewArrows);
47
- const arrows = module as SettingsViewArrows;
49
+ const { module, observer } = createSettingsViewTestModule(SettingsFieldsControllerArrows);
50
+ const arrows = module as SettingsFieldsControllerArrows;
48
51
  const stateUpdate = spyEvent(observer, SUBSCRIBE_EVENTS.STATE_UPDATE);
49
52
  const updateFast = spyEvent(observer, SUBSCRIBE_EVENTS.UPDATE_FAST);
50
53
 
@@ -57,8 +60,8 @@ describe("SettingsViewArrows", () => {
57
60
  });
58
61
 
59
62
  it("arrow wrap cycles fields", async () => {
60
- const { module, observer } = createSettingsViewTestModule(SettingsViewArrows);
61
- const arrows = module as SettingsViewArrows;
63
+ const { module, observer } = createSettingsViewTestModule(SettingsFieldsControllerArrows);
64
+ const arrows = module as SettingsFieldsControllerArrows;
62
65
  const stateUpdate = spyEvent(observer, SUBSCRIBE_EVENTS.STATE_UPDATE);
63
66
 
64
67
  await observer.emit(SUBSCRIBE_EVENTS.SHOW, { tab: generalTab });
@@ -75,8 +78,8 @@ describe("SettingsViewArrows", () => {
75
78
  });
76
79
 
77
80
  it("TAB_SET resets currentItem and syncs fields", async () => {
78
- const { module, observer } = createSettingsViewTestModule(SettingsViewArrows);
79
- const arrows = module as SettingsViewArrows;
81
+ const { module, observer } = createSettingsViewTestModule(SettingsFieldsControllerArrows);
82
+ const arrows = module as SettingsFieldsControllerArrows;
80
83
  const stateUpdate = spyEvent(observer, SUBSCRIBE_EVENTS.STATE_UPDATE);
81
84
 
82
85
  await observer.emit(SUBSCRIBE_EVENTS.SHOW, { tab: generalTab });
@@ -86,7 +89,11 @@ describe("SettingsViewArrows", () => {
86
89
  await observer.emit(SUBSCRIBE_EVENTS.TAB_SET, {
87
90
  tab: {
88
91
  titleLocKey: "audio",
89
- fields: [{ settingKey: "c", type: "toggle" }, { settingKey: "d", type: "toggle" }, { settingKey: "e", type: "toggle" }],
92
+ fields: [
93
+ { settingKey: "c", type: "toggle" },
94
+ { settingKey: "d", type: "toggle" },
95
+ { settingKey: "e", type: "toggle" },
96
+ ],
90
97
  },
91
98
  });
92
99
 
@@ -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 { SettingsViewController } from "../modules/controller.js";
6
+ import { SettingsFieldsController } from "../modules/fields.controller.js";
7
7
  import { createSettingsViewTestModule, registerSettingsViewPluginVne, SUBSCRIBE_EVENTS } from "./setup.js";
8
8
 
9
- describe("SettingsViewController", () => {
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(SettingsViewController);
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 SettingsViewController).state.fields).toHaveLength(2);
29
- expect((module as SettingsViewController).state.isShow).toBe(true);
30
- expect((module as SettingsViewController).state.tabKey).toBe("general");
31
- expect(Object.keys((module as SettingsViewController).state.tabsContent ?? {})).toEqual(["general"]);
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(SettingsViewController, {
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 SettingsViewController).updateState({ currentArrowVerticalItem: 0 });
43
+ (module as SettingsFieldsController).updateState({ currentArrowVerticalItem: 0 });
44
44
 
45
45
  const settingsSet = spyEvent(observer, SETTINGS_EVENTS.SET);
46
46
 
47
- (module as SettingsViewController).onArrowRight();
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(SettingsViewController);
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 SettingsViewController).state.fields).toHaveLength(2);
85
- expect((module as SettingsViewController).state.showTextExample).toBe(true);
86
- expect((module as SettingsViewController).state.currentItemInner).toBe(0);
87
- expect((module as SettingsViewController).state.currentArrowVerticalItem).toBeNull();
88
- expect((module as SettingsViewController).state.tabKey).toBe("audio");
89
- expect(Object.keys((module as SettingsViewController).state.tabsContent ?? {}).sort()).toEqual(["audio", "general"]);
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(SettingsViewController, {
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 SettingsViewController;
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(SettingsViewController, {
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 SettingsViewController;
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(SettingsViewController);
162
- const controller = module as SettingsViewController;
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(SettingsViewController, {
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 SettingsViewController;
224
+ const controller = module as SettingsFieldsController;
225
225
 
226
226
  controller.updateState({ currentArrowVerticalItem: 0, currentItemInner: 99 });
227
227
 
@@ -1,12 +1,7 @@
1
1
  import { CONSTANTS as CONTROLS_CONST, PLUGIN_NAME as CONTROLS, SUBSCRIBE_EVENTS as CONTROLS_EVENTS } from "@vnejs/contracts.controls";
2
2
  import { PARAMS, PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.views.settings";
3
3
  import { SourcesSet } from "@vnejs/sources-set";
4
- import {
5
- createTestModule as baseCreateTestModule,
6
- registerCoreVne,
7
- registerVnePlugin,
8
- stubSilentEvent,
9
- } from "@vnejs/test-utils";
4
+ import { createTestModule as baseCreateTestModule, registerCoreVne, registerVnePlugin, stubSilentEvent } from "@vnejs/test-utils";
10
5
 
11
6
  export const registerSettingsViewPluginVne = () => {
12
7
  registerCoreVne();
package/src/types.ts CHANGED
@@ -5,9 +5,7 @@ import type { SettingsKeys as TextsizeSettingsKeys, PluginName as TextsizePlugin
5
5
  import type { Params as TextSmoothParams, PluginName as TextSmoothPluginName, SettingsKeys as TextSmoothSettingsKeys } from "@vnejs/contracts.text.smooth";
6
6
  import type { Params, PluginName, SubscribeEvents } from "@vnejs/contracts.views.settings";
7
7
 
8
- export type SettingsViewPluginEvents = ModuleComponentsEvents &
9
- Record<PluginName, SubscribeEvents> &
10
- Record<SettingsPluginName, SettingsSubscribeEvents>;
8
+ export type SettingsViewPluginEvents = ModuleComponentsEvents & Record<PluginName, SubscribeEvents> & Record<SettingsPluginName, SettingsSubscribeEvents>;
11
9
 
12
10
  export type SettingsViewPluginConstants = ModuleComponentsConstants & Record<ControlsPluginName, ControlsConstants>;
13
11
 
@@ -15,6 +13,4 @@ export type SettingsViewPluginSettings = ModuleComponentsSettings &
15
13
  Record<TextSmoothPluginName, TextSmoothSettingsKeys> &
16
14
  Record<TextsizePluginName, TextsizeSettingsKeys>;
17
15
 
18
- export type SettingsViewPluginParams = ModuleComponentsParams &
19
- Record<PluginName, Params> &
20
- Record<TextSmoothPluginName, TextSmoothParams>;
16
+ export type SettingsViewPluginParams = ModuleComponentsParams & Record<PluginName, Params> & Record<TextSmoothPluginName, TextSmoothParams>;
@@ -41,9 +41,7 @@ export const SettingsExampleText = ({ isShow = false, locs = {}, PARAMS, shared,
41
41
  return () => clearTimeout(tm);
42
42
  }, [isShow, isForce, PARAMS.SETTINGS_VIEW.TRANSITION]);
43
43
 
44
- const charDelay = isForce
45
- ? 0
46
- : PARAMS.TEXT_SMOOTH.TOKEN_RENDER_DELAY / Number(shared.settings[SETTINGS.TEXT_SMOOTH.TOKEN_RENDER_SPEED]);
44
+ const charDelay = isForce ? 0 : PARAMS.TEXT_SMOOTH.TOKEN_RENDER_DELAY / Number(shared.settings[SETTINGS.TEXT_SMOOTH.TOKEN_RENDER_SPEED]);
47
45
 
48
46
  return (
49
47
  <SmoothText
@@ -40,7 +40,20 @@ const SettingsViewComponent = ({ store, onMount, PARAMS, emit, EVENTS, shared, C
40
40
  );
41
41
 
42
42
  const propsTab = useMemo(
43
- () => ({ store, onMount, PARAMS, emit, EVENTS, shared, CONST, SETTINGS, isForce: isRealForce, currentItem: currentArrowVerticalItem, currentItemInner, locs }),
43
+ () => ({
44
+ store,
45
+ onMount,
46
+ PARAMS,
47
+ emit,
48
+ EVENTS,
49
+ shared,
50
+ CONST,
51
+ SETTINGS,
52
+ isForce: isRealForce,
53
+ currentItem: currentArrowVerticalItem,
54
+ currentItemInner,
55
+ locs,
56
+ }),
44
57
  [store, onMount, PARAMS, emit, EVENTS, shared, CONST, SETTINGS, isRealForce, currentArrowVerticalItem, currentItemInner, locs],
45
58
  );
46
59
 
@@ -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
- }