@king-design/intact 3.1.1-beta.3 → 3.1.2
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/components/affix/styles.ts +4 -2
- package/components/badge/index.vdt +1 -1
- package/components/badge/styles.ts +4 -3
- package/components/breadcrumb/index.vdt +1 -1
- package/components/breadcrumb/styles.ts +4 -2
- package/components/button/styles.ts +7 -5
- package/components/card/styles.ts +4 -2
- package/components/carousel/styles.ts +7 -4
- package/components/cascader/index.vdt +2 -1
- package/components/cascader/styles.ts +7 -4
- package/components/checkbox/index.vdt +1 -1
- package/components/checkbox/styles.ts +4 -2
- package/components/code/styles.ts +3 -2
- package/components/collapse/index.spec.ts +1 -1
- package/components/collapse/styles.ts +7 -4
- package/components/colorpicker/styles.ts +7 -4
- package/components/copy/styles.ts +3 -2
- package/components/datepicker/styles.ts +10 -6
- package/components/diagram/styles.ts +3 -2
- package/components/dialog/styles.ts +10 -6
- package/components/drawer/styles.ts +4 -2
- package/components/dropdown/styles.ts +7 -4
- package/components/editable/styles.ts +4 -2
- package/components/form/index.md +1 -0
- package/components/form/index.spec.ts +17 -0
- package/components/form/item.ts +2 -0
- package/components/form/styles.ts +7 -4
- package/components/form/useDirty.ts +4 -0
- package/components/grid/styles.ts +12 -9
- package/components/icon/index.vdt +1 -1
- package/components/icon/styles.ts +4 -2
- package/components/input/styles.ts +8 -5
- package/components/layout/styles.ts +13 -9
- package/components/menu/demos/recursive.md +340 -0
- package/components/menu/styles.ts +21 -16
- package/components/message/styles.ts +7 -5
- package/components/pagination/styles.ts +4 -2
- package/components/popover/content.vdt +1 -1
- package/components/popover/demos/basic.md +1 -0
- package/components/popover/styles.ts +12 -2
- package/components/progress/styles.ts +4 -4
- package/components/radio/styles.ts +4 -2
- package/components/rate/styles.ts +4 -2
- package/components/scrollSelect/styles.ts +4 -2
- package/components/select/base.ts +3 -2
- package/components/select/base.vdt +1 -1
- package/components/select/styles.ts +10 -6
- package/components/skeleton/styles.ts +7 -4
- package/components/slider/styles.ts +4 -2
- package/components/spin/styles.ts +4 -4
- package/components/spinner/styles.ts +4 -3
- package/components/split/styles.ts +4 -2
- package/components/steps/index.vdt +2 -2
- package/components/steps/styles.ts +7 -5
- package/components/switch/styles.ts +4 -2
- package/components/table/column.ts +2 -0
- package/components/table/column.vdt +7 -3
- package/components/table/demos/basic.md +2 -2
- package/components/table/demos/fixColumn.md +3 -1
- package/components/table/demos/groupHeader.md +11 -11
- package/components/table/demos/scheme.md +1 -1
- package/components/table/index.spec.ts +8 -3
- package/components/table/styles.ts +11 -8
- package/components/table/table.vdt +3 -4
- package/components/table/useColumns.ts +1 -0
- package/components/table/useFixedColumns.ts +27 -49
- package/components/table/useGroup.ts +5 -0
- package/components/table/useResizable.ts +38 -10
- package/components/table/useWidth.ts +3 -0
- package/components/tabs/styles.ts +4 -2
- package/components/tag/styles.ts +7 -4
- package/components/timeline/styles.ts +7 -5
- package/components/timepicker/styles.ts +4 -2
- package/components/tip/styles.ts +4 -2
- package/components/tooltip/content.vdt +1 -1
- package/components/tooltip/styles.ts +4 -2
- package/components/transfer/styles.ts +4 -2
- package/components/tree/demos/checkbox.md +1 -0
- package/components/tree/demos/contextmenu.md +10 -1
- package/components/tree/index.spec.ts +7 -0
- package/components/tree/styles.ts +4 -2
- package/components/tree/useChecked.ts +3 -0
- package/components/treeSelect/styles.ts +4 -2
- package/components/upload/styles.ts +7 -4
- package/components/utils.ts +10 -4
- package/components/wave/styles.ts +4 -2
- package/es/components/affix/styles.d.ts +4 -1
- package/es/components/affix/styles.js +4 -2
- package/es/components/badge/index.vdt.js +1 -1
- package/es/components/badge/styles.d.ts +4 -1
- package/es/components/badge/styles.js +4 -2
- package/es/components/breadcrumb/index.vdt.js +1 -1
- package/es/components/breadcrumb/styles.d.ts +4 -1
- package/es/components/breadcrumb/styles.js +4 -2
- package/es/components/button/styles.d.ts +8 -2
- package/es/components/button/styles.js +7 -4
- package/es/components/card/styles.d.ts +4 -1
- package/es/components/card/styles.js +4 -2
- package/es/components/carousel/styles.d.ts +8 -2
- package/es/components/carousel/styles.js +7 -4
- package/es/components/cascader/index.vdt.js +3 -1
- package/es/components/cascader/styles.d.ts +8 -2
- package/es/components/cascader/styles.js +7 -4
- package/es/components/checkbox/index.vdt.js +1 -1
- package/es/components/checkbox/styles.d.ts +4 -1
- package/es/components/checkbox/styles.js +4 -2
- package/es/components/code/styles.d.ts +4 -1
- package/es/components/code/styles.js +3 -2
- package/es/components/collapse/index.spec.js +1 -1
- package/es/components/collapse/styles.d.ts +8 -2
- package/es/components/collapse/styles.js +7 -4
- package/es/components/colorpicker/styles.d.ts +8 -2
- package/es/components/colorpicker/styles.js +7 -4
- package/es/components/copy/styles.d.ts +4 -1
- package/es/components/copy/styles.js +3 -2
- package/es/components/datepicker/styles.d.ts +12 -3
- package/es/components/datepicker/styles.js +10 -6
- package/es/components/diagram/styles.d.ts +4 -1
- package/es/components/diagram/styles.js +3 -2
- package/es/components/dialog/styles.d.ts +12 -3
- package/es/components/dialog/styles.js +10 -6
- package/es/components/drawer/styles.d.ts +4 -1
- package/es/components/drawer/styles.js +4 -2
- package/es/components/dropdown/styles.d.ts +8 -2
- package/es/components/dropdown/styles.js +7 -4
- package/es/components/editable/styles.d.ts +4 -1
- package/es/components/editable/styles.js +4 -2
- package/es/components/form/index.spec.js +43 -0
- package/es/components/form/item.d.ts +1 -0
- package/es/components/form/item.js +2 -1
- package/es/components/form/styles.d.ts +8 -2
- package/es/components/form/styles.js +7 -4
- package/es/components/form/useDirty.js +4 -0
- package/es/components/grid/styles.d.ts +8 -2
- package/es/components/grid/styles.js +12 -13
- package/es/components/icon/index.vdt.js +1 -1
- package/es/components/icon/styles.d.ts +4 -1
- package/es/components/icon/styles.js +4 -2
- package/es/components/input/styles.d.ts +8 -2
- package/es/components/input/styles.js +7 -4
- package/es/components/layout/styles.d.ts +16 -4
- package/es/components/layout/styles.js +13 -8
- package/es/components/menu/styles.d.ts +16 -4
- package/es/components/menu/styles.js +14 -9
- package/es/components/message/styles.d.ts +8 -2
- package/es/components/message/styles.js +7 -4
- package/es/components/pagination/styles.d.ts +4 -1
- package/es/components/pagination/styles.js +4 -2
- package/es/components/popover/content.vdt.js +1 -1
- package/es/components/popover/styles.d.ts +4 -1
- package/es/components/popover/styles.js +8 -3
- package/es/components/progress/styles.d.ts +4 -1
- package/es/components/progress/styles.js +4 -2
- package/es/components/radio/styles.d.ts +4 -1
- package/es/components/radio/styles.js +4 -2
- package/es/components/rate/styles.d.ts +4 -1
- package/es/components/rate/styles.js +4 -2
- package/es/components/scrollSelect/styles.d.ts +4 -1
- package/es/components/scrollSelect/styles.js +4 -2
- package/es/components/select/base.js +3 -1
- package/es/components/select/base.vdt.js +1 -1
- package/es/components/select/styles.d.ts +12 -3
- package/es/components/select/styles.js +10 -6
- package/es/components/skeleton/styles.d.ts +8 -2
- package/es/components/skeleton/styles.js +7 -4
- package/es/components/slider/styles.d.ts +4 -1
- package/es/components/slider/styles.js +4 -2
- package/es/components/spin/styles.d.ts +4 -1
- package/es/components/spin/styles.js +4 -2
- package/es/components/spinner/styles.d.ts +4 -1
- package/es/components/spinner/styles.js +4 -2
- package/es/components/split/styles.d.ts +4 -1
- package/es/components/split/styles.js +4 -2
- package/es/components/steps/index.vdt.js +2 -2
- package/es/components/steps/styles.d.ts +4 -3
- package/es/components/steps/styles.js +9 -4
- package/es/components/switch/styles.d.ts +4 -1
- package/es/components/switch/styles.js +4 -2
- package/es/components/table/column.d.ts +1 -0
- package/es/components/table/column.js +2 -1
- package/es/components/table/column.vdt.js +9 -3
- package/es/components/table/index.spec.js +18 -11
- package/es/components/table/styles.d.ts +8 -2
- package/es/components/table/styles.js +8 -5
- package/es/components/table/table.vdt.js +3 -4
- package/es/components/table/useColumns.js +1 -0
- package/es/components/table/useFixedColumns.d.ts +3 -3
- package/es/components/table/useFixedColumns.js +27 -46
- package/es/components/table/useGroup.d.ts +1 -0
- package/es/components/table/useGroup.js +11 -1
- package/es/components/table/useResizable.js +41 -5
- package/es/components/table/useWidth.js +3 -0
- package/es/components/tabs/styles.d.ts +4 -1
- package/es/components/tabs/styles.js +4 -2
- package/es/components/tag/styles.d.ts +8 -2
- package/es/components/tag/styles.js +7 -4
- package/es/components/timeline/styles.d.ts +8 -2
- package/es/components/timeline/styles.js +7 -5
- package/es/components/timepicker/styles.d.ts +4 -1
- package/es/components/timepicker/styles.js +4 -2
- package/es/components/tip/styles.d.ts +4 -1
- package/es/components/tip/styles.js +4 -2
- package/es/components/tooltip/content.vdt.js +1 -1
- package/es/components/tooltip/styles.d.ts +4 -1
- package/es/components/tooltip/styles.js +4 -2
- package/es/components/transfer/styles.d.ts +4 -1
- package/es/components/transfer/styles.js +4 -2
- package/es/components/tree/index.spec.js +13 -1
- package/es/components/tree/styles.d.ts +4 -1
- package/es/components/tree/styles.js +4 -2
- package/es/components/tree/useChecked.js +4 -0
- package/es/components/treeSelect/styles.d.ts +4 -1
- package/es/components/treeSelect/styles.js +4 -2
- package/es/components/upload/styles.d.ts +8 -2
- package/es/components/upload/styles.js +7 -4
- package/es/components/utils.d.ts +10 -2
- package/es/components/utils.js +9 -2
- package/es/components/wave/styles.d.ts +4 -1
- package/es/components/wave/styles.js +4 -2
- package/es/i18n/en-US.d.ts +1 -0
- package/es/i18n/en-US.js +1 -0
- package/es/index.d.ts +2 -2
- package/es/index.js +2 -2
- package/es/site/data/components/menu/demos/recursive/index.d.ts +29 -0
- package/es/site/data/components/menu/demos/recursive/index.js +57 -0
- package/es/site/data/components/menu/demos/recursive/react.d.ts +2 -0
- package/es/site/data/components/menu/demos/recursive/react.js +69 -0
- package/es/site/data/components/popover/demos/basic/react.js +2 -1
- package/es/site/data/components/table/demos/basic/react.js +4 -2
- package/es/site/data/components/table/demos/fixColumn/react.js +2 -1
- package/es/site/data/components/table/demos/groupHeader/react.js +11 -20
- package/es/site/data/components/table/demos/scheme/react.js +2 -1
- package/es/site/data/components/tree/demos/checkbox/index.d.ts +12 -2
- package/es/site/data/components/tree/demos/checkbox/index.js +1 -0
- package/es/site/data/components/tree/demos/checkbox/react.d.ts +12 -2
- package/es/site/data/components/tree/demos/checkbox/react.js +1 -0
- package/es/site/data/components/tree/demos/contextmenu/index.d.ts +1 -0
- package/es/site/data/components/tree/demos/contextmenu/index.js +1 -0
- package/es/site/data/components/tree/demos/contextmenu/react.d.ts +1 -0
- package/es/site/data/components/tree/demos/contextmenu/react.js +1 -0
- package/es/site/src/components/article/index.js +6 -2
- package/es/styles/fonts/iconfont.d.ts +4 -1
- package/es/styles/fonts/iconfont.js +1 -1
- package/es/styles/global.js +1 -1
- package/i18n/en-US.ts +1 -0
- package/index.ts +2 -2
- package/package.json +3 -3
- package/styles/fonts/iconfont.ts +2 -2
- package/styles/global.ts +22 -0
|
@@ -2,6 +2,7 @@ import {css} from '@emotion/css';
|
|
|
2
2
|
import {theme, setDefault} from '../../styles/theme';
|
|
3
3
|
import {deepDefaults} from '../../styles/utils';
|
|
4
4
|
import '../../styles/global';
|
|
5
|
+
import { cache } from '../utils';
|
|
5
6
|
|
|
6
7
|
const defaults = {
|
|
7
8
|
item: {
|
|
@@ -36,9 +37,11 @@ const defaults = {
|
|
|
36
37
|
let form: typeof defaults;
|
|
37
38
|
setDefault(() => {
|
|
38
39
|
form = deepDefaults(theme, {form: defaults}).form;
|
|
40
|
+
makeItemStyles?.clearCache();
|
|
41
|
+
makeFormStyles?.clearCache();
|
|
39
42
|
});
|
|
40
43
|
|
|
41
|
-
export function makeItemStyles(k: string) {
|
|
44
|
+
export const makeItemStyles = cache(function makeItemStyles(k: string) {
|
|
42
45
|
return css`
|
|
43
46
|
display: flex;
|
|
44
47
|
position: relative;
|
|
@@ -118,9 +121,9 @@ export function makeItemStyles(k: string) {
|
|
|
118
121
|
vertical-align: middle;
|
|
119
122
|
}
|
|
120
123
|
`
|
|
121
|
-
}
|
|
124
|
+
});
|
|
122
125
|
|
|
123
|
-
export function makeFormStyles(k: string) {
|
|
126
|
+
export const makeFormStyles = cache(function makeFormStyles(k: string) {
|
|
124
127
|
return css`
|
|
125
128
|
// layout
|
|
126
129
|
&.${k}-inline {
|
|
@@ -162,4 +165,4 @@ export function makeFormStyles(k: string) {
|
|
|
162
165
|
`
|
|
163
166
|
})}
|
|
164
167
|
`;
|
|
165
|
-
}
|
|
168
|
+
});
|
|
@@ -3,15 +3,18 @@ import {theme, setDefault} from '../../styles/theme';
|
|
|
3
3
|
import {deepDefaults} from '../../styles/utils';
|
|
4
4
|
import '../../styles/global';
|
|
5
5
|
import {breakpoints, responsiveMap} from './constants';
|
|
6
|
+
import { cache } from '../utils';
|
|
6
7
|
|
|
7
|
-
const defaults = {};
|
|
8
|
+
// const defaults = {};
|
|
8
9
|
|
|
9
|
-
let grid: typeof defaults;
|
|
10
|
-
setDefault(() => {
|
|
11
|
-
grid = deepDefaults(theme, {grid: defaults}).grid;
|
|
12
|
-
|
|
10
|
+
// let grid: typeof defaults;
|
|
11
|
+
// setDefault(() => {
|
|
12
|
+
// grid = deepDefaults(theme, {grid: defaults}).grid;
|
|
13
|
+
// makeRowStyles?.clearCache();
|
|
14
|
+
// makeColStyles?.clearCache();
|
|
15
|
+
// });
|
|
13
16
|
|
|
14
|
-
export function makeRowStyles(k: string) {
|
|
17
|
+
export const makeRowStyles = cache(function makeRowStyles(k: string) {
|
|
15
18
|
return css`
|
|
16
19
|
position: relative;
|
|
17
20
|
display: flex;
|
|
@@ -52,9 +55,9 @@ export function makeRowStyles(k: string) {
|
|
|
52
55
|
align-items: baseline;
|
|
53
56
|
}
|
|
54
57
|
`;
|
|
55
|
-
}
|
|
58
|
+
});
|
|
56
59
|
|
|
57
|
-
export function makeColStyles(k: string) {
|
|
60
|
+
export const makeColStyles = cache(function makeColStyles(k: string) {
|
|
58
61
|
return css`
|
|
59
62
|
position: relative;
|
|
60
63
|
width: 100%;
|
|
@@ -63,7 +66,7 @@ export function makeColStyles(k: string) {
|
|
|
63
66
|
}
|
|
64
67
|
${makeBreakpointsCols(k)}
|
|
65
68
|
`;
|
|
66
|
-
}
|
|
69
|
+
});
|
|
67
70
|
|
|
68
71
|
function makeBreakpointsCols(k: string) {
|
|
69
72
|
const styles: string[] = [];
|
|
@@ -5,6 +5,7 @@ import {rotate} from '../../styles/keyframes';
|
|
|
5
5
|
import {makeIconStyles} from '../../styles/fonts/iconfont';
|
|
6
6
|
import '../../styles/fonts/ionicons';
|
|
7
7
|
import '../../styles/global';
|
|
8
|
+
import { cache } from '../utils';
|
|
8
9
|
|
|
9
10
|
const defaults = {
|
|
10
11
|
get transition() { return theme.transition.small },
|
|
@@ -21,12 +22,13 @@ const defaults = {
|
|
|
21
22
|
let icon: typeof defaults;
|
|
22
23
|
setDefault(() => {
|
|
23
24
|
icon = deepDefaults(theme, {icon: defaults}).icon;
|
|
25
|
+
makeStyles?.clearCache();
|
|
24
26
|
});
|
|
25
27
|
|
|
26
28
|
export const colors = ['primary', 'warning', 'danger', 'success'] as const;
|
|
27
29
|
export const sizes = ['large', 'small', 'mini'] as const;
|
|
28
30
|
|
|
29
|
-
export
|
|
31
|
+
export const makeStyles = cache(function makeStyles(k: string, color?: string) {
|
|
30
32
|
// create the global icon styles
|
|
31
33
|
makeIconStyles(k);
|
|
32
34
|
|
|
@@ -86,4 +88,4 @@ export default function makeStyles(k: string, color?: string) {
|
|
|
86
88
|
color: ${icon.disabledColor} !important;
|
|
87
89
|
}
|
|
88
90
|
`;
|
|
89
|
-
}
|
|
91
|
+
});
|
|
@@ -3,6 +3,7 @@ import {theme, setDefault} from '../../styles/theme';
|
|
|
3
3
|
import {deepDefaults, sizes, Sizes} from '../../styles/utils';
|
|
4
4
|
import '../../styles/global';
|
|
5
5
|
import {Input} from './';
|
|
6
|
+
import { cache } from '../utils';
|
|
6
7
|
|
|
7
8
|
const defaults = deepDefaults(
|
|
8
9
|
{
|
|
@@ -67,9 +68,11 @@ const defaults = deepDefaults(
|
|
|
67
68
|
let input: typeof defaults;
|
|
68
69
|
setDefault(() => {
|
|
69
70
|
input = deepDefaults(theme, {input: defaults}).input;
|
|
70
|
-
|
|
71
|
+
makeStyles?.clearCache();
|
|
72
|
+
makeSearchStyles?.clearCache();
|
|
73
|
+
});
|
|
71
74
|
|
|
72
|
-
export function makeStyles(k: string) {
|
|
75
|
+
export const makeStyles = cache(function makeStyles(k: string) {
|
|
73
76
|
return css`
|
|
74
77
|
display: inline-block;
|
|
75
78
|
width: ${input.width};
|
|
@@ -322,9 +325,9 @@ export function makeStyles(k: string) {
|
|
|
322
325
|
color: ${input.count.color};
|
|
323
326
|
}
|
|
324
327
|
`
|
|
325
|
-
}
|
|
328
|
+
});
|
|
326
329
|
|
|
327
|
-
export function makeSearchStyles(k: string) {
|
|
330
|
+
export const makeSearchStyles = cache(function makeSearchStyles(k: string) {
|
|
328
331
|
return css`
|
|
329
332
|
position: relative;
|
|
330
333
|
display: inline-block;
|
|
@@ -377,4 +380,4 @@ export function makeSearchStyles(k: string) {
|
|
|
377
380
|
}
|
|
378
381
|
}
|
|
379
382
|
`
|
|
380
|
-
}
|
|
383
|
+
});
|
|
@@ -5,6 +5,7 @@ import '../../styles/global';
|
|
|
5
5
|
import {menu} from '../menu/styles';
|
|
6
6
|
import { isNullOrUndefined } from 'intact-shared';
|
|
7
7
|
import { getStyle } from './helpers';
|
|
8
|
+
import { cache } from '../utils';
|
|
8
9
|
|
|
9
10
|
const sizes = ['small', 'large'] as const;
|
|
10
11
|
export const themes = ['light', 'dark', 'white'] as const;
|
|
@@ -32,13 +33,17 @@ const defaults = {
|
|
|
32
33
|
let layout: typeof defaults;
|
|
33
34
|
setDefault(() => {
|
|
34
35
|
layout = deepDefaults(theme, {layout: defaults}).layout;
|
|
36
|
+
makeLayoutStyles?.clearCache();
|
|
37
|
+
makeHeaderStyles?.clearCache();
|
|
38
|
+
makeAsideStyles?.clearCache();
|
|
39
|
+
makeBodyStyles?.clearCache();
|
|
35
40
|
});
|
|
36
41
|
|
|
37
42
|
export function getCollapseWidth(collapsedWidth?: string | number) {
|
|
38
43
|
return isNullOrUndefined(collapsedWidth) ? layout.collapsedWidth : getStyle(collapsedWidth);
|
|
39
44
|
}
|
|
40
45
|
|
|
41
|
-
export function makeLayoutStyles(k: string) {
|
|
46
|
+
export const makeLayoutStyles = cache(function makeLayoutStyles(k: string) {
|
|
42
47
|
return css`
|
|
43
48
|
display: flex;
|
|
44
49
|
flex-direction: column;
|
|
@@ -54,9 +59,9 @@ export function makeLayoutStyles(k: string) {
|
|
|
54
59
|
flex: 1;
|
|
55
60
|
}
|
|
56
61
|
`
|
|
57
|
-
}
|
|
62
|
+
});
|
|
58
63
|
|
|
59
|
-
export function makeHeaderStyles(k: string) {
|
|
64
|
+
export const makeHeaderStyles = cache(function makeHeaderStyles(k: string) {
|
|
60
65
|
return css`
|
|
61
66
|
display: flex;
|
|
62
67
|
align-items: center;
|
|
@@ -99,9 +104,9 @@ export function makeHeaderStyles(k: string) {
|
|
|
99
104
|
`
|
|
100
105
|
})}
|
|
101
106
|
`;
|
|
102
|
-
}
|
|
107
|
+
});
|
|
103
108
|
|
|
104
|
-
export function makeAsideStyles(k: string) {
|
|
109
|
+
export const makeAsideStyles = cache(function makeAsideStyles(k: string) {
|
|
105
110
|
return css`
|
|
106
111
|
transition: width ${layout.transition};
|
|
107
112
|
display: flex;
|
|
@@ -131,11 +136,10 @@ export function makeAsideStyles(k: string) {
|
|
|
131
136
|
width: auto !important;
|
|
132
137
|
}
|
|
133
138
|
`
|
|
134
|
-
}
|
|
139
|
+
});
|
|
135
140
|
|
|
136
|
-
export function makeBodyStyles(k: string) {
|
|
141
|
+
export const makeBodyStyles = cache(function makeBodyStyles(k: string) {
|
|
137
142
|
return css`
|
|
138
143
|
transition: padding-left ${layout.transition};
|
|
139
144
|
`
|
|
140
|
-
}
|
|
141
|
-
|
|
145
|
+
});
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 递归渲染子菜单
|
|
3
|
+
order: 5
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
由于`Menu`和`MenuItem`必须直接嵌套才能渲染子菜单,所以在vue下,必须使用jsx才能实现递归渲染,递归组件会
|
|
7
|
+
阻断直接嵌套关系,导致达不到效果
|
|
8
|
+
|
|
9
|
+
```vdt
|
|
10
|
+
import {Menu, MenuItem, Icon} from 'kpc';
|
|
11
|
+
|
|
12
|
+
const renderMenuItem = (item) => {
|
|
13
|
+
return <MenuItem key={item.key}>
|
|
14
|
+
{item.title}
|
|
15
|
+
{item.children && item.children.length && (
|
|
16
|
+
<Menu>
|
|
17
|
+
{item.children.map(renderMenuItem)}
|
|
18
|
+
</Menu>
|
|
19
|
+
)}
|
|
20
|
+
</MenuItem>
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
<Menu
|
|
24
|
+
v-model:expandedKeys="expandedKeys"
|
|
25
|
+
v-model:selectedKey="selectedKey"
|
|
26
|
+
>
|
|
27
|
+
<b:header>
|
|
28
|
+
<Icon class="ion-star" />测试
|
|
29
|
+
</b:header>
|
|
30
|
+
{this.get('menuList').map(renderMenuItem)}
|
|
31
|
+
</Menu>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
export default class extends Component {
|
|
36
|
+
static template = template;
|
|
37
|
+
|
|
38
|
+
static defaults() {
|
|
39
|
+
return {
|
|
40
|
+
expandedKeys: [],
|
|
41
|
+
selectedKey: '3-1',
|
|
42
|
+
menuList: [
|
|
43
|
+
{
|
|
44
|
+
key: '1',
|
|
45
|
+
title: 'menu 1'
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
key: '2',
|
|
49
|
+
title: 'menu 2'
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
key: '3',
|
|
53
|
+
title: 'menu 3',
|
|
54
|
+
children: [
|
|
55
|
+
{
|
|
56
|
+
key: '3-1',
|
|
57
|
+
title: 'sub menu 1'
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
key: '3-2',
|
|
61
|
+
title: 'sub menu 2'
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
key: '3-3',
|
|
65
|
+
title: 'sub menu 3'
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
key: '3-4',
|
|
69
|
+
title: 'sub menu 4',
|
|
70
|
+
children: [
|
|
71
|
+
{
|
|
72
|
+
key: '3-4-1',
|
|
73
|
+
title: 'option 1'
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
key: '3-4-2',
|
|
77
|
+
title: 'option 2'
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
key: '4',
|
|
85
|
+
title: 'menu 4'
|
|
86
|
+
},
|
|
87
|
+
]
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
import { Menu, MenuItem, Icon } from '@king-design/react';
|
|
95
|
+
import React, { useState } from 'react';
|
|
96
|
+
|
|
97
|
+
type MenuItemData = {
|
|
98
|
+
key: string;
|
|
99
|
+
title: string;
|
|
100
|
+
children?: MenuItemData[];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export default function() {
|
|
104
|
+
const [expandedKeys, setExpandedKeys] = useState<string[]>([]);
|
|
105
|
+
const [selectedKey, setSelectedKey] = useState('3-1');
|
|
106
|
+
const [menuList] = useState<MenuItemData[]>([
|
|
107
|
+
{
|
|
108
|
+
key: '1',
|
|
109
|
+
title: 'menu 1'
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
key: '2',
|
|
113
|
+
title: 'menu 2'
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
key: '3',
|
|
117
|
+
title: 'menu 3',
|
|
118
|
+
children: [
|
|
119
|
+
{
|
|
120
|
+
key: '3-1',
|
|
121
|
+
title: 'sub menu 1'
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
key: '3-2',
|
|
125
|
+
title: 'sub menu 2'
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
key: '3-3',
|
|
129
|
+
title: 'sub menu 3'
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
key: '3-4',
|
|
133
|
+
title: 'sub menu 4',
|
|
134
|
+
children: [
|
|
135
|
+
{
|
|
136
|
+
key: '3-4-1',
|
|
137
|
+
title: 'option 1'
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
key: '3-4-2',
|
|
141
|
+
title: 'option 2'
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
]
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
key: '4',
|
|
149
|
+
title: 'menu 4'
|
|
150
|
+
},
|
|
151
|
+
]);
|
|
152
|
+
|
|
153
|
+
return <Menu
|
|
154
|
+
expandedKeys={expandedKeys}
|
|
155
|
+
onChangeExpandedKeys={(v) => setExpandedKeys(v!)}
|
|
156
|
+
selectedKey={selectedKey}
|
|
157
|
+
onChangeSelectedKey={(v) => setSelectedKey(v!)}
|
|
158
|
+
slotHeader={<><Icon className="ion-star" />测试</>}
|
|
159
|
+
>
|
|
160
|
+
{menuList.map(renderMenuItem)}
|
|
161
|
+
</Menu>
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function renderMenuItem(item: MenuItemData) {
|
|
165
|
+
return <MenuItem key={item.key}>
|
|
166
|
+
{item.title}
|
|
167
|
+
{item.children && item.children.length && (
|
|
168
|
+
<Menu>
|
|
169
|
+
{item.children.map(renderMenuItem)}
|
|
170
|
+
</Menu>
|
|
171
|
+
)}
|
|
172
|
+
</MenuItem>
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
```vue
|
|
177
|
+
<script lang="jsx">
|
|
178
|
+
import { Menu, MenuItem, Icon } from "@king-design/vue-legacy";
|
|
179
|
+
export default {
|
|
180
|
+
data() {
|
|
181
|
+
return {
|
|
182
|
+
expandedKeys: [],
|
|
183
|
+
selectedKey: '3-1',
|
|
184
|
+
menuList: [
|
|
185
|
+
{
|
|
186
|
+
key: '1',
|
|
187
|
+
title: 'menu 1'
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
key: '2',
|
|
191
|
+
title: 'menu 2'
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
key: '3',
|
|
195
|
+
title: 'menu 3',
|
|
196
|
+
children: [
|
|
197
|
+
{
|
|
198
|
+
key: '3-1',
|
|
199
|
+
title: 'sub menu 1'
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
key: '3-2',
|
|
203
|
+
title: 'sub menu 2'
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
key: '3-3',
|
|
207
|
+
title: 'sub menu 3'
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
key: '3-4',
|
|
211
|
+
title: 'sub menu 4',
|
|
212
|
+
children: [
|
|
213
|
+
{
|
|
214
|
+
key: '3-4-1',
|
|
215
|
+
title: 'option 1'
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
key: '3-4-2',
|
|
219
|
+
title: 'option 2'
|
|
220
|
+
}
|
|
221
|
+
]
|
|
222
|
+
}
|
|
223
|
+
]
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
key: '4',
|
|
227
|
+
title: 'menu 4'
|
|
228
|
+
},
|
|
229
|
+
]
|
|
230
|
+
};
|
|
231
|
+
},
|
|
232
|
+
render(h) {
|
|
233
|
+
const renderMenuItem = (item) => {
|
|
234
|
+
return <MenuItem key={item.key}>
|
|
235
|
+
{item.title}
|
|
236
|
+
{item.children && item.children.length && (
|
|
237
|
+
<Menu>
|
|
238
|
+
{item.children.map(renderMenuItem)}
|
|
239
|
+
</Menu>
|
|
240
|
+
)}
|
|
241
|
+
</MenuItem>
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return (
|
|
245
|
+
<Menu
|
|
246
|
+
expandedKeys={this.expandedKeys}
|
|
247
|
+
onChangeExpandedKeys={(v) => (this.expandedKeys = v)}
|
|
248
|
+
selectedKey={this.selectedKey}
|
|
249
|
+
onChangeSelectedKey={(v) => (this.selectedKey = v)}
|
|
250
|
+
>
|
|
251
|
+
<template slot="header">
|
|
252
|
+
<Icon class="ion-star" />测试
|
|
253
|
+
</template>
|
|
254
|
+
{this.menuList.map(renderMenuItem)}
|
|
255
|
+
</Menu>
|
|
256
|
+
)
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
</script>
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
```vue3
|
|
263
|
+
<script lang="jsx">
|
|
264
|
+
import { Menu, MenuItem, Icon } from "@king-design/vue";
|
|
265
|
+
import { ref, defineComponent } from 'vue';
|
|
266
|
+
|
|
267
|
+
export default defineComponent({
|
|
268
|
+
setup() {
|
|
269
|
+
const expandedKeys = ref([]);
|
|
270
|
+
const selectedKey = ref('3-1');
|
|
271
|
+
const menuList = [
|
|
272
|
+
{
|
|
273
|
+
key: '1',
|
|
274
|
+
title: 'menu 1'
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
key: '2',
|
|
278
|
+
title: 'menu 2'
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
key: '3',
|
|
282
|
+
title: 'menu 3',
|
|
283
|
+
children: [
|
|
284
|
+
{
|
|
285
|
+
key: '3-1',
|
|
286
|
+
title: 'sub menu 1'
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
key: '3-2',
|
|
290
|
+
title: 'sub menu 2'
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
key: '3-3',
|
|
294
|
+
title: 'sub menu 3'
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
key: '3-4',
|
|
298
|
+
title: 'sub menu 4',
|
|
299
|
+
children: [
|
|
300
|
+
{
|
|
301
|
+
key: '3-4-1',
|
|
302
|
+
title: 'option 1'
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
key: '3-4-2',
|
|
306
|
+
title: 'option 2'
|
|
307
|
+
}
|
|
308
|
+
]
|
|
309
|
+
}
|
|
310
|
+
]
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
key: '4',
|
|
314
|
+
title: 'menu 4'
|
|
315
|
+
},
|
|
316
|
+
];
|
|
317
|
+
const renderMenuItem = (item) => {
|
|
318
|
+
return <MenuItem key={item.key}>
|
|
319
|
+
{item.title}
|
|
320
|
+
{item.children && item.children.length && (
|
|
321
|
+
<Menu>
|
|
322
|
+
{item.children.map(renderMenuItem)}
|
|
323
|
+
</Menu>
|
|
324
|
+
)}
|
|
325
|
+
</MenuItem>
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return () => (
|
|
329
|
+
<Menu
|
|
330
|
+
v-model:expandedKeys={expandedKeys.value}
|
|
331
|
+
v-model:selectedKey={selectedKey.value}
|
|
332
|
+
v-slots={{ header() { return <><Icon class="ion-star" />测试</> } }}
|
|
333
|
+
>
|
|
334
|
+
{menuList.map(renderMenuItem)}
|
|
335
|
+
</Menu>
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
</script>
|
|
340
|
+
```
|
|
@@ -2,6 +2,7 @@ import {css} from '@emotion/css';
|
|
|
2
2
|
import {theme, setDefault} from '../../styles/theme';
|
|
3
3
|
import {deepDefaults, getLeft, palette} from '../../styles/utils';
|
|
4
4
|
import '../../styles/global';
|
|
5
|
+
import { cache } from '../utils';
|
|
5
6
|
|
|
6
7
|
const sizes = ['large', 'small'] as const;
|
|
7
8
|
|
|
@@ -81,11 +82,15 @@ const defaults = {
|
|
|
81
82
|
let menu: typeof defaults;
|
|
82
83
|
setDefault(() => {
|
|
83
84
|
menu = deepDefaults(theme, {menu: defaults}).menu;
|
|
85
|
+
makeMenuStyles?.clearCache();
|
|
86
|
+
makeItemStyles?.clearCache();
|
|
87
|
+
makeTitleStyles?.clearCache();
|
|
88
|
+
makeNestedMenuStyles?.clearCache();
|
|
84
89
|
});
|
|
85
90
|
|
|
86
91
|
export {menu};
|
|
87
92
|
|
|
88
|
-
export function makeMenuStyles(k: string) {
|
|
93
|
+
export const makeMenuStyles = cache(function makeMenuStyles(k: string) {
|
|
89
94
|
// we must increase the priority by adding &.${k}-menu
|
|
90
95
|
// to override the css of dropdownMenu
|
|
91
96
|
return css`
|
|
@@ -209,9 +214,9 @@ export function makeMenuStyles(k: string) {
|
|
|
209
214
|
}
|
|
210
215
|
}
|
|
211
216
|
`
|
|
212
|
-
}
|
|
217
|
+
});
|
|
213
218
|
|
|
214
|
-
export function makeTitleStyles(k: string) {
|
|
219
|
+
export const makeTitleStyles = cache(function makeTitleStyles(k: string) {
|
|
215
220
|
const item = menu.item;
|
|
216
221
|
return css`
|
|
217
222
|
display: flex;
|
|
@@ -222,16 +227,16 @@ export function makeTitleStyles(k: string) {
|
|
|
222
227
|
overflow: hidden;
|
|
223
228
|
flex-wrap: nowrap;
|
|
224
229
|
`;
|
|
225
|
-
}
|
|
230
|
+
});
|
|
226
231
|
|
|
227
|
-
export function makeItemStyles(k: string) {
|
|
232
|
+
export const makeItemStyles = cache(function makeItemStyles(k: string) {
|
|
228
233
|
const item = menu.item;
|
|
229
234
|
return css`
|
|
230
235
|
.${k}-menu-title {
|
|
231
236
|
cursor: pointer;
|
|
232
|
-
height: ${
|
|
237
|
+
height: ${item.height};
|
|
233
238
|
&:hover {
|
|
234
|
-
color: ${
|
|
239
|
+
color: ${item.hoverColor};
|
|
235
240
|
}
|
|
236
241
|
}
|
|
237
242
|
.${k}-menu-name {
|
|
@@ -256,7 +261,7 @@ export function makeItemStyles(k: string) {
|
|
|
256
261
|
// expanded
|
|
257
262
|
&.${k}-expanded {
|
|
258
263
|
> .${k}-menu-title {
|
|
259
|
-
color: ${
|
|
264
|
+
color: ${item.hoverColor};
|
|
260
265
|
.${k}-menu-arrow {
|
|
261
266
|
transform: rotateX(180deg);
|
|
262
267
|
}
|
|
@@ -266,35 +271,35 @@ export function makeItemStyles(k: string) {
|
|
|
266
271
|
// highlighted
|
|
267
272
|
&.${k}-highlighted {
|
|
268
273
|
> .${k}-menu-title {
|
|
269
|
-
color: ${
|
|
274
|
+
color: ${item.hoverColor};
|
|
270
275
|
}
|
|
271
276
|
}
|
|
272
277
|
|
|
273
278
|
// active
|
|
274
279
|
&.${k}-active {
|
|
275
280
|
> .${k}-menu-title {
|
|
276
|
-
color: ${
|
|
277
|
-
background: ${
|
|
281
|
+
color: ${item.hoverColor} !important;
|
|
282
|
+
background: ${item.activeBgColor};
|
|
278
283
|
}
|
|
279
284
|
}
|
|
280
285
|
|
|
281
286
|
// disabled
|
|
282
287
|
&.${k}-disabled {
|
|
283
288
|
> .${k}-menu-title {
|
|
284
|
-
color: ${
|
|
289
|
+
color: ${item.disabledColor} !important;
|
|
285
290
|
cursor: not-allowed;
|
|
286
291
|
}
|
|
287
292
|
}
|
|
288
293
|
|
|
289
294
|
// dot
|
|
290
295
|
.${k}-menu-dot {
|
|
291
|
-
font-size: ${
|
|
296
|
+
font-size: ${item.dotFontSize};
|
|
292
297
|
transform: scale(.4);
|
|
293
298
|
}
|
|
294
299
|
`
|
|
295
|
-
}
|
|
300
|
+
});
|
|
296
301
|
|
|
297
|
-
export function makeNestedMenuStyles(k: string, hasIcon: boolean, parentPaddingLeft: string = getLeft(menu.item.padding)) {
|
|
302
|
+
export const makeNestedMenuStyles = cache(function makeNestedMenuStyles(k: string, hasIcon: boolean, parentPaddingLeft: string = getLeft(menu.item.padding)) {
|
|
298
303
|
const paddingLeft = `${parentPaddingLeft}${hasIcon ? ' + ' + menu.icon.width : ''} + ${menu.icon.gap}`;
|
|
299
304
|
return [
|
|
300
305
|
css`
|
|
@@ -308,4 +313,4 @@ export function makeNestedMenuStyles(k: string, hasIcon: boolean, parentPaddingL
|
|
|
308
313
|
`,
|
|
309
314
|
paddingLeft,
|
|
310
315
|
]
|
|
311
|
-
}
|
|
316
|
+
});
|