@king-design/intact 2.0.15 → 2.0.17-beta.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 (33) hide show
  1. package/components/cascader/styles.ts +2 -1
  2. package/components/dropdown/dropdown.ts +18 -9
  3. package/components/dropdown/menu.ts +1 -1
  4. package/components/select/demos/basic.md +1 -1
  5. package/components/table/column.vdt +26 -10
  6. package/components/table/demos/rowExpandable.md +1 -1
  7. package/components/table/demos/selectedKeys.md +1 -1
  8. package/components/table/index.md +3 -3
  9. package/components/table/index.spec.ts +2 -2
  10. package/components/table/styles.ts +6 -0
  11. package/components/table/useGroup.ts +18 -2
  12. package/components/table/useSortable.ts +4 -1
  13. package/components/tooltip/tooltip.ts +0 -2
  14. package/es/components/cascader/styles.js +1 -1
  15. package/es/components/dropdown/dropdown.d.ts +0 -1
  16. package/es/components/dropdown/dropdown.js +19 -7
  17. package/es/components/dropdown/menu.js +1 -1
  18. package/es/components/table/column.vdt.js +43 -7
  19. package/es/components/table/index.spec.js +2 -2
  20. package/es/components/table/styles.js +7 -1
  21. package/es/components/table/useGroup.d.ts +3 -0
  22. package/es/components/table/useGroup.js +24 -1
  23. package/es/components/table/useSortable.d.ts +3 -1
  24. package/es/components/table/useSortable.js +4 -1
  25. package/es/components/tooltip/tooltip.d.ts +0 -1
  26. package/es/components/tooltip/tooltip.js +1 -12
  27. package/es/index.d.ts +2 -2
  28. package/es/index.js +2 -2
  29. package/es/site/data/components/menu/demos/collapse/react.d.ts +11 -0
  30. package/es/site/data/components/menu/demos/size/react.d.ts +7 -0
  31. package/es/site/data/components/select/demos/basic/react.js +1 -2
  32. package/index.ts +2 -2
  33. package/package.json +3 -3
@@ -33,7 +33,8 @@ setDefault(() => {
33
33
  export function makeMenuStyles() {
34
34
  return css`
35
35
  min-width: ${cascader.width} !important;
36
- min-height: ${cascader.height};
36
+ height: ${cascader.height};
37
+ overflow: auto;
37
38
  .k-cascader-arrow {
38
39
  float: right;
39
40
  height: 100%;
@@ -126,10 +126,7 @@ export class Dropdown<
126
126
 
127
127
  return [
128
128
  clonedTrigger,
129
- // wrap the root dropdown menu to Portal to render into body
130
- this.alwaysPortal || !this.rootDropdown ?
131
- h(Portal, {children: menu, container: this.get('container')}) :
132
- menu
129
+ h(Portal, {children: menu, container: this.get('container')})
133
130
  ];
134
131
  };
135
132
 
@@ -139,8 +136,6 @@ export class Dropdown<
139
136
  public showedDropdown: Dropdown | null = null;
140
137
  public positionHook = usePosition();
141
138
 
142
- protected alwaysPortal = false;
143
-
144
139
  private timer: number | undefined = undefined;
145
140
  private triggerProps: any = null;
146
141
 
@@ -294,9 +289,10 @@ export class Dropdown<
294
289
  function useDocumentClickForDropdown(dropdown: Dropdown) {
295
290
  const elementRef = () => findDomFromVNode(dropdown.menuVNode!, true) as Element;
296
291
  const [addDocumentClick, removeDocumentClick] = useDocumentClick(elementRef, (e) => {
297
- // case 1: if click an trigger and the trigger type is hover, ignore it
298
- // case 2: if right click on trigger and the trigger type is contextmenu, ignore it
299
- // case 3: if click on trigger and the trigger type is focus, do nothing
292
+ // case 1: if click a trigger and its trigger type is hover, ignore it
293
+ // case 2: if right click on a trigger and its trigger type is contextmenu, ignore it
294
+ // case 3: if click on a trigger and its trigger type is focus, do nothing
295
+ // case 3: if click on sub-dropdown, we should also show the parent dropdown, so ignore it
300
296
  const trigger = dropdown.get('trigger');
301
297
  if (trigger === 'focus') return;
302
298
 
@@ -310,6 +306,8 @@ function useDocumentClickForDropdown(dropdown: Dropdown) {
310
306
  }
311
307
  }
312
308
 
309
+ if (isSubDropdownElement(e.target as Element, dropdown)) return;
310
+
313
311
  dropdown.hide(true);
314
312
  }, true);
315
313
 
@@ -317,6 +315,17 @@ function useDocumentClickForDropdown(dropdown: Dropdown) {
317
315
  dropdown.on('hide', removeDocumentClick);
318
316
  }
319
317
 
318
+ function isSubDropdownElement(elem: Element, dropdown: Dropdown): boolean {
319
+ const showedDropdown = dropdown.showedDropdown;
320
+ if (!showedDropdown) return false;
321
+
322
+ const subMenuElement = findDomFromVNode(showedDropdown.menuVNode!, true) as Element;
323
+ if (containsOrEqual(subMenuElement, elem)) {
324
+ return true;
325
+ }
326
+ return isSubDropdownElement(elem, showedDropdown);
327
+ }
328
+
320
329
  function useHideLastMenuOnShow(dropdown: Dropdown) {
321
330
  const parentDropdown = dropdown.dropdown;
322
331
  dropdown.on('show', () => {
@@ -63,7 +63,7 @@ function useKeyboardForDropdownMenu(dropdown: Dropdown) {
63
63
  const focus = () => focusByIndex(0);
64
64
 
65
65
  // In Cascader the menu may have been replaced by another menu, in this case,
66
- // if the dropdown has showed on mount the menu, add keydown listener
66
+ // if the dropdown has showed while we mounted the menu, add keydown listener
67
67
  if (dropdown.get('value')) {
68
68
  onShow();
69
69
  }
@@ -11,7 +11,7 @@ import {Select, Option} from 'kpc';
11
11
 
12
12
  <div>
13
13
  <div style="margin-bottom: 16px;">
14
- <Select v-model="day" show={true}>
14
+ <Select v-model="day">
15
15
  <Option value="Monday">星期一</Option>
16
16
  <Option value="Tuesday">星期二</Option>
17
17
  <Option value="Wednesday">星期三</Option>
@@ -12,9 +12,11 @@ import {context as TableContext} from './useColumns';
12
12
  import {context as ResizableContext} from './useResizable';
13
13
  import {context as FixedColumnsContext} from './useFixedColumns';
14
14
  import {stopPropagation} from '../utils';
15
+ import {Input} from '../input';
16
+ import {_$} from '../../i18n';
15
17
 
16
18
  const {title, fixed, group, multiple, key, sortable, cols, rows} = this.get();
17
- const {onSelect, isChecked, getGroupText} = this.group;
19
+ const {onSelect, isChecked, getGroupText, keywords, filteredGroup} = this.group;
18
20
 
19
21
  <TableContext.Consumer>
20
22
  {checkType => {
@@ -61,21 +63,35 @@ const {onSelect, isChecked, getGroupText} = this.group;
61
63
  <Dropdown v-if={group}
62
64
  position={{my: 'center top', at: 'center bottom+5', collision: 'flipfit'}}
63
65
  key="dropdown"
66
+ trigger="click"
67
+ ev-show={() => keywords.set('')}
64
68
  >
65
69
  <Button icon size="mini" class="k-table-group"
66
- ev-click={stopPropagation}
70
+ ev-click={e => e._ignoreSortable = true}
67
71
  >
68
72
  <Icon class="ion-android-arrow-dropdown" />
69
73
  </Button>
70
74
  <DropdownMenu class={{"k-table-group-dropdown": true, [makeGroupMenuStyles()]: true}}>
71
- <DropdownItem v-for={group}
72
- ev-select={() => onSelect($value.value, groupValue, onChange)}
73
- hideOnSelect={!multiple}
74
- class={{'k-active': (checked = isChecked($value.value, groupValue))}}
75
- >
76
- <Checkbox v-if={multiple} value={checked}>{$value.label}</Checkbox>
77
- <span v-else>{$value.label}</span>
78
- </DropdownItem>
75
+ <div class="k-table-group-header">
76
+ <Input size="small" fluid
77
+ placeholder={_$('请输入关键字')}
78
+ value={keywords.value}
79
+ ev-$change:value={keywords.set}
80
+ clearable
81
+ >
82
+ <b:suffix><Icon class="ion-ios-search" /></b:suffix>
83
+ </Input>
84
+ </div>
85
+ <div class="k-table-group-body">
86
+ <DropdownItem v-for={filteredGroup.value}
87
+ ev-select={() => onSelect($value.value, groupValue, onChange)}
88
+ hideOnSelect={!multiple}
89
+ class={{'k-active': (checked = isChecked($value.value, groupValue))}}
90
+ >
91
+ <Checkbox v-if={multiple} value={checked}>{$value.label}</Checkbox>
92
+ <span v-else>{$value.label}</span>
93
+ </DropdownItem>
94
+ </div>
79
95
  </DropdownMenu>
80
96
  </Dropdown>
81
97
  <div v-if={sortable}
@@ -5,7 +5,7 @@ order: 8
5
5
 
6
6
  通过`expand`扩展点指定行展开后的模板内容。是否支持点击该行任何区域都展开内容,
7
7
  是由`rowExpandable`控制的,默认情况下它为`true`。你也可以将它设为`false`,来自定义展开逻辑。例如:
8
- 点击某个`icon`后展开改行,而点击其它元素无效。自定义展开逻辑,修改`expandedKeys`属性值,来指定哪些`key`对应的行展开。
8
+ 点击某个`icon`后展开该行,而点击其它元素无效。自定义展开逻辑,修改`expandedKeys`属性值,来指定哪些`key`对应的行展开。
9
9
 
10
10
  ```vdt
11
11
  import {Table, TableColumn} from 'kpc';
@@ -3,7 +3,7 @@ title: 行高亮
3
3
  order: 5
4
4
  ---
5
5
 
6
- 给`Table`添加`rowSelectable`属性,可以让表格点击行时高亮改行,你可以指定值为`multiple`来支持多行
6
+ 给`Table`添加`rowSelectable`属性,可以让表格点击行时高亮该行,你可以指定值为`multiple`来支持多行
7
7
  高亮。类似`checkedKeys`,我们可以通过`selectedKeys`来绑定高亮行的`key`,当高亮的行改变时,组件也会
8
8
  抛出`$change:selectedKeys`事件,我们可以通过`getSelectedData`来获取高亮行的数据
9
9
 
@@ -19,7 +19,7 @@ sidebar: doc
19
19
  | checkedKeys | 通过`key`数组来指定哪些行被选中 | `TableRowKey[]` | `[]` |
20
20
  | rowKey | 设置每行的key | `(value: T, index: number) => TableRowKey` | `(value: T, index: number) => index` |
21
21
  | rowCheckable | 当行可选时,是否点击该行任意区域都可选中 | `boolean` | `true` |
22
- | disableRow | 定义行禁用可选的逻辑,返回`true`,则改行被禁用选择 | `(value: T, index: number, key: TableRowKey) => boolean` | `undefined` |
22
+ | disableRow | 定义行禁用可选的逻辑,返回`true`,则该行被禁用选择 | `(value: T, index: number, key: TableRowKey) => boolean` | `undefined` |
23
23
  | type | 表格类型,默认左右无边框,`"border"`类型会添加边框, `"grid"`类型会展示栅格边框 | `"default"` &#124; `"border"` &#124; `"grid"` | `"default"` |
24
24
  | stripe | 相邻行是否展示不同的背景色 | `boolean` | `false` |
25
25
  | rowClassName | 通过一个函数定义行的`className`,该函数会传入该行数据,索引和`key`当做参数,返回的字符串将被设为该行的`className` | <code>(value: T, index: number, key: TableRowKey) => string &#124; undefined</code> | `undefined` |
@@ -28,9 +28,9 @@ sidebar: doc
28
28
  | loading | 是否展示加载状态 | `boolean` | `false` |
29
29
  | merge | 指定表格单元格合并逻辑 | `TableMerge` | `undefined` |
30
30
  | expandedKeys | 通过`key`来指定哪些行展开 | `TableRowKey[]` | `undefined` |
31
- | rowExpandable | 是否点击改行任意区域即展开 | `boolean` | `true` |
31
+ | rowExpandable | 是否点击该行任意区域即展开 | `boolean` | `true` |
32
32
  | selectedKeys | 当`rowSelectable`取值为非`false`时,指定哪些行高亮 | `TableRowKey[]` | `undefined` |
33
- | rowSelectable | 是否点击行时高亮改行,取值为`multiple`时,可以同时高亮多行 | `boolean` &#124; `"single"` &#124; `"multiple"` | `false` |
33
+ | rowSelectable | 是否点击行时高亮该行,取值为`multiple`时,可以同时高亮多行 | `boolean` &#124; `"single"` &#124; `"multiple"` | `false` |
34
34
  | childrenKey | 树形表格指定子元素键名 | `string` | `"children"` |
35
35
  | indent | 树形表格指定子元素缩进宽度 | `number` | `32` |
36
36
  | spreadKeys | 树形表格指定展开的行 | `TableRowKey[]` | `undefined` |
@@ -194,7 +194,7 @@ describe('Table', () => {
194
194
  const [table1, table2] = element.querySelectorAll<HTMLElement>('.k-table');
195
195
 
196
196
  const icon = table1.querySelector('.k-table-group') as HTMLElement;
197
- dispatchEvent(icon, 'mouseenter');
197
+ dispatchEvent(icon, 'click');
198
198
  await wait();
199
199
  const dropdown = getElement('.k-table-group-dropdown')!;
200
200
  expect(dropdown.innerHTML).to.matchSnapshot();
@@ -206,7 +206,7 @@ describe('Table', () => {
206
206
  expect(table1.innerHTML).to.matchSnapshot();
207
207
 
208
208
  const icon2 = table2.querySelector('.k-table-group') as HTMLElement;
209
- dispatchEvent(icon2, 'mouseenter');
209
+ dispatchEvent(icon2, 'click');
210
210
  await wait();
211
211
  const dropdown2 = getElement('.k-table-group-dropdown')!;
212
212
  expect(dropdown2.innerHTML).to.matchSnapshot();
@@ -41,6 +41,8 @@ const defaults = {
41
41
  color: `#a6a6a6`,
42
42
  menuMaxHeight: '200px',
43
43
  get activeColor() { return theme.color.primary },
44
+ headerPadding: `8px`,
45
+ get headerBorder() { return `1px solid ${theme.color.bg}` },
44
46
  },
45
47
 
46
48
  // sort
@@ -371,5 +373,9 @@ export function makeGroupMenuStyles() {
371
373
  .k-dropdown-item.k-active {
372
374
  color: ${table.group.activeColor};
373
375
  }
376
+ .k-table-group-header {
377
+ padding: ${table.group.headerPadding};
378
+ border-bottom: ${table.group.headerBorder};
379
+ }
374
380
  `
375
381
  }
@@ -1,8 +1,9 @@
1
1
  import {useInstance} from 'intact';
2
- import type {TableColumn} from './column';
2
+ import type {TableColumn, TableColumnGroupItem} from './column';
3
3
  import {isNullOrUndefined} from 'intact-shared';
4
4
  import {toggleArray} from '../utils';
5
5
  import {createContext} from '../context';
6
+ import {useState, watchState} from '../../hooks/useState';
6
7
 
7
8
  type ContextValue = {
8
9
  groupValue: any
@@ -13,6 +14,8 @@ export const context = createContext<ContextValue>();
13
14
 
14
15
  export function useGroup() {
15
16
  const instance = useInstance() as TableColumn;
17
+ const keywords = useState<string>('');
18
+ const filteredGroup = useState<TableColumnGroupItem[] | undefined>(instance.get('group'));
16
19
 
17
20
  function onSelect(value: any, groupValue: any, onChange: ContextValue['onChange']) {
18
21
  const {multiple, key} = instance.get();
@@ -51,5 +54,18 @@ export function useGroup() {
51
54
  return null;
52
55
  }
53
56
 
54
- return {onSelect, isChecked, getGroupText};
57
+ watchState(keywords, (v) => {
58
+ const {group = []} = instance.get();
59
+ v = v.trim();
60
+
61
+ if (!v) {
62
+ filteredGroup.set(group);
63
+ } else {
64
+ filteredGroup.set(group.filter(item => {
65
+ return String(item.label).includes(v) || String(item.value).includes(v);
66
+ }));
67
+ }
68
+ });
69
+
70
+ return {onSelect, isChecked, getGroupText, keywords, filteredGroup};
55
71
  }
@@ -10,7 +10,10 @@ export function useSortable() {
10
10
  // if the same column has been clicked three times consecutively,
11
11
  // then let the third click to reset the sort
12
12
  let count = 0;
13
- function onChange(key: string) {
13
+ function onChange(key: string, event: Event & {_ignoreSortable?: boolean}) {
14
+ // ignore when click group dropdown menu
15
+ if (event._ignoreSortable) return;
16
+
14
17
  let sort = {...instance.get('sort')} as TableSortValue;
15
18
  if (sort.key === key) {
16
19
  count++;
@@ -72,8 +72,6 @@ export class Tooltip<
72
72
  static defaults = defaults;
73
73
  static events = events;
74
74
 
75
- protected alwaysPortal = true;
76
-
77
75
  hide(immediately: boolean) {
78
76
  if (this.get('always')) return;
79
77
 
@@ -43,7 +43,7 @@ setDefault(function () {
43
43
  }).cascader;
44
44
  });
45
45
  export function makeMenuStyles() {
46
- return /*#__PURE__*/css("min-width:", cascader.width, "!important;min-height:", cascader.height, ";.k-cascader-arrow{float:right;height:100%;margin-left:", cascader.arrowGap, ";line-height:inherit;}.k-cascader-loading{display:block;text-align:center;margin-top:", cascader.loadingGap, ";}.k-cascader-empty{padding:", cascader.empty.padding, ";color:", cascader.empty.color, ";text-align:center;}.k-cascader-option{&.k-selected{color:", cascader.selectedColor, ";}&.k-active{background:", cascader.activeBgColor, ";}}");
46
+ return /*#__PURE__*/css("min-width:", cascader.width, "!important;height:", cascader.height, ";overflow:auto;.k-cascader-arrow{float:right;height:100%;margin-left:", cascader.arrowGap, ";line-height:inherit;}.k-cascader-loading{display:block;text-align:center;margin-top:", cascader.loadingGap, ";}.k-cascader-empty{padding:", cascader.empty.padding, ";color:", cascader.empty.color, ";text-align:center;}.k-cascader-option{&.k-selected{color:", cascader.selectedColor, ";}&.k-active{background:", cascader.activeBgColor, ";}}");
47
47
  }
48
48
  export function makeFilterMenuStyles() {
49
49
  return /*#__PURE__*/css("min-width:", _filterInstanceProperty(cascader).minWidth, "!important;height:auto;max-height:", _filterInstanceProperty(cascader).maxHeight, ";em{font-style:normal;color:", _filterInstanceProperty(cascader).highlightColor, ";}");
@@ -41,7 +41,6 @@ export declare class Dropdown<T extends DropdownProps = DropdownProps, E extends
41
41
  value: boolean;
42
42
  };
43
43
  };
44
- protected alwaysPortal: boolean;
45
44
  private timer;
46
45
  private triggerProps;
47
46
  init(): void;
@@ -57,7 +57,6 @@ export var Dropdown = /*#__PURE__*/function (_Component) {
57
57
  _this.rootDropdown = null;
58
58
  _this.showedDropdown = null;
59
59
  _this.positionHook = usePosition();
60
- _this.alwaysPortal = false;
61
60
  _this.timer = undefined;
62
61
  _this.triggerProps = null;
63
62
  return _this;
@@ -267,11 +266,10 @@ Dropdown.template = function () {
267
266
  });
268
267
  clonedTrigger.className = className;
269
268
  this.menuVNode = menu;
270
- return [clonedTrigger, // wrap the root dropdown menu to Portal to render into body
271
- this.alwaysPortal || !this.rootDropdown ? h(Portal, {
269
+ return [clonedTrigger, h(Portal, {
272
270
  children: menu,
273
271
  container: this.get('container')
274
- }) : menu];
272
+ })];
275
273
  };
276
274
 
277
275
  __decorate([bind], Dropdown.prototype, "position", null);
@@ -288,9 +286,10 @@ function useDocumentClickForDropdown(dropdown) {
288
286
  };
289
287
 
290
288
  var _useDocumentClick = useDocumentClick(elementRef, function (e) {
291
- // case 1: if click an trigger and the trigger type is hover, ignore it
292
- // case 2: if right click on trigger and the trigger type is contextmenu, ignore it
293
- // case 3: if click on trigger and the trigger type is focus, do nothing
289
+ // case 1: if click a trigger and its trigger type is hover, ignore it
290
+ // case 2: if right click on a trigger and its trigger type is contextmenu, ignore it
291
+ // case 3: if click on a trigger and its trigger type is focus, do nothing
292
+ // case 3: if click on sub-dropdown, we should also show the parent dropdown, so ignore it
294
293
  var trigger = dropdown.get('trigger');
295
294
  if (trigger === 'focus') return;
296
295
  var isHover = trigger === 'hover';
@@ -305,6 +304,7 @@ function useDocumentClickForDropdown(dropdown) {
305
304
  }
306
305
  }
307
306
 
307
+ if (isSubDropdownElement(e.target, dropdown)) return;
308
308
  dropdown.hide(true);
309
309
  }, true),
310
310
  addDocumentClick = _useDocumentClick[0],
@@ -314,6 +314,18 @@ function useDocumentClickForDropdown(dropdown) {
314
314
  dropdown.on('hide', removeDocumentClick);
315
315
  }
316
316
 
317
+ function isSubDropdownElement(elem, dropdown) {
318
+ var showedDropdown = dropdown.showedDropdown;
319
+ if (!showedDropdown) return false;
320
+ var subMenuElement = findDomFromVNode(showedDropdown.menuVNode, true);
321
+
322
+ if (containsOrEqual(subMenuElement, elem)) {
323
+ return true;
324
+ }
325
+
326
+ return isSubDropdownElement(elem, showedDropdown);
327
+ }
328
+
317
329
  function useHideLastMenuOnShow(dropdown) {
318
330
  var parentDropdown = dropdown.dropdown;
319
331
  dropdown.on('show', function () {
@@ -85,7 +85,7 @@ function useKeyboardForDropdownMenu(dropdown) {
85
85
  var focus = function focus() {
86
86
  return focusByIndex(0);
87
87
  }; // In Cascader the menu may have been replaced by another menu, in this case,
88
- // if the dropdown has showed on mount the menu, add keydown listener
88
+ // if the dropdown has showed while we mounted the menu, add keydown listener
89
89
 
90
90
 
91
91
  if (dropdown.get('value')) {
@@ -1,5 +1,5 @@
1
1
  import _sortInstanceProperty from "@babel/runtime-corejs3/core-js/instance/sort";
2
- import { createUnknownComponentVNode as _$cc, createElementVNode as _$ce, noop as _$no, className as _$cn, map as _$ma } from 'intact';
2
+ import { createUnknownComponentVNode as _$cc, createElementVNode as _$ce, noop as _$no, className as _$cn, extend as _$ex, EMPTY_OBJ as _$em, map as _$ma } from 'intact';
3
3
  import { getClassAndStyleForFixed } from './useFixedColumns';
4
4
  import { Dropdown, DropdownMenu, DropdownItem } from '../dropdown';
5
5
  import { Button } from '../button';
@@ -14,13 +14,18 @@ import { context as TableContext } from './useColumns';
14
14
  import { context as ResizableContext } from './useResizable';
15
15
  import { context as FixedColumnsContext } from './useFixedColumns';
16
16
  import { stopPropagation } from '../utils';
17
+ import { Input } from '../input';
18
+ import { _$ } from '../../i18n';
17
19
  var _$tmp0 = {
18
20
  'className': 'ion-android-arrow-dropdown'
19
21
  };
20
22
  var _$tmp1 = {
21
- 'className': 'ion-android-arrow-dropup k-asc'
23
+ 'className': 'ion-ios-search'
22
24
  };
23
25
  var _$tmp2 = {
26
+ 'className': 'ion-android-arrow-dropup k-asc'
27
+ };
28
+ var _$tmp3 = {
24
29
  'className': 'ion-android-arrow-dropdown k-desc'
25
30
  };
26
31
  export default function ($props, $blocks, $__proto__) {
@@ -45,7 +50,9 @@ export default function ($props, $blocks, $__proto__) {
45
50
  var _this$group = this.group,
46
51
  onSelect = _this$group.onSelect,
47
52
  isChecked = _this$group.isChecked,
48
- getGroupText = _this$group.getGroupText;
53
+ getGroupText = _this$group.getGroupText,
54
+ keywords = _this$group.keywords,
55
+ filteredGroup = _this$group.filteredGroup;
49
56
  return _$cc(TableContext.Consumer, {
50
57
  'children': function children(checkType) {
51
58
  return _$cc(GroupContext.Consumer, {
@@ -98,17 +105,46 @@ export default function ($props, $blocks, $__proto__) {
98
105
  collision: 'flipfit'
99
106
  },
100
107
  'key': 'dropdown',
108
+ 'trigger': 'click',
109
+ 'ev-show': function evShow() {
110
+ return keywords.set('');
111
+ },
101
112
  'children': [_$cc(Button, {
102
113
  'icon': true,
103
114
  'size': 'mini',
104
115
  'className': 'k-table-group',
105
- 'ev-click': stopPropagation,
116
+ 'ev-click': function evClick(e) {
117
+ return e._ignoreSortable = true;
118
+ },
106
119
  'children': _$cc(Icon, _$tmp0)
107
120
  }), _$cc(DropdownMenu, {
108
121
  'className': _$cn((_$cn2 = {
109
122
  "k-table-group-dropdown": true
110
123
  }, _$cn2[makeGroupMenuStyles()] = true, _$cn2)),
111
- 'children': _$ma(group, function ($value, $key) {
124
+ 'children': [_$ce(2, 'div', _$cc(Input, {
125
+ 'size': 'small',
126
+ 'fluid': true,
127
+ 'placeholder': _$('请输入关键字'),
128
+ 'value': keywords.value,
129
+ 'ev-$change:value': keywords.set,
130
+ 'clearable': true,
131
+ '$blocks': function ($blocks) {
132
+ var _$blocks = {},
133
+ __$blocks = _$ex({}, $blocks);
134
+
135
+ return (_$blocks['suffix'] = function ($super) {
136
+ return _$cc(Icon, _$tmp1);
137
+ }, __$blocks['suffix'] = function ($super, data) {
138
+ var block = $blocks['suffix'];
139
+
140
+ var callBlock = function callBlock() {
141
+ return _$blocks['suffix'].call($this, $super, data);
142
+ };
143
+
144
+ return block ? block.call($this, callBlock, data) : callBlock();
145
+ }), __$blocks;
146
+ }.call($this, _$em)
147
+ }), 2, 'k-table-group-header'), _$ce(2, 'div', _$ma(filteredGroup.value, function ($value, $key) {
112
148
  return _$cc(DropdownItem, {
113
149
  'ev-select': function evSelect() {
114
150
  return onSelect($value.value, groupValue, onChange);
@@ -122,9 +158,9 @@ export default function ($props, $blocks, $__proto__) {
122
158
  'children': $value.label
123
159
  }) : _$ce(2, 'span', $value.label, 0)
124
160
  });
125
- }, $this)
161
+ }, $this), 4, 'k-table-group-body')]
126
162
  })]
127
- }, 'dropdown') : undefined, sortable ? _$ce(2, 'div', [_$cc(Icon, _$tmp1), _$cc(Icon, _$tmp2)], 4, _$cn((_$cn3 = {
163
+ }, 'dropdown') : undefined, sortable ? _$ce(2, 'div', [_$cc(Icon, _$tmp2), _$cc(Icon, _$tmp3)], 4, _$cn((_$cn3 = {
128
164
  'k-column-sort': true
129
165
  }, _$cn3["k-" + type] = type, _$cn3))) : undefined], 0, 'k-table-title')], 0, _$cn(classNameObj), {
130
166
  'style': style,
@@ -352,7 +352,7 @@ describe('Table', function () {
352
352
  _instance$refs4 = instance.refs, __test1 = _instance$refs4.__test1, __test2 = _instance$refs4.__test2;
353
353
  _element$querySelecto8 = element.querySelectorAll('.k-table'), table1 = _element$querySelecto8[0], table2 = _element$querySelecto8[1];
354
354
  icon = table1.querySelector('.k-table-group');
355
- dispatchEvent(icon, 'mouseenter');
355
+ dispatchEvent(icon, 'click');
356
356
  _context7.next = 7;
357
357
  return wait();
358
358
 
@@ -370,7 +370,7 @@ describe('Table', function () {
370
370
  });
371
371
  expect(table1.innerHTML).to.matchSnapshot();
372
372
  icon2 = table2.querySelector('.k-table-group');
373
- dispatchEvent(icon2, 'mouseenter');
373
+ dispatchEvent(icon2, 'click');
374
374
  _context7.next = 19;
375
375
  return wait();
376
376
 
@@ -53,6 +53,12 @@ var defaults = {
53
53
 
54
54
  get activeColor() {
55
55
  return theme.color.primary;
56
+ },
57
+
58
+ headerPadding: "8px",
59
+
60
+ get headerBorder() {
61
+ return "1px solid " + theme.color.bg;
56
62
  }
57
63
 
58
64
  },
@@ -89,5 +95,5 @@ export function makeStyles() {
89
95
  }), ";");
90
96
  }
91
97
  export function makeGroupMenuStyles() {
92
- return /*#__PURE__*/css("max-height:", table.group.menuMaxHeight, ";overflow:auto;.k-dropdown-item.k-active{color:", table.group.activeColor, ";}");
98
+ return /*#__PURE__*/css("max-height:", table.group.menuMaxHeight, ";overflow:auto;.k-dropdown-item.k-active{color:", table.group.activeColor, ";}.k-table-group-header{padding:", table.group.headerPadding, ";border-bottom:", table.group.headerBorder, ";}");
93
99
  }
@@ -1,3 +1,4 @@
1
+ import type { TableColumnGroupItem } from './column';
1
2
  declare type ContextValue = {
2
3
  groupValue: any;
3
4
  onChange: (key: string, groupValue: any) => void;
@@ -10,5 +11,7 @@ export declare function useGroup(): {
10
11
  onSelect: (value: any, groupValue: any, onChange: ContextValue['onChange']) => void;
11
12
  isChecked: (value: any, groupValue: any) => any;
12
13
  getGroupText: (groupValue: any) => string | null;
14
+ keywords: import("../../hooks/useState").State<string>;
15
+ filteredGroup: import("../../hooks/useState").State<TableColumnGroupItem[] | undefined>;
13
16
  };
14
17
  export {};
@@ -1,13 +1,17 @@
1
1
  import _includesInstanceProperty from "@babel/runtime-corejs3/core-js/instance/includes";
2
2
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js/instance/map";
3
3
  import _filterInstanceProperty from "@babel/runtime-corejs3/core-js/instance/filter";
4
+ import _trimInstanceProperty from "@babel/runtime-corejs3/core-js/instance/trim";
4
5
  import { useInstance } from 'intact';
5
6
  import { isNullOrUndefined } from 'intact-shared';
6
7
  import { toggleArray } from '../utils';
7
8
  import { createContext } from '../context';
9
+ import { useState, watchState } from '../../hooks/useState';
8
10
  export var context = createContext();
9
11
  export function useGroup() {
10
12
  var instance = useInstance();
13
+ var keywords = useState('');
14
+ var filteredGroup = useState(instance.get('group'));
11
15
 
12
16
  function onSelect(value, groupValue, onChange) {
13
17
  var _instance$get = instance.get(),
@@ -60,9 +64,28 @@ export function useGroup() {
60
64
  return null;
61
65
  }
62
66
 
67
+ watchState(keywords, function (v) {
68
+ var _instance$get4 = instance.get(),
69
+ _instance$get4$group = _instance$get4.group,
70
+ group = _instance$get4$group === void 0 ? [] : _instance$get4$group;
71
+
72
+ v = _trimInstanceProperty(v).call(v);
73
+
74
+ if (!v) {
75
+ filteredGroup.set(group);
76
+ } else {
77
+ filteredGroup.set(_filterInstanceProperty(group).call(group, function (item) {
78
+ var _context2, _context3;
79
+
80
+ return _includesInstanceProperty(_context2 = String(item.label)).call(_context2, v) || _includesInstanceProperty(_context3 = String(item.value)).call(_context3, v);
81
+ }));
82
+ }
83
+ });
63
84
  return {
64
85
  onSelect: onSelect,
65
86
  isChecked: isChecked,
66
- getGroupText: getGroupText
87
+ getGroupText: getGroupText,
88
+ keywords: keywords,
89
+ filteredGroup: filteredGroup
67
90
  };
68
91
  }
@@ -3,5 +3,7 @@ export declare const context: {
3
3
  Consumer: import("intact").ComponentConstructor<import("intact").Component<import("../context").ConsumerProps<any>, {}, {}, {}>>;
4
4
  };
5
5
  export declare function useSortable(): {
6
- onChange: (key: string) => void;
6
+ onChange: (key: string, event: Event & {
7
+ _ignoreSortable?: boolean;
8
+ }) => void;
7
9
  };
@@ -8,7 +8,10 @@ export function useSortable() {
8
8
 
9
9
  var count = 0;
10
10
 
11
- function onChange(key) {
11
+ function onChange(key, event) {
12
+ // ignore when click group dropdown menu
13
+ if (event._ignoreSortable) return;
14
+
12
15
  var sort = _extends({}, instance.get('sort'));
13
16
 
14
17
  if (sort.key === key) {
@@ -23,6 +23,5 @@ export declare class Tooltip<T extends TooltipProps = TooltipProps, E extends To
23
23
  static typeDefs: Required<TypeDefs<TooltipProps>>;
24
24
  static defaults: () => Partial<TooltipProps>;
25
25
  static events: Events<TooltipEvents>;
26
- protected alwaysPortal: boolean;
27
26
  hide(immediately: boolean): void;
28
27
  }
@@ -1,6 +1,5 @@
1
1
  import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
2
2
  import _extends from "@babel/runtime-corejs3/helpers/extends";
3
- import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
4
3
  import { Dropdown } from '../dropdown/dropdown';
5
4
  import { _$ } from '../../i18n';
6
5
  import { themes } from './styles';
@@ -44,17 +43,7 @@ export var Tooltip = /*#__PURE__*/function (_Dropdown) {
44
43
  _inheritsLoose(Tooltip, _Dropdown);
45
44
 
46
45
  function Tooltip() {
47
- var _context;
48
-
49
- var _this;
50
-
51
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
52
- args[_key] = arguments[_key];
53
- }
54
-
55
- _this = _Dropdown.call.apply(_Dropdown, _concatInstanceProperty(_context = [this]).call(_context, args)) || this;
56
- _this.alwaysPortal = true;
57
- return _this;
46
+ return _Dropdown.apply(this, arguments) || this;
58
47
  }
59
48
 
60
49
  var _proto = Tooltip.prototype;
package/es/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @king-design v2.0.15
2
+ * @king-design v2.0.17-beta.0
3
3
  *
4
4
  * Copyright (c) Kingsoft Cloud
5
5
  * Released under the MIT License
@@ -57,4 +57,4 @@ export * from './components/tree';
57
57
  export * from './components/treeSelect';
58
58
  export * from './components/upload';
59
59
  export * from './components/wave';
60
- export declare const version = "2.0.15";
60
+ export declare const version = "2.0.17-beta.0";
package/es/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @king-design v2.0.15
2
+ * @king-design v2.0.17-beta.0
3
3
  *
4
4
  * Copyright (c) Kingsoft Cloud
5
5
  * Released under the MIT License
@@ -59,5 +59,5 @@ export * from './components/tree';
59
59
  export * from './components/treeSelect';
60
60
  export * from './components/upload';
61
61
  export * from './components/wave';
62
- export var version = '2.0.15';
62
+ export var version = '2.0.17-beta.0';
63
63
  /* generate end */
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { MenuProps } from '@king-design/react';
3
+ interface Props extends MenuProps {
4
+ }
5
+ export default class Demo extends React.Component<{}, Props> {
6
+ state: MenuProps<import("misstime").Key>;
7
+ private __test;
8
+ setTheme(theme?: string): void;
9
+ render(): JSX.Element;
10
+ }
11
+ export {};
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import './index.styl';
3
+ import type { MenuProps } from '@king-design/react';
4
+ export default class Demo extends React.Component {
5
+ state: MenuProps<import("misstime").Key>;
6
+ render(): JSX.Element;
7
+ }
@@ -37,8 +37,7 @@ var Demo = /*#__PURE__*/function (_React$Component) {
37
37
  return _this2.setState({
38
38
  day: day
39
39
  });
40
- },
41
- show: true
40
+ }
42
41
  }, /*#__PURE__*/React.createElement(Option, {
43
42
  value: "Monday"
44
43
  }, "\u661F\u671F\u4E00"), /*#__PURE__*/React.createElement(Option, {
package/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @king-design v2.0.15
2
+ * @king-design v2.0.17-beta.0
3
3
  *
4
4
  * Copyright (c) Kingsoft Cloud
5
5
  * Released under the MIT License
@@ -62,6 +62,6 @@ export * from './components/treeSelect';
62
62
  export * from './components/upload';
63
63
  export * from './components/wave';
64
64
 
65
- export const version = '2.0.15';
65
+ export const version = '2.0.17-beta.0';
66
66
 
67
67
  /* generate end */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@king-design/intact",
3
- "version": "2.0.15",
3
+ "version": "2.0.17-beta.0",
4
4
  "description": "A component library written in Intact for Intact, Vue, React and Angular",
5
5
  "main": "es/index.js",
6
6
  "scripts": {
@@ -116,7 +116,7 @@
116
116
  "highlight.js": "^10.4.1",
117
117
  "history": "^5.0.0",
118
118
  "html-webpack-plugin": "5.3.1",
119
- "intact-react": "^3.0.15",
119
+ "intact-react": "^3.0.16",
120
120
  "istanbul-instrumenter-loader": "^3.0.0",
121
121
  "js-yaml": "^4.1.0",
122
122
  "karma": "^6.3.2",
@@ -178,7 +178,7 @@
178
178
  "dayjs": "^1.10.7",
179
179
  "downloadjs": "^1.4.7",
180
180
  "enquire.js": "^2.1.6",
181
- "intact": "^3.0.13",
181
+ "intact": "^3.0.16",
182
182
  "monaco-editor": "^0.26.1",
183
183
  "mxgraphx": "^4.0.7",
184
184
  "resize-observer-polyfill": "^1.5.1",