@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.
Files changed (138) hide show
  1. package/components/badge/styles.ts +1 -1
  2. package/components/breadcrumb/demos/separator.md +1 -1
  3. package/components/button/demos/group.md +7 -0
  4. package/components/button/group.ts +3 -1
  5. package/components/button/group.vdt +2 -1
  6. package/components/button/index.md +1 -0
  7. package/components/button/index.vdt +1 -1
  8. package/components/button/styles.ts +18 -3
  9. package/components/checkbox/styles.ts +6 -10
  10. package/components/collapse/styles.ts +0 -2
  11. package/components/dropdown/dropdown.ts +1 -0
  12. package/components/dropdown/usePosition.ts +2 -1
  13. package/components/form/index.spec.ts +21 -0
  14. package/components/form/styles.ts +1 -0
  15. package/components/icon/index.vdt +1 -1
  16. package/components/layout/body.ts +7 -2
  17. package/components/layout/demos/aside.md +1 -1
  18. package/components/layout/demos/basic.md +29 -9
  19. package/components/layout/header.ts +7 -1
  20. package/components/layout/helpers.ts +1 -0
  21. package/components/layout/index.md +2 -0
  22. package/components/layout/index.spec.ts +32 -0
  23. package/components/layout/layout.ts +4 -2
  24. package/components/layout/styles.ts +19 -3
  25. package/components/menu/styles.ts +8 -2
  26. package/components/menu/useDropdown.ts +5 -1
  27. package/components/message/demos/config.md +2 -2
  28. package/components/message/index.md +1 -1
  29. package/components/message/message.ts +1 -1
  30. package/components/pagination/styles.ts +1 -4
  31. package/components/popover/styles.ts +1 -1
  32. package/components/radio/styles.ts +4 -1
  33. package/components/scrollSelect/styles.ts +1 -1
  34. package/components/select/base.vdt +7 -4
  35. package/components/select/styles.ts +1 -1
  36. package/components/switch/styles.ts +17 -1
  37. package/components/table/column.vdt +3 -2
  38. package/components/table/demos/pagination.md +6 -0
  39. package/components/table/demos/showIndeterminate.md +2 -2
  40. package/components/table/index.md +2 -1
  41. package/components/table/index.spec.ts +1 -1
  42. package/components/table/row.ts +9 -1
  43. package/components/table/styles.ts +5 -2
  44. package/components/table/table.ts +3 -2
  45. package/components/table/useGroup.ts +2 -1
  46. package/components/table/usePagination.ts +1 -1
  47. package/components/tabs/demos/closable.md +1 -1
  48. package/components/tip/styles.ts +1 -1
  49. package/components/tooltip/index.spec.ts +30 -0
  50. package/components/tooltip/tooltip.ts +3 -0
  51. package/components/utils.ts +15 -0
  52. package/components/virtual.ts +4 -2
  53. package/es/components/badge/styles.js +1 -1
  54. package/es/components/button/group.d.ts +1 -0
  55. package/es/components/button/group.js +2 -1
  56. package/es/components/button/group.vdt.js +4 -2
  57. package/es/components/button/index.vdt.js +1 -1
  58. package/es/components/button/styles.js +11 -4
  59. package/es/components/checkbox/styles.js +4 -8
  60. package/es/components/collapse/styles.js +2 -2
  61. package/es/components/dropdown/dropdown.js +2 -1
  62. package/es/components/dropdown/usePosition.js +2 -2
  63. package/es/components/form/index.spec.js +45 -0
  64. package/es/components/form/styles.js +1 -1
  65. package/es/components/icon/index.vdt.js +3 -2
  66. package/es/components/layout/body.d.ts +1 -0
  67. package/es/components/layout/body.js +7 -2
  68. package/es/components/layout/header.d.ts +2 -0
  69. package/es/components/layout/header.js +9 -3
  70. package/es/components/layout/helpers.d.ts +1 -0
  71. package/es/components/layout/helpers.js +1 -0
  72. package/es/components/layout/index.spec.d.ts +1 -0
  73. package/es/components/layout/index.spec.js +53 -0
  74. package/es/components/layout/layout.d.ts +1 -0
  75. package/es/components/layout/layout.js +3 -2
  76. package/es/components/layout/styles.js +5 -5
  77. package/es/components/menu/styles.js +2 -2
  78. package/es/components/menu/useDropdown.js +6 -1
  79. package/es/components/message/message.js +1 -1
  80. package/es/components/pagination/styles.js +2 -5
  81. package/es/components/popover/styles.js +1 -1
  82. package/es/components/radio/styles.js +1 -1
  83. package/es/components/scrollSelect/styles.js +1 -1
  84. package/es/components/select/base.vdt.js +4 -1
  85. package/es/components/select/styles.js +1 -1
  86. package/es/components/switch/styles.js +10 -2
  87. package/es/components/table/column.vdt.js +4 -2
  88. package/es/components/table/index.spec.js +1 -1
  89. package/es/components/table/row.js +8 -1
  90. package/es/components/table/styles.js +2 -2
  91. package/es/components/table/table.d.ts +1 -1
  92. package/es/components/table/table.js +3 -2
  93. package/es/components/table/useGroup.d.ts +1 -1
  94. package/es/components/table/useGroup.js +2 -1
  95. package/es/components/table/usePagination.js +1 -1
  96. package/es/components/tip/styles.js +1 -1
  97. package/es/components/tooltip/index.spec.js +57 -0
  98. package/es/components/tooltip/tooltip.js +5 -1
  99. package/es/components/utils.d.ts +1 -0
  100. package/es/components/utils.js +16 -0
  101. package/es/components/virtual.js +5 -2
  102. package/es/index.d.ts +2 -2
  103. package/es/index.js +2 -2
  104. package/es/site/data/components/button/demos/group/react.js +17 -0
  105. package/es/site/data/components/layout/demos/aside/react.js +2 -1
  106. package/es/site/data/components/layout/demos/basic/react.js +13 -4
  107. package/es/site/data/components/message/demos/config/index.js +1 -1
  108. package/es/site/data/components/message/demos/config/react.js +1 -1
  109. package/es/site/data/components/table/demos/pagination/index.d.ts +4 -0
  110. package/es/site/data/components/table/demos/pagination/index.js +11 -2
  111. package/es/site/data/components/table/demos/pagination/react.d.ts +4 -0
  112. package/es/site/data/components/table/demos/pagination/react.js +11 -3
  113. package/es/site/data/components/table/demos/showIndeterminate/react.js +1 -1
  114. package/es/site/data/components/tabs/demos/closable/react.js +2 -1
  115. package/es/site/src/pages/layout.js +1 -3
  116. package/es/styles/fonts/iconfont.eot +0 -0
  117. package/es/styles/fonts/iconfont.js +1 -1
  118. package/es/styles/fonts/iconfont.svg +1 -1
  119. package/es/styles/fonts/iconfont.ttf +0 -0
  120. package/es/styles/fonts/iconfont.woff +0 -0
  121. package/es/styles/theme.js +1 -1
  122. package/es/styles/utils.d.ts +1 -0
  123. package/es/styles/utils.js +3 -0
  124. package/index.ts +2 -2
  125. package/package.json +3 -3
  126. package/styles/fonts/demo_index.html +6 -6
  127. package/styles/fonts/iconfont.css +6 -6
  128. package/styles/fonts/iconfont.eot +0 -0
  129. package/styles/fonts/iconfont.js +1 -1
  130. package/styles/fonts/iconfont.svg +1 -1
  131. package/styles/fonts/iconfont.ts +1 -1
  132. package/styles/fonts/iconfont.ttf +0 -0
  133. package/styles/fonts/iconfont.woff +0 -0
  134. package/styles/fonts/iconfont.woff2 +0 -0
  135. package/styles/theme.ts +1 -1
  136. package/styles/utils.ts +5 -1
  137. package/es/site/data/components/menu/demos/collapse/react.d.ts +0 -11
  138. package/es/site/data/components/menu/demos/size/react.d.ts +0 -7
@@ -34,7 +34,7 @@ export default function makeStyles() {
34
34
  right: 0;
35
35
  transform: translate(50%, -50%);
36
36
  background: ${badge.bgColor};
37
- font-size: 75%;
37
+ font-size: 85%;
38
38
  vertical-align: baseline;
39
39
  }
40
40
 
@@ -26,7 +26,7 @@ import {Breadcrumb, BreadcrumbItem, Icon} from 'kpc';
26
26
 
27
27
  ```styl
28
28
  .separator
29
- color #ffa133
29
+ color #0091ea
30
30
  vertical-align middle
31
31
  i
32
32
  margin-right 3px
@@ -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"` &#124; `"checkbox"` &#124; `"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="-2px"
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 ${theme.default.padding}` },
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-block;
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: '5px',
29
+ width: '6px',
30
30
  height: '10px',
31
31
  top: '0px',
32
- left: '5px',
33
- border: '1px solid #fff',
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
- &:hover {
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) {
@@ -68,6 +68,7 @@ const typeDefs: Required<TypeDefs<DropdownProps>> = {
68
68
  const defaults = (): Partial<DropdownProps> => ({
69
69
  trigger: 'hover',
70
70
  of: 'self',
71
+ value: false,
71
72
  });
72
73
 
73
74
  const events: Events<DropdownEvents> = {
@@ -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
- JSON.stringify(newValue) === JSON.stringify(oldValue)
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
  });
@@ -55,6 +55,7 @@ export function makeItemStyles() {
55
55
  width: ${form.item.labelWidth};
56
56
  padding-right: ${form.item.labelGap};
57
57
  max-height: ${form.item.labelHeight};
58
+ flex-shrink: 0;
58
59
  }
59
60
  .k-form-star {
60
61
  color: ${form.item.starColor};
@@ -30,6 +30,6 @@ if (this.colors.indexOf(color) > -1) {
30
30
  }
31
31
 
32
32
  <i class={classNameObj}
33
- style={addStyle(style, _style)}
34
33
  {...getRestProps(this)}
34
+ style={addStyle(style, _style)}
35
35
  >{children}</i>
@@ -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
- <Breadcrumb>
78
- <BreadcrumbItem>Home</BreadcrumbItem>
79
- <BreadcrumbItem>Detail</BreadcrumbItem>
80
- </Breadcrumb>
81
- <div>content</div>
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 0
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,
@@ -2,6 +2,7 @@ import {isNumber} from 'intact-shared';
2
2
 
3
3
  export const ROOT_LAYOUT = 'RootLayout';
4
4
  export const LAYOUT = 'Layout';
5
+ export const BODY = 'LayoutBody';
5
6
  export const defaultHeight = `64px`;
6
7
  export const defaultWidth = `200px`;
7
8
 
@@ -14,6 +14,8 @@ sidebar: doc
14
14
  | fixed | 是否固定头部 | `boolean` | `false` |
15
15
  | theme | 主题颜色 | `"dark"` &#124; `"light"` &#124; `"white"` | `"dark"` |
16
16
  | height | 高度 | `string` &#124; `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.bgColor },
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.bgColor },
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: ${menu.item.padding};
234
- color: ${menu.item.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: false,
35
+ closable: true,
36
36
  hideIcon: true,
37
37
  });
38
38
  }
@@ -15,7 +15,7 @@ sidebar: doc
15
15
  | content | 提示内容 | `string` &#124; `VNode` | `undefined` |
16
16
  | duration | 提示展示多长时间后自动关闭,当传入0时,提示将会一直展示。单位ms | `number` | `5000` |
17
17
  | type | 提示类型 | `"info"` &#124; `"error"` &#124; `"success"` &#124; `"warning"`|
18
- | closable | 是否展示关闭按钮 | `boolean` | `true` |
18
+ | closable | 是否展示关闭按钮 | `boolean` | `false` |
19
19
  | hideIcon | 是否隐藏文字前面的icon | `boolean` | `false` |
20
20
 
21
21
  # 静态方法
@@ -33,7 +33,7 @@ let id = 0;
33
33
  const defaults = (): Partial<MessageProps> => ({
34
34
  duration: 5000,
35
35
  type: 'info',
36
- closable: true,
36
+ closable: false,
37
37
  });
38
38
 
39
39
  let messages: Messages | null = null;
@@ -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;
@@ -3,7 +3,7 @@ import {theme, setDefault} from '../../styles/theme';
3
3
  import {deepDefaults} from '../../styles/utils';
4
4
 
5
5
  const defaults = {
6
- width: '240px',
6
+ width: '320px',
7
7
  padding: '8px 16px',
8
8
  gap: '8px',
9
9
  title: {