@king-design/intact 3.0.0-beta.2 → 3.0.1
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/badge/styles.ts +1 -1
- package/components/breadcrumb/demos/separator.md +1 -1
- package/components/button/demos/group.md +7 -0
- package/components/button/group.ts +3 -1
- package/components/button/group.vdt +2 -1
- package/components/button/index.md +1 -0
- package/components/button/index.vdt +1 -1
- package/components/button/styles.ts +18 -3
- package/components/checkbox/styles.ts +6 -10
- package/components/collapse/styles.ts +0 -2
- package/components/dropdown/dropdown.ts +1 -0
- package/components/dropdown/usePosition.ts +2 -1
- package/components/form/index.spec.ts +21 -0
- package/components/form/styles.ts +1 -0
- package/components/icon/index.vdt +1 -1
- package/components/layout/body.ts +7 -2
- package/components/layout/demos/aside.md +1 -1
- package/components/layout/demos/basic.md +29 -9
- package/components/layout/header.ts +7 -1
- package/components/layout/helpers.ts +1 -0
- package/components/layout/index.md +2 -0
- package/components/layout/index.spec.ts +32 -0
- package/components/layout/layout.ts +4 -2
- package/components/layout/styles.ts +19 -3
- package/components/menu/styles.ts +8 -2
- package/components/menu/useDropdown.ts +5 -1
- package/components/message/demos/config.md +2 -2
- package/components/message/index.md +1 -1
- package/components/message/message.ts +1 -1
- package/components/pagination/styles.ts +1 -4
- package/components/popover/styles.ts +1 -1
- package/components/radio/styles.ts +4 -1
- package/components/scrollSelect/styles.ts +1 -1
- package/components/select/base.vdt +7 -4
- package/components/select/styles.ts +1 -1
- package/components/switch/styles.ts +17 -1
- package/components/table/column.vdt +3 -2
- package/components/table/demos/pagination.md +6 -0
- package/components/table/demos/showIndeterminate.md +2 -2
- package/components/table/index.md +2 -1
- package/components/table/index.spec.ts +1 -1
- package/components/table/row.ts +9 -1
- package/components/table/styles.ts +5 -2
- package/components/table/table.ts +3 -2
- package/components/table/useGroup.ts +2 -1
- package/components/table/usePagination.ts +1 -1
- package/components/tabs/demos/closable.md +1 -1
- package/components/tip/styles.ts +1 -1
- package/components/tooltip/index.spec.ts +30 -0
- package/components/tooltip/tooltip.ts +3 -0
- package/components/utils.ts +15 -0
- package/components/virtual.ts +4 -2
- package/es/components/badge/styles.js +1 -1
- package/es/components/button/group.d.ts +1 -0
- package/es/components/button/group.js +2 -1
- package/es/components/button/group.vdt.js +4 -2
- package/es/components/button/index.vdt.js +1 -1
- package/es/components/button/styles.js +11 -4
- package/es/components/checkbox/styles.js +4 -8
- package/es/components/collapse/styles.js +2 -2
- package/es/components/dropdown/dropdown.js +2 -1
- package/es/components/dropdown/usePosition.js +2 -2
- package/es/components/form/index.spec.js +45 -0
- package/es/components/form/styles.js +1 -1
- package/es/components/icon/index.vdt.js +3 -2
- package/es/components/layout/body.d.ts +1 -0
- package/es/components/layout/body.js +7 -2
- package/es/components/layout/header.d.ts +2 -0
- package/es/components/layout/header.js +9 -3
- package/es/components/layout/helpers.d.ts +1 -0
- package/es/components/layout/helpers.js +1 -0
- package/es/components/layout/index.spec.d.ts +1 -0
- package/es/components/layout/index.spec.js +53 -0
- package/es/components/layout/layout.d.ts +1 -0
- package/es/components/layout/layout.js +3 -2
- package/es/components/layout/styles.js +5 -5
- package/es/components/menu/styles.js +2 -2
- package/es/components/menu/useDropdown.js +6 -1
- package/es/components/message/message.js +1 -1
- package/es/components/pagination/styles.js +2 -5
- package/es/components/popover/styles.js +1 -1
- package/es/components/radio/styles.js +1 -1
- package/es/components/scrollSelect/styles.js +1 -1
- package/es/components/select/base.vdt.js +4 -1
- package/es/components/select/styles.js +1 -1
- package/es/components/switch/styles.js +10 -2
- package/es/components/table/column.vdt.js +4 -2
- package/es/components/table/index.spec.js +1 -1
- package/es/components/table/row.js +8 -1
- package/es/components/table/styles.js +2 -2
- package/es/components/table/table.d.ts +1 -1
- package/es/components/table/table.js +3 -2
- package/es/components/table/useGroup.d.ts +1 -1
- package/es/components/table/useGroup.js +2 -1
- package/es/components/table/usePagination.js +1 -1
- package/es/components/tip/styles.js +1 -1
- package/es/components/tooltip/index.spec.js +57 -0
- package/es/components/tooltip/tooltip.js +5 -1
- package/es/components/utils.d.ts +1 -0
- package/es/components/utils.js +16 -0
- package/es/components/virtual.js +5 -2
- package/es/index.d.ts +2 -2
- package/es/index.js +2 -2
- package/es/site/data/components/button/demos/group/react.js +17 -0
- package/es/site/data/components/layout/demos/aside/react.js +2 -1
- package/es/site/data/components/layout/demos/basic/react.js +13 -4
- package/es/site/data/components/message/demos/config/index.js +1 -1
- package/es/site/data/components/message/demos/config/react.js +1 -1
- package/es/site/data/components/table/demos/pagination/index.d.ts +4 -0
- package/es/site/data/components/table/demos/pagination/index.js +11 -2
- package/es/site/data/components/table/demos/pagination/react.d.ts +4 -0
- package/es/site/data/components/table/demos/pagination/react.js +11 -3
- package/es/site/data/components/table/demos/showIndeterminate/react.js +1 -1
- package/es/site/data/components/tabs/demos/closable/react.js +2 -1
- package/es/site/src/pages/layout.js +1 -3
- package/es/styles/fonts/iconfont.eot +0 -0
- package/es/styles/fonts/iconfont.js +1 -1
- package/es/styles/fonts/iconfont.svg +1 -1
- package/es/styles/fonts/iconfont.ttf +0 -0
- package/es/styles/fonts/iconfont.woff +0 -0
- package/es/styles/theme.js +1 -1
- package/es/styles/utils.d.ts +1 -0
- package/es/styles/utils.js +3 -0
- package/index.ts +2 -2
- package/package.json +3 -3
- package/styles/fonts/demo_index.html +6 -6
- package/styles/fonts/iconfont.css +6 -6
- package/styles/fonts/iconfont.eot +0 -0
- package/styles/fonts/iconfont.js +1 -1
- package/styles/fonts/iconfont.svg +1 -1
- package/styles/fonts/iconfont.ts +1 -1
- package/styles/fonts/iconfont.ttf +0 -0
- package/styles/fonts/iconfont.woff +0 -0
- package/styles/fonts/iconfont.woff2 +0 -0
- package/styles/theme.ts +1 -1
- package/styles/utils.ts +5 -1
- package/es/site/data/components/menu/demos/collapse/react.d.ts +0 -11
- package/es/site/data/components/menu/demos/size/react.d.ts +0 -7
|
@@ -61,6 +61,13 @@ import {Button, ButtonGroup} from 'kpc';
|
|
|
61
61
|
<Button value="guangzhou" size="small">广州</Button>
|
|
62
62
|
<Button value="shenzhen" size="small">深圳</Button>
|
|
63
63
|
</ButtonGroup>
|
|
64
|
+
<p>有间隔的按钮组</p>
|
|
65
|
+
<ButtonGroup checkType="radio" v-model="city" seperate>
|
|
66
|
+
<Button value="beijing">北京</Button>
|
|
67
|
+
<Button value="shanghai">上海</Button>
|
|
68
|
+
<Button value="guangzhou">广州</Button>
|
|
69
|
+
<Button value="shenzhen">深圳</Button>
|
|
70
|
+
</ButtonGroup>
|
|
64
71
|
</div>
|
|
65
72
|
```
|
|
66
73
|
|
|
@@ -8,13 +8,15 @@ export interface ButtonGroupProps {
|
|
|
8
8
|
value?: any
|
|
9
9
|
checkType?: 'none' | 'radio' | 'checkbox'
|
|
10
10
|
fluid?: boolean
|
|
11
|
+
seperate?: boolean
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
const typeDefs: Required<TypeDefs<ButtonGroupProps>> = {
|
|
14
15
|
vertical: Boolean,
|
|
15
16
|
value: null,
|
|
16
17
|
fluid: Boolean,
|
|
17
|
-
checkType: ['none', 'radio', 'checkbox']
|
|
18
|
+
checkType: ['none', 'radio', 'checkbox'],
|
|
19
|
+
seperate: Boolean,
|
|
18
20
|
};
|
|
19
21
|
|
|
20
22
|
const defaults = (): Partial<ButtonGroupProps> => ({
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {getRestProps} from '../utils';
|
|
2
2
|
import {makeButtonGroupStyles} from './styles';
|
|
3
3
|
|
|
4
|
-
const {className, vertical, children, fluid} = this.get();
|
|
4
|
+
const {className, vertical, children, fluid, seperate} = this.get();
|
|
5
5
|
|
|
6
6
|
const classNameObj = {
|
|
7
7
|
'k-btns': true,
|
|
8
8
|
'k-vertical': vertical,
|
|
9
9
|
'k-fluid': fluid,
|
|
10
|
+
'k-seperate': seperate,
|
|
10
11
|
[className]: className,
|
|
11
12
|
[makeButtonGroupStyles()]: true,
|
|
12
13
|
};
|
|
@@ -32,6 +32,7 @@ sidebar: doc
|
|
|
32
32
|
| checkType | 指定按钮组为单选或复选类型,此时需要给每个按钮指定`value`来作为选中的值 | `"radio"` | `"checkbox"` | `"none"` | `"none"` |
|
|
33
33
|
| value | 对于`radio`和`checkbox`类型按钮组,该值表示选中的按钮的值,可以使用`v-model`进行双向绑定 | `*` | `undefined` |
|
|
34
34
|
| fluid | 是否宽度100% | `boolean` | `false` |
|
|
35
|
+
| seperate | 是否展示间隔 | `boolean` | `false` |
|
|
35
36
|
|
|
36
37
|
# 方法
|
|
37
38
|
|
|
@@ -67,7 +67,7 @@ const typeStyles = theme[type];
|
|
|
67
67
|
const waveColor = typeStyles && typeStyles.borderColor || theme.primary.borderColor;
|
|
68
68
|
|
|
69
69
|
<Wave disabled={loading || disabled || type === 'none' || type === 'link'}
|
|
70
|
-
inset=
|
|
70
|
+
inset={type === 'flat' ? '-1px' : '-2px'}
|
|
71
71
|
color={waveColor}
|
|
72
72
|
>
|
|
73
73
|
<DynamicButton
|
|
@@ -32,7 +32,7 @@ const btnStyles = {
|
|
|
32
32
|
get color() { return theme.color.text },
|
|
33
33
|
bgColor: '#fff',
|
|
34
34
|
lineHeight: '1.15',
|
|
35
|
-
get padding() { return `0
|
|
35
|
+
get padding() { return `0 16px` },
|
|
36
36
|
get borderColor() { return theme.color.border },
|
|
37
37
|
get borderRadius() { return theme.borderRadius },
|
|
38
38
|
get fontSize() { return theme.default.fontSize },
|
|
@@ -97,6 +97,11 @@ const btnSizeStyles = sizes.reduce((memo, size) => {
|
|
|
97
97
|
get height() { return theme[size].height },
|
|
98
98
|
get padding() { return `0 ${theme[size].padding}` },
|
|
99
99
|
};
|
|
100
|
+
if (size === 'large') {
|
|
101
|
+
Object.defineProperty(memo[size], 'padding', {
|
|
102
|
+
value: `0 24px`,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
100
105
|
|
|
101
106
|
return memo;
|
|
102
107
|
}, {} as {[key in Sizes]: SizeStyles});
|
|
@@ -412,7 +417,9 @@ export function makeButtonStyles({iconSide}: {iconSide?: string}) {
|
|
|
412
417
|
|
|
413
418
|
export function makeButtonGroupStyles() {
|
|
414
419
|
return css`
|
|
415
|
-
display: inline-
|
|
420
|
+
display: inline-flex;
|
|
421
|
+
align-items: center;
|
|
422
|
+
flex-wrap: wrap;
|
|
416
423
|
vertical-align: middle;
|
|
417
424
|
.k-btn {
|
|
418
425
|
margin: 0;
|
|
@@ -470,8 +477,8 @@ export function makeButtonGroupStyles() {
|
|
|
470
477
|
|
|
471
478
|
// vertical
|
|
472
479
|
&.k-vertical {
|
|
480
|
+
flex-direction: column;
|
|
473
481
|
> .k-btn {
|
|
474
|
-
display: block;
|
|
475
482
|
&:not(.k-btn-icon) {
|
|
476
483
|
width: 100%;
|
|
477
484
|
}
|
|
@@ -503,5 +510,13 @@ export function makeButtonGroupStyles() {
|
|
|
503
510
|
})}
|
|
504
511
|
}
|
|
505
512
|
}
|
|
513
|
+
|
|
514
|
+
// seperate
|
|
515
|
+
&.k-seperate {
|
|
516
|
+
gap: 8px;
|
|
517
|
+
> .k-btn {
|
|
518
|
+
border-radius: ${button.borderRadius} !important;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
506
521
|
`;
|
|
507
522
|
}
|
|
@@ -26,11 +26,11 @@ const defaults = {
|
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
inner: {
|
|
29
|
-
width: '
|
|
29
|
+
width: '6px',
|
|
30
30
|
height: '10px',
|
|
31
31
|
top: '0px',
|
|
32
|
-
left: '
|
|
33
|
-
border: '
|
|
32
|
+
left: '4px',
|
|
33
|
+
border: '2px solid #fff',
|
|
34
34
|
},
|
|
35
35
|
|
|
36
36
|
// disabled
|
|
@@ -48,11 +48,6 @@ const defaults = {
|
|
|
48
48
|
},
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
|
-
|
|
52
|
-
// indeterminate
|
|
53
|
-
indeterminate: {
|
|
54
|
-
innerLeft: '4px',
|
|
55
|
-
}
|
|
56
51
|
};
|
|
57
52
|
|
|
58
53
|
let checkbox: typeof defaults;
|
|
@@ -91,7 +86,9 @@ export default function makeStyles() {
|
|
|
91
86
|
transform: rotate(45deg) scale(0);
|
|
92
87
|
transition: all ${checkbox.transition};
|
|
93
88
|
}
|
|
94
|
-
|
|
89
|
+
}
|
|
90
|
+
&:hover {
|
|
91
|
+
.k-checkbox-wrapper {
|
|
95
92
|
border: ${checkbox.hoverBorder}
|
|
96
93
|
}
|
|
97
94
|
}
|
|
@@ -125,7 +122,6 @@ export default function makeStyles() {
|
|
|
125
122
|
&:before {
|
|
126
123
|
transform: rotate(90deg) scale(1);
|
|
127
124
|
border-bottom: 0;
|
|
128
|
-
left: ${checkbox.indeterminate.innerLeft};
|
|
129
125
|
}
|
|
130
126
|
}
|
|
131
127
|
|
|
@@ -35,7 +35,6 @@ export function makeStyles() {
|
|
|
35
35
|
.${kls('arrow')} {
|
|
36
36
|
float: left;
|
|
37
37
|
margin-right: ${collapse.titleMarginRight};
|
|
38
|
-
transform-origin: center center 0;
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
40
|
|
|
@@ -69,7 +68,6 @@ export function makeItemStyles() {
|
|
|
69
68
|
transition: transform ${collapse.transition};
|
|
70
69
|
line-height: ${collapseItem.titleHeight};
|
|
71
70
|
height: ${collapseItem.titleHeight};
|
|
72
|
-
transform-origin: left center 0;
|
|
73
71
|
}
|
|
74
72
|
|
|
75
73
|
&:not(.k-disabled) {
|
|
@@ -3,6 +3,7 @@ import type {Dropdown} from './';
|
|
|
3
3
|
import {Options, position, Feedback} from '../position';
|
|
4
4
|
import {noop} from 'intact-shared';
|
|
5
5
|
import {isObject} from 'intact-shared';
|
|
6
|
+
import { isEqualObject } from '../utils';
|
|
6
7
|
|
|
7
8
|
export type FeedbackCallback = (feedback: Feedback) => void;
|
|
8
9
|
|
|
@@ -23,7 +24,7 @@ export function usePosition() {
|
|
|
23
24
|
isObject(newValue) && isObject(oldValue) &&
|
|
24
25
|
// is not event object
|
|
25
26
|
!(newValue instanceof Event) &&
|
|
26
|
-
|
|
27
|
+
isEqualObject(newValue, oldValue)
|
|
27
28
|
) {
|
|
28
29
|
return;
|
|
29
30
|
}
|
|
@@ -6,6 +6,7 @@ import {mount, unmount, dispatchEvent, wait} from '../../test/utils';
|
|
|
6
6
|
import {Component, findDomFromVNode} from 'intact';
|
|
7
7
|
import {Form, FormItem} from './';
|
|
8
8
|
import {Input} from '../input';
|
|
9
|
+
import { Select } from '../select';
|
|
9
10
|
|
|
10
11
|
RemoteDemo.prototype.validateUserName = function(value) {
|
|
11
12
|
// mock api
|
|
@@ -440,4 +441,24 @@ describe('Form', () => {
|
|
|
440
441
|
await wait();
|
|
441
442
|
expect(classList.contains('k-ellipsis')).to.be.true;
|
|
442
443
|
});
|
|
444
|
+
|
|
445
|
+
it('should not validate when select is disabled on init', async () => {
|
|
446
|
+
class Demo extends Component {
|
|
447
|
+
static template = `
|
|
448
|
+
const {Form, FormItem, Select} = this;
|
|
449
|
+
<Form ref="form">
|
|
450
|
+
<FormItem rules={{required: true}}>
|
|
451
|
+
<Select disabled />
|
|
452
|
+
</FormItem>
|
|
453
|
+
</Form>
|
|
454
|
+
`;
|
|
455
|
+
Form = Form;
|
|
456
|
+
FormItem = FormItem;
|
|
457
|
+
Select = Select;
|
|
458
|
+
}
|
|
459
|
+
const [instance, element] = mount(Demo);
|
|
460
|
+
|
|
461
|
+
await wait(500);
|
|
462
|
+
expect(element.querySelector('.k-form-error')).to.be.null;
|
|
463
|
+
});
|
|
443
464
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {Component, inject} from 'intact';
|
|
1
|
+
import {Component, inject, provide} from 'intact';
|
|
2
2
|
import template from './template.vdt';
|
|
3
|
-
import {LAYOUT, getStyle} from './helpers';
|
|
3
|
+
import {LAYOUT, getStyle, BODY} from './helpers';
|
|
4
4
|
import type {Layout} from './layout';
|
|
5
5
|
import {addStyle} from '../utils';
|
|
6
6
|
|
|
@@ -9,6 +9,10 @@ export class Body extends Component {
|
|
|
9
9
|
|
|
10
10
|
private layout = inject<Layout>(LAYOUT)!;
|
|
11
11
|
|
|
12
|
+
init() {
|
|
13
|
+
provide(BODY, this);
|
|
14
|
+
}
|
|
15
|
+
|
|
12
16
|
private getClassNames() {
|
|
13
17
|
const {className} = this.get();
|
|
14
18
|
return {
|
|
@@ -24,6 +28,7 @@ export class Body extends Component {
|
|
|
24
28
|
if (!hasFixedAside && !hasFixedHeader) return style;
|
|
25
29
|
|
|
26
30
|
return addStyle(style, {
|
|
31
|
+
// FIXME: we must use padding instead of margin, otherwise the table's width is wired
|
|
27
32
|
paddingLeft: hasFixedAside ? getStyle(asideWidth) : null,
|
|
28
33
|
marginTop: hasFixedHeader ? getStyle(headerHeight) : null,
|
|
29
34
|
});
|
|
@@ -47,7 +47,7 @@ import {
|
|
|
47
47
|
</Aside>
|
|
48
48
|
<Layout>
|
|
49
49
|
<Header>
|
|
50
|
-
<Button type="none" size="large" style="height: 64px" ev-click={this.toggle}>
|
|
50
|
+
<Button type="none" size="large" style="height: 64px" ev-click={this.toggle} ghost>
|
|
51
51
|
<Icon class="ion-navicon" size="30"/>
|
|
52
52
|
</Button>
|
|
53
53
|
</Header>
|
|
@@ -21,9 +21,9 @@ import {Icon} from 'kpc';
|
|
|
21
21
|
import {Breadcrumb, BreadcrumbItem} from 'kpc';
|
|
22
22
|
|
|
23
23
|
<Layout class="layout">
|
|
24
|
-
<Header class="header">
|
|
24
|
+
<Header class="header" blur boxShadow theme="white" height="54px" fixed>
|
|
25
25
|
<div class="logo">LOGO</div>
|
|
26
|
-
<Menu type="horizontal">
|
|
26
|
+
<Menu type="horizontal" theme="white">
|
|
27
27
|
<MenuItem key="1">menu 1</MenuItem>
|
|
28
28
|
<MenuItem key="2" disabled>menu 2</MenuItem>
|
|
29
29
|
<MenuItem key="3">
|
|
@@ -45,7 +45,7 @@ import {Breadcrumb, BreadcrumbItem} from 'kpc';
|
|
|
45
45
|
</Menu>
|
|
46
46
|
</Header>
|
|
47
47
|
<Layout>
|
|
48
|
-
<Aside theme="light">
|
|
48
|
+
<Aside theme="light" fixed>
|
|
49
49
|
<Menu
|
|
50
50
|
v-model:expandedKeys="expandedKeys"
|
|
51
51
|
v-model:selectedKey="selectedKey"
|
|
@@ -74,11 +74,29 @@ import {Breadcrumb, BreadcrumbItem} from 'kpc';
|
|
|
74
74
|
</Menu>
|
|
75
75
|
</Aside>
|
|
76
76
|
<Body>
|
|
77
|
-
<
|
|
78
|
-
<
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
77
|
+
<div class="content">
|
|
78
|
+
<Breadcrumb>
|
|
79
|
+
<BreadcrumbItem>Home</BreadcrumbItem>
|
|
80
|
+
<BreadcrumbItem>Detail</BreadcrumbItem>
|
|
81
|
+
</Breadcrumb>
|
|
82
|
+
<div>content</div>
|
|
83
|
+
<div>content</div>
|
|
84
|
+
<div>content</div>
|
|
85
|
+
<div>content</div>
|
|
86
|
+
<div>content</div>
|
|
87
|
+
<div>content</div>
|
|
88
|
+
<div>content</div>
|
|
89
|
+
<div>content</div>
|
|
90
|
+
<div>content</div>
|
|
91
|
+
<div>content</div>
|
|
92
|
+
<div>content</div>
|
|
93
|
+
<div>content</div>
|
|
94
|
+
<div>content</div>
|
|
95
|
+
<div>content</div>
|
|
96
|
+
<div>content</div>
|
|
97
|
+
<div>content</div>
|
|
98
|
+
<div>content</div>
|
|
99
|
+
</div>
|
|
82
100
|
</Body>
|
|
83
101
|
</Layout>
|
|
84
102
|
</Layout>
|
|
@@ -92,8 +110,10 @@ import {Breadcrumb, BreadcrumbItem} from 'kpc';
|
|
|
92
110
|
text-align center
|
|
93
111
|
background gray
|
|
94
112
|
margin 0 20px
|
|
113
|
+
.content
|
|
114
|
+
padding: 20px
|
|
95
115
|
.k-breadcrumb
|
|
96
|
-
margin 20px
|
|
116
|
+
margin-bottom 20px
|
|
97
117
|
```
|
|
98
118
|
|
|
99
119
|
```ts
|
|
@@ -12,6 +12,8 @@ export interface HeaderProps {
|
|
|
12
12
|
height?: number | string
|
|
13
13
|
style?: string | Record<string, string>
|
|
14
14
|
theme?: MenuProps['theme']
|
|
15
|
+
blur?: boolean
|
|
16
|
+
boxShadow?: boolean
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
const typeDefs: Required<TypeDefs<HeaderProps>> = {
|
|
@@ -19,6 +21,8 @@ const typeDefs: Required<TypeDefs<HeaderProps>> = {
|
|
|
19
21
|
height: [Number, String],
|
|
20
22
|
style: [String, Object],
|
|
21
23
|
theme: themes,
|
|
24
|
+
blur: Boolean,
|
|
25
|
+
boxShadow: Boolean,
|
|
22
26
|
};
|
|
23
27
|
|
|
24
28
|
const defaults = (): Partial<HeaderProps> => ({
|
|
@@ -34,10 +38,12 @@ export class Header extends Component<HeaderProps> {
|
|
|
34
38
|
private rootLayout = inject<Layout>(ROOT_LAYOUT)!;
|
|
35
39
|
|
|
36
40
|
private getClassNames() {
|
|
37
|
-
const {className, fixed, theme} = this.get();
|
|
41
|
+
const {className, fixed, theme, blur, boxShadow} = this.get();
|
|
38
42
|
return {
|
|
39
43
|
'k-layout-header': true,
|
|
40
44
|
'k-fixed': fixed,
|
|
45
|
+
'k-blur': blur,
|
|
46
|
+
'k-box-shadow': boxShadow,
|
|
41
47
|
[`k-${theme!}`]: true,
|
|
42
48
|
[className as string]: className,
|
|
43
49
|
[makeHeaderStyles()]: true,
|
|
@@ -14,6 +14,8 @@ sidebar: doc
|
|
|
14
14
|
| fixed | 是否固定头部 | `boolean` | `false` |
|
|
15
15
|
| theme | 主题颜色 | `"dark"` | `"light"` | `"white"` | `"dark"` |
|
|
16
16
|
| height | 高度 | `string` | `number` | `"64px"` |
|
|
17
|
+
| blur | 是否高斯模糊背景 | `boolean` | `false` |
|
|
18
|
+
| boxShadow | 是否展示阴影 | `boolean` | `false` |
|
|
17
19
|
|
|
18
20
|
## Aside
|
|
19
21
|
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {mount, unmount, dispatchEvent, wait, getElement} from '../../test/utils';
|
|
2
|
+
import { Component } from 'intact';
|
|
3
|
+
import { Layout, Header, Aside, Body } from './';
|
|
4
|
+
|
|
5
|
+
describe('Layout', () => {
|
|
6
|
+
afterEach(() => {unmount()});
|
|
7
|
+
|
|
8
|
+
it('nest Layout in Body with fixed header', async () => {
|
|
9
|
+
class Demo extends Component {
|
|
10
|
+
static template = `
|
|
11
|
+
const { Layout, Header, Aside, Body } = this;
|
|
12
|
+
<Layout>
|
|
13
|
+
<Header fixed />
|
|
14
|
+
<Body>
|
|
15
|
+
<Layout>
|
|
16
|
+
<Aside fixed />
|
|
17
|
+
<Body>body</Body>
|
|
18
|
+
</Layout>
|
|
19
|
+
</Body>
|
|
20
|
+
</Layout>
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
Layout = Layout;
|
|
24
|
+
Header = Header;
|
|
25
|
+
Aside = Aside;
|
|
26
|
+
Body = Body;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const [instance, element] = mount(Demo);
|
|
30
|
+
expect(element.innerHTML).to.matchSnapshot();
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -2,14 +2,16 @@ import {Component, TypeDefs, inject, provide} from 'intact';
|
|
|
2
2
|
import template from './template.vdt';
|
|
3
3
|
import {makeLayoutStyles} from './styles';
|
|
4
4
|
import {addStyle} from '../utils';
|
|
5
|
-
import {ROOT_LAYOUT, LAYOUT, getStyle} from './helpers';
|
|
5
|
+
import {ROOT_LAYOUT, LAYOUT, getStyle, BODY} from './helpers';
|
|
6
6
|
import {useParse} from './useParse';
|
|
7
|
+
import type { Body } from './body';
|
|
7
8
|
|
|
8
9
|
export class Layout extends Component {
|
|
9
10
|
static template = template;
|
|
10
11
|
|
|
11
12
|
public parse = useParse();
|
|
12
13
|
public layout = inject<Layout | null>(LAYOUT, null);
|
|
14
|
+
private body = inject<Body | null>(BODY, null);
|
|
13
15
|
|
|
14
16
|
init() {
|
|
15
17
|
provide(LAYOUT, this);
|
|
@@ -32,7 +34,7 @@ export class Layout extends Component {
|
|
|
32
34
|
private getStyles() {
|
|
33
35
|
const style = this.get<string>('style');
|
|
34
36
|
const layout = this.layout;
|
|
35
|
-
if (!layout) return style;
|
|
37
|
+
if (!layout || this.body) return style;
|
|
36
38
|
|
|
37
39
|
const {hasFixedHeader, headerHeight, hasFixedAside, asideWidth} = layout.parse();
|
|
38
40
|
if (!hasFixedHeader && !hasFixedAside) return style;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {css} from '@emotion/css';
|
|
2
2
|
import {theme, setDefault} from '../../styles/theme';
|
|
3
|
-
import {deepDefaults, getLeft} from '../../styles/utils';
|
|
3
|
+
import {deepDefaults, getLeft, setAlpha} from '../../styles/utils';
|
|
4
4
|
import '../../styles/global';
|
|
5
5
|
import {menu} from '../menu/styles';
|
|
6
6
|
|
|
@@ -12,12 +12,12 @@ const defaults = {
|
|
|
12
12
|
get color() { return menu.item.color },
|
|
13
13
|
get bgColor() { return menu.bgColor },
|
|
14
14
|
light: {
|
|
15
|
-
get color() { return menu.light.
|
|
15
|
+
get color() { return menu.light.item.color },
|
|
16
16
|
get bgColor() { return menu.light.bgColor },
|
|
17
17
|
get border() { return menu.light.border },
|
|
18
18
|
},
|
|
19
19
|
white: {
|
|
20
|
-
get color() { return menu.white.
|
|
20
|
+
get color() { return menu.white.item.color },
|
|
21
21
|
get bgColor() { return menu.white.bgColor },
|
|
22
22
|
get border() { return menu.white.border },
|
|
23
23
|
},
|
|
@@ -69,6 +69,19 @@ export function makeHeaderStyles() {
|
|
|
69
69
|
top: 0;
|
|
70
70
|
z-index: ${theme.midZIndex + 1};
|
|
71
71
|
}
|
|
72
|
+
> .k-menu {
|
|
73
|
+
background: transparent !important;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
&.k-blur {
|
|
77
|
+
backdrop-filter: blur(20px);
|
|
78
|
+
background: ${setAlpha(layout.bgColor, 0.1)};
|
|
79
|
+
}
|
|
80
|
+
&.k-box-shadow {
|
|
81
|
+
border-bottom: none !important;
|
|
82
|
+
box-shadow: ${theme.boxShadow};
|
|
83
|
+
}
|
|
84
|
+
|
|
72
85
|
${themes.map(theme => {
|
|
73
86
|
if (theme === 'dark') return;
|
|
74
87
|
const styles = layout[theme];
|
|
@@ -77,6 +90,9 @@ export function makeHeaderStyles() {
|
|
|
77
90
|
background: ${styles.bgColor};
|
|
78
91
|
color: ${styles.color};
|
|
79
92
|
border-bottom: ${styles.border};
|
|
93
|
+
&.k-blur {
|
|
94
|
+
background: ${setAlpha(styles.bgColor, 0.1)};
|
|
95
|
+
}
|
|
80
96
|
}
|
|
81
97
|
`
|
|
82
98
|
})}
|
|
@@ -230,8 +230,8 @@ export function makeTitleStyles() {
|
|
|
230
230
|
return css`
|
|
231
231
|
display: flex;
|
|
232
232
|
align-items: center;
|
|
233
|
-
padding: ${
|
|
234
|
-
color: ${
|
|
233
|
+
padding: ${item.padding};
|
|
234
|
+
color: ${item.color};
|
|
235
235
|
white-space: nowrap;
|
|
236
236
|
overflow: hidden;
|
|
237
237
|
flex-wrap: nowrap;
|
|
@@ -253,6 +253,12 @@ export function makeItemStyles() {
|
|
|
253
253
|
flex: 1;
|
|
254
254
|
display: flex;
|
|
255
255
|
align-items: center;
|
|
256
|
+
min-width: 0;
|
|
257
|
+
span {
|
|
258
|
+
overflow: hidden;
|
|
259
|
+
text-overflow: ellipsis;
|
|
260
|
+
min-width: 0;
|
|
261
|
+
}
|
|
256
262
|
}
|
|
257
263
|
.k-menu-arrow {
|
|
258
264
|
transition: transform ${menu.transition};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {useInstance, VNodeComponentClass, onBeforeMount, onBeforeUpdate, inject} from 'intact';
|
|
1
|
+
import {useInstance, VNodeComponentClass, onBeforeMount, onBeforeUpdate, inject, createVNode} from 'intact';
|
|
2
2
|
import {Menu, MenuItem, MenuProps} from './';
|
|
3
3
|
import {Icon} from '../icon';
|
|
4
4
|
import {
|
|
@@ -52,6 +52,10 @@ export function useDropdown(rootMenu: Menu, parentMenu: Menu) {
|
|
|
52
52
|
iconVNode = vNode;
|
|
53
53
|
}
|
|
54
54
|
} else {
|
|
55
|
+
if (isStringOrNumberNotEmpty(vNode) || isTextVNode(vNode)) {
|
|
56
|
+
// wrap with span for showing text ellipsis
|
|
57
|
+
vNode = createVNode('span', null, vNode);
|
|
58
|
+
}
|
|
55
59
|
titleVNodes.push(vNode);
|
|
56
60
|
}
|
|
57
61
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: 隐藏Icon
|
|
2
|
+
title: 隐藏Icon或展示关闭按钮
|
|
3
3
|
order: 1.1
|
|
4
4
|
---
|
|
5
5
|
|
|
@@ -32,7 +32,7 @@ export default class extends Component {
|
|
|
32
32
|
Message[type]({
|
|
33
33
|
content: type,
|
|
34
34
|
duration: 3000,
|
|
35
|
-
closable:
|
|
35
|
+
closable: true,
|
|
36
36
|
hideIcon: true,
|
|
37
37
|
});
|
|
38
38
|
}
|
|
@@ -15,7 +15,7 @@ sidebar: doc
|
|
|
15
15
|
| content | 提示内容 | `string` | `VNode` | `undefined` |
|
|
16
16
|
| duration | 提示展示多长时间后自动关闭,当传入0时,提示将会一直展示。单位ms | `number` | `5000` |
|
|
17
17
|
| type | 提示类型 | `"info"` | `"error"` | `"success"` | `"warning"`|
|
|
18
|
-
| closable | 是否展示关闭按钮 | `boolean` | `
|
|
18
|
+
| closable | 是否展示关闭按钮 | `boolean` | `false` |
|
|
19
19
|
| hideIcon | 是否隐藏文字前面的icon | `boolean` | `false` |
|
|
20
20
|
|
|
21
21
|
# 静态方法
|
|
@@ -32,7 +32,7 @@ const defaults = deepDefaults(
|
|
|
32
32
|
gap: '6px',
|
|
33
33
|
padding: '0 3px',
|
|
34
34
|
get borderRadius() { return theme.borderRadius },
|
|
35
|
-
get hoverBgColor() { return theme.color.hoverBg }
|
|
35
|
+
// get hoverBgColor() { return theme.color.hoverBg }
|
|
36
36
|
},
|
|
37
37
|
// goto
|
|
38
38
|
goto: {
|
|
@@ -82,9 +82,6 @@ export function makeStyles() {
|
|
|
82
82
|
&:last-of-type {
|
|
83
83
|
margin: 0 !important;
|
|
84
84
|
}
|
|
85
|
-
&:hover {
|
|
86
|
-
background: ${pagination.btn.hoverBgColor};
|
|
87
|
-
}
|
|
88
85
|
}
|
|
89
86
|
.k-icon {
|
|
90
87
|
font-size: 18px;
|