@king-design/intact 3.1.1 → 3.1.3
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/item.vdt +1 -1
- package/components/collapse/styles.ts +16 -12
- 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/index.spec.ts +30 -0
- package/components/dialog/styles.ts +10 -6
- package/components/dialog/usePosition.ts +4 -0
- package/components/drawer/styles.ts +4 -2
- package/components/dropdown/styles.ts +7 -4
- package/components/dropdown/usePosition.ts +19 -9
- package/components/editable/styles.ts +4 -2
- package/components/form/styles.ts +7 -4
- 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/styles.ts +4 -2
- package/components/portal.ts +16 -3
- 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/upload/useFiles.ts +3 -2
- 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/item.vdt.js +3 -3
- package/es/components/collapse/styles.d.ts +8 -2
- package/es/components/collapse/styles.js +11 -8
- 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/index.spec.js +61 -1
- package/es/components/dialog/styles.d.ts +12 -3
- package/es/components/dialog/styles.js +10 -6
- package/es/components/dialog/usePosition.js +7 -0
- 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/dropdown/usePosition.js +14 -11
- package/es/components/editable/styles.d.ts +4 -1
- package/es/components/editable/styles.js +4 -2
- package/es/components/form/styles.d.ts +8 -2
- package/es/components/form/styles.js +7 -4
- 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 +4 -2
- package/es/components/portal.js +15 -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/upload/useFiles.js +3 -2
- 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/packages/kpc-react/__tests__/components/cascader.spec.js +0 -1
- 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/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 +7 -2
- 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 +32 -0
|
@@ -2,6 +2,7 @@ import {css} from '@emotion/css';
|
|
|
2
2
|
import {theme, setDefault} from '../../styles/theme';
|
|
3
3
|
import {deepDefaults, sizes, 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.middle },
|
|
@@ -56,9 +57,10 @@ const defaults = {
|
|
|
56
57
|
let kswitch: typeof defaults;
|
|
57
58
|
setDefault(() => {
|
|
58
59
|
kswitch = deepDefaults(theme, {switch: defaults}).switch;
|
|
60
|
+
makeStyles?.clearCache();
|
|
59
61
|
});
|
|
60
62
|
|
|
61
|
-
export function makeStyles(k: string) {
|
|
63
|
+
export const makeStyles = cache(function makeStyles(k: string) {
|
|
62
64
|
return css`
|
|
63
65
|
display: inline-block;
|
|
64
66
|
vertical-align: middle;
|
|
@@ -206,4 +208,4 @@ export function makeStyles(k: string) {
|
|
|
206
208
|
}
|
|
207
209
|
}
|
|
208
210
|
`;
|
|
209
|
-
}
|
|
211
|
+
});
|
|
@@ -22,6 +22,7 @@ export interface TableColumnProps {
|
|
|
22
22
|
cols?: number
|
|
23
23
|
rows?: number
|
|
24
24
|
prevVNode?: VNodeComponentClass<TableColumn> | null
|
|
25
|
+
nextVNode?: VNodeComponentClass<TableColumn> | null
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
export interface TableColumnEvents { }
|
|
@@ -58,6 +59,7 @@ const typeDefs: Required<TypeDefs<TableColumnProps>> = {
|
|
|
58
59
|
cols: null,
|
|
59
60
|
rows: null,
|
|
60
61
|
prevVNode: null,
|
|
62
|
+
nextVNode: null,
|
|
61
63
|
};
|
|
62
64
|
|
|
63
65
|
export class TableColumn<T = any> extends Component<TableColumnProps, TableColumnEvents, TableColumnBlocks<T>> {
|
|
@@ -19,7 +19,7 @@ const {title, fixed, group, multiple, key, sortable, cols, rows} = this.get();
|
|
|
19
19
|
const {
|
|
20
20
|
onSelect, isChecked, keywords, filteredGroup,
|
|
21
21
|
onShow, reset, confirm, dropdownRef,
|
|
22
|
-
localGroupValue, isEmptyValue,
|
|
22
|
+
localGroupValue, isEmptyValue, checkAll,
|
|
23
23
|
} = this.group;
|
|
24
24
|
const { k } = this.config;
|
|
25
25
|
|
|
@@ -96,14 +96,18 @@ const { k } = this.config;
|
|
|
96
96
|
</DropdownItem>
|
|
97
97
|
</div>
|
|
98
98
|
<div class={`${k}-table-group-footer`} v-if={multiple}>
|
|
99
|
+
<Button size="mini"
|
|
100
|
+
type="link"
|
|
101
|
+
ev-click={checkAll}
|
|
102
|
+
>{_$('全选')}</Button>
|
|
99
103
|
<Button size="small"
|
|
100
104
|
disabled={isEmptyValue(localGroupValue.value)}
|
|
101
105
|
type="secondary"
|
|
102
106
|
ev-click={() => reset(onChange)}
|
|
103
|
-
|
|
107
|
+
>{_$('重置')}</Button>
|
|
104
108
|
<Button type="primary" size="small"
|
|
105
109
|
ev-click={() => confirm(onChange)}
|
|
106
|
-
|
|
110
|
+
>{_$('确定')}</Button>
|
|
107
111
|
</div>
|
|
108
112
|
</DropdownMenu>
|
|
109
113
|
</Dropdown>
|
|
@@ -10,8 +10,8 @@ order: 0
|
|
|
10
10
|
import {Table, TableColumn} from 'kpc';
|
|
11
11
|
|
|
12
12
|
<Table data={this.get('data')} resizable>
|
|
13
|
-
<TableColumn key="a" title="Title 1" />
|
|
14
|
-
<TableColumn key="b" title="Title 2" />
|
|
13
|
+
<TableColumn key="a" title="Title 1" minWidth={200}/>
|
|
14
|
+
<TableColumn key="b" title="Title 2" minWidth={300} />
|
|
15
15
|
</Table>
|
|
16
16
|
```
|
|
17
17
|
|
|
@@ -9,6 +9,8 @@ order: 14
|
|
|
9
9
|
> 固定列通过`position: sticky`来实现,所以对于非首/尾列,需要指定它们之前或之后的列的固定宽度`width`来
|
|
10
10
|
> 帮助该列来确定固定的位置
|
|
11
11
|
|
|
12
|
+
> @since 3.1.2 `width`属性不再是必须的
|
|
13
|
+
|
|
12
14
|
```vdt
|
|
13
15
|
import {Table, TableColumn} from 'kpc';
|
|
14
16
|
|
|
@@ -34,7 +36,7 @@ import {Table, TableColumn} from 'kpc';
|
|
|
34
36
|
<TableColumn key="column1" title="Column1" width="300" />
|
|
35
37
|
<TableColumn key="column2" title="Column2" width="300" />
|
|
36
38
|
<TableColumn key="column3" title="Column3" width="300" />
|
|
37
|
-
<TableColumn key="column4" title="Column4" width="300" />
|
|
39
|
+
<TableColumn key="column4" title="Column4" width="300" fixed="right" />
|
|
38
40
|
<TableColumn fixed="right" key="action" title="Action" width="200">
|
|
39
41
|
<b:template args="data">
|
|
40
42
|
<a>action</a>
|
|
@@ -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
|
+
});
|