@king-design/intact 3.4.1 → 3.4.3-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/button/demos/disabled.md +14 -4
- package/components/button/index.vdt +1 -1
- package/components/button/styles.ts +14 -1
- package/components/descriptions/item.vdt +2 -4
- package/components/dialog/styles.ts +3 -3
- package/components/dropdown/item.ts +7 -2
- package/components/editable/index.spec.ts +8 -8
- package/components/editable/index.vdt +3 -1
- package/components/editable/styles.ts +8 -1
- package/components/ellipsis/index.vdt +1 -0
- package/components/menu/styles.ts +3 -0
- package/components/select/base.ts +7 -1
- package/components/select/base.vdt +2 -1
- package/components/select/demos/immutable.md +38 -0
- package/components/select/useImmutable.ts +46 -0
- package/components/switch/index.ts +1 -1
- package/components/table/cell.ts +1 -0
- package/components/table/cell.vdt +8 -2
- package/components/table/column.ts +2 -0
- package/components/table/demos/asyncTree.md +70 -0
- package/components/table/demos/footer.md +38 -0
- package/components/table/index.md +3 -0
- package/components/table/row.ts +4 -3
- package/components/table/row.vdt +2 -2
- package/components/table/styles.ts +1 -1
- package/components/table/table.ts +3 -0
- package/components/table/table.vdt +10 -2
- package/components/table/useTree.ts +9 -2
- package/components/tooltip/tooltip.ts +2 -0
- package/components/treeSelect/demos/basic.md +1 -0
- package/components/treeSelect/index.vdt +1 -0
- package/es/components/button/index.vdt.js +1 -1
- package/es/components/button/styles.js +3 -3
- package/es/components/descriptions/item.vdt.js +2 -3
- package/es/components/diagram/shapes/callout.d.ts +1 -1
- package/es/components/diagram/shapes/circle.d.ts +1 -1
- package/es/components/diagram/shapes/document.d.ts +1 -1
- package/es/components/diagram/shapes/ellipse.d.ts +1 -1
- package/es/components/diagram/shapes/hexagon.d.ts +1 -1
- package/es/components/diagram/shapes/image.d.ts +1 -1
- package/es/components/diagram/shapes/parallelogram.d.ts +1 -1
- package/es/components/diagram/shapes/rectangle.d.ts +1 -1
- package/es/components/diagram/shapes/square.d.ts +1 -1
- package/es/components/diagram/shapes/text.d.ts +1 -1
- package/es/components/dialog/styles.js +3 -3
- package/es/components/dropdown/item.js +5 -2
- package/es/components/editable/index.spec.js +8 -8
- package/es/components/editable/index.vdt.js +3 -1
- package/es/components/editable/styles.d.ts +1 -0
- package/es/components/editable/styles.js +4 -1
- package/es/components/ellipsis/index.vdt.js +1 -0
- package/es/components/menu/styles.js +1 -1
- package/es/components/select/base.d.ts +4 -0
- package/es/components/select/base.js +11 -1
- package/es/components/select/base.vdt.js +2 -1
- package/es/components/select/useImmutable.d.ts +4 -0
- package/es/components/select/useImmutable.js +46 -0
- package/es/components/switch/index.js +1 -1
- package/es/components/table/cell.d.ts +1 -0
- package/es/components/table/cell.vdt.js +13 -3
- package/es/components/table/column.d.ts +1 -0
- package/es/components/table/column.js +1 -0
- package/es/components/table/row.d.ts +2 -1
- package/es/components/table/row.js +3 -2
- package/es/components/table/row.vdt.js +3 -1
- package/es/components/table/styles.js +1 -1
- package/es/components/table/table.d.ts +2 -0
- package/es/components/table/table.js +2 -1
- package/es/components/table/table.vdt.js +14 -0
- package/es/components/table/useTree.d.ts +1 -1
- package/es/components/table/useTree.js +30 -2
- package/es/components/tooltip/tooltip.d.ts +1 -0
- package/es/components/tooltip/tooltip.js +9 -1
- package/es/components/treeSelect/index.vdt.js +1 -0
- package/es/index.d.ts +2 -2
- package/es/index.js +2 -2
- package/es/site/data/components/button/demos/disabled/index.d.ts +1 -0
- package/es/site/data/components/button/demos/disabled/index.js +1 -0
- package/es/site/data/components/button/demos/disabled/react.d.ts +1 -0
- package/es/site/data/components/button/demos/disabled/react.js +28 -15
- package/es/site/data/components/select/demos/immutable/index.d.ts +9 -0
- package/es/site/data/components/select/demos/immutable/index.js +18 -0
- package/es/site/data/components/select/demos/immutable/react.d.ts +9 -0
- package/es/site/data/components/select/demos/immutable/react.js +53 -0
- package/es/site/data/components/table/demos/asyncTree/index.d.ts +20 -0
- package/es/site/data/components/table/demos/asyncTree/index.js +53 -0
- package/es/site/data/components/table/demos/asyncTree/react.d.ts +20 -0
- package/es/site/data/components/table/demos/asyncTree/react.js +76 -0
- package/es/site/data/components/table/demos/footer/index.d.ts +12 -0
- package/es/site/data/components/table/demos/footer/index.js +25 -0
- package/es/site/data/components/table/demos/footer/react.d.ts +11 -0
- package/es/site/data/components/table/demos/footer/react.js +46 -0
- package/es/site/data/components/treeSelect/demos/basic/react.js +2 -1
- package/index.ts +2 -2
- package/package.json +2 -2
- package/components/descriptions/.DS_Store +0 -0
- package/components/menu/.DS_Store +0 -0
- package/components/menu/demos/.DS_Store +0 -0
- package/styles/.DS_Store +0 -0
|
@@ -10,9 +10,19 @@ import {Button, Icon} from 'kpc';
|
|
|
10
10
|
|
|
11
11
|
<div>
|
|
12
12
|
<Button disabled>disabled</Button>
|
|
13
|
-
<Button
|
|
14
|
-
<Button
|
|
15
|
-
<Button
|
|
16
|
-
<Button
|
|
13
|
+
<Button type="primary" disabled>primary</Button>
|
|
14
|
+
<Button type="secondary" disabled>secondary</Button>
|
|
15
|
+
<Button type="warning" disabled>warning</Button>
|
|
16
|
+
<Button type="danger" disabled>danger</Button>
|
|
17
|
+
<Button type="success" disabled>success</Button>
|
|
18
|
+
<Button type="none" disabled>none</Button>
|
|
19
|
+
<Button type="link" disabled>link</Button>
|
|
20
|
+
<Button type="flat" disabled>flat</Button>
|
|
21
|
+
<Button color="red" disabled>custom</Button>
|
|
17
22
|
</div>
|
|
18
23
|
```
|
|
24
|
+
|
|
25
|
+
```styl
|
|
26
|
+
.k-btn
|
|
27
|
+
margin 0 20px 20px 0
|
|
28
|
+
```
|
|
@@ -49,9 +49,9 @@ const classNameObj = {
|
|
|
49
49
|
[cls('loading')]: loading,
|
|
50
50
|
[cls('fluid')]: fluid,
|
|
51
51
|
[cls('active')]: checked,
|
|
52
|
+
[cls('custom')]: color,
|
|
52
53
|
[cls('disabled')]: disabled || loading,
|
|
53
54
|
[cls('ghost')]: ghost,
|
|
54
|
-
[cls('custom')]: color,
|
|
55
55
|
[makeButtonStyles(k, iconSide, color)]: true,
|
|
56
56
|
};
|
|
57
57
|
|
|
@@ -31,7 +31,7 @@ const sizes = ['large', 'small', 'mini'] as const;
|
|
|
31
31
|
const btnStyles = {
|
|
32
32
|
get color() { return theme.color.text },
|
|
33
33
|
bgColor: '#fff',
|
|
34
|
-
lineHeight: '1
|
|
34
|
+
lineHeight: '1',
|
|
35
35
|
get padding() { return `0 16px` },
|
|
36
36
|
get borderColor() { return theme.color.border },
|
|
37
37
|
get borderRadius() { return theme.borderRadius },
|
|
@@ -230,6 +230,13 @@ export const makeButtonStyles = cache(function makeButtonStyles(k: string, iconS
|
|
|
230
230
|
background: ${palette(typeStyles.bgColor, 1)};
|
|
231
231
|
border-color: ${palette(typeStyles.borderColor, 1)};
|
|
232
232
|
}
|
|
233
|
+
&.${k}-disabled {
|
|
234
|
+
&, &:hover {
|
|
235
|
+
background: ${palette(typeStyles.bgColor, -2)};
|
|
236
|
+
color: ${palette(typeStyles.color, -2)};
|
|
237
|
+
border-color: ${palette(typeStyles.borderColor, -2)};
|
|
238
|
+
}
|
|
239
|
+
}
|
|
233
240
|
}
|
|
234
241
|
`;
|
|
235
242
|
})}
|
|
@@ -245,6 +252,9 @@ export const makeButtonStyles = cache(function makeButtonStyles(k: string, iconS
|
|
|
245
252
|
&:active {
|
|
246
253
|
background: ${secondary.activeBgColor};
|
|
247
254
|
}
|
|
255
|
+
&.${k}-disabled {
|
|
256
|
+
border: none;
|
|
257
|
+
}
|
|
248
258
|
}
|
|
249
259
|
|
|
250
260
|
|
|
@@ -260,6 +270,9 @@ export const makeButtonStyles = cache(function makeButtonStyles(k: string, iconS
|
|
|
260
270
|
&:active {
|
|
261
271
|
background: ${palette(color, -3)};
|
|
262
272
|
}
|
|
273
|
+
&.${k}-disabled {
|
|
274
|
+
border: none;
|
|
275
|
+
}
|
|
263
276
|
}
|
|
264
277
|
`}
|
|
265
278
|
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import {makeStyles} from './styles';
|
|
2
|
-
import {getRestProps
|
|
3
|
-
import {
|
|
4
|
-
import {Ellipsis} from 'kpc';
|
|
2
|
+
import {getRestProps} from '../utils';
|
|
3
|
+
import {Ellipsis} from '../ellipsis';
|
|
5
4
|
|
|
6
5
|
const {
|
|
7
6
|
children, className, span, label, content, append
|
|
8
7
|
} = this.get();
|
|
9
8
|
const { k } = this.config;
|
|
10
9
|
|
|
11
|
-
|
|
12
10
|
const classNameObj = {
|
|
13
11
|
[`${k}-description-item`]: true,
|
|
14
12
|
[className]: className,
|
|
@@ -52,12 +52,12 @@ const defaults = {
|
|
|
52
52
|
padding: `0 24px`,
|
|
53
53
|
bodyMarginTop: `-25px`,
|
|
54
54
|
tipIconMarginBottom: '10px',
|
|
55
|
-
tipIconFontSize: '
|
|
56
|
-
tipIconLineHeight: '
|
|
55
|
+
tipIconFontSize: '24px',
|
|
56
|
+
tipIconLineHeight: '24px',
|
|
57
57
|
|
|
58
58
|
// with title
|
|
59
59
|
titleFontWeight: '500',
|
|
60
|
-
titleTipIconFontSize: '
|
|
60
|
+
titleTipIconFontSize: '24px',
|
|
61
61
|
titleFontSize: '14px',
|
|
62
62
|
wrapperPaddingLeft: '8px',
|
|
63
63
|
titleBodyMarginTop: '-36px',
|
|
@@ -7,6 +7,7 @@ import {DropdownMenu, DROPDOWN_MENU} from './menu';
|
|
|
7
7
|
import {IgnoreClickEvent} from '../../hooks/useDocumentClick';
|
|
8
8
|
import { Dropdown as ExportDropdown, DropdownMenu as ExportDropdownMenu } from '.';
|
|
9
9
|
import { useConfigContext } from '../config';
|
|
10
|
+
import type { Tooltip } from '../tooltip/tooltip';
|
|
10
11
|
|
|
11
12
|
export interface DropdownItemProps {
|
|
12
13
|
disabled?: boolean
|
|
@@ -61,8 +62,12 @@ export class DropdownItem extends Component<DropdownItemProps, DropdownItemEvent
|
|
|
61
62
|
if (this.get('hideOnSelect')) {
|
|
62
63
|
// hide all dropdowns
|
|
63
64
|
let dropdown = this.dropdown;
|
|
64
|
-
do {
|
|
65
|
-
|
|
65
|
+
do {
|
|
66
|
+
if (!(dropdown as Tooltip).$isTooltip) {
|
|
67
|
+
dropdown!.hide(true);
|
|
68
|
+
}
|
|
69
|
+
dropdown = dropdown!.dropdown;
|
|
70
|
+
} while (dropdown);
|
|
66
71
|
}
|
|
67
72
|
}
|
|
68
73
|
|
|
@@ -17,7 +17,7 @@ describe('Editable', () => {
|
|
|
17
17
|
expect(element.innerHTML).to.matchSnapshot();
|
|
18
18
|
|
|
19
19
|
// input
|
|
20
|
-
let input = element.querySelector('
|
|
20
|
+
let input = element.querySelector('textarea') as HTMLTextAreaElement;
|
|
21
21
|
input.value = 'test';
|
|
22
22
|
dispatchEvent(input, 'blur');
|
|
23
23
|
await wait();
|
|
@@ -29,7 +29,7 @@ describe('Editable', () => {
|
|
|
29
29
|
editable.edit();
|
|
30
30
|
await wait();
|
|
31
31
|
expect(element.innerHTML).to.matchSnapshot();
|
|
32
|
-
input = element.querySelector('
|
|
32
|
+
input = element.querySelector('textarea') as HTMLTextAreaElement;
|
|
33
33
|
input.value = 'new';
|
|
34
34
|
dispatchEvent(input, 'keydown', {keyCode: 27});
|
|
35
35
|
await wait();
|
|
@@ -41,7 +41,7 @@ describe('Editable', () => {
|
|
|
41
41
|
editable.edit();
|
|
42
42
|
await wait();
|
|
43
43
|
expect(element.innerHTML).to.matchSnapshot();
|
|
44
|
-
input = element.querySelector('
|
|
44
|
+
input = element.querySelector('textarea') as HTMLTextAreaElement;
|
|
45
45
|
input.value = 'new';
|
|
46
46
|
dispatchEvent(input, 'keydown', {keyCode: 13});
|
|
47
47
|
await wait();
|
|
@@ -58,7 +58,7 @@ describe('Editable', () => {
|
|
|
58
58
|
// @ts-ignore
|
|
59
59
|
first.edit();
|
|
60
60
|
await wait();
|
|
61
|
-
let input = (findDomFromVNode(first.$lastInput!, true) as HTMLElement).querySelector('
|
|
61
|
+
let input = (findDomFromVNode(first.$lastInput!, true) as HTMLElement).querySelector('textarea') as HTMLTextAreaElement;
|
|
62
62
|
dispatchEvent(input, 'focus');
|
|
63
63
|
input.value = 'a';
|
|
64
64
|
dispatchEvent(input, 'input');
|
|
@@ -69,7 +69,7 @@ describe('Editable', () => {
|
|
|
69
69
|
// @ts-ignore
|
|
70
70
|
second.edit();
|
|
71
71
|
await wait();
|
|
72
|
-
input = (findDomFromVNode(second.$lastInput!, true) as HTMLElement).querySelector('
|
|
72
|
+
input = (findDomFromVNode(second.$lastInput!, true) as HTMLElement).querySelector('textarea') as HTMLTextAreaElement;
|
|
73
73
|
input.value = 'a';
|
|
74
74
|
dispatchEvent(input, 'input');
|
|
75
75
|
dispatchEvent(input, 'blur');
|
|
@@ -79,7 +79,7 @@ describe('Editable', () => {
|
|
|
79
79
|
// @ts-ignore
|
|
80
80
|
third.edit();
|
|
81
81
|
await wait();
|
|
82
|
-
input = (findDomFromVNode(third.$lastInput!, true) as HTMLElement).querySelector('
|
|
82
|
+
input = (findDomFromVNode(third.$lastInput!, true) as HTMLElement).querySelector('textarea') as HTMLTextAreaElement;
|
|
83
83
|
input.value = 'a';
|
|
84
84
|
dispatchEvent(input, 'input');
|
|
85
85
|
dispatchEvent(input, 'blur');
|
|
@@ -110,14 +110,14 @@ describe('Editable', () => {
|
|
|
110
110
|
expect(element.outerHTML).to.matchSnapshot();
|
|
111
111
|
element.querySelector<HTMLElement>('.k-editable-icon')!.click();
|
|
112
112
|
await wait();
|
|
113
|
-
let input = element.querySelector("
|
|
113
|
+
let input = element.querySelector("textarea") as HTMLTextAreaElement;
|
|
114
114
|
input.value = 'aa';
|
|
115
115
|
dispatchEvent(input, 'blur');
|
|
116
116
|
await wait();
|
|
117
117
|
expect(element.innerText).to.eql('test');
|
|
118
118
|
element.querySelector<HTMLElement>('.k-editable-icon')!.click();
|
|
119
119
|
await wait();
|
|
120
|
-
input = element.querySelector("
|
|
120
|
+
input = element.querySelector("textarea") as HTMLTextAreaElement;
|
|
121
121
|
expect(input.value).to.eql('aa');
|
|
122
122
|
});
|
|
123
123
|
});
|
|
@@ -6,7 +6,7 @@ import { cache } from '../utils';
|
|
|
6
6
|
|
|
7
7
|
const defaults = {
|
|
8
8
|
iconGap: '0 0 0 8px',
|
|
9
|
-
|
|
9
|
+
get smallPadding() { return theme.small.padding },
|
|
10
10
|
// invalid
|
|
11
11
|
invalid: {
|
|
12
12
|
get border() { return `1px solid ${theme.color.danger}`},
|
|
@@ -35,5 +35,12 @@ export const makeStyles = cache(function makeStyles(k: string) {
|
|
|
35
35
|
border: ${editable.invalid.border} !important;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
+
&.${k}-editable {
|
|
39
|
+
.${k}-type-textarea {
|
|
40
|
+
.${k}-textarea {
|
|
41
|
+
padding: 0 ${editable.smallPadding};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
38
45
|
`;
|
|
39
46
|
});
|
|
@@ -19,6 +19,7 @@ import {useFocusout} from './useFocusout';
|
|
|
19
19
|
import type {Events} from '../types';
|
|
20
20
|
import {isNullOrUndefined} from 'intact-shared';
|
|
21
21
|
import { useDraggable } from './useDraggble';
|
|
22
|
+
import { useImmutable } from './useImmutable';
|
|
22
23
|
import { useConfigContext } from '../config';
|
|
23
24
|
|
|
24
25
|
export interface BaseSelectProps<V, Multipe extends boolean = boolean, Attach = V | null> {
|
|
@@ -107,6 +108,7 @@ export abstract class BaseSelect<
|
|
|
107
108
|
public input = useInput(this.resetKeywords);
|
|
108
109
|
private focusout = useFocusout();
|
|
109
110
|
private draggable = useDraggable();
|
|
111
|
+
public immutable = useImmutable();
|
|
110
112
|
protected config = useConfigContext();
|
|
111
113
|
|
|
112
114
|
init() {
|
|
@@ -160,7 +162,11 @@ export abstract class BaseSelect<
|
|
|
160
162
|
@bind
|
|
161
163
|
protected clear(e: MouseEvent) {
|
|
162
164
|
e.stopPropagation();
|
|
163
|
-
|
|
165
|
+
const {value, multiple} = this.get();
|
|
166
|
+
const immutableValues = this.immutable.immutableValues.value;
|
|
167
|
+
|
|
168
|
+
this.set('value', multiple ? (Array.isArray(value) ? value.filter(key => immutableValues.includes(key)) : []) : null);
|
|
169
|
+
|
|
164
170
|
}
|
|
165
171
|
|
|
166
172
|
@bind
|
|
@@ -39,6 +39,7 @@ const label = this.getLabel();
|
|
|
39
39
|
const hasValue = this.hasValue();
|
|
40
40
|
const {onInput, inputRef, keywords: {value: keywords}} = this.input;
|
|
41
41
|
const {onFocusout, triggerRef} = this.focusout;
|
|
42
|
+
const {isClosable} = this.immutable;
|
|
42
43
|
const filterInput = <Input v-if={filterable}
|
|
43
44
|
class={`${k}-select-input`}
|
|
44
45
|
value={keywords}
|
|
@@ -122,7 +123,7 @@ const filterInput = <Input v-if={filterable}
|
|
|
122
123
|
value[$key] :
|
|
123
124
|
$key
|
|
124
125
|
}
|
|
125
|
-
closable
|
|
126
|
+
closable={isClosable(value[$key])}
|
|
126
127
|
ev-close={this.delete.bind(this, $key)}
|
|
127
128
|
disabled={disabled}
|
|
128
129
|
size={size}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 禁用选项不可删除
|
|
3
|
+
order: 14
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
在指定`multiple`多选的情况下,`Select`指定`value`包含`disabled Option`,则禁止删除
|
|
7
|
+
|
|
8
|
+
```vdt
|
|
9
|
+
import {Select, Option, OptionGroup} from 'kpc';
|
|
10
|
+
|
|
11
|
+
<div>
|
|
12
|
+
<Select v-model="day" multiple filterable clearable>
|
|
13
|
+
<Option value="Monday">星期一</Option>
|
|
14
|
+
<Option value="Tuesday" disabled>星期二</Option>
|
|
15
|
+
<Option value="Wednesday">星期三</Option>
|
|
16
|
+
<Option value="Thursday">星期四</Option>
|
|
17
|
+
<Option value="Friday" disabled>星期五</Option>
|
|
18
|
+
<Option value="Saturday">星期六</Option>
|
|
19
|
+
<Option value="Sunday">星期天</Option>
|
|
20
|
+
</Select>
|
|
21
|
+
You selected: {JSON.stringify(this.get('day'))}
|
|
22
|
+
</div>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
interface Props {
|
|
27
|
+
day?: string[]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default class extends Component {
|
|
31
|
+
static template = template;
|
|
32
|
+
static defaults() {
|
|
33
|
+
return {
|
|
34
|
+
day: ['Tuesday', 'Sunday', 'Wednesday'],
|
|
35
|
+
} as Props;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useInstance, Children } from 'intact';
|
|
2
|
+
import type { Select } from './select';
|
|
3
|
+
import { Option, OptionProps } from './option';
|
|
4
|
+
import { OptionGroup } from './group';
|
|
5
|
+
import { eachChildren, isComponentVNode } from '../utils';
|
|
6
|
+
import { useState } from '../../hooks/useState';
|
|
7
|
+
|
|
8
|
+
export function useImmutable() {
|
|
9
|
+
const instance = useInstance() as Select<any, true>;
|
|
10
|
+
const immutableValues = useState<any[]>([]);
|
|
11
|
+
|
|
12
|
+
function setImmutableValues() {
|
|
13
|
+
const { children, multiple } = instance.get();
|
|
14
|
+
if (!multiple) return;
|
|
15
|
+
updateImmutableValues(children);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function updateImmutableValues(children: Children) {
|
|
19
|
+
const _immutableValues: any[] = [];
|
|
20
|
+
const loop = (children: Children) => {
|
|
21
|
+
eachChildren(children, vNode => {
|
|
22
|
+
if (isComponentVNode(vNode, Option)) {
|
|
23
|
+
const { disabled, value } = vNode.props as OptionProps;
|
|
24
|
+
if (disabled) {
|
|
25
|
+
_immutableValues.push(value);
|
|
26
|
+
}
|
|
27
|
+
} else if (isComponentVNode(vNode, OptionGroup)) {
|
|
28
|
+
loop(vNode.props!.children);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
loop(children);
|
|
34
|
+
immutableValues.set(_immutableValues);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function isClosable(key: string) {
|
|
38
|
+
return !immutableValues.value.includes(key);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
setImmutableValues();
|
|
42
|
+
|
|
43
|
+
// instance.on('$receive:children', setImmutableValues);
|
|
44
|
+
|
|
45
|
+
return { immutableValues, isClosable };
|
|
46
|
+
}
|
package/components/table/cell.ts
CHANGED
|
@@ -3,11 +3,12 @@ import {get, noop} from 'intact-shared';
|
|
|
3
3
|
import {Button} from '../button';
|
|
4
4
|
import {Icon} from '../icon';
|
|
5
5
|
import {getTextByChildren} from '../utils';
|
|
6
|
+
import {Ellipsis} from '../ellipsis';
|
|
6
7
|
|
|
7
8
|
const {
|
|
8
9
|
props, rowIndex, columnIndex, offset,
|
|
9
10
|
data, checkType, indent, grid,
|
|
10
|
-
colspan, rowspan, onClickArrow, hasChildren,
|
|
11
|
+
colspan, rowspan, onClickArrow, hasChildren, loaded
|
|
11
12
|
} = this.get();
|
|
12
13
|
const { k } = this.config;
|
|
13
14
|
|
|
@@ -20,6 +21,10 @@ if (blocks) {
|
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
|
|
24
|
+
if (props.ellipsis) {
|
|
25
|
+
children = <Ellipsis>{children}</Ellipsis>
|
|
26
|
+
}
|
|
27
|
+
|
|
23
28
|
let {className, style} = getClassAndStyleForFixed(props, offset, k, checkType);
|
|
24
29
|
if (columnIndex === 0 && indent) {
|
|
25
30
|
style || (style = {});
|
|
@@ -42,7 +47,8 @@ const classNameObj = {
|
|
|
42
47
|
class={`${k}-table-arrow`}
|
|
43
48
|
ev-click={onClickArrow}
|
|
44
49
|
>
|
|
45
|
-
<Icon class={`${k}-icon-right`} size="small" />
|
|
50
|
+
<Icon v-if={loaded !== false} class={`${k}-icon-right`} size="small" />
|
|
51
|
+
<Icon v-else class={`${k}-tree-icon ion-load-c`} rotate />
|
|
46
52
|
</Button>
|
|
47
53
|
{children}
|
|
48
54
|
</td>
|
|
@@ -18,6 +18,7 @@ export interface TableColumnProps {
|
|
|
18
18
|
exportCell?: (data: any, index: number) => string
|
|
19
19
|
minWidth?: number
|
|
20
20
|
hidden?: boolean
|
|
21
|
+
ellipsis?: boolean
|
|
21
22
|
|
|
22
23
|
// passed by Table
|
|
23
24
|
// offset: number
|
|
@@ -58,6 +59,7 @@ const typeDefs: Required<TypeDefs<TableColumnProps>> = {
|
|
|
58
59
|
exportCell: Function,
|
|
59
60
|
minWidth: Number,
|
|
60
61
|
hidden: Boolean,
|
|
62
|
+
ellipsis: Boolean,
|
|
61
63
|
|
|
62
64
|
// offset: null,
|
|
63
65
|
cols: null,
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 树形表格异步加载
|
|
3
|
+
order: 33
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
添加`load`数据加载函数即可实现异步加载子节点功能,组件会传入当前节点对象作为参数,函数可以返回
|
|
7
|
+
数组或者异步返回数组作为当前异步加载的子节点。如果子节点还可以进一步展开,可以将`children`属性
|
|
8
|
+
设为空数组`[]`,否则不指定`children`则表示该节点为叶子节点。
|
|
9
|
+
|
|
10
|
+
组件默认遇到`children`为`[]`空数组的情况就会去进行异步加载,你可以通过`loaded`属性设为`true`来
|
|
11
|
+
标识该子节点已经加载完成,无需再次加载
|
|
12
|
+
|
|
13
|
+
```vdt
|
|
14
|
+
import {Table, TableColumn} from 'kpc';
|
|
15
|
+
|
|
16
|
+
<Table data={this.get('data')} rowKey={data => data.name} load={this.loadData}>
|
|
17
|
+
<TableColumn key="name" title="Name" />
|
|
18
|
+
<TableColumn key="size" title="Size">
|
|
19
|
+
<b:template args="[data]">
|
|
20
|
+
{data.size}MB
|
|
21
|
+
</b:template>
|
|
22
|
+
</TableColumn>
|
|
23
|
+
</Table>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import {bind} from 'kpc';
|
|
28
|
+
interface Props {
|
|
29
|
+
data: NonNullable<any>
|
|
30
|
+
}
|
|
31
|
+
export default class extends Component<Props> {
|
|
32
|
+
static template = template;
|
|
33
|
+
|
|
34
|
+
static defaults() {
|
|
35
|
+
return {
|
|
36
|
+
data: [
|
|
37
|
+
{
|
|
38
|
+
name: 'Audios',
|
|
39
|
+
size: 12,
|
|
40
|
+
children: []
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'Images',
|
|
44
|
+
size: 14,
|
|
45
|
+
children: []
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'doc.pdf',
|
|
49
|
+
size: 18,
|
|
50
|
+
},
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@bind
|
|
56
|
+
loadData(node: any) {
|
|
57
|
+
return new Promise<void>(resolve => {
|
|
58
|
+
setTimeout(() => {
|
|
59
|
+
node.children = [
|
|
60
|
+
{name: 'child1', size: 17},
|
|
61
|
+
{name: 'child2', size: 15, loaded: true},
|
|
62
|
+
];
|
|
63
|
+
this.set('data', [...this.get('data')]);
|
|
64
|
+
|
|
65
|
+
resolve();
|
|
66
|
+
}, 2000);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
```
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 自定义footer
|
|
3
|
+
order: 32
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
```vdt
|
|
8
|
+
import {Table, TableColumn} from 'kpc';
|
|
9
|
+
|
|
10
|
+
<div>
|
|
11
|
+
<Table data={this.get('data')} resizable>
|
|
12
|
+
<TableColumn key="a" title="Title 1" minWidth={200}/>
|
|
13
|
+
<TableColumn key="b" title="Title 2" minWidth={300}/>
|
|
14
|
+
<b:footer>
|
|
15
|
+
<div class="footer">自定义底部</div>
|
|
16
|
+
</b:footer>
|
|
17
|
+
</Table>
|
|
18
|
+
</div>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```styl
|
|
22
|
+
.k-table
|
|
23
|
+
margin-bottom 20px
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
export default class extends Component {
|
|
28
|
+
static template = template;
|
|
29
|
+
static defaults() {
|
|
30
|
+
return {
|
|
31
|
+
data: [
|
|
32
|
+
{a: 'Cell 1-1', b: 'Cell 1-2'},
|
|
33
|
+
{a: 'Cell 2-1', b: 'Cell 2-2'}
|
|
34
|
+
],
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
@@ -45,6 +45,7 @@ sidebar: doc
|
|
|
45
45
|
| animation | 是否开启动效,默认开启。可以通过`true` `false`全部设置,或者通过数组单独设置行和列的动效 | `boolean` | `[boolean, boolean]` | `true` |
|
|
46
46
|
| hideHeader | 是否隐藏表头 | `boolean` | `false` |
|
|
47
47
|
| pagination | 是否支持分页 | `boolean` | `PaginationProps` | `false` |
|
|
48
|
+
| load | 指定异步加载节点数据的函数,该函数通过`Promise`返回数组来添加子节点数据 | <code>(node: any) => Promise<void> | void</code> | `undefined` |
|
|
48
49
|
|
|
49
50
|
```ts
|
|
50
51
|
import {Props} from 'intact';
|
|
@@ -113,6 +114,7 @@ export interface PaginationProps {
|
|
|
113
114
|
| minWidth | 指定当前列拖动时的最小宽度,优先级高于`Table`的`minColWidth` | `number` | `undefined` |
|
|
114
115
|
| className | 给当前列添加className | `string` | `Record<string, any>` | `undefined` |
|
|
115
116
|
| hidden | 是否隐藏当前列,仅为不可见,不影响`exportTable`导出表格 | `boolean` | `false` |
|
|
117
|
+
| ellipsis | 是否开启超长省略 | `boolean` | `false` |
|
|
116
118
|
|
|
117
119
|
```ts
|
|
118
120
|
import {VNode} from 'intact';
|
|
@@ -132,6 +134,7 @@ export type TableColumnGroupItem = {
|
|
|
132
134
|
| empty | 自定义无数据展示模板 | - |
|
|
133
135
|
| expand | 指定行展开后要展示的模板内容 | `([data: T, index: number]) => Children` |
|
|
134
136
|
| tooltip | 行提示内容 | `([data: T, index: number]) => Children` |
|
|
137
|
+
| footer | 自定义`Table`底部 | - |
|
|
135
138
|
|
|
136
139
|
## TableColumn
|
|
137
140
|
|
package/components/table/row.ts
CHANGED
|
@@ -34,10 +34,11 @@ export interface TableRowProps {
|
|
|
34
34
|
spreaded: boolean
|
|
35
35
|
hasChildren: boolean
|
|
36
36
|
indent: number
|
|
37
|
-
onToggleSpreadRow: (key: TableRowKey) => void
|
|
37
|
+
onToggleSpreadRow: (key: TableRowKey, rowData?: any) => void
|
|
38
38
|
onBeforeUnmount: (key: TableRowKey) => void
|
|
39
39
|
offsetMap: Record<Key, number>
|
|
40
40
|
animation: boolean
|
|
41
|
+
loaded: boolean
|
|
41
42
|
|
|
42
43
|
draggable: boolean
|
|
43
44
|
draggingKey: TableRowKey | null
|
|
@@ -109,8 +110,8 @@ export class TableRow extends Component<TableRowProps> {
|
|
|
109
110
|
@bind
|
|
110
111
|
onClickArrow(e: MouseEvent) {
|
|
111
112
|
e.stopPropagation();
|
|
112
|
-
const {onToggleSpreadRow, key} = this.get();
|
|
113
|
-
onToggleSpreadRow(key);
|
|
113
|
+
const {onToggleSpreadRow, key, data} = this.get();
|
|
114
|
+
onToggleSpreadRow(key, data);
|
|
114
115
|
}
|
|
115
116
|
|
|
116
117
|
@bind
|
package/components/table/row.vdt
CHANGED
|
@@ -11,7 +11,7 @@ const {
|
|
|
11
11
|
grid, index: rowIndex, indeterminate,
|
|
12
12
|
allDisabled, selected, /* hidden, */spreaded,
|
|
13
13
|
hasChildren, indent, key, offsetMap,
|
|
14
|
-
draggable, draggingKey, animation,
|
|
14
|
+
draggable, draggingKey, animation, loaded,
|
|
15
15
|
} = this.get();
|
|
16
16
|
const { k } = this.config;
|
|
17
17
|
|
|
@@ -71,13 +71,13 @@ cols.forEach((props, columnIndex) => {
|
|
|
71
71
|
if (!render) return;
|
|
72
72
|
|
|
73
73
|
const columnKey = props.key;
|
|
74
|
-
|
|
75
74
|
vNodes.push(
|
|
76
75
|
<TableCell
|
|
77
76
|
props={props}
|
|
78
77
|
columnIndex={columnIndex}
|
|
79
78
|
rowIndex={rowIndex}
|
|
80
79
|
data={data}
|
|
80
|
+
loaded={loaded}
|
|
81
81
|
offset={offsetMap[columnKey]}
|
|
82
82
|
checkType={checkType}
|
|
83
83
|
indent={indent}
|