@king-design/react 3.0.0-beta.0 → 3.0.0-beta.2
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__/Dialog.md +1 -1
- package/__tests__/__snapshots__/React Demos.md +468 -309
- package/__tests__/components/cascader.spec.tsx +53 -0
- package/__tests__/components/drawer.spec.tsx +67 -5
- package/components/button/index.d.ts +1 -1
- package/components/button/index.js +1 -1
- package/components/button/styles.d.ts +1 -1
- package/components/button/styles.js +3 -5
- package/components/carousel/index.vdt.js +2 -2
- 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 +11 -9
- 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/collapse/item.vdt.js +1 -1
- 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/copy/index.d.ts +17 -0
- package/components/copy/index.js +43 -0
- package/components/copy/index.spec.d.ts +1 -0
- package/components/copy/index.spec.js +52 -0
- package/components/copy/index.vdt.js +45 -0
- package/components/copy/styles.d.ts +2 -0
- package/components/copy/styles.js +14 -0
- package/components/copy/useCopy.d.ts +4 -0
- package/components/copy/useCopy.js +90 -0
- package/components/datepicker/calendar.vdt.js +6 -6
- package/components/datepicker/index.spec.js +171 -153
- package/components/datepicker/index.vdt.js +1 -1
- package/components/datepicker/styles.js +1 -1
- package/components/datepicker/useValue.d.ts +3 -3
- package/components/datepicker/useValue.js +38 -9
- package/components/diagram/shapes/callout.d.ts +1 -1
- package/components/diagram/shapes/circle.d.ts +1 -1
- package/components/diagram/shapes/document.d.ts +1 -1
- package/components/diagram/shapes/ellipse.d.ts +1 -1
- package/components/diagram/shapes/hexagon.d.ts +1 -1
- package/components/diagram/shapes/image.d.ts +1 -1
- package/components/diagram/shapes/parallelogram.d.ts +1 -1
- package/components/diagram/shapes/rectangle.d.ts +1 -1
- package/components/diagram/shapes/square.d.ts +1 -1
- package/components/diagram/shapes/text.d.ts +1 -1
- package/components/dialog/alert.vdt.js +6 -5
- package/components/dialog/index.spec.js +6 -6
- package/components/dialog/styles.js +1 -1
- package/components/dropdown/dropdown.d.ts +6 -6
- package/components/dropdown/dropdown.js +58 -75
- package/components/dropdown/index.spec.js +96 -17
- package/components/dropdown/item.d.ts +1 -1
- package/components/dropdown/item.js +19 -7
- package/components/dropdown/menu.js +1 -1
- package/components/dropdown/usePosition.js +11 -2
- 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/form/index.spec.js +4 -2
- package/components/form/item.vdt.js +2 -1
- package/components/form/styles.js +4 -4
- package/components/grid/useGutter.js +8 -8
- package/components/icon/styles.js +1 -1
- package/components/input/index.d.ts +13 -2
- package/components/input/index.js +16 -13
- package/components/input/index.spec.js +169 -1
- package/components/input/index.vdt.js +44 -12
- package/components/input/search.vdt.js +2 -4
- package/components/input/styles.js +30 -6
- 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/useFocus.d.ts +4 -0
- package/components/input/useFocus.js +21 -0
- package/components/input/useShowPassword.d.ts +7 -0
- package/components/input/useShowPassword.js +31 -0
- package/components/menu/index.spec.js +26 -15
- package/components/menu/item.d.ts +2 -0
- package/components/menu/item.js +5 -0
- package/components/menu/item.vdt.js +4 -1
- package/components/pagination/index.d.ts +1 -1
- package/components/pagination/index.js +3 -2
- package/components/pagination/index.spec.js +49 -0
- package/components/pagination/index.vdt.js +10 -12
- package/components/pagination/styles.js +1 -1
- package/components/popover/content.d.ts +19 -0
- package/components/popover/content.js +31 -0
- package/components/popover/content.vdt.js +68 -0
- package/components/popover/index.d.ts +16 -0
- package/components/popover/index.js +44 -0
- package/components/popover/index.spec.d.ts +1 -0
- package/components/popover/index.spec.js +195 -0
- package/components/popover/styles.d.ts +1 -0
- package/components/popover/styles.js +22 -0
- package/components/portal.d.ts +6 -2
- package/components/portal.js +4 -3
- package/components/position.js +2 -1
- package/components/progress/index.js +1 -1
- package/components/progress/index.vdt.js +46 -8
- package/components/progress/styles.js +19 -13
- package/components/rate/styles.js +1 -1
- package/components/select/base.d.ts +7 -3
- package/components/select/base.js +9 -3
- package/components/select/base.vdt.js +75 -47
- package/components/select/index.spec.js +25 -13
- package/components/select/menu.vdt.js +6 -6
- package/components/select/option.vdt.js +2 -1
- package/components/select/styles.js +11 -5
- package/components/select/useDraggble.d.ts +2 -0
- package/components/select/useDraggble.js +11 -0
- package/components/slider/index.spec.js +48 -9
- package/components/slider/index.vdt.js +23 -12
- package/components/slider/styles.js +23 -14
- package/components/slider/useValue.d.ts +3 -1
- package/components/slider/useValue.js +12 -0
- package/components/spinner/index.d.ts +0 -1
- package/components/spinner/index.js +1 -19
- package/components/spinner/index.vdt.js +13 -8
- package/components/spinner/styles.js +2 -2
- package/components/spinner/useChange.d.ts +1 -1
- package/components/spinner/useChange.js +2 -2
- package/components/spinner/useValue.d.ts +1 -0
- package/components/spinner/useValue.js +16 -1
- package/components/split/index.vdt.js +32 -20
- package/components/split/memo.d.ts +9 -0
- package/components/split/memo.js +26 -0
- package/components/steps/index.d.ts +1 -0
- package/components/steps/index.js +2 -1
- package/components/steps/index.spec.js +1 -1
- package/components/steps/index.vdt.js +7 -4
- package/components/steps/step.vdt.js +2 -3
- package/components/steps/styles.d.ts +1 -0
- package/components/steps/styles.js +50 -17
- package/components/switch/index.spec.js +82 -65
- package/components/table/cell.js +1 -6
- package/components/table/cell.vdt.js +1 -1
- package/components/table/column.vdt.js +40 -24
- package/components/table/index.spec.js +162 -20
- package/components/table/row.d.ts +1 -1
- package/components/table/row.js +2 -1
- package/components/table/styles.js +16 -9
- 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 -15
- package/components/table/useGroup.d.ts +9 -3
- package/components/table/useGroup.js +48 -37
- 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/useStickyScrollbar.js +2 -2
- package/components/table/useTree.d.ts +2 -1
- package/components/table/useTree.js +3 -4
- package/components/table/useWidth.js +2 -2
- package/components/tabs/index.d.ts +1 -1
- package/components/tabs/index.js +1 -1
- package/components/tabs/index.spec.js +67 -0
- package/components/tabs/index.vdt.js +9 -4
- package/components/tabs/styles.js +32 -34
- package/components/tabs/useScroll.d.ts +1 -1
- package/components/tabs/useScroll.js +75 -48
- package/components/tag/base.d.ts +1 -0
- package/components/tag/base.js +1 -1
- package/components/tag/index.d.ts +1 -0
- package/components/tag/index.js +2 -1
- package/components/tag/index.spec.js +147 -4
- package/components/tag/styles.d.ts +67 -0
- package/components/tag/styles.js +33 -8
- package/components/tag/tags.d.ts +27 -0
- package/components/tag/tags.js +51 -0
- package/components/tag/tags.vdt.js +91 -0
- package/components/tag/useChildren.d.ts +2 -0
- package/components/tag/useChildren.js +39 -0
- package/components/tag/useDraggable.d.ts +3 -0
- package/components/tag/useDraggable.js +89 -0
- package/components/tag/useNowrap.d.ts +7 -0
- package/components/tag/useNowrap.js +115 -0
- package/components/timepicker/index.spec.js +1 -1
- package/components/tooltip/content.d.ts +3 -2
- package/components/tooltip/content.js +18 -1
- package/components/tooltip/content.vdt.js +22 -10
- package/components/tooltip/index.spec.js +147 -92
- package/components/tooltip/styles.d.ts +23 -0
- package/components/tooltip/styles.js +2 -2
- package/components/tooltip/tooltip.d.ts +1 -1
- package/components/tooltip/tooltip.js +11 -11
- package/components/transfer/index.vdt.js +14 -3
- package/components/types.d.ts +1 -0
- package/components/upload/index.spec.js +5 -6
- package/components/upload/index.vdt.js +7 -5
- package/components/utils.d.ts +2 -0
- package/components/utils.js +24 -3
- package/components/virtual.d.ts +8 -0
- package/components/virtual.js +126 -0
- package/hooks/useResizeObserver.d.ts +1 -1
- package/hooks/useResizeObserver.js +19 -6
- package/i18n/en-US.d.ts +4 -1
- package/i18n/en-US.js +6 -2
- package/index.d.ts +5 -3
- package/index.js +5 -3
- package/package.json +2 -2
- package/styles/fonts/iconfont.eot +0 -0
- package/styles/fonts/iconfont.js +2 -2
- package/styles/fonts/iconfont.svg +35 -35
- package/styles/fonts/iconfont.ttf +0 -0
- package/styles/fonts/iconfont.woff +0 -0
- package/styles/fonts/ionicons.js +3 -3
- package/styles/global.js +1 -1
- package/yarn-error.log +41 -43
- package/components/table/useResizeObserver.d.ts +0 -2
- package/components/table/useResizeObserver.js +0 -20
|
@@ -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-react';
|
|
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,12 @@
|
|
|
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"];
|
|
4
|
-
import
|
|
3
|
+
var _excluded = ["className", "style", "type", "value", "defaultValue", "placeholder", "clearable", "disabled", "size", "rows", "autoWidth", "fluid", "width", "stackClearIcon", "frozenOnInput", "readonly", "inline", "waveDisabled", "resize", "flat", "showCount", "maxlength", "ev-click", "ev-mounseenter", "ev-mouseleave"];
|
|
4
|
+
import _flatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/flat";
|
|
5
|
+
import { createElementVNode as _$ce, className as _$cn, createUnknownComponentVNode as _$cc, noop as _$no, createVNode as _$cv, createTextVNode as _$ct } from 'intact-react';
|
|
5
6
|
import { Icon } from '../icon';
|
|
6
|
-
import { addStyle, isTextBlock, getRestProps } from '../utils';
|
|
7
|
+
import { addStyle, isTextBlock, getRestProps, stopPropagation } from '../utils';
|
|
7
8
|
import { makeStyles } from './styles';
|
|
8
|
-
import { noop, isNullOrUndefined } from 'intact-shared';
|
|
9
|
+
import { noop, isNullOrUndefined, isStringOrNumber } from 'intact-shared';
|
|
9
10
|
import { Wave } from '../wave';
|
|
10
11
|
import { context as ErrorContext } from '../form/useError';
|
|
11
12
|
export default function ($props, $blocks, $__proto__) {
|
|
@@ -39,6 +40,10 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
39
40
|
readonly = _this$get.readonly,
|
|
40
41
|
inline = _this$get.inline,
|
|
41
42
|
waveDisabled = _this$get.waveDisabled,
|
|
43
|
+
resize = _this$get.resize,
|
|
44
|
+
flat = _flatInstanceProperty(_this$get),
|
|
45
|
+
showCount = _this$get.showCount,
|
|
46
|
+
maxlength = _this$get.maxlength,
|
|
42
47
|
click = _this$get['ev-click'],
|
|
43
48
|
mouseenter = _this$get['ev-mounseenter'],
|
|
44
49
|
mouseleave = _this$get['ev-mouseleave'],
|
|
@@ -50,12 +55,22 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
50
55
|
startInput = _this$frozen.startInput,
|
|
51
56
|
onInput = _this$frozen.onInput,
|
|
52
57
|
endInput = _this$frozen.endInput;
|
|
58
|
+
var _this$focusHook = this.focusHook,
|
|
59
|
+
isFocus = _this$focusHook.isFocus,
|
|
60
|
+
focusInputOnClick = _this$focusHook.focusInputOnClick;
|
|
61
|
+
var isNotAutoRows = isStringOrNumber(rows) && rows !== 'auto';
|
|
53
62
|
var classNameObj = (_classNameObj = {
|
|
54
63
|
'k-input': true
|
|
55
|
-
}, _classNameObj["k-" + size] = size !== 'default', _classNameObj['k-group'] = $blocks.prepend || $blocks.append, _classNameObj['k-disabled'] = disabled, _classNameObj['k-
|
|
64
|
+
}, _classNameObj["k-" + size] = size !== 'default', _classNameObj['k-group'] = $blocks.prepend || $blocks.append, _classNameObj['k-disabled'] = disabled, _classNameObj['k-clearable'] = clearable, _classNameObj['k-auto-width'] = autoWidth, _classNameObj['k-fluid'] = fluid, _classNameObj['k-stack-clear'] = stackClearIcon, _classNameObj['k-inline'] = inline, _classNameObj['k-flat'] = flat, _classNameObj['k-type-textarea'] = type === 'textarea', _classNameObj['k-focus'] = isFocus.value, _classNameObj["k-resize-" + resize] = type === 'textarea' && isNotAutoRows, _classNameObj["k-resize-none"] = type === 'textarea' && !isNotAutoRows, _classNameObj[className] = className, _classNameObj[makeStyles()] = true, _classNameObj);
|
|
65
|
+
var _this$showPassword = this.showPassword,
|
|
66
|
+
isShowPassword = _this$showPassword.isShow,
|
|
67
|
+
toggleShowPassword = _this$showPassword.toggleShow,
|
|
68
|
+
showPasswordType = _this$showPassword.type,
|
|
69
|
+
showPasswordIcon = _this$showPassword.showIcon;
|
|
56
70
|
var _this$autoWidth = this.autoWidth,
|
|
57
71
|
fakeRef = _this$autoWidth.fakeRef,
|
|
58
72
|
fakeWidth = _this$autoWidth.width.value;
|
|
73
|
+
var height = this.autoRows;
|
|
59
74
|
var inputValue = frozenOnInput && inputing ? originalValue : value;
|
|
60
75
|
var hasInputValue = !isNullOrUndefined(inputValue);
|
|
61
76
|
var hasValue = hasInputValue && inputValue !== '';
|
|
@@ -68,8 +83,9 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
68
83
|
readOnly: readonly,
|
|
69
84
|
placeholder: placeholder,
|
|
70
85
|
disabled: disabled,
|
|
86
|
+
maxLength: maxlength,
|
|
71
87
|
ref: this.inputRef,
|
|
72
|
-
style: autoWidth ? {
|
|
88
|
+
style: autoWidth && fakeWidth ? {
|
|
73
89
|
width: fakeWidth + 'px'
|
|
74
90
|
} : undefined
|
|
75
91
|
}); // if we pass value to input element, the input is controlled and the
|
|
@@ -88,6 +104,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
88
104
|
'children': function children(isInvalid) {
|
|
89
105
|
return _$cc(Wave, {
|
|
90
106
|
'disabled': waveDisabled || disabled || isInvalid,
|
|
107
|
+
'inset': '-2px',
|
|
91
108
|
'children': _$ce(2, 'div', [$blocks.prefix ? _$ce(2, 'div', (_$blocks['prefix'] = function ($super) {
|
|
92
109
|
return null;
|
|
93
110
|
}, __$blocks['prefix'] = function ($super, data) {
|
|
@@ -100,18 +117,29 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
100
117
|
return block ? block.call($this, callBlock, data) : callBlock();
|
|
101
118
|
}, __$blocks['prefix'](_$no)), 0, 'k-input-prefix') : undefined, type !== 'textarea' ? _$cv('input', _extends({}, inputProps, {
|
|
102
119
|
'className': 'k-input-inner',
|
|
103
|
-
'type':
|
|
120
|
+
'type': showPasswordType.value
|
|
104
121
|
})) : _$cv('textarea', _extends({}, inputProps, {
|
|
105
122
|
'className': 'k-input-inner k-textarea',
|
|
106
|
-
'rows': rows
|
|
107
|
-
|
|
123
|
+
'rows': isNotAutoRows ? rows : 1,
|
|
124
|
+
'style': height.value ? addStyle(inputProps.style, {
|
|
125
|
+
height: height.value + 'px'
|
|
126
|
+
}) : inputProps.style
|
|
127
|
+
})), $blocks.suffix || clearable && !disabled || showPasswordIcon.value || showCount ? _$ce(2, 'div', [showPasswordIcon.value ? [_$cc(Icon, {
|
|
128
|
+
'hoverable': true,
|
|
108
129
|
'className': _$cn({
|
|
109
|
-
"k-input-
|
|
130
|
+
"k-input-show-password": true,
|
|
131
|
+
"k-icon-hidden": !isShowPassword.value,
|
|
132
|
+
"k-icon-visible": isShowPassword.value
|
|
133
|
+
}),
|
|
134
|
+
'ev-click': toggleShowPassword
|
|
135
|
+
}), ' '] : undefined, clearable && !disabled ? _$cc(Icon, {
|
|
136
|
+
'className': _$cn({
|
|
137
|
+
"k-input-clear k-icon-error-fill": true,
|
|
110
138
|
"k-input-show": hasValue
|
|
111
139
|
}),
|
|
112
140
|
'ev-click': _this.clear,
|
|
113
141
|
'hoverable': true
|
|
114
|
-
}) : undefined, ' ', (_$blocks['suffix'] = function ($super) {
|
|
142
|
+
}) : undefined, ' ', showCount ? _$ce(2, 'span', [hasValue ? value.length : 0, maxlength ? _$ce(2, 'span', [_$ct(' / '), maxlength], 0) : undefined], 0, 'k-input-count') : undefined, (_$blocks['suffix'] = function ($super) {
|
|
115
143
|
return null;
|
|
116
144
|
}, __$blocks['suffix'] = function ($super, data) {
|
|
117
145
|
var block = $blocks['suffix'];
|
|
@@ -121,7 +149,11 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
121
149
|
};
|
|
122
150
|
|
|
123
151
|
return block ? block.call($this, callBlock, data) : callBlock();
|
|
124
|
-
}, __$blocks['suffix'](_$no))], 0, 'k-input-suffix'
|
|
152
|
+
}, __$blocks['suffix'](_$no))], 0, 'k-input-suffix', {
|
|
153
|
+
'ev-click': stopPropagation
|
|
154
|
+
}) : undefined, autoWidth ? _$ce(2, 'div', _$ce(2, 'span', !hasValue ? placeholder : inputValue, 0, null, null, null, fakeRef), 2, 'k-input-fake') : undefined], 0, 'k-input-wrapper', {
|
|
155
|
+
'ev-click': focusInputOnClick
|
|
156
|
+
})
|
|
125
157
|
});
|
|
126
158
|
}
|
|
127
159
|
}), $blocks.append ? (_children = $blocks.append(noop), _$ce(2, 'div', _children, 0, _$cn({
|
|
@@ -23,10 +23,9 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
23
23
|
size = _this$get.size,
|
|
24
24
|
open = _this$get.open;
|
|
25
25
|
|
|
26
|
-
var isTypeNotDefault = type !== 'default';
|
|
27
26
|
var classNameObj = (_classNameObj = {
|
|
28
27
|
'k-search': true
|
|
29
|
-
}, _classNameObj[className] = className, _classNameObj['k-open'] = open, _classNameObj['k-hide'] = !open, _classNameObj["k-" + type] =
|
|
28
|
+
}, _classNameObj[className] = className, _classNameObj['k-open'] = open, _classNameObj['k-hide'] = !open, _classNameObj["k-" + type] = type, _classNameObj[makeSearchStyles()] = true, _classNameObj);
|
|
30
29
|
return _$cv('form', _extends({}, getRestProps(this), {
|
|
31
30
|
'className': _$cn(classNameObj),
|
|
32
31
|
'ev-submit': this.onSubmit,
|
|
@@ -39,8 +38,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
39
38
|
'ev-$change:value': this.onChangeValue,
|
|
40
39
|
'readonly': !open,
|
|
41
40
|
'size': size,
|
|
42
|
-
'
|
|
43
|
-
'waveDisabled': isTypeNotDefault
|
|
41
|
+
'waveDisabled': type !== 'default'
|
|
44
42
|
}, null, this.inputRef), _$cc(Button, {
|
|
45
43
|
'icon': true,
|
|
46
44
|
'type': 'none',
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import _flatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/flat";
|
|
1
2
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js/instance/map";
|
|
2
3
|
import { css } from '@emotion/css';
|
|
3
4
|
import { theme, setDefault } from '../../styles/theme';
|
|
4
5
|
import { deepDefaults, sizes } from '../../styles/utils';
|
|
5
6
|
import '../../styles/global';
|
|
7
|
+
import { Input } from './';
|
|
6
8
|
var defaults = deepDefaults({
|
|
7
9
|
get transition() {
|
|
8
10
|
return theme.transition.middle;
|
|
@@ -58,7 +60,7 @@ var defaults = deepDefaults({
|
|
|
58
60
|
|
|
59
61
|
// textarea
|
|
60
62
|
get textareaPadding() {
|
|
61
|
-
return "
|
|
63
|
+
return "6px " + input.paddingGap;
|
|
62
64
|
},
|
|
63
65
|
|
|
64
66
|
// group
|
|
@@ -84,6 +86,24 @@ var defaults = deepDefaults({
|
|
|
84
86
|
// search input
|
|
85
87
|
search: {
|
|
86
88
|
suffixMarginRight: '15px'
|
|
89
|
+
},
|
|
90
|
+
// flat
|
|
91
|
+
flat: {
|
|
92
|
+
get color() {
|
|
93
|
+
return theme.color.lightBlack;
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
get bgColor() {
|
|
97
|
+
return theme.color.bg;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
},
|
|
101
|
+
// count
|
|
102
|
+
count: {
|
|
103
|
+
get color() {
|
|
104
|
+
return theme.color.placeholder;
|
|
105
|
+
}
|
|
106
|
+
|
|
87
107
|
}
|
|
88
108
|
}, sizes.reduce(function (memo, size) {
|
|
89
109
|
var styles = theme[size];
|
|
@@ -110,16 +130,20 @@ setDefault(function () {
|
|
|
110
130
|
}).input;
|
|
111
131
|
});
|
|
112
132
|
export function makeStyles() {
|
|
113
|
-
|
|
133
|
+
var _context;
|
|
134
|
+
|
|
135
|
+
return /*#__PURE__*/css("display:inline-block;width:", input.width, ";color:", input.color, ";vertical-align:middle;.k-input-wrapper{display:inline-flex;align-items:center;width:100%;position:relative;border:", input.border, ";background-color:", input.bgColor, ";transition:border ", input.transition, ",background ", input.transition, ",box-shadow ", input.transition, ";border-radius:", input.borderRadius, ";&:hover{border:", input.hoverBorder, ";z-index:1;}}&.k-focus .k-input-wrapper{border:", input.focusBorder, ";z-index:1;}.k-input-inner{flex:1;outline:none;color:inherit;font-size:inherit;border:none;background:transparent;padding:0;width:0;&::placeholder{color:", input.placeholderColor, ";}}&.k-fluid{width:100%;}.k-input-prefix,.k-input-suffix{display:flex;align-items:center;gap:", input.clearIconGap, ";color:", theme.color.lightBlack, ";position:relative;}.k-input-prefix{margin-right:", input.clearIconGap, ";}.k-input-suffix{margin-left:", input.clearIconGap, ";}.k-input-clear{opacity:0;transition:opacity ", input.transition, ";pointer-events:none;color:", input.clearIconColor, ";}&:hover .k-input-clear.k-input-show{opacity:1;pointer-events:all;}.k-input-show-password{color:", input.clearIconColor, ";}&.k-stack-clear{.k-input-clear{position:absolute;z-index:1;right:0;&.k-input-show+*{transition:opacity ", input.transition, ";}}&:hover{.k-input-clear.k-input-show+*{opacity:0;}}}&.k-group{display:inline-flex;.k-input-wrapper{border-radius:0;}.k-input-wrapper:first-child{border-radius:", input.borderRadius, " 0 0 ", input.borderRadius, ";}.k-input-wrapper:last-child{border-radius:0 ", input.borderRadius, " ", input.borderRadius, " 0;}}.k-input-prepend,.k-input-append{display:inline-flex;align-items:center;background-color:", input.groupBgColor, ";border:", input.border, ";white-space:nowrap;.k-btn{margin:-1px;border:none;&.k-none:hover{background:transparent;}}.k-select{margin:-1px;text-align:left;}}.k-input-prepend{&,.k-btn,.k-select{z-index:1;border-radius:", input.borderRadius, " 0 0 ", input.borderRadius, ";}}.k-input-append{&,.k-btn,.k-select{z-index:1;border-radius:0 ", input.borderRadius, " ", input.borderRadius, " 0;}}.k-input-padding{padding:0 ", input.groupPaddingGap, ";}.k-input-prepend{border-right:none;}.k-input-append{border-left:none;}&.k-flat{color:", _flatInstanceProperty(input).color, ";.k-input-wrapper{border:none;background:", _flatInstanceProperty(input).bgColor, ";}}&.k-disabled{color:", input.disabledColor, ";cursor:not-allowed;.k-input-wrapper{border-color:", input.disabledBorderColor, ";background:", input.disabledBgColor, ";}.k-input-inner{cursor:not-allowed;}}", _mapInstanceProperty(sizes).call(sizes, function (size) {
|
|
114
136
|
var styles = input[size];
|
|
115
|
-
var sizeClassName = /*#__PURE__*/css("font-size:", styles.fontSize, ";.k-input-
|
|
137
|
+
var sizeClassName = /*#__PURE__*/css("font-size:", styles.fontSize, ";.k-input-wrapper{height:", styles.height, ";padding:0 ", styles.paddingGap, ";}");
|
|
116
138
|
if (size === 'default') return sizeClassName;
|
|
117
139
|
return /*#__PURE__*/css("&.k-", size, "{", sizeClassName, ";}");
|
|
118
|
-
}), "&.k-inline{.k-input-
|
|
140
|
+
}), "&.k-inline{.k-input-wrapper{height:auto;border:none;border-radius:0;padding:0;}}&.k-type-textarea{.k-input-wrapper{display:inline-block;padding:0;height:auto;}.k-textarea{width:100%;padding:", input.textareaPadding, ";line-height:1.5;vertical-align:top;}.k-input-suffix{margin:0;justify-content:flex-end;}}", _mapInstanceProperty(_context = Input.typeDefs.resize).call(_context, function (type) {
|
|
141
|
+
return /*#__PURE__*/css("&.k-resize-", type, "{.k-textarea{resize:", type, ";}}");
|
|
142
|
+
}), ".k-input-fake{left:0;top:0;right:0;position:absolute;overflow:hidden;width:100%;visibility:hidden;white-space:nowrap;}&.k-auto-width{width:auto;max-width:100%;}.k-input-count{color:", input.count.color, ";}");
|
|
119
143
|
}
|
|
120
144
|
export function makeSearchStyles() {
|
|
121
|
-
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) {
|
|
145
|
+
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-default .k-btn:hover{background:transparent;}.k-input-suffix{margin-right:", input.search.suffixMarginRight, ";}&.k-hide{", _mapInstanceProperty(sizes).call(sizes, function (size) {
|
|
122
146
|
if (size == 'default') return;
|
|
123
147
|
return /*#__PURE__*/css(".k-input.k-", size, "{width:", input[size].height, ";}");
|
|
124
|
-
}), ";.k-input{width:", input.default.height, ";}.k-input-inner{padding:0!important;}}&.k-line{.k-input-
|
|
148
|
+
}), ";.k-input{width:", input.default.height, ";}.k-input-inner{padding:0!important;}}&.k-line{.k-input-wrapper{border-width:0;}&.k-open{.k-input-wrapper{border-bottom-width:1px;}.k-btn:hover{background:transparent;}}}");
|
|
125
149
|
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { useInstance, onMounted } from 'intact-react';
|
|
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-react';
|
|
1
|
+
import { useInstance, createRef, onMounted, nextTick } from 'intact-react';
|
|
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
|
-
|
|
19
|
+
nextTick(function () {
|
|
20
|
+
var fakeElem = fakeRef.value;
|
|
20
21
|
|
|
21
|
-
|
|
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,21 @@
|
|
|
1
|
+
import { useInstance } from 'intact-react';
|
|
2
|
+
import { useState } from '../../hooks/useState';
|
|
3
|
+
export function useFocus() {
|
|
4
|
+
var instance = useInstance();
|
|
5
|
+
var isFocus = useState(false);
|
|
6
|
+
instance.on('focus', function () {
|
|
7
|
+
return isFocus.set(true);
|
|
8
|
+
});
|
|
9
|
+
instance.on('blur', function () {
|
|
10
|
+
return isFocus.set(false);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
function focusInputOnClick(e) {
|
|
14
|
+
instance.focus();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
isFocus: isFocus,
|
|
19
|
+
focusInputOnClick: focusInputOnClick
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -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-react';
|
|
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
|
+
}
|