@king-design/intact 3.1.6 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/components/config/index.spec.ts +3 -3
  2. package/components/layout/aside.vdt +1 -1
  3. package/components/layout/demos/basic.md +1 -1
  4. package/components/layout/demos/fix.md +1 -1
  5. package/components/layout/demos/theme.md +2 -3
  6. package/components/layout/index.md +1 -1
  7. package/components/layout/styles.ts +9 -20
  8. package/components/menu/.DS_Store +0 -0
  9. package/components/menu/demos/.DS_Store +0 -0
  10. package/components/menu/demos/collapse.md +4 -1
  11. package/components/menu/demos/showCollapseArrow.md +93 -0
  12. package/components/menu/demos/size.md +0 -1
  13. package/components/menu/demos/theme.md +0 -1
  14. package/components/menu/index.md +2 -1
  15. package/components/menu/index.spec.ts +41 -20
  16. package/components/menu/index.ts +2 -1
  17. package/components/menu/item.vdt +3 -2
  18. package/components/menu/menu.ts +10 -0
  19. package/components/menu/menu.vdt +12 -3
  20. package/components/menu/styles.ts +195 -88
  21. package/components/menu/title.ts +12 -0
  22. package/components/menu/title.vdt +25 -0
  23. package/components/radio/styles.ts +1 -1
  24. package/components/select/demos/searchable.md +2 -2
  25. package/components/select/index.spec.ts +1 -1
  26. package/components/select/option.vdt +1 -0
  27. package/components/select/select.ts +4 -1
  28. package/components/table/column.vdt +5 -3
  29. package/components/table/demos/sort.md +1 -0
  30. package/components/table/useSortable.ts +8 -2
  31. package/es/components/config/index.spec.js +22 -14
  32. package/es/components/layout/aside.vdt.js +1 -1
  33. package/es/components/layout/styles.js +2 -17
  34. package/es/components/menu/index.d.ts +1 -0
  35. package/es/components/menu/index.js +2 -1
  36. package/es/components/menu/index.spec.js +59 -28
  37. package/es/components/menu/item.vdt.js +3 -3
  38. package/es/components/menu/menu.d.ts +2 -0
  39. package/es/components/menu/menu.js +12 -1
  40. package/es/components/menu/menu.vdt.js +9 -4
  41. package/es/components/menu/styles.d.ts +15 -12
  42. package/es/components/menu/styles.js +38 -38
  43. package/es/components/menu/title.d.ts +7 -0
  44. package/es/components/menu/title.js +22 -0
  45. package/es/components/menu/title.vdt.js +25 -0
  46. package/es/components/radio/styles.js +1 -1
  47. package/es/components/select/index.spec.js +1 -1
  48. package/es/components/select/option.vdt.js +1 -0
  49. package/es/components/select/select.js +4 -1
  50. package/es/components/table/column.vdt.js +6 -6
  51. package/es/components/table/useSortable.d.ts +7 -3
  52. package/es/components/table/useSortable.js +5 -1
  53. package/es/index.d.ts +2 -2
  54. package/es/index.js +2 -2
  55. package/es/site/data/components/layout/demos/basic/react.js +2 -2
  56. package/es/site/data/components/layout/demos/fix/react.js +2 -2
  57. package/es/site/data/components/layout/demos/theme/index.js +1 -1
  58. package/es/site/data/components/layout/demos/theme/react.js +4 -6
  59. package/es/site/data/components/menu/demos/collapse/react.js +12 -2
  60. package/es/site/data/components/menu/demos/showCollapseArrow/index.d.ts +10 -0
  61. package/es/site/data/components/menu/demos/showCollapseArrow/index.js +23 -0
  62. package/es/site/data/components/menu/demos/showCollapseArrow/react.d.ts +10 -0
  63. package/es/site/data/components/menu/demos/showCollapseArrow/react.js +117 -0
  64. package/es/site/data/components/menu/demos/size/react.js +1 -3
  65. package/es/site/data/components/menu/demos/theme/react.js +1 -3
  66. package/es/site/data/components/select/demos/searchable/react.js +4 -2
  67. package/es/site/data/components/table/demos/sort/react.js +2 -1
  68. package/es/styles/theme.js +1 -2
  69. package/index.ts +2 -2
  70. package/package.json +2 -2
  71. package/styles/theme.ts +1 -2
@@ -9,18 +9,28 @@ const sizes = ['large', 'small'] as const;
9
9
  const defaults = {
10
10
  get transition() { return theme.transition.large },
11
11
  width: '200px',
12
- bgColor: '#262626',
12
+ bgColor: '#1c1c20',
13
13
  fontSize: '14px',
14
14
  get borderRadius() { return theme.borderRadius },
15
+ get border() { return `1px solid ${theme.color.darkBorder}` },
15
16
 
16
17
  item: {
17
18
  height: '40px',
18
- padding: '0 21px',
19
- color: '#b2b2b2',
19
+ padding: '0 17px',
20
+ bodyPadding: '0 4px',
21
+ color: '#aeaeb9',
20
22
  hoverColor: '#fff',
21
- get disabledColor() { return theme.color.text },
23
+ disabledColor: '#53535a',
22
24
  get activeBgColor() { return theme.color.primary },
23
- dotFontSize: '12px'
25
+ get hoverBgColor() { return palette(theme.color.primary, 4) },
26
+ dotFontSize: '12px',
27
+ subTitleColor: '#858592',
28
+ },
29
+
30
+ title: {
31
+ height: '40px',
32
+ padding: '0 17px',
33
+ color: '#fff',
24
34
  },
25
35
 
26
36
  icon: {
@@ -29,33 +39,24 @@ const defaults = {
29
39
  },
30
40
 
31
41
  header: {
32
- height: '50px',
42
+ height: '52px',
33
43
  fontSize: '14px',
44
+ color: '#fff',
34
45
  borderBottom: '1px solid #1b1b1d',
35
46
  },
36
47
 
37
- // sub-menu
38
- subBgColor: '#000',
39
-
40
48
  light: {
41
- bgColor: '#e5e5e9',
42
- subBgColor: '#d5d5d9',
43
- border: '1px solid #d5d5d9',
44
- item: {
45
- get color() { return theme.color.text },
46
- get hoverColor() { return theme.color.primary },
47
- disabledColor: '#999'
48
- },
49
- },
50
-
51
- white: {
52
49
  bgColor: '#fff',
53
- subBgColor: '#fafafa',
54
- border: '1px solid #eee',
50
+ get border() { return `1px solid ${theme.color.disabledBg}` },
55
51
  item: {
56
52
  get color() { return theme.color.text },
57
53
  get hoverColor() { return theme.color.primary },
58
- get disabledColor() { return theme.color.disabled },
54
+ get hoverBg() { return theme.color.hoverBg },
55
+ disabledColor: '#b6bec2',
56
+ subTitleColor: '#5e686f',
57
+ },
58
+ title: {
59
+ get color() { return theme.color.title },
59
60
  },
60
61
  active: {
61
62
  get color() { return theme.color.primary },
@@ -99,6 +100,7 @@ export const makeMenuStyles = cache(function makeMenuStyles(k: string) {
99
100
  transition: width ${menu.transition};
100
101
  background: ${menu.bgColor};
101
102
  font-size: ${menu.fontSize};
103
+ position: relative;
102
104
  }
103
105
 
104
106
  .${k}-icon {
@@ -108,62 +110,129 @@ export const makeMenuStyles = cache(function makeMenuStyles(k: string) {
108
110
  flex-shrink: 0;
109
111
  }
110
112
 
111
-
112
113
  // header
113
114
  .${k}-menu-header {
114
115
  height: ${menu.header.height};
116
+ padding: 0 21px;
117
+ color: ${menu.header.color};
115
118
  font-size: ${menu.header.fontSize};
116
119
  font-weight: bold;
117
- border-bottom: ${menu.header.borderBottom};
118
120
  }
119
121
 
120
- // theme
121
- ${(['light', 'white'] as const).map(theme => {
122
- const styles = menu[theme];
123
- return css`
124
- &.${k}-${theme} {
125
- background: ${styles.bgColor};
126
- .${k}-menu-header {
127
- color: ${styles.item.color};
128
- border-bottom: ${styles.border};
122
+ .${k}-menu-body {
123
+ padding: ${menu.item.bodyPadding};
124
+ max-height: calc(100vh - ${menu.header.height});
125
+ overflow-y: auto;
126
+ }
127
+
128
+ // menu title
129
+ .${k}-menu-title {
130
+ height: ${menu.title.height};
131
+ border-top: ${menu.border};
132
+ margin-top: 4px;
133
+ .${k}-menu-name {
134
+ transition: all ${menu.transition};
135
+ height: ${menu.title.height};
136
+ color: ${menu.title.color};
137
+ font-weight: bold;
138
+ }
139
+ }
140
+
141
+ // menu arrow
142
+ .${k}-menu-arrow-box {
143
+ width: 14px;
144
+ height: 60px;
145
+ cursor: pointer;
146
+ background: ${menu.bgColor};
147
+ border-radius: 0 8px 8px 0;
148
+ position: absolute;
149
+ display: flex;
150
+ align-items: center;
151
+ justify-content: center;
152
+ top: 50%;
153
+ left: calc(${menu.width} - 2px);
154
+ transition: left ${menu.transition};
155
+ transform: translateY(-50%);
156
+ border: ${menu.border};
157
+ border-left: none;
158
+ .${k}-icon {
159
+ margin-right: 0;
160
+ }
161
+ &:hover {
162
+ .${k}-menu-arrow:before {
163
+ color: ${menu.item.activeBgColor};
164
+ }
165
+ }
166
+ }
167
+
168
+ // theme light
169
+ &.${k}-light {
170
+ border: 1px solid ${theme.color.disabledBg};
171
+ background: ${menu.light.bgColor};
172
+ .${k}-menu-header {
173
+ color: ${menu.light.title.color};
174
+ }
175
+ .${k}-menu-item {
176
+ .${k}-menu-item-title {
177
+ color: ${menu.light.item.color};
178
+ &:hover {
179
+ background: ${menu.light.item.hoverBg};
129
180
  }
130
- .${k}-menu-item {
131
- .${k}-menu-title {
132
- color: ${styles.item.color};
133
- &:hover {
134
- color: ${styles.item.hoverColor};
135
- }
136
- }
137
- &.${k}-highlighted {
138
- > .${k}-menu-title {
139
- color: ${styles.item.hoverColor};
140
- }
141
- }
142
- &.${k}-disabled {
143
- > .${k}-menu-title {
144
- color: ${styles.item.disabledColor} !important;
145
- }
146
- }
181
+ }
182
+ .${k}-menu-item-arrow {
183
+ color: ${menu.light.item.color};
184
+ }
185
+ &.${k}-highlighted {
186
+ > .${k}-menu-item-title {
187
+ color: ${menu.light.item.hoverColor};
147
188
  }
148
- .${k}-menu:not(.${k}-dropdown-menu) {
149
- background: ${styles.subBgColor};
189
+ }
190
+ &.${k}-disabled {
191
+ > .${k}-menu-item-title {
192
+ color: ${menu.light.item.disabledColor} !important;
150
193
  }
194
+ }
195
+ }
151
196
 
152
- &.${k}-horizontal {
153
- .${k}-menu-header {
154
- border-right: ${styles.border};
155
- }
197
+ .${k}-menu-title {
198
+ border-top: ${menu.light.border};
199
+ .${k}-menu-name {
200
+ color: ${menu.light.title.color};
201
+ }
202
+ }
203
+
204
+ .${k}-menu-arrow-box {
205
+ background: ${menu.light.bgColor};
206
+ border: ${menu.light.border};
207
+ border-left: none;
208
+ &:hover {
209
+ .${k}-menu-arrow:before {
210
+ color: ${menu.light.active.color};
156
211
  }
157
212
  }
158
- `;
159
- })}
213
+ }
214
+ .${k}-menu:not(.${k}-dropdown-menu) {
215
+ background: ${menu.light.bgColor};
216
+ }
160
217
 
161
- &.${k}-white {
218
+ &.${k}-horizontal {
219
+ .${k}-menu-header {
220
+ border-right: ${menu.light.border};
221
+ }
222
+ .${k}-menu-body > .${k}-menu-title {
223
+ border-right: ${menu.light.border};
224
+ }
225
+ }
162
226
  // active
163
227
  .${k}-menu-item.${k}-active {
164
- > .${k}-menu-title {
165
- color: ${menu.white.active.color } !important;
166
- background: ${menu.white.active.bgColor};
228
+ > .${k}-menu-item-title {
229
+ color: ${menu.light.active.color } !important;
230
+ background: ${menu.light.active.bgColor};
231
+ }
232
+ }
233
+ .${k}-sub-menu {
234
+ .${k}-menu-item-title, .${k}-menu-item-arrow {
235
+ color: ${menu.light.item.subTitleColor} !important;
167
236
  }
168
237
  }
169
238
  }
@@ -179,26 +248,45 @@ export const makeMenuStyles = cache(function makeMenuStyles(k: string) {
179
248
  .${k}-menu {
180
249
  font-size: ${styles.fontSize};
181
250
  }
251
+ .${k}-menu-arrow-box {
252
+ left: calc(${styles.width} - 2px);
253
+ }
182
254
  }
183
255
  `;
184
256
  })}
185
257
 
186
258
  // collapse
187
259
  &.${k}-collapsed {
188
- width: calc(${menu.icon.width} + ${getLeft(menu.item.padding)} * 2);
260
+ width: calc(${menu.icon.width} + (${getLeft(menu.item.padding)} + ${getLeft(menu.item.bodyPadding)}) * 2);
189
261
  .${k}-icon {
190
262
  margin-right: 0;
191
263
  }
192
- .${k}-menu-arrow {
264
+ .${k}-menu-item-arrow {
193
265
  display: none;
194
266
  }
195
267
  }
196
268
 
269
+ // show collapse arrow
270
+ &.${k}-collapsed-arrow {
271
+ width: 0px;
272
+ border-left: none;
273
+ .${k}-menu-body {
274
+ overflow: hidden;
275
+ padding: 0;
276
+ }
277
+ .${k}-menu-arrow-box {
278
+ left: 0;
279
+ .${k}-menu-arrow:before {
280
+ transform: rotateY(180deg);
281
+ }
282
+ }
283
+ }
284
+
197
285
  // dropdown
198
286
  &.${k}-dropdown-menu {
199
- width: auto;
287
+ width: fit-content;
200
288
  min-width: ${menu.dropdown.minWidth};
201
- .${k}-menu-arrow {
289
+ .${k}-menu-item-arrow {
202
290
  transform: rotate(-90deg)
203
291
  }
204
292
  }
@@ -207,10 +295,13 @@ export const makeMenuStyles = cache(function makeMenuStyles(k: string) {
207
295
  &.${k}-horizontal {
208
296
  width: auto;
209
297
  display: flex;
210
- align-items: center;
211
- .${k}-menu-header {
212
- border-bottom: none;
213
- border-right: ${menu.header.borderBottom};
298
+ .${k}-menu-body {
299
+ display: flex;
300
+ align-items: center;
301
+ .${k}-menu-title {
302
+ border-top: none;
303
+ border-right: ${menu.border};
304
+ }
214
305
  }
215
306
  }
216
307
  `
@@ -232,11 +323,17 @@ export const makeTitleStyles = cache(function makeTitleStyles(k: string) {
232
323
  export const makeItemStyles = cache(function makeItemStyles(k: string) {
233
324
  const item = menu.item;
234
325
  return css`
235
- .${k}-menu-title {
326
+ .${k}-menu-item-title {
327
+ transition: all ${menu.transition};
236
328
  cursor: pointer;
237
329
  height: ${item.height};
238
330
  &:hover {
239
- color: ${item.hoverColor};
331
+ padding: ${item.padding};
332
+ border-radius: ${menu.borderRadius};
333
+ background: #2a2a30;
334
+ }
335
+ & > .${k}-menu-item-arrow:before {
336
+ font-size: small;
240
337
  }
241
338
  }
242
339
  .${k}-menu-name {
@@ -253,39 +350,41 @@ export const makeItemStyles = cache(function makeItemStyles(k: string) {
253
350
  color: inherit;
254
351
  }
255
352
  }
256
- .${k}-menu-arrow {
257
- transition: transform ${menu.transition};
353
+ .${k}-menu-item-arrow {
354
+ color: ${item.color};
258
355
  margin: 0 0 0 ${menu.icon.gap};
356
+ transition: transform ${menu.transition};
259
357
  }
260
358
 
261
359
  // expanded
262
360
  &.${k}-expanded {
263
- > .${k}-menu-title {
361
+ > .${k}-menu-item-title {
264
362
  color: ${item.hoverColor};
265
- .${k}-menu-arrow {
266
- transform: rotateX(180deg);
363
+ .${k}-menu-item-arrow {
364
+ transform: rotate(180deg);
267
365
  }
268
366
  }
269
367
  }
270
368
 
271
369
  // highlighted
272
370
  &.${k}-highlighted {
273
- > .${k}-menu-title {
274
- color: ${item.hoverColor};
371
+ > .${k}-menu-item-title {
372
+ color: ${menu.light.item.hoverColor};
275
373
  }
276
374
  }
277
375
 
278
376
  // active
279
377
  &.${k}-active {
280
- > .${k}-menu-title {
281
- color: ${item.hoverColor} !important;
282
- background: ${item.activeBgColor};
378
+ > .${k}-menu-item-title {
379
+ border-radius: ${menu.borderRadius};
380
+ color: ${item.activeBgColor} !important;
381
+ background: ${item.hoverBgColor};
283
382
  }
284
383
  }
285
384
 
286
385
  // disabled
287
386
  &.${k}-disabled {
288
- > .${k}-menu-title {
387
+ > .${k}-menu-item-title {
289
388
  color: ${item.disabledColor} !important;
290
389
  cursor: not-allowed;
291
390
  }
@@ -300,14 +399,22 @@ export const makeItemStyles = cache(function makeItemStyles(k: string) {
300
399
  });
301
400
 
302
401
  export const makeNestedMenuStyles = cache(function makeNestedMenuStyles(k: string, hasIcon: boolean, parentPaddingLeft: string = getLeft(menu.item.padding)) {
303
- const paddingLeft = `${parentPaddingLeft}${hasIcon ? ' + ' + menu.icon.width : ''} + ${menu.icon.gap}`;
402
+ const paddingLeft = `${parentPaddingLeft}${hasIcon ? ' + ' + menu.icon.width + ' + ' + menu.icon.gap : ''}`;
304
403
  return [
305
404
  css`
306
405
  &.${k}-menu {
406
+ position: relative;
307
407
  width: auto;
308
- background: ${menu.subBgColor};
309
- .${k}-menu-title {
310
- padding-left: calc(${paddingLeft});
408
+ background: ${menu.bgColor};
409
+ border: none;
410
+ .${k}-menu-body {
411
+ padding: 0;
412
+ .${k}-menu-item-title {
413
+ padding-left: calc(${paddingLeft});
414
+ }
415
+ .${k}-menu-item-title, .${k}-menu-item-arrow {
416
+ color: ${menu.item.subTitleColor};
417
+ }
311
418
  }
312
419
  }
313
420
  `,
@@ -0,0 +1,12 @@
1
+ import {Component, inject} from 'intact';
2
+ import {ROOT_MENU, Menu} from './menu'
3
+ import template from './title.vdt';
4
+ import { useConfigContext } from '../config';
5
+
6
+ export class MenuTitle extends Component {
7
+ static template = template;
8
+
9
+ public rootMenu = inject<Menu>(ROOT_MENU)!;
10
+ private config = useConfigContext();
11
+ }
12
+
@@ -0,0 +1,25 @@
1
+ import {Icon} from '../icon';
2
+ import {getRestProps, findChildren, isComponentVNode} from '../utils';
3
+ import {makeTitleStyles} from './styles';
4
+
5
+ const rootMenu = this.rootMenu;
6
+ const {collapse} = rootMenu.get();
7
+ const {children, className} = this.get();
8
+ const { k } = this.config;
9
+
10
+ const classNameObj = {
11
+ [`${k}-menu-title`]: true,
12
+ [className]: className,
13
+ };
14
+
15
+ <div class={classNameObj} {...getRestProps(this)}>
16
+ <div class={{
17
+ [`${k}-menu-name`]: true,
18
+ [makeTitleStyles(k)]: true
19
+ }}>
20
+ <span v-if={!collapse}>{children}</span>
21
+ <template v-else>
22
+ {findChildren(children, vNode => isComponentVNode(vNode, Icon))}
23
+ </template>
24
+ </div>
25
+ </div>
@@ -7,7 +7,7 @@ import { cache } from '../utils';
7
7
  const defaults = {
8
8
  width: '16px',
9
9
  get transition() { return theme.transition.small },
10
- get borderColor() { return theme.color.darkBorder; },
10
+ get borderColor() { return theme.color.border; },
11
11
  get hoverBorderColor() { return theme.color.primary; },
12
12
  bgColor: '#fff',
13
13
  textGap: '8px',
@@ -13,7 +13,7 @@ import {Select, Option} from 'kpc';
13
13
 
14
14
  <div>
15
15
  <Select v-model="day" searchable>
16
- <Option value="Monday">星期一</Option>
16
+ <Option value="Monday" disabled>星期一</Option>
17
17
  <Option value="Tuesday">星期二</Option>
18
18
  <Option value="Wednesday">星期三</Option>
19
19
  <Option value="Thursday">星期四</Option>
@@ -22,7 +22,7 @@ import {Select, Option} from 'kpc';
22
22
  <Option value="Sunday">星期天</Option>
23
23
  </Select>
24
24
  <Select v-model="days" searchable multiple>
25
- <Option value="Monday">星期一</Option>
25
+ <Option value="Monday" disabled>星期一</Option>
26
26
  <Option value="Tuesday">星期二</Option>
27
27
  <Option value="Wednesday">星期三</Option>
28
28
  <Option value="Thursday">星期四</Option>
@@ -262,7 +262,7 @@ describe('Select', () => {
262
262
  selectAll.click();
263
263
  confirm.click();
264
264
  await wait();
265
- expect(instance.get('days')).have.length(7);
265
+ expect(instance.get('days')).have.length(6);
266
266
 
267
267
  // unselect all
268
268
  select.click();
@@ -28,6 +28,7 @@ if (searchable && multiple) {
28
28
  value={value.value}
29
29
  ev-$change:value={value.set}
30
30
  trueValue={this.get('value')}
31
+ disabled={disabled}
31
32
  >{children}</Checkbox>
32
33
  )}
33
34
  </Consumer>
@@ -77,7 +77,10 @@ export class Select<
77
77
  const loop = (children: Children) => {
78
78
  eachChildren(children, vNode => {
79
79
  if (isComponentVNode(vNode, Option)) {
80
- values.push((vNode.props! as OptionProps).value);
80
+ const props = vNode.props as OptionProps;
81
+ if (!props.disabled) {
82
+ values.push(props.value);
83
+ }
81
84
  } else if (isComponentVNode(vNode, OptionGroup)) {
82
85
  loop(vNode.props!.children);
83
86
  }
@@ -14,6 +14,7 @@ import {context as FixedColumnsContext} from './useFixedColumns';
14
14
  import {stopPropagation} from '../utils';
15
15
  import {Input} from '../input';
16
16
  import {_$} from '../../i18n';
17
+ import {ignoreSortable} from './useSortable';
17
18
 
18
19
  const {title, fixed, group, multiple, key, sortable, cols, rows} = this.get();
19
20
  const {
@@ -57,6 +58,7 @@ const { k } = this.config;
57
58
  e._vNode = this.$vNode;
58
59
  onStart(e);
59
60
  }}
61
+ ev-click={ignoreSortable}
60
62
  />
61
63
  <div class={`${k}-table-title`}>
62
64
  <div class={`${k}-table-title-text c-ellipsis`}>
@@ -70,7 +72,7 @@ const { k } = this.config;
70
72
  ref={dropdownRef}
71
73
  >
72
74
  <Icon class={`${k}-icon-down-squared ${k}-table-group`}
73
- ev-click={e => e._ignoreSortable = true}
75
+ ev-click={ignoreSortable}
74
76
  hoverable
75
77
  color={isEmptyValue(groupValue) ? null : 'primary'}
76
78
  />
@@ -114,8 +116,8 @@ const { k } = this.config;
114
116
  <div v-if={sortable}
115
117
  class={{[`${k}-column-sort`]: true, [`${k}-${type}`]: type}}
116
118
  >
117
- <Icon class={`${k}-icon-up ${k}-asc`} size="mini" />
118
- <Icon class={`${k}-icon-down ${k}-desc`} size="mini" />
119
+ <Icon class={`${k}-icon-up-bold ${k}-asc`} size="mini" />
120
+ <Icon class={`${k}-icon-down-bold ${k}-desc`} size="mini" />
119
121
  </div>
120
122
  </div>
121
123
  </th>
@@ -18,6 +18,7 @@ import {Table, TableColumn} from 'kpc';
18
18
  sort={this.get('sort')}
19
19
  ev-$change:sort={this._onSort}
20
20
  rowKey={item => item.name}
21
+ resizable
21
22
  >
22
23
  <TableColumn title='姓名' key='name' sortable />
23
24
  <TableColumn title='年龄' key='age' sortable />
@@ -2,6 +2,8 @@ import {useInstance} from 'intact';
2
2
  import {createContext} from '../context';
3
3
  import type {Table, TableSortValue} from './table';
4
4
 
5
+ type SortEvent = Event & { _ignoreSortable?: boolean };
6
+
5
7
  export const context = createContext();
6
8
 
7
9
  export function useSortable() {
@@ -10,7 +12,7 @@ export function useSortable() {
10
12
  // if the same column has been clicked three times consecutively,
11
13
  // then let the third click to reset the sort
12
14
  let count = 0;
13
- function onChange(key: string, event: Event & {_ignoreSortable?: boolean}) {
15
+ function onChange(key: string, event: SortEvent) {
14
16
  // ignore when click group dropdown menu
15
17
  if (event._ignoreSortable) return;
16
18
 
@@ -31,5 +33,9 @@ export function useSortable() {
31
33
  instance.set('sort', sort);
32
34
  }
33
35
 
34
- return {onChange};
36
+ return {onChange, ignoreSortable};
37
+ }
38
+
39
+ export function ignoreSortable(e: SortEvent) {
40
+ e._ignoreSortable = true;
35
41
  }
@@ -1,29 +1,37 @@
1
1
  import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
2
2
  import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
3
- import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
4
3
  import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
4
+ import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
5
5
  import { Component } from 'intact';
6
- import { mount, wait } from '../../test/utils';
6
+ import { mount, unmount, wait } from '../../test/utils';
7
7
  import { ConfigProvider } from '.';
8
8
  import { Button, ButtonGroup } from '../button';
9
9
  describe('Config', function () {
10
- // afterEach(async () => {
11
- // unmount();
12
- // });
13
- it('should change classname prefix', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
10
+ afterEach( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
11
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
12
+ while (1) switch (_context.prev = _context.next) {
13
+ case 0:
14
+ unmount();
15
+ case 1:
16
+ case "end":
17
+ return _context.stop();
18
+ }
19
+ }, _callee);
20
+ })));
21
+ it('should change classname prefix', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
14
22
  var Demo, _mount, instance, element;
15
- return _regeneratorRuntime.wrap(function _callee$(_context2) {
16
- while (1) switch (_context2.prev = _context2.next) {
23
+ return _regeneratorRuntime.wrap(function _callee2$(_context3) {
24
+ while (1) switch (_context3.prev = _context3.next) {
17
25
  case 0:
18
26
  Demo = /*#__PURE__*/function (_Component) {
19
27
  _inheritsLoose(Demo, _Component);
20
28
  function Demo() {
21
- var _context;
29
+ var _context2;
22
30
  var _this;
23
31
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
24
32
  args[_key] = arguments[_key];
25
33
  }
26
- _this = _Component.call.apply(_Component, _concatInstanceProperty(_context = [this]).call(_context, args)) || this;
34
+ _this = _Component.call.apply(_Component, _concatInstanceProperty(_context2 = [this]).call(_context2, args)) || this;
27
35
  _this.ConfigProvider = ConfigProvider;
28
36
  _this.ButtonGroup = ButtonGroup;
29
37
  _this.Button = Button;
@@ -40,19 +48,19 @@ describe('Config', function () {
40
48
  _mount = mount(Demo), instance = _mount[0], element = _mount[1];
41
49
  expect(element.innerHTML).to.matchSnapshot();
42
50
  instance.set('k', 'a');
43
- _context2.next = 7;
51
+ _context3.next = 7;
44
52
  return wait();
45
53
  case 7:
46
54
  expect(element.innerHTML).to.matchSnapshot();
47
55
  instance.set('k', 'b');
48
- _context2.next = 11;
56
+ _context3.next = 11;
49
57
  return wait();
50
58
  case 11:
51
59
  expect(element.innerHTML).to.matchSnapshot();
52
60
  case 12:
53
61
  case "end":
54
- return _context2.stop();
62
+ return _context3.stop();
55
63
  }
56
- }, _callee);
64
+ }, _callee2);
57
65
  })));
58
66
  });