@vnejs/plugins.view.coralina.settings.defaults 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,17 @@
1
- import { Module } from "@vnejs/module";
1
+ import { ModuleController } from "@vnejs/module.components";
2
2
 
3
- export class SettingsDefaultsController extends Module.Controller {
3
+ const mapField = (field) => ({ ...field, isNotRender: typeof field.isNotShowFunc === "function" ? field.isNotShowFunc() : false });
4
+ const mapTabInfo = ({ ...tabInfo }) => {
5
+ if (tabInfo.options) tabInfo.options = [...tabInfo.options.map(mapField)];
6
+
7
+ return tabInfo;
8
+ };
9
+
10
+ export class SettingsDefaultsController extends ModuleController {
4
11
  name = "settings.defaults.controller";
5
12
 
13
+ bgName = "Menu/save";
14
+
6
15
  updateEvent = this.EVENTS.SETTINGS_DEFAULTS.UPDATE;
7
16
 
8
17
  subscribe = () => {
@@ -12,7 +21,11 @@ export class SettingsDefaultsController extends Module.Controller {
12
21
  this.on(this.EVENTS.SETTINGS.CHANGED, this.onSettingChange);
13
22
  };
14
23
 
15
- beforeShow = () => this.updateState({ defaultSettingsItems: window.VNESettingsDefaultsItems.map(this.emitFunc) });
24
+ init = () => {
25
+ this.tab = mapTabInfo(this.PARAMS.SETTINGS_VIEW.TABS.DEFAULT);
26
+ };
27
+
28
+ beforeShow = async () => this.updateState({ bgSrc: (await this.loadBgMedia()).src, tab: this.tab, currentTab: 0 });
16
29
 
17
30
  emitFunc = (func) => func({ SETTINGS: this.SETTINGS, CONST: this.CONST, platform: window.VneCore.getPlatform() });
18
31
 
package/modules/view.js CHANGED
@@ -1,12 +1,14 @@
1
- import { Module } from "@vnejs/module";
1
+ import { ModuleView } from "@vnejs/module.components";
2
2
 
3
3
  import { render } from "../view";
4
4
 
5
- export class SettingsDefaultsView extends Module.View {
5
+ export class SettingsDefaultsView extends ModuleView {
6
6
  name = "settings.defaults.view";
7
- locLabel = "settings_defaults";
7
+
8
+ locLabel = "settings";
8
9
  animationTime = 300;
9
- renderFunc = render;
10
10
  updateEvent = this.EVENTS.SETTINGS_DEFAULTS.UPDATE;
11
+
12
+ renderFunc = render;
11
13
  updateHandler = this.onUpdateReactComponent;
12
14
  }
package/package.json CHANGED
@@ -1,18 +1,17 @@
1
1
  {
2
2
  "name": "@vnejs/plugins.view.coralina.settings.defaults",
3
- "version": "0.0.1",
3
+ "version": "0.1.0",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
7
+ "publish:major:plugin": "npm run publish:major",
8
+ "publish:minor:plugin": "npm run publish:minor",
9
+ "publish:patch:plugin": "npm run publish:patch",
7
10
  "publish:major": "npm version major && npm publish --access public",
8
11
  "publish:minor": "npm version minor && npm publish --access public",
9
12
  "publish:patch": "npm version patch && npm publish --access public"
10
13
  },
11
14
  "author": "",
12
15
  "license": "ISC",
13
- "description": "",
14
- "peerDependencies": {
15
- "@vnejs/shared": "*",
16
- "@vnejs/module": "*"
17
- }
16
+ "description": ""
18
17
  }
package/view/index.jsx CHANGED
@@ -1,57 +1,72 @@
1
1
  import React from "react";
2
2
  import ReactDOM from "react-dom";
3
3
 
4
- import { cn } from "@bem-react/classname";
4
+ import { Flex, Text, Screen, Settings, PositionBox } from "@vnejs/uis.base";
5
5
 
6
- import "./index.styl";
6
+ export const TRANSITION = 500;
7
+ export const ZINDEX = 4000;
7
8
 
8
- const b = cn("SettingsDefaults");
9
+ const EMPTY_ARRAY = [];
9
10
 
10
11
  class SettingsDefaults extends React.Component {
11
- state = { locs: {} };
12
+ state = { isShow: false, locs: {}, tokens: EMPTY_ARRAY, tab: { options: [], fields: [] } };
12
13
 
13
- onClickValue = (e) => {
14
- const { value, settingKey } = e.currentTarget.dataset;
14
+ mapTokens = (token) => ({ token });
15
+ recalcTokens = () => this.setState({ tokens: [...this.props.text].map(this.mapTokens) });
15
16
 
16
- return this.props.emit(this.props.EVENTS.SETTINGS.SET, { name: settingKey, value });
17
- };
17
+ componentDidUpdate(props) {
18
+ if (props.text !== this.props.text || (!props.isShow && this.props.isShow)) this.recalcTokens();
19
+ }
18
20
 
19
21
  onClickConfirm = () => this.props.emit(this.props.EVENTS.SETTINGS_DEFAULTS.CONFIRM);
20
22
 
21
- renderValues = ({ titleKey = "", value = "" } = {}, settingKey = "") => (
22
- <div
23
- className={b("value", { current: this.props.shared.settings[settingKey] === value }, ["textWrap_120"])}
24
- onClick={this.onClickValue}
25
- data-value={value}
26
- data-setting-key={settingKey}
27
- key={value}
28
- >
29
- <span className="text">{this.state.locs[titleKey]}</span>
30
- </div>
31
- );
32
-
33
- renderItem = ({ titleKey = "", settingKey = "", values = [] } = {}, i) => (
34
- <div className={b("item")} key={settingKey}>
35
- <div className={b("name", ["textWrap_120"])}>
36
- <span className="text">{this.state.locs[titleKey]}</span>
37
- </div>
38
- <div className={b("values")}>{values.map((value) => this.renderValues(value, settingKey))}</div>
39
- </div>
40
- );
23
+ mapFields = ({ locKey = "", type = "", settingKey = "", options = [], titleToggledLocKey = "", titleUntoggledLocKey = "", ...props } = {}) => {
24
+ const { shared: { settings = {} } = {} } = this.props;
25
+ const { locs = {} } = this.state;
26
+
27
+ const onChange = (value) => this.props.emit(this.props.EVENTS.SETTINGS.SET, { name: settingKey, value });
28
+
29
+ const titles = { title: locs[locKey], titleToggled: locs[titleToggledLocKey], titleUntoggled: locs[titleUntoggledLocKey] };
30
+
31
+ return { ...titles, value: settings[settingKey], type, onChange, props, options };
32
+ };
41
33
 
42
34
  render() {
43
- const { isShow = false, defaultSettingsItems = [], locs = {} } = this.state;
35
+ const { isShow = false, locs = {}, tab = {}, bgSrc = "" } = this.state;
44
36
 
45
37
  return (
46
- <div className={b({ isShow })} data-html2canvas-ignore="1">
47
- <div className={b("title", ["textWrap_120"])}>
48
- <span className="text">{locs.title}</span>
49
- </div>
50
- <div className={b("items")}>{defaultSettingsItems.map(this.renderItem)}</div>
51
- <div className={b("confirm", ["textWrap_120"])} onClick={this.onClickConfirm}>
52
- <span className="text">{locs.confirm}</span>
53
- </div>
54
- </div>
38
+ <Screen
39
+ isShow={isShow}
40
+ zIndex={ZINDEX}
41
+ transition={TRANSITION}
42
+ bgSrc={bgSrc}
43
+ >
44
+ <PositionBox isCentered={true}>
45
+ <Flex
46
+ direction={Flex.DIRECTION.COLUMN}
47
+ gap={120}
48
+ >
49
+ <Text
50
+ align={Text.ALIGNS.CENTER}
51
+ width={3120}
52
+ text={locs[tab.titleLocKey]}
53
+ />
54
+ <Settings
55
+ selectedIndex={0}
56
+ selectedIndexInner={0}
57
+ transition={TRANSITION}
58
+ settings={tab.fields.map(this.mapFields)}
59
+ />
60
+
61
+ <Text
62
+ align={Text.ALIGNS.CENTER}
63
+ width={3120}
64
+ text={locs[tab.acceptLocKey]}
65
+ onClick={this.onClickConfirm}
66
+ />
67
+ </Flex>
68
+ </PositionBox>
69
+ </Screen>
55
70
  );
56
71
  }
57
72
  }
package/view/index.styl DELETED
@@ -1,62 +0,0 @@
1
- .SettingsDefaults
2
- position: absolute
3
- top: 0
4
- right: 0
5
- bottom: 0
6
- left: 0
7
-
8
- display: flex
9
- align-items: center
10
- justify-content: center
11
- flex-direction: column;
12
- gap: calc(180 / 2160* 100%);
13
-
14
- color: rgba(255,255,255,0.6);
15
- font-family: Montserrat;
16
- text-align: center
17
-
18
- opacity: 0
19
- pointer-events: none
20
-
21
- transition: color 300ms, opacity 1000ms
22
-
23
- &-items
24
- width: 100%
25
-
26
- &-item
27
- display: flex
28
- justify-content: space-evenly
29
-
30
- &-item ~ &-item
31
- margin-top: 2.345%
32
-
33
- &-name
34
- width: 20%
35
-
36
- &-values
37
- width: 65%
38
- display: flex
39
- justify-content: space-evenly
40
-
41
- &-value
42
- cursor: pointer
43
- transition: color 300ms
44
-
45
- &:hover
46
- color: rgba(255,255,255,0.75);
47
-
48
- &_current
49
- color: rgba(255,255,255,0.9);
50
-
51
- &-confirm
52
- color: rgba(255,255,255,0.6);
53
- cursor: pointer
54
- transition: color 300ms
55
-
56
- &:hover
57
- color: rgba(255,255,255,1);
58
-
59
- &_isShow
60
- pointer-events: all
61
- opacity: 1
62
-