@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,75 @@
|
|
|
1
|
+
export var computedWidth = function computedWidth(_ref) {
|
|
2
|
+
var props = _ref.props;
|
|
3
|
+
return function () {
|
|
4
|
+
if (typeof props.width === 'number' || !Number.isNaN(+props.width)) {
|
|
5
|
+
return props.width + 'px';
|
|
6
|
+
}
|
|
7
|
+
return props.width;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export var watchValue = function watchValue(_ref2) {
|
|
11
|
+
var api = _ref2.api,
|
|
12
|
+
props = _ref2.props,
|
|
13
|
+
state = _ref2.state;
|
|
14
|
+
return function (newValue) {
|
|
15
|
+
newValue = newValue.toString();
|
|
16
|
+
if (state.type === 'textarea') {
|
|
17
|
+
state.textAreaValue = api.jointText(newValue, props.separtor);
|
|
18
|
+
} else {
|
|
19
|
+
state.text && (state.text.value = newValue);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export var mounted = function mounted(_ref3) {
|
|
24
|
+
var props = _ref3.props,
|
|
25
|
+
refs = _ref3.refs,
|
|
26
|
+
state = _ref3.state;
|
|
27
|
+
return function () {
|
|
28
|
+
state.text = refs['text'];
|
|
29
|
+
state.popup = refs['popup'];
|
|
30
|
+
state.text.value = props.modelValue.toString();
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export var onFocus = function onFocus(_ref4) {
|
|
34
|
+
var api = _ref4.api,
|
|
35
|
+
emit = _ref4.emit,
|
|
36
|
+
props = _ref4.props,
|
|
37
|
+
nextTick = _ref4.nextTick,
|
|
38
|
+
state = _ref4.state;
|
|
39
|
+
return function () {
|
|
40
|
+
state.type = 'textarea';
|
|
41
|
+
nextTick(function () {
|
|
42
|
+
state.popup.focus();
|
|
43
|
+
state.text.placeholder && (state.popup.placeholder = state.text.placeholder);
|
|
44
|
+
state.textAreaValue = api.jointText(state.text.value, props.separtor);
|
|
45
|
+
emit('popup', true);
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export var onBlur = function onBlur(_ref5) {
|
|
50
|
+
var api = _ref5.api,
|
|
51
|
+
emit = _ref5.emit,
|
|
52
|
+
props = _ref5.props,
|
|
53
|
+
state = _ref5.state;
|
|
54
|
+
return function () {
|
|
55
|
+
state.type = 'input';
|
|
56
|
+
state.text.value = api.separteText(state.textAreaValue, props.separtor);
|
|
57
|
+
emit('popup', false);
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
export var onInput = function onInput(_ref6) {
|
|
61
|
+
var api = _ref6.api,
|
|
62
|
+
emit = _ref6.emit,
|
|
63
|
+
props = _ref6.props;
|
|
64
|
+
return function (event) {
|
|
65
|
+
var value = api.separteText(event.target.value, props.separtor);
|
|
66
|
+
emit('update:modelValue', value);
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
export var separteText = function separteText(str, separtor) {
|
|
70
|
+
return str.replace(/\n/g, separtor);
|
|
71
|
+
};
|
|
72
|
+
export var jointText = function jointText(str, separtor) {
|
|
73
|
+
if (separtor === ']') separtor = '\\' + separtor;
|
|
74
|
+
return str.replace(new RegExp("[".concat(separtor, "]"), 'g'), '\n');
|
|
75
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { computedWidth, watchValue, mounted, onFocus, onBlur, onInput, separteText, jointText } from './index';
|
|
2
|
+
export var api = ['state', 'onFocus', 'onBlur', 'onInput'];
|
|
3
|
+
export var renderless = function renderless(props, _ref, _ref2) {
|
|
4
|
+
var computed = _ref.computed,
|
|
5
|
+
onMounted = _ref.onMounted,
|
|
6
|
+
reactive = _ref.reactive,
|
|
7
|
+
watch = _ref.watch;
|
|
8
|
+
var emit = _ref2.emit,
|
|
9
|
+
nextTick = _ref2.nextTick,
|
|
10
|
+
refs = _ref2.refs;
|
|
11
|
+
var api = {};
|
|
12
|
+
var state = reactive({
|
|
13
|
+
type: 'input',
|
|
14
|
+
textAreaValue: '',
|
|
15
|
+
text: null,
|
|
16
|
+
popup: null,
|
|
17
|
+
width: computed(function () {
|
|
18
|
+
return api.computedWidth();
|
|
19
|
+
})
|
|
20
|
+
});
|
|
21
|
+
Object.assign(api, {
|
|
22
|
+
state: state,
|
|
23
|
+
jointText: jointText,
|
|
24
|
+
separteText: separteText,
|
|
25
|
+
computedWidth: computedWidth({
|
|
26
|
+
props: props
|
|
27
|
+
}),
|
|
28
|
+
mounted: mounted({
|
|
29
|
+
props: props,
|
|
30
|
+
refs: refs,
|
|
31
|
+
state: state
|
|
32
|
+
}),
|
|
33
|
+
onInput: onInput({
|
|
34
|
+
api: api,
|
|
35
|
+
emit: emit,
|
|
36
|
+
props: props
|
|
37
|
+
}),
|
|
38
|
+
watchValue: watchValue({
|
|
39
|
+
api: api,
|
|
40
|
+
props: props,
|
|
41
|
+
state: state
|
|
42
|
+
}),
|
|
43
|
+
onBlur: onBlur({
|
|
44
|
+
api: api,
|
|
45
|
+
emit: emit,
|
|
46
|
+
props: props,
|
|
47
|
+
state: state
|
|
48
|
+
}),
|
|
49
|
+
onFocus: onFocus({
|
|
50
|
+
api: api,
|
|
51
|
+
emit: emit,
|
|
52
|
+
props: props,
|
|
53
|
+
nextTick: nextTick,
|
|
54
|
+
state: state
|
|
55
|
+
})
|
|
56
|
+
});
|
|
57
|
+
watch(function () {
|
|
58
|
+
return props.modelValue;
|
|
59
|
+
}, api.watchValue, {
|
|
60
|
+
immediate: true
|
|
61
|
+
});
|
|
62
|
+
onMounted(api.mounted);
|
|
63
|
+
return api;
|
|
64
|
+
};
|
package/time/index.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { limitTimeRange, clearMilliseconds, timeWithinRange } from '@opentiny/vue-renderless/common/deps/date-util';
|
|
2
|
+
export var watchValue = function watchValue(_ref) {
|
|
3
|
+
var api = _ref.api,
|
|
4
|
+
nextTick = _ref.nextTick,
|
|
5
|
+
state = _ref.state;
|
|
6
|
+
return function (value) {
|
|
7
|
+
var date;
|
|
8
|
+
if (value instanceof Date) {
|
|
9
|
+
date = limitTimeRange(value, state.selectableRange, state.format);
|
|
10
|
+
} else if (!value) {
|
|
11
|
+
date = state.defaultValue ? new Date(state.defaultValue) : new Date();
|
|
12
|
+
}
|
|
13
|
+
state.date = date;
|
|
14
|
+
if (state.visible && state.needInitAdjust) {
|
|
15
|
+
nextTick(function () {
|
|
16
|
+
return api.adjustSpinners();
|
|
17
|
+
});
|
|
18
|
+
state.needInitAdjust = false;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export var watchVisible = function watchVisible(_ref2) {
|
|
23
|
+
var nextTick = _ref2.nextTick,
|
|
24
|
+
refs = _ref2.refs,
|
|
25
|
+
state = _ref2.state;
|
|
26
|
+
return function (value) {
|
|
27
|
+
if (value) {
|
|
28
|
+
state.oldValue = state.value;
|
|
29
|
+
nextTick(function () {
|
|
30
|
+
return refs.spinner.emitSelectRange('hours');
|
|
31
|
+
});
|
|
32
|
+
} else {
|
|
33
|
+
state.needInitAdjust = true;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export var handleCancel = function handleCancel(_ref3) {
|
|
38
|
+
var state = _ref3.state,
|
|
39
|
+
emit = _ref3.emit;
|
|
40
|
+
return function () {
|
|
41
|
+
emit('pick', state.oldValue, false);
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export var handleChange = function handleChange(_ref4) {
|
|
45
|
+
var api = _ref4.api,
|
|
46
|
+
state = _ref4.state,
|
|
47
|
+
emit = _ref4.emit;
|
|
48
|
+
return function (date) {
|
|
49
|
+
if (state.visible) {
|
|
50
|
+
state.date = clearMilliseconds(date);
|
|
51
|
+
if (api.isValidValue(state.date)) {
|
|
52
|
+
emit('pick', state.date, true);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
export var setSelectionRange = function setSelectionRange(_ref5) {
|
|
58
|
+
var state = _ref5.state,
|
|
59
|
+
emit = _ref5.emit;
|
|
60
|
+
return function (start, end) {
|
|
61
|
+
emit('select-range', start, end);
|
|
62
|
+
state.selectionRange = [start, end];
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
export var handleConfirm = function handleConfirm(_ref6) {
|
|
66
|
+
var state = _ref6.state,
|
|
67
|
+
emit = _ref6.emit;
|
|
68
|
+
return function () {
|
|
69
|
+
var visible = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
70
|
+
var first = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
71
|
+
if (first) return;
|
|
72
|
+
var date = clearMilliseconds(limitTimeRange(state.date, state.selectableRange, state.format));
|
|
73
|
+
emit('pick', date, visible, first);
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
export var handleKeydown = function handleKeydown(_ref7) {
|
|
77
|
+
var api = _ref7.api,
|
|
78
|
+
refs = _ref7.refs;
|
|
79
|
+
return function (event) {
|
|
80
|
+
var mapping = {
|
|
81
|
+
38: -1,
|
|
82
|
+
40: 1,
|
|
83
|
+
37: -1,
|
|
84
|
+
39: 1
|
|
85
|
+
};
|
|
86
|
+
var keyCode = event.keyCode;
|
|
87
|
+
if (keyCode === 37 || keyCode === 39) {
|
|
88
|
+
var key = mapping[keyCode];
|
|
89
|
+
api.changeSelectionRange(key);
|
|
90
|
+
event.preventDefault();
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (keyCode === 38 || keyCode === 40) {
|
|
94
|
+
var _key = mapping[keyCode];
|
|
95
|
+
refs.spinner.scrollDown(_key);
|
|
96
|
+
event.preventDefault();
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
export var isValidValue = function isValidValue(_ref8) {
|
|
101
|
+
var state = _ref8.state;
|
|
102
|
+
return function (date) {
|
|
103
|
+
return timeWithinRange(date, state.selectableRange, state.format);
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
export var adjustSpinners = function adjustSpinners(refs) {
|
|
107
|
+
return function () {
|
|
108
|
+
return refs.spinner.adjustSpinners();
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
export var changeSelectionRange = function changeSelectionRange(_ref9) {
|
|
112
|
+
var refs = _ref9.refs,
|
|
113
|
+
state = _ref9.state;
|
|
114
|
+
return function (step) {
|
|
115
|
+
var list = [0, 3].concat(state.showSeconds ? [6] : []);
|
|
116
|
+
var mapping = ['hours', 'minutes'].concat(state.showSeconds ? ['seconds'] : []);
|
|
117
|
+
var index = list.indexOf(state.selectionRange[0]);
|
|
118
|
+
var next = (index + step + list.length) % list.length;
|
|
119
|
+
refs.spinner.emitSelectRange(mapping[next]);
|
|
120
|
+
};
|
|
121
|
+
};
|
package/time/vue.js
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { changeSelectionRange, adjustSpinners, isValidValue, handleKeydown, watchValue, watchVisible, handleCancel, handleChange, setSelectionRange, handleConfirm } from './index';
|
|
2
|
+
import { compuAmPmMode } from '@opentiny/vue-renderless/time-range';
|
|
3
|
+
import { isDate } from '@opentiny/vue-renderless/common/deps/date-util';
|
|
4
|
+
export var api = ['state', 'handleChange', 'setSelectionRange', 'handleCancel', 'handleConfirm', 'adjustSpinners'];
|
|
5
|
+
var initState = function initState(_ref) {
|
|
6
|
+
var reactive = _ref.reactive,
|
|
7
|
+
props = _ref.props,
|
|
8
|
+
computed = _ref.computed,
|
|
9
|
+
api = _ref.api;
|
|
10
|
+
var state = reactive({
|
|
11
|
+
popperClass: '',
|
|
12
|
+
format: 'HH:mm:ss',
|
|
13
|
+
value: '',
|
|
14
|
+
defaultValue: null,
|
|
15
|
+
date: props.value || new Date(),
|
|
16
|
+
oldValue: new Date(),
|
|
17
|
+
selectableRange: [],
|
|
18
|
+
selectionRange: [0, 2],
|
|
19
|
+
disabled: false,
|
|
20
|
+
arrowControl: false,
|
|
21
|
+
visible: false,
|
|
22
|
+
needInitAdjust: true,
|
|
23
|
+
showSeconds: computed(function () {
|
|
24
|
+
return (state.format || '').indexOf('ss') !== -1;
|
|
25
|
+
}),
|
|
26
|
+
useArrow: computed(function () {
|
|
27
|
+
return state.arrowControl || props.timeArrowControl || false;
|
|
28
|
+
}),
|
|
29
|
+
amPmMode: computed(function () {
|
|
30
|
+
return api.compuAmPmMode();
|
|
31
|
+
})
|
|
32
|
+
});
|
|
33
|
+
return state;
|
|
34
|
+
};
|
|
35
|
+
export var renderless = function renderless(props, _ref2, _ref3) {
|
|
36
|
+
var computed = _ref2.computed,
|
|
37
|
+
onMounted = _ref2.onMounted,
|
|
38
|
+
reactive = _ref2.reactive,
|
|
39
|
+
watch = _ref2.watch,
|
|
40
|
+
nextTick = _ref2.nextTick;
|
|
41
|
+
var t = _ref3.t,
|
|
42
|
+
$emit = _ref3.emit,
|
|
43
|
+
refs = _ref3.refs;
|
|
44
|
+
var api = {};
|
|
45
|
+
var emit = props.emitter ? props.emitter.emit : $emit;
|
|
46
|
+
var state = initState({
|
|
47
|
+
reactive: reactive,
|
|
48
|
+
props: props,
|
|
49
|
+
computed: computed,
|
|
50
|
+
api: api
|
|
51
|
+
});
|
|
52
|
+
Object.assign(api, {
|
|
53
|
+
t: t,
|
|
54
|
+
state: state,
|
|
55
|
+
compuAmPmMode: compuAmPmMode(state),
|
|
56
|
+
adjustSpinners: adjustSpinners(refs),
|
|
57
|
+
handleCancel: handleCancel({
|
|
58
|
+
state: state,
|
|
59
|
+
emit: emit
|
|
60
|
+
}),
|
|
61
|
+
setSelectionRange: setSelectionRange({
|
|
62
|
+
state: state,
|
|
63
|
+
emit: emit
|
|
64
|
+
}),
|
|
65
|
+
watchVisible: watchVisible({
|
|
66
|
+
nextTick: nextTick,
|
|
67
|
+
refs: refs,
|
|
68
|
+
state: state
|
|
69
|
+
}),
|
|
70
|
+
isValidValue: isValidValue({
|
|
71
|
+
state: state
|
|
72
|
+
}),
|
|
73
|
+
changeSelectionRange: changeSelectionRange({
|
|
74
|
+
refs: refs,
|
|
75
|
+
state: state
|
|
76
|
+
}),
|
|
77
|
+
handleConfirm: handleConfirm({
|
|
78
|
+
state: state,
|
|
79
|
+
emit: emit
|
|
80
|
+
}),
|
|
81
|
+
handleKeydown: handleKeydown({
|
|
82
|
+
api: api,
|
|
83
|
+
refs: refs
|
|
84
|
+
}),
|
|
85
|
+
handleChange: handleChange({
|
|
86
|
+
api: api,
|
|
87
|
+
emit: emit,
|
|
88
|
+
state: state
|
|
89
|
+
}),
|
|
90
|
+
watchValue: watchValue({
|
|
91
|
+
api: api,
|
|
92
|
+
emit: emit,
|
|
93
|
+
nextTick: nextTick,
|
|
94
|
+
state: state
|
|
95
|
+
})
|
|
96
|
+
});
|
|
97
|
+
watch(function () {
|
|
98
|
+
return state.value;
|
|
99
|
+
}, api.watchValue);
|
|
100
|
+
watch(function () {
|
|
101
|
+
return props.show;
|
|
102
|
+
}, function (value) {
|
|
103
|
+
state.visible = value;
|
|
104
|
+
}, {
|
|
105
|
+
immediate: true
|
|
106
|
+
});
|
|
107
|
+
watch(function () {
|
|
108
|
+
return state.selectableRange;
|
|
109
|
+
}, function (value) {
|
|
110
|
+
return refs.spinner.state.selectableRange = value;
|
|
111
|
+
});
|
|
112
|
+
watch(function () {
|
|
113
|
+
return state.defaultValue;
|
|
114
|
+
}, function (value) {
|
|
115
|
+
return !isDate(state.value) && (state.date = value ? new Date(value) : new Date());
|
|
116
|
+
});
|
|
117
|
+
onMounted(function () {
|
|
118
|
+
api.handleConfirm(true, true);
|
|
119
|
+
});
|
|
120
|
+
watch(function () {
|
|
121
|
+
return state.visible;
|
|
122
|
+
}, api.watchVisible);
|
|
123
|
+
return api;
|
|
124
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { format } from '@opentiny/vue-renderless/common/date';
|
|
2
|
+
export var getDate = function getDate(dateTime) {
|
|
3
|
+
return {
|
|
4
|
+
date: format(dateTime, 'yyyy-MM-dd'),
|
|
5
|
+
time: format(dateTime, 'hh:mm')
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export var getStatus = function getStatus(_ref) {
|
|
9
|
+
var state = _ref.state,
|
|
10
|
+
t = _ref.t;
|
|
11
|
+
return function (value) {
|
|
12
|
+
var status = state.current - value;
|
|
13
|
+
return status > 0 ? t('ui.steps.done') : status === 0 ? t('ui.steps.doing') : t('ui.steps.wait');
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export var handleClick = function handleClick(_ref2) {
|
|
17
|
+
var emit = _ref2.emit,
|
|
18
|
+
state = _ref2.state;
|
|
19
|
+
return function (_ref3) {
|
|
20
|
+
var index = _ref3.index,
|
|
21
|
+
node = _ref3.node;
|
|
22
|
+
emit('click', state.isReverse ? state.nodes.length - index - 1 : index, node);
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export var getStatusCls = function getStatusCls(_ref4) {
|
|
26
|
+
var constants = _ref4.constants,
|
|
27
|
+
state = _ref4.state;
|
|
28
|
+
return function (index) {
|
|
29
|
+
var PROCESS_DONE_CLS = constants.PROCESS_DONE_CLS,
|
|
30
|
+
PROCESS_CUR_CLS = constants.PROCESS_CUR_CLS,
|
|
31
|
+
PROCESS_WAIT_CLS = constants.PROCESS_WAIT_CLS;
|
|
32
|
+
var cls = {};
|
|
33
|
+
var reverse = state.isReverse;
|
|
34
|
+
cls[PROCESS_DONE_CLS] = reverse ? index > state.current : index < state.current;
|
|
35
|
+
cls[PROCESS_CUR_CLS] = index === state.current;
|
|
36
|
+
cls[PROCESS_WAIT_CLS] = reverse ? index < state.current : index > state.current;
|
|
37
|
+
return cls;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export var computedData = function computedData(_ref5) {
|
|
41
|
+
var props = _ref5.props,
|
|
42
|
+
state = _ref5.state;
|
|
43
|
+
return function () {
|
|
44
|
+
return state.isReverse ? props.data.map(function (item, i) {
|
|
45
|
+
return props.data[props.data.length - 1 - i];
|
|
46
|
+
}) : props.data;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export var computedCurrent = function computedCurrent(_ref6) {
|
|
50
|
+
var props = _ref6.props,
|
|
51
|
+
state = _ref6.state;
|
|
52
|
+
return function () {
|
|
53
|
+
return state.isReverse ? state.nodes.length - props.active - 1 : props.active;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
export var computedIsReverse = function computedIsReverse(props) {
|
|
57
|
+
return function () {
|
|
58
|
+
return props.reverse && props.vertical;
|
|
59
|
+
};
|
|
60
|
+
};
|
package/time-line/vue.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { handleClick, getStatusCls, getStatus, computedData, getDate, computedCurrent, computedIsReverse } from './index';
|
|
2
|
+
export var api = ['state', 'handleClick', 'getStatusCls', 'getStatus', 'getDate'];
|
|
3
|
+
export var renderless = function renderless(props, _ref, _ref2) {
|
|
4
|
+
var computed = _ref.computed,
|
|
5
|
+
reactive = _ref.reactive;
|
|
6
|
+
var t = _ref2.t,
|
|
7
|
+
emit = _ref2.emit,
|
|
8
|
+
constants = _ref2.constants;
|
|
9
|
+
var api = {};
|
|
10
|
+
var state = reactive({
|
|
11
|
+
nodes: computed(function () {
|
|
12
|
+
return api.computedData();
|
|
13
|
+
}),
|
|
14
|
+
current: computed(function () {
|
|
15
|
+
return api.computedCurrent();
|
|
16
|
+
}),
|
|
17
|
+
isReverse: computed(function () {
|
|
18
|
+
return api.computedIsReverse();
|
|
19
|
+
})
|
|
20
|
+
});
|
|
21
|
+
Object.assign(api, {
|
|
22
|
+
state: state,
|
|
23
|
+
getDate: getDate,
|
|
24
|
+
computedData: computedData({
|
|
25
|
+
props: props,
|
|
26
|
+
state: state
|
|
27
|
+
}),
|
|
28
|
+
computedCurrent: computedCurrent({
|
|
29
|
+
props: props,
|
|
30
|
+
state: state
|
|
31
|
+
}),
|
|
32
|
+
computedIsReverse: computedIsReverse(props),
|
|
33
|
+
getStatus: getStatus({
|
|
34
|
+
state: state,
|
|
35
|
+
t: t
|
|
36
|
+
}),
|
|
37
|
+
handleClick: handleClick({
|
|
38
|
+
emit: emit,
|
|
39
|
+
state: state,
|
|
40
|
+
api: api
|
|
41
|
+
}),
|
|
42
|
+
getStatusCls: getStatusCls({
|
|
43
|
+
constants: constants,
|
|
44
|
+
props: props,
|
|
45
|
+
state: state
|
|
46
|
+
})
|
|
47
|
+
});
|
|
48
|
+
return api;
|
|
49
|
+
};
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import scrollIntoView from '@opentiny/vue-renderless/common/deps/scroll-into-view';
|
|
2
|
+
import { DATEPICKER } from '@opentiny/vue-renderless/common';
|
|
3
|
+
export var parseTime = function parseTime() {
|
|
4
|
+
return function (time) {
|
|
5
|
+
var values = (time || '').split(':');
|
|
6
|
+
if (values.length >= 2) {
|
|
7
|
+
var hours = parseInt(values[0], 10);
|
|
8
|
+
var minutes = parseInt(values[1], 10);
|
|
9
|
+
return {
|
|
10
|
+
hours: hours,
|
|
11
|
+
minutes: minutes
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export var compareTime = function compareTime(api) {
|
|
18
|
+
return function (time1, time2) {
|
|
19
|
+
var value1 = api.parseTime(time1);
|
|
20
|
+
var value2 = api.parseTime(time2);
|
|
21
|
+
var minutes1 = value1.minutes + value1.hours * 60;
|
|
22
|
+
var minutes2 = value2.minutes + value2.hours * 60;
|
|
23
|
+
if (minutes1 === minutes2) {
|
|
24
|
+
return 0;
|
|
25
|
+
}
|
|
26
|
+
return minutes1 > minutes2 ? 1 : -1;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export var formatTime = function formatTime() {
|
|
30
|
+
return function (time) {
|
|
31
|
+
return (time.hours < 10 ? '0' + time.hours : time.hours) + ':' + (time.minutes < 10 ? '0' + time.minutes : time.minutes);
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export var nextTime = function nextTime(api) {
|
|
35
|
+
return function (time, step) {
|
|
36
|
+
var timeValue = api.parseTime(time);
|
|
37
|
+
var stepValue = api.parseTime(step);
|
|
38
|
+
var next = {
|
|
39
|
+
hours: timeValue.hours,
|
|
40
|
+
minutes: timeValue.minutes
|
|
41
|
+
};
|
|
42
|
+
next.minutes += stepValue.minutes;
|
|
43
|
+
next.hours += stepValue.hours;
|
|
44
|
+
next.hours += Math.floor(next.minutes / 60);
|
|
45
|
+
next.minutes = next.minutes % 60;
|
|
46
|
+
return api.formatTime(next);
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export var emitDestroy = function emitDestroy(emit) {
|
|
50
|
+
return function () {
|
|
51
|
+
return emit('dodestroy');
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
export var emitPick = function emitPick(_ref) {
|
|
55
|
+
var emit = _ref.emit,
|
|
56
|
+
state = _ref.state;
|
|
57
|
+
return function () {
|
|
58
|
+
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
59
|
+
_ref2$value = _ref2.value,
|
|
60
|
+
value = _ref2$value === void 0 ? null : _ref2$value,
|
|
61
|
+
_ref2$visible = _ref2.visible,
|
|
62
|
+
visible = _ref2$visible === void 0 ? false : _ref2$visible;
|
|
63
|
+
var lastEmitValue = JSON.stringify({
|
|
64
|
+
value: value,
|
|
65
|
+
visible: visible
|
|
66
|
+
});
|
|
67
|
+
if (!state.lastEmitValue || state.lastEmitValue !== lastEmitValue) {
|
|
68
|
+
state.lastEmitValue = lastEmitValue;
|
|
69
|
+
emit('pick', value, visible);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
export var watchValue = function watchValue(_ref3) {
|
|
74
|
+
var api = _ref3.api,
|
|
75
|
+
nextTick = _ref3.nextTick;
|
|
76
|
+
return function (value) {
|
|
77
|
+
if (!value) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
nextTick(function () {
|
|
81
|
+
return api.scrollToOption();
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
export var computItems = function computItems(_ref4) {
|
|
86
|
+
var api = _ref4.api,
|
|
87
|
+
state = _ref4.state;
|
|
88
|
+
return function () {
|
|
89
|
+
var start = state.start;
|
|
90
|
+
var end = state.end;
|
|
91
|
+
var step = state.step;
|
|
92
|
+
var result = [];
|
|
93
|
+
if (start && end && step) {
|
|
94
|
+
var current = start;
|
|
95
|
+
while (api.compareTime(current, end) <= 0) {
|
|
96
|
+
result.push({
|
|
97
|
+
value: current,
|
|
98
|
+
disabled: api.compareTime(current, state.minTime || DATEPICKER.CompareOne) <= 0 || api.compareTime(current, state.maxTime || DATEPICKER.CompareHundred) >= 0
|
|
99
|
+
});
|
|
100
|
+
current = api.nextTime(current, step);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return result;
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
export var handleClick = function handleClick(api) {
|
|
107
|
+
return function (item) {
|
|
108
|
+
return !item.disabled && api.emitPick({
|
|
109
|
+
value: item.value
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
export var handleClear = function handleClear(_ref5) {
|
|
114
|
+
var api = _ref5.api,
|
|
115
|
+
state = _ref5.state;
|
|
116
|
+
return function () {
|
|
117
|
+
state.defaultValue = '';
|
|
118
|
+
state.defaultTime = '';
|
|
119
|
+
api.emitPick();
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
export var scrollToOption = function scrollToOption(_ref6) {
|
|
123
|
+
var refs = _ref6.refs;
|
|
124
|
+
return function () {
|
|
125
|
+
var selector = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DATEPICKER.selClass;
|
|
126
|
+
var menu = refs.popper.querySelector(DATEPICKER.queryClass);
|
|
127
|
+
scrollIntoView(menu, menu.querySelector(selector));
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
export var handleMenuEnter = function handleMenuEnter(_ref7) {
|
|
131
|
+
var api = _ref7.api,
|
|
132
|
+
nextTick = _ref7.nextTick,
|
|
133
|
+
state = _ref7.state;
|
|
134
|
+
return function () {
|
|
135
|
+
var selected = state.items.map(function (item) {
|
|
136
|
+
return item.value;
|
|
137
|
+
}).indexOf(state.value) !== -1;
|
|
138
|
+
var hasDefault = state.items.map(function (item) {
|
|
139
|
+
return item.value;
|
|
140
|
+
}).indexOf(state["default"]) !== -1;
|
|
141
|
+
var option = selected && DATEPICKER.selClass || hasDefault && DATEPICKER.defaultClass || DATEPICKER.disableClass;
|
|
142
|
+
nextTick(function () {
|
|
143
|
+
return api.scrollToOption(option);
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
export var scrollDown = function scrollDown(_ref8) {
|
|
148
|
+
var api = _ref8.api,
|
|
149
|
+
state = _ref8.state;
|
|
150
|
+
return function (step) {
|
|
151
|
+
var items = state.items;
|
|
152
|
+
var length = items.length;
|
|
153
|
+
var total = items.length;
|
|
154
|
+
var index = items.map(function (item) {
|
|
155
|
+
return item.value;
|
|
156
|
+
}).indexOf(state.value);
|
|
157
|
+
while (total--) {
|
|
158
|
+
index = (index + step + length) % length;
|
|
159
|
+
if (!items[index].disabled) {
|
|
160
|
+
api.emitPick({
|
|
161
|
+
value: items[index].value,
|
|
162
|
+
visible: true
|
|
163
|
+
});
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
export var isValidValue = function isValidValue(state) {
|
|
170
|
+
return function (date) {
|
|
171
|
+
return state.items.filter(function (item) {
|
|
172
|
+
return !item.disabled;
|
|
173
|
+
}).map(function (item) {
|
|
174
|
+
return item.value;
|
|
175
|
+
}).indexOf(date) !== -1;
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
export var handleKeydown = function handleKeydown(_ref9) {
|
|
179
|
+
var api = _ref9.api;
|
|
180
|
+
return function (event) {
|
|
181
|
+
var keyCode = event.keyCode;
|
|
182
|
+
if (keyCode === 38 || keyCode === 40) {
|
|
183
|
+
var mapping = DATEPICKER.MappingKeyCode;
|
|
184
|
+
var offset = mapping[keyCode.toString()];
|
|
185
|
+
api.scrollDown(offset);
|
|
186
|
+
event.stopPropagation();
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export default (function (container, selected) {
|
|
2
|
+
if (!selected) {
|
|
3
|
+
container.scrollTop = 0;
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
var offsetParents = [];
|
|
7
|
+
var pointer = selected.offsetParent;
|
|
8
|
+
while (pointer && container !== pointer && container.contains(pointer)) {
|
|
9
|
+
offsetParents.push(pointer);
|
|
10
|
+
pointer = pointer.offsetParent;
|
|
11
|
+
}
|
|
12
|
+
var top = selected.offsetTop + offsetParents.reduce(function (prev, curr) {
|
|
13
|
+
return prev + curr.offsetTop;
|
|
14
|
+
}, 0);
|
|
15
|
+
var bottom = top + selected.offsetHeight;
|
|
16
|
+
var viewRectTop = container.scrollTop;
|
|
17
|
+
var viewRectBottom = viewRectTop + container.clientHeight;
|
|
18
|
+
if (top < viewRectTop) {
|
|
19
|
+
container.scrollTop = top;
|
|
20
|
+
} else if (bottom > viewRectBottom) {
|
|
21
|
+
container.scrollTop = bottom - container.clientHeight;
|
|
22
|
+
}
|
|
23
|
+
});
|