@king-design/intact 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/components/cascader/index.md +18 -0
- package/components/cascader/index.spec.ts +56 -0
- package/components/cascader/index.ts +35 -12
- package/components/cascader/index.vdt +9 -8
- package/components/cascader/styles.ts +2 -1
- package/components/cascader/useFields.ts +22 -0
- package/components/cascader/useFilterable.ts +23 -8
- package/components/cascader/useLabel.ts +7 -4
- package/components/cascader/useLoad.ts +4 -2
- package/components/code/demos/basic.md +1 -1
- package/components/colorpicker/index.md +16 -0
- package/components/colorpicker/index.ts +4 -0
- package/components/colorpicker/index.vdt +3 -2
- package/components/datepicker/index.md +11 -0
- package/components/dialog/index.spec.ts +2 -2
- package/components/dropdown/dropdown.ts +18 -10
- package/components/dropdown/item.ts +3 -2
- package/components/dropdown/menu.ts +1 -1
- package/components/dropdown/usePosition.ts +9 -1
- package/components/editable/index.ts +17 -3
- package/components/editable/index.vdt +1 -0
- package/components/input/demos/autoRows.md +44 -0
- package/components/input/demos/password.md +12 -0
- package/components/input/demos/textarea.md +2 -2
- package/components/input/index.md +1 -0
- package/components/input/index.spec.ts +97 -1
- package/components/input/index.ts +17 -3
- package/components/input/index.vdt +29 -6
- package/components/input/styles.ts +18 -1
- package/components/input/useAutoRows.ts +65 -0
- package/components/input/useAutoWidth.ts +12 -3
- package/components/input/useShowPassword.ts +27 -0
- package/components/pagination/index.spec.ts +1 -1
- package/components/pagination/index.ts +1 -2
- package/components/portal.ts +4 -4
- package/components/position.ts +5 -1
- package/components/select/base.ts +3 -1
- package/components/select/base.vdt +2 -0
- package/components/select/index.md +11 -1
- package/components/table/cell.ts +4 -5
- package/components/table/demos/hideHeader.md +33 -0
- package/components/table/demos/pagination.md +53 -0
- package/components/table/index.md +22 -0
- package/components/table/index.spec.ts +73 -1
- package/components/table/row.ts +3 -3
- package/components/table/styles.ts +5 -0
- package/components/table/table.ts +29 -4
- package/components/table/table.vdt +21 -3
- package/components/table/useChecked.ts +21 -6
- package/components/table/useDisableRow.ts +3 -2
- package/components/table/useDraggable.ts +11 -8
- package/components/table/useGroup.ts +2 -0
- package/components/table/useMerge.ts +6 -3
- package/components/table/usePagination.ts +71 -0
- package/components/table/useRestRowStatus.ts +4 -1
- package/components/table/useTree.ts +4 -3
- package/components/timepicker/index.md +11 -0
- package/components/tooltip/demos/trigger.md +1 -1
- package/components/tooltip/index.md +1 -1
- package/components/tooltip/index.spec.ts +8 -5
- package/components/tooltip/tooltip.ts +0 -2
- package/components/treeSelect/index.md +9 -0
- package/es/components/cascader/index.d.ts +22 -11
- package/es/components/cascader/index.js +9 -12
- package/es/components/cascader/index.spec.js +81 -0
- package/es/components/cascader/index.vdt.js +10 -8
- package/es/components/cascader/styles.js +1 -1
- package/es/components/cascader/useFields.d.ts +2 -0
- package/es/components/cascader/useFields.js +18 -0
- package/es/components/cascader/useFilterable.d.ts +2 -1
- package/es/components/cascader/useFilterable.js +17 -6
- package/es/components/cascader/useLabel.d.ts +2 -1
- package/es/components/cascader/useLabel.js +4 -4
- package/es/components/cascader/useLoad.d.ts +2 -1
- package/es/components/cascader/useLoad.js +9 -7
- package/es/components/colorpicker/index.d.ts +2 -0
- package/es/components/colorpicker/index.js +7 -2
- package/es/components/colorpicker/index.vdt.js +3 -6
- package/es/components/dialog/index.spec.js +2 -2
- package/es/components/dropdown/dropdown.d.ts +0 -1
- package/es/components/dropdown/dropdown.js +19 -8
- package/es/components/dropdown/item.js +3 -3
- package/es/components/dropdown/menu.js +1 -1
- package/es/components/dropdown/usePosition.js +8 -1
- package/es/components/editable/index.d.ts +1 -0
- package/es/components/editable/index.js +20 -6
- package/es/components/editable/index.vdt.js +2 -1
- package/es/components/input/index.d.ts +10 -2
- package/es/components/input/index.js +10 -3
- package/es/components/input/index.spec.js +169 -1
- package/es/components/input/index.vdt.js +26 -7
- package/es/components/input/styles.js +8 -3
- package/es/components/input/useAutoRows.d.ts +2 -0
- package/es/components/input/useAutoRows.js +79 -0
- package/es/components/input/useAutoWidth.js +13 -3
- package/es/components/input/useShowPassword.d.ts +7 -0
- package/es/components/input/useShowPassword.js +31 -0
- package/es/components/pagination/index.js +1 -3
- package/es/components/pagination/index.spec.js +2 -4
- package/es/components/portal.d.ts +6 -2
- package/es/components/portal.js +4 -3
- package/es/components/position.js +2 -1
- package/es/components/select/base.d.ts +2 -1
- package/es/components/select/base.js +3 -1
- package/es/components/select/base.vdt.js +3 -1
- package/es/components/table/cell.js +1 -6
- package/es/components/table/index.spec.js +130 -19
- package/es/components/table/row.d.ts +1 -1
- package/es/components/table/row.js +2 -1
- package/es/components/table/styles.js +1 -1
- package/es/components/table/table.d.ts +15 -0
- package/es/components/table/table.js +16 -7
- package/es/components/table/table.vdt.js +20 -6
- package/es/components/table/useChecked.d.ts +3 -2
- package/es/components/table/useChecked.js +23 -12
- package/es/components/table/useDisableRow.d.ts +2 -1
- package/es/components/table/useDisableRow.js +4 -4
- package/es/components/table/useDraggable.d.ts +3 -2
- package/es/components/table/useDraggable.js +11 -8
- package/es/components/table/useGroup.js +3 -0
- package/es/components/table/useMerge.d.ts +2 -1
- package/es/components/table/useMerge.js +5 -4
- package/es/components/table/usePagination.d.ts +8 -0
- package/es/components/table/usePagination.js +81 -0
- package/es/components/table/useTree.d.ts +2 -1
- package/es/components/table/useTree.js +3 -4
- package/es/components/tooltip/index.spec.js +9 -10
- package/es/components/tooltip/tooltip.d.ts +0 -1
- package/es/components/tooltip/tooltip.js +1 -12
- package/es/index.d.ts +3 -3
- package/es/index.js +3 -3
- package/es/packages/kpc-react/__tests__/components/cascader.spec.d.ts +1 -0
- package/es/packages/kpc-react/__tests__/components/cascader.spec.js +79 -0
- package/es/site/data/components/dialog/demos/basic/react.js +4 -1
- package/es/site/data/components/input/demos/autoRows/index.d.ts +9 -0
- package/es/site/data/components/input/demos/autoRows/index.js +24 -0
- package/es/site/data/components/input/demos/autoRows/react.d.ts +8 -0
- package/es/site/data/components/input/demos/autoRows/react.js +62 -0
- package/es/site/data/components/input/demos/password/index.d.ts +5 -0
- package/es/site/data/components/input/demos/password/index.js +17 -0
- package/es/site/data/components/input/demos/password/react.d.ts +5 -0
- package/es/site/data/components/input/demos/password/react.js +41 -0
- package/es/site/data/components/input/demos/textarea/react.js +4 -2
- package/es/site/data/components/table/demos/hideHeader/index.d.ts +12 -0
- package/es/site/data/components/table/demos/hideHeader/index.js +30 -0
- package/es/site/data/components/table/demos/hideHeader/react.d.ts +11 -0
- package/es/site/data/components/table/demos/hideHeader/react.js +60 -0
- package/es/site/data/components/table/demos/pagination/index.d.ts +12 -0
- package/es/site/data/components/table/demos/pagination/index.js +35 -0
- package/es/site/data/components/table/demos/pagination/react.d.ts +16 -0
- package/es/site/data/components/table/demos/pagination/react.js +65 -0
- package/es/styles/fonts/ionicons.js +1 -1
- package/index.ts +3 -3
- package/package.json +4 -4
- package/styles/fonts/ionicons.ts +0 -1
|
@@ -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';
|
|
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';
|
|
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';
|
|
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 () {
|
|
@@ -49,7 +49,9 @@ export var DropdownItem = /*#__PURE__*/function (_Component) {
|
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
_proto.select = function select() {
|
|
52
|
-
if (this.parentDropdown) return;
|
|
52
|
+
if (this.parentDropdown) return; // trigger select event firstly for Cascader update values
|
|
53
|
+
|
|
54
|
+
this.trigger('select');
|
|
53
55
|
|
|
54
56
|
if (this.get('hideOnSelect')) {
|
|
55
57
|
// hide all dropdowns
|
|
@@ -59,8 +61,6 @@ export var DropdownItem = /*#__PURE__*/function (_Component) {
|
|
|
59
61
|
dropdown.hide(true);
|
|
60
62
|
} while (dropdown = dropdown.dropdown);
|
|
61
63
|
}
|
|
62
|
-
|
|
63
|
-
this.trigger('select');
|
|
64
64
|
};
|
|
65
65
|
|
|
66
66
|
_proto.hasSubMenu = function hasSubMenu() {
|
|
@@ -85,7 +85,7 @@ function useKeyboardForDropdownMenu(dropdown) {
|
|
|
85
85
|
var focus = function focus() {
|
|
86
86
|
return focusByIndex(0);
|
|
87
87
|
}; // In Cascader the menu may have been replaced by another menu, in this case,
|
|
88
|
-
// if the dropdown has showed
|
|
88
|
+
// if the dropdown has showed while we mounted the menu, add keydown listener
|
|
89
89
|
|
|
90
90
|
|
|
91
91
|
if (dropdown.get('value')) {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
|
+
import _JSON$stringify from "@babel/runtime-corejs3/core-js/json/stringify";
|
|
2
3
|
import { useInstance, findDomFromVNode } from 'intact';
|
|
3
4
|
import { position } from '../position';
|
|
4
5
|
import { noop } from 'intact-shared';
|
|
6
|
+
import { isObject } from 'intact-shared';
|
|
5
7
|
export function usePosition() {
|
|
6
8
|
var instance = useInstance();
|
|
7
9
|
var positioned = {
|
|
@@ -13,7 +15,12 @@ export function usePosition() {
|
|
|
13
15
|
}
|
|
14
16
|
});
|
|
15
17
|
['of', 'position'].forEach(function (item) {
|
|
16
|
-
instance.watch(item, function () {
|
|
18
|
+
instance.watch(item, function (newValue, oldValue) {
|
|
19
|
+
// return if object is the same
|
|
20
|
+
if (isObject(newValue) && isObject(oldValue) && _JSON$stringify(newValue) === _JSON$stringify(oldValue)) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
17
24
|
if (instance.get('value')) {
|
|
18
25
|
handle(noop);
|
|
19
26
|
}
|
|
@@ -2,7 +2,7 @@ import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
|
|
|
2
2
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
|
|
3
3
|
import _trimInstanceProperty from "@babel/runtime-corejs3/core-js/instance/trim";
|
|
4
4
|
import { __decorate } from "tslib";
|
|
5
|
-
import { Component, createRef
|
|
5
|
+
import { Component, createRef } from 'intact';
|
|
6
6
|
import template from './index.vdt';
|
|
7
7
|
import { _$ } from '../../i18n';
|
|
8
8
|
import { bind } from '../utils';
|
|
@@ -49,12 +49,24 @@ export var Editable = /*#__PURE__*/function (_Component) {
|
|
|
49
49
|
var _proto = Editable.prototype;
|
|
50
50
|
|
|
51
51
|
_proto.edit = function edit() {
|
|
52
|
-
var _this2 = this;
|
|
53
|
-
|
|
54
52
|
this.set('editing', true);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Intact will update in nextTick, but Vue will call
|
|
55
|
+
* call updated method in nextTick of this nextTick
|
|
56
|
+
* so we should do it after two nextTicks
|
|
57
|
+
* https://github.com/ksc-fe/kpc/issues/847
|
|
58
|
+
*
|
|
59
|
+
* use binding this.select to Input $mounted event instead
|
|
60
|
+
*/
|
|
61
|
+
// nextTick(() => {
|
|
62
|
+
// nextTick(() => {
|
|
63
|
+
// this.inputRef.value!.select();
|
|
64
|
+
// });
|
|
65
|
+
// });
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
_proto.select = function select() {
|
|
69
|
+
this.inputRef.value.select();
|
|
58
70
|
};
|
|
59
71
|
|
|
60
72
|
_proto.onBlur = function onBlur(e) {
|
|
@@ -124,6 +136,8 @@ Editable.events = events;
|
|
|
124
136
|
|
|
125
137
|
__decorate([bind], Editable.prototype, "edit", null);
|
|
126
138
|
|
|
139
|
+
__decorate([bind], Editable.prototype, "select", null);
|
|
140
|
+
|
|
127
141
|
__decorate([bind], Editable.prototype, "onBlur", null);
|
|
128
142
|
|
|
129
143
|
__decorate([bind], Editable.prototype, "onKeydown", null);
|
|
@@ -40,7 +40,8 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
40
40
|
'ev-blur': this.onBlur,
|
|
41
41
|
'ev-keydown': this.onKeydown,
|
|
42
42
|
'ref': this.inputRef,
|
|
43
|
-
'frozenOnInput': true
|
|
43
|
+
'frozenOnInput': true,
|
|
44
|
+
'ev-$mounted': this.select
|
|
44
45
|
}, null, this.inputRef), 0, 'c-ellipsis')]);
|
|
45
46
|
}
|
|
46
47
|
;
|
|
@@ -2,7 +2,7 @@ import { Component, TypeDefs } from 'intact';
|
|
|
2
2
|
import { Sizes } from '../../styles/utils';
|
|
3
3
|
import { CommonInputHTMLAttributes, Events } from '../types';
|
|
4
4
|
export * from './search';
|
|
5
|
-
declare type HTMLInputTypes = 'textarea' | 'button' | 'checkbox' | 'color' | 'date' | 'datetime-local' | 'email' | 'file' | 'hidden' | 'image' | 'month' | 'number' | 'password' | 'radio' | 'range' | 'reset' | 'search' | 'submit' | 'tel' | 'text' | 'time' | 'url' | 'week' | (string & {});
|
|
5
|
+
export declare type HTMLInputTypes = 'textarea' | 'button' | 'checkbox' | 'color' | 'date' | 'datetime-local' | 'email' | 'file' | 'hidden' | 'image' | 'month' | 'number' | 'password' | 'radio' | 'range' | 'reset' | 'search' | 'submit' | 'tel' | 'text' | 'time' | 'url' | 'week' | (string & {});
|
|
6
6
|
interface InputHTMLAttributes extends CommonInputHTMLAttributes {
|
|
7
7
|
pattern?: string;
|
|
8
8
|
dirname?: string;
|
|
@@ -20,7 +20,7 @@ export interface InputProps<V extends Value = Value> extends InputHTMLAttributes
|
|
|
20
20
|
clearable?: boolean;
|
|
21
21
|
disabled?: boolean;
|
|
22
22
|
size?: Sizes;
|
|
23
|
-
rows?: string | number;
|
|
23
|
+
rows?: string | number | 'auto' | AutoRows;
|
|
24
24
|
autoWidth?: boolean;
|
|
25
25
|
fluid?: boolean;
|
|
26
26
|
width?: number | string;
|
|
@@ -28,7 +28,13 @@ export interface InputProps<V extends Value = Value> extends InputHTMLAttributes
|
|
|
28
28
|
frozenOnInput?: boolean;
|
|
29
29
|
inline?: boolean;
|
|
30
30
|
waveDisabled?: boolean;
|
|
31
|
+
resize?: 'none' | 'vertical' | 'horizontal' | 'both';
|
|
32
|
+
showPassword?: boolean;
|
|
31
33
|
}
|
|
34
|
+
export declare type AutoRows = {
|
|
35
|
+
min?: number;
|
|
36
|
+
max?: number;
|
|
37
|
+
};
|
|
32
38
|
export interface InputEvents {
|
|
33
39
|
clear: [MouseEvent];
|
|
34
40
|
focus: [FocusEvent];
|
|
@@ -49,6 +55,8 @@ export declare class Input<V extends Value = Value> extends Component<InputProps
|
|
|
49
55
|
private inputRef;
|
|
50
56
|
private autoWidth;
|
|
51
57
|
private frozen;
|
|
58
|
+
private autoRows;
|
|
59
|
+
private showPassword;
|
|
52
60
|
focus(): void;
|
|
53
61
|
blur(): void;
|
|
54
62
|
select(): void;
|
|
@@ -7,6 +7,8 @@ import template from './index.vdt';
|
|
|
7
7
|
import { bind } from '../utils';
|
|
8
8
|
import { useAutoWidth } from './useAutoWidth';
|
|
9
9
|
import { useFrozen } from './useFrozen';
|
|
10
|
+
import { useAutoRows } from './useAutoRows';
|
|
11
|
+
import { useShowPassword } from './useShowPassword';
|
|
10
12
|
export * from './search';
|
|
11
13
|
var typeDefs = {
|
|
12
14
|
type: String,
|
|
@@ -17,21 +19,24 @@ var typeDefs = {
|
|
|
17
19
|
clearable: Boolean,
|
|
18
20
|
disabled: Boolean,
|
|
19
21
|
size: sizes,
|
|
20
|
-
rows: [String, Number],
|
|
22
|
+
rows: [String, Number, 'auto', Object],
|
|
21
23
|
autoWidth: Boolean,
|
|
22
24
|
fluid: Boolean,
|
|
23
25
|
width: [Number, String],
|
|
24
26
|
stackClearIcon: Boolean,
|
|
25
27
|
frozenOnInput: Boolean,
|
|
26
28
|
inline: Boolean,
|
|
27
|
-
waveDisabled: Boolean
|
|
29
|
+
waveDisabled: Boolean,
|
|
30
|
+
resize: ['none', 'vertical', 'horizontal', 'both'],
|
|
31
|
+
showPassword: Boolean
|
|
28
32
|
};
|
|
29
33
|
|
|
30
34
|
var defaults = function defaults() {
|
|
31
35
|
return {
|
|
32
36
|
type: 'text',
|
|
33
37
|
size: 'default',
|
|
34
|
-
rows: 2
|
|
38
|
+
rows: 2,
|
|
39
|
+
resize: 'vertical'
|
|
35
40
|
};
|
|
36
41
|
};
|
|
37
42
|
|
|
@@ -57,6 +62,8 @@ export var Input = /*#__PURE__*/function (_Component) {
|
|
|
57
62
|
_this.inputRef = createRef();
|
|
58
63
|
_this.autoWidth = useAutoWidth();
|
|
59
64
|
_this.frozen = useFrozen();
|
|
65
|
+
_this.autoRows = useAutoRows(_this.inputRef);
|
|
66
|
+
_this.showPassword = useShowPassword();
|
|
60
67
|
return _this;
|
|
61
68
|
}
|
|
62
69
|
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
|
|
1
2
|
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
|
|
3
|
+
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
|
|
2
4
|
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
3
5
|
import BasicDemo from '~/components/input/demos/basic';
|
|
4
|
-
import { mount, unmount, dispatchEvent, wait } from '../../test/utils';
|
|
6
|
+
import { mount, unmount, dispatchEvent, wait, getElement } from '../../test/utils';
|
|
5
7
|
import SearchDemo from '~/components/input/demos/search';
|
|
6
8
|
import FrozenDemo from '~/components/input/demos/frozen';
|
|
9
|
+
import AutoRowsDemo from '~/components/input/demos/autoRows';
|
|
10
|
+
import PasswordDemo from '~/components/input/demos/password';
|
|
11
|
+
import { Input } from './';
|
|
12
|
+
import { Dialog } from '../dialog';
|
|
13
|
+
import { Component } from 'intact';
|
|
7
14
|
describe('Input', function () {
|
|
8
15
|
afterEach(function () {
|
|
9
16
|
unmount();
|
|
@@ -124,4 +131,165 @@ describe('Input', function () {
|
|
|
124
131
|
}
|
|
125
132
|
}, _callee3);
|
|
126
133
|
})));
|
|
134
|
+
it('should auto expand or shrink textarea', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
135
|
+
var _mount4, instance, element, _element$querySelecto2, textarea1, textarea2;
|
|
136
|
+
|
|
137
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
138
|
+
while (1) {
|
|
139
|
+
switch (_context4.prev = _context4.next) {
|
|
140
|
+
case 0:
|
|
141
|
+
_mount4 = mount(AutoRowsDemo), instance = _mount4[0], element = _mount4[1];
|
|
142
|
+
_element$querySelecto2 = element.querySelectorAll('textarea'), textarea1 = _element$querySelecto2[0], textarea2 = _element$querySelecto2[1]; // const lineHeight = parseInt(getComputedStyle(textarea1).lineHeight);
|
|
143
|
+
|
|
144
|
+
instance.set('value1', 'a\nb');
|
|
145
|
+
_context4.next = 5;
|
|
146
|
+
return wait();
|
|
147
|
+
|
|
148
|
+
case 5:
|
|
149
|
+
expect(textarea1.style.height).to.eql('50px');
|
|
150
|
+
instance.set('value1', 'a');
|
|
151
|
+
_context4.next = 9;
|
|
152
|
+
return wait();
|
|
153
|
+
|
|
154
|
+
case 9:
|
|
155
|
+
expect(textarea1.style.height).to.eql('32px');
|
|
156
|
+
instance.set('value2', 'a');
|
|
157
|
+
_context4.next = 13;
|
|
158
|
+
return wait();
|
|
159
|
+
|
|
160
|
+
case 13:
|
|
161
|
+
expect(textarea2.style.height).to.eql('68px');
|
|
162
|
+
instance.set('value2', 'a\nb\nc');
|
|
163
|
+
_context4.next = 17;
|
|
164
|
+
return wait();
|
|
165
|
+
|
|
166
|
+
case 17:
|
|
167
|
+
expect(textarea2.style.height).to.eql('68px');
|
|
168
|
+
instance.set('value2', 'a\nb\nc\nd');
|
|
169
|
+
_context4.next = 21;
|
|
170
|
+
return wait();
|
|
171
|
+
|
|
172
|
+
case 21:
|
|
173
|
+
expect(textarea2.style.height).to.eql('86px');
|
|
174
|
+
instance.set('value2', 'a\nb\nc\nd\ne\nf\ng\nh');
|
|
175
|
+
_context4.next = 25;
|
|
176
|
+
return wait();
|
|
177
|
+
|
|
178
|
+
case 25:
|
|
179
|
+
expect(textarea2.style.height).to.eql('104px');
|
|
180
|
+
|
|
181
|
+
case 26:
|
|
182
|
+
case "end":
|
|
183
|
+
return _context4.stop();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}, _callee4);
|
|
187
|
+
})));
|
|
188
|
+
it('should show or hide password', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
189
|
+
var _mount5, instance, element, input, icon, inputInstance;
|
|
190
|
+
|
|
191
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
192
|
+
while (1) {
|
|
193
|
+
switch (_context5.prev = _context5.next) {
|
|
194
|
+
case 0:
|
|
195
|
+
_mount5 = mount(PasswordDemo), instance = _mount5[0], element = _mount5[1];
|
|
196
|
+
input = element.querySelector('input');
|
|
197
|
+
icon = element.querySelector('.k-icon');
|
|
198
|
+
inputInstance = instance.refs.__demo;
|
|
199
|
+
icon.click();
|
|
200
|
+
_context5.next = 7;
|
|
201
|
+
return wait();
|
|
202
|
+
|
|
203
|
+
case 7:
|
|
204
|
+
expect(input.type).to.eql('text');
|
|
205
|
+
expect(element.innerHTML).to.matchSnapshot();
|
|
206
|
+
icon.click();
|
|
207
|
+
_context5.next = 12;
|
|
208
|
+
return wait();
|
|
209
|
+
|
|
210
|
+
case 12:
|
|
211
|
+
expect(input.type).to.eql('password');
|
|
212
|
+
expect(element.innerHTML).to.matchSnapshot(); // simulate receive type
|
|
213
|
+
|
|
214
|
+
inputInstance.$props.type = 'number';
|
|
215
|
+
inputInstance.trigger('$receive:type', 'number');
|
|
216
|
+
_context5.next = 18;
|
|
217
|
+
return wait();
|
|
218
|
+
|
|
219
|
+
case 18:
|
|
220
|
+
expect(input.type).to.eql('number');
|
|
221
|
+
expect(icon.parentElement.parentElement).to.eql(null);
|
|
222
|
+
expect(element.innerHTML).to.matchSnapshot(); // simulate receive showPassword
|
|
223
|
+
|
|
224
|
+
inputInstance.$props.type = 'password';
|
|
225
|
+
inputInstance.$props.showPassword = false;
|
|
226
|
+
inputInstance.trigger('$receive:type', 'password');
|
|
227
|
+
inputInstance.trigger('$receive:showPassword', false);
|
|
228
|
+
_context5.next = 27;
|
|
229
|
+
return wait();
|
|
230
|
+
|
|
231
|
+
case 27:
|
|
232
|
+
expect(input.type).to.eql('password');
|
|
233
|
+
expect(element.querySelector('.k-icon')).to.eql(null);
|
|
234
|
+
expect(element.innerHTML).to.matchSnapshot();
|
|
235
|
+
|
|
236
|
+
case 30:
|
|
237
|
+
case "end":
|
|
238
|
+
return _context5.stop();
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}, _callee5);
|
|
242
|
+
})));
|
|
243
|
+
it('should set width when dialog show and input mounted', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
244
|
+
var Demo, _mount6, instance, dialog, width;
|
|
245
|
+
|
|
246
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context7) {
|
|
247
|
+
while (1) {
|
|
248
|
+
switch (_context7.prev = _context7.next) {
|
|
249
|
+
case 0:
|
|
250
|
+
Demo = /*#__PURE__*/function (_Component) {
|
|
251
|
+
_inheritsLoose(Demo, _Component);
|
|
252
|
+
|
|
253
|
+
function Demo() {
|
|
254
|
+
var _context6;
|
|
255
|
+
|
|
256
|
+
var _this;
|
|
257
|
+
|
|
258
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
259
|
+
args[_key] = arguments[_key];
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
_this = _Component.call.apply(_Component, _concatInstanceProperty(_context6 = [this]).call(_context6, args)) || this;
|
|
263
|
+
_this.Dialog = Dialog;
|
|
264
|
+
_this.Input = Input;
|
|
265
|
+
return _this;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
Demo.defaults = function defaults() {
|
|
269
|
+
return {
|
|
270
|
+
show: false
|
|
271
|
+
};
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
return Demo;
|
|
275
|
+
}(Component);
|
|
276
|
+
|
|
277
|
+
Demo.template = "\n var Dialog = this.Dialog;\n var Input = this.Input;\n <Dialog value={this.get('show')}>\n <Input autoWidth placeholder=\"test\" v-if={this.get('show')} />\n </Dialog>\n ";
|
|
278
|
+
_mount6 = mount(Demo), instance = _mount6[0];
|
|
279
|
+
instance.set('show', true);
|
|
280
|
+
_context7.next = 6;
|
|
281
|
+
return wait(50);
|
|
282
|
+
|
|
283
|
+
case 6:
|
|
284
|
+
dialog = getElement('.k-dialog');
|
|
285
|
+
width = parseInt(dialog.querySelector('.k-input-inner').style.width);
|
|
286
|
+
expect(width).to.gt(1);
|
|
287
|
+
|
|
288
|
+
case 9:
|
|
289
|
+
case "end":
|
|
290
|
+
return _context7.stop();
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}, _callee6);
|
|
294
|
+
})));
|
|
127
295
|
});
|