@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
package/tab-item/vue.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { computedIsClosable, computedActive, computedPaneName, watchTitle } from './index';
|
|
2
|
+
export var api = ['state'];
|
|
3
|
+
export var renderless = function renderless(props, _ref, _ref2) {
|
|
4
|
+
var computed = _ref.computed,
|
|
5
|
+
inject = _ref.inject,
|
|
6
|
+
reactive = _ref.reactive,
|
|
7
|
+
watch = _ref.watch;
|
|
8
|
+
var parent = _ref2.parent,
|
|
9
|
+
nextTick = _ref2.nextTick;
|
|
10
|
+
var api = {
|
|
11
|
+
watchTitle: watchTitle(parent),
|
|
12
|
+
computedIsClosable: computedIsClosable({
|
|
13
|
+
parent: parent,
|
|
14
|
+
props: props
|
|
15
|
+
})
|
|
16
|
+
};
|
|
17
|
+
var state = reactive({
|
|
18
|
+
index: null,
|
|
19
|
+
loaded: false,
|
|
20
|
+
animateShow: true,
|
|
21
|
+
rootTabs: inject('rootTabs'),
|
|
22
|
+
active: computed(function () {
|
|
23
|
+
return api.computedActive();
|
|
24
|
+
}),
|
|
25
|
+
paneName: computed(function () {
|
|
26
|
+
return api.computedPaneName();
|
|
27
|
+
}),
|
|
28
|
+
isClosable: computed(function () {
|
|
29
|
+
return api.computedIsClosable();
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
Object.assign(api, {
|
|
33
|
+
state: state,
|
|
34
|
+
computedActive: computedActive({
|
|
35
|
+
parent: parent,
|
|
36
|
+
nextTick: nextTick,
|
|
37
|
+
props: props,
|
|
38
|
+
state: state
|
|
39
|
+
}),
|
|
40
|
+
computedPaneName: computedPaneName({
|
|
41
|
+
props: props,
|
|
42
|
+
state: state
|
|
43
|
+
})
|
|
44
|
+
});
|
|
45
|
+
watch(function () {
|
|
46
|
+
return props.title;
|
|
47
|
+
}, api.watchTitle);
|
|
48
|
+
return api;
|
|
49
|
+
};
|
package/tab-nav/index.js
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { KEY_CODE, POSITION } from '@opentiny/vue-renderless/common';
|
|
2
|
+
import { capitalize } from '@opentiny/vue-renderless/common/string';
|
|
3
|
+
import { addResizeListener, removeResizeListener } from '@opentiny/vue-renderless/common/deps/resize-event';
|
|
4
|
+
import { on, off } from '@opentiny/vue-renderless/common/deps/dom';
|
|
5
|
+
export var computedNavStyle = function computedNavStyle(state) {
|
|
6
|
+
var dir = ~[POSITION.Top, POSITION.Bottom].indexOf(state.rootTabs.position) ? 'X' : 'Y';
|
|
7
|
+
if (state.mode === 'mobile') {
|
|
8
|
+
return {
|
|
9
|
+
transform: "translate".concat(dir, "(").concat(state.lineOffset, "px) translate").concat(dir, "(-50%)"),
|
|
10
|
+
width: "".concat(state.lineWidth, "px")
|
|
11
|
+
};
|
|
12
|
+
} else {
|
|
13
|
+
return {
|
|
14
|
+
transform: "translate".concat(dir, "(-").concat(state.navOffset, "px)")
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
export var scrollIntoView = function scrollIntoView(_ref) {
|
|
19
|
+
var parent = _ref.parent,
|
|
20
|
+
refs = _ref.refs,
|
|
21
|
+
state = _ref.state;
|
|
22
|
+
return function () {
|
|
23
|
+
if (!state.scrollable) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
var nav = refs.nav;
|
|
27
|
+
var activeTab = parent.$el.querySelector('.is-active');
|
|
28
|
+
if (!activeTab) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
var to = activeTab.offsetLeft - (nav.offsetWidth - activeTab.offsetWidth) / 2;
|
|
32
|
+
var from = nav.scrollLeft;
|
|
33
|
+
if (state.mode === 'mobile') {
|
|
34
|
+
nav.scrollLeft += to - from;
|
|
35
|
+
state.lineOffset = activeTab.offsetLeft + activeTab.offsetWidth / 2;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export var computedSizeName = function computedSizeName(state) {
|
|
40
|
+
return ~[POSITION.Top, POSITION.Bottom].indexOf(state.rootTabs.position) ? 'width' : 'height';
|
|
41
|
+
};
|
|
42
|
+
export var updated = function updated(_ref2) {
|
|
43
|
+
var api = _ref2.api,
|
|
44
|
+
refs = _ref2.refs,
|
|
45
|
+
state = _ref2.state;
|
|
46
|
+
return function () {
|
|
47
|
+
if (!refs.nav) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
var navSize = refs.nav["offset".concat(capitalize(state.sizeName))];
|
|
51
|
+
if (state.mode === 'mobile') {
|
|
52
|
+
Array.prototype.forEach.call(refs.nav.children, function (item) {
|
|
53
|
+
if (item.classList && item.classList.contains('tiny-mobile-tabs__item')) {
|
|
54
|
+
navSize += item.offsetWidth;
|
|
55
|
+
}
|
|
56
|
+
if (item.classList && item.classList.contains('is-active')) {
|
|
57
|
+
var line = item.querySelector('.tiny-mobile-tabs__name');
|
|
58
|
+
state.isActive = true;
|
|
59
|
+
state.lineWidth = line.offsetWidth;
|
|
60
|
+
state.lineOffset = item.offsetLeft + item.offsetWidth / 2;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
var containerSize = refs.navScroll["offset".concat(capitalize(state.sizeName))];
|
|
65
|
+
var currentOffset = state.navOffset;
|
|
66
|
+
if (containerSize < navSize) {
|
|
67
|
+
var _currentOffset = state.navOffset;
|
|
68
|
+
state.scrollable = state.scrollable || {};
|
|
69
|
+
state.scrollable.prev = _currentOffset;
|
|
70
|
+
state.scrollable.next = _currentOffset + containerSize < navSize;
|
|
71
|
+
if (navSize - _currentOffset < containerSize) {
|
|
72
|
+
state.navOffset = navSize - containerSize;
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
state.scrollable = false;
|
|
76
|
+
if (currentOffset > 0) {
|
|
77
|
+
state.navOffset = 0;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
state.isActive && api.scrollIntoView();
|
|
81
|
+
if (refs.tabBar) {
|
|
82
|
+
refs.tabBar.state.barStyle = refs.tabBar.computedBarStyle(refs.tabBar, state);
|
|
83
|
+
} else {
|
|
84
|
+
var line = refs.nav.querySelector('tiny-mobile-tabs__line');
|
|
85
|
+
line && line.style && (line.style.transform = api.computedNavStyle().transform);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
export var mounted = function mounted(_ref3) {
|
|
90
|
+
var api = _ref3.api,
|
|
91
|
+
parent = _ref3.parent;
|
|
92
|
+
var el = parent.$refs.nav.$el;
|
|
93
|
+
addResizeListener(el, api.updated);
|
|
94
|
+
on(document, 'visibilitychange', api.visibilityChangeHandler);
|
|
95
|
+
on(window, 'blur', api.windowBlurHandler);
|
|
96
|
+
on(window, 'focus', api.windowFocusHandler);
|
|
97
|
+
api.scrollToActiveTab();
|
|
98
|
+
api.scrollIntoView();
|
|
99
|
+
};
|
|
100
|
+
export var beforeUnmount = function beforeUnmount(_ref4) {
|
|
101
|
+
var api = _ref4.api,
|
|
102
|
+
parent = _ref4.parent;
|
|
103
|
+
var el = parent.$refs.nav && parent.$refs.nav.$el;
|
|
104
|
+
if (el && api.updated) {
|
|
105
|
+
removeResizeListener(el, api.updated);
|
|
106
|
+
}
|
|
107
|
+
off(document, 'visibilitychange', api.visibilityChangeHandler);
|
|
108
|
+
off(window, 'blur', api.windowBlurHandler);
|
|
109
|
+
off(window, 'focus', api.windowFocusHandler);
|
|
110
|
+
};
|
|
111
|
+
export var visibilityChangeHandler = function visibilityChangeHandler(state) {
|
|
112
|
+
return function () {
|
|
113
|
+
var visibility = document.visibilityState;
|
|
114
|
+
if (visibility === 'hidden') {
|
|
115
|
+
state.focusable = false;
|
|
116
|
+
} else if (visibility === 'visible') {
|
|
117
|
+
setTimeout(function () {
|
|
118
|
+
state.focusable = true;
|
|
119
|
+
}, 50);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
export var windowBlurHandler = function windowBlurHandler(state) {
|
|
124
|
+
return function () {
|
|
125
|
+
state.focusable = false;
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
export var windowFocusHandler = function windowFocusHandler(state) {
|
|
129
|
+
return function () {
|
|
130
|
+
setTimeout(function () {
|
|
131
|
+
state.focusable = true;
|
|
132
|
+
}, 50);
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
export var scrollToActiveTab = function scrollToActiveTab(_ref5) {
|
|
136
|
+
var parent = _ref5.parent,
|
|
137
|
+
refs = _ref5.refs,
|
|
138
|
+
state = _ref5.state;
|
|
139
|
+
return function () {
|
|
140
|
+
if (!state.scrollable) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
var nav = refs.nav;
|
|
144
|
+
var activeTab = parent.$el.querySelector('.is-active');
|
|
145
|
+
if (!activeTab) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
var navScroll = refs.navScroll;
|
|
149
|
+
var activeTabBounding = activeTab.getBoundingClientRect();
|
|
150
|
+
var navScrollBounding = navScroll.getBoundingClientRect();
|
|
151
|
+
var maxOffset = nav.offsetWidth - navScrollBounding.width;
|
|
152
|
+
if (state.mode === 'mobile') {
|
|
153
|
+
if (activeTabBounding.left > navScrollBounding.width) {
|
|
154
|
+
maxOffset = activeTabBounding.left - navScrollBounding.width + activeTabBounding.width;
|
|
155
|
+
} else {
|
|
156
|
+
maxOffset = activeTabBounding.width;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
var currentOffset = state.navOffset;
|
|
160
|
+
var newOffset = currentOffset;
|
|
161
|
+
if (activeTabBounding.left < navScrollBounding.left) {
|
|
162
|
+
newOffset = currentOffset - (navScrollBounding.left - activeTabBounding.left);
|
|
163
|
+
}
|
|
164
|
+
if (activeTabBounding.right > navScrollBounding.right) {
|
|
165
|
+
newOffset = currentOffset + activeTabBounding.right - navScrollBounding.right;
|
|
166
|
+
}
|
|
167
|
+
newOffset = Math.max(newOffset, 0);
|
|
168
|
+
state.navOffset = Math.min(newOffset, maxOffset);
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
export var scrollPrev = function scrollPrev(_ref6) {
|
|
172
|
+
var refs = _ref6.refs,
|
|
173
|
+
state = _ref6.state;
|
|
174
|
+
return function () {
|
|
175
|
+
var containerSize = refs.navScroll["offset".concat(capitalize(state.sizeName))];
|
|
176
|
+
var currentOffset = state.navOffset;
|
|
177
|
+
if (!currentOffset) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
var newOffset = currentOffset > containerSize ? currentOffset - containerSize : 0;
|
|
181
|
+
state.navOffset = newOffset;
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
export var scrollNext = function scrollNext(_ref7) {
|
|
185
|
+
var refs = _ref7.refs,
|
|
186
|
+
state = _ref7.state;
|
|
187
|
+
return function () {
|
|
188
|
+
var navSize = refs.nav["offset".concat(capitalize(state.sizeName))];
|
|
189
|
+
var containerSize = refs.navScroll["offset".concat(capitalize(state.sizeName))];
|
|
190
|
+
var currentOffset = state.navOffset;
|
|
191
|
+
if (navSize - currentOffset <= containerSize) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
var newOffset = navSize - currentOffset > containerSize * 2 ? currentOffset + containerSize : navSize - containerSize;
|
|
195
|
+
state.navOffset = newOffset;
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
export var changeTab = function changeTab(api) {
|
|
199
|
+
return function (event) {
|
|
200
|
+
var keyCode = event.keyCode;
|
|
201
|
+
var nextIndex;
|
|
202
|
+
var currentIndex, tabList;
|
|
203
|
+
if (~[KEY_CODE.ArrowLeft, KEY_CODE.ArrowRight, KEY_CODE.ArrowUp, KEY_CODE.ArrowDown].indexOf(keyCode)) {
|
|
204
|
+
tabList = event.currentTarget.querySelectorAll('[role=tab]');
|
|
205
|
+
currentIndex = Array.prototype.indexOf.call(tabList, event.target);
|
|
206
|
+
} else {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
if (keyCode === KEY_CODE.ArrowLeft || keyCode === KEY_CODE.ArrowUp) {
|
|
210
|
+
if (currentIndex === 0) {
|
|
211
|
+
nextIndex = tabList.length - 1;
|
|
212
|
+
} else {
|
|
213
|
+
nextIndex = currentIndex - 1;
|
|
214
|
+
}
|
|
215
|
+
} else {
|
|
216
|
+
if (currentIndex < tabList.length - 1) {
|
|
217
|
+
nextIndex = currentIndex + 1;
|
|
218
|
+
} else {
|
|
219
|
+
nextIndex = 0;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
tabList[nextIndex].focus();
|
|
223
|
+
tabList[nextIndex].click();
|
|
224
|
+
api.setFocus();
|
|
225
|
+
};
|
|
226
|
+
};
|
|
227
|
+
export var setFocus = function setFocus(state) {
|
|
228
|
+
return function () {
|
|
229
|
+
if (state.focusable) {
|
|
230
|
+
state.isFocus = true;
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
};
|
|
234
|
+
export var removeFocus = function removeFocus(state) {
|
|
235
|
+
return function () {
|
|
236
|
+
state.isFocus = true;
|
|
237
|
+
};
|
|
238
|
+
};
|
|
239
|
+
export var moreTabShow = function moreTabShow(state) {
|
|
240
|
+
return function () {
|
|
241
|
+
if (state.showMoreItem) {
|
|
242
|
+
state.showMoreItem = false;
|
|
243
|
+
} else {
|
|
244
|
+
state.showMoreItem = true;
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
};
|
package/tab-nav/vue.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { computedNavStyle, computedSizeName, updated, visibilityChangeHandler, windowBlurHandler, windowFocusHandler, scrollToActiveTab, scrollIntoView, mounted, moreTabShow, beforeUnmount, scrollPrev, scrollNext, changeTab, setFocus, removeFocus } from './index';
|
|
2
|
+
export var api = ['state', 'setFocus', 'removeFocus', 'scrollPrev', 'scrollNext', 'changeTab', 'scrollToActiveTab', 'scrollIntoView', 'moreTabShow', 'swiperHandle'];
|
|
3
|
+
export var renderless = function renderless(props, _ref, _ref2) {
|
|
4
|
+
var computed = _ref.computed,
|
|
5
|
+
watch = _ref.watch,
|
|
6
|
+
inject = _ref.inject,
|
|
7
|
+
onBeforeUnmount = _ref.onBeforeUnmount,
|
|
8
|
+
onMounted = _ref.onMounted,
|
|
9
|
+
onUpdated = _ref.onUpdated,
|
|
10
|
+
reactive = _ref.reactive;
|
|
11
|
+
var parent = _ref2.parent,
|
|
12
|
+
refs = _ref2.refs,
|
|
13
|
+
nextTick = _ref2.nextTick,
|
|
14
|
+
tinyMode = _ref2.mode;
|
|
15
|
+
var api = {
|
|
16
|
+
mounted: mounted,
|
|
17
|
+
beforeUnmount: beforeUnmount,
|
|
18
|
+
computedNavStyle: computedNavStyle,
|
|
19
|
+
computedSizeName: computedSizeName
|
|
20
|
+
};
|
|
21
|
+
var state = reactive({
|
|
22
|
+
navOffset: 0,
|
|
23
|
+
lineOffset: 0,
|
|
24
|
+
lineWidth: 0,
|
|
25
|
+
scrollable: false,
|
|
26
|
+
isFocus: false,
|
|
27
|
+
focusable: false,
|
|
28
|
+
showMoreItem: false,
|
|
29
|
+
isActive: false,
|
|
30
|
+
showMoreTabs: props.showMoreTabs,
|
|
31
|
+
mode: props._mode || parent.$mode || (tinyMode ? tinyMode.value : 'pc'),
|
|
32
|
+
rootTabs: inject('rootTabs'),
|
|
33
|
+
sizeName: computed(function () {
|
|
34
|
+
return api.computedSizeName(state);
|
|
35
|
+
}),
|
|
36
|
+
navStyle: computed(function () {
|
|
37
|
+
return api.computedNavStyle(state);
|
|
38
|
+
})
|
|
39
|
+
});
|
|
40
|
+
Object.assign(api, {
|
|
41
|
+
state: state,
|
|
42
|
+
setFocus: setFocus(state),
|
|
43
|
+
removeFocus: removeFocus(state),
|
|
44
|
+
moreTabShow: moreTabShow(state),
|
|
45
|
+
scrollPrev: scrollPrev({
|
|
46
|
+
refs: refs,
|
|
47
|
+
state: state
|
|
48
|
+
}),
|
|
49
|
+
scrollNext: scrollNext({
|
|
50
|
+
refs: refs,
|
|
51
|
+
state: state
|
|
52
|
+
}),
|
|
53
|
+
windowBlurHandler: windowBlurHandler(state),
|
|
54
|
+
windowFocusHandler: windowFocusHandler(state),
|
|
55
|
+
visibilityChangeHandler: visibilityChangeHandler(state),
|
|
56
|
+
scrollToActiveTab: scrollToActiveTab({
|
|
57
|
+
props: props,
|
|
58
|
+
parent: parent,
|
|
59
|
+
refs: refs,
|
|
60
|
+
state: state
|
|
61
|
+
}),
|
|
62
|
+
scrollIntoView: scrollIntoView({
|
|
63
|
+
props: props,
|
|
64
|
+
parent: parent,
|
|
65
|
+
refs: refs,
|
|
66
|
+
state: state
|
|
67
|
+
})
|
|
68
|
+
});
|
|
69
|
+
watch(function () {
|
|
70
|
+
return props.currentName;
|
|
71
|
+
}, function () {
|
|
72
|
+
nextTick(function () {
|
|
73
|
+
var tabBarVnode = refs.tabBar;
|
|
74
|
+
if (tabBarVnode) {
|
|
75
|
+
tabBarVnode.state.barStyle = tabBarVnode.computedBarStyle(tabBarVnode, state);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}, {
|
|
79
|
+
immediate: true
|
|
80
|
+
});
|
|
81
|
+
Object.assign(api, {
|
|
82
|
+
updated: updated({
|
|
83
|
+
api: api,
|
|
84
|
+
props: props,
|
|
85
|
+
refs: refs,
|
|
86
|
+
state: state
|
|
87
|
+
}),
|
|
88
|
+
changeTab: changeTab(api)
|
|
89
|
+
});
|
|
90
|
+
onUpdated(function () {
|
|
91
|
+
return api.updated();
|
|
92
|
+
});
|
|
93
|
+
onMounted(function () {
|
|
94
|
+
return api.mounted({
|
|
95
|
+
api: api,
|
|
96
|
+
parent: parent
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
onBeforeUnmount(function () {
|
|
100
|
+
return api.beforeUnmount({
|
|
101
|
+
api: api,
|
|
102
|
+
parent: parent
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
return api;
|
|
106
|
+
};
|
package/tabbar/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export var setActiveItem = function setActiveItem(_ref) {
|
|
2
|
+
var props = _ref.props,
|
|
3
|
+
state = _ref.state;
|
|
4
|
+
return function () {
|
|
5
|
+
state.children.forEach(function (item, index) {
|
|
6
|
+
item.state ? item.state.index = index : item.index = index;
|
|
7
|
+
item.state && (item.state.active = (item.name || index) === props.modelValue);
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export var onChange = function onChange(_ref2) {
|
|
12
|
+
var emit = _ref2.emit,
|
|
13
|
+
props = _ref2.props;
|
|
14
|
+
return function (active) {
|
|
15
|
+
if (active !== props.modelValue) {
|
|
16
|
+
emit('update:modelValue', active);
|
|
17
|
+
emit('change', active);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export var getChildrens = function getChildrens(_ref3) {
|
|
22
|
+
var childrenHandler = _ref3.childrenHandler;
|
|
23
|
+
return function () {
|
|
24
|
+
var $children = [];
|
|
25
|
+
childrenHandler(function (_ref4) {
|
|
26
|
+
var options = _ref4.options,
|
|
27
|
+
vm = _ref4.vm;
|
|
28
|
+
options.componentName === 'TinyTabbarItem' && $children.push(vm);
|
|
29
|
+
});
|
|
30
|
+
return $children;
|
|
31
|
+
};
|
|
32
|
+
};
|
package/tabbar/vue.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { setActiveItem, onChange, getChildrens } from './index';
|
|
2
|
+
export var api = ['state', 'onChange', 'getChildrens'];
|
|
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 refs = _ref2.refs,
|
|
9
|
+
emit = _ref2.emit,
|
|
10
|
+
nextTick = _ref2.nextTick,
|
|
11
|
+
childrenHandler = _ref2.childrenHandler;
|
|
12
|
+
var state = reactive({
|
|
13
|
+
height: null,
|
|
14
|
+
children: [],
|
|
15
|
+
fit: computed(function () {
|
|
16
|
+
return props.safeAreaInsetBottom !== null ? props.safeAreaInsetBottom : props.fixed;
|
|
17
|
+
})
|
|
18
|
+
});
|
|
19
|
+
var api = {
|
|
20
|
+
state: state,
|
|
21
|
+
onChange: onChange({
|
|
22
|
+
emit: emit,
|
|
23
|
+
props: props
|
|
24
|
+
}),
|
|
25
|
+
parent: computed(function () {
|
|
26
|
+
return api.getParent();
|
|
27
|
+
}),
|
|
28
|
+
setActiveItem: setActiveItem({
|
|
29
|
+
props: props,
|
|
30
|
+
state: state
|
|
31
|
+
}),
|
|
32
|
+
getChildrens: getChildrens({
|
|
33
|
+
childrenHandler: childrenHandler
|
|
34
|
+
})
|
|
35
|
+
};
|
|
36
|
+
onMounted(function () {
|
|
37
|
+
if (props.placeholder && props.fixed) {
|
|
38
|
+
nextTick(function () {
|
|
39
|
+
state.height = refs.tabbar.getBoundingClientRect().height;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
watch(function () {
|
|
44
|
+
return props.modelValue;
|
|
45
|
+
}, api.setActiveItem, {
|
|
46
|
+
immediate: true
|
|
47
|
+
});
|
|
48
|
+
watch(function () {
|
|
49
|
+
return state.children;
|
|
50
|
+
}, api.setActiveItem, {
|
|
51
|
+
immediate: true
|
|
52
|
+
});
|
|
53
|
+
return api;
|
|
54
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { isObject, isNull } from '@opentiny/vue-renderless/common/type';
|
|
2
|
+
export var getRouteActive = function getRouteActive(_ref) {
|
|
3
|
+
var props = _ref.props,
|
|
4
|
+
route = _ref.route;
|
|
5
|
+
return function () {
|
|
6
|
+
if (props.to && route) {
|
|
7
|
+
var config = isObject(props.to) ? props.to : {
|
|
8
|
+
path: props.to
|
|
9
|
+
};
|
|
10
|
+
var pathMatched = config.path === route.path;
|
|
11
|
+
var nameMatched = !isNull(config.name) && config.name === route.name;
|
|
12
|
+
return pathMatched || nameMatched;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export var onClick = function onClick(_ref2) {
|
|
17
|
+
var api = _ref2.api,
|
|
18
|
+
emit = _ref2.emit,
|
|
19
|
+
parent = _ref2.parent,
|
|
20
|
+
props = _ref2.props,
|
|
21
|
+
router = _ref2.router,
|
|
22
|
+
state = _ref2.state;
|
|
23
|
+
return function () {
|
|
24
|
+
parent.$parent.onChange(props.name || parent.index || state.index);
|
|
25
|
+
emit('click', event);
|
|
26
|
+
api.routeTab(router);
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export var bindChildren = function bindChildren(parent) {
|
|
30
|
+
return function () {
|
|
31
|
+
if (!parent.$parent) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
parent.$parent.state.children = parent.$parent.getChildrens();
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export var routeTab = function routeTab(props, state) {
|
|
38
|
+
return function (router) {
|
|
39
|
+
var to = props.to,
|
|
40
|
+
replace = props.replace;
|
|
41
|
+
var url = state.url;
|
|
42
|
+
if (to && router) {
|
|
43
|
+
var promise = router[replace ? 'replace' : 'push'](to);
|
|
44
|
+
if (promise && promise["catch"]) {
|
|
45
|
+
promise["catch"](function (err) {
|
|
46
|
+
if (err && err.name !== 'NavigationDuplicated') {
|
|
47
|
+
throw err;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
} else if (url) {
|
|
52
|
+
replace ? location.replace(url) : location.href = url;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { getRouteActive, onClick, bindChildren, routeTab } from './index';
|
|
2
|
+
import { xss } from '@opentiny/vue-renderless/common/xss.js';
|
|
3
|
+
export var api = ['state', 'onClick'];
|
|
4
|
+
export var renderless = function renderless(props, _ref, _ref2) {
|
|
5
|
+
var computed = _ref.computed,
|
|
6
|
+
onMounted = _ref.onMounted,
|
|
7
|
+
reactive = _ref.reactive;
|
|
8
|
+
var parent = _ref2.parent,
|
|
9
|
+
emit = _ref2.emit,
|
|
10
|
+
nextTick = _ref2.nextTick,
|
|
11
|
+
route = _ref2.route,
|
|
12
|
+
router = _ref2.router;
|
|
13
|
+
var api = {};
|
|
14
|
+
var state = reactive({
|
|
15
|
+
active: false,
|
|
16
|
+
info: computed(function () {
|
|
17
|
+
return props.dot ? '' : !props.dot && props.badge;
|
|
18
|
+
}),
|
|
19
|
+
url: computed(function () {
|
|
20
|
+
return xss.filterUrl(props.url);
|
|
21
|
+
}),
|
|
22
|
+
routeActive: computed(function () {
|
|
23
|
+
return api.getRouteActive();
|
|
24
|
+
}),
|
|
25
|
+
renderActive: computed(function () {
|
|
26
|
+
return parent.$parent.route ? state.routeActive : state.active;
|
|
27
|
+
}),
|
|
28
|
+
renderColor: computed(function () {
|
|
29
|
+
return parent.$parent[state.active ? 'activeColor' : 'inactiveColor'];
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
Object.assign(api, {
|
|
33
|
+
state: state,
|
|
34
|
+
bindChildren: bindChildren(parent),
|
|
35
|
+
routeTab: routeTab(props, state),
|
|
36
|
+
getRouteActive: getRouteActive({
|
|
37
|
+
props: props,
|
|
38
|
+
route: route
|
|
39
|
+
}),
|
|
40
|
+
onClick: onClick({
|
|
41
|
+
api: api,
|
|
42
|
+
emit: emit,
|
|
43
|
+
parent: parent,
|
|
44
|
+
props: props,
|
|
45
|
+
router: router,
|
|
46
|
+
state: state
|
|
47
|
+
})
|
|
48
|
+
});
|
|
49
|
+
onMounted(function () {
|
|
50
|
+
return nextTick(api.bindChildren);
|
|
51
|
+
});
|
|
52
|
+
return api;
|
|
53
|
+
};
|
package/table/index.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
export var computedCheckableData = function computedCheckableData(_ref) {
|
|
2
|
+
var props = _ref.props;
|
|
3
|
+
return function () {
|
|
4
|
+
return props.data.filter(function (item) {
|
|
5
|
+
return !item['disabled'];
|
|
6
|
+
});
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export var computedSelectedKeys = function computedSelectedKeys(_ref2) {
|
|
10
|
+
var props = _ref2.props,
|
|
11
|
+
state = _ref2.state;
|
|
12
|
+
return function () {
|
|
13
|
+
var keys = [];
|
|
14
|
+
state.checkableData.forEach(function (item) {
|
|
15
|
+
return keys.push(item[props.keys]);
|
|
16
|
+
});
|
|
17
|
+
return keys;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export var computedSelectCls = function computedSelectCls(_ref3) {
|
|
21
|
+
var state = _ref3.state;
|
|
22
|
+
return function () {
|
|
23
|
+
if (state.selected.length > 0 && state.selected.length >= state.checkableData.length) {
|
|
24
|
+
return 'checked-sur';
|
|
25
|
+
} else if (state.selected.length > 0 && state.selected.length < state.checkableData.length) {
|
|
26
|
+
return 'halfselect';
|
|
27
|
+
}
|
|
28
|
+
return 'check';
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export var watchDefaultChecked = function watchDefaultChecked(_ref4) {
|
|
32
|
+
var props = _ref4.props,
|
|
33
|
+
state = _ref4.state;
|
|
34
|
+
return function (value, oldvalue) {
|
|
35
|
+
if (oldvalue && value.length === oldvalue.length && value.every(function (item) {
|
|
36
|
+
return oldvalue.indexOf(item) > -1;
|
|
37
|
+
})) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
var checked = [];
|
|
41
|
+
state.checkableData.forEach(function (item) {
|
|
42
|
+
var index = value.indexOf(item[props.keys]);
|
|
43
|
+
if (~index) {
|
|
44
|
+
checked.push(item);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
state.selected = checked;
|
|
48
|
+
state.checkedChangeByUser = false;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export var watchSelected = function watchSelected(_ref5) {
|
|
52
|
+
var emit = _ref5.emit,
|
|
53
|
+
props = _ref5.props,
|
|
54
|
+
state = _ref5.state;
|
|
55
|
+
return function (value, oldvalue) {
|
|
56
|
+
var keys = [];
|
|
57
|
+
value.forEach(function (item) {
|
|
58
|
+
return keys.push(item[props.keys]);
|
|
59
|
+
});
|
|
60
|
+
if (state.checkedChangeByUser) {
|
|
61
|
+
var movedKeys = value.concat(oldvalue).filter(function (item) {
|
|
62
|
+
return value.indexOf(item) === -1 || oldvalue.indexOf(item) === -1;
|
|
63
|
+
});
|
|
64
|
+
emit('checked-change', keys, false, movedKeys);
|
|
65
|
+
} else {
|
|
66
|
+
emit('checked-change', keys, false);
|
|
67
|
+
state.checkedChangeByUser = true;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
export var selectRow = function selectRow(_ref6) {
|
|
72
|
+
var emit = _ref6.emit,
|
|
73
|
+
state = _ref6.state;
|
|
74
|
+
return function (row) {
|
|
75
|
+
state.selectedRow = row;
|
|
76
|
+
emit('radio-change', row);
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
export var togeSelected = function togeSelected(_ref7) {
|
|
80
|
+
var state = _ref7.state;
|
|
81
|
+
return function (row) {
|
|
82
|
+
if (row.disabled) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
var index = state.selected.indexOf(row);
|
|
86
|
+
if (index !== -1) {
|
|
87
|
+
state.selected.splice(index, 1);
|
|
88
|
+
} else {
|
|
89
|
+
state.selected.push(row);
|
|
90
|
+
}
|
|
91
|
+
state.selected = state.selected.slice();
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
export var togeSelectAll = function togeSelectAll(_ref8) {
|
|
95
|
+
var emit = _ref8.emit,
|
|
96
|
+
props = _ref8.props,
|
|
97
|
+
state = _ref8.state;
|
|
98
|
+
return function () {
|
|
99
|
+
var data = [];
|
|
100
|
+
if (state.selectCls === 'checked-sur') {
|
|
101
|
+
state.selected = [];
|
|
102
|
+
data = [];
|
|
103
|
+
} else {
|
|
104
|
+
data = state.checkableData.map(function (item) {
|
|
105
|
+
return item[props.keys];
|
|
106
|
+
});
|
|
107
|
+
state.selected = state.checkableData;
|
|
108
|
+
}
|
|
109
|
+
emit('checked-change', data, true);
|
|
110
|
+
};
|
|
111
|
+
};
|