@king-design/intact 3.1.1-beta.3 → 3.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (249) hide show
  1. package/components/affix/styles.ts +4 -2
  2. package/components/badge/index.vdt +1 -1
  3. package/components/badge/styles.ts +4 -3
  4. package/components/breadcrumb/index.vdt +1 -1
  5. package/components/breadcrumb/styles.ts +4 -2
  6. package/components/button/styles.ts +7 -5
  7. package/components/card/styles.ts +4 -2
  8. package/components/carousel/styles.ts +7 -4
  9. package/components/cascader/index.vdt +2 -1
  10. package/components/cascader/styles.ts +7 -4
  11. package/components/checkbox/index.vdt +1 -1
  12. package/components/checkbox/styles.ts +4 -2
  13. package/components/code/styles.ts +3 -2
  14. package/components/collapse/index.spec.ts +1 -1
  15. package/components/collapse/styles.ts +7 -4
  16. package/components/colorpicker/styles.ts +7 -4
  17. package/components/copy/styles.ts +3 -2
  18. package/components/datepicker/styles.ts +10 -6
  19. package/components/diagram/styles.ts +3 -2
  20. package/components/dialog/styles.ts +10 -6
  21. package/components/drawer/styles.ts +4 -2
  22. package/components/dropdown/styles.ts +7 -4
  23. package/components/editable/styles.ts +4 -2
  24. package/components/form/index.md +1 -0
  25. package/components/form/index.spec.ts +17 -0
  26. package/components/form/item.ts +2 -0
  27. package/components/form/styles.ts +7 -4
  28. package/components/form/useDirty.ts +4 -0
  29. package/components/grid/styles.ts +12 -9
  30. package/components/icon/index.vdt +1 -1
  31. package/components/icon/styles.ts +4 -2
  32. package/components/input/styles.ts +8 -5
  33. package/components/layout/styles.ts +13 -9
  34. package/components/menu/demos/recursive.md +340 -0
  35. package/components/menu/styles.ts +21 -16
  36. package/components/message/styles.ts +7 -5
  37. package/components/pagination/styles.ts +4 -2
  38. package/components/popover/content.vdt +1 -1
  39. package/components/popover/demos/basic.md +1 -0
  40. package/components/popover/styles.ts +12 -2
  41. package/components/progress/styles.ts +4 -4
  42. package/components/radio/styles.ts +4 -2
  43. package/components/rate/styles.ts +4 -2
  44. package/components/scrollSelect/styles.ts +4 -2
  45. package/components/select/base.ts +3 -2
  46. package/components/select/base.vdt +1 -1
  47. package/components/select/styles.ts +10 -6
  48. package/components/skeleton/styles.ts +7 -4
  49. package/components/slider/styles.ts +4 -2
  50. package/components/spin/styles.ts +4 -4
  51. package/components/spinner/styles.ts +4 -3
  52. package/components/split/styles.ts +4 -2
  53. package/components/steps/index.vdt +2 -2
  54. package/components/steps/styles.ts +7 -5
  55. package/components/switch/styles.ts +4 -2
  56. package/components/table/column.ts +2 -0
  57. package/components/table/column.vdt +7 -3
  58. package/components/table/demos/basic.md +2 -2
  59. package/components/table/demos/fixColumn.md +3 -1
  60. package/components/table/demos/groupHeader.md +11 -11
  61. package/components/table/demos/scheme.md +1 -1
  62. package/components/table/index.spec.ts +8 -3
  63. package/components/table/styles.ts +11 -8
  64. package/components/table/table.vdt +3 -4
  65. package/components/table/useColumns.ts +1 -0
  66. package/components/table/useFixedColumns.ts +27 -49
  67. package/components/table/useGroup.ts +5 -0
  68. package/components/table/useResizable.ts +38 -10
  69. package/components/table/useWidth.ts +3 -0
  70. package/components/tabs/styles.ts +4 -2
  71. package/components/tag/styles.ts +7 -4
  72. package/components/timeline/styles.ts +7 -5
  73. package/components/timepicker/styles.ts +4 -2
  74. package/components/tip/styles.ts +4 -2
  75. package/components/tooltip/content.vdt +1 -1
  76. package/components/tooltip/styles.ts +4 -2
  77. package/components/transfer/styles.ts +4 -2
  78. package/components/tree/demos/checkbox.md +1 -0
  79. package/components/tree/demos/contextmenu.md +10 -1
  80. package/components/tree/index.spec.ts +7 -0
  81. package/components/tree/styles.ts +4 -2
  82. package/components/tree/useChecked.ts +3 -0
  83. package/components/treeSelect/styles.ts +4 -2
  84. package/components/upload/styles.ts +7 -4
  85. package/components/utils.ts +10 -4
  86. package/components/wave/styles.ts +4 -2
  87. package/es/components/affix/styles.d.ts +4 -1
  88. package/es/components/affix/styles.js +4 -2
  89. package/es/components/badge/index.vdt.js +1 -1
  90. package/es/components/badge/styles.d.ts +4 -1
  91. package/es/components/badge/styles.js +4 -2
  92. package/es/components/breadcrumb/index.vdt.js +1 -1
  93. package/es/components/breadcrumb/styles.d.ts +4 -1
  94. package/es/components/breadcrumb/styles.js +4 -2
  95. package/es/components/button/styles.d.ts +8 -2
  96. package/es/components/button/styles.js +7 -4
  97. package/es/components/card/styles.d.ts +4 -1
  98. package/es/components/card/styles.js +4 -2
  99. package/es/components/carousel/styles.d.ts +8 -2
  100. package/es/components/carousel/styles.js +7 -4
  101. package/es/components/cascader/index.vdt.js +3 -1
  102. package/es/components/cascader/styles.d.ts +8 -2
  103. package/es/components/cascader/styles.js +7 -4
  104. package/es/components/checkbox/index.vdt.js +1 -1
  105. package/es/components/checkbox/styles.d.ts +4 -1
  106. package/es/components/checkbox/styles.js +4 -2
  107. package/es/components/code/styles.d.ts +4 -1
  108. package/es/components/code/styles.js +3 -2
  109. package/es/components/collapse/index.spec.js +1 -1
  110. package/es/components/collapse/styles.d.ts +8 -2
  111. package/es/components/collapse/styles.js +7 -4
  112. package/es/components/colorpicker/styles.d.ts +8 -2
  113. package/es/components/colorpicker/styles.js +7 -4
  114. package/es/components/copy/styles.d.ts +4 -1
  115. package/es/components/copy/styles.js +3 -2
  116. package/es/components/datepicker/styles.d.ts +12 -3
  117. package/es/components/datepicker/styles.js +10 -6
  118. package/es/components/diagram/styles.d.ts +4 -1
  119. package/es/components/diagram/styles.js +3 -2
  120. package/es/components/dialog/styles.d.ts +12 -3
  121. package/es/components/dialog/styles.js +10 -6
  122. package/es/components/drawer/styles.d.ts +4 -1
  123. package/es/components/drawer/styles.js +4 -2
  124. package/es/components/dropdown/styles.d.ts +8 -2
  125. package/es/components/dropdown/styles.js +7 -4
  126. package/es/components/editable/styles.d.ts +4 -1
  127. package/es/components/editable/styles.js +4 -2
  128. package/es/components/form/index.spec.js +43 -0
  129. package/es/components/form/item.d.ts +1 -0
  130. package/es/components/form/item.js +2 -1
  131. package/es/components/form/styles.d.ts +8 -2
  132. package/es/components/form/styles.js +7 -4
  133. package/es/components/form/useDirty.js +4 -0
  134. package/es/components/grid/styles.d.ts +8 -2
  135. package/es/components/grid/styles.js +12 -13
  136. package/es/components/icon/index.vdt.js +1 -1
  137. package/es/components/icon/styles.d.ts +4 -1
  138. package/es/components/icon/styles.js +4 -2
  139. package/es/components/input/styles.d.ts +8 -2
  140. package/es/components/input/styles.js +7 -4
  141. package/es/components/layout/styles.d.ts +16 -4
  142. package/es/components/layout/styles.js +13 -8
  143. package/es/components/menu/styles.d.ts +16 -4
  144. package/es/components/menu/styles.js +14 -9
  145. package/es/components/message/styles.d.ts +8 -2
  146. package/es/components/message/styles.js +7 -4
  147. package/es/components/pagination/styles.d.ts +4 -1
  148. package/es/components/pagination/styles.js +4 -2
  149. package/es/components/popover/content.vdt.js +1 -1
  150. package/es/components/popover/styles.d.ts +4 -1
  151. package/es/components/popover/styles.js +8 -3
  152. package/es/components/progress/styles.d.ts +4 -1
  153. package/es/components/progress/styles.js +4 -2
  154. package/es/components/radio/styles.d.ts +4 -1
  155. package/es/components/radio/styles.js +4 -2
  156. package/es/components/rate/styles.d.ts +4 -1
  157. package/es/components/rate/styles.js +4 -2
  158. package/es/components/scrollSelect/styles.d.ts +4 -1
  159. package/es/components/scrollSelect/styles.js +4 -2
  160. package/es/components/select/base.js +3 -1
  161. package/es/components/select/base.vdt.js +1 -1
  162. package/es/components/select/styles.d.ts +12 -3
  163. package/es/components/select/styles.js +10 -6
  164. package/es/components/skeleton/styles.d.ts +8 -2
  165. package/es/components/skeleton/styles.js +7 -4
  166. package/es/components/slider/styles.d.ts +4 -1
  167. package/es/components/slider/styles.js +4 -2
  168. package/es/components/spin/styles.d.ts +4 -1
  169. package/es/components/spin/styles.js +4 -2
  170. package/es/components/spinner/styles.d.ts +4 -1
  171. package/es/components/spinner/styles.js +4 -2
  172. package/es/components/split/styles.d.ts +4 -1
  173. package/es/components/split/styles.js +4 -2
  174. package/es/components/steps/index.vdt.js +2 -2
  175. package/es/components/steps/styles.d.ts +4 -3
  176. package/es/components/steps/styles.js +9 -4
  177. package/es/components/switch/styles.d.ts +4 -1
  178. package/es/components/switch/styles.js +4 -2
  179. package/es/components/table/column.d.ts +1 -0
  180. package/es/components/table/column.js +2 -1
  181. package/es/components/table/column.vdt.js +9 -3
  182. package/es/components/table/index.spec.js +18 -11
  183. package/es/components/table/styles.d.ts +8 -2
  184. package/es/components/table/styles.js +8 -5
  185. package/es/components/table/table.vdt.js +3 -4
  186. package/es/components/table/useColumns.js +1 -0
  187. package/es/components/table/useFixedColumns.d.ts +3 -3
  188. package/es/components/table/useFixedColumns.js +27 -46
  189. package/es/components/table/useGroup.d.ts +1 -0
  190. package/es/components/table/useGroup.js +11 -1
  191. package/es/components/table/useResizable.js +41 -5
  192. package/es/components/table/useWidth.js +3 -0
  193. package/es/components/tabs/styles.d.ts +4 -1
  194. package/es/components/tabs/styles.js +4 -2
  195. package/es/components/tag/styles.d.ts +8 -2
  196. package/es/components/tag/styles.js +7 -4
  197. package/es/components/timeline/styles.d.ts +8 -2
  198. package/es/components/timeline/styles.js +7 -5
  199. package/es/components/timepicker/styles.d.ts +4 -1
  200. package/es/components/timepicker/styles.js +4 -2
  201. package/es/components/tip/styles.d.ts +4 -1
  202. package/es/components/tip/styles.js +4 -2
  203. package/es/components/tooltip/content.vdt.js +1 -1
  204. package/es/components/tooltip/styles.d.ts +4 -1
  205. package/es/components/tooltip/styles.js +4 -2
  206. package/es/components/transfer/styles.d.ts +4 -1
  207. package/es/components/transfer/styles.js +4 -2
  208. package/es/components/tree/index.spec.js +13 -1
  209. package/es/components/tree/styles.d.ts +4 -1
  210. package/es/components/tree/styles.js +4 -2
  211. package/es/components/tree/useChecked.js +4 -0
  212. package/es/components/treeSelect/styles.d.ts +4 -1
  213. package/es/components/treeSelect/styles.js +4 -2
  214. package/es/components/upload/styles.d.ts +8 -2
  215. package/es/components/upload/styles.js +7 -4
  216. package/es/components/utils.d.ts +10 -2
  217. package/es/components/utils.js +9 -2
  218. package/es/components/wave/styles.d.ts +4 -1
  219. package/es/components/wave/styles.js +4 -2
  220. package/es/i18n/en-US.d.ts +1 -0
  221. package/es/i18n/en-US.js +1 -0
  222. package/es/index.d.ts +2 -2
  223. package/es/index.js +2 -2
  224. package/es/site/data/components/menu/demos/recursive/index.d.ts +29 -0
  225. package/es/site/data/components/menu/demos/recursive/index.js +57 -0
  226. package/es/site/data/components/menu/demos/recursive/react.d.ts +2 -0
  227. package/es/site/data/components/menu/demos/recursive/react.js +69 -0
  228. package/es/site/data/components/popover/demos/basic/react.js +2 -1
  229. package/es/site/data/components/table/demos/basic/react.js +4 -2
  230. package/es/site/data/components/table/demos/fixColumn/react.js +2 -1
  231. package/es/site/data/components/table/demos/groupHeader/react.js +11 -20
  232. package/es/site/data/components/table/demos/scheme/react.js +2 -1
  233. package/es/site/data/components/tree/demos/checkbox/index.d.ts +12 -2
  234. package/es/site/data/components/tree/demos/checkbox/index.js +1 -0
  235. package/es/site/data/components/tree/demos/checkbox/react.d.ts +12 -2
  236. package/es/site/data/components/tree/demos/checkbox/react.js +1 -0
  237. package/es/site/data/components/tree/demos/contextmenu/index.d.ts +1 -0
  238. package/es/site/data/components/tree/demos/contextmenu/index.js +1 -0
  239. package/es/site/data/components/tree/demos/contextmenu/react.d.ts +1 -0
  240. package/es/site/data/components/tree/demos/contextmenu/react.js +1 -0
  241. package/es/site/src/components/article/index.js +6 -2
  242. package/es/styles/fonts/iconfont.d.ts +4 -1
  243. package/es/styles/fonts/iconfont.js +1 -1
  244. package/es/styles/global.js +1 -1
  245. package/i18n/en-US.ts +1 -0
  246. package/index.ts +2 -2
  247. package/package.json +3 -3
  248. package/styles/fonts/iconfont.ts +2 -2
  249. package/styles/global.ts +22 -0
@@ -10,22 +10,22 @@ order: 12
10
10
  ```vdt
11
11
  import {Table, TableColumn} from 'kpc';
12
12
 
13
- <Table data={this.get('data')} type="grid" resizable stickHeader="64">
14
- <TableColumn title="Weekday" key='weekday' fixed="left" width="100" />
13
+ <Table data={this.get('data')} type="grid" resizable stickHeader="64" minColWidth={100}>
14
+ <TableColumn title="Weekday" key='weekday' fixed="left" />
15
15
  <TableColumn title="Forenoon" key="forenoon">
16
- <TableColumn title="Time" key="forenoonTime" fixed="left" width="100" />
16
+ <TableColumn title="Time" key="forenoonTime" fixed="left" />
17
17
  <TableColumn title="Classes" key="classes">
18
- <TableColumn title="Class 1" key='class1' width="100" />
19
- <TableColumn title="Class 2" key='class2' width="100" />
20
- <TableColumn title="Class 3" key='class3' width="100" />
21
- <TableColumn title="Class 4" key='class4' width="100" />
18
+ <TableColumn title="Class 1" key='class1' />
19
+ <TableColumn title="Class 2" key='class2' />
20
+ <TableColumn title="Class 3" key='class3' />
21
+ <TableColumn title="Class 4" key='class4' />
22
22
  </TableColumn>
23
23
  </TableColumn>
24
24
  <TableColumn title="Afternoon" key="afternoon">
25
- <TableColumn title="Time" key="afternoonTime" width="100" />
26
- <TableColumn title="Class 5" key='class5' width="100" />
27
- <TableColumn title="Class 6" key='class6' width="100" fixed="right" />
28
- <TableColumn title="Class 7" key='class7' fixed="right" width="100" />
25
+ <TableColumn title="Time" key="afternoonTime" />
26
+ <TableColumn title="Class 5" key='class5' />
27
+ <TableColumn title="Class 6" key='class6' fixed="right" />
28
+ <TableColumn title="Class 7" key='class7' fixed="right" />
29
29
  </TableColumn>
30
30
  </Table>
31
31
  ```
@@ -11,7 +11,7 @@ order: 1
11
11
  ```vdt
12
12
  import {Table, TableColumn} from 'kpc';
13
13
 
14
- <Table data={this.get('data')}>
14
+ <Table data={this.get('data')} resizable>
15
15
  <TableColumn title='定义该列单元格内容' key='a'>
16
16
  <b:template args="[data, index]">
17
17
  <a>{data.a}</a>
@@ -238,7 +238,7 @@ describe('Table', () => {
238
238
  expect(instance.get('multipleGroup')).to.eql({status: []});
239
239
 
240
240
  // click confirm
241
- const [reset, confirm] = dropdown2.querySelectorAll<HTMLElement>('.k-table-group-footer .k-btn');
241
+ const [checkAll, reset, confirm] = dropdown2.querySelectorAll<HTMLElement>('.k-table-group-footer .k-btn');
242
242
  confirm.click();
243
243
  await wait();
244
244
  expect(instance.get('multipleGroup')).to.eql({status: ['active', 'stopped']});
@@ -251,10 +251,15 @@ describe('Table', () => {
251
251
  reset.click();
252
252
  await wait();
253
253
  expect(dropdown2.innerHTML).to.matchSnapshot();
254
- confirm.click();
255
- await wait();
256
254
  expect(instance.get('multipleGroup')).to.eql({status: []});
257
255
 
256
+ // click checkAll
257
+ dispatchEvent(icon2, 'click');
258
+ await wait();
259
+ checkAll.click();
260
+ await wait();
261
+ expect(dropdown2.querySelectorAll('.k-checkbox.k-checked')).to.length(2);
262
+
258
263
  // update group
259
264
  instance.set('statusGroup', [{label: 'label', value: 'value'}]);
260
265
  dispatchEvent(icon, 'click');
@@ -2,6 +2,7 @@ import {css} from '@emotion/css';
2
2
  import {theme, setDefault} from '../../styles/theme';
3
3
  import {deepDefaults, palette} from '../../styles/utils';
4
4
  import '../../styles/global';
5
+ import { cache } from '../utils';
5
6
 
6
7
  const defaults = {
7
8
  get transition() { return theme.transition.large },
@@ -72,9 +73,11 @@ const aligns = ['left', 'right', 'center'];
72
73
  let table: typeof defaults;
73
74
  setDefault(() => {
74
75
  table = deepDefaults(theme, {table: defaults}).table;
76
+ makeStyles?.clearCache();
77
+ makeGroupMenuStyles?.clearCache();
75
78
  });
76
79
 
77
- export function makeStyles(k: string) {
80
+ export const makeStyles = cache(function makeStyles(k: string) {
78
81
  return css`
79
82
  font-size: ${table.fontSize};
80
83
  color: ${table.color};
@@ -90,10 +93,10 @@ export function makeStyles(k: string) {
90
93
  // border-collapse: collapse;
91
94
  border-spacing: 0;
92
95
  table-layout: fixed;
93
- td,
94
- th {
95
- transition: all ${table.transition};
96
- }
96
+ // td,
97
+ // th {
98
+ // transition: all ${table.transition};
99
+ // }
97
100
  }
98
101
 
99
102
  // thead
@@ -369,9 +372,9 @@ export function makeStyles(k: string) {
369
372
  }
370
373
  }
371
374
  `;
372
- }
375
+ });
373
376
 
374
- export function makeGroupMenuStyles(k: string) {
377
+ export const makeGroupMenuStyles = cache(function makeGroupMenuStyles(k: string) {
375
378
  return css`
376
379
  min-width: ${table.group.menuMinWidth} !important;
377
380
  .${k}-dropdown-item.${k}-active {
@@ -394,4 +397,4 @@ export function makeGroupMenuStyles(k: string) {
394
397
  }
395
398
  }
396
399
  `
397
- }
400
+ });
@@ -29,7 +29,7 @@ const {
29
29
  } = this.get();
30
30
  const animation = !Array.isArray(_animation) ? [_animation, _animation] : _animation;
31
31
  const {columns, cols, maxRows, maxCols} = this.columns.getData();
32
- const {scrollPosition, hasFixed, getHasFixedLeft, getOffsetMap} = this.fixedColumns;
32
+ const {scrollPosition, hasFixed, getHasFixedLeft, offsetMap} = this.fixedColumns;
33
33
  const {scrollRef} = this.scroll;
34
34
  const {stickHeader, excludeStickHeader, elementRef, headRef} = this.stickyHeader;
35
35
  const { k } = this.config;
@@ -66,13 +66,12 @@ const hasData = data && data.length;
66
66
  const hasFixedLeft = getHasFixedLeft();
67
67
  const {getAllCheckedStatus, toggleCheckedAll, getAllStatus, onChangeChecked} = this.checked;
68
68
  const allCheckedStatus = getAllCheckedStatus();
69
- const offsetMap = getOffsetMap();
70
69
  const thead = hideHeader ? null : (
71
70
  <TableContext.Provider value={checkType}>
72
71
  <GroupContext.Provider value={{group, onChange: this.onChangeGroup}}>
73
72
  <SortableContext.Provider value={{sort, onChange: this.sortable.onChange}}>
74
73
  <ResizableContext.Provider value={{resizable, onStart}}>
75
- <FixedColumnsContext.Provider value={offsetMap}>
74
+ <FixedColumnsContext.Provider value={offsetMap.value}>
76
75
  <thead>
77
76
  <tr v-for={columns}>
78
77
  {(() => {
@@ -158,7 +157,7 @@ const tbody = (
158
157
  indent={indentSize}
159
158
  onToggleSpreadRow={toggleSpreadRow}
160
159
  onBeforeUnmount={this.resetRowStatus.onRowBeforeUnmount}
161
- offsetMap={offsetMap}
160
+ offsetMap={offsetMap.value}
162
161
  animation={animation[1]}
163
162
 
164
163
  draggable={draggable}
@@ -51,6 +51,7 @@ export function useColumns() {
51
51
  ret = true;
52
52
 
53
53
  const clonedVNode = directClone(vNode) as VNodeComponentClass<TableColumn>;
54
+ if (currentVNode) (currentVNode.props as any).nextVNode = clonedVNode;
54
55
  const props = {
55
56
  ...clonedVNode.props!,
56
57
  cols: 0,
@@ -2,21 +2,19 @@ import {
2
2
  useInstance,
3
3
  VNodeComponentClass,
4
4
  Props,
5
- directClone,
6
- onMounted,
7
- onUnmounted,
8
- RefObject,
9
5
  Key,
6
+ findDomFromVNode,
7
+ nextTick,
10
8
  } from 'intact';
11
9
  import {TableColumn, TableColumnProps} from './column';
12
10
  import {useState} from '../../hooks/useState';
13
11
  import {cx} from '@emotion/css';
14
- import type {TableProps, TableRowKey} from './table';
15
- import {isNullOrUndefined, isString, error} from 'intact-shared';
16
- import {throttle} from '../utils';
12
+ import type {TableProps, TableRowKey, Table} from './table';
17
13
  import {State, watchState} from '../../hooks/useState';
18
14
  import {createContext} from '../context';
19
15
  import type {useScroll} from './useScroll';
16
+ import { useResizeObserver } from '../../hooks/useResizeObserver';
17
+ import { isEqualObject } from '../utils';
20
18
 
21
19
  type ScrollPosition = 'left' | 'middle' | 'right';
22
20
  type FixedInfo = {
@@ -31,48 +29,35 @@ export function useFixedColumns(
31
29
  {scrollRef, callbacks}: ReturnType<typeof useScroll>,
32
30
  widthMap: State<Record<TableRowKey, number>>,
33
31
  ) {
34
- const instance = useInstance()!;
32
+ const instance = useInstance() as Table;
35
33
  const scrollPosition = useState<ScrollPosition | null>(null);
36
34
  const hasFixed = useState<boolean>(false);
35
+ const offsetMap = useState<Record<Key, number>>({}, isEqualObject);
37
36
  let hasFixedLeft = false;
38
37
  let hasFixedRight = false;
39
- let offsetMap: Record<Key, number> = {};
40
38
 
41
39
  callbacks.push(setScrollPosition);
42
40
 
43
- instance.on('$receive:children', handleFixedColumns);
44
- watchState(widthMap, () => {
45
- handleFixedColumns();
46
- updateScrollPositionOnResize();
47
- });
48
-
49
- const throttleUpdate = throttle(() => {
50
- if (instance.$unmounted) return;
51
- updateScrollPositionOnResize();
52
- }, 100);
41
+ instance.watch('children', handleFixedColumnsAndUpdate, { presented: true });
42
+ watchState(widthMap, () => nextTick(handleFixedColumnsAndUpdate));
43
+ useResizeObserver(scrollRef, handleFixedColumnsAndUpdate, true);
53
44
 
54
- onMounted(() => {
45
+ function handleFixedColumnsAndUpdate() {
46
+ handleFixedColumns();
55
47
  updateScrollPositionOnResize();
56
- window.addEventListener('resize', throttleUpdate);
57
- });
58
-
59
- onUnmounted(() => {
60
- window.removeEventListener('resize', throttleUpdate);
61
- });
48
+ }
62
49
 
63
50
  function handleFixedColumns() {
64
51
  const columns = getColumns();
65
52
 
53
+ let _offsetMap: Record<Key, number> = {};
66
54
  hasFixedLeft = false;
67
55
  hasFixedRight = false;
68
- offsetMap = {};
69
56
 
70
57
  columns.forEach((columns, row) => {
71
- let offset = 0;
72
58
  columns.forEach((vNode, col) => {
73
59
  const props = vNode.props as Props<TableColumnProps>;
74
60
  const key = props.key;
75
- offsetMap[key] = 0;
76
61
 
77
62
  const fixed = props.fixed;
78
63
  if (fixed === 'left') {
@@ -81,34 +66,29 @@ export function useFixedColumns(
81
66
  while (prevVNode) {
82
67
  const props = prevVNode.props!;
83
68
  if (props.fixed === 'left') {
84
- if (process.env.NODE_ENV !== 'production') {
85
- validateWidth(props);
86
- }
87
- value += widthMap.value[props.key] || parseInt(props.width as string, 10) || 0;
69
+ value += getWidth(prevVNode);
88
70
  }
89
71
  prevVNode = props.prevVNode;
90
72
  }
91
- offsetMap[key] = value;
73
+ _offsetMap[key] = value;
92
74
  hasFixedLeft = true;
93
75
  } else if (fixed === 'right') {
94
76
  let value = 0;
95
- let lastVNode = columns[columns.length - 1];
96
- while (vNode !== lastVNode) {
97
- const props = lastVNode.props!;
77
+ let nextVNode = props.nextVNode;
78
+ while (nextVNode) {
79
+ const props = nextVNode.props!;
98
80
  if (props.fixed === 'right') {
99
- if (process.env.NODE_ENV !== 'production') {
100
- validateWidth(props);
101
- }
102
- value += widthMap.value[props.key] || parseInt(props.width as string, 10) || 0;
81
+ value += getWidth(nextVNode);
103
82
  }
104
- lastVNode = props.prevVNode!;
83
+ nextVNode = props.nextVNode;
105
84
  }
106
- offsetMap[key] = value;
85
+ _offsetMap[key] = value;
107
86
  hasFixedRight = true;
108
87
  }
109
88
  });
110
89
  });
111
90
 
91
+ offsetMap.set(_offsetMap);
112
92
  hasFixed.set(hasFixedLeft || hasFixedRight);
113
93
  }
114
94
 
@@ -138,8 +118,8 @@ export function useFixedColumns(
138
118
  scrollPosition,
139
119
  setScrollPosition,
140
120
  hasFixed,
121
+ offsetMap,
141
122
  getHasFixedLeft: () => hasFixedLeft,
142
- getOffsetMap: () => offsetMap,
143
123
  };
144
124
  }
145
125
 
@@ -160,9 +140,7 @@ export function getClassAndStyleForFixed(
160
140
  };
161
141
  }
162
142
 
163
-
164
- function validateWidth({width, key}: TableColumnProps) {
165
- if (isNullOrUndefined(width) || isString(width) && !/\d+(px)?/.test(width)) {
166
- error(`The width must be specified with 'px' when the column has fixed. <TableColumn key="${key}" />`);
167
- }
143
+ function getWidth(vNode: VNodeComponentClass) {
144
+ const dom = findDomFromVNode(vNode, true) as HTMLElement;
145
+ return dom.offsetWidth;
168
146
  }
@@ -59,6 +59,10 @@ export function useGroup() {
59
59
  confirm(onChange);
60
60
  }
61
61
 
62
+ function checkAll() {
63
+ localGroupValue.set(filteredGroup.value?.map((item) => item.value));
64
+ }
65
+
62
66
  function isEmptyValue(groupValue: any) {
63
67
  const {multiple} = instance.get();
64
68
  return !groupValue || multiple && (!isArray(groupValue) || groupValue.every(value => !value));
@@ -88,5 +92,6 @@ export function useGroup() {
88
92
  dropdownRef,
89
93
  localGroupValue,
90
94
  isEmptyValue,
95
+ checkAll,
91
96
  };
92
97
  }
@@ -22,16 +22,18 @@ export function useResizable(
22
22
  let x: number;
23
23
  let prevVNode: ColumnVNode;
24
24
  let prevTh: HTMLElement;
25
+ let prevMinWidth: number;
25
26
  let currentVNode: ColumnVNode;
26
27
  let currentTh: HTMLElement;
27
- let minWidth: number;
28
+ let currentMinWidth: number;
29
+ let nextVNode: ColumnVNode | null | undefined;
28
30
 
29
31
  function onStart(e: MouseEvent) {
30
32
  containerWidth = scrollRef.value!.clientWidth;
31
33
  x = e.clientX;
32
34
 
33
35
  // find the previous column but exclude the hidden columns, #467
34
- prevVNode = currentVNode = (e as MouseEvent & {_vNode: ColumnVNode})._vNode;
36
+ prevVNode = nextVNode = currentVNode = (e as MouseEvent & {_vNode: ColumnVNode})._vNode;
35
37
  prevTh;
36
38
  do {
37
39
  prevVNode = prevVNode.props!.prevVNode!;
@@ -39,27 +41,53 @@ export function useResizable(
39
41
  } while(window.getComputedStyle(prevTh).display === 'none');
40
42
 
41
43
  currentTh = findDomFromVNode(currentVNode, true) as HTMLElement;
42
- minWidth = prevVNode.props!.minWidth || instance.get('minColWidth')!;
44
+ prevMinWidth= prevVNode.props!.minWidth || instance.get('minColWidth')!;
45
+ currentMinWidth = currentVNode.props!.minWidth || instance.get('minColWidth')!;
46
+
47
+ while (nextVNode = nextVNode?.props!.nextVNode) {
48
+ const th = findDomFromVNode(nextVNode, true) as HTMLElement;
49
+ if (window.getComputedStyle(th).display === 'none') {
50
+ continue;
51
+ }
52
+ break;
53
+ }
43
54
  }
44
55
 
45
56
  function onMove(e: MouseEvent) {
46
57
  const delX = e.clientX - x;
47
58
  if (delX === 0) return;
48
59
 
49
- const newPrevWidth = prevTh.offsetWidth + delX;
50
- if (newPrevWidth < minWidth && delX < 0) return;
60
+ let newPrevWidth = prevTh.offsetWidth + delX;
61
+ let newCurrentWidth = currentTh.offsetWidth - delX;
62
+ let newTableWidth = tableRef.value!.offsetWidth + delX;
63
+ const isCurrentFixedRight = currentVNode.props!.fixed === 'right';
64
+ // const isPrevFixedRight = prevVNode.props!.fixed === 'right';
65
+
66
+ if ((newPrevWidth < prevMinWidth || isCurrentFixedRight) && delX < 0) {
67
+ // if (nextVNode) return;
68
+ // the last column, we should expand its width
69
+ if (newPrevWidth < prevMinWidth) {
70
+ newPrevWidth -= delX;
71
+ newTableWidth -= delX;
72
+ }
73
+ }
51
74
 
52
- const newCurrentWidth = currentTh.offsetWidth - delX;
53
- const newTableWidth = tableRef.value!.offsetWidth + delX;
54
75
  const currentKey = currentVNode.props!.key;
55
76
  const prevKey = prevVNode.props!.key;
56
-
57
- x = e.clientX;
58
-
59
77
  const map = {
60
78
  [prevKey]: newPrevWidth
61
79
  }
62
80
 
81
+ if (!nextVNode || isCurrentFixedRight) {
82
+ newTableWidth -= delX;
83
+ if (newCurrentWidth < currentMinWidth && delX > 0) {
84
+ newCurrentWidth = currentMinWidth;
85
+ }
86
+ map[currentKey] = newCurrentWidth;
87
+ }
88
+
89
+ x = e.clientX;
90
+
63
91
  if (containerWidth > newTableWidth) {
64
92
  map[currentKey] = newCurrentWidth;
65
93
  } else {
@@ -90,6 +90,9 @@ export function useWidth(
90
90
  });
91
91
  });
92
92
  if (shouldUpdate) {
93
+ // let useFixedColumns to update scroll position
94
+ widthMap.set({ ...widthMap.value });
95
+
93
96
  instance.forceUpdate(() => {
94
97
  // check again because it may affect other columns
95
98
  if (!isStop) {
@@ -2,6 +2,7 @@ import {css} from '@emotion/css';
2
2
  import {theme, setDefault} from '../../styles/theme';
3
3
  import {deepDefaults, sizes, Sizes} from '../../styles/utils';
4
4
  import '../../styles/global';
5
+ import { cache } from '../utils';
5
6
 
6
7
  type SizeStyles = {
7
8
  fontSize: string;
@@ -81,9 +82,10 @@ const defaults = deepDefaults(
81
82
  let tabs: typeof defaults;
82
83
  setDefault(() => {
83
84
  tabs = deepDefaults(theme, {tabs: defaults}).tabs;
85
+ makeStyles?.clearCache();
84
86
  });
85
87
 
86
- export function makeStyles(k: string) {
88
+ export const makeStyles = cache(function makeStyles(k: string) {
87
89
  return css`
88
90
  ${makeCommonStyles(k)};
89
91
  ${makeScrollStyles(k)};
@@ -100,7 +102,7 @@ export function makeStyles(k: string) {
100
102
  ${makeFlatCardStyles(k)};
101
103
  }
102
104
  `;
103
- }
105
+ });
104
106
 
105
107
  function makeCommonStyles(k: string) {
106
108
  const active = tabs.active;
@@ -2,6 +2,7 @@ import {css} from '@emotion/css';
2
2
  import {deepDefaults, sizes, palette} from '../../styles/utils';
3
3
  import {theme, setDefault} from '../../styles/theme';
4
4
  import '../../styles/global';
5
+ import { cache } from '../utils';
5
6
 
6
7
  type ValueOf<T extends readonly any[]> = T[number]
7
8
  type Types = ValueOf<typeof types>
@@ -83,11 +84,13 @@ const defaults = deepDefaults(
83
84
  let tag: typeof defaults;
84
85
  setDefault(() => {
85
86
  tag = deepDefaults(theme, {tag: defaults}).tag;
87
+ makeStyles?.clearCache();
88
+ makeTagsStyles?.clearCache();
86
89
  });
87
90
 
88
91
  export { tag };
89
92
 
90
- export function makeStyles(k: string) {
93
+ export const makeStyles = cache(function makeStyles(k: string) {
91
94
  return css`
92
95
  display: inline-flex;
93
96
  align-items: center;
@@ -144,9 +147,9 @@ export function makeStyles(k: string) {
144
147
  opacity: 0;
145
148
  }
146
149
  `;
147
- }
150
+ });
148
151
 
149
- export function makeTagsStyles(k: string) {
152
+ export const makeTagsStyles = cache(function makeTagsStyles(k: string) {
150
153
  return css`
151
154
  display: flex;
152
155
  flex-wrap: wrap;
@@ -172,4 +175,4 @@ export function makeTagsStyles(k: string) {
172
175
  cursor: move;
173
176
  }
174
177
  `;
175
- }
178
+ });
@@ -2,6 +2,7 @@ import {css} from '@emotion/css';
2
2
  import {theme, setDefault} from '../../styles/theme';
3
3
  import {deepDefaults, Sizes, sizes, palette} from '../../styles/utils';
4
4
  import '../../styles/global';
5
+ import { cache } from '../utils';
5
6
 
6
7
  type ValueOf<T extends readonly any[]> = T[number]
7
8
 
@@ -58,16 +59,18 @@ const defaults = deepDefaults(
58
59
  let timeline: typeof defaults;
59
60
  setDefault(() => {
60
61
  timeline = deepDefaults(theme, {timeline: defaults}).timeline;
62
+ makeStyles?.clearCache();
63
+ makeItemStyles?.clearCache();
61
64
  });
62
65
 
63
- export function makeStyles(k: string) {
66
+ export const makeStyles = cache(function makeStyles(k: string) {
64
67
  return css`
65
68
  font-size: ${timeline.fontSize};
66
69
  padding-top: calc(${theme.lineHeight}em / 2);
67
70
  `;
68
- }
71
+ });
69
72
 
70
- export function makeItemStyles(k: string) {
73
+ export const makeItemStyles = cache(function makeItemStyles(k: string) {
71
74
  return css`
72
75
  position: relative;
73
76
  padding: ${timeline.padding};
@@ -148,5 +151,4 @@ export function makeItemStyles(k: string) {
148
151
  `
149
152
  })}
150
153
  `;
151
- };
152
-
154
+ });
@@ -3,6 +3,7 @@ import {theme, setDefault} from '../../styles/theme';
3
3
  import {deepDefaults, sizes, Sizes, getRight, getLeft, palette} from '../../styles/utils';
4
4
  import '../../styles/global';
5
5
  import {datepicker, makePanelStyles as makePanelStylesBase} from '../datepicker/styles';
6
+ import { cache } from '../utils';
6
7
 
7
8
  const defaults = {
8
9
  get border() { return datepicker.border; },
@@ -21,9 +22,10 @@ const defaults = {
21
22
  let timepicker: typeof defaults;
22
23
  setDefault(() => {
23
24
  timepicker = deepDefaults(theme, {timepicker: defaults}).timepicker;
25
+ makePanelStyles?.clearCache();
24
26
  });
25
27
 
26
- export function makePanelStyles(k: string) {
28
+ export const makePanelStyles = cache(function makePanelStyles(k: string) {
27
29
  return cx(
28
30
  makePanelStylesBase(k),
29
31
  css`
@@ -55,4 +57,4 @@ export function makePanelStyles(k: string) {
55
57
  }
56
58
  `,
57
59
  );
58
- }
60
+ });
@@ -2,6 +2,7 @@ import {theme, setDefault} from '../../styles/theme';
2
2
  import {css} from '@emotion/css';
3
3
  import '../../styles/global';
4
4
  import {deepDefaults} from '../../styles/utils';
5
+ import { cache } from '../utils';
5
6
 
6
7
  const defaults = {
7
8
  title: {
@@ -16,9 +17,10 @@ const defaults = {
16
17
  let tip: typeof defaults;
17
18
  setDefault(() => {
18
19
  tip = deepDefaults(theme, {tip: defaults}).tip;
20
+ makeStyles?.clearCache();
19
21
  });
20
22
 
21
- export function makeStyles(k: string) {
23
+ export const makeStyles = cache(function makeStyles(k: string) {
22
24
  return css`
23
25
  // Tip extends Tag, so we add.${k}-tip to increase the priority of class
24
26
  &.${k}-tip {
@@ -47,4 +49,4 @@ export function makeStyles(k: string) {
47
49
  background: none;
48
50
  }
49
51
  `;
50
- }
52
+ });
@@ -1,5 +1,5 @@
1
1
  import {Button} from '../button';
2
- import makeStyles from './styles';
2
+ import {makeStyles} from './styles';
3
3
 
4
4
  const {
5
5
  showArrow, confirm, className,
@@ -2,6 +2,7 @@ import {css} from '@emotion/css';
2
2
  import {theme, setDefault} from '../../styles/theme';
3
3
  import {deepDefaults} from '../../styles/utils';
4
4
  import '../../styles/global';
5
+ import { cache } from '../utils';
5
6
 
6
7
  const defaults = {
7
8
  padding: '8px 12px',
@@ -35,6 +36,7 @@ const defaults = {
35
36
  export let tooltip: typeof defaults;
36
37
  setDefault(() => {
37
38
  tooltip = deepDefaults(theme, {tooltip: defaults}).tooltip;
39
+ makeStyles?.clearCache();
38
40
  });
39
41
 
40
42
  export type Theme = 'dark' | 'light';
@@ -47,7 +49,7 @@ const directionMap = {
47
49
  right: 'left',
48
50
  };
49
51
 
50
- export default function makeStyles(k: string) {
52
+ export const makeStyles = cache(function makeStyles(k: string) {
51
53
  const arrowLong = tooltip.arrow.width;
52
54
  const arrowShort = `calc(${arrowLong} - 1px)`;
53
55
 
@@ -174,4 +176,4 @@ export default function makeStyles(k: string) {
174
176
  }
175
177
  }
176
178
  `
177
- }
179
+ });
@@ -2,6 +2,7 @@ import {css} from '@emotion/css';
2
2
  import {theme, setDefault} from '../../styles/theme';
3
3
  import {deepDefaults, palette} from '../../styles/utils';
4
4
  import '../../styles/global';
5
+ import { cache } from '../utils';
5
6
 
6
7
  const defaults = {
7
8
  fontSize: '12px',
@@ -41,9 +42,10 @@ const defaults = {
41
42
  let transfer: typeof defaults;
42
43
  setDefault(() => {
43
44
  transfer = deepDefaults(theme, {transfer: defaults}).transfer;
45
+ makeStyles?.clearCache();
44
46
  });
45
47
 
46
- export function makeStyles(k: string) {
48
+ export const makeStyles = cache(function makeStyles(k: string) {
47
49
  return css`
48
50
  font-size: ${transfer.fontSize};
49
51
  .${k}-transfer-panel,
@@ -117,4 +119,4 @@ export function makeStyles(k: string) {
117
119
  }
118
120
  }
119
121
  `;
120
- }
122
+ });
@@ -55,6 +55,7 @@ export default class extends Component {
55
55
  },
56
56
  {
57
57
  label: 'First floor-2',
58
+ key: 'floor-2',
58
59
  children: [
59
60
  {
60
61
  label: 'Second floor-2.1',