@opentiny/vue-renderless 3.1.0-alpha.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/action-sheet/index.js +28 -0
- package/action-sheet/vue.js +29 -0
- package/alert/index.js +23 -0
- package/alert/vue.js +37 -0
- package/autocomplete/index.js +175 -0
- package/autocomplete/vue.js +171 -0
- package/avatar/index.js +29 -0
- package/avatar/vue.js +24 -0
- package/badge/index.js +16 -0
- package/badge/vue.js +30 -0
- package/breadcrumb/vue.js +4 -0
- package/breadcrumb-item/vue.js +24 -0
- package/bulletin-board/index.js +21 -0
- package/bulletin-board/vue.js +36 -0
- package/button/index.js +19 -0
- package/button/vue.js +43 -0
- package/button-group/index.js +25 -0
- package/button-group/vue.js +51 -0
- package/calendar/index.js +279 -0
- package/calendar/vue.js +124 -0
- package/card-template/index.js +39 -0
- package/card-template/vue.js +34 -0
- package/carousel/index.js +206 -0
- package/carousel/vue.js +222 -0
- package/carousel-item/index.js +93 -0
- package/carousel-item/vue.js +57 -0
- package/cascader/index.js +511 -0
- package/cascader/vue.js +342 -0
- package/cascader-menu/index.js +41 -0
- package/cascader-menu/vue.js +36 -0
- package/cascader-node/index.js +63 -0
- package/cascader-node/vue.js +62 -0
- package/cascader-panel/index.js +359 -0
- package/cascader-panel/node.js +199 -0
- package/cascader-panel/store.js +80 -0
- package/cascader-panel/vue.js +217 -0
- package/checkbox/index.js +145 -0
- package/checkbox/vue.js +139 -0
- package/checkbox-button/index.js +102 -0
- package/checkbox-button/vue.js +150 -0
- package/checkbox-group/index.js +12 -0
- package/checkbox-group/vue.js +33 -0
- package/col/index.js +132 -0
- package/col/vue.js +34 -0
- package/collapse/index.js +45 -0
- package/collapse/vue.js +35 -0
- package/collapse-item/index.js +38 -0
- package/collapse-item/vue.js +48 -0
- package/common/array.js +120 -0
- package/common/bigInt.js +352 -0
- package/common/browser.js +69 -0
- package/common/dataset/index.js +135 -0
- package/common/date.js +352 -0
- package/common/decimal.js +203 -0
- package/common/deps/ResizeObserver.js +474 -0
- package/common/deps/after-leave.js +25 -0
- package/common/deps/clickoutside.js +61 -0
- package/common/deps/date-util.js +262 -0
- package/common/deps/date.js +308 -0
- package/common/deps/debounce.js +4 -0
- package/common/deps/dom.js +190 -0
- package/common/deps/fullscreen/apis.js +157 -0
- package/common/deps/fullscreen/screenfull.js +106 -0
- package/common/deps/letter-only.js +15 -0
- package/common/deps/memorize.js +149 -0
- package/common/deps/number-only.js +16 -0
- package/common/deps/popper.js +713 -0
- package/common/deps/popup-manager.js +179 -0
- package/common/deps/repeat-click.js +24 -0
- package/common/deps/requestAnimationFrame.js +25 -0
- package/common/deps/resize-event.js +29 -0
- package/common/deps/scroll-into-view.js +29 -0
- package/common/deps/scrollbar-width.js +25 -0
- package/common/deps/throttle.js +34 -0
- package/common/deps/touch.js +33 -0
- package/common/deps/tree-model/node.js +586 -0
- package/common/deps/tree-model/tree-store.js +377 -0
- package/common/deps/tree-model/util.js +14 -0
- package/common/deps/upload-ajax.js +71 -0
- package/common/deps/vue-emitter.js +30 -0
- package/common/deps/vue-popper.js +291 -0
- package/common/deps/vue-popup.js +211 -0
- package/common/event.js +17 -0
- package/common/index.js +288 -0
- package/common/object.js +228 -0
- package/common/runtime.js +52 -0
- package/common/string.js +446 -0
- package/common/type.js +65 -0
- package/common/validate/index.js +6 -0
- package/common/validate/messages.js +68 -0
- package/common/validate/rules/enum.js +8 -0
- package/common/validate/rules/index.js +14 -0
- package/common/validate/rules/pattern.js +16 -0
- package/common/validate/rules/range.js +62 -0
- package/common/validate/rules/required.js +13 -0
- package/common/validate/rules/type.js +110 -0
- package/common/validate/rules/whitespace.js +6 -0
- package/common/validate/schema.js +323 -0
- package/common/validate/util.js +198 -0
- package/common/validate/validations/array.js +25 -0
- package/common/validate/validations/date.js +35 -0
- package/common/validate/validations/enum.js +24 -0
- package/common/validate/validations/float.js +24 -0
- package/common/validate/validations/index.js +42 -0
- package/common/validate/validations/integer.js +24 -0
- package/common/validate/validations/method.js +23 -0
- package/common/validate/validations/number.js +27 -0
- package/common/validate/validations/pattern.js +23 -0
- package/common/validate/validations/required.js +15 -0
- package/common/validate/validations/string.js +29 -0
- package/common/validate/validations/type.js +25 -0
- package/common/xss.js +325 -0
- package/container/index.js +110 -0
- package/container/vue.js +63 -0
- package/credit-card/index.js +107 -0
- package/credit-card/vue.js +117 -0
- package/credit-card-form/index.js +143 -0
- package/credit-card-form/vue.js +150 -0
- package/crop/index.js +297 -0
- package/crop/vue.js +191 -0
- package/date-panel/index.js +584 -0
- package/date-panel/vue.js +319 -0
- package/date-picker/index.js +301 -0
- package/date-picker/vue.js +169 -0
- package/date-range/index.js +463 -0
- package/date-range/vue.js +297 -0
- package/date-table/index.js +457 -0
- package/date-table/vue.js +151 -0
- package/detail-page/index.js +135 -0
- package/detail-page/vue.js +145 -0
- package/dialog-box/index.js +268 -0
- package/dialog-box/vue.js +226 -0
- package/drop-times/index.js +23 -0
- package/drop-times/vue.js +28 -0
- package/dropdown/index.js +259 -0
- package/dropdown/vue.js +107 -0
- package/dropdown-item/index.js +155 -0
- package/dropdown-item/vue.js +124 -0
- package/dropdown-menu/index.js +148 -0
- package/dropdown-menu/vue.js +44 -0
- package/exception/index.js +13 -0
- package/exception/vue.js +25 -0
- package/fall-menu/index.js +121 -0
- package/fall-menu/vue.js +90 -0
- package/file-upload/index.js +1940 -0
- package/file-upload/vue.js +458 -0
- package/floatbar/index.js +10 -0
- package/floatbar/vue.js +17 -0
- package/form/index.js +186 -0
- package/form/vue.js +69 -0
- package/form-item/index.js +364 -0
- package/form-item/vue.js +210 -0
- package/fullscreen/index.js +138 -0
- package/fullscreen/vue.js +77 -0
- package/grid/core/index.js +3 -0
- package/grid/core/interceptor.js +38 -0
- package/grid/core/storeMap.js +19 -0
- package/grid/plugins/export.js +169 -0
- package/grid/plugins/exportExcel.js +749 -0
- package/grid/plugins/header.js +58 -0
- package/grid/plugins/resize.js +82 -0
- package/grid/static/array/arrayEach.js +12 -0
- package/grid/static/array/arrayIndexOf.js +11 -0
- package/grid/static/array/eachTree.js +32 -0
- package/grid/static/array/every.js +2 -0
- package/grid/static/array/filterTree.js +16 -0
- package/grid/static/array/find.js +3 -0
- package/grid/static/array/findTree.js +46 -0
- package/grid/static/array/helperCreateIterateHandle.js +59 -0
- package/grid/static/array/helperCreateTreeFunc.js +18 -0
- package/grid/static/array/includes.js +5 -0
- package/grid/static/array/lastArrayEach.js +6 -0
- package/grid/static/array/map.js +23 -0
- package/grid/static/array/mapTree.js +33 -0
- package/grid/static/array/slice.js +10 -0
- package/grid/static/array/sortBy.js +69 -0
- package/grid/static/array/sum.js +28 -0
- package/grid/static/array/toArray.js +7 -0
- package/grid/static/array/toTreeArray.js +24 -0
- package/grid/static/base/clear.js +44 -0
- package/grid/static/base/clone.js +18 -0
- package/grid/static/base/destructuring.js +18 -0
- package/grid/static/base/each.js +9 -0
- package/grid/static/base/eqNull.js +6 -0
- package/grid/static/base/findIndexOf.js +10 -0
- package/grid/static/base/get.js +42 -0
- package/grid/static/base/has.js +60 -0
- package/grid/static/base/hasOwnProp.js +4 -0
- package/grid/static/base/helperCreateGetObjects.js +26 -0
- package/grid/static/base/helperCreateInInObjectString.js +7 -0
- package/grid/static/base/helperCreateInTypeof.js +6 -0
- package/grid/static/base/helperCreateIndexOf.js +21 -0
- package/grid/static/base/helperCreateiterateIndexOf.js +21 -0
- package/grid/static/base/helperDefaultCompare.js +4 -0
- package/grid/static/base/helperDeleteProperty.js +8 -0
- package/grid/static/base/helperEqualCompare.js +60 -0
- package/grid/static/base/helperGetHGSKeys.js +4 -0
- package/grid/static/base/indexOf.js +3 -0
- package/grid/static/base/isArray.js +3 -0
- package/grid/static/base/isBoolean.js +4 -0
- package/grid/static/base/isDate.js +3 -0
- package/grid/static/base/isEmpty.js +8 -0
- package/grid/static/base/isEqual.js +11 -0
- package/grid/static/base/isFunction.js +4 -0
- package/grid/static/base/isNaN.js +5 -0
- package/grid/static/base/isNull.js +4 -0
- package/grid/static/base/isNumber.js +4 -0
- package/grid/static/base/isObject.js +5 -0
- package/grid/static/base/isPlainObject.js +2 -0
- package/grid/static/base/isRegExp.js +3 -0
- package/grid/static/base/isSet.js +5 -0
- package/grid/static/base/isString.js +4 -0
- package/grid/static/base/isUndefined.js +4 -0
- package/grid/static/base/keys.js +3 -0
- package/grid/static/base/lastEach.js +9 -0
- package/grid/static/base/remove.js +44 -0
- package/grid/static/base/set.js +43 -0
- package/grid/static/base/toJSONString.js +4 -0
- package/grid/static/base/toStringJSON.js +13 -0
- package/grid/static/base/uniqueId.js +5 -0
- package/grid/static/browse/browse.js +54 -0
- package/grid/static/function/property.js +7 -0
- package/grid/static/function/throttle.js +43 -0
- package/grid/static/index.js +55 -0
- package/grid/static/number/helperCreateToNumber.js +12 -0
- package/grid/static/number/toNumber.js +3 -0
- package/grid/static/object/assign.js +41 -0
- package/grid/static/object/extend.js +3 -0
- package/grid/static/object/lastObjectEach.js +8 -0
- package/grid/static/object/objectEach.js +11 -0
- package/grid/static/object/objectMap.js +20 -0
- package/grid/static/object/values.js +9 -0
- package/grid/static/static/staticDocument.js +4 -0
- package/grid/static/static/staticHGKeyRE.js +2 -0
- package/grid/static/static/staticParseInt.js +2 -0
- package/grid/static/static/staticStrUndefined.js +2 -0
- package/grid/static/static/staticWindow.js +4 -0
- package/grid/static/string/template.js +12 -0
- package/grid/static/string/toString.js +12 -0
- package/grid/utils/column.js +72 -0
- package/grid/utils/common.js +155 -0
- package/grid/utils/dom.js +213 -0
- package/grid/utils/event.js +40 -0
- package/grid/utils/index.js +5 -0
- package/image/index.js +187 -0
- package/image/vue.js +142 -0
- package/image-viewer/index.js +469 -0
- package/image-viewer/vue.js +243 -0
- package/input/index.js +319 -0
- package/input/vue.js +319 -0
- package/ip-address/index.js +370 -0
- package/ip-address/vue.js +185 -0
- package/layout/vue.js +4 -0
- package/link/index.js +10 -0
- package/link/vue.js +26 -0
- package/link-menu/index.js +146 -0
- package/link-menu/vue.js +138 -0
- package/list/index.js +13 -0
- package/list/vue.js +17 -0
- package/loading/index.js +29 -0
- package/loading/vue.js +28 -0
- package/milestone/index.js +92 -0
- package/milestone/vue.js +31 -0
- package/mini-picker/index.js +227 -0
- package/mini-picker/vue.js +142 -0
- package/modal/index.js +866 -0
- package/modal/vue.js +130 -0
- package/month-range/index.js +169 -0
- package/month-range/vue.js +104 -0
- package/month-table/index.js +232 -0
- package/month-table/vue.js +72 -0
- package/nav-menu/index.js +457 -0
- package/nav-menu/vue.js +187 -0
- package/notify/index.js +91 -0
- package/notify/vue.js +67 -0
- package/numeric/index.js +419 -0
- package/numeric/vue.js +218 -0
- package/option/index.js +79 -0
- package/option/vue.js +219 -0
- package/option-group/index.js +18 -0
- package/option-group/vue.js +37 -0
- package/package.json +179 -0
- package/pager-item/index.js +122 -0
- package/pager-item/vue.js +52 -0
- package/panel/index.js +30 -0
- package/panel/vue.js +26 -0
- package/picker/index.js +1039 -0
- package/picker/timezone.js +974 -0
- package/picker/vue.js +415 -0
- package/picker-column/index.js +261 -0
- package/picker-column/vue.js +163 -0
- package/pop-upload/index.js +324 -0
- package/pop-upload/vue.js +292 -0
- package/popeditor/index.js +884 -0
- package/popeditor/vue.js +368 -0
- package/popover/index.js +203 -0
- package/popover/vue.js +174 -0
- package/popup/index.js +139 -0
- package/popup/vue.js +129 -0
- package/progress/index.js +174 -0
- package/progress/vue.js +118 -0
- package/pull-refresh/index.js +104 -0
- package/pull-refresh/vue.js +64 -0
- package/radio/index.js +83 -0
- package/radio/vue.js +99 -0
- package/radio-button/index.js +58 -0
- package/radio-button/vue.js +70 -0
- package/radio-group/index.js +51 -0
- package/radio-group/vue.js +34 -0
- package/rate/index.js +254 -0
- package/rate/vue.js +158 -0
- package/row/index.js +19 -0
- package/row/vue.js +24 -0
- package/scroll-text/index.js +24 -0
- package/scroll-text/vue.js +31 -0
- package/scrollbar/index.js +127 -0
- package/scrollbar/vue-bar.js +49 -0
- package/scrollbar/vue.js +43 -0
- package/search/index.js +110 -0
- package/search/vue.js +110 -0
- package/select/index.js +1766 -0
- package/select/vue.js +693 -0
- package/select-dropdown/index.js +23 -0
- package/select-dropdown/vue.js +122 -0
- package/slide-bar/index.js +94 -0
- package/slide-bar/vue.js +58 -0
- package/slider/index.js +434 -0
- package/slider/vue.js +172 -0
- package/split/index.js +122 -0
- package/split/vue.js +131 -0
- package/steps/vue.js +4 -0
- package/switch/index.js +45 -0
- package/switch/vue.js +62 -0
- package/tab-bar/index.js +51 -0
- package/tab-bar/vue.js +16 -0
- package/tab-dropdown/index.js +11 -0
- package/tab-dropdown/vue.js +17 -0
- package/tab-item/index.js +37 -0
- package/tab-item/vue.js +49 -0
- package/tab-nav/index.js +247 -0
- package/tab-nav/vue.js +106 -0
- package/tabbar/index.js +32 -0
- package/tabbar/vue.js +54 -0
- package/tabbar-item/index.js +55 -0
- package/tabbar-item/vue.js +53 -0
- package/table/index.js +111 -0
- package/table/vue.js +66 -0
- package/tabs/index.js +174 -0
- package/tabs/vue.js +141 -0
- package/tag/index.js +14 -0
- package/tag/vue.js +13 -0
- package/tall-storage/index.js +161 -0
- package/tall-storage/vue-storage-box.js +25 -0
- package/tall-storage/vue.js +38 -0
- package/text-popup/index.js +75 -0
- package/text-popup/vue.js +64 -0
- package/time/index.js +121 -0
- package/time/vue.js +124 -0
- package/time-line/index.js +60 -0
- package/time-line/vue.js +49 -0
- package/time-panel/index.js +189 -0
- package/time-panel/scrollIntoView.js +23 -0
- package/time-panel/vue.js +110 -0
- package/time-range/index.js +199 -0
- package/time-range/vue.js +129 -0
- package/time-spinner/index.js +175 -0
- package/time-spinner/vue.js +122 -0
- package/toggle-menu/index.js +104 -0
- package/toggle-menu/vue.js +74 -0
- package/tooltip/index.js +171 -0
- package/tooltip/vue.js +133 -0
- package/top-box/index.js +81 -0
- package/top-box/vue.js +77 -0
- package/transfer/index.js +296 -0
- package/transfer/vue.js +138 -0
- package/transfer-panel/index.js +364 -0
- package/transfer-panel/vue.js +258 -0
- package/tree/index.js +642 -0
- package/tree/vue.js +268 -0
- package/tree-menu/index.js +124 -0
- package/tree-menu/vue.js +60 -0
- package/tree-node/index.js +271 -0
- package/tree-node/vue.js +211 -0
- package/upload/index.js +324 -0
- package/upload/vue.js +93 -0
- package/upload-dragger/index.js +50 -0
- package/upload-dragger/vue.js +27 -0
- package/upload-list/index.js +55 -0
- package/upload-list/vue.js +48 -0
- package/user-contact/index.js +13 -0
- package/user-contact/vue.js +20 -0
- package/user-head/index.js +71 -0
- package/user-head/vue.js +47 -0
- package/wizard/index.js +123 -0
- package/wizard/vue.js +45 -0
- package/year-table/index.js +40 -0
- package/year-table/vue.js +23 -0
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import { KEY_CODE, IPTHRESHOLD } from '@opentiny/vue-renderless/common';
|
|
2
|
+
export var isIP6 = function isIP6(str) {
|
|
3
|
+
return /^IPv6$/i.test(str);
|
|
4
|
+
};
|
|
5
|
+
export var isIP4 = function isIP4(str) {
|
|
6
|
+
return /^IPv4$/i.test(str);
|
|
7
|
+
};
|
|
8
|
+
export var ipValidator = function ipValidator(_ref) {
|
|
9
|
+
var props = _ref.props,
|
|
10
|
+
api = _ref.api;
|
|
11
|
+
return function (value) {
|
|
12
|
+
var result = true;
|
|
13
|
+
if (props.type) {
|
|
14
|
+
if (api.isIP6(props.type)) {
|
|
15
|
+
result = typeof value === 'string';
|
|
16
|
+
} else if (api.isIP4(props.type)) {
|
|
17
|
+
result = /^((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}$/.test(value);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return result;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export var getCursorPosition = function getCursorPosition(el) {
|
|
24
|
+
var cursorPos = 0;
|
|
25
|
+
var selectRange = null;
|
|
26
|
+
if (document.selection) {
|
|
27
|
+
selectRange = document.selection.createRange();
|
|
28
|
+
selectRange.moveStart('character', -el.value.length);
|
|
29
|
+
cursorPos = selectRange.text.length;
|
|
30
|
+
}
|
|
31
|
+
if (el.selectionStart || el.selectionStart === '0') {
|
|
32
|
+
cursorPos = el.selectionStart;
|
|
33
|
+
}
|
|
34
|
+
return cursorPos;
|
|
35
|
+
};
|
|
36
|
+
export var getValue = function getValue(_ref2) {
|
|
37
|
+
var api = _ref2.api,
|
|
38
|
+
props = _ref2.props,
|
|
39
|
+
state = _ref2.state;
|
|
40
|
+
return function () {
|
|
41
|
+
var valueArr = [];
|
|
42
|
+
var result = '';
|
|
43
|
+
if (api.isIP6(props.type)) {
|
|
44
|
+
result = state.address[0].value || '';
|
|
45
|
+
} else {
|
|
46
|
+
state.address.forEach(function (item) {
|
|
47
|
+
if (api.isIP4(props.type) && item.value) {
|
|
48
|
+
item.value = item.value.replace(/\D/g, '');
|
|
49
|
+
}
|
|
50
|
+
item.value && valueArr.push(item.value);
|
|
51
|
+
});
|
|
52
|
+
result = state.address.filter(function (item) {
|
|
53
|
+
return item.value;
|
|
54
|
+
}).length === 4 ? valueArr.join('.') : '';
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
export var setValue = function setValue(_ref3) {
|
|
60
|
+
var api = _ref3.api,
|
|
61
|
+
props = _ref3.props,
|
|
62
|
+
state = _ref3.state;
|
|
63
|
+
return function (value) {
|
|
64
|
+
if (value) {
|
|
65
|
+
if (api.ipValidator(value)) {
|
|
66
|
+
if (api.isIP6(props.type)) {
|
|
67
|
+
state.address = [{
|
|
68
|
+
value: value
|
|
69
|
+
}];
|
|
70
|
+
} else {
|
|
71
|
+
state.address = value.split('.').map(function (item) {
|
|
72
|
+
return {
|
|
73
|
+
value: item
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
} else {
|
|
79
|
+
state.address = api.isIP6(props.type) ? [{
|
|
80
|
+
value: ''
|
|
81
|
+
}] : [{
|
|
82
|
+
value: ''
|
|
83
|
+
}, {
|
|
84
|
+
value: ''
|
|
85
|
+
}, {
|
|
86
|
+
value: ''
|
|
87
|
+
}, {
|
|
88
|
+
value: ''
|
|
89
|
+
}];
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
var activeEvent = function activeEvent(_ref4) {
|
|
94
|
+
var emit = _ref4.emit,
|
|
95
|
+
parent = _ref4.parent,
|
|
96
|
+
state = _ref4.state,
|
|
97
|
+
index = _ref4.index,
|
|
98
|
+
event = _ref4.event,
|
|
99
|
+
type = _ref4.type;
|
|
100
|
+
var target = event && event.target ? event.target : parent.$el.querySelectorAll('input')[index || 0];
|
|
101
|
+
type === 'focus' && (state.active = true);
|
|
102
|
+
if (!event) {
|
|
103
|
+
if (target && !state.isSelected) {
|
|
104
|
+
state.isSelected = true;
|
|
105
|
+
target[type]();
|
|
106
|
+
setTimeout(function () {
|
|
107
|
+
state.isSelected = false;
|
|
108
|
+
}, 10);
|
|
109
|
+
emit(type, target.value, index);
|
|
110
|
+
}
|
|
111
|
+
} else {
|
|
112
|
+
!state.isSelected && emit(type, target.value, index);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
export var focus = function focus(_ref5) {
|
|
116
|
+
var emit = _ref5.emit,
|
|
117
|
+
parent = _ref5.parent,
|
|
118
|
+
state = _ref5.state;
|
|
119
|
+
return function (_ref6) {
|
|
120
|
+
var index = _ref6.index,
|
|
121
|
+
event = _ref6.event;
|
|
122
|
+
activeEvent({
|
|
123
|
+
emit: emit,
|
|
124
|
+
parent: parent,
|
|
125
|
+
state: state,
|
|
126
|
+
index: index,
|
|
127
|
+
event: event,
|
|
128
|
+
type: 'focus'
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
export var select = function select(_ref7) {
|
|
133
|
+
var emit = _ref7.emit,
|
|
134
|
+
parent = _ref7.parent,
|
|
135
|
+
state = _ref7.state;
|
|
136
|
+
return function (_ref8) {
|
|
137
|
+
var index = _ref8.index,
|
|
138
|
+
event = _ref8.event;
|
|
139
|
+
activeEvent({
|
|
140
|
+
emit: emit,
|
|
141
|
+
parent: parent,
|
|
142
|
+
state: state,
|
|
143
|
+
index: index,
|
|
144
|
+
event: event,
|
|
145
|
+
type: 'select'
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
export var inputEvent = function inputEvent(_ref9) {
|
|
150
|
+
var api = _ref9.api,
|
|
151
|
+
emit = _ref9.emit,
|
|
152
|
+
props = _ref9.props;
|
|
153
|
+
return function (_ref10) {
|
|
154
|
+
var item = _ref10.item,
|
|
155
|
+
index = _ref10.index;
|
|
156
|
+
var val = item.value.trim();
|
|
157
|
+
var value = '';
|
|
158
|
+
if (api.isIP4(props.type)) {
|
|
159
|
+
if (!index && api.ipValidator(val)) {
|
|
160
|
+
api.setValue(val);
|
|
161
|
+
} else if (isNaN(val) || val < IPTHRESHOLD.Min || val > IPTHRESHOLD.Max) {
|
|
162
|
+
item.value = '';
|
|
163
|
+
}
|
|
164
|
+
} else {
|
|
165
|
+
item.value = val.replace(/[\u4E00-\u9FA5]/g, '');
|
|
166
|
+
}
|
|
167
|
+
value = api.getValue();
|
|
168
|
+
emit('update:modelValue', value, index);
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
export var change = function change(_ref11) {
|
|
172
|
+
var api = _ref11.api,
|
|
173
|
+
emit = _ref11.emit;
|
|
174
|
+
return function () {
|
|
175
|
+
var value = api.getValue();
|
|
176
|
+
emit('change', value);
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
export var blur = function blur(_ref12) {
|
|
180
|
+
var api = _ref12.api,
|
|
181
|
+
componentName = _ref12.componentName,
|
|
182
|
+
emit = _ref12.emit,
|
|
183
|
+
eventName = _ref12.eventName,
|
|
184
|
+
props = _ref12.props,
|
|
185
|
+
state = _ref12.state;
|
|
186
|
+
return function (_ref13) {
|
|
187
|
+
var item = _ref13.item,
|
|
188
|
+
index = _ref13.index;
|
|
189
|
+
state.active = false;
|
|
190
|
+
state.isDel = false;
|
|
191
|
+
if (api.isIP4(props.type)) {
|
|
192
|
+
item.value = item.value.replace(/\D/g, '');
|
|
193
|
+
}
|
|
194
|
+
emit('blur', item.value, index);
|
|
195
|
+
api.dispatch(componentName, eventName);
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
export var keyup = function keyup(_ref14) {
|
|
199
|
+
var api = _ref14.api,
|
|
200
|
+
props = _ref14.props;
|
|
201
|
+
return function (_ref15) {
|
|
202
|
+
var item = _ref15.item,
|
|
203
|
+
index = _ref15.index,
|
|
204
|
+
event = _ref15.event;
|
|
205
|
+
var keyCode = event.keyCode;
|
|
206
|
+
var value = item.value.trim();
|
|
207
|
+
var nextIndex = index + 1;
|
|
208
|
+
if (api.isIP4(props.type)) {
|
|
209
|
+
if (isNaN(item.value)) {
|
|
210
|
+
item.value = item.value.replace(/\D/g, '');
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
if ([KEY_CODE.Tab, KEY_CODE.Space, KEY_CODE.NumpadDecimal, KEY_CODE.NumpadComma].indexOf(keyCode) > -1 && value) {
|
|
214
|
+
api.select({
|
|
215
|
+
index: nextIndex
|
|
216
|
+
});
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
if ((value === '0' || value > IPTHRESHOLD.NonNumeric || value.length === 3) && !isNaN(event.key)) {
|
|
220
|
+
api.focus({
|
|
221
|
+
index: nextIndex
|
|
222
|
+
});
|
|
223
|
+
api.select({
|
|
224
|
+
index: nextIndex
|
|
225
|
+
});
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
var checkError1 = function checkError1(_ref16) {
|
|
232
|
+
var Tab = _ref16.Tab,
|
|
233
|
+
Space = _ref16.Space,
|
|
234
|
+
NumpadDecimal = _ref16.NumpadDecimal,
|
|
235
|
+
NumpadComma = _ref16.NumpadComma,
|
|
236
|
+
keyCode = _ref16.keyCode,
|
|
237
|
+
value = _ref16.value;
|
|
238
|
+
return [Tab, Space, NumpadDecimal, NumpadComma].indexOf(keyCode) > -1 && value;
|
|
239
|
+
};
|
|
240
|
+
var checkError2 = function checkError2(newValue) {
|
|
241
|
+
return newValue && (isNaN(newValue) || newValue > IPTHRESHOLD.Max);
|
|
242
|
+
};
|
|
243
|
+
var checkError3 = function checkError3(_ref17) {
|
|
244
|
+
var isfilterKeyCodes = _ref17.isfilterKeyCodes,
|
|
245
|
+
isSelected = _ref17.isSelected,
|
|
246
|
+
value = _ref17.value;
|
|
247
|
+
return !isfilterKeyCodes && !isSelected && value === '0';
|
|
248
|
+
};
|
|
249
|
+
var checkError4 = function checkError4(_ref18) {
|
|
250
|
+
var isfilterKeyCodes = _ref18.isfilterKeyCodes,
|
|
251
|
+
isSelected = _ref18.isSelected,
|
|
252
|
+
value = _ref18.value,
|
|
253
|
+
key = _ref18.key;
|
|
254
|
+
return !isfilterKeyCodes && !isSelected && value + key > IPTHRESHOLD.Max;
|
|
255
|
+
};
|
|
256
|
+
var checkError5 = function checkError5(_ref19) {
|
|
257
|
+
var key = _ref19.key,
|
|
258
|
+
isfilterKeyCodes = _ref19.isfilterKeyCodes,
|
|
259
|
+
value = _ref19.value,
|
|
260
|
+
ctrlKey = _ref19.ctrlKey,
|
|
261
|
+
keyCode = _ref19.keyCode,
|
|
262
|
+
KeyV = _ref19.KeyV;
|
|
263
|
+
return isNaN(key) && !isfilterKeyCodes && !(!value && ctrlKey && keyCode === KeyV);
|
|
264
|
+
};
|
|
265
|
+
var isError = function isError(_ref20) {
|
|
266
|
+
var key = _ref20.key,
|
|
267
|
+
value = _ref20.value,
|
|
268
|
+
isSelected = _ref20.isSelected,
|
|
269
|
+
isfilterKeyCodes = _ref20.isfilterKeyCodes,
|
|
270
|
+
ctrlKey = _ref20.ctrlKey,
|
|
271
|
+
keyCode = _ref20.keyCode,
|
|
272
|
+
newValue = _ref20.newValue;
|
|
273
|
+
var Tab = KEY_CODE.Tab,
|
|
274
|
+
Space = KEY_CODE.Space,
|
|
275
|
+
NumpadDecimal = KEY_CODE.NumpadDecimal,
|
|
276
|
+
NumpadComma = KEY_CODE.NumpadComma,
|
|
277
|
+
KeyV = KEY_CODE.KeyV;
|
|
278
|
+
return checkError1({
|
|
279
|
+
Tab: Tab,
|
|
280
|
+
Space: Space,
|
|
281
|
+
NumpadDecimal: NumpadDecimal,
|
|
282
|
+
NumpadComma: NumpadComma,
|
|
283
|
+
keyCode: keyCode,
|
|
284
|
+
value: value
|
|
285
|
+
}) || checkError2(newValue) || checkError3({
|
|
286
|
+
isfilterKeyCodes: isfilterKeyCodes,
|
|
287
|
+
isSelected: isSelected,
|
|
288
|
+
value: value
|
|
289
|
+
}) || checkError4({
|
|
290
|
+
isfilterKeyCodes: isfilterKeyCodes,
|
|
291
|
+
isSelected: isSelected,
|
|
292
|
+
value: value,
|
|
293
|
+
key: key
|
|
294
|
+
}) || checkError5({
|
|
295
|
+
key: key,
|
|
296
|
+
isfilterKeyCodes: isfilterKeyCodes,
|
|
297
|
+
value: value,
|
|
298
|
+
ctrlKey: ctrlKey,
|
|
299
|
+
keyCode: keyCode,
|
|
300
|
+
KeyV: KeyV
|
|
301
|
+
});
|
|
302
|
+
};
|
|
303
|
+
export var keydown = function keydown(_ref21) {
|
|
304
|
+
var api = _ref21.api,
|
|
305
|
+
props = _ref21.props,
|
|
306
|
+
state = _ref21.state;
|
|
307
|
+
return function (_ref22) {
|
|
308
|
+
var item = _ref22.item,
|
|
309
|
+
index = _ref22.index,
|
|
310
|
+
event = _ref22.event;
|
|
311
|
+
var target = event.target,
|
|
312
|
+
key = event.key,
|
|
313
|
+
keyCode = event.keyCode,
|
|
314
|
+
ctrlKey = event.ctrlKey;
|
|
315
|
+
var value = item.value;
|
|
316
|
+
var selectionStart = target.selectionStart;
|
|
317
|
+
var selectionEnd = target.selectionEnd;
|
|
318
|
+
var isSelected = selectionStart !== selectionEnd;
|
|
319
|
+
var cursorPosition = api.getCursorPosition(target);
|
|
320
|
+
var isfilterKeyCodes = state.filterKeyCodes.indexOf(keyCode) !== -1;
|
|
321
|
+
var nextIndex = index + 1;
|
|
322
|
+
var lastIndex = index - 1;
|
|
323
|
+
var newValue = isSelected && !isfilterKeyCodes && value.substr(0, selectionStart) + key + value.substr(selectionEnd);
|
|
324
|
+
if (api.isIP4(props.type)) {
|
|
325
|
+
state.isDel = keyCode === KEY_CODE.Backspace || keyCode === KEY_CODE.Delete;
|
|
326
|
+
if (keyCode === KEY_CODE.Backspace && cursorPosition === 0 && !selectionEnd) {
|
|
327
|
+
api.focus({
|
|
328
|
+
index: lastIndex
|
|
329
|
+
});
|
|
330
|
+
return false;
|
|
331
|
+
}
|
|
332
|
+
if (keyCode === KEY_CODE.ArrowLeft && cursorPosition === 0) {
|
|
333
|
+
api.focus({
|
|
334
|
+
index: lastIndex
|
|
335
|
+
});
|
|
336
|
+
event.preventDefault();
|
|
337
|
+
return false;
|
|
338
|
+
}
|
|
339
|
+
if (keyCode === KEY_CODE.ArrowRight && cursorPosition === value.length) {
|
|
340
|
+
api.focus({
|
|
341
|
+
index: nextIndex
|
|
342
|
+
});
|
|
343
|
+
event.preventDefault();
|
|
344
|
+
return false;
|
|
345
|
+
}
|
|
346
|
+
if (isError({
|
|
347
|
+
key: key,
|
|
348
|
+
value: value,
|
|
349
|
+
isSelected: isSelected,
|
|
350
|
+
isfilterKeyCodes: isfilterKeyCodes,
|
|
351
|
+
ctrlKey: ctrlKey,
|
|
352
|
+
keyCode: keyCode,
|
|
353
|
+
newValue: newValue
|
|
354
|
+
})) {
|
|
355
|
+
event.preventDefault();
|
|
356
|
+
return false;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
};
|
|
361
|
+
export var getHeightOfSize = function getHeightOfSize(size) {
|
|
362
|
+
var isLineHeight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'height';
|
|
363
|
+
var sizeMap = {
|
|
364
|
+
medium: '42px',
|
|
365
|
+
small: '36px',
|
|
366
|
+
mini: '24px'
|
|
367
|
+
};
|
|
368
|
+
var sizePX = sizeMap[size];
|
|
369
|
+
return sizePX ? isLineHeight + ':' + sizePX + ';' : '';
|
|
370
|
+
};
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
import { isIP6, isIP4, ipValidator, getCursorPosition, getValue, setValue, focus, select, inputEvent, change, blur, keyup, keydown, getHeightOfSize } from './index';
|
|
5
|
+
import { KEY_CODE } from '@opentiny/vue-renderless/common';
|
|
6
|
+
export var api = ['state', 'focus', 'inputEvent', 'blur', 'keyup', 'keydown', 'change', 'select'];
|
|
7
|
+
var initState = function initState(_ref) {
|
|
8
|
+
var reactive = _ref.reactive,
|
|
9
|
+
computed = _ref.computed,
|
|
10
|
+
handleValue = _ref.handleValue,
|
|
11
|
+
parent = _ref.parent,
|
|
12
|
+
props = _ref.props;
|
|
13
|
+
var state = reactive(_objectSpread(_objectSpread({}, handleValue.state), {}, {
|
|
14
|
+
active: false,
|
|
15
|
+
isSelected: false,
|
|
16
|
+
filterKeyCodes: [KEY_CODE.AtMark, KEY_CODE.Backspace, KEY_CODE.ArrowLeft, KEY_CODE.ArrowRight, KEY_CODE.Tab, KEY_CODE.Delete],
|
|
17
|
+
formDisabled: computed(function () {
|
|
18
|
+
return (parent.tinyForm || {}).disabled;
|
|
19
|
+
}),
|
|
20
|
+
disabled: computed(function () {
|
|
21
|
+
return props.disabled || state.formDisabled;
|
|
22
|
+
}),
|
|
23
|
+
heightStyle: computed(function () {
|
|
24
|
+
return getHeightOfSize(props.size);
|
|
25
|
+
}),
|
|
26
|
+
lineHeightStyle: computed(function () {
|
|
27
|
+
return getHeightOfSize(props.size, 'line-height');
|
|
28
|
+
}),
|
|
29
|
+
allHeightStyle: computed(function () {
|
|
30
|
+
return "".concat(state.heightStyle).concat(state.lineHeightStyle);
|
|
31
|
+
})
|
|
32
|
+
}));
|
|
33
|
+
return state;
|
|
34
|
+
};
|
|
35
|
+
var initApi = function initApi(_ref2) {
|
|
36
|
+
var state = _ref2.state,
|
|
37
|
+
api = _ref2.api,
|
|
38
|
+
dispatch = _ref2.dispatch,
|
|
39
|
+
handleValue = _ref2.handleValue,
|
|
40
|
+
emit = _ref2.emit,
|
|
41
|
+
broadcast = _ref2.broadcast,
|
|
42
|
+
parent = _ref2.parent,
|
|
43
|
+
componentName = _ref2.componentName,
|
|
44
|
+
props = _ref2.props,
|
|
45
|
+
eventName = _ref2.eventName;
|
|
46
|
+
Object.assign(api, _objectSpread(_objectSpread({}, handleValue.api), {}, {
|
|
47
|
+
state: state,
|
|
48
|
+
dispatch: dispatch,
|
|
49
|
+
broadcast: broadcast,
|
|
50
|
+
getCursorPosition: getCursorPosition,
|
|
51
|
+
focus: focus({
|
|
52
|
+
emit: emit,
|
|
53
|
+
props: props,
|
|
54
|
+
parent: parent,
|
|
55
|
+
state: state
|
|
56
|
+
}),
|
|
57
|
+
select: select({
|
|
58
|
+
emit: emit,
|
|
59
|
+
props: props,
|
|
60
|
+
parent: parent,
|
|
61
|
+
state: state
|
|
62
|
+
}),
|
|
63
|
+
blur: blur({
|
|
64
|
+
api: api,
|
|
65
|
+
componentName: componentName,
|
|
66
|
+
emit: emit,
|
|
67
|
+
eventName: eventName.blur,
|
|
68
|
+
props: props,
|
|
69
|
+
state: state
|
|
70
|
+
}),
|
|
71
|
+
keyup: keyup({
|
|
72
|
+
api: api,
|
|
73
|
+
props: props,
|
|
74
|
+
parent: parent
|
|
75
|
+
}),
|
|
76
|
+
change: change({
|
|
77
|
+
api: api,
|
|
78
|
+
emit: emit,
|
|
79
|
+
props: props
|
|
80
|
+
}),
|
|
81
|
+
keydown: keydown({
|
|
82
|
+
api: api,
|
|
83
|
+
props: props,
|
|
84
|
+
state: state
|
|
85
|
+
}),
|
|
86
|
+
inputEvent: inputEvent({
|
|
87
|
+
api: api,
|
|
88
|
+
emit: emit,
|
|
89
|
+
props: props
|
|
90
|
+
})
|
|
91
|
+
}));
|
|
92
|
+
};
|
|
93
|
+
export var useHandleValue = function useHandleValue(_ref3) {
|
|
94
|
+
var componentName = _ref3.componentName,
|
|
95
|
+
dispatch = _ref3.dispatch,
|
|
96
|
+
eventName = _ref3.eventName,
|
|
97
|
+
props = _ref3.props,
|
|
98
|
+
reactive = _ref3.reactive,
|
|
99
|
+
toRefs = _ref3.toRefs,
|
|
100
|
+
watch = _ref3.watch;
|
|
101
|
+
var state = reactive({
|
|
102
|
+
address: [],
|
|
103
|
+
isDel: false
|
|
104
|
+
});
|
|
105
|
+
var api = {
|
|
106
|
+
isIP6: isIP6,
|
|
107
|
+
isIP4: isIP4
|
|
108
|
+
};
|
|
109
|
+
api.getValue = getValue({
|
|
110
|
+
api: api,
|
|
111
|
+
props: props,
|
|
112
|
+
state: state
|
|
113
|
+
});
|
|
114
|
+
api.setValue = setValue({
|
|
115
|
+
api: api,
|
|
116
|
+
props: props,
|
|
117
|
+
state: state
|
|
118
|
+
});
|
|
119
|
+
api.ipValidator = ipValidator({
|
|
120
|
+
api: api,
|
|
121
|
+
props: props
|
|
122
|
+
});
|
|
123
|
+
watch(function () {
|
|
124
|
+
return props.modelValue;
|
|
125
|
+
}, function (value) {
|
|
126
|
+
if (!state.isDel) {
|
|
127
|
+
api.setValue(value);
|
|
128
|
+
dispatch(componentName, eventName, [value]);
|
|
129
|
+
}
|
|
130
|
+
}, {
|
|
131
|
+
immediate: true
|
|
132
|
+
});
|
|
133
|
+
return {
|
|
134
|
+
state: toRefs(state),
|
|
135
|
+
api: api
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
export var renderless = function renderless(props, _ref4, _ref5) {
|
|
139
|
+
var reactive = _ref4.reactive,
|
|
140
|
+
toRefs = _ref4.toRefs,
|
|
141
|
+
watch = _ref4.watch,
|
|
142
|
+
inject = _ref4.inject,
|
|
143
|
+
computed = _ref4.computed;
|
|
144
|
+
var $prefix = _ref5.$prefix,
|
|
145
|
+
emit = _ref5.emit,
|
|
146
|
+
parent = _ref5.parent,
|
|
147
|
+
broadcast = _ref5.broadcast,
|
|
148
|
+
dispatch = _ref5.dispatch;
|
|
149
|
+
var api = {};
|
|
150
|
+
var componentName = "".concat($prefix, "FormItem");
|
|
151
|
+
var eventName = {
|
|
152
|
+
change: "".concat($prefix, ".form.change"),
|
|
153
|
+
blur: "".concat($prefix, ".form.blur")
|
|
154
|
+
};
|
|
155
|
+
parent.tinyForm = parent.tinyForm || inject('form', null);
|
|
156
|
+
var handleValue = useHandleValue({
|
|
157
|
+
componentName: componentName,
|
|
158
|
+
dispatch: dispatch,
|
|
159
|
+
eventName: eventName.change,
|
|
160
|
+
props: props,
|
|
161
|
+
reactive: reactive,
|
|
162
|
+
toRefs: toRefs,
|
|
163
|
+
watch: watch
|
|
164
|
+
});
|
|
165
|
+
var state = initState({
|
|
166
|
+
reactive: reactive,
|
|
167
|
+
computed: computed,
|
|
168
|
+
handleValue: handleValue,
|
|
169
|
+
parent: parent,
|
|
170
|
+
props: props
|
|
171
|
+
});
|
|
172
|
+
initApi({
|
|
173
|
+
api: api,
|
|
174
|
+
state: state,
|
|
175
|
+
handleValue: handleValue,
|
|
176
|
+
dispatch: dispatch,
|
|
177
|
+
broadcast: broadcast,
|
|
178
|
+
emit: emit,
|
|
179
|
+
props: props,
|
|
180
|
+
parent: parent,
|
|
181
|
+
componentName: componentName,
|
|
182
|
+
eventName: eventName
|
|
183
|
+
});
|
|
184
|
+
return api;
|
|
185
|
+
};
|
package/layout/vue.js
ADDED
package/link/index.js
ADDED
package/link/vue.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { handleClick } from './index';
|
|
2
|
+
export var api = ['state', 'handleClick'];
|
|
3
|
+
export var renderless = function renderless(props, _ref, _ref2) {
|
|
4
|
+
var inject = _ref.inject,
|
|
5
|
+
reactive = _ref.reactive,
|
|
6
|
+
computed = _ref.computed;
|
|
7
|
+
var emit = _ref2.emit,
|
|
8
|
+
parent = _ref2.parent;
|
|
9
|
+
parent.tinyForm = parent.tinyForm || inject('form', null);
|
|
10
|
+
var state = reactive({
|
|
11
|
+
formDisabled: computed(function () {
|
|
12
|
+
return (parent.tinyForm || {}).disabled;
|
|
13
|
+
}),
|
|
14
|
+
disabled: computed(function () {
|
|
15
|
+
return props.disabled || state.formDisabled;
|
|
16
|
+
})
|
|
17
|
+
});
|
|
18
|
+
return {
|
|
19
|
+
state: state,
|
|
20
|
+
handleClick: handleClick({
|
|
21
|
+
emit: emit,
|
|
22
|
+
props: props,
|
|
23
|
+
state: state
|
|
24
|
+
})
|
|
25
|
+
};
|
|
26
|
+
};
|