@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.
- package/components/affix/styles.ts +4 -2
- package/components/badge/index.vdt +1 -1
- package/components/badge/styles.ts +4 -3
- package/components/breadcrumb/index.vdt +1 -1
- package/components/breadcrumb/styles.ts +4 -2
- package/components/button/styles.ts +7 -5
- package/components/card/styles.ts +4 -2
- package/components/carousel/styles.ts +7 -4
- package/components/cascader/index.vdt +2 -1
- package/components/cascader/styles.ts +7 -4
- package/components/checkbox/index.vdt +1 -1
- package/components/checkbox/styles.ts +4 -2
- package/components/code/styles.ts +3 -2
- package/components/collapse/index.spec.ts +1 -1
- package/components/collapse/styles.ts +7 -4
- package/components/colorpicker/styles.ts +7 -4
- package/components/copy/styles.ts +3 -2
- package/components/datepicker/styles.ts +10 -6
- package/components/diagram/styles.ts +3 -2
- package/components/dialog/styles.ts +10 -6
- package/components/drawer/styles.ts +4 -2
- package/components/dropdown/styles.ts +7 -4
- package/components/editable/styles.ts +4 -2
- package/components/form/index.md +1 -0
- package/components/form/index.spec.ts +17 -0
- package/components/form/item.ts +2 -0
- package/components/form/styles.ts +7 -4
- package/components/form/useDirty.ts +4 -0
- package/components/grid/styles.ts +12 -9
- package/components/icon/index.vdt +1 -1
- package/components/icon/styles.ts +4 -2
- package/components/input/styles.ts +8 -5
- package/components/layout/styles.ts +13 -9
- package/components/menu/demos/recursive.md +340 -0
- package/components/menu/styles.ts +21 -16
- package/components/message/styles.ts +7 -5
- package/components/pagination/styles.ts +4 -2
- package/components/popover/content.vdt +1 -1
- package/components/popover/demos/basic.md +1 -0
- package/components/popover/styles.ts +12 -2
- package/components/progress/styles.ts +4 -4
- package/components/radio/styles.ts +4 -2
- package/components/rate/styles.ts +4 -2
- package/components/scrollSelect/styles.ts +4 -2
- package/components/select/base.ts +3 -2
- package/components/select/base.vdt +1 -1
- package/components/select/styles.ts +10 -6
- package/components/skeleton/styles.ts +7 -4
- package/components/slider/styles.ts +4 -2
- package/components/spin/styles.ts +4 -4
- package/components/spinner/styles.ts +4 -3
- package/components/split/styles.ts +4 -2
- package/components/steps/index.vdt +2 -2
- package/components/steps/styles.ts +7 -5
- package/components/switch/styles.ts +4 -2
- package/components/table/column.ts +2 -0
- package/components/table/column.vdt +7 -3
- package/components/table/demos/basic.md +2 -2
- package/components/table/demos/fixColumn.md +3 -1
- package/components/table/demos/groupHeader.md +11 -11
- package/components/table/demos/scheme.md +1 -1
- package/components/table/index.spec.ts +8 -3
- package/components/table/styles.ts +11 -8
- package/components/table/table.vdt +3 -4
- package/components/table/useColumns.ts +1 -0
- package/components/table/useFixedColumns.ts +27 -49
- package/components/table/useGroup.ts +5 -0
- package/components/table/useResizable.ts +38 -10
- package/components/table/useWidth.ts +3 -0
- package/components/tabs/styles.ts +4 -2
- package/components/tag/styles.ts +7 -4
- package/components/timeline/styles.ts +7 -5
- package/components/timepicker/styles.ts +4 -2
- package/components/tip/styles.ts +4 -2
- package/components/tooltip/content.vdt +1 -1
- package/components/tooltip/styles.ts +4 -2
- package/components/transfer/styles.ts +4 -2
- package/components/tree/demos/checkbox.md +1 -0
- package/components/tree/demos/contextmenu.md +10 -1
- package/components/tree/index.spec.ts +7 -0
- package/components/tree/styles.ts +4 -2
- package/components/tree/useChecked.ts +3 -0
- package/components/treeSelect/styles.ts +4 -2
- package/components/upload/styles.ts +7 -4
- package/components/utils.ts +10 -4
- package/components/wave/styles.ts +4 -2
- package/es/components/affix/styles.d.ts +4 -1
- package/es/components/affix/styles.js +4 -2
- package/es/components/badge/index.vdt.js +1 -1
- package/es/components/badge/styles.d.ts +4 -1
- package/es/components/badge/styles.js +4 -2
- package/es/components/breadcrumb/index.vdt.js +1 -1
- package/es/components/breadcrumb/styles.d.ts +4 -1
- package/es/components/breadcrumb/styles.js +4 -2
- package/es/components/button/styles.d.ts +8 -2
- package/es/components/button/styles.js +7 -4
- package/es/components/card/styles.d.ts +4 -1
- package/es/components/card/styles.js +4 -2
- package/es/components/carousel/styles.d.ts +8 -2
- package/es/components/carousel/styles.js +7 -4
- package/es/components/cascader/index.vdt.js +3 -1
- package/es/components/cascader/styles.d.ts +8 -2
- package/es/components/cascader/styles.js +7 -4
- package/es/components/checkbox/index.vdt.js +1 -1
- package/es/components/checkbox/styles.d.ts +4 -1
- package/es/components/checkbox/styles.js +4 -2
- package/es/components/code/styles.d.ts +4 -1
- package/es/components/code/styles.js +3 -2
- package/es/components/collapse/index.spec.js +1 -1
- package/es/components/collapse/styles.d.ts +8 -2
- package/es/components/collapse/styles.js +7 -4
- package/es/components/colorpicker/styles.d.ts +8 -2
- package/es/components/colorpicker/styles.js +7 -4
- package/es/components/copy/styles.d.ts +4 -1
- package/es/components/copy/styles.js +3 -2
- package/es/components/datepicker/styles.d.ts +12 -3
- package/es/components/datepicker/styles.js +10 -6
- package/es/components/diagram/styles.d.ts +4 -1
- package/es/components/diagram/styles.js +3 -2
- package/es/components/dialog/styles.d.ts +12 -3
- package/es/components/dialog/styles.js +10 -6
- package/es/components/drawer/styles.d.ts +4 -1
- package/es/components/drawer/styles.js +4 -2
- package/es/components/dropdown/styles.d.ts +8 -2
- package/es/components/dropdown/styles.js +7 -4
- package/es/components/editable/styles.d.ts +4 -1
- package/es/components/editable/styles.js +4 -2
- package/es/components/form/index.spec.js +43 -0
- package/es/components/form/item.d.ts +1 -0
- package/es/components/form/item.js +2 -1
- package/es/components/form/styles.d.ts +8 -2
- package/es/components/form/styles.js +7 -4
- package/es/components/form/useDirty.js +4 -0
- package/es/components/grid/styles.d.ts +8 -2
- package/es/components/grid/styles.js +12 -13
- package/es/components/icon/index.vdt.js +1 -1
- package/es/components/icon/styles.d.ts +4 -1
- package/es/components/icon/styles.js +4 -2
- package/es/components/input/styles.d.ts +8 -2
- package/es/components/input/styles.js +7 -4
- package/es/components/layout/styles.d.ts +16 -4
- package/es/components/layout/styles.js +13 -8
- package/es/components/menu/styles.d.ts +16 -4
- package/es/components/menu/styles.js +14 -9
- package/es/components/message/styles.d.ts +8 -2
- package/es/components/message/styles.js +7 -4
- package/es/components/pagination/styles.d.ts +4 -1
- package/es/components/pagination/styles.js +4 -2
- package/es/components/popover/content.vdt.js +1 -1
- package/es/components/popover/styles.d.ts +4 -1
- package/es/components/popover/styles.js +8 -3
- package/es/components/progress/styles.d.ts +4 -1
- package/es/components/progress/styles.js +4 -2
- package/es/components/radio/styles.d.ts +4 -1
- package/es/components/radio/styles.js +4 -2
- package/es/components/rate/styles.d.ts +4 -1
- package/es/components/rate/styles.js +4 -2
- package/es/components/scrollSelect/styles.d.ts +4 -1
- package/es/components/scrollSelect/styles.js +4 -2
- package/es/components/select/base.js +3 -1
- package/es/components/select/base.vdt.js +1 -1
- package/es/components/select/styles.d.ts +12 -3
- package/es/components/select/styles.js +10 -6
- package/es/components/skeleton/styles.d.ts +8 -2
- package/es/components/skeleton/styles.js +7 -4
- package/es/components/slider/styles.d.ts +4 -1
- package/es/components/slider/styles.js +4 -2
- package/es/components/spin/styles.d.ts +4 -1
- package/es/components/spin/styles.js +4 -2
- package/es/components/spinner/styles.d.ts +4 -1
- package/es/components/spinner/styles.js +4 -2
- package/es/components/split/styles.d.ts +4 -1
- package/es/components/split/styles.js +4 -2
- package/es/components/steps/index.vdt.js +2 -2
- package/es/components/steps/styles.d.ts +4 -3
- package/es/components/steps/styles.js +9 -4
- package/es/components/switch/styles.d.ts +4 -1
- package/es/components/switch/styles.js +4 -2
- package/es/components/table/column.d.ts +1 -0
- package/es/components/table/column.js +2 -1
- package/es/components/table/column.vdt.js +9 -3
- package/es/components/table/index.spec.js +18 -11
- package/es/components/table/styles.d.ts +8 -2
- package/es/components/table/styles.js +8 -5
- package/es/components/table/table.vdt.js +3 -4
- package/es/components/table/useColumns.js +1 -0
- package/es/components/table/useFixedColumns.d.ts +3 -3
- package/es/components/table/useFixedColumns.js +27 -46
- package/es/components/table/useGroup.d.ts +1 -0
- package/es/components/table/useGroup.js +11 -1
- package/es/components/table/useResizable.js +41 -5
- package/es/components/table/useWidth.js +3 -0
- package/es/components/tabs/styles.d.ts +4 -1
- package/es/components/tabs/styles.js +4 -2
- package/es/components/tag/styles.d.ts +8 -2
- package/es/components/tag/styles.js +7 -4
- package/es/components/timeline/styles.d.ts +8 -2
- package/es/components/timeline/styles.js +7 -5
- package/es/components/timepicker/styles.d.ts +4 -1
- package/es/components/timepicker/styles.js +4 -2
- package/es/components/tip/styles.d.ts +4 -1
- package/es/components/tip/styles.js +4 -2
- package/es/components/tooltip/content.vdt.js +1 -1
- package/es/components/tooltip/styles.d.ts +4 -1
- package/es/components/tooltip/styles.js +4 -2
- package/es/components/transfer/styles.d.ts +4 -1
- package/es/components/transfer/styles.js +4 -2
- package/es/components/tree/index.spec.js +13 -1
- package/es/components/tree/styles.d.ts +4 -1
- package/es/components/tree/styles.js +4 -2
- package/es/components/tree/useChecked.js +4 -0
- package/es/components/treeSelect/styles.d.ts +4 -1
- package/es/components/treeSelect/styles.js +4 -2
- package/es/components/upload/styles.d.ts +8 -2
- package/es/components/upload/styles.js +7 -4
- package/es/components/utils.d.ts +10 -2
- package/es/components/utils.js +9 -2
- package/es/components/wave/styles.d.ts +4 -1
- package/es/components/wave/styles.js +4 -2
- package/es/i18n/en-US.d.ts +1 -0
- package/es/i18n/en-US.js +1 -0
- package/es/index.d.ts +2 -2
- package/es/index.js +2 -2
- package/es/site/data/components/menu/demos/recursive/index.d.ts +29 -0
- package/es/site/data/components/menu/demos/recursive/index.js +57 -0
- package/es/site/data/components/menu/demos/recursive/react.d.ts +2 -0
- package/es/site/data/components/menu/demos/recursive/react.js +69 -0
- package/es/site/data/components/popover/demos/basic/react.js +2 -1
- package/es/site/data/components/table/demos/basic/react.js +4 -2
- package/es/site/data/components/table/demos/fixColumn/react.js +2 -1
- package/es/site/data/components/table/demos/groupHeader/react.js +11 -20
- package/es/site/data/components/table/demos/scheme/react.js +2 -1
- package/es/site/data/components/tree/demos/checkbox/index.d.ts +12 -2
- package/es/site/data/components/tree/demos/checkbox/index.js +1 -0
- package/es/site/data/components/tree/demos/checkbox/react.d.ts +12 -2
- package/es/site/data/components/tree/demos/checkbox/react.js +1 -0
- package/es/site/data/components/tree/demos/contextmenu/index.d.ts +1 -0
- package/es/site/data/components/tree/demos/contextmenu/index.js +1 -0
- package/es/site/data/components/tree/demos/contextmenu/react.d.ts +1 -0
- package/es/site/data/components/tree/demos/contextmenu/react.js +1 -0
- package/es/site/src/components/article/index.js +6 -2
- package/es/styles/fonts/iconfont.d.ts +4 -1
- package/es/styles/fonts/iconfont.js +1 -1
- package/es/styles/global.js +1 -1
- package/i18n/en-US.ts +1 -0
- package/index.ts +2 -2
- package/package.json +3 -3
- package/styles/fonts/iconfont.ts +2 -2
- 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"
|
|
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"
|
|
16
|
+
<TableColumn title="Time" key="forenoonTime" fixed="left" />
|
|
17
17
|
<TableColumn title="Classes" key="classes">
|
|
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'
|
|
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"
|
|
26
|
-
<TableColumn title="Class 5" key='class5'
|
|
27
|
-
<TableColumn title="Class 6" key='class6'
|
|
28
|
-
<TableColumn title="Class 7" key='class7' fixed="right"
|
|
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
|
```
|
|
@@ -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,
|
|
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}
|
|
@@ -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.
|
|
44
|
-
watchState(widthMap, () =>
|
|
45
|
-
|
|
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
|
-
|
|
45
|
+
function handleFixedColumnsAndUpdate() {
|
|
46
|
+
handleFixedColumns();
|
|
55
47
|
updateScrollPositionOnResize();
|
|
56
|
-
|
|
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
|
-
|
|
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
|
-
|
|
73
|
+
_offsetMap[key] = value;
|
|
92
74
|
hasFixedLeft = true;
|
|
93
75
|
} else if (fixed === 'right') {
|
|
94
76
|
let value = 0;
|
|
95
|
-
let
|
|
96
|
-
while (
|
|
97
|
-
const props =
|
|
77
|
+
let nextVNode = props.nextVNode;
|
|
78
|
+
while (nextVNode) {
|
|
79
|
+
const props = nextVNode.props!;
|
|
98
80
|
if (props.fixed === 'right') {
|
|
99
|
-
|
|
100
|
-
validateWidth(props);
|
|
101
|
-
}
|
|
102
|
-
value += widthMap.value[props.key] || parseInt(props.width as string, 10) || 0;
|
|
81
|
+
value += getWidth(nextVNode);
|
|
103
82
|
}
|
|
104
|
-
|
|
83
|
+
nextVNode = props.nextVNode;
|
|
105
84
|
}
|
|
106
|
-
|
|
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
|
-
|
|
165
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
50
|
-
|
|
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;
|
package/components/tag/styles.ts
CHANGED
|
@@ -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
|
+
});
|
package/components/tip/styles.ts
CHANGED
|
@@ -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
|
+
});
|
|
@@ -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
|
|
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
|
+
});
|