@king-design/vue 3.4.3-beta.1 → 3.4.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/__tests__/__snapshots__/Vue Next Demos.md +279 -217
- package/__tests__/components/editable.spec.ts +1 -1
- package/__tests__/components/table.spec.ts +54 -0
- package/components/button/index.vdt.js +1 -1
- package/components/button/styles.js +3 -3
- package/components/diagram/shapes/callout.d.ts +1 -1
- package/components/diagram/shapes/circle.d.ts +1 -1
- package/components/diagram/shapes/document.d.ts +1 -1
- package/components/diagram/shapes/ellipse.d.ts +1 -1
- package/components/diagram/shapes/hexagon.d.ts +1 -1
- package/components/diagram/shapes/image.d.ts +1 -1
- package/components/diagram/shapes/parallelogram.d.ts +1 -1
- package/components/diagram/shapes/rectangle.d.ts +1 -1
- package/components/diagram/shapes/square.d.ts +1 -1
- package/components/diagram/shapes/text.d.ts +1 -1
- package/components/dialog/styles.js +3 -3
- package/components/dropdown/item.js +5 -2
- package/components/editable/index.d.ts +2 -0
- package/components/editable/index.js +4 -2
- package/components/editable/index.spec.js +39 -0
- package/components/editable/index.vdt.js +17 -6
- package/components/editable/styles.d.ts +1 -0
- package/components/editable/styles.js +3 -0
- package/components/ellipsis/index.d.ts +1 -0
- package/components/ellipsis/index.js +4 -2
- package/components/ellipsis/index.vdt.js +3 -1
- package/components/input/styles.js +11 -1
- package/components/select/base.d.ts +4 -0
- package/components/select/base.js +11 -1
- package/components/select/base.vdt.js +2 -1
- package/components/select/index.spec.js +47 -0
- package/components/select/useImmutable.d.ts +4 -0
- package/components/select/useImmutable.js +45 -0
- package/components/switch/styles.js +1 -1
- package/components/table/cell.d.ts +1 -0
- package/components/table/cell.vdt.js +14 -3
- package/components/table/column.d.ts +1 -0
- package/components/table/column.js +1 -0
- package/components/table/row.d.ts +2 -1
- package/components/table/row.js +24 -15
- package/components/table/row.vdt.js +3 -1
- package/components/table/styles.js +2 -2
- package/components/table/table.d.ts +3 -0
- package/components/table/table.js +3 -1
- package/components/table/table.vdt.js +19 -3
- package/components/table/useTree.d.ts +1 -1
- package/components/table/useTree.js +30 -2
- package/components/tooltip/index.spec.js +99 -67
- package/components/tooltip/tooltip.d.ts +1 -0
- package/components/tooltip/tooltip.js +9 -1
- package/components/treeSelect/index.vdt.js +1 -0
- package/index.d.ts +2 -2
- package/index.js +2 -2
- package/package.json +2 -2
|
@@ -35,7 +35,7 @@ describe('Editable', () => {
|
|
|
35
35
|
container.querySelector<HTMLDivElement>('.k-icon')!.click();
|
|
36
36
|
await wait();
|
|
37
37
|
|
|
38
|
-
const input = container.querySelector('.k-input
|
|
38
|
+
const input = container.querySelector('.k-input textarea') as HTMLTextAreaElement;
|
|
39
39
|
expect(input.selectionStart).to.eql(0);
|
|
40
40
|
expect(input.selectionEnd).to.eql(1);
|
|
41
41
|
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import {createApp, render} from 'vue';
|
|
2
|
+
import {mount, unmount, dispatchEvent, getElement, wait} from '@/test/utils';
|
|
3
|
+
import {Table, TableColumn, Input} from '../../';
|
|
4
|
+
|
|
5
|
+
describe('Table', () => {
|
|
6
|
+
it('should update Input in children rows', async () => {
|
|
7
|
+
const container = document.createElement('div');
|
|
8
|
+
document.body.appendChild(container);
|
|
9
|
+
const vue = createApp({
|
|
10
|
+
template: `
|
|
11
|
+
<Table ref="table" :data="data" checkType="none">
|
|
12
|
+
<TableColumn key="discount" title="折扣">
|
|
13
|
+
<template v-slot="[data]">
|
|
14
|
+
<Input v-model="data.discount" />
|
|
15
|
+
</template>
|
|
16
|
+
</TableColumn>
|
|
17
|
+
</Table>
|
|
18
|
+
`,
|
|
19
|
+
components: {
|
|
20
|
+
Table, TableColumn, Input
|
|
21
|
+
},
|
|
22
|
+
data() {
|
|
23
|
+
return {
|
|
24
|
+
data: [
|
|
25
|
+
{
|
|
26
|
+
discount: "3.5",
|
|
27
|
+
children: [
|
|
28
|
+
{
|
|
29
|
+
discount: "4.5",
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}).mount(container);
|
|
37
|
+
|
|
38
|
+
const table = vue.$refs.table as Table;
|
|
39
|
+
table.set('spreadKeys', [0]);
|
|
40
|
+
await wait();
|
|
41
|
+
|
|
42
|
+
const [, input] = document.querySelectorAll('input');
|
|
43
|
+
dispatchEvent(input, 'focus');
|
|
44
|
+
input.value = 'a';
|
|
45
|
+
dispatchEvent(input, 'input')
|
|
46
|
+
dispatchEvent(input, 'blur');
|
|
47
|
+
|
|
48
|
+
await wait();
|
|
49
|
+
expect(input.value).to.eql('a');
|
|
50
|
+
|
|
51
|
+
render(null, container);
|
|
52
|
+
document.body.removeChild(container);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -55,7 +55,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
|
-
var classNameObj = (_classNameObj = {}, _classNameObj[cls('btn')] = true, _classNameObj[cls(size)] = size !== 'default', _classNameObj[cls(type)] = !color, _classNameObj[cls("btn-icon")] = icon, _classNameObj[className] = className, _classNameObj[cls('circle')] = circle, _classNameObj[cls('loading')] = loading, _classNameObj[cls('fluid')] = fluid, _classNameObj[cls('active')] = checked, _classNameObj[cls('
|
|
58
|
+
var classNameObj = (_classNameObj = {}, _classNameObj[cls('btn')] = true, _classNameObj[cls(size)] = size !== 'default', _classNameObj[cls(type)] = !color, _classNameObj[cls("btn-icon")] = icon, _classNameObj[className] = className, _classNameObj[cls('circle')] = circle, _classNameObj[cls('loading')] = loading, _classNameObj[cls('fluid')] = fluid, _classNameObj[cls('active')] = checked, _classNameObj[cls('custom')] = color, _classNameObj[cls('disabled')] = disabled || loading, _classNameObj[cls('ghost')] = ghost, _classNameObj[makeButtonStyles(k, iconSide, color)] = true, _classNameObj);
|
|
59
59
|
var loadingIcon = _$cc(Icon, {
|
|
60
60
|
'className': _$cn("ion-load-c " + k + "-icon-loading"),
|
|
61
61
|
'size': size /*loadingSizeMap[size]*/,
|
|
@@ -11,7 +11,7 @@ var btnStyles = {
|
|
|
11
11
|
return theme.color.text;
|
|
12
12
|
},
|
|
13
13
|
bgColor: '#fff',
|
|
14
|
-
lineHeight: '1
|
|
14
|
+
lineHeight: '1',
|
|
15
15
|
get padding() {
|
|
16
16
|
return "0 16px";
|
|
17
17
|
},
|
|
@@ -199,8 +199,8 @@ export var makeButtonStyles = cache(function makeButtonStyles(k, iconSide, color
|
|
|
199
199
|
// extract static styles to individual css method for performance
|
|
200
200
|
css("display:inline-flex;align-items:center;justify-content:center;cursor:pointer;height:", button.height, ";padding:", button.padding, ";outline:none;vertical-align:middle;color:", button.color, ";background:", button.bgColor, ";border-radius:", button.borderRadius, ";border:1px solid ", button.borderColor, ";font-size:", button.fontSize, ";white-space:nowrap;transition:all ", button.transition, ";line-height:", button.lineHeight, ";.", k, "-icon{color:inherit;}&.", k, "-default,&.", k, "-none,&.", k, "-flat{.", k, "-icon{color:", theme.color.lightBlack, ";}&:hover{.", k, "-icon{color:inherit;}}}&:hover,&:focus{border-color:", button.hoverBorderColor, ";color:", button.hoverColor, ";}&:active{background:", palette(theme.color.primary, -4), ";}.", k, "-button-input{position:absolute;opacity:0;width:0;height:0;}", _mapInstanceProperty(types).call(types, function (type) {
|
|
201
201
|
var typeStyles = button[type];
|
|
202
|
-
return /*#__PURE__*/css("&.", k, "-", type, "{background:", typeStyles.bgColor, ";color:", typeStyles.color, ";border-color:", typeStyles.borderColor, ";&:hover,&:focus{background:", palette(typeStyles.bgColor, -1), ";border-color:", typeStyles.hoverBorderColor, ";color:", typeStyles.color, ";}&:active{background:", palette(typeStyles.bgColor, 1), ";border-color:", palette(typeStyles.borderColor, 1), ";}}");
|
|
203
|
-
}), "&.", k, "-secondary{color:", secondary.color, ";border-color:", secondary.borderColor, ";&:hover,&:focus{background:", secondary.hoverBgColor, ";}&:active{background:", secondary.activeBgColor, ";}}", color && /*#__PURE__*/css("&.", k, "-custom{color:", color, ";border-color:", color, ";&:hover,&:focus{background:", palette(color, -4), ";}&:active{background:", palette(color, -3), ";}}"), " &.", k, "-link{color:", link.color, ";&:hover{color:", link.hoverColor, ";background:", link.hoverBgColor, ";}}&.", k, "-none,&.", k, "-link,&.", k, "-flat{background:transparent;&,&:hover{border:none;}&.", k, "-active{color:", theme.color.primary, ";}}&.", k, "-none:hover{background:", button.none.hoverBgColor, ";}&.", k, "-flat{background:", button.none.hoverBgColor, ";}&.", k, "-disabled{.", k, "-icon{color:inherit;}&,&:hover{color:", button.disabled.color, ";background:", button.disabled.bgColor, ";border-color:", button.disabled.borderColor, ";cursor:not-allowed;}}&.", k, "-none.", k, "-disabled,&.", k, "-link.", k, "-disabled{&,&:hover{background:transparent;}}", _mapInstanceProperty(sizes).call(sizes, function (size) {
|
|
202
|
+
return /*#__PURE__*/css("&.", k, "-", type, "{background:", typeStyles.bgColor, ";color:", typeStyles.color, ";border-color:", typeStyles.borderColor, ";&:hover,&:focus{background:", palette(typeStyles.bgColor, -1), ";border-color:", typeStyles.hoverBorderColor, ";color:", typeStyles.color, ";}&:active{background:", palette(typeStyles.bgColor, 1), ";border-color:", palette(typeStyles.borderColor, 1), ";}&.", k, "-disabled{&,&:hover{background:", palette(typeStyles.bgColor, -2), ";color:", palette(typeStyles.color, -2), ";border-color:", palette(typeStyles.borderColor, -2), ";}}}");
|
|
203
|
+
}), "&.", k, "-secondary{color:", secondary.color, ";border-color:", secondary.borderColor, ";&:hover,&:focus{background:", secondary.hoverBgColor, ";}&:active{background:", secondary.activeBgColor, ";}&.", k, "-disabled{border:none;}}", color && /*#__PURE__*/css("&.", k, "-custom{color:", color, ";border-color:", color, ";&:hover,&:focus{background:", palette(color, -4), ";}&:active{background:", palette(color, -3), ";}&.", k, "-disabled{border:none;}}"), " &.", k, "-link{color:", link.color, ";&:hover{color:", link.hoverColor, ";background:", link.hoverBgColor, ";}}&.", k, "-none,&.", k, "-link,&.", k, "-flat{background:transparent;&,&:hover{border:none;}&.", k, "-active{color:", theme.color.primary, ";}}&.", k, "-none:hover{background:", button.none.hoverBgColor, ";}&.", k, "-flat{background:", button.none.hoverBgColor, ";}&.", k, "-disabled{.", k, "-icon{color:inherit;}&,&:hover{color:", button.disabled.color, ";background:", button.disabled.bgColor, ";border-color:", button.disabled.borderColor, ";cursor:not-allowed;}}&.", k, "-none.", k, "-disabled,&.", k, "-link.", k, "-disabled{&,&:hover{background:transparent;}}", _mapInstanceProperty(sizes).call(sizes, function (size) {
|
|
204
204
|
var styles = button[size];
|
|
205
205
|
return /*#__PURE__*/css("&.", k, "-", size, "{font-size:", styles.fontSize, ";height:", styles.height, ";padding:", styles.padding, ";&.", k, "-btn-icon{width:", styles.height, ";}}");
|
|
206
206
|
}), "&.", k, "-btn-icon{width:", button.height, ";padding:0;.", k, "-icon{margin:0;}}&.", k, "-fluid{width:100%;padding:0;}&.", k, "-circle{border-radius:calc(", button.large.height, " / 2);}&.", k, "-loading{", _mapInstanceProperty(types).call(types, function (type) {
|
|
@@ -12,7 +12,7 @@ export declare class DCallout extends DShape {
|
|
|
12
12
|
rotatable?: boolean | undefined;
|
|
13
13
|
editable?: boolean | undefined;
|
|
14
14
|
connectable?: boolean | undefined;
|
|
15
|
-
strokeStyle?: "
|
|
15
|
+
strokeStyle?: "dashed" | "dotted" | "solid" | undefined;
|
|
16
16
|
label?: string | number | undefined;
|
|
17
17
|
style?: Record<string, string | number> | undefined;
|
|
18
18
|
data?: any;
|
|
@@ -12,7 +12,7 @@ export declare class DCircle extends DShape {
|
|
|
12
12
|
rotatable?: boolean | undefined;
|
|
13
13
|
editable?: boolean | undefined;
|
|
14
14
|
connectable?: boolean | undefined;
|
|
15
|
-
strokeStyle?: "
|
|
15
|
+
strokeStyle?: "dashed" | "dotted" | "solid" | undefined;
|
|
16
16
|
label?: string | number | undefined;
|
|
17
17
|
style?: Record<string, string | number> | undefined;
|
|
18
18
|
data?: any;
|
|
@@ -12,7 +12,7 @@ export declare class DDocument extends DShape {
|
|
|
12
12
|
rotatable?: boolean | undefined;
|
|
13
13
|
editable?: boolean | undefined;
|
|
14
14
|
connectable?: boolean | undefined;
|
|
15
|
-
strokeStyle?: "
|
|
15
|
+
strokeStyle?: "dashed" | "dotted" | "solid" | undefined;
|
|
16
16
|
label?: string | number | undefined;
|
|
17
17
|
style?: Record<string, string | number> | undefined;
|
|
18
18
|
data?: any;
|
|
@@ -12,7 +12,7 @@ export declare class DEllipse extends DShape {
|
|
|
12
12
|
rotatable?: boolean | undefined;
|
|
13
13
|
editable?: boolean | undefined;
|
|
14
14
|
connectable?: boolean | undefined;
|
|
15
|
-
strokeStyle?: "
|
|
15
|
+
strokeStyle?: "dashed" | "dotted" | "solid" | undefined;
|
|
16
16
|
label?: string | number | undefined;
|
|
17
17
|
style?: Record<string, string | number> | undefined;
|
|
18
18
|
data?: any;
|
|
@@ -12,7 +12,7 @@ export declare class DHexagon extends DShape {
|
|
|
12
12
|
rotatable?: boolean | undefined;
|
|
13
13
|
editable?: boolean | undefined;
|
|
14
14
|
connectable?: boolean | undefined;
|
|
15
|
-
strokeStyle?: "
|
|
15
|
+
strokeStyle?: "dashed" | "dotted" | "solid" | undefined;
|
|
16
16
|
label?: string | number | undefined;
|
|
17
17
|
style?: Record<string, string | number> | undefined;
|
|
18
18
|
data?: any;
|
|
@@ -18,7 +18,7 @@ export declare class DImage extends DShape<DImageProps> {
|
|
|
18
18
|
rotatable?: boolean | undefined;
|
|
19
19
|
editable?: boolean | undefined;
|
|
20
20
|
connectable?: boolean | undefined;
|
|
21
|
-
strokeStyle?: "
|
|
21
|
+
strokeStyle?: "dashed" | "dotted" | "solid" | undefined;
|
|
22
22
|
label?: string | number | undefined;
|
|
23
23
|
style?: Record<string, string | number> | undefined;
|
|
24
24
|
data?: any;
|
|
@@ -12,7 +12,7 @@ export declare class DParallelogram extends DShape {
|
|
|
12
12
|
rotatable?: boolean | undefined;
|
|
13
13
|
editable?: boolean | undefined;
|
|
14
14
|
connectable?: boolean | undefined;
|
|
15
|
-
strokeStyle?: "
|
|
15
|
+
strokeStyle?: "dashed" | "dotted" | "solid" | undefined;
|
|
16
16
|
label?: string | number | undefined;
|
|
17
17
|
style?: Record<string, string | number> | undefined;
|
|
18
18
|
data?: any;
|
|
@@ -18,7 +18,7 @@ export declare class DRectangle extends DShape<DRectangleProps> {
|
|
|
18
18
|
rotatable?: boolean | undefined;
|
|
19
19
|
editable?: boolean | undefined;
|
|
20
20
|
connectable?: boolean | undefined;
|
|
21
|
-
strokeStyle?: "
|
|
21
|
+
strokeStyle?: "dashed" | "dotted" | "solid" | undefined;
|
|
22
22
|
label?: string | number | undefined;
|
|
23
23
|
style?: Record<string, string | number> | undefined;
|
|
24
24
|
data?: any;
|
|
@@ -13,7 +13,7 @@ export declare class DSquare extends DRectangle {
|
|
|
13
13
|
rotatable?: boolean | undefined;
|
|
14
14
|
editable?: boolean | undefined;
|
|
15
15
|
connectable?: boolean | undefined;
|
|
16
|
-
strokeStyle?: "
|
|
16
|
+
strokeStyle?: "dashed" | "dotted" | "solid" | undefined;
|
|
17
17
|
label?: string | number | undefined;
|
|
18
18
|
style?: Record<string, string | number> | undefined;
|
|
19
19
|
data?: any;
|
|
@@ -12,7 +12,7 @@ export declare class DText extends DShape {
|
|
|
12
12
|
rotatable?: boolean | undefined;
|
|
13
13
|
editable?: boolean | undefined;
|
|
14
14
|
connectable?: boolean | undefined;
|
|
15
|
-
strokeStyle?: "
|
|
15
|
+
strokeStyle?: "dashed" | "dotted" | "solid" | undefined;
|
|
16
16
|
label?: string | number | undefined;
|
|
17
17
|
style?: Record<string, string | number> | undefined;
|
|
18
18
|
data?: any;
|
|
@@ -58,11 +58,11 @@ var defaults = {
|
|
|
58
58
|
padding: "0 24px",
|
|
59
59
|
bodyMarginTop: "-25px",
|
|
60
60
|
tipIconMarginBottom: '10px',
|
|
61
|
-
tipIconFontSize: '
|
|
62
|
-
tipIconLineHeight: '
|
|
61
|
+
tipIconFontSize: '24px',
|
|
62
|
+
tipIconLineHeight: '24px',
|
|
63
63
|
// with title
|
|
64
64
|
titleFontWeight: '500',
|
|
65
|
-
titleTipIconFontSize: '
|
|
65
|
+
titleTipIconFontSize: '24px',
|
|
66
66
|
titleFontSize: '14px',
|
|
67
67
|
wrapperPaddingLeft: '8px',
|
|
68
68
|
titleBodyMarginTop: '-36px'
|
|
@@ -50,8 +50,11 @@ export var DropdownItem = /*#__PURE__*/function (_Component) {
|
|
|
50
50
|
// hide all dropdowns
|
|
51
51
|
var dropdown = this.dropdown;
|
|
52
52
|
do {
|
|
53
|
-
dropdown
|
|
54
|
-
|
|
53
|
+
if (!dropdown.$isTooltip) {
|
|
54
|
+
dropdown.hide(true);
|
|
55
|
+
}
|
|
56
|
+
dropdown = dropdown.dropdown;
|
|
57
|
+
} while (dropdown);
|
|
55
58
|
}
|
|
56
59
|
};
|
|
57
60
|
_proto.hasSubMenu = function hasSubMenu() {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Component, TypeDefs } from 'intact-vue-next';
|
|
2
|
+
import type { AutoRows } from '../input';
|
|
2
3
|
import type { Events } from '../types';
|
|
3
4
|
type Value = string | number;
|
|
4
5
|
export interface EditableProps<V extends Value = Value> {
|
|
@@ -10,6 +11,7 @@ export interface EditableProps<V extends Value = Value> {
|
|
|
10
11
|
tip?: Value;
|
|
11
12
|
trim?: boolean;
|
|
12
13
|
invalid?: boolean;
|
|
14
|
+
rows?: string | number | 'auto' | AutoRows;
|
|
13
15
|
}
|
|
14
16
|
export interface EditableEvents<V extends Value = Value> {
|
|
15
17
|
error: [string];
|
|
@@ -15,13 +15,15 @@ var typeDefs = {
|
|
|
15
15
|
disabled: Boolean,
|
|
16
16
|
tip: [String, Number],
|
|
17
17
|
trim: Boolean,
|
|
18
|
-
invalid: Boolean
|
|
18
|
+
invalid: Boolean,
|
|
19
|
+
rows: [String, Number, 'auto', Object]
|
|
19
20
|
};
|
|
20
21
|
var defaults = function defaults() {
|
|
21
22
|
return {
|
|
22
23
|
required: true,
|
|
23
24
|
tip: _$('编辑'),
|
|
24
|
-
trim: true
|
|
25
|
+
trim: true,
|
|
26
|
+
rows: 1
|
|
25
27
|
};
|
|
26
28
|
};
|
|
27
29
|
var events = {
|
|
@@ -4,6 +4,7 @@ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/con
|
|
|
4
4
|
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
5
5
|
import BasicDemo from '~/components/editable/demos/basic';
|
|
6
6
|
import ValidateDemo from '~/components/editable/demos/validate';
|
|
7
|
+
import TextAreaDemo from '~/components/editable/demos/textarea';
|
|
7
8
|
import { mount, unmount, dispatchEvent, wait } from '../../test/utils';
|
|
8
9
|
import { Editable } from './';
|
|
9
10
|
import { Component, findDomFromVNode } from 'intact-vue-next';
|
|
@@ -183,4 +184,42 @@ describe('Editable', function () {
|
|
|
183
184
|
}
|
|
184
185
|
}, _callee3);
|
|
185
186
|
})));
|
|
187
|
+
it('should auto use input or textarea', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
188
|
+
var _mount4, instance, element, editable, input, textarea, textarea2;
|
|
189
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context5) {
|
|
190
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
191
|
+
case 0:
|
|
192
|
+
_mount4 = mount(TextAreaDemo), instance = _mount4[0], element = _mount4[1];
|
|
193
|
+
editable = instance.refs.__test; // @ts-ignore
|
|
194
|
+
editable.edit();
|
|
195
|
+
_context5.next = 5;
|
|
196
|
+
return wait();
|
|
197
|
+
case 5:
|
|
198
|
+
expect(element.innerHTML).to.matchSnapshot();
|
|
199
|
+
input = element.querySelector('input');
|
|
200
|
+
textarea = element.querySelector('textarea');
|
|
201
|
+
expect(input).to.be.null;
|
|
202
|
+
textarea.value = 'test';
|
|
203
|
+
dispatchEvent(textarea, 'blur');
|
|
204
|
+
_context5.next = 13;
|
|
205
|
+
return wait();
|
|
206
|
+
case 13:
|
|
207
|
+
expect(instance.get('text')).to.eql('test');
|
|
208
|
+
editable.set('rows', 1);
|
|
209
|
+
_context5.next = 17;
|
|
210
|
+
return wait();
|
|
211
|
+
case 17:
|
|
212
|
+
// @ts-ignore
|
|
213
|
+
editable.edit();
|
|
214
|
+
_context5.next = 20;
|
|
215
|
+
return wait();
|
|
216
|
+
case 20:
|
|
217
|
+
textarea2 = element.querySelector('textarea');
|
|
218
|
+
expect(textarea2).to.be.null;
|
|
219
|
+
case 22:
|
|
220
|
+
case "end":
|
|
221
|
+
return _context5.stop();
|
|
222
|
+
}
|
|
223
|
+
}, _callee4);
|
|
224
|
+
})));
|
|
186
225
|
});
|
|
@@ -5,6 +5,7 @@ import { Input } from '../input';
|
|
|
5
5
|
import { Icon } from '../icon';
|
|
6
6
|
import { makeStyles } from './styles';
|
|
7
7
|
import { Tooltip } from '../tooltip';
|
|
8
|
+
import { isNullOrUndefined } from 'intact-shared';
|
|
8
9
|
export default function ($props, $blocks, $__proto__) {
|
|
9
10
|
var _classNameObj;
|
|
10
11
|
$blocks || ($blocks = {});
|
|
@@ -18,21 +19,31 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
18
19
|
validate = _this$get.validate,
|
|
19
20
|
disabled = _this$get.disabled,
|
|
20
21
|
tip = _this$get.tip,
|
|
21
|
-
invalid = _this$get.invalid
|
|
22
|
+
invalid = _this$get.invalid,
|
|
23
|
+
rows = _this$get.rows;
|
|
22
24
|
var k = this.config.k;
|
|
23
25
|
var classNameObj = (_classNameObj = {}, _classNameObj[k + "-editable"] = true, _classNameObj[k + "-editing"] = editing, _classNameObj[k + "-disabled"] = disabled, _classNameObj[k + "-invalid"] = invalid, _classNameObj[className] = className, _classNameObj[makeStyles(k)] = true, _classNameObj);
|
|
26
|
+
var isTextArea = !isNullOrUndefined(rows) && rows != '1';
|
|
27
|
+
var inputProps = _extends({
|
|
28
|
+
autoWidth: !isTextArea,
|
|
29
|
+
fluid: isTextArea
|
|
30
|
+
}, isTextArea && {
|
|
31
|
+
type: 'textarea'
|
|
32
|
+
}, {
|
|
33
|
+
rows: rows
|
|
34
|
+
}, (!isTextArea || rows === 'auto') && {
|
|
35
|
+
size: 'mini'
|
|
36
|
+
});
|
|
24
37
|
return _$cv('div', _extends({}, getRestProps(this), {
|
|
25
38
|
'className': _$cn(classNameObj)
|
|
26
|
-
}), [_$ce(2, 'div', !editing ? children : _$cc(Input, {
|
|
27
|
-
'size': 'mini',
|
|
39
|
+
}), [_$ce(2, 'div', !editing ? children : _$cc(Input, _extends({
|
|
28
40
|
'defaultValue': value,
|
|
29
41
|
'ev-blur': this.onBlur,
|
|
30
42
|
'ev-keydown': this.onKeydown,
|
|
31
43
|
'ref': this.inputRef,
|
|
32
44
|
'frozenOnInput': true,
|
|
33
|
-
'ev-$mounted': this.select
|
|
34
|
-
|
|
35
|
-
}, null, this.inputRef), 0, 'c-ellipsis'), !disabled && !editing ? _$cc(Tooltip, {
|
|
45
|
+
'ev-$mounted': this.select
|
|
46
|
+
}, inputProps), null, this.inputRef), 0, 'c-ellipsis'), !disabled && !editing ? _$cc(Tooltip, {
|
|
36
47
|
'content': tip,
|
|
37
48
|
'children': _$cc(Icon, {
|
|
38
49
|
'className': _$cn(k + "-icon-edit " + k + "-editable-icon"),
|
|
@@ -6,6 +6,7 @@ export interface EllipsisProps {
|
|
|
6
6
|
disabled?: boolean;
|
|
7
7
|
position?: Position | 'left' | 'bottom' | 'right' | 'top';
|
|
8
8
|
theme?: 'light' | 'dark';
|
|
9
|
+
hoverable?: boolean;
|
|
9
10
|
}
|
|
10
11
|
export declare class Ellipsis extends Component<EllipsisProps> {
|
|
11
12
|
static template: string | import('intact-vue-next').Template<any>;
|
|
@@ -8,12 +8,14 @@ var typeDefs = {
|
|
|
8
8
|
maxLines: Number,
|
|
9
9
|
disabled: Boolean,
|
|
10
10
|
position: [Object, 'left', 'bottom', 'right', 'top'],
|
|
11
|
-
theme: ['light', 'dark']
|
|
11
|
+
theme: ['light', 'dark'],
|
|
12
|
+
hoverable: Boolean
|
|
12
13
|
};
|
|
13
14
|
var defaults = function defaults() {
|
|
14
15
|
return {
|
|
15
16
|
disabled: false,
|
|
16
|
-
theme: 'light'
|
|
17
|
+
theme: 'light',
|
|
18
|
+
hoverable: false
|
|
17
19
|
};
|
|
18
20
|
};
|
|
19
21
|
export var Ellipsis = /*#__PURE__*/function (_Component) {
|
|
@@ -15,7 +15,8 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
15
15
|
disabled = _this$get.disabled,
|
|
16
16
|
position = _this$get.position,
|
|
17
17
|
theme = _this$get.theme,
|
|
18
|
-
style = _this$get.style
|
|
18
|
+
style = _this$get.style,
|
|
19
|
+
hoverable = _this$get.hoverable;
|
|
19
20
|
var k = this.config.k;
|
|
20
21
|
var _this$ellipsis = this.ellipsis,
|
|
21
22
|
showTooltip = _this$ellipsis.showTooltip,
|
|
@@ -31,6 +32,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
31
32
|
'position': position,
|
|
32
33
|
'theme': theme,
|
|
33
34
|
'className': _$cn(className),
|
|
35
|
+
'hoverable': hoverable,
|
|
34
36
|
'children': wrapper,
|
|
35
37
|
'$blocks': function ($blocks) {
|
|
36
38
|
var _$blocks = {},
|
|
@@ -6,6 +6,12 @@ import { deepDefaults, sizes } from '../../styles/utils';
|
|
|
6
6
|
import '../../styles/global';
|
|
7
7
|
import { Input } from './';
|
|
8
8
|
import { cache } from '../utils';
|
|
9
|
+
var textareaSize = {
|
|
10
|
+
mini: '0',
|
|
11
|
+
small: '1px',
|
|
12
|
+
default: '5px',
|
|
13
|
+
large: '7px'
|
|
14
|
+
};
|
|
9
15
|
var defaults = deepDefaults({
|
|
10
16
|
get transition() {
|
|
11
17
|
return theme.transition.middle;
|
|
@@ -85,6 +91,7 @@ var defaults = deepDefaults({
|
|
|
85
91
|
}
|
|
86
92
|
}, sizes.reduce(function (memo, size) {
|
|
87
93
|
var styles = theme[size];
|
|
94
|
+
var textareaStyles = textareaSize[size];
|
|
88
95
|
memo[size] = {
|
|
89
96
|
get fontSize() {
|
|
90
97
|
return styles.fontSize;
|
|
@@ -94,6 +101,9 @@ var defaults = deepDefaults({
|
|
|
94
101
|
},
|
|
95
102
|
get paddingGap() {
|
|
96
103
|
return styles.padding;
|
|
104
|
+
},
|
|
105
|
+
get padding() {
|
|
106
|
+
return textareaStyles;
|
|
97
107
|
}
|
|
98
108
|
};
|
|
99
109
|
return memo;
|
|
@@ -110,7 +120,7 @@ export var makeStyles = cache(function makeStyles(k) {
|
|
|
110
120
|
var _context;
|
|
111
121
|
return /*#__PURE__*/css("display:inline-block;width:", input.width, ";color:", input.color, ";vertical-align:middle;.", k, "-input-wrapper{display:inline-flex;align-items:center;width:100%;position:relative;border:", input.border, ";background-color:", input.bgColor, ";transition:border ", input.transition, ",background ", input.transition, ",box-shadow ", input.transition, ";border-radius:", input.borderRadius, ";&:hover{border:", input.hoverBorder, ";z-index:1;}}&.", k, "-focus .", k, "-input-wrapper{border:", input.focusBorder, ";z-index:1;}.", k, "-input-inner{flex:1;outline:none;color:inherit;font-size:inherit;border:none;background:transparent;padding:0;width:0;max-width:100%;&::placeholder{color:", input.placeholderColor, ";}}&.", k, "-fluid{width:100%;}.", k, "-input-prefix,.", k, "-input-suffix{display:flex;align-items:center;gap:", input.clearIconGap, ";color:", theme.color.lightBlack, ";position:relative;}.", k, "-input-prefix{margin-right:", input.clearIconGap, ";}.", k, "-input-suffix{margin-left:", input.clearIconGap, ";}.", k, "-input-clear{opacity:0;transition:opacity ", input.transition, ";pointer-events:none;color:", input.clearIconColor, ";}&:hover .", k, "-input-clear.", k, "-input-show{opacity:1;pointer-events:all;}.", k, "-input-show-password{color:", input.clearIconColor, ";}&.", k, "-stack-clear{.", k, "-input-clear{position:absolute;z-index:1;right:0;&.", k, "-input-show+*{transition:opacity ", input.transition, ";}}&:hover{.", k, "-input-clear.", k, "-input-show+*{opacity:0;}}}&.", k, "-group{display:inline-flex;.", k, "-input-wrapper{border-radius:0;flex:1;}.", k, "-input-wrapper:first-child{border-radius:", input.borderRadius, " 0 0 ", input.borderRadius, ";}.", k, "-input-wrapper:last-child{border-radius:0 ", input.borderRadius, " ", input.borderRadius, " 0;}}.", k, "-input-prepend,.", k, "-input-append{display:inline-flex;align-items:center;background-color:", input.groupBgColor, ";border:", input.border, ";white-space:nowrap;.", k, "-btn{margin:-1px;&.", k, "-none:hover{background:transparent;}}.", k, "-select{margin:-1px;text-align:left;}}.", k, "-input-prepend{&,.", k, "-btn,.", k, "-select{z-index:1;border-radius:", input.borderRadius, " 0 0 ", input.borderRadius, ";}}.", k, "-input-append{&,.", k, "-btn,.", k, "-select{z-index:1;border-radius:0 ", input.borderRadius, " ", input.borderRadius, " 0;}}.", k, "-input-padding{padding:0 ", input.groupPaddingGap, ";}.", k, "-input-prepend{border-right:none;}.", k, "-input-append{border-left:none;}&.", k, "-flat{color:", _flatInstanceProperty(input).color, ";.", k, "-input-wrapper{border:none;background:", _flatInstanceProperty(input).bgColor, ";}}&.", k, "-disabled{color:", input.disabledColor, ";cursor:not-allowed;.", k, "-input-wrapper{border-color:", input.disabledBorderColor, ";background:", input.disabledBgColor, ";}.", k, "-input-inner{cursor:not-allowed;}}", _mapInstanceProperty(sizes).call(sizes, function (size) {
|
|
112
122
|
var styles = input[size];
|
|
113
|
-
var sizeClassName = /*#__PURE__*/css("font-size:", styles.fontSize, ";.", k, "-input-wrapper{height:", styles.height, ";padding:0 ", styles.paddingGap, ";}");
|
|
123
|
+
var sizeClassName = /*#__PURE__*/css("font-size:", styles.fontSize, ";.", k, "-input-wrapper{height:", styles.height, ";padding:0 ", styles.paddingGap, ";.", k, "-textarea{padding:", styles.padding, " ", styles.paddingGap, ";}}");
|
|
114
124
|
if (size === 'default') return sizeClassName;
|
|
115
125
|
return /*#__PURE__*/css("&.", k, "-", size, "{", sizeClassName, ";}");
|
|
116
126
|
}), "&.", k, "-inline{.", k, "-input-wrapper{height:auto;border:none;border-radius:0;padding:0;}}&.", k, "-type-textarea{.", k, "-input-wrapper{display:inline-block;padding:0;height:auto;}.", k, "-textarea{width:100%;padding:", input.textareaPadding, ";line-height:1.5;vertical-align:top;}.", k, "-input-suffix{margin:0;justify-content:flex-end;}}", _mapInstanceProperty(_context = Input.typeDefs.resize).call(_context, function (type) {
|
|
@@ -51,6 +51,10 @@ export declare abstract class BaseSelect<T extends BaseSelectProps<any> = BaseSe
|
|
|
51
51
|
};
|
|
52
52
|
private focusout;
|
|
53
53
|
private draggable;
|
|
54
|
+
immutable: {
|
|
55
|
+
immutableValues: State<any[]>;
|
|
56
|
+
isClosable: (key: string) => boolean;
|
|
57
|
+
};
|
|
54
58
|
protected config: {
|
|
55
59
|
cls: (name: string) => string;
|
|
56
60
|
readonly k: string;
|
|
@@ -2,6 +2,8 @@ import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
|
|
|
2
2
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
|
|
3
3
|
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/slice";
|
|
4
4
|
import _spliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/splice";
|
|
5
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js/instance/filter";
|
|
6
|
+
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js/instance/includes";
|
|
5
7
|
import { __decorate } from "tslib";
|
|
6
8
|
import { Component, provide, createRef } from 'intact-vue-next';
|
|
7
9
|
import template from './base.vdt';
|
|
@@ -14,6 +16,7 @@ import { useInput } from './useInput';
|
|
|
14
16
|
import { useFocusout } from './useFocusout';
|
|
15
17
|
import { isNullOrUndefined } from 'intact-shared';
|
|
16
18
|
import { useDraggable } from './useDraggble';
|
|
19
|
+
import { useImmutable } from './useImmutable';
|
|
17
20
|
import { useConfigContext } from '../config';
|
|
18
21
|
var typeDefs = {
|
|
19
22
|
value: null,
|
|
@@ -60,6 +63,7 @@ export var BaseSelect = /*#__PURE__*/function (_Component) {
|
|
|
60
63
|
_this.input = useInput(_this.resetKeywords);
|
|
61
64
|
_this.focusout = useFocusout();
|
|
62
65
|
_this.draggable = useDraggable();
|
|
66
|
+
_this.immutable = useImmutable();
|
|
63
67
|
_this.config = useConfigContext();
|
|
64
68
|
return _this;
|
|
65
69
|
}
|
|
@@ -104,7 +108,13 @@ export var BaseSelect = /*#__PURE__*/function (_Component) {
|
|
|
104
108
|
};
|
|
105
109
|
_proto.clear = function clear(e) {
|
|
106
110
|
e.stopPropagation();
|
|
107
|
-
|
|
111
|
+
var _this$get2 = this.get(),
|
|
112
|
+
value = _this$get2.value,
|
|
113
|
+
multiple = _this$get2.multiple;
|
|
114
|
+
var immutableValues = this.immutable.immutableValues.value;
|
|
115
|
+
this.set('value', multiple ? Array.isArray(value) ? _filterInstanceProperty(value).call(value, function (key) {
|
|
116
|
+
return _includesInstanceProperty(immutableValues).call(immutableValues, key);
|
|
117
|
+
}) : [] : null);
|
|
108
118
|
};
|
|
109
119
|
_proto.onKeydown = function onKeydown(e) {
|
|
110
120
|
this.trigger('keydown', e);
|
|
@@ -57,6 +57,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
57
57
|
var _this$focusout = this.focusout,
|
|
58
58
|
onFocusout = _this$focusout.onFocusout,
|
|
59
59
|
triggerRef = _this$focusout.triggerRef;
|
|
60
|
+
var isClosable = this.immutable.isClosable;
|
|
60
61
|
var filterInput = filterable ? _$cc(Input, {
|
|
61
62
|
'className': _$cn(k + "-select-input"),
|
|
62
63
|
'value': keywords,
|
|
@@ -139,7 +140,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
139
140
|
'children': _$ma(label, function ($label, $key) {
|
|
140
141
|
return _$cc(Tag, {
|
|
141
142
|
'key': isStringOrNumber($label) ? $label : isStringOrNumber(value[$key]) ? value[$key] : $key,
|
|
142
|
-
'closable':
|
|
143
|
+
'closable': isClosable(value[$key]),
|
|
143
144
|
'ev-close': this.delete.bind(this, $key),
|
|
144
145
|
'disabled': disabled,
|
|
145
146
|
'size': size,
|
|
@@ -13,6 +13,7 @@ import { Tooltip } from '../tooltip';
|
|
|
13
13
|
import { Component } from 'intact-vue-next';
|
|
14
14
|
import { Select, Option } from '../select';
|
|
15
15
|
import SearchableDemo from '~/components/select/demos/searchable';
|
|
16
|
+
import ImmutableDemo from '~/components/select/demos/immutable';
|
|
16
17
|
describe('Select', function () {
|
|
17
18
|
afterEach(function (done) {
|
|
18
19
|
unmount();
|
|
@@ -449,6 +450,52 @@ describe('Select', function () {
|
|
|
449
450
|
}
|
|
450
451
|
}, _callee10);
|
|
451
452
|
})));
|
|
453
|
+
it('disabled option does not allow clearable and close', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
|
|
454
|
+
var _mount12, instance, element, _element$querySelecto7, clear1, _element$querySelecto8, tag1, _element$querySelecto9, clear2, _element$querySelecto10, clear3;
|
|
455
|
+
return _regeneratorRuntime.wrap(function _callee11$(_context13) {
|
|
456
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
457
|
+
case 0:
|
|
458
|
+
_mount12 = mount(ImmutableDemo), instance = _mount12[0], element = _mount12[1];
|
|
459
|
+
instance.set('days', ['Tuesday', 'Friday']);
|
|
460
|
+
_context13.next = 4;
|
|
461
|
+
return wait();
|
|
462
|
+
case 4:
|
|
463
|
+
expect(element.outerHTML).to.matchSnapshot();
|
|
464
|
+
_element$querySelecto7 = element.querySelectorAll('.k-select-clear'), clear1 = _element$querySelecto7[0];
|
|
465
|
+
clear1.click();
|
|
466
|
+
_context13.next = 9;
|
|
467
|
+
return wait();
|
|
468
|
+
case 9:
|
|
469
|
+
_element$querySelecto8 = element.querySelectorAll('.k-tag'), tag1 = _element$querySelecto8[0];
|
|
470
|
+
expect(tag1.className).not.contain("k-closable");
|
|
471
|
+
expect(instance.get('days')).to.eql(['Tuesday', 'Friday']);
|
|
472
|
+
instance.set('days', ['Monday', 'Tuesday']);
|
|
473
|
+
_context13.next = 15;
|
|
474
|
+
return wait();
|
|
475
|
+
case 15:
|
|
476
|
+
_element$querySelecto9 = element.querySelectorAll('.k-select-clear'), clear2 = _element$querySelecto9[0];
|
|
477
|
+
clear2.click();
|
|
478
|
+
_context13.next = 19;
|
|
479
|
+
return wait();
|
|
480
|
+
case 19:
|
|
481
|
+
expect(instance.get('days')).to.eql(['Tuesday']);
|
|
482
|
+
instance.set('days', ['Monday', 'Wednesday']);
|
|
483
|
+
_context13.next = 23;
|
|
484
|
+
return wait();
|
|
485
|
+
case 23:
|
|
486
|
+
_element$querySelecto10 = element.querySelectorAll('.k-select-clear'), clear3 = _element$querySelecto10[0];
|
|
487
|
+
clear3.click();
|
|
488
|
+
_context13.next = 27;
|
|
489
|
+
return wait();
|
|
490
|
+
case 27:
|
|
491
|
+
expect(instance.get('days')).to.eql([]);
|
|
492
|
+
// expect(clear).to.be.null;
|
|
493
|
+
case 28:
|
|
494
|
+
case "end":
|
|
495
|
+
return _context13.stop();
|
|
496
|
+
}
|
|
497
|
+
}, _callee11);
|
|
498
|
+
})));
|
|
452
499
|
// it('should trigger change event correctly', async () => {
|
|
453
500
|
// const spy = sinon.spy();
|
|
454
501
|
// class Demo extends Component {
|