@king-design/vue 2.0.17-beta.0 → 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.
Files changed (68) hide show
  1. package/__tests__/__snapshots__/Vue Next Demos.md +115 -91
  2. package/__tests__/components/editable.spec.ts +45 -0
  3. package/components/cascader/index.d.ts +22 -11
  4. package/components/cascader/index.js +9 -12
  5. package/components/cascader/index.spec.js +81 -0
  6. package/components/cascader/index.vdt.js +10 -8
  7. package/components/cascader/useFields.d.ts +2 -0
  8. package/components/cascader/useFields.js +18 -0
  9. package/components/cascader/useFilterable.d.ts +2 -1
  10. package/components/cascader/useFilterable.js +17 -6
  11. package/components/cascader/useLabel.d.ts +2 -1
  12. package/components/cascader/useLabel.js +4 -4
  13. package/components/cascader/useLoad.d.ts +2 -1
  14. package/components/cascader/useLoad.js +9 -7
  15. package/components/colorpicker/index.d.ts +2 -0
  16. package/components/colorpicker/index.js +7 -2
  17. package/components/colorpicker/index.vdt.js +3 -6
  18. package/components/dialog/index.spec.js +2 -2
  19. package/components/dropdown/dropdown.js +0 -1
  20. package/components/dropdown/item.js +3 -3
  21. package/components/dropdown/usePosition.js +8 -1
  22. package/components/editable/index.d.ts +1 -0
  23. package/components/editable/index.js +20 -6
  24. package/components/editable/index.vdt.js +2 -1
  25. package/components/input/index.d.ts +10 -2
  26. package/components/input/index.js +10 -3
  27. package/components/input/index.spec.js +169 -1
  28. package/components/input/index.vdt.js +26 -7
  29. package/components/input/styles.js +8 -3
  30. package/components/input/useAutoRows.d.ts +2 -0
  31. package/components/input/useAutoRows.js +79 -0
  32. package/components/input/useAutoWidth.js +13 -3
  33. package/components/input/useShowPassword.d.ts +7 -0
  34. package/components/input/useShowPassword.js +31 -0
  35. package/components/pagination/index.js +1 -3
  36. package/components/pagination/index.spec.js +2 -4
  37. package/components/portal.d.ts +6 -2
  38. package/components/portal.js +4 -3
  39. package/components/position.js +2 -1
  40. package/components/select/base.d.ts +2 -1
  41. package/components/select/base.js +3 -1
  42. package/components/select/base.vdt.js +3 -1
  43. package/components/table/cell.js +1 -6
  44. package/components/table/index.spec.js +130 -19
  45. package/components/table/row.d.ts +1 -1
  46. package/components/table/row.js +2 -1
  47. package/components/table/styles.js +1 -1
  48. package/components/table/table.d.ts +15 -0
  49. package/components/table/table.js +16 -7
  50. package/components/table/table.vdt.js +20 -6
  51. package/components/table/useChecked.d.ts +3 -2
  52. package/components/table/useChecked.js +23 -12
  53. package/components/table/useDisableRow.d.ts +2 -1
  54. package/components/table/useDisableRow.js +4 -4
  55. package/components/table/useDraggable.d.ts +3 -2
  56. package/components/table/useDraggable.js +11 -8
  57. package/components/table/useGroup.js +3 -0
  58. package/components/table/useMerge.d.ts +2 -1
  59. package/components/table/useMerge.js +5 -4
  60. package/components/table/usePagination.d.ts +8 -0
  61. package/components/table/usePagination.js +81 -0
  62. package/components/table/useTree.d.ts +2 -1
  63. package/components/table/useTree.js +3 -4
  64. package/components/tooltip/index.spec.js +9 -10
  65. package/index.d.ts +3 -3
  66. package/index.js +3 -3
  67. package/package.json +2 -2
  68. package/styles/fonts/ionicons.js +1 -1
@@ -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, nextTick } from 'intact-vue-next';
5
+ import { Component, createRef } from 'intact-vue-next';
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
- nextTick(function () {
56
- _this2.inputRef.value.select();
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-vue-next';
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-vue-next';
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
  });
@@ -1,11 +1,11 @@
1
1
  import _extends from "@babel/runtime-corejs3/helpers/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime-corejs3/helpers/objectWithoutPropertiesLoose";
3
- var _excluded = ["className", "style", "type", "value", "defaultValue", "placeholder", "clearable", "disabled", "size", "rows", "autoWidth", "fluid", "width", "stackClearIcon", "frozenOnInput", "readonly", "inline", "waveDisabled", "ev-click", "ev-mounseenter", "ev-mouseleave"];
3
+ var _excluded = ["className", "style", "type", "value", "defaultValue", "placeholder", "clearable", "disabled", "size", "rows", "autoWidth", "fluid", "width", "stackClearIcon", "frozenOnInput", "readonly", "inline", "waveDisabled", "resize", "ev-click", "ev-mounseenter", "ev-mouseleave"];
4
4
  import { createElementVNode as _$ce, className as _$cn, createUnknownComponentVNode as _$cc, noop as _$no, createVNode as _$cv } from 'intact-vue-next';
5
5
  import { Icon } from '../icon';
6
6
  import { addStyle, isTextBlock, getRestProps } from '../utils';
7
7
  import { makeStyles } from './styles';
8
- import { noop, isNullOrUndefined } from 'intact-shared';
8
+ import { noop, isNullOrUndefined, isStringOrNumber } from 'intact-shared';
9
9
  import { Wave } from '../wave';
10
10
  import { context as ErrorContext } from '../form/useError';
11
11
  export default function ($props, $blocks, $__proto__) {
@@ -39,6 +39,7 @@ export default function ($props, $blocks, $__proto__) {
39
39
  readonly = _this$get.readonly,
40
40
  inline = _this$get.inline,
41
41
  waveDisabled = _this$get.waveDisabled,
42
+ resize = _this$get.resize,
42
43
  click = _this$get['ev-click'],
43
44
  mouseenter = _this$get['ev-mounseenter'],
44
45
  mouseleave = _this$get['ev-mouseleave'],
@@ -50,12 +51,19 @@ export default function ($props, $blocks, $__proto__) {
50
51
  startInput = _this$frozen.startInput,
51
52
  onInput = _this$frozen.onInput,
52
53
  endInput = _this$frozen.endInput;
54
+ var isNotAutoRows = isStringOrNumber(rows) && rows !== 'auto';
53
55
  var classNameObj = (_classNameObj = {
54
56
  'k-input': true
55
- }, _classNameObj["k-" + size] = size !== 'default', _classNameObj['k-group'] = $blocks.prepend || $blocks.append, _classNameObj['k-disabled'] = disabled, _classNameObj['k-with-prefix'] = $blocks.prefix, _classNameObj['k-with-suffix'] = $blocks.suffix, _classNameObj['k-clearable'] = clearable, _classNameObj['k-auto-width'] = autoWidth, _classNameObj['k-fluid'] = fluid, _classNameObj['k-stack-clear'] = stackClearIcon, _classNameObj['k-inline'] = inline, _classNameObj[className] = className, _classNameObj[makeStyles()] = true, _classNameObj);
57
+ }, _classNameObj["k-" + size] = size !== 'default', _classNameObj['k-group'] = $blocks.prepend || $blocks.append, _classNameObj['k-disabled'] = disabled, _classNameObj['k-with-prefix'] = $blocks.prefix, _classNameObj['k-with-suffix'] = $blocks.suffix, _classNameObj['k-clearable'] = clearable, _classNameObj['k-auto-width'] = autoWidth, _classNameObj['k-fluid'] = fluid, _classNameObj['k-stack-clear'] = stackClearIcon, _classNameObj['k-inline'] = inline, _classNameObj["k-resize-" + resize] = type === 'textarea' && isNotAutoRows, _classNameObj["k-resize-none"] = type === 'textarea' && !isNotAutoRows, _classNameObj[className] = className, _classNameObj[makeStyles()] = true, _classNameObj);
58
+ var _this$showPassword = this.showPassword,
59
+ isShowPassword = _this$showPassword.isShow,
60
+ toggleShowPassword = _this$showPassword.toggleShow,
61
+ showPasswordType = _this$showPassword.type,
62
+ showPasswordIcon = _this$showPassword.showIcon;
56
63
  var _this$autoWidth = this.autoWidth,
57
64
  fakeRef = _this$autoWidth.fakeRef,
58
65
  fakeWidth = _this$autoWidth.width.value;
66
+ var height = this.autoRows;
59
67
  var inputValue = frozenOnInput && inputing ? originalValue : value;
60
68
  var hasInputValue = !isNullOrUndefined(inputValue);
61
69
  var hasValue = hasInputValue && inputValue !== '';
@@ -69,7 +77,7 @@ export default function ($props, $blocks, $__proto__) {
69
77
  placeholder: placeholder,
70
78
  disabled: disabled,
71
79
  ref: this.inputRef,
72
- style: autoWidth ? {
80
+ style: autoWidth && fakeWidth ? {
73
81
  width: fakeWidth + 'px'
74
82
  } : undefined
75
83
  }); // if we pass value to input element, the input is controlled and the
@@ -100,11 +108,22 @@ export default function ($props, $blocks, $__proto__) {
100
108
  return block ? block.call($this, callBlock, data) : callBlock();
101
109
  }, __$blocks['prefix'](_$no)), 0, 'k-input-prefix') : undefined, type !== 'textarea' ? _$cv('input', _extends({}, inputProps, {
102
110
  'className': 'k-input-inner',
103
- 'type': type
111
+ 'type': showPasswordType.value
104
112
  })) : _$cv('textarea', _extends({}, inputProps, {
105
113
  'className': 'k-input-inner k-textarea',
106
- 'rows': rows
107
- })), $blocks.suffix || clearable && !disabled ? _$ce(2, 'div', [clearable && !disabled ? _$cc(Icon, {
114
+ 'rows': isNotAutoRows ? rows : 1,
115
+ 'style': height.value ? addStyle(inputProps.style, {
116
+ height: height.value + 'px'
117
+ }) : inputProps.style
118
+ })), $blocks.suffix || clearable && !disabled || showPasswordIcon.value ? _$ce(2, 'div', [showPasswordIcon.value ? [_$cc(Icon, {
119
+ 'hoverable': true,
120
+ 'className': _$cn({
121
+ "k-input-show-password": true,
122
+ "ion-eye-disabled": !isShowPassword.value,
123
+ "ion-eye": isShowPassword.value
124
+ }),
125
+ 'ev-click': toggleShowPassword
126
+ }), ' '] : undefined, clearable && !disabled ? _$cc(Icon, {
108
127
  'className': _$cn({
109
128
  "k-input-clear ion-ios-close": true,
110
129
  "k-input-show": hasValue
@@ -3,6 +3,7 @@ import { css } from '@emotion/css';
3
3
  import { theme, setDefault } from '../../styles/theme';
4
4
  import { deepDefaults, sizes } from '../../styles/utils';
5
5
  import '../../styles/global';
6
+ import { Input } from './';
6
7
  var defaults = deepDefaults({
7
8
  get transition() {
8
9
  return theme.transition.middle;
@@ -58,7 +59,7 @@ var defaults = deepDefaults({
58
59
 
59
60
  // textarea
60
61
  get textareaPadding() {
61
- return "5px " + input.paddingGap;
62
+ return "6px " + input.paddingGap;
62
63
  },
63
64
 
64
65
  // group
@@ -120,12 +121,16 @@ setDefault(function () {
120
121
  }).input;
121
122
  });
122
123
  export function makeStyles() {
123
- return /*#__PURE__*/css("display:inline-block;width:", input.width, ";vertical-align:middle;.k-input-wrapper{display:inline-block;width:100%;position:relative;}.k-input-inner{display:inline-block;width:100%;border:", input.border, ";background-color:", input.bgColor, ";transition:border ", input.transition, ",background ", input.transition, ",box-shadow ", input.transition, ";border-radius:", input.borderRadius, ";outline:none;position:relative;color:", input.color, ";&:hover{border:", input.hoverBorder, ";z-index:1;}&:focus{border:", input.focusBorder, ";z-index:1;}&::placeholder{color:", input.placeholderColor, ";}}&.k-fluid{width:100%;}.k-input-prefix,.k-input-suffix{position:absolute;top:50%;transform:translateY(-50%);z-index:2;}.k-input-clear{opacity:0;transition:opacity ", input.transition, ";pointer-events:none;color:", input.clearIconColor, ";+*{margin-left:", input.clearIconGap, ";}}&:hover .k-input-clear.k-input-show{opacity:1;pointer-events:all;}&.k-stack-clear{.k-input-clear{position:absolute;z-index:1;right:0;&.k-input-show+i{transition:opacity ", input.transition, ";}}&:hover{.k-input-clear.k-input-show+i{opacity:0;}}}&.k-group{display:table;.k-input-inner{border-radius:0;}.k-input-wrapper:first-child{.k-input-inner{border-radius:", input.borderRadius, " 0 0 ", input.borderRadius, ";}}.k-input-wrapper:last-child{.k-input-inner{border-radius:0 ", input.borderRadius, " ", input.borderRadius, " 0;}}}.k-input-prepend,.k-input-append{display:table-cell;width:1px;vertical-align:middle;background-color:", input.groupBgColor, ";border:", input.border, ";text-align:center;white-space:nowrap;.k-btn{margin:-1px 0;border-radius:0;border:none;}.k-select{margin:-1px;text-align:left;}}.k-input-prepend{border-radius:", input.borderRadius, " 0 0 ", input.borderRadius, ";.k-select{z-index:1;.k-select-wrapper{border-radius:", theme.borderRadius, " 0 0 ", theme.borderRadius, ";}}}.k-input-append{border-radius:0 ", input.borderRadius, " ", input.borderRadius, " 0;.k-select{.k-select-wrapper{border-radius:0 ", theme.borderRadius, " ", theme.borderRadius, " 0;}}}.k-input-padding{padding:0 ", input.groupPaddingGap, ";}.k-input-prepend{border-right:none;}.k-input-append{border-left:none;}&.k-disabled{color:", input.disabledColor, ";cursor:not-allowed;.k-input-inner{color:", input.disabledColor, ";border-color:", input.disabledBorderColor, ";background:", input.disabledBgColor, ";cursor:not-allowed;}}", _mapInstanceProperty(sizes).call(sizes, function (size) {
124
+ var _context;
125
+
126
+ return /*#__PURE__*/css("display:inline-block;width:", input.width, ";vertical-align:middle;.k-input-wrapper{display:inline-block;width:100%;position:relative;}.k-input-inner{display:inline-block;width:100%;border:", input.border, ";background-color:", input.bgColor, ";transition:border ", input.transition, ",background ", input.transition, ",box-shadow ", input.transition, ";border-radius:", input.borderRadius, ";outline:none;position:relative;color:", input.color, ";&:hover{border:", input.hoverBorder, ";z-index:1;}&:focus{border:", input.focusBorder, ";z-index:1;}&::placeholder{color:", input.placeholderColor, ";}}&.k-fluid{width:100%;}.k-input-prefix,.k-input-suffix{position:absolute;top:50%;transform:translateY(-50%);z-index:2;}.k-input-clear{opacity:0;transition:opacity ", input.transition, ";pointer-events:none;color:", input.clearIconColor, ";+*{margin-left:", input.clearIconGap, ";}}&: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+i{transition:opacity ", input.transition, ";}}&:hover{.k-input-clear.k-input-show+i{opacity:0;}}}&.k-group{display:table;.k-input-inner{border-radius:0;}.k-input-wrapper:first-child{.k-input-inner{border-radius:", input.borderRadius, " 0 0 ", input.borderRadius, ";}}.k-input-wrapper:last-child{.k-input-inner{border-radius:0 ", input.borderRadius, " ", input.borderRadius, " 0;}}}.k-input-prepend,.k-input-append{display:table-cell;width:1px;vertical-align:middle;background-color:", input.groupBgColor, ";border:", input.border, ";text-align:center;white-space:nowrap;.k-btn{margin:-1px 0;border-radius:0;border:none;}.k-select{margin:-1px;text-align:left;}}.k-input-prepend{border-radius:", input.borderRadius, " 0 0 ", input.borderRadius, ";.k-select{z-index:1;.k-select-wrapper{border-radius:", theme.borderRadius, " 0 0 ", theme.borderRadius, ";}}}.k-input-append{border-radius:0 ", input.borderRadius, " ", input.borderRadius, " 0;.k-select{.k-select-wrapper{border-radius:0 ", theme.borderRadius, " ", theme.borderRadius, " 0;}}}.k-input-padding{padding:0 ", input.groupPaddingGap, ";}.k-input-prepend{border-right:none;}.k-input-append{border-left:none;}&.k-disabled{color:", input.disabledColor, ";cursor:not-allowed;.k-input-inner{color:", input.disabledColor, ";border-color:", input.disabledBorderColor, ";background:", input.disabledBgColor, ";cursor:not-allowed;}}", _mapInstanceProperty(sizes).call(sizes, function (size) {
124
127
  var styles = input[size];
125
128
  var sizeClassName = /*#__PURE__*/css("font-size:", styles.fontSize, ";.k-input-inner{height:", styles.height, ";line-height:", styles.height, ";font-size:", styles.fontSize, ";padding:0 ", styles.paddingGap, ";}.k-input-prefix{left:", styles.paddingGap, ";}.k-input-suffix{right:", styles.paddingGap, ";}&.k-with-prefix{.k-input-inner{padding-left:calc(", styles.paddingGap, " + 1rem + ", input.clearIconGap, ");}}&.k-with-suffix,&.k-clearable{.k-input-inner{padding-right:calc(", styles.paddingGap, " + 1rem + ", input.clearIconGap, ");}}&:not(.k-stack-clear).k-with-suffix.k-clearable{.k-input-inner{padding-right:calc(", styles.paddingGap, " + 2rem + ", input.clearIconGap, " * 2);}}");
126
129
  if (size === 'default') return sizeClassName;
127
130
  return /*#__PURE__*/css("&.k-", size, "{", sizeClassName, ";}");
128
- }), "&.k-inline{.k-input-inner{height:auto;line-height:inherit;border:none;border-radius:0;padding:0;}}.k-textarea{padding:", input.textareaPadding, ";height:auto;line-height:1.5;vertical-align:top;}.k-input-fake{position:absolute;visibility:hidden;top:0;white-space:nowrap;}&.k-auto-width{width:auto;.k-input-inner{box-sizing:content-box;}}");
131
+ }), "&.k-inline{.k-input-inner{height:auto;line-height:inherit;border:none;border-radius:0;padding:0;}}.k-textarea{padding:", input.textareaPadding, ";height:auto;line-height:1.5;vertical-align:top;}", _mapInstanceProperty(_context = Input.typeDefs.resize).call(_context, function (type) {
132
+ return /*#__PURE__*/css("&.k-resize-", type, "{.k-textarea{resize:", type, ";}}");
133
+ }), ".k-input-fake{position:absolute;visibility:hidden;top:0;white-space:nowrap;}&.k-auto-width{width:auto;max-width:100%;.k-input-inner{max-width:100%;box-sizing:content-box;}}");
129
134
  }
130
135
  export function makeSearchStyles() {
131
136
  return /*#__PURE__*/css("position:relative;display:inline-block;.k-input{transition:width ", input.transition, ";}.k-btn{position:absolute;top:0;right:0;z-index:1;}.k-input-suffix{margin-right:", input.search.suffixMarginRight, ";}&.k-hide{", _mapInstanceProperty(sizes).call(sizes, function (size) {
@@ -0,0 +1,2 @@
1
+ import { RefObject } from 'intact-vue-next';
2
+ export declare function useAutoRows(inputRef: RefObject<HTMLInputElement>): import("../../hooks/useState").State<number>;
@@ -0,0 +1,79 @@
1
+ import { useInstance, onMounted } from 'intact-vue-next';
2
+ import { useState } from '../../hooks/useState';
3
+ import { isObject } from 'intact-shared';
4
+ export function useAutoRows(inputRef) {
5
+ var instance = useInstance();
6
+ var height = useState(0);
7
+ var lineHeight;
8
+ var paddingTop;
9
+ var paddingBottom;
10
+ var isBorderBox;
11
+
12
+ function getStyles() {
13
+ if (instance.get('type') === 'textarea') {
14
+ var styles = getComputedStyle(inputRef.value);
15
+ lineHeight = parseInt(styles.lineHeight);
16
+ paddingTop = parseInt(styles.paddingTop);
17
+ paddingBottom = parseInt(styles.paddingBottom);
18
+ isBorderBox = styles.boxSizing === 'border-box';
19
+ }
20
+ }
21
+
22
+ onMounted(getStyles);
23
+ instance.watch('type', getStyles, {
24
+ presented: true
25
+ });
26
+ instance.watch('value', adjust, {
27
+ inited: true,
28
+ presented: true
29
+ });
30
+ instance.watch('placeholder', adjust, {
31
+ inited: true,
32
+ presented: true
33
+ });
34
+ instance.watch('rows', adjust, {
35
+ inited: true,
36
+ presented: true
37
+ });
38
+ onMounted(adjust);
39
+
40
+ function adjust() {
41
+ var _instance$get = instance.get(),
42
+ rows = _instance$get.rows,
43
+ type = _instance$get.type;
44
+
45
+ if (type === 'textarea' && (rows === 'auto' || isObject(rows))) {
46
+ var textarea = inputRef.value;
47
+ var originheight = textarea.style.height; // we shuold remove height before get scrollHeight,
48
+ // otherwise we cannot shrink the height when we remove the text
49
+
50
+ textarea.style.height = '';
51
+ var scrollHeight = textarea.scrollHeight;
52
+ var lines = (scrollHeight - paddingTop - paddingBottom) / lineHeight;
53
+ textarea.style.height = originheight;
54
+ var actualLines = lines;
55
+
56
+ if (rows !== 'auto') {
57
+ var min = rows.min,
58
+ max = rows.max;
59
+
60
+ if (min && lines <= min) {
61
+ actualLines = min;
62
+ }
63
+
64
+ if (max && lines >= max) {
65
+ actualLines = max;
66
+ }
67
+ }
68
+
69
+ height.set(lineHeight * actualLines + (isBorderBox ? paddingTop + paddingBottom + 2
70
+ /* border */
71
+ : 0));
72
+ return;
73
+ }
74
+
75
+ height.set(0);
76
+ }
77
+
78
+ return height;
79
+ }
@@ -1,4 +1,4 @@
1
- import { useInstance, createRef, onMounted } from 'intact-vue-next';
1
+ import { useInstance, createRef, onMounted, nextTick } from 'intact-vue-next';
2
2
  import { useState } from '../../hooks/useState';
3
3
  export function useAutoWidth() {
4
4
  var instance = useInstance();
@@ -16,9 +16,15 @@ export function useAutoWidth() {
16
16
 
17
17
  function adjustWidth() {
18
18
  if (instance.get('autoWidth')) {
19
- var _width = fakeRef.value.offsetWidth || 1;
19
+ nextTick(function () {
20
+ var fakeElem = fakeRef.value;
20
21
 
21
- width.set(_width);
22
+ if (isVisible(fakeElem)) {
23
+ var _width = fakeElem.offsetWidth || 1;
24
+
25
+ width.set(_width);
26
+ }
27
+ });
22
28
  }
23
29
  }
24
30
 
@@ -26,4 +32,8 @@ export function useAutoWidth() {
26
32
  fakeRef: fakeRef,
27
33
  width: width
28
34
  };
35
+ }
36
+
37
+ function isVisible(elem) {
38
+ return elem && (elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length);
29
39
  }
@@ -0,0 +1,7 @@
1
+ import type { HTMLInputTypes } from './';
2
+ export declare function useShowPassword(): {
3
+ isShow: import("../../hooks/useState").State<boolean>;
4
+ type: import("../../hooks/useState").State<HTMLInputTypes | undefined>;
5
+ toggleShow: () => void;
6
+ showIcon: import("../../hooks/useState").State<boolean>;
7
+ };
@@ -0,0 +1,31 @@
1
+ import { useInstance } from 'intact-vue-next';
2
+ import { useState } from '../../hooks/useState';
3
+ import { useReceive } from '../../hooks/useReceive';
4
+ export function useShowPassword() {
5
+ var instance = useInstance();
6
+ var isShow = useState(false);
7
+ var type = useState(undefined);
8
+ var showIcon = useState(false);
9
+ instance.on('$receive:type', function (_type) {
10
+ type.set(_type);
11
+ });
12
+ useReceive(['type', 'showPassword'], function () {
13
+ var _instance$get = instance.get(),
14
+ showPassword = _instance$get.showPassword,
15
+ type = _instance$get.type;
16
+
17
+ showIcon.set(type === 'password' && !!showPassword);
18
+ });
19
+
20
+ function toggleShow() {
21
+ isShow.set(!isShow.value);
22
+ type.set(isShow.value ? 'text' : 'password');
23
+ }
24
+
25
+ return {
26
+ isShow: isShow,
27
+ type: type,
28
+ toggleShow: toggleShow,
29
+ showIcon: showIcon
30
+ };
31
+ }
@@ -105,9 +105,7 @@ export var Pagination = /*#__PURE__*/function (_Component) {
105
105
 
106
106
  if (page > totalPages) {
107
107
  page = totalPages;
108
- }
109
-
110
- if (page < 1) {
108
+ } else if (page < 1) {
111
109
  page = 1;
112
110
  }
113
111
 
@@ -4,11 +4,9 @@ import BasicDemo from '~/components/pagination/demos/basic';
4
4
  import GotoDemo from '~/components/pagination/demos/goto';
5
5
  import CurrentDemo from '~/components/pagination/demos/current';
6
6
  import DisableDemo from '~/components/pagination/demos/disable';
7
- import { mount, unmount, dispatchEvent, wait } from '../../test/utils';
7
+ import { mount, dispatchEvent, wait } from '../../test/utils';
8
8
  describe('Pagination', function () {
9
- afterEach(function () {
10
- return unmount();
11
- });
9
+ // afterEach(() => unmount());
12
10
  it('basic test', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
13
11
  var _mount, instance, element, pagination, btns, prev, next;
14
12
 
@@ -11,8 +11,12 @@ export declare class Portal<T extends PortalProps = PortalProps> extends Compone
11
11
  mountedQueue?: Function[];
12
12
  mountedDone?: boolean;
13
13
  $isPortal: boolean;
14
- $render(lastVNode: VNodeComponentClass<this> | null, nextVNode: VNodeComponentClass<this>, parentDom: Element, anchor: IntactDom | null, mountedQueue: Function[]): void;
15
- $update(lastVNode: VNodeComponentClass<this>, nextVNode: VNodeComponentClass<this>, parentDom: Element, anchor: IntactDom | null, mountedQueue: Function[], force: boolean): void;
14
+ $render(lastVNode: VNodeComponentClass<this> | null, nextVNode: VNodeComponentClass<this>, parentDom: Element, anchor: IntactDom | null, mountedQueue: Function[] & {
15
+ priority?: Function[];
16
+ }): void;
17
+ $update(lastVNode: VNodeComponentClass<this>, nextVNode: VNodeComponentClass<this>, parentDom: Element, anchor: IntactDom | null, mountedQueue: Function[] & {
18
+ priority?: Function[];
19
+ }, force: boolean): void;
16
20
  $unmount(vNode: VNodeComponentClass<this>, nextVNode: VNodeComponentClass<this> | null): void;
17
21
  private initContainer;
18
22
  }