plain-design 1.0.0-beta.85 → 1.0.0-beta.87
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/plain-design.commonjs.min.js +2 -2
- package/dist/plain-design.min.js +2 -2
- package/dist/report.html +2 -2
- package/package.json +1 -1
- package/src/packages/components/PageThemeUtils/index.tsx +16 -15
- package/src/packages/components/ThemeColorSelector/index.tsx +15 -2
- package/src/packages/components/ThemeDarkSelector/index.tsx +17 -3
- package/src/packages/components/ThemeLocaleSelector/index.tsx +16 -2
- package/src/packages/components/ThemeShapeSelector/index.tsx +14 -3
- package/src/packages/components/ThemeSizeSelector/index.tsx +15 -4
package/package.json
CHANGED
@@ -88,38 +88,39 @@ export const PageThemeUtils = (() => {
|
|
88
88
|
return config;
|
89
89
|
});
|
90
90
|
|
91
|
-
const toggle = (isDark?: boolean) => {
|
92
|
-
|
93
|
-
|
91
|
+
const toggle = (isDark?: boolean, onlyCache?: boolean) => {
|
92
|
+
const dark: boolean = isDark == null ? !isDark : isDark;
|
93
|
+
!onlyCache && (state.dark = dark);
|
94
|
+
darkCache.set(dark);
|
94
95
|
};
|
95
96
|
|
96
|
-
const primary = (val: string | null) => {
|
97
|
-
state.primaryKey = val;
|
97
|
+
const primary = (val: string | null, onlyCache?: boolean) => {
|
98
|
+
!onlyCache && (state.primaryKey = val);
|
98
99
|
primaryCache.set(val);
|
99
100
|
};
|
100
101
|
|
101
|
-
const size = (val: typeof ThemeSize.TYPE | null) => {
|
102
|
-
state.size = val;
|
102
|
+
const size = (val: typeof ThemeSize.TYPE | null, onlyCache?: boolean) => {
|
103
|
+
!onlyCache && (state.size = val);
|
103
104
|
sizeCache.set(val);
|
104
105
|
};
|
105
106
|
|
106
|
-
const shape = (val: typeof ThemeShape.TYPE | null) => {
|
107
|
-
state.shape = val;
|
107
|
+
const shape = (val: typeof ThemeShape.TYPE | null, onlyCache?: boolean) => {
|
108
|
+
!onlyCache && (state.shape = val);
|
108
109
|
shapeCache.set(val);
|
109
110
|
};
|
110
111
|
|
111
|
-
const inputMode = (val: typeof InputMode.TYPE | null) => {
|
112
|
-
state.inputMode = val;
|
112
|
+
const inputMode = (val: typeof InputMode.TYPE | null, onlyCache?: boolean) => {
|
113
|
+
!onlyCache && (state.inputMode = val);
|
113
114
|
inputModeCache.set(val);
|
114
115
|
};
|
115
116
|
|
116
|
-
const buttonMode = (val: typeof ThemeMode.TYPE | null) => {
|
117
|
-
state.buttonMode = val;
|
117
|
+
const buttonMode = (val: typeof ThemeMode.TYPE | null, onlyCache?: boolean) => {
|
118
|
+
!onlyCache && (state.buttonMode = val);
|
118
119
|
buttonModeCache.set(val);
|
119
120
|
};
|
120
121
|
|
121
|
-
const zoom = (val: number | null) => {
|
122
|
-
state.zoom = val;
|
122
|
+
const zoom = (val: number | null, onlyCache?: boolean) => {
|
123
|
+
!onlyCache && (state.zoom = val);
|
123
124
|
zoomCache.set(val);
|
124
125
|
};
|
125
126
|
|
@@ -8,13 +8,26 @@ import DropdownOption from "../DropdownOption";
|
|
8
8
|
export const ThemeColorSelector = designComponent({
|
9
9
|
name: 'theme-color-selector',
|
10
10
|
inheritPropsType: Dropdown,
|
11
|
-
|
11
|
+
props: {
|
12
|
+
reloadOnChange: { type: Boolean },
|
13
|
+
onlyCache: { type: Boolean },
|
14
|
+
},
|
15
|
+
emits: {
|
16
|
+
onChange: (primaryKey: string) => true,
|
17
|
+
},
|
18
|
+
setup({ props, event: { emit } }) {
|
12
19
|
|
13
20
|
const classes = useClassCache(() => [
|
14
21
|
getComponentCls('theme-selector'),
|
15
22
|
getComponentCls('theme-color-selector'),
|
16
23
|
]);
|
17
24
|
|
25
|
+
const change = (key: string) => {
|
26
|
+
PageThemeUtils.primary(key, props.onlyCache || props.reloadOnChange);
|
27
|
+
emit.onChange(key);
|
28
|
+
props.reloadOnChange && window.location.reload();
|
29
|
+
};
|
30
|
+
|
18
31
|
return () => (
|
19
32
|
<Dropdown
|
20
33
|
trigger="hover"
|
@@ -27,7 +40,7 @@ export const ThemeColorSelector = designComponent({
|
|
27
40
|
</div>
|
28
41
|
),
|
29
42
|
popper: () => Object.entries(ThemePrimaryColors).map(([key]) => (
|
30
|
-
<DropdownOption key={key} onClick={() =>
|
43
|
+
<DropdownOption key={key} onClick={() => change(key)}>
|
31
44
|
<ThemeColor className="dropdown-theme-color" primaryKey={key}/>
|
32
45
|
</DropdownOption>
|
33
46
|
))
|
@@ -7,15 +7,29 @@ import './theme-dark-selector.scss';
|
|
7
7
|
|
8
8
|
export const ThemeDarkSelector = designComponent({
|
9
9
|
name: 'theme-dark-selector',
|
10
|
-
|
11
|
-
|
10
|
+
props: {
|
11
|
+
reloadOnChange: { type: Boolean },
|
12
|
+
onlyCache: { type: Boolean },
|
13
|
+
},
|
14
|
+
emits: {
|
15
|
+
onChange: (dark: boolean) => true,
|
16
|
+
},
|
17
|
+
setup({ props, event: { emit } }) {
|
18
|
+
|
12
19
|
const classes = useClassCache(() => [
|
13
20
|
getComponentCls('theme-selector'),
|
14
21
|
getComponentCls('theme-dark-selector'),
|
15
22
|
]);
|
23
|
+
|
24
|
+
const change = () => {
|
25
|
+
const dark = !(PageThemeUtils.state.dark == null ? false : PageThemeUtils.state.dark);
|
26
|
+
PageThemeUtils.toggle(dark, props.onlyCache || props.reloadOnChange);
|
27
|
+
emit.onChange(dark);
|
28
|
+
props.reloadOnChange && window.location.reload();
|
29
|
+
};
|
16
30
|
return () => (
|
17
31
|
<Tooltip message={i18n.$it('theme.darkOrLight').d("深浅主题")}>
|
18
|
-
<div className={classes.value} onClick={
|
32
|
+
<div className={classes.value} onClick={change}>
|
19
33
|
<Icon icon={PageThemeUtils.state.dark ? 'pi-sun' : 'pi-moon'}/>
|
20
34
|
</div>
|
21
35
|
</Tooltip>
|
@@ -7,15 +7,29 @@ import './theme-locale-selector.scss';
|
|
7
7
|
|
8
8
|
export const ThemeLocaleSelector = designComponent({
|
9
9
|
name: 'theme-locale-selector',
|
10
|
-
|
10
|
+
props: {
|
11
|
+
reloadOnChange: { type: Boolean },
|
12
|
+
onlyCache: { type: Boolean },
|
13
|
+
},
|
14
|
+
emits: {
|
15
|
+
onChange: (locale: string) => true,
|
16
|
+
},
|
17
|
+
setup({ props, event: { emit } }) {
|
11
18
|
const classes = useClassCache(() => [
|
12
19
|
getComponentCls('theme-selector'),
|
13
20
|
getComponentCls('theme-locale-selector'),
|
14
21
|
]);
|
22
|
+
|
23
|
+
const change = (key: string, fn: () => any) => {
|
24
|
+
i18n.switchTo(key, fn);
|
25
|
+
emit.onChange(key);
|
26
|
+
props.reloadOnChange && window.location.reload();
|
27
|
+
};
|
28
|
+
|
15
29
|
return () => (
|
16
30
|
<Dropdown trigger="hover" align="center" placement="bottom" hideOnClickReference={false} v-slots={{
|
17
31
|
popper: () => i18n.state.localeOptions.map(opt => (
|
18
|
-
<DropdownOption label={opt.label} key={opt.label} onClick={() =>
|
32
|
+
<DropdownOption label={opt.label} key={opt.label} onClick={() => change(opt.key, () => opt.lang)}/>
|
19
33
|
)),
|
20
34
|
default: () => (
|
21
35
|
<div className={classes.value}>
|
@@ -9,7 +9,14 @@ import './theme-shape-selector.scss';
|
|
9
9
|
|
10
10
|
export const ThemeShapeSelector = designComponent({
|
11
11
|
name: 'theme-shape-selector',
|
12
|
-
|
12
|
+
props: {
|
13
|
+
reloadOnChange: { type: Boolean },
|
14
|
+
onlyCache: { type: Boolean },
|
15
|
+
},
|
16
|
+
emits: {
|
17
|
+
onChange: (shape: typeof ThemeShape.TYPE) => true,
|
18
|
+
},
|
19
|
+
setup({ props, event: { emit } }) {
|
13
20
|
|
14
21
|
const radiusOptions = computed((): { label: string, val: string | undefined }[] => [
|
15
22
|
{ label: i18n.$it('theme.radiusOptions.round').d('圆角'), val: undefined },
|
@@ -17,7 +24,11 @@ export const ThemeShapeSelector = designComponent({
|
|
17
24
|
{ label: i18n.$it('theme.radiusOptions.none').d('无圆角'), val: ThemeShape.none },
|
18
25
|
]);
|
19
26
|
|
20
|
-
const
|
27
|
+
const change = (shape: typeof ThemeShape.TYPE) => {
|
28
|
+
PageThemeUtils.shape(shape, props.onlyCache || props.reloadOnChange);
|
29
|
+
emit.onChange(shape);
|
30
|
+
props.reloadOnChange && window.location.reload();
|
31
|
+
};
|
21
32
|
|
22
33
|
const classes = useClassCache(() => [
|
23
34
|
getComponentCls('theme-selector'),
|
@@ -36,7 +47,7 @@ export const ThemeShapeSelector = designComponent({
|
|
36
47
|
</div>
|
37
48
|
),
|
38
49
|
popper: () => radiusOptions.value.map(opt => (
|
39
|
-
<DropdownOption label={opt.label} val={opt.val} key={opt.val || ""} onClick={() =>
|
50
|
+
<DropdownOption label={opt.label} val={opt.val} key={opt.val || ""} onClick={() => change(opt.val as any)}/>
|
40
51
|
)),
|
41
52
|
}}
|
42
53
|
/>
|
@@ -5,11 +5,18 @@ import i18n from "../i18n";
|
|
5
5
|
import Icon from "../Icon";
|
6
6
|
import PageThemeUtils from "../PageThemeUtils";
|
7
7
|
import './theme-size-selector.scss';
|
8
|
+
import {ThemeSize} from "../../uses/useStyle";
|
8
9
|
|
9
10
|
export const ThemeSizeSelector = designComponent({
|
10
11
|
name: 'theme-size-selector',
|
11
|
-
props: {
|
12
|
-
|
12
|
+
props: {
|
13
|
+
reloadOnChange: { type: Boolean },
|
14
|
+
onlyCache: { type: Boolean },
|
15
|
+
},
|
16
|
+
emits: {
|
17
|
+
onChange: (size: typeof ThemeSize.TYPE) => true,
|
18
|
+
},
|
19
|
+
setup({ props, event: { emit } }) {
|
13
20
|
|
14
21
|
const sizeOptions = computed((): { label: string, val: string }[] => [
|
15
22
|
{ label: i18n.$it('theme.sizeOptions.large').d('大'), val: 'large' },
|
@@ -18,7 +25,11 @@ export const ThemeSizeSelector = designComponent({
|
|
18
25
|
{ label: i18n.$it('theme.sizeOptions.mini').d('极小'), val: 'mini' },
|
19
26
|
]);
|
20
27
|
|
21
|
-
const
|
28
|
+
const change = (size: typeof ThemeSize.TYPE) => {
|
29
|
+
PageThemeUtils.size(size, props.onlyCache || props.reloadOnChange);
|
30
|
+
emit.onChange(size);
|
31
|
+
props.reloadOnChange && window.location.reload();
|
32
|
+
};
|
22
33
|
|
23
34
|
const classes = useClassCache(() => [
|
24
35
|
getComponentCls('theme-selector'),
|
@@ -27,7 +38,7 @@ export const ThemeSizeSelector = designComponent({
|
|
27
38
|
return () => (
|
28
39
|
<Dropdown trigger="hover" align="center" placement="bottom" hideOnClickReference={false} v-slots={{
|
29
40
|
popper: () => sizeOptions.value.map(opt => (
|
30
|
-
<DropdownOption label={opt.label} val={opt.val} key={opt.val} onClick={() =>
|
41
|
+
<DropdownOption label={opt.label} val={opt.val} key={opt.val} onClick={() => change(opt.val as any)}/>
|
31
42
|
)),
|
32
43
|
default: () => (
|
33
44
|
<div className={classes.value}>
|