@king-design/intact 3.4.3-beta.2 → 3.4.4
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 -3
- package/components/button/demos/group.md +3 -3
- package/components/button/group.ts +5 -0
- package/components/button/group.vdt +2 -2
- package/components/button/index.md +2 -1
- package/components/button/index.vdt +1 -1
- package/components/button/styles.ts +18 -5
- package/components/dialog/styles.ts +3 -3
- package/components/dropdown/item.ts +7 -2
- package/components/editable/demos/textarea.md +53 -0
- package/components/editable/index.md +7 -1
- package/components/editable/index.spec.ts +27 -0
- package/components/editable/index.ts +4 -1
- package/components/editable/index.vdt +13 -4
- package/components/editable/styles.ts +1 -1
- package/components/ellipsis/demos/hoverable.md +23 -0
- package/components/ellipsis/index.ts +4 -1
- package/components/ellipsis/index.vdt +3 -1
- package/components/input/demos/size.md +9 -1
- package/components/input/styles.ts +12 -2
- package/components/menu/styles.ts +0 -3
- package/components/select/demos/immutable.md +7 -6
- package/components/select/index.spec.ts +31 -0
- package/components/select/useImmutable.ts +1 -1
- package/components/switch/styles.ts +5 -0
- package/components/table/cell.ts +3 -2
- package/components/table/cell.vdt +13 -4
- package/components/table/column.ts +2 -0
- package/components/table/column.vdt +4 -3
- package/components/table/demos/asyncTree.md +73 -0
- package/components/table/demos/ellipsis.md +29 -0
- package/components/table/demos/fixFooter.md +52 -0
- package/components/table/demos/footer.md +38 -0
- package/components/table/demos/tree.md +22 -10
- package/components/table/index.md +5 -0
- package/components/table/row.ts +27 -17
- package/components/table/row.vdt +4 -2
- package/components/table/styles.ts +27 -3
- package/components/table/table.ts +8 -2
- package/components/table/table.vdt +18 -3
- package/components/table/useColumns.ts +24 -1
- package/components/table/useTree.ts +9 -2
- package/components/tip/demos/icon.md +53 -0
- package/components/tip/demos/size.md +39 -0
- package/components/tip/index.md +2 -0
- package/components/tip/index.ts +17 -1
- package/components/tip/index.vdt +38 -5
- package/components/tip/styles.ts +84 -3
- package/components/tooltip/demos/always.md +6 -0
- package/components/tooltip/demos/content.md +17 -2
- package/components/tooltip/index.spec.ts +21 -2
- package/components/tooltip/tooltip.ts +4 -1
- package/components/transfer/index.vdt +2 -4
- package/components/tree/demos/loading.md +3 -0
- package/components/treeSelect/demos/basic.md +1 -0
- package/components/treeSelect/index.vdt +1 -0
- package/components/upload/demos/files.md +1 -0
- package/components/upload/index.vdt +4 -1
- package/components/upload/styles.ts +1 -0
- package/es/components/button/group.d.ts +1 -0
- package/es/components/button/group.js +4 -0
- package/es/components/button/group.vdt.js +3 -2
- package/es/components/button/index.vdt.js +1 -1
- package/es/components/button/styles.js +6 -6
- 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.d.ts +2 -0
- package/es/components/editable/index.js +4 -2
- package/es/components/editable/index.spec.js +39 -0
- package/es/components/editable/index.vdt.js +17 -6
- package/es/components/editable/styles.d.ts +1 -0
- package/es/components/editable/styles.js +3 -0
- package/es/components/ellipsis/index.d.ts +1 -0
- package/es/components/ellipsis/index.js +4 -2
- package/es/components/ellipsis/index.vdt.js +3 -1
- package/es/components/input/styles.js +11 -1
- package/es/components/menu/styles.js +1 -1
- package/es/components/select/index.spec.js +47 -0
- package/es/components/switch/styles.js +1 -1
- package/es/components/table/cell.d.ts +2 -0
- package/es/components/table/cell.vdt.js +18 -5
- package/es/components/table/column.d.ts +1 -0
- package/es/components/table/column.js +1 -0
- package/es/components/table/column.vdt.js +16 -12
- package/es/components/table/row.d.ts +3 -1
- package/es/components/table/row.js +24 -15
- package/es/components/table/row.vdt.js +6 -2
- package/es/components/table/styles.d.ts +49 -0
- package/es/components/table/styles.js +3 -2
- package/es/components/table/table.d.ts +4 -0
- package/es/components/table/table.js +4 -1
- package/es/components/table/table.vdt.js +29 -4
- package/es/components/table/useColumns.d.ts +9 -0
- package/es/components/table/useColumns.js +29 -1
- package/es/components/table/useTree.d.ts +1 -1
- package/es/components/table/useTree.js +30 -2
- package/es/components/tip/index.d.ts +6 -1
- package/es/components/tip/index.js +12 -1
- package/es/components/tip/index.vdt.js +25 -5
- package/es/components/tip/styles.js +44 -2
- package/es/components/tooltip/index.spec.js +99 -67
- package/es/components/tooltip/tooltip.d.ts +1 -0
- package/es/components/tooltip/tooltip.js +14 -2
- package/es/components/transfer/index.vdt.js +2 -4
- package/es/components/treeSelect/index.vdt.js +1 -0
- package/es/components/upload/index.vdt.js +4 -1
- package/es/components/upload/styles.js +1 -1
- 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 +27 -8
- package/es/site/data/components/button/demos/group/react.js +2 -2
- package/es/site/data/components/editable/demos/textarea/index.d.ts +16 -0
- package/es/site/data/components/editable/demos/textarea/index.js +21 -0
- package/es/site/data/components/editable/demos/textarea/react.d.ts +17 -0
- package/es/site/data/components/editable/demos/textarea/react.js +72 -0
- package/es/site/data/components/ellipsis/demos/hoverable/index.d.ts +6 -0
- package/es/site/data/components/ellipsis/demos/hoverable/index.js +14 -0
- package/es/site/data/components/ellipsis/demos/hoverable/react.d.ts +5 -0
- package/es/site/data/components/ellipsis/demos/hoverable/react.js +21 -0
- package/es/site/data/components/input/demos/size/react.js +20 -0
- package/es/site/data/components/select/demos/immutable/index.d.ts +2 -2
- package/es/site/data/components/select/demos/immutable/index.js +1 -1
- package/es/site/data/components/select/demos/immutable/react.d.ts +1 -1
- package/es/site/data/components/select/demos/immutable/react.js +5 -5
- 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/ellipsis/index.d.ts +11 -0
- package/es/site/data/components/table/demos/ellipsis/index.js +24 -0
- package/es/site/data/components/table/demos/ellipsis/react.d.ts +10 -0
- package/es/site/data/components/table/demos/ellipsis/react.js +43 -0
- package/es/site/data/components/table/demos/fixFooter/index.d.ts +6 -0
- package/es/site/data/components/table/demos/fixFooter/index.js +14 -0
- package/es/site/data/components/table/demos/fixFooter/react.d.ts +5 -0
- package/es/site/data/components/table/demos/fixFooter/react.js +69 -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/table/demos/tree/react.js +18 -2
- package/es/site/data/components/tip/demos/icon/index.d.ts +9 -0
- package/es/site/data/components/tip/demos/icon/index.js +19 -0
- package/es/site/data/components/tip/demos/icon/react.d.ts +8 -0
- package/es/site/data/components/tip/demos/icon/react.js +54 -0
- package/es/site/data/components/tip/demos/size/index.d.ts +9 -0
- package/es/site/data/components/tip/demos/size/index.js +19 -0
- package/es/site/data/components/tip/demos/size/react.d.ts +8 -0
- package/es/site/data/components/tip/demos/size/react.js +39 -0
- package/es/site/data/components/tooltip/demos/always/react.js +5 -0
- package/es/site/data/components/tooltip/demos/content/index.d.ts +2 -0
- package/es/site/data/components/tooltip/demos/content/index.js +3 -1
- package/es/site/data/components/tooltip/demos/content/react.d.ts +2 -0
- package/es/site/data/components/tooltip/demos/content/react.js +21 -3
- package/es/site/data/components/treeSelect/demos/basic/react.js +2 -1
- package/es/site/data/components/upload/demos/files/index.js +3 -0
- package/es/site/data/components/upload/demos/files/react.js +3 -0
- package/es/site/src/pages/font/index.js +1 -1
- package/es/site/src/pages/font/styles.js +1 -1
- package/index.ts +2 -2
- package/package.json +2 -2
|
@@ -10,9 +10,20 @@ import {Button, Icon} from 'kpc';
|
|
|
10
10
|
|
|
11
11
|
<div>
|
|
12
12
|
<Button disabled>disabled</Button>
|
|
13
|
-
<Button disabled type="none">disabled text</Button>
|
|
14
13
|
<Button disabled icon circle><Icon class="k-icon-search" /></Button>
|
|
15
|
-
<Button
|
|
16
|
-
<Button
|
|
14
|
+
<Button type="primary" disabled>primary</Button>
|
|
15
|
+
<Button type="secondary" disabled>secondary</Button>
|
|
16
|
+
<Button type="warning" disabled>warning</Button>
|
|
17
|
+
<Button type="danger" disabled>danger</Button>
|
|
18
|
+
<Button type="success" disabled>success</Button>
|
|
19
|
+
<Button type="none" disabled>none</Button>
|
|
20
|
+
<Button type="link" disabled>link</Button>
|
|
21
|
+
<Button type="flat" disabled>flat</Button>
|
|
22
|
+
<Button color="red" disabled>custom</Button>
|
|
17
23
|
</div>
|
|
18
24
|
```
|
|
25
|
+
|
|
26
|
+
```styl
|
|
27
|
+
.k-btn
|
|
28
|
+
margin 0 20px 20px 0
|
|
29
|
+
```
|
|
@@ -4,7 +4,7 @@ order: 1
|
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
将`Button`作为`ButtonGroup`的子元素,可以展示按钮组。给`ButtonGroup`添加`vertical`属性,
|
|
7
|
-
|
|
7
|
+
可以使按钮组纵向排列。给`ButtonGroup`添加`separate`属性,可以在按钮之间插入间隔。给`ButtonGroup`添加`checkType`属性,可以使按钮组拥有单选或复选能力。
|
|
8
8
|
|
|
9
9
|
```vdt
|
|
10
10
|
import {Button, ButtonGroup, Icon} from 'kpc';
|
|
@@ -62,13 +62,13 @@ import {Button, ButtonGroup, Icon} from 'kpc';
|
|
|
62
62
|
<Button value="shenzhen" size="small">深圳</Button>
|
|
63
63
|
</ButtonGroup>
|
|
64
64
|
<p>有间隔的按钮组</p>
|
|
65
|
-
<ButtonGroup checkType="radio" v-model="city"
|
|
65
|
+
<ButtonGroup checkType="radio" v-model="city" separate>
|
|
66
66
|
<Button value="beijing">北京</Button>
|
|
67
67
|
<Button value="shanghai">上海</Button>
|
|
68
68
|
<Button value="guangzhou">广州</Button>
|
|
69
69
|
<Button value="shenzhen">深圳</Button>
|
|
70
70
|
</ButtonGroup>
|
|
71
|
-
<ButtonGroup
|
|
71
|
+
<ButtonGroup separate>
|
|
72
72
|
<Button value="beijing" type="primary" disabled>北京</Button>
|
|
73
73
|
<Button value="shanghai">上海</Button>
|
|
74
74
|
<Button value="guangzhou">广州</Button>
|
|
@@ -10,6 +10,7 @@ export interface ButtonGroupProps {
|
|
|
10
10
|
checkType?: 'none' | 'radio' | 'checkbox'
|
|
11
11
|
fluid?: boolean
|
|
12
12
|
seperate?: boolean
|
|
13
|
+
separate?: boolean
|
|
13
14
|
btnWidth?: number | string
|
|
14
15
|
}
|
|
15
16
|
|
|
@@ -19,6 +20,7 @@ const typeDefs: Required<TypeDefs<ButtonGroupProps>> = {
|
|
|
19
20
|
fluid: Boolean,
|
|
20
21
|
checkType: ['none', 'radio', 'checkbox'],
|
|
21
22
|
seperate: Boolean,
|
|
23
|
+
separate: Boolean,
|
|
22
24
|
btnWidth: [Number, String],
|
|
23
25
|
};
|
|
24
26
|
|
|
@@ -35,6 +37,9 @@ export class ButtonGroup extends Component<ButtonGroupProps> {
|
|
|
35
37
|
|
|
36
38
|
init() {
|
|
37
39
|
provide(BUTTON_GROUP, this);
|
|
40
|
+
if (typeof this.get().seperate === 'boolean') {
|
|
41
|
+
console.warn("`seperate` is a typo which will be removed in next version, please using `separate` instead");
|
|
42
|
+
}
|
|
38
43
|
}
|
|
39
44
|
|
|
40
45
|
setValue(v: any): void {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {getRestProps} from '../utils';
|
|
2
2
|
import {makeButtonGroupStyles} from './styles';
|
|
3
3
|
|
|
4
|
-
const {className, vertical, children, fluid, seperate} = this.get();
|
|
4
|
+
const {className, vertical, children, fluid, seperate, separate} = this.get();
|
|
5
5
|
const {k} = this.config;
|
|
6
6
|
|
|
7
7
|
const classNameObj = {
|
|
8
8
|
[`${k}-btns`]: true,
|
|
9
9
|
[`${k}-vertical`]: vertical,
|
|
10
10
|
[`${k}-fluid`]: fluid,
|
|
11
|
-
[`${k}-
|
|
11
|
+
[`${k}-separate`]: typeof separate === 'boolean' ? separate : separate,
|
|
12
12
|
[className]: className,
|
|
13
13
|
[makeButtonGroupStyles(k)]: true,
|
|
14
14
|
};
|
|
@@ -33,7 +33,8 @@ sidebar: doc
|
|
|
33
33
|
| checkType | 指定按钮组为单选或复选类型,此时需要给每个按钮指定`value`来作为选中的值 | `"radio"` | `"checkbox"` | `"none"` | `"none"` |
|
|
34
34
|
| value | 对于`radio`和`checkbox`类型按钮组,该值表示选中的按钮的值,可以使用`v-model`进行双向绑定 | `*` | `undefined` |
|
|
35
35
|
| fluid | 是否宽度100% | `boolean` | `false` |
|
|
36
|
-
| seperate |
|
|
36
|
+
| seperate | 是否展示间隔,此属性为错别字,将会在下个版本被删除,请使用正确的属性 `separate`,若两个属性同时使用,则会优先使用`separate`属性 | `boolean` | `false` |
|
|
37
|
+
| separate | 是否展示间隔 | `boolean` | `false` |
|
|
37
38
|
|
|
38
39
|
# 方法
|
|
39
40
|
|
|
@@ -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
|
|
|
@@ -489,7 +502,7 @@ export const makeButtonGroupStyles = cache(function makeButtonGroupStyles(k: str
|
|
|
489
502
|
}
|
|
490
503
|
|
|
491
504
|
// horizontal
|
|
492
|
-
&:not(.${k}-vertical):not(.${k}-
|
|
505
|
+
&:not(.${k}-vertical):not(.${k}-separate) {
|
|
493
506
|
> .${k}-btn {
|
|
494
507
|
&:not(:first-child) {
|
|
495
508
|
margin-left: -1px;
|
|
@@ -527,7 +540,7 @@ export const makeButtonGroupStyles = cache(function makeButtonGroupStyles(k: str
|
|
|
527
540
|
}
|
|
528
541
|
|
|
529
542
|
// vertical
|
|
530
|
-
&.${k}-vertical:not(.${k}-
|
|
543
|
+
&.${k}-vertical:not(.${k}-separate) {
|
|
531
544
|
flex-direction: column;
|
|
532
545
|
> .${k}-btn {
|
|
533
546
|
&:not(.${k}-btn-icon) {
|
|
@@ -562,8 +575,8 @@ export const makeButtonGroupStyles = cache(function makeButtonGroupStyles(k: str
|
|
|
562
575
|
}
|
|
563
576
|
}
|
|
564
577
|
|
|
565
|
-
//
|
|
566
|
-
&.${k}-
|
|
578
|
+
// separate
|
|
579
|
+
&.${k}-separate {
|
|
567
580
|
gap: 8px;
|
|
568
581
|
}
|
|
569
582
|
`;
|
|
@@ -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
|
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 多行使用
|
|
3
|
+
order: 2
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
当`rows`属性默认为`1`,此时为单行输入,设置成`'auto'`时,组件的高度将会自适应。
|
|
7
|
+
你也可以通过对象`{min, max}`来设置文本框最小和最大的自动调整行数。
|
|
8
|
+
|
|
9
|
+
```vdt
|
|
10
|
+
import {Editable} from 'kpc';
|
|
11
|
+
|
|
12
|
+
<div>
|
|
13
|
+
<Editable v-model="text" ref="__test" rows="auto">
|
|
14
|
+
<i class="ion-ios-location"></i>
|
|
15
|
+
<a href="">{this.get('text')}</a>
|
|
16
|
+
</Editable>
|
|
17
|
+
<br />
|
|
18
|
+
<Editable v-model="text2" rows={5}>
|
|
19
|
+
<i class="ion-ios-location"></i>
|
|
20
|
+
<a href="">{this.get('text2')}</a>
|
|
21
|
+
</Editable>
|
|
22
|
+
<br />
|
|
23
|
+
<Editable v-model="text3" rows={{min: 3, max: 4}}>
|
|
24
|
+
<i class="ion-ios-location"></i>
|
|
25
|
+
<a href="">{this.get('text3')}</a>
|
|
26
|
+
</Editable>
|
|
27
|
+
</div>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```styl
|
|
31
|
+
.ion-ios-location
|
|
32
|
+
margin-right 10px
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
interface Props {
|
|
37
|
+
text?: string
|
|
38
|
+
text2?: string
|
|
39
|
+
text3?: string
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export default class extends Component<Props> {
|
|
43
|
+
static template = template;
|
|
44
|
+
|
|
45
|
+
static defaults() {
|
|
46
|
+
return {
|
|
47
|
+
text: 'editable text auto',
|
|
48
|
+
text2: 'editable text for 5 rows',
|
|
49
|
+
text3: 'editable text for many rows',
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
@@ -17,7 +17,13 @@ sidebar: doc
|
|
|
17
17
|
| tip | 编辑按钮提示文案 | `string` | `"编辑"` |
|
|
18
18
|
| trim | 是否去掉前后空白字符 | `boolean` | `true` |
|
|
19
19
|
| invalid | 是否为验证失败状态 | `boolean` | `false` |
|
|
20
|
-
|
|
20
|
+
| rows | 是否自动折行,以及行数控制 | `string`|`number`|`auto`| `AutoRows` | `1` |
|
|
21
|
+
```ts
|
|
22
|
+
type AutoRows = {
|
|
23
|
+
min?: number
|
|
24
|
+
max?: number
|
|
25
|
+
}
|
|
26
|
+
```
|
|
21
27
|
# 事件
|
|
22
28
|
|
|
23
29
|
| 事件名 | 说明 | 参数 |
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import BasicDemo from '~/components/editable/demos/basic';
|
|
2
2
|
import ValidateDemo from '~/components/editable/demos/validate';
|
|
3
|
+
import TextAreaDemo from '~/components/editable/demos/textarea';
|
|
3
4
|
import {mount, unmount, dispatchEvent, wait} from '../../test/utils';
|
|
4
5
|
import {Editable} from './';
|
|
5
6
|
import {Component, findDomFromVNode} from 'intact';
|
|
@@ -120,4 +121,30 @@ describe('Editable', () => {
|
|
|
120
121
|
input = element.querySelector("input") as HTMLInputElement;
|
|
121
122
|
expect(input.value).to.eql('aa');
|
|
122
123
|
});
|
|
124
|
+
|
|
125
|
+
it('should auto use input or textarea', async () => {
|
|
126
|
+
const [instance, element] = mount(TextAreaDemo);
|
|
127
|
+
const editable = instance.refs.__test as Editable;
|
|
128
|
+
// @ts-ignore
|
|
129
|
+
editable.edit();
|
|
130
|
+
await wait();
|
|
131
|
+
expect(element.innerHTML).to.matchSnapshot();
|
|
132
|
+
|
|
133
|
+
let input = element.querySelector('input') as HTMLInputElement;
|
|
134
|
+
let textarea = element.querySelector('textarea') as HTMLTextAreaElement;
|
|
135
|
+
expect(input).to.be.null;
|
|
136
|
+
|
|
137
|
+
textarea.value = 'test';
|
|
138
|
+
dispatchEvent(textarea, 'blur');
|
|
139
|
+
await wait();
|
|
140
|
+
expect(instance.get('text')).to.eql('test');
|
|
141
|
+
|
|
142
|
+
editable.set('rows', 1);
|
|
143
|
+
await wait();
|
|
144
|
+
// @ts-ignore
|
|
145
|
+
editable.edit();
|
|
146
|
+
await wait();
|
|
147
|
+
let textarea2 = element.querySelector('textarea') as HTMLTextAreaElement;
|
|
148
|
+
expect(textarea2).to.be.null;
|
|
149
|
+
});
|
|
123
150
|
});
|
|
@@ -2,7 +2,7 @@ import {Component, TypeDefs, createRef, nextTick, Children} from 'intact';
|
|
|
2
2
|
import template from './index.vdt';
|
|
3
3
|
import {_$} from '../../i18n';
|
|
4
4
|
import {bind} from '../utils';
|
|
5
|
-
import type {Input} from '../input';
|
|
5
|
+
import type {Input, AutoRows} from '../input';
|
|
6
6
|
import type {Events} from '../types';
|
|
7
7
|
import { useConfigContext } from '../config';
|
|
8
8
|
|
|
@@ -17,6 +17,7 @@ export interface EditableProps<V extends Value = Value> {
|
|
|
17
17
|
tip?: Value,
|
|
18
18
|
trim?: boolean,
|
|
19
19
|
invalid?: boolean,
|
|
20
|
+
rows?: string | number | 'auto' | AutoRows
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
export interface EditableEvents<V extends Value = Value> {
|
|
@@ -33,12 +34,14 @@ const typeDefs: Required<TypeDefs<EditableProps>> = {
|
|
|
33
34
|
tip: [String, Number],
|
|
34
35
|
trim: Boolean,
|
|
35
36
|
invalid: Boolean,
|
|
37
|
+
rows: [String, Number, 'auto', Object],
|
|
36
38
|
};
|
|
37
39
|
|
|
38
40
|
const defaults = (): Partial<EditableProps> => ({
|
|
39
41
|
required: true,
|
|
40
42
|
tip: _$('编辑'),
|
|
41
43
|
trim: true,
|
|
44
|
+
rows: 1
|
|
42
45
|
});
|
|
43
46
|
|
|
44
47
|
const events: Events<EditableEvents> = {
|
|
@@ -3,11 +3,12 @@ import {Input} from '../input';
|
|
|
3
3
|
import {Icon} from '../icon';
|
|
4
4
|
import {makeStyles} from './styles';
|
|
5
5
|
import { Tooltip } from '../tooltip';
|
|
6
|
+
import {isNullOrUndefined} from 'intact-shared';
|
|
6
7
|
|
|
7
8
|
const {
|
|
8
9
|
children, className, editing,
|
|
9
10
|
value, validate, disabled,
|
|
10
|
-
tip, invalid
|
|
11
|
+
tip, invalid, rows
|
|
11
12
|
} = this.get();
|
|
12
13
|
const { k } = this.config;
|
|
13
14
|
|
|
@@ -19,19 +20,27 @@ const classNameObj = {
|
|
|
19
20
|
[className]: className,
|
|
20
21
|
[makeStyles(k)]: true
|
|
21
22
|
};
|
|
23
|
+
const isTextArea = !isNullOrUndefined(rows) && rows != '1';
|
|
24
|
+
|
|
25
|
+
const inputProps = {
|
|
26
|
+
autoWidth: !isTextArea,
|
|
27
|
+
fluid: isTextArea,
|
|
28
|
+
...(isTextArea && { type: 'textarea' }),
|
|
29
|
+
rows,
|
|
30
|
+
...((!isTextArea || rows === 'auto') && {size: 'mini'})
|
|
31
|
+
};
|
|
22
32
|
|
|
23
33
|
<div {...getRestProps(this)} class={classNameObj}>
|
|
24
34
|
<div class="c-ellipsis">
|
|
25
35
|
<template v-if={!editing}>{children}</template>
|
|
26
36
|
<Input v-else
|
|
27
|
-
|
|
28
|
-
defaultValue={value}
|
|
37
|
+
defaultValue={value}
|
|
29
38
|
ev-blur={this.onBlur}
|
|
30
39
|
ev-keydown={this.onKeydown}
|
|
31
40
|
ref={this.inputRef}
|
|
32
41
|
frozenOnInput
|
|
33
42
|
ev-$mounted={this.select}
|
|
34
|
-
|
|
43
|
+
{...inputProps}
|
|
35
44
|
/>
|
|
36
45
|
</div>
|
|
37
46
|
<Tooltip v-if={!disabled && !editing} content={tip}>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: hoverable
|
|
3
|
+
order: 3
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
鼠标离开触发器,弹层就会消失,如果我们需要鼠标能离开触发器并悬浮在弹层上,需要添加`hoverable`属性
|
|
7
|
+
|
|
8
|
+
```vdt
|
|
9
|
+
import {Ellipsis} from 'kpc';
|
|
10
|
+
|
|
11
|
+
<div>
|
|
12
|
+
<Ellipsis style={{width: '50px'}} hoverable>hoverable</Ellipsis>
|
|
13
|
+
</div>
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```styl
|
|
17
|
+
.k-split
|
|
18
|
+
border 1px solid #ccc
|
|
19
|
+
height 200px
|
|
20
|
+
margin-bottom 20px
|
|
21
|
+
.panel
|
|
22
|
+
margin 10px
|
|
23
|
+
```
|
|
@@ -10,6 +10,7 @@ export interface EllipsisProps {
|
|
|
10
10
|
disabled?: boolean,
|
|
11
11
|
position?: Position | 'left' | 'bottom' | 'right' | 'top',
|
|
12
12
|
theme?: 'light' | 'dark',
|
|
13
|
+
hoverable?: boolean
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
const typeDefs: Required<TypeDefs<EllipsisProps>> = {
|
|
@@ -17,11 +18,13 @@ const typeDefs: Required<TypeDefs<EllipsisProps>> = {
|
|
|
17
18
|
disabled: Boolean,
|
|
18
19
|
position: [Object, 'left', 'bottom', 'right', 'top'],
|
|
19
20
|
theme: ['light', 'dark'],
|
|
21
|
+
hoverable: Boolean
|
|
20
22
|
};
|
|
21
23
|
|
|
22
24
|
const defaults = (): Partial<EllipsisProps> => ({
|
|
23
25
|
disabled: false,
|
|
24
|
-
theme: 'light'
|
|
26
|
+
theme: 'light',
|
|
27
|
+
hoverable: false
|
|
25
28
|
});
|
|
26
29
|
|
|
27
30
|
export class Ellipsis extends Component<EllipsisProps> {
|
|
@@ -4,7 +4,8 @@ import {getRestProps, addStyle} from '../utils';
|
|
|
4
4
|
|
|
5
5
|
const {
|
|
6
6
|
children, className, maxLines,
|
|
7
|
-
disabled, position, theme, style
|
|
7
|
+
disabled, position, theme, style,
|
|
8
|
+
hoverable
|
|
8
9
|
} = this.get();
|
|
9
10
|
const { k } = this.config;
|
|
10
11
|
|
|
@@ -30,6 +31,7 @@ const wrapper = <div class={{
|
|
|
30
31
|
position={position}
|
|
31
32
|
theme={theme}
|
|
32
33
|
class={className}
|
|
34
|
+
hoverable={hoverable}
|
|
33
35
|
>
|
|
34
36
|
{wrapper}
|
|
35
37
|
<b:content>{children}</b:content>
|
|
@@ -3,7 +3,7 @@ title: 尺寸
|
|
|
3
3
|
order: 2
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
添加`size`属性,定义如下尺寸:`large`, `default`,`small`,`mini`
|
|
6
|
+
添加`size`属性,定义如下尺寸:`large`, `default`,`small`,`mini`;`textarea`使用`size`时,仅支持`rows`为`auto`
|
|
7
7
|
|
|
8
8
|
```vdt
|
|
9
9
|
import {Input, Button, Icon} from 'kpc';
|
|
@@ -30,6 +30,14 @@ import {Input, Button, Icon} from 'kpc';
|
|
|
30
30
|
</Input>
|
|
31
31
|
<br />
|
|
32
32
|
<Input value="mini" size="mini" />
|
|
33
|
+
<br />
|
|
34
|
+
<Input value="textarea auto mini" size="mini" type="textarea" rows="auto"/>
|
|
35
|
+
<br />
|
|
36
|
+
<Input value="textarea auto small" size="small" type="textarea" rows="auto"/>
|
|
37
|
+
<br />
|
|
38
|
+
<Input value="textarea auto default" size="default" type="textarea" rows="auto"/>
|
|
39
|
+
<br />
|
|
40
|
+
<Input value="textarea auto large" size="large" type="textarea" rows="auto"/>
|
|
33
41
|
</div>
|
|
34
42
|
```
|
|
35
43
|
|
|
@@ -4,7 +4,12 @@ import {deepDefaults, sizes, Sizes} from '../../styles/utils';
|
|
|
4
4
|
import '../../styles/global';
|
|
5
5
|
import {Input} from './';
|
|
6
6
|
import { cache } from '../utils';
|
|
7
|
-
|
|
7
|
+
const textareaSize = {
|
|
8
|
+
mini: '0',
|
|
9
|
+
small: '1px',
|
|
10
|
+
default: '5px',
|
|
11
|
+
large: '7px'
|
|
12
|
+
}
|
|
8
13
|
const defaults = deepDefaults(
|
|
9
14
|
{
|
|
10
15
|
get transition() { return theme.transition.middle },
|
|
@@ -55,14 +60,16 @@ const defaults = deepDefaults(
|
|
|
55
60
|
},
|
|
56
61
|
sizes.reduce((memo, size) => {
|
|
57
62
|
const styles = theme[size];
|
|
63
|
+
const textareaStyles = textareaSize[size];
|
|
58
64
|
memo[size] = {
|
|
59
65
|
get fontSize() { return styles.fontSize },
|
|
60
66
|
get height() { return styles.height },
|
|
61
67
|
get paddingGap() { return styles.padding },
|
|
68
|
+
get padding() {return textareaStyles }
|
|
62
69
|
}
|
|
63
70
|
|
|
64
71
|
return memo;
|
|
65
|
-
}, {} as Record<Sizes, {fontSize: string, height: string, paddingGap: string}>),
|
|
72
|
+
}, {} as Record<Sizes, {fontSize: string, height: string, paddingGap: string, padding: string}>),
|
|
66
73
|
)
|
|
67
74
|
|
|
68
75
|
let input: typeof defaults;
|
|
@@ -255,6 +262,9 @@ export const makeStyles = cache(function makeStyles(k: string) {
|
|
|
255
262
|
.${k}-input-wrapper {
|
|
256
263
|
height: ${styles.height};
|
|
257
264
|
padding: 0 ${styles.paddingGap};
|
|
265
|
+
.${k}-textarea {
|
|
266
|
+
padding: ${styles.padding} ${styles.paddingGap};
|
|
267
|
+
}
|
|
258
268
|
}
|
|
259
269
|
`;
|
|
260
270
|
|
|
@@ -7,8 +7,9 @@ order: 14
|
|
|
7
7
|
|
|
8
8
|
```vdt
|
|
9
9
|
import {Select, Option, OptionGroup} from 'kpc';
|
|
10
|
+
|
|
10
11
|
<div>
|
|
11
|
-
<Select v-model="
|
|
12
|
+
<Select v-model="days" multiple filterable clearable>
|
|
12
13
|
<Option value="Monday">星期一</Option>
|
|
13
14
|
<Option value="Tuesday" disabled>星期二</Option>
|
|
14
15
|
<Option value="Wednesday">星期三</Option>
|
|
@@ -17,21 +18,21 @@ import {Select, Option, OptionGroup} from 'kpc';
|
|
|
17
18
|
<Option value="Saturday">星期六</Option>
|
|
18
19
|
<Option value="Sunday">星期天</Option>
|
|
19
20
|
</Select>
|
|
20
|
-
You selected: {JSON.stringify(this.get('
|
|
21
|
+
You selected: {JSON.stringify(this.get('days'))}
|
|
21
22
|
</div>
|
|
22
23
|
```
|
|
23
24
|
|
|
24
25
|
```ts
|
|
25
26
|
interface Props {
|
|
26
|
-
|
|
27
|
+
days?: string[]
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
export default class extends Component {
|
|
30
|
+
export default class extends Component<Props> {
|
|
30
31
|
static template = template;
|
|
31
32
|
static defaults() {
|
|
32
33
|
return {
|
|
33
|
-
|
|
34
|
+
days: ['Tuesday', 'Sunday', 'Wednesday'],
|
|
34
35
|
} as Props;
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
|
-
```
|
|
38
|
+
```
|
|
@@ -9,6 +9,7 @@ import {Tooltip} from '../tooltip';
|
|
|
9
9
|
import {Component} from 'intact';
|
|
10
10
|
import {Select, Option} from '../select';
|
|
11
11
|
import SearchableDemo from '~/components/select/demos/searchable';
|
|
12
|
+
import ImmutableDemo from '~/components/select/demos/immutable';
|
|
12
13
|
|
|
13
14
|
describe('Select', () => {
|
|
14
15
|
afterEach((done) => {
|
|
@@ -288,6 +289,36 @@ describe('Select', () => {
|
|
|
288
289
|
expect(instance.get('days')).include('Monday')
|
|
289
290
|
});
|
|
290
291
|
|
|
292
|
+
it('disabled option does not allow clearable and close', async () => {
|
|
293
|
+
const [instance, element] = mount(ImmutableDemo);
|
|
294
|
+
|
|
295
|
+
instance.set('days', ['Tuesday', 'Friday']);
|
|
296
|
+
await wait();
|
|
297
|
+
expect(element.outerHTML).to.matchSnapshot();
|
|
298
|
+
const [clear1] = element.querySelectorAll<HTMLElement>('.k-select-clear');
|
|
299
|
+
clear1.click();
|
|
300
|
+
await wait();
|
|
301
|
+
const [tag1] = element.querySelectorAll<HTMLElement>('.k-tag');
|
|
302
|
+
expect(tag1.className).not.contain("k-closable");
|
|
303
|
+
expect(instance.get('days')).to.eql(['Tuesday', 'Friday']);
|
|
304
|
+
|
|
305
|
+
instance.set('days', ['Monday', 'Tuesday']);
|
|
306
|
+
await wait();
|
|
307
|
+
const [clear2] = element.querySelectorAll<HTMLElement>('.k-select-clear');
|
|
308
|
+
clear2.click();
|
|
309
|
+
await wait();
|
|
310
|
+
expect(instance.get('days')).to.eql(['Tuesday']);
|
|
311
|
+
|
|
312
|
+
instance.set('days', ['Monday', 'Wednesday']);
|
|
313
|
+
await wait();
|
|
314
|
+
const [clear3] = element.querySelectorAll<HTMLElement>('.k-select-clear');
|
|
315
|
+
clear3.click();
|
|
316
|
+
await wait();
|
|
317
|
+
expect(instance.get('days')).to.eql([]);
|
|
318
|
+
|
|
319
|
+
// expect(clear).to.be.null;
|
|
320
|
+
});
|
|
321
|
+
|
|
291
322
|
// it('should trigger change event correctly', async () => {
|
|
292
323
|
// const spy = sinon.spy();
|
|
293
324
|
|