@king-design/vue 2.0.16 → 2.1.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/__tests__/__snapshots__/Vue Next Demos.md +115 -91
- package/__tests__/components/editable.spec.ts +45 -0
- package/components/cascader/index.d.ts +22 -11
- package/components/cascader/index.js +9 -12
- package/components/cascader/index.spec.js +81 -0
- package/components/cascader/index.vdt.js +10 -8
- package/components/cascader/styles.js +1 -1
- package/components/cascader/useFields.d.ts +2 -0
- package/components/cascader/useFields.js +18 -0
- package/components/cascader/useFilterable.d.ts +2 -1
- package/components/cascader/useFilterable.js +17 -6
- package/components/cascader/useLabel.d.ts +2 -1
- package/components/cascader/useLabel.js +4 -4
- package/components/cascader/useLoad.d.ts +2 -1
- package/components/cascader/useLoad.js +9 -7
- package/components/colorpicker/index.d.ts +2 -0
- package/components/colorpicker/index.js +7 -2
- package/components/colorpicker/index.vdt.js +3 -6
- package/components/dialog/index.spec.js +2 -2
- package/components/dropdown/dropdown.d.ts +0 -1
- package/components/dropdown/dropdown.js +19 -8
- package/components/dropdown/item.js +3 -3
- package/components/dropdown/menu.js +1 -1
- package/components/dropdown/usePosition.js +8 -1
- package/components/editable/index.d.ts +1 -0
- package/components/editable/index.js +20 -6
- package/components/editable/index.vdt.js +2 -1
- package/components/input/index.d.ts +10 -2
- package/components/input/index.js +10 -3
- package/components/input/index.spec.js +169 -1
- package/components/input/index.vdt.js +26 -7
- package/components/input/styles.js +8 -3
- package/components/input/useAutoRows.d.ts +2 -0
- package/components/input/useAutoRows.js +79 -0
- package/components/input/useAutoWidth.js +13 -3
- package/components/input/useShowPassword.d.ts +7 -0
- package/components/input/useShowPassword.js +31 -0
- package/components/pagination/index.js +1 -3
- package/components/pagination/index.spec.js +2 -4
- package/components/portal.d.ts +6 -2
- package/components/portal.js +4 -3
- package/components/position.js +2 -1
- package/components/select/base.d.ts +2 -1
- package/components/select/base.js +3 -1
- package/components/select/base.vdt.js +3 -1
- package/components/table/cell.js +1 -6
- package/components/table/index.spec.js +130 -19
- package/components/table/row.d.ts +1 -1
- package/components/table/row.js +2 -1
- package/components/table/styles.js +1 -1
- package/components/table/table.d.ts +15 -0
- package/components/table/table.js +16 -7
- package/components/table/table.vdt.js +20 -6
- package/components/table/useChecked.d.ts +3 -2
- package/components/table/useChecked.js +23 -12
- package/components/table/useDisableRow.d.ts +2 -1
- package/components/table/useDisableRow.js +4 -4
- package/components/table/useDraggable.d.ts +3 -2
- package/components/table/useDraggable.js +11 -8
- package/components/table/useGroup.js +3 -0
- package/components/table/useMerge.d.ts +2 -1
- package/components/table/useMerge.js +5 -4
- package/components/table/usePagination.d.ts +8 -0
- package/components/table/usePagination.js +81 -0
- package/components/table/useTree.d.ts +2 -1
- package/components/table/useTree.js +3 -4
- package/components/tooltip/index.spec.js +9 -10
- package/components/tooltip/tooltip.d.ts +0 -1
- package/components/tooltip/tooltip.js +1 -12
- package/index.d.ts +3 -3
- package/index.js +3 -3
- package/package.json +2 -2
- package/styles/fonts/ionicons.js +1 -1
- package/yarn-error.log +0 -899
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {createApp, render, defineComponent} from 'vue';
|
|
2
|
+
import {mount, unmount, dispatchEvent, getElement, wait, fakeError} from '@/test/utils';
|
|
3
|
+
import {Table, TableColumn, Editable, Tooltip} from '../../';
|
|
4
|
+
|
|
5
|
+
describe('Editable', () => {
|
|
6
|
+
it('should correctly mount Input on editing ', async () => {
|
|
7
|
+
const container = document.createElement('div');
|
|
8
|
+
document.body.appendChild(container);
|
|
9
|
+
|
|
10
|
+
const vue = createApp({
|
|
11
|
+
template: `
|
|
12
|
+
<Table :data="data">
|
|
13
|
+
<TableColumn key="a">
|
|
14
|
+
<template v-slot:template="[data]">
|
|
15
|
+
<Tooltip content="test">
|
|
16
|
+
<Editable v-model="data.a" ref="editable">
|
|
17
|
+
<span>{{ data.a }}</span>
|
|
18
|
+
</Editable>
|
|
19
|
+
</Tooltip>
|
|
20
|
+
</template>
|
|
21
|
+
</TableColumn>
|
|
22
|
+
</Table>
|
|
23
|
+
`,
|
|
24
|
+
components: {
|
|
25
|
+
Table, TableColumn, Editable, Tooltip
|
|
26
|
+
},
|
|
27
|
+
data() {
|
|
28
|
+
return {
|
|
29
|
+
data: [{a: 1}]
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
}).mount(container);
|
|
33
|
+
await wait();
|
|
34
|
+
|
|
35
|
+
container.querySelector<HTMLDivElement>('.k-icon')!.click();
|
|
36
|
+
await wait();
|
|
37
|
+
|
|
38
|
+
const input = container.querySelector('.k-input input') as HTMLInputElement;
|
|
39
|
+
expect(input.selectionStart).to.eql(0);
|
|
40
|
+
expect(input.selectionEnd).to.eql(1);
|
|
41
|
+
|
|
42
|
+
render(null, container);
|
|
43
|
+
document.body.removeChild(container);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -1,28 +1,39 @@
|
|
|
1
1
|
import { TypeDefs } from 'intact-vue-next';
|
|
2
2
|
import { BaseSelect, BaseSelectProps, BaseSelectEvents, BaseSelectBlocks } from '../select/base';
|
|
3
|
-
export interface CascaderProps<V = any, Multipe extends boolean = boolean
|
|
4
|
-
data?:
|
|
3
|
+
export interface CascaderProps<V = any, Multipe extends boolean = boolean, Data extends BaseCascaderData = CascaderData<V>> extends BaseSelectProps<V[], Multipe> {
|
|
4
|
+
data?: Data[];
|
|
5
5
|
trigger?: 'click' | 'hover';
|
|
6
6
|
changeOnSelect?: boolean;
|
|
7
7
|
format?: (labels: string[]) => string;
|
|
8
|
-
loadData?: (data:
|
|
9
|
-
filter?: (keywords: string, data:
|
|
8
|
+
loadData?: (data: Data) => any;
|
|
9
|
+
filter?: (keywords: string, data: Data) => boolean;
|
|
10
|
+
fields?: CascaderFields<Data>;
|
|
10
11
|
}
|
|
11
|
-
export declare type
|
|
12
|
+
export declare type CascaderFields<Data> = {
|
|
13
|
+
value?: keyof Data;
|
|
14
|
+
label?: keyof Data;
|
|
15
|
+
children?: keyof Data;
|
|
16
|
+
disabled?: keyof Data;
|
|
17
|
+
};
|
|
18
|
+
export interface BaseCascaderData {
|
|
19
|
+
loaded?: boolean;
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
}
|
|
22
|
+
export interface CascaderData<V> extends BaseCascaderData {
|
|
12
23
|
value: V;
|
|
13
24
|
label: string;
|
|
14
|
-
disabled?: boolean;
|
|
15
|
-
loaded?: boolean;
|
|
16
25
|
children?: CascaderData<V>[];
|
|
17
|
-
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
}
|
|
18
28
|
export interface CascaderEvents extends BaseSelectEvents {
|
|
19
29
|
}
|
|
20
30
|
export interface CascaderBlocks<V> extends BaseSelectBlocks<V> {
|
|
21
31
|
}
|
|
22
|
-
export declare class Cascader<V = any, Multipe extends boolean = false
|
|
32
|
+
export declare class Cascader<V = any, Multipe extends boolean = false, Data extends BaseCascaderData = CascaderData<V>> extends BaseSelect<CascaderProps<V, Multipe, Data>, CascaderEvents, CascaderBlocks<V>> {
|
|
23
33
|
static template: string | import("intact").Template<any>;
|
|
24
|
-
static typeDefs: Required<TypeDefs<CascaderProps<any, boolean
|
|
25
|
-
static defaults: () => Partial<CascaderProps<any, boolean
|
|
34
|
+
static typeDefs: Required<TypeDefs<CascaderProps<any, boolean, CascaderData<any>>>>;
|
|
35
|
+
static defaults: () => Partial<CascaderProps<any, boolean, CascaderData<any>>>;
|
|
36
|
+
private fields;
|
|
26
37
|
private value;
|
|
27
38
|
private label;
|
|
28
39
|
private load;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
|
|
2
2
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
3
|
-
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js/instance/includes";
|
|
4
3
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
|
|
5
4
|
import template from './index.vdt';
|
|
6
5
|
import { BaseSelect } from '../select/base';
|
|
@@ -10,6 +9,7 @@ import { useValue } from './useValue';
|
|
|
10
9
|
import { useLabel } from './useLabel';
|
|
11
10
|
import { useLoad } from './useLoad';
|
|
12
11
|
import { useFilterable } from './useFilterable';
|
|
12
|
+
import { useFields } from './useFields';
|
|
13
13
|
|
|
14
14
|
var typeDefs = _extends({}, BaseSelect.typeDefs, {
|
|
15
15
|
data: Array,
|
|
@@ -17,7 +17,8 @@ var typeDefs = _extends({}, BaseSelect.typeDefs, {
|
|
|
17
17
|
changeOnSelect: Boolean,
|
|
18
18
|
format: Function,
|
|
19
19
|
loadData: Function,
|
|
20
|
-
filter: Function
|
|
20
|
+
filter: Function,
|
|
21
|
+
fields: Object
|
|
21
22
|
});
|
|
22
23
|
|
|
23
24
|
var defaults = function defaults() {
|
|
@@ -26,11 +27,6 @@ var defaults = function defaults() {
|
|
|
26
27
|
trigger: 'click',
|
|
27
28
|
format: function format(labels) {
|
|
28
29
|
return labels.join(' / ');
|
|
29
|
-
},
|
|
30
|
-
filter: function filter(keywords, data) {
|
|
31
|
-
var _context;
|
|
32
|
-
|
|
33
|
-
return _includesInstanceProperty(_context = data.label).call(_context, keywords);
|
|
34
30
|
}
|
|
35
31
|
});
|
|
36
32
|
};
|
|
@@ -39,7 +35,7 @@ export var Cascader = /*#__PURE__*/function (_BaseSelect) {
|
|
|
39
35
|
_inheritsLoose(Cascader, _BaseSelect);
|
|
40
36
|
|
|
41
37
|
function Cascader() {
|
|
42
|
-
var
|
|
38
|
+
var _context;
|
|
43
39
|
|
|
44
40
|
var _this;
|
|
45
41
|
|
|
@@ -47,11 +43,12 @@ export var Cascader = /*#__PURE__*/function (_BaseSelect) {
|
|
|
47
43
|
args[_key] = arguments[_key];
|
|
48
44
|
}
|
|
49
45
|
|
|
50
|
-
_this = _BaseSelect.call.apply(_BaseSelect, _concatInstanceProperty(
|
|
46
|
+
_this = _BaseSelect.call.apply(_BaseSelect, _concatInstanceProperty(_context = [this]).call(_context, args)) || this;
|
|
47
|
+
_this.fields = useFields();
|
|
51
48
|
_this.value = useValue();
|
|
52
|
-
_this.label = useLabel();
|
|
53
|
-
_this.load = useLoad();
|
|
54
|
-
_this.filterable = useFilterable(_this.input.keywords, _this.value.setValue);
|
|
49
|
+
_this.label = useLabel(_this.fields);
|
|
50
|
+
_this.load = useLoad(_this.fields);
|
|
51
|
+
_this.filterable = useFilterable(_this.input.keywords, _this.value.setValue, _this.fields);
|
|
55
52
|
_this.positionObj = {
|
|
56
53
|
my: 'left top',
|
|
57
54
|
at: 'right top',
|
|
@@ -366,4 +366,85 @@ describe('Cascader', function () {
|
|
|
366
366
|
}
|
|
367
367
|
}, _callee8);
|
|
368
368
|
})));
|
|
369
|
+
it('specify fields', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
|
|
370
|
+
var Demo, _mount8, instance, element, select, dropdown1, _dropdown1$querySelec5, item1, dropdown2, _dropdown2$querySelec4, item11;
|
|
371
|
+
|
|
372
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context11) {
|
|
373
|
+
while (1) {
|
|
374
|
+
switch (_context11.prev = _context11.next) {
|
|
375
|
+
case 0:
|
|
376
|
+
Demo = /*#__PURE__*/function (_Component2) {
|
|
377
|
+
_inheritsLoose(Demo, _Component2);
|
|
378
|
+
|
|
379
|
+
function Demo() {
|
|
380
|
+
var _context10;
|
|
381
|
+
|
|
382
|
+
var _this2;
|
|
383
|
+
|
|
384
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
385
|
+
args[_key2] = arguments[_key2];
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
_this2 = _Component2.call.apply(_Component2, _concatInstanceProperty(_context10 = [this]).call(_context10, args)) || this;
|
|
389
|
+
_this2.Cascader = Cascader;
|
|
390
|
+
return _this2;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
Demo.defaults = function defaults() {
|
|
394
|
+
return {
|
|
395
|
+
value: [],
|
|
396
|
+
data: [{
|
|
397
|
+
v: 'beijing',
|
|
398
|
+
l: '北京',
|
|
399
|
+
c: [{
|
|
400
|
+
v: 'haidian',
|
|
401
|
+
l: '海淀区'
|
|
402
|
+
}]
|
|
403
|
+
}, {
|
|
404
|
+
v: 'hunan',
|
|
405
|
+
l: '湖南',
|
|
406
|
+
c: [{
|
|
407
|
+
v: 'haidian',
|
|
408
|
+
l: '海淀区'
|
|
409
|
+
}]
|
|
410
|
+
}]
|
|
411
|
+
};
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
return Demo;
|
|
415
|
+
}(Component);
|
|
416
|
+
|
|
417
|
+
Demo.template = "\n const {Cascader} = this;\n <Cascader data={this.get('data')}\n v-model=\"value\"\n fields={{value: 'v', label: 'l', children: 'c'}}\n />\n ";
|
|
418
|
+
_mount8 = mount(Demo), instance = _mount8[0], element = _mount8[1];
|
|
419
|
+
select = element;
|
|
420
|
+
select.click();
|
|
421
|
+
_context11.next = 7;
|
|
422
|
+
return wait();
|
|
423
|
+
|
|
424
|
+
case 7:
|
|
425
|
+
dropdown1 = getElement('.k-cascader-menu');
|
|
426
|
+
_dropdown1$querySelec5 = dropdown1.querySelectorAll(':scope > .k-dropdown-item'), item1 = _dropdown1$querySelec5[0];
|
|
427
|
+
item1.click();
|
|
428
|
+
_context11.next = 12;
|
|
429
|
+
return wait();
|
|
430
|
+
|
|
431
|
+
case 12:
|
|
432
|
+
expect(dropdown1.innerHTML).to.matchSnapshot();
|
|
433
|
+
dropdown2 = getElement('.k-cascader-menu');
|
|
434
|
+
_dropdown2$querySelec4 = dropdown2.querySelectorAll(':scope > .k-dropdown-item'), item11 = _dropdown2$querySelec4[0];
|
|
435
|
+
item11.click();
|
|
436
|
+
_context11.next = 18;
|
|
437
|
+
return wait();
|
|
438
|
+
|
|
439
|
+
case 18:
|
|
440
|
+
expect(element.innerHTML).to.matchSnapshot();
|
|
441
|
+
expect(instance.get('value')).to.eql(['beijing', 'haidian']);
|
|
442
|
+
|
|
443
|
+
case 20:
|
|
444
|
+
case "end":
|
|
445
|
+
return _context11.stop();
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}, _callee9);
|
|
449
|
+
})));
|
|
369
450
|
});
|
|
@@ -27,12 +27,14 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
27
27
|
var _this$get = this.get(),
|
|
28
28
|
data = _this$get.data,
|
|
29
29
|
trigger = _this$get.trigger,
|
|
30
|
-
filterable = _this$get.filterable
|
|
30
|
+
filterable = _this$get.filterable,
|
|
31
|
+
fields = _this$get.fields;
|
|
31
32
|
|
|
32
33
|
var baseMenuStyles = makeMenuStyles();
|
|
33
34
|
var classNameObj = (_classNameObj = {
|
|
34
35
|
'k-cascader-menu': true
|
|
35
36
|
}, _classNameObj[baseMenuStyles] = true, _classNameObj);
|
|
37
|
+
var getField = this.fields;
|
|
36
38
|
|
|
37
39
|
var _this$value = this.value,
|
|
38
40
|
values = _valuesInstanceProperty(_this$value),
|
|
@@ -51,31 +53,31 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
return _mapInstanceProperty(data).call(data, function (item, index) {
|
|
54
|
-
var value = item
|
|
56
|
+
var value = getField(item, 'value');
|
|
55
57
|
var showed = isShowed(value, level);
|
|
56
58
|
var selected = parentSelected && isSelected(value, level);
|
|
57
|
-
var children = item
|
|
59
|
+
var children = getField(item, 'children');
|
|
58
60
|
|
|
59
61
|
var Item = function Item() {
|
|
60
62
|
return _$cc(DropdownItem, {
|
|
61
|
-
'disabled': item
|
|
63
|
+
'disabled': getField(item, 'disabled'),
|
|
62
64
|
'className': _$cn({
|
|
63
65
|
'k-cascader-option': true,
|
|
64
66
|
'k-active': showed,
|
|
65
67
|
'k-selected': selected
|
|
66
68
|
}),
|
|
67
69
|
'ev-select': onSelect.bind(null, value, level),
|
|
68
|
-
'children': [item
|
|
70
|
+
'children': [getField(item, 'label'), children ? _$cc(Icon, _$tmp1) : undefined]
|
|
69
71
|
});
|
|
70
72
|
};
|
|
71
73
|
|
|
72
74
|
return children ? _$cc(Dropdown, {
|
|
73
75
|
'position': _this.positionObj,
|
|
74
76
|
'of': 'parent',
|
|
75
|
-
'disabled': item
|
|
77
|
+
'disabled': getField(item, 'disabled'),
|
|
76
78
|
'trigger': trigger,
|
|
77
79
|
'value': showed,
|
|
78
|
-
'ev-$
|
|
80
|
+
'ev-$change:value': toggleShowedValue.bind(null, value, level),
|
|
79
81
|
'ev-show': _this.load.bind(null, item),
|
|
80
82
|
'children': [Item(), _$cc(DropdownMenu, {
|
|
81
83
|
'className': _$cn(classNameObj),
|
|
@@ -116,7 +118,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
116
118
|
'children': function () {
|
|
117
119
|
// highlight keywords
|
|
118
120
|
var label = _mapInstanceProperty($value).call($value, function (item) {
|
|
119
|
-
return item
|
|
121
|
+
return getField(item, 'label');
|
|
120
122
|
}).join(' / ');
|
|
121
123
|
|
|
122
124
|
var labels = label.split(keywords);
|
|
@@ -43,7 +43,7 @@ setDefault(function () {
|
|
|
43
43
|
}).cascader;
|
|
44
44
|
});
|
|
45
45
|
export function makeMenuStyles() {
|
|
46
|
-
return /*#__PURE__*/css("min-width:", cascader.width, "!important;
|
|
46
|
+
return /*#__PURE__*/css("min-width:", cascader.width, "!important;height:", cascader.height, ";overflow:auto;.k-cascader-arrow{float:right;height:100%;margin-left:", cascader.arrowGap, ";line-height:inherit;}.k-cascader-loading{display:block;text-align:center;margin-top:", cascader.loadingGap, ";}.k-cascader-empty{padding:", cascader.empty.padding, ";color:", cascader.empty.color, ";text-align:center;}.k-cascader-option{&.k-selected{color:", cascader.selectedColor, ";}&.k-active{background:", cascader.activeBgColor, ";}}");
|
|
47
47
|
}
|
|
48
48
|
export function makeFilterMenuStyles() {
|
|
49
49
|
return /*#__PURE__*/css("min-width:", _filterInstanceProperty(cascader).minWidth, "!important;height:auto;max-height:", _filterInstanceProperty(cascader).maxHeight, ";em{font-style:normal;color:", _filterInstanceProperty(cascader).highlightColor, ";}");
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useInstance } from 'intact-vue-next';
|
|
2
|
+
export function useFields() {
|
|
3
|
+
var instance = useInstance();
|
|
4
|
+
return function getField(data, key) {
|
|
5
|
+
var _instance$get = instance.get(),
|
|
6
|
+
fields = _instance$get.fields;
|
|
7
|
+
|
|
8
|
+
if (fields) {
|
|
9
|
+
var field = fields[key];
|
|
10
|
+
|
|
11
|
+
if (field) {
|
|
12
|
+
return data[field];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return data[key];
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { CascaderData } from './';
|
|
2
2
|
import { State } from '../../hooks/useState';
|
|
3
3
|
import type { Value } from './useValue';
|
|
4
|
-
|
|
4
|
+
import type { useFields } from './useFields';
|
|
5
|
+
export declare function useFilterable(keywords: State<string>, setValue: (value: Value) => void, getField: ReturnType<typeof useFields>): {
|
|
5
6
|
filter: () => CascaderData<any>[][];
|
|
6
7
|
selectByFilter: (data: CascaderData<any>[]) => void;
|
|
7
8
|
keywords: State<string>;
|
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js/instance/filter";
|
|
2
|
+
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js/instance/includes";
|
|
2
3
|
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/slice";
|
|
3
4
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js/instance/map";
|
|
4
5
|
import { useInstance } from 'intact-vue-next';
|
|
5
|
-
export function useFilterable(keywords, setValue) {
|
|
6
|
+
export function useFilterable(keywords, setValue, getField) {
|
|
6
7
|
var instance = useInstance();
|
|
7
8
|
|
|
8
9
|
function filter() {
|
|
10
|
+
var ret = [];
|
|
11
|
+
|
|
9
12
|
var _instance$get = instance.get(),
|
|
10
13
|
data = _instance$get.data,
|
|
11
14
|
filter = _filterInstanceProperty(_instance$get);
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
if (!filter) {
|
|
17
|
+
filter = function filter(keywords, data) {
|
|
18
|
+
var _context;
|
|
19
|
+
|
|
20
|
+
return _includesInstanceProperty(_context = getField(data, 'label')).call(_context, keywords);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
14
23
|
|
|
15
24
|
var loop = function loop(data, prefix, valid, disabled) {
|
|
16
25
|
if (prefix === void 0) {
|
|
@@ -28,14 +37,16 @@ export function useFilterable(keywords, setValue) {
|
|
|
28
37
|
data.forEach(function (item) {
|
|
29
38
|
var _valid = valid || filter(keywords.value, item);
|
|
30
39
|
|
|
31
|
-
var _disabled = disabled || item
|
|
40
|
+
var _disabled = disabled || getField(item, 'disabled');
|
|
32
41
|
|
|
33
42
|
var _prefix = _sliceInstanceProperty(prefix).call(prefix, 0);
|
|
34
43
|
|
|
35
44
|
_prefix.push(item);
|
|
36
45
|
|
|
37
|
-
|
|
38
|
-
|
|
46
|
+
var children = getField(item, 'children');
|
|
47
|
+
|
|
48
|
+
if (children) {
|
|
49
|
+
loop(children, _prefix, _valid, _disabled);
|
|
39
50
|
} else if (_valid) {
|
|
40
51
|
_prefix.disabled = _disabled;
|
|
41
52
|
ret.push(_prefix);
|
|
@@ -49,7 +60,7 @@ export function useFilterable(keywords, setValue) {
|
|
|
49
60
|
|
|
50
61
|
function selectByFilter(data) {
|
|
51
62
|
var value = _mapInstanceProperty(data).call(data, function (item) {
|
|
52
|
-
return item
|
|
63
|
+
return getField(item, 'value');
|
|
53
64
|
});
|
|
54
65
|
|
|
55
66
|
setValue(value);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useInstance } from 'intact-vue-next';
|
|
2
2
|
import { useBaseLabel } from '../select/useBaseLabel';
|
|
3
|
-
export function useLabel() {
|
|
3
|
+
export function useLabel(getField) {
|
|
4
4
|
var instance = useInstance();
|
|
5
5
|
|
|
6
6
|
function findLabel(data, value) {
|
|
@@ -16,9 +16,9 @@ export function useLabel() {
|
|
|
16
16
|
for (var i = 0; i < data.length; i++) {
|
|
17
17
|
var item = data[i];
|
|
18
18
|
|
|
19
|
-
if (item
|
|
20
|
-
labels.push(item
|
|
21
|
-
var children = item
|
|
19
|
+
if (getField(item, 'value') === value[level]) {
|
|
20
|
+
labels.push(getField(item, 'label'));
|
|
21
|
+
var children = getField(item, 'children');
|
|
22
22
|
|
|
23
23
|
if (children) {
|
|
24
24
|
loop(children, level + 1);
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { CascaderData } from './';
|
|
2
|
-
|
|
2
|
+
import type { useFields } from './useFields';
|
|
3
|
+
export declare function useLoad(getField: ReturnType<typeof useFields>): (item: CascaderData<any>) => Promise<void>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
|
|
2
2
|
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
3
3
|
import { useInstance } from 'intact-vue-next';
|
|
4
|
-
export function useLoad() {
|
|
4
|
+
export function useLoad(getField) {
|
|
5
5
|
var instance = useInstance();
|
|
6
6
|
|
|
7
7
|
function loadData(_x) {
|
|
@@ -10,7 +10,7 @@ export function useLoad() {
|
|
|
10
10
|
|
|
11
11
|
function _loadData() {
|
|
12
12
|
_loadData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(item) {
|
|
13
|
-
var _instance$get, loadData;
|
|
13
|
+
var _instance$get, loadData, children;
|
|
14
14
|
|
|
15
15
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
16
16
|
while (1) {
|
|
@@ -26,19 +26,21 @@ export function useLoad() {
|
|
|
26
26
|
return _context.abrupt("return");
|
|
27
27
|
|
|
28
28
|
case 3:
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
children = getField(item, 'children');
|
|
30
|
+
|
|
31
|
+
if (!(children && !children.length && !item.loaded)) {
|
|
32
|
+
_context.next = 9;
|
|
31
33
|
break;
|
|
32
34
|
}
|
|
33
35
|
|
|
34
|
-
_context.next =
|
|
36
|
+
_context.next = 7;
|
|
35
37
|
return loadData(item);
|
|
36
38
|
|
|
37
|
-
case
|
|
39
|
+
case 7:
|
|
38
40
|
item.loaded = true;
|
|
39
41
|
instance.forceUpdate();
|
|
40
42
|
|
|
41
|
-
case
|
|
43
|
+
case 9:
|
|
42
44
|
case "end":
|
|
43
45
|
return _context.stop();
|
|
44
46
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Component, TypeDefs } from 'intact-vue-next';
|
|
2
2
|
import { Sizes } from '../../styles/utils';
|
|
3
3
|
import { Container } from '../portal';
|
|
4
|
+
import { DropdownProps } from '../dropdown';
|
|
4
5
|
export interface ColorpickerProps {
|
|
5
6
|
value: string;
|
|
6
7
|
presets?: string[];
|
|
@@ -8,6 +9,7 @@ export interface ColorpickerProps {
|
|
|
8
9
|
disabled?: boolean;
|
|
9
10
|
container?: Container;
|
|
10
11
|
show?: boolean;
|
|
12
|
+
position?: DropdownProps['position'];
|
|
11
13
|
}
|
|
12
14
|
export interface ColorpickerEvents {
|
|
13
15
|
}
|
|
@@ -2,6 +2,7 @@ import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
|
|
|
2
2
|
import { Component } from 'intact-vue-next';
|
|
3
3
|
import template from './index.vdt';
|
|
4
4
|
import { sizes } from '../../styles/utils';
|
|
5
|
+
import { Dropdown } from '../dropdown';
|
|
5
6
|
var typeDefs = {
|
|
6
7
|
value: {
|
|
7
8
|
type: String,
|
|
@@ -11,13 +12,17 @@ var typeDefs = {
|
|
|
11
12
|
size: sizes,
|
|
12
13
|
disabled: Boolean,
|
|
13
14
|
container: [Function, String],
|
|
14
|
-
show: Boolean
|
|
15
|
+
show: Boolean,
|
|
16
|
+
position: Dropdown.typeDefs.position
|
|
15
17
|
};
|
|
16
18
|
|
|
17
19
|
var defaults = function defaults() {
|
|
18
20
|
return {
|
|
19
21
|
presets: ['#D0021B', '#F5A623', '#F8E71C', '#8B572A', '#7ED321', '#417505', '#BD10E0', '#9013FE', '#4A90E2', '#50E3C2', '#B8E986', '#000000', '#4A4A4A', '#9B9B9B', '#FFFFFF'],
|
|
20
|
-
size: 'default'
|
|
22
|
+
size: 'default',
|
|
23
|
+
position: {
|
|
24
|
+
collision: 'fit'
|
|
25
|
+
}
|
|
21
26
|
};
|
|
22
27
|
};
|
|
23
28
|
|
|
@@ -19,7 +19,8 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
19
19
|
value = _this$get.value,
|
|
20
20
|
size = _this$get.size,
|
|
21
21
|
disabled = _this$get.disabled,
|
|
22
|
-
container = _this$get.container
|
|
22
|
+
container = _this$get.container,
|
|
23
|
+
position = _this$get.position;
|
|
23
24
|
|
|
24
25
|
var classNameObj = (_classNameObj = {
|
|
25
26
|
'k-colorpicker': true
|
|
@@ -27,11 +28,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
27
28
|
return _$cv('div', _extends({
|
|
28
29
|
'className': _$cn(classNameObj)
|
|
29
30
|
}, getRestProps(this)), _$cc(Dropdown, {
|
|
30
|
-
'position':
|
|
31
|
-
my: 'left top+8',
|
|
32
|
-
at: 'left bottom',
|
|
33
|
-
collision: 'flip'
|
|
34
|
-
},
|
|
31
|
+
'position': position,
|
|
35
32
|
'trigger': 'click',
|
|
36
33
|
'disabled': disabled,
|
|
37
34
|
'container': container,
|
|
@@ -243,7 +243,7 @@ describe('Dialog', function () {
|
|
|
243
243
|
return wait(500);
|
|
244
244
|
|
|
245
245
|
case 20:
|
|
246
|
-
expect(document.body.getAttribute('style')).to.be.
|
|
246
|
+
expect(!!document.body.getAttribute('style')).to.be.false;
|
|
247
247
|
|
|
248
248
|
case 21:
|
|
249
249
|
case "end":
|
|
@@ -347,7 +347,7 @@ describe('Dialog', function () {
|
|
|
347
347
|
return wait(500);
|
|
348
348
|
|
|
349
349
|
case 18:
|
|
350
|
-
expect(document.body.getAttribute('style')).to.be.
|
|
350
|
+
expect(!!document.body.getAttribute('style')).to.be.false;
|
|
351
351
|
|
|
352
352
|
case 19:
|
|
353
353
|
case "end":
|
|
@@ -26,7 +26,6 @@ var typeDefs = {
|
|
|
26
26
|
var defaults = function defaults() {
|
|
27
27
|
return {
|
|
28
28
|
trigger: 'hover',
|
|
29
|
-
position: {},
|
|
30
29
|
of: 'self'
|
|
31
30
|
};
|
|
32
31
|
};
|
|
@@ -57,7 +56,6 @@ export var Dropdown = /*#__PURE__*/function (_Component) {
|
|
|
57
56
|
_this.rootDropdown = null;
|
|
58
57
|
_this.showedDropdown = null;
|
|
59
58
|
_this.positionHook = usePosition();
|
|
60
|
-
_this.alwaysPortal = false;
|
|
61
59
|
_this.timer = undefined;
|
|
62
60
|
_this.triggerProps = null;
|
|
63
61
|
return _this;
|
|
@@ -267,11 +265,10 @@ Dropdown.template = function () {
|
|
|
267
265
|
});
|
|
268
266
|
clonedTrigger.className = className;
|
|
269
267
|
this.menuVNode = menu;
|
|
270
|
-
return [clonedTrigger,
|
|
271
|
-
this.alwaysPortal || !this.rootDropdown ? h(Portal, {
|
|
268
|
+
return [clonedTrigger, h(Portal, {
|
|
272
269
|
children: menu,
|
|
273
270
|
container: this.get('container')
|
|
274
|
-
})
|
|
271
|
+
})];
|
|
275
272
|
};
|
|
276
273
|
|
|
277
274
|
__decorate([bind], Dropdown.prototype, "position", null);
|
|
@@ -288,9 +285,10 @@ function useDocumentClickForDropdown(dropdown) {
|
|
|
288
285
|
};
|
|
289
286
|
|
|
290
287
|
var _useDocumentClick = useDocumentClick(elementRef, function (e) {
|
|
291
|
-
// case 1: if click
|
|
292
|
-
// case 2: if right click on trigger and
|
|
293
|
-
// case 3: if click on trigger and
|
|
288
|
+
// case 1: if click a trigger and its trigger type is hover, ignore it
|
|
289
|
+
// case 2: if right click on a trigger and its trigger type is contextmenu, ignore it
|
|
290
|
+
// case 3: if click on a trigger and its trigger type is focus, do nothing
|
|
291
|
+
// case 3: if click on sub-dropdown, we should also show the parent dropdown, so ignore it
|
|
294
292
|
var trigger = dropdown.get('trigger');
|
|
295
293
|
if (trigger === 'focus') return;
|
|
296
294
|
var isHover = trigger === 'hover';
|
|
@@ -305,6 +303,7 @@ function useDocumentClickForDropdown(dropdown) {
|
|
|
305
303
|
}
|
|
306
304
|
}
|
|
307
305
|
|
|
306
|
+
if (isSubDropdownElement(e.target, dropdown)) return;
|
|
308
307
|
dropdown.hide(true);
|
|
309
308
|
}, true),
|
|
310
309
|
addDocumentClick = _useDocumentClick[0],
|
|
@@ -314,6 +313,18 @@ function useDocumentClickForDropdown(dropdown) {
|
|
|
314
313
|
dropdown.on('hide', removeDocumentClick);
|
|
315
314
|
}
|
|
316
315
|
|
|
316
|
+
function isSubDropdownElement(elem, dropdown) {
|
|
317
|
+
var showedDropdown = dropdown.showedDropdown;
|
|
318
|
+
if (!showedDropdown) return false;
|
|
319
|
+
var subMenuElement = findDomFromVNode(showedDropdown.menuVNode, true);
|
|
320
|
+
|
|
321
|
+
if (containsOrEqual(subMenuElement, elem)) {
|
|
322
|
+
return true;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
return isSubDropdownElement(elem, showedDropdown);
|
|
326
|
+
}
|
|
327
|
+
|
|
317
328
|
function useHideLastMenuOnShow(dropdown) {
|
|
318
329
|
var parentDropdown = dropdown.dropdown;
|
|
319
330
|
dropdown.on('show', function () {
|