@opentiny/vue-renderless 3.13.1 → 3.14.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 +20 -13
- package/action-sheet/vue.js +8 -7
- package/amount/index.js +100 -25
- package/amount/vue.js +102 -26
- package/anchor/index.js +1 -0
- package/area/index.js +8 -8
- package/area/vue.js +5 -5
- package/async-flowchart/index.js +16 -3
- package/autocomplete/index.js +58 -14
- package/autocomplete/vue.js +40 -12
- package/badge/index.js +12 -0
- package/badge/vue.js +6 -4
- package/breadcrumb/vue.js +3 -1
- package/breadcrumb-item/vue.js +6 -2
- package/button/index.js +5 -1
- package/calendar/index.js +2 -86
- package/calendar-bar/index.js +18 -4
- package/calendar-view/index.js +5 -1
- package/calendar-view/vue.js +16 -3
- package/card-group/vue.js +4 -2
- package/cascader/index.js +86 -34
- package/cascader/vue.js +61 -20
- package/cascader-menu/index.js +7 -7
- package/cascader-menu/vue.js +2 -3
- package/cascader-mobile/index.js +36 -23
- package/cascader-mobile/vue.js +6 -0
- package/cascader-node/index.js +13 -1
- package/cascader-node/vue.js +15 -4
- package/cascader-panel/index.js +1 -1
- package/cascader-select/column-index.js +150 -0
- package/cascader-select/column.js +120 -0
- package/cascader-select/index.js +29 -165
- package/cascader-select/usePicker.js +251 -0
- package/cascader-select/useTouch.js +65 -0
- package/cascader-select/vue.js +35 -47
- package/cell/vue.js +2 -1
- package/chart-bar/index.js +2 -3
- package/chart-core/deps/constants.js +43 -43
- package/chart-core/index.js +1 -1
- package/chart-gauge/index.js +2 -2
- package/chart-heatmap/index.js +17 -10
- package/chart-line/index.js +8 -9
- package/chart-tree/index.js +2 -2
- package/chart-waterfall/index.js +4 -6
- package/checkbox/index.js +18 -1
- package/checkbox/vue.js +15 -7
- package/checkbox-group/vue.js +1 -0
- package/col/vue.js +1 -1
- package/collapse/index.js +3 -3
- package/color-select-panel/vue.js +0 -7
- package/column-list-item/index.js +17 -1
- package/column-list-item/vue.js +8 -3
- package/common/date.js +7 -5
- package/common/deps/clickoutside.js +6 -2
- package/common/deps/dom.js +19 -4
- package/common/deps/popper.js +44 -11
- package/common/deps/resize-event.js +1 -0
- package/common/deps/touch-emulator.js +4 -1
- package/common/deps/tree-model/node.js +2 -2
- package/common/deps/tree-model/tree-store.js +2 -13
- package/common/deps/useRect.js +25 -0
- package/common/deps/vue-popper.js +38 -20
- package/common/index.js +2 -2
- package/common/runtime.js +1 -1
- package/common/string.js +2 -2
- package/common/type.js +2 -1
- package/common/validate/rules/enum.js +1 -1
- package/common/validate/rules/pattern.js +2 -2
- package/common/validate/rules/range.js +8 -5
- package/common/validate/rules/required.js +1 -1
- package/common/validate/rules/type.js +5 -5
- package/common/validate/rules/whitespace.js +1 -1
- package/common/validate/util.js +15 -16
- package/common/validate/validations/integer.js +1 -1
- package/common/validate/validations/method.js +1 -1
- package/currency/index.js +74 -7
- package/currency/vue.js +21 -5
- package/date-panel/index.js +16 -0
- package/date-panel/vue.js +8 -2
- package/date-picker-mobile/index.js +12 -0
- package/date-picker-mobile/vue.js +7 -1
- package/date-range/vue.js +14 -6
- package/date-table/index.js +5 -0
- package/date-table/vue.js +3 -1
- package/dialog-box/index.js +46 -14
- package/dialog-box/vue.js +30 -7
- package/dialog-select/index.js +6 -3
- package/dialog-select/vue.js +8 -4
- package/drawer/index.js +27 -5
- package/drawer/vue.js +14 -7
- package/dropdown/index.js +7 -7
- package/dropdown/vue.js +6 -2
- package/dropdown-item/index.js +9 -1
- package/dropdown-item/mf.js +6 -10
- package/dropdown-item/vue.js +20 -7
- package/dropdown-menu/index.js +20 -7
- package/dropdown-menu/vue.js +4 -3
- package/exception/index.js +2 -7
- package/exception/vue.js +7 -10
- package/fall-menu/index.js +5 -1
- package/fall-menu/vue.js +13 -2
- package/file-upload/index.js +68 -18
- package/file-upload/vue.js +38 -8
- package/filter-box/index.js +1 -0
- package/float-button/index.js +42 -0
- package/float-button/vue.js +101 -0
- package/floating-button/index.js +62 -16
- package/floating-button/vue.js +27 -9
- package/flowchart/index.js +134 -25
- package/flowchart/node.js +13 -4
- package/flowchart/vue.js +16 -4
- package/form/vue.js +8 -0
- package/form-item/index.js +5 -5
- package/form-item/vue.js +3 -1
- package/fullscreen/index.js +5 -5
- package/fullscreen/vue.js +3 -3
- package/grid/plugins/export.js +5 -2
- package/grid/utils/column.js +1 -0
- package/grid/utils/dom.js +7 -1
- package/image/index.js +6 -1
- package/image/vue.js +6 -3
- package/image-viewer/index.js +62 -51
- package/image-viewer/vue.js +17 -5
- package/input/index.js +81 -20
- package/input/vue.js +44 -18
- package/ip-address/index.js +61 -19
- package/ip-address/vue.js +22 -4
- package/link/vue.js +3 -1
- package/loading/index.js +2 -2
- package/loading/vue.js +8 -2
- package/logout/index.js +1 -1
- package/menu/index.js +15 -2
- package/menu/vue.js +22 -17
- package/mind-map/index.js +47 -0
- package/mind-map/vue.js +53 -0
- package/modal/index.js +44 -4
- package/modal/vue.js +18 -4
- package/multi-select/index.js +186 -11
- package/multi-select/vue.js +60 -15
- package/multi-select-item/index.js +23 -0
- package/multi-select-item/vue.js +31 -0
- package/numeric/index.js +46 -12
- package/numeric/vue.js +44 -19
- package/option/index.js +27 -9
- package/option/vue.js +37 -21
- package/option-group/index.js +3 -3
- package/package.json +1 -1
- package/pager/index.js +18 -4
- package/pager/vue.js +16 -5
- package/picker/index.js +258 -49
- package/picker/mb.js +42 -0
- package/picker/vue.js +70 -17
- package/picker-column/index.js +1 -1
- package/pop-upload/vue.js +3 -0
- package/popconfirm/index.js +3 -6
- package/popconfirm/vue.js +1 -1
- package/popeditor/index.js +71 -32
- package/popeditor/vue.js +15 -11
- package/popover/index.js +4 -4
- package/popover/vue.js +6 -6
- package/popup/index.js +3 -3
- package/popup/vue.js +5 -5
- package/pull-refresh/index.js +13 -13
- package/pull-refresh/vue.js +5 -4
- package/radio/index.js +0 -17
- package/radio/vue.js +4 -10
- package/rate/index.js +1 -1
- package/rate/vue.js +0 -2
- package/record/index.js +4 -1
- package/rich-text/clipboard.js +54 -0
- package/rich-text/index.js +192 -0
- package/rich-text/module/file-upload.js +107 -0
- package/rich-text/module/image-drop.js +63 -0
- package/rich-text/module/image-upload.js +89 -0
- package/rich-text/options.js +141 -0
- package/rich-text/table-module.js +382 -0
- package/rich-text/vue.js +102 -0
- package/{rich-text-edtior → rich-text-editor}/index.js +2 -2
- package/{rich-text-edtior → rich-text-editor}/vue.js +2 -5
- package/scrollbar/index.js +11 -11
- package/scrollbar/vue-bar.js +3 -3
- package/scrollbar/vue.js +5 -5
- package/search/index.js +9 -9
- package/search/vue.js +8 -6
- package/select/index.js +457 -389
- package/select/vue.js +257 -161
- package/select-dropdown/index.js +61 -3
- package/select-dropdown/vue.js +85 -8
- package/select-view/index.js +3 -1
- package/selected-box/index.js +2 -0
- package/selected-box/vue.js +6 -3
- package/signature/index.js +241 -0
- package/signature/vue.js +88 -0
- package/skeleton/index.js +14 -0
- package/skeleton/vue.js +15 -0
- package/skeleton-item/vue.js +15 -0
- package/slider/index.js +70 -17
- package/slider/vue.js +16 -7
- package/split/index.js +5 -3
- package/split/vue.js +4 -6
- package/standard-list-item/index.js +15 -1
- package/standard-list-item/vue.js +6 -5
- package/steps/index.js +25 -2
- package/steps/slide-bar.js +8 -1
- package/steps/vue.js +15 -3
- package/tab-item-mf/vue.js +14 -8
- package/tab-nav/index.js +30 -5
- package/tab-nav/vue.js +16 -4
- package/tabbar/vue.js +9 -3
- package/tabbar-item/vue.js +3 -2
- package/tabs/index.js +16 -4
- package/tabs/vue.js +2 -1
- package/tabs-mf/index.js +20 -6
- package/tabs-mf/vue-nav.js +26 -11
- package/tabs-mf/vue.js +7 -7
- package/tabs-mf/wheel.js +1 -0
- package/tag/index.js +1 -1
- package/tag-group/index.js +2 -1
- package/time/index.js +5 -2
- package/time/vue.js +1 -1
- package/time-line/index.js +3 -3
- package/time-line/vue.js +2 -2
- package/time-picker-mobile/index.js +24 -5
- package/time-picker-mobile/vue.js +17 -7
- package/time-range/index.js +2 -0
- package/timeline-item/vue.js +1 -1
- package/tooltip/index.js +6 -3
- package/tooltip/vue.js +4 -4
- package/transfer/index.js +20 -22
- package/transfer/vue.js +1 -6
- package/transfer-panel/vue.js +3 -5
- package/tree/index.js +21 -4
- package/tree/vue.js +10 -8
- package/tree-menu/index.js +31 -5
- package/tree-menu/vue.js +28 -15
- package/tree-node/index.js +18 -18
- package/tree-node/vue.js +6 -5
- package/types/action-sheet.type.d.ts +118 -1
- package/types/alert.type.d.ts +1 -1
- package/types/amount.type.d.ts +168 -1
- package/types/area.type.d.ts +134 -1
- package/types/async-flowchart.type.d.ts +72 -0
- package/types/autocomplete.type.d.ts +199 -1
- package/types/badge.type.d.ts +3 -1
- package/types/breadcrumb-item.type.d.ts +2 -0
- package/types/breadcrumb.type.d.ts +2 -0
- package/types/button-group.type.d.ts +3 -3
- package/types/button.type.d.ts +4 -0
- package/types/cascader-menu.type.d.ts +3 -4
- package/types/cascader-node.type.d.ts +5 -2
- package/types/cascader-panel.type-2bd03be3.d.ts +241 -0
- package/types/cascader-panel.type.d.ts +3 -241
- package/types/cascader.type.d.ts +329 -1
- package/types/checkbox.type.d.ts +9 -3
- package/types/collapse.type.d.ts +20 -3
- package/types/date-picker.type.d.ts +37 -0
- package/types/dialog-box.type.d.ts +13 -3
- package/types/drawer.type.d.ts +133 -1
- package/types/{dropdown-item.type-8ea6c633.d.ts → dropdown-item.type-8475a549.d.ts} +7 -13
- package/types/dropdown-item.type.d.ts +1 -1
- package/types/dropdown-menu.type.d.ts +1 -1
- package/types/dropdown.type.d.ts +1 -5
- package/types/fall-menu.type.d.ts +94 -1
- package/types/file-upload.type.d.ts +1 -1
- package/types/float-button.type.d.ts +123 -0
- package/types/form-item.type.d.ts +1 -1
- package/types/{form.type-d0fd42f3.d.ts → form.type-222799ae.d.ts} +5 -2
- package/types/form.type.d.ts +1 -1
- package/types/{index-e0250f63.d.ts → index-b012f687.d.ts} +9 -0
- package/types/input.type.d.ts +1 -5
- package/types/ip-address.type.d.ts +160 -1
- package/types/link.type.d.ts +6 -3
- package/types/loading.type.d.ts +7 -0
- package/types/milestone.type.d.ts +1 -1
- package/types/mind-map.type.d.ts +20 -0
- package/types/modal.type.d.ts +29 -2
- package/types/numeric.type.d.ts +41 -10
- package/types/pager.type.d.ts +13 -1
- package/types/picker.type.d.ts +18 -0
- package/types/popconfirm.type.d.ts +86 -1
- package/types/popeditor.type.d.ts +5 -1
- package/types/popover.type.d.ts +3 -3
- package/types/progress.type.d.ts +3 -1
- package/types/radio.type.d.ts +0 -4
- package/types/rate.type.d.ts +236 -1
- package/types/search.type.d.ts +88 -1
- package/types/shared.type.d.ts +1 -1
- package/types/skeleton-item.type.d.ts +38 -0
- package/types/skeleton.type.d.ts +45 -0
- package/types/slider.type.d.ts +49 -10
- package/types/steps.type.d.ts +15 -4
- package/types/switch.type.d.ts +3 -3
- package/types/tab-bar.type.d.ts +1 -1
- package/types/tab-nav.type.d.ts +7 -2
- package/types/tabs.type.d.ts +9 -1
- package/types/tag-group.type.d.ts +64 -1
- package/types/{time-line.type-d7daa669.d.ts → time-line.type-b155cb4f.d.ts} +12 -0
- package/types/time-line.type.d.ts +1 -1
- package/types/timeline-item.type.d.ts +1 -1
- package/types/tooltip.type.d.ts +2 -2
- package/types/transfer.type.d.ts +185 -1
- package/types/tree-menu.type.d.ts +210 -1
- package/types/upload-dragger.type.d.ts +2 -2
- package/types/{upload-list.type-343e8c11.d.ts → upload-list.type-a29aea50.d.ts} +31 -8
- package/types/upload-list.type.d.ts +1 -1
- package/types/upload.type.d.ts +1 -1
- package/types/user-head.type.d.ts +146 -1
- package/types/wizard.type.d.ts +1 -0
- package/upload/index.js +64 -34
- package/upload/vue.js +9 -5
- package/upload-dragger/index.js +22 -20
- package/upload-list/index.js +24 -18
- package/upload-list/vue.js +9 -4
- package/user/index.js +34 -25
- package/user/vue.js +1 -1
- package/user-head/index.js +3 -3
- package/watermark/index.js +11 -0
- package/wheel/index.js +3 -0
- package/wizard/vue.js +4 -2
- package/common/deps/modal-queue.js +0 -6
- package/common/deps/requestAnimationFrame.js +0 -25
package/cascader-node/vue.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import "../chunk-G2ADBYYC.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
comptCheckPath,
|
|
4
|
+
handleExpand,
|
|
5
|
+
isInPath,
|
|
6
|
+
handleCheckChange,
|
|
7
|
+
handleMultiCheckChange,
|
|
8
|
+
handleNodeClick
|
|
9
|
+
} from "./index";
|
|
10
|
+
const api = ["state", "handleMultiCheckChange", "handleCheckChange", "handleExpand", "handleNodeClick"];
|
|
4
11
|
const renderless = (props, { computed, reactive, inject }, { dispatch }) => {
|
|
5
12
|
const parent = inject("panel");
|
|
6
13
|
const api2 = {};
|
|
@@ -12,7 +19,10 @@ const renderless = (props, { computed, reactive, inject }, { dispatch }) => {
|
|
|
12
19
|
isChecked: computed(() => props.node.isSameNode(state.checkedValue)),
|
|
13
20
|
inActivePath: computed(() => api2.isInPath(parent.state.activePath)),
|
|
14
21
|
inCheckedPath: computed(() => api2.comptCheckPath()),
|
|
15
|
-
value: computed(() => props.node.getValueByOption())
|
|
22
|
+
value: computed(() => props.node.getValueByOption()),
|
|
23
|
+
nodeLabel: computed(() => {
|
|
24
|
+
return parent.state.renderLabelFn ? parent.state.renderLabelFn({ node: props.node, data: props.node.data }) : props.node.label;
|
|
25
|
+
})
|
|
16
26
|
});
|
|
17
27
|
Object.assign(api2, {
|
|
18
28
|
state,
|
|
@@ -20,7 +30,8 @@ const renderless = (props, { computed, reactive, inject }, { dispatch }) => {
|
|
|
20
30
|
handleExpand: handleExpand({ api: api2, props, parent, state }),
|
|
21
31
|
comptCheckPath: comptCheckPath({ api: api2, parent, state }),
|
|
22
32
|
handleCheckChange: handleCheckChange({ api: api2, parent, dispatch, state }),
|
|
23
|
-
handleMultiCheckChange: handleMultiCheckChange({ parent, props })
|
|
33
|
+
handleMultiCheckChange: handleMultiCheckChange({ parent, props }),
|
|
34
|
+
handleNodeClick: handleNodeClick({ state, api: api2 })
|
|
24
35
|
});
|
|
25
36
|
return api2;
|
|
26
37
|
};
|
package/cascader-panel/index.js
CHANGED
|
@@ -223,7 +223,7 @@ const getCheckedNodes = ({ api, state }) => (leafOnly, cascaderCheckedValue) =>
|
|
|
223
223
|
const nodes = api.getFlattedNodes(leafOnly);
|
|
224
224
|
return nodes.filter((node2) => node2.checked && isCascaderChecked(node2.value, cascaderCheckedValue));
|
|
225
225
|
}
|
|
226
|
-
const node = api.getNodeByValue(state.checkedValue);
|
|
226
|
+
const node = api.getNodeByValue(cascaderCheckedValue || state.checkedValue);
|
|
227
227
|
return isEmpty(state.checkedValue) || !node ? [] : [node];
|
|
228
228
|
};
|
|
229
229
|
const clearCheckedNodes = ({ api, state }) => () => {
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import "../chunk-G2ADBYYC.js";
|
|
2
|
+
const DEFAULT_DURATION = 200;
|
|
3
|
+
const INERTIA_TIME = 300;
|
|
4
|
+
const INERTIA_DISTANCE = 15;
|
|
5
|
+
const preventDefault = (event, isStopPropagation) => {
|
|
6
|
+
if (typeof event.cancelable !== "boolean" || event.cancelable) {
|
|
7
|
+
event.preventDefault();
|
|
8
|
+
}
|
|
9
|
+
if (isStopPropagation) {
|
|
10
|
+
event.stopPropagation();
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
|
|
14
|
+
const pxCheck = (value) => {
|
|
15
|
+
return isNaN(Number(value)) ? String(value) : `${value}px`;
|
|
16
|
+
};
|
|
17
|
+
const stopMomentum = ({ state, api }) => () => {
|
|
18
|
+
state.moving = false;
|
|
19
|
+
state.touchTime = 0;
|
|
20
|
+
api.setChooseValue();
|
|
21
|
+
};
|
|
22
|
+
const setRollerStyle = ({ state }) => (index) => {
|
|
23
|
+
return `transform: rotate3d(1, 0, 0, ${-state.rotation * index}deg) translate3d(0px, 0px, 104px)`;
|
|
24
|
+
};
|
|
25
|
+
const onTouchStart = ({ state, props, touch, vm }) => (event) => {
|
|
26
|
+
touch.start(event);
|
|
27
|
+
if (state.moving) {
|
|
28
|
+
const dom = vm.$refs.roller;
|
|
29
|
+
const { transform } = window.getComputedStyle(dom);
|
|
30
|
+
if (props.threeDimensional) {
|
|
31
|
+
const circle = Math.floor(parseInt(state.touchDeg) / 360);
|
|
32
|
+
const cos = +transform.split(", ")[5];
|
|
33
|
+
const sin = +transform.split(", ")[6] < 0 ? 180 : 0;
|
|
34
|
+
const endDeg = circle * 360 + Math.acos(cos) / Math.PI * 180 + sin;
|
|
35
|
+
state.scrollDistance = -Math.abs((endDeg / state.rotation - 1) * +props.optionHeight);
|
|
36
|
+
} else {
|
|
37
|
+
state.scrollDistance = +transform.slice(7, transform.length - 1).split(", ")[5];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
preventDefault(event, true);
|
|
41
|
+
state.touchParams.startY = touch.deltaY.value;
|
|
42
|
+
state.touchParams.startTime = Date.now();
|
|
43
|
+
state.transformY = state.scrollDistance;
|
|
44
|
+
};
|
|
45
|
+
const onTouchMove = ({ state, api, touch }) => (event) => {
|
|
46
|
+
touch.move(event);
|
|
47
|
+
if (touch.isVertical()) {
|
|
48
|
+
state.moving = true;
|
|
49
|
+
preventDefault(event, true);
|
|
50
|
+
}
|
|
51
|
+
state.touchParams.lastY = touch.deltaY.value;
|
|
52
|
+
let move = state.touchParams.lastY - state.touchParams.startY;
|
|
53
|
+
api.setMove(move);
|
|
54
|
+
};
|
|
55
|
+
const onTouchEnd = ({ state, props, api, touch }) => () => {
|
|
56
|
+
state.touchParams.lastY = touch.deltaY.value;
|
|
57
|
+
state.touchParams.lastTime = Date.now();
|
|
58
|
+
let move = state.touchParams.lastY - state.touchParams.startY;
|
|
59
|
+
let moveTime = state.touchParams.lastTime - state.touchParams.startTime;
|
|
60
|
+
if (moveTime <= INERTIA_TIME && Math.abs(move) > INERTIA_DISTANCE) {
|
|
61
|
+
const distance = api.momentum(move, moveTime);
|
|
62
|
+
api.setMove(distance, "end", +props.swipeDuration);
|
|
63
|
+
return;
|
|
64
|
+
} else {
|
|
65
|
+
api.setMove(move, "end");
|
|
66
|
+
}
|
|
67
|
+
setTimeout(() => {
|
|
68
|
+
touch.reset();
|
|
69
|
+
state.moving = false;
|
|
70
|
+
}, 0);
|
|
71
|
+
};
|
|
72
|
+
const momentum = (distance, duration) => {
|
|
73
|
+
const speed = Math.abs(distance / duration);
|
|
74
|
+
distance = speed / 3e-3 * (distance < 0 ? -1 : 1);
|
|
75
|
+
return distance;
|
|
76
|
+
};
|
|
77
|
+
const isHidden = ({ state }) => (index) => {
|
|
78
|
+
if (index >= state.currIndex + 8 || index <= state.currIndex - 8) {
|
|
79
|
+
return true;
|
|
80
|
+
} else {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const setTransform = ({ state }) => (type, deg, translateY = 0, time = DEFAULT_DURATION) => {
|
|
85
|
+
if (type === "end") {
|
|
86
|
+
state.touchTime = time;
|
|
87
|
+
} else {
|
|
88
|
+
state.touchTime = 0;
|
|
89
|
+
}
|
|
90
|
+
state.touchDeg = deg;
|
|
91
|
+
state.scrollDistance = translateY;
|
|
92
|
+
};
|
|
93
|
+
const setMove = ({ state, props, api }) => (move, type, time) => {
|
|
94
|
+
const { optionHeight } = props;
|
|
95
|
+
let updateMove = move + state.transformY;
|
|
96
|
+
if (type === "end") {
|
|
97
|
+
if (updateMove > 0) {
|
|
98
|
+
updateMove = 0;
|
|
99
|
+
}
|
|
100
|
+
if (updateMove < -(props.column.length - 1) * +optionHeight) {
|
|
101
|
+
updateMove = -(props.column.length - 1) * +optionHeight;
|
|
102
|
+
}
|
|
103
|
+
let endMove = Math.round(updateMove / +optionHeight) * +optionHeight;
|
|
104
|
+
let deg = `${(Math.abs(Math.round(endMove / +optionHeight)) + 1) * state.rotation}deg`;
|
|
105
|
+
api.setTransform(type, deg, endMove, time);
|
|
106
|
+
state.currIndex = Math.abs(Math.round(endMove / +optionHeight)) + 1;
|
|
107
|
+
} else {
|
|
108
|
+
let deg = 0;
|
|
109
|
+
let currentDeg = (-updateMove / +optionHeight + 1) * state.rotation;
|
|
110
|
+
const maxDeg = (props.column.length + 1) * state.rotation;
|
|
111
|
+
const minDeg = 0;
|
|
112
|
+
deg = clamp(currentDeg, minDeg, maxDeg);
|
|
113
|
+
if (minDeg < deg && deg < maxDeg) {
|
|
114
|
+
api.setTransform(null, deg + "deg", updateMove, void 0);
|
|
115
|
+
state.currIndex = Math.abs(Math.round(updateMove / +optionHeight)) + 1;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
const setChooseValue = ({ props, state, emit }) => () => {
|
|
120
|
+
emit("change", props.column[state.currIndex - 1]);
|
|
121
|
+
};
|
|
122
|
+
const modifyStatus = ({ state, props, api }) => (type) => {
|
|
123
|
+
const { column } = props;
|
|
124
|
+
let index = column.findIndex((columnItem) => columnItem[props.fieldNames.value] === props.value);
|
|
125
|
+
state.currIndex = index === -1 ? 1 : index + 1;
|
|
126
|
+
let move = index === -1 ? 0 : index * +props.optionHeight;
|
|
127
|
+
type && api.setChooseValue();
|
|
128
|
+
api.setMove(-move);
|
|
129
|
+
};
|
|
130
|
+
const OptionStyle = ({ state }) => (option, column, offset) => {
|
|
131
|
+
const currentIndex = state.currIndex - 1;
|
|
132
|
+
return option === column[currentIndex + offset] || option === column[currentIndex - offset];
|
|
133
|
+
};
|
|
134
|
+
export {
|
|
135
|
+
OptionStyle,
|
|
136
|
+
clamp,
|
|
137
|
+
isHidden,
|
|
138
|
+
modifyStatus,
|
|
139
|
+
momentum,
|
|
140
|
+
onTouchEnd,
|
|
141
|
+
onTouchMove,
|
|
142
|
+
onTouchStart,
|
|
143
|
+
preventDefault,
|
|
144
|
+
pxCheck,
|
|
145
|
+
setChooseValue,
|
|
146
|
+
setMove,
|
|
147
|
+
setRollerStyle,
|
|
148
|
+
setTransform,
|
|
149
|
+
stopMomentum
|
|
150
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import "../chunk-G2ADBYYC.js";
|
|
2
|
+
import {
|
|
3
|
+
pxCheck,
|
|
4
|
+
stopMomentum,
|
|
5
|
+
setRollerStyle,
|
|
6
|
+
onTouchStart,
|
|
7
|
+
onTouchMove,
|
|
8
|
+
onTouchEnd,
|
|
9
|
+
momentum,
|
|
10
|
+
isHidden,
|
|
11
|
+
setTransform,
|
|
12
|
+
setMove,
|
|
13
|
+
setChooseValue,
|
|
14
|
+
modifyStatus,
|
|
15
|
+
OptionStyle
|
|
16
|
+
} from "./column-index";
|
|
17
|
+
import { useTouch } from "./useTouch";
|
|
18
|
+
const api = [
|
|
19
|
+
"state",
|
|
20
|
+
"touch",
|
|
21
|
+
"OptionStyle",
|
|
22
|
+
"setRollerStyle",
|
|
23
|
+
"isHidden",
|
|
24
|
+
"onTouchStart",
|
|
25
|
+
"onTouchMove",
|
|
26
|
+
"onTouchEnd",
|
|
27
|
+
"setMove",
|
|
28
|
+
"stopMomentum",
|
|
29
|
+
"pxCheck"
|
|
30
|
+
];
|
|
31
|
+
const renderless = (props, { reactive, computed, watch, ref, onMounted }, { emit, vm }) => {
|
|
32
|
+
const touch = useTouch({ ref });
|
|
33
|
+
const state = reactive({
|
|
34
|
+
touchParams: {
|
|
35
|
+
startY: 0,
|
|
36
|
+
endY: 0,
|
|
37
|
+
startTime: 0,
|
|
38
|
+
endTime: 0,
|
|
39
|
+
lastY: 0,
|
|
40
|
+
lastTime: 0
|
|
41
|
+
},
|
|
42
|
+
currIndex: 1,
|
|
43
|
+
transformY: 0,
|
|
44
|
+
scrollDistance: 0,
|
|
45
|
+
rotation: 20,
|
|
46
|
+
moving: false,
|
|
47
|
+
touchDeg: 0,
|
|
48
|
+
touchTime: 0,
|
|
49
|
+
currentValue: computed(() => props.column[state.currIndex - 1][props.fieldNames.value]),
|
|
50
|
+
touchTileStyle: computed(() => {
|
|
51
|
+
const { optionHeight } = props;
|
|
52
|
+
return {
|
|
53
|
+
transition: `transform ${state.touchTime}ms cubic-bezier(0.17, 0.89, 0.45, 1)`,
|
|
54
|
+
transform: `translate3d(0, ${state.scrollDistance}px, 0)`,
|
|
55
|
+
top: `calc(50% - ${+optionHeight / 2}px)`,
|
|
56
|
+
height: `${optionHeight}px`
|
|
57
|
+
};
|
|
58
|
+
}),
|
|
59
|
+
touchRollerStyle: computed(() => {
|
|
60
|
+
return {
|
|
61
|
+
transition: `transform ${state.touchTime}ms cubic-bezier(0.17, 0.89, 0.45, 1)`,
|
|
62
|
+
transform: `rotate3d(1, 0, 0, ${state.touchDeg})`,
|
|
63
|
+
top: `calc(50% - ${+props.optionHeight / 2}px)`
|
|
64
|
+
};
|
|
65
|
+
}),
|
|
66
|
+
maskStyles: computed(() => {
|
|
67
|
+
return {
|
|
68
|
+
backgroundSize: `100% ${(+props.visibleOptionNum - 1) * +props.optionHeight / 2}px`
|
|
69
|
+
};
|
|
70
|
+
})
|
|
71
|
+
});
|
|
72
|
+
const api2 = {};
|
|
73
|
+
Object.assign(api2, {
|
|
74
|
+
state,
|
|
75
|
+
touch,
|
|
76
|
+
OptionStyle: OptionStyle({ state }),
|
|
77
|
+
setRollerStyle: setRollerStyle({ state }),
|
|
78
|
+
isHidden: isHidden({ state }),
|
|
79
|
+
onTouchStart: onTouchStart({ state, props, touch, vm }),
|
|
80
|
+
onTouchMove: onTouchMove({ state, api: api2, touch }),
|
|
81
|
+
onTouchEnd: onTouchEnd({ state, props, api: api2, touch }),
|
|
82
|
+
setMove: setMove({ state, props, api: api2 }),
|
|
83
|
+
stopMomentum: stopMomentum({ state, api: api2 }),
|
|
84
|
+
setTransform: setTransform({ state }),
|
|
85
|
+
setChooseValue: setChooseValue({ props, state, emit }),
|
|
86
|
+
modifyStatus: modifyStatus({ state, props, api: api2 }),
|
|
87
|
+
pxCheck,
|
|
88
|
+
momentum
|
|
89
|
+
});
|
|
90
|
+
watch(
|
|
91
|
+
() => props.column,
|
|
92
|
+
() => {
|
|
93
|
+
if (props.column && props.column.length > 0) {
|
|
94
|
+
state.transformY = 0;
|
|
95
|
+
api2.modifyStatus(false);
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
deep: true
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
watch(
|
|
103
|
+
() => props.value,
|
|
104
|
+
() => {
|
|
105
|
+
state.transformY = 0;
|
|
106
|
+
api2.modifyStatus(false);
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
deep: true
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
onMounted(() => {
|
|
113
|
+
api2.modifyStatus(false);
|
|
114
|
+
});
|
|
115
|
+
return api2;
|
|
116
|
+
};
|
|
117
|
+
export {
|
|
118
|
+
api,
|
|
119
|
+
renderless
|
|
120
|
+
};
|
package/cascader-select/index.js
CHANGED
|
@@ -1,179 +1,43 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
__spreadValues
|
|
4
|
-
} from "../chunk-G2ADBYYC.js";
|
|
5
|
-
const normalRange = (value, min, max) => value < min ? min : value > max ? max : value;
|
|
6
|
-
const sliceValue = (value, min, max, count, cycleRoll) => {
|
|
7
|
-
value = normalRange(value, min, max);
|
|
8
|
-
const values = [value];
|
|
9
|
-
const tmpArr = Array.from({ length: rightShift(count) });
|
|
10
|
-
const prev = () => cycleRoll ? tVal + max - min + 1 : null;
|
|
11
|
-
const next = () => cycleRoll ? tVal - max + min - 1 : null;
|
|
12
|
-
let tVal;
|
|
13
|
-
tmpArr.map((v, i) => values.unshift((tVal = value - i - 1) < min ? prev() : tVal));
|
|
14
|
-
tmpArr.map((v, i) => values.push((tVal = value + i + 1) > max ? next() : tVal));
|
|
15
|
-
return values;
|
|
16
|
-
};
|
|
17
|
-
const validArr = (arr) => Array.isArray(arr) && arr.length;
|
|
18
|
-
const validProps = (props) => {
|
|
19
|
-
const { modelValue, options } = props;
|
|
20
|
-
return validArr(modelValue) && validArr(options) && modelValue.length === options.length;
|
|
21
|
-
};
|
|
22
|
-
const rightShift = (count) => count >>> 1;
|
|
23
|
-
const getFont = (pos, count) => Math.abs(rightShift(count) + 1 - pos);
|
|
24
|
-
const parseType = (props) => (values) => {
|
|
25
|
-
const { valueType } = props;
|
|
26
|
-
return values.map(valueType === "number" ? Number : valueType === "string" ? String : (i) => i);
|
|
27
|
-
};
|
|
28
|
-
const init = ({ api, props, state }) => (valuesCopy) => {
|
|
29
|
-
if (!validProps(props))
|
|
30
|
-
return;
|
|
31
|
-
const { modelValue, options, cycleRoll, valueField, textField } = props;
|
|
32
|
-
const { visibleOptionCount } = state;
|
|
33
|
-
let { disabled } = props;
|
|
34
|
-
disabled = typeof disabled === "function" ? disabled : () => false;
|
|
35
|
-
const values = api.parseType(valuesCopy || modelValue.slice(0));
|
|
36
|
-
const types = Array.from({ length: values.length });
|
|
37
|
-
const ranges = Array.from({ length: values.length });
|
|
38
|
-
const indices = Array.from({ length: values.length });
|
|
39
|
-
const visibleOptions = options.map((opt, i) => {
|
|
40
|
-
let slicedValues, existOption;
|
|
41
|
-
if (Array.isArray(opt)) {
|
|
42
|
-
if (opt.length === 0)
|
|
43
|
-
return [];
|
|
44
|
-
let index = opt.findIndex((item) => item[valueField] === values[i]);
|
|
45
|
-
index = index === -1 ? 0 : index;
|
|
46
|
-
types[i] = "a";
|
|
47
|
-
ranges[i] = [0, opt.length - 1];
|
|
48
|
-
indices[i] = index;
|
|
49
|
-
slicedValues = sliceValue(index, 0, opt.length - 1, visibleOptionCount, cycleRoll);
|
|
50
|
-
existOption = (i2) => __spreadProps(__spreadValues({}, opt[i2]), { disabled: disabled(opt[i2][valueField], ...values) });
|
|
51
|
-
} else if (opt && typeof opt === "object") {
|
|
52
|
-
let range;
|
|
53
|
-
if (Array.isArray(opt.range)) {
|
|
54
|
-
range = opt.range.slice(0, 2);
|
|
55
|
-
} else if (typeof opt.rangeMethod === "function") {
|
|
56
|
-
range = opt.rangeMethod(...values);
|
|
57
|
-
}
|
|
58
|
-
types[i] = "o";
|
|
59
|
-
ranges[i] = api.parseType(range);
|
|
60
|
-
slicedValues = sliceValue(values[i], ranges[i][0], ranges[i][1], visibleOptionCount, cycleRoll);
|
|
61
|
-
existOption = (i2) => opt.optionMethod(i2, ...values);
|
|
62
|
-
}
|
|
63
|
-
if (!slicedValues || !existOption)
|
|
64
|
-
return [];
|
|
65
|
-
return slicedValues.map((slicedValue, i2) => {
|
|
66
|
-
const option = slicedValue === null ? { [valueField]: null, [textField]: "" } : existOption(slicedValue);
|
|
67
|
-
option._$font = getFont(i2 + 1, visibleOptionCount);
|
|
68
|
-
option._$status = option.disabled ? "disabled" : option._$font === 0 ? "focus" : "normal";
|
|
69
|
-
return option;
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
state.selectorCount = values.length;
|
|
73
|
-
values.map((value, i) => {
|
|
74
|
-
const index = indices[i];
|
|
75
|
-
const opts = options[i];
|
|
76
|
-
const vOpts = visibleOptions[i];
|
|
77
|
-
state[`selector${i}`] = { index, options: opts, ranges, types, value, values, visibleOptions: vOpts };
|
|
78
|
-
});
|
|
79
|
-
};
|
|
80
|
-
const calcSelector = (api) => (cycleRoll, dy, pos, selector, valueField) => {
|
|
81
|
-
const { index, options, ranges, types, value, values } = selector;
|
|
82
|
-
const valuesCopy = values.slice(0);
|
|
83
|
-
const sRange = ranges[pos];
|
|
84
|
-
const sType = types[pos];
|
|
85
|
-
let sVal = sType === "o" ? value : sType === "a" ? index : null;
|
|
86
|
-
const f = (arr) => arr[0];
|
|
87
|
-
const l = (arr) => arr[arr.length - 1];
|
|
88
|
-
const noop = () => sVal;
|
|
89
|
-
const prev = () => cycleRoll && sVal === f(sRange) ? l(sRange) : sVal - 1;
|
|
90
|
-
const next = () => cycleRoll && sVal === l(sRange) ? f(sRange) : sVal + 1;
|
|
91
|
-
sVal = dy > 0 ? prev() : dy < 0 ? next() : noop();
|
|
92
|
-
sVal = normalRange(sVal, ...sRange);
|
|
93
|
-
if (sType === "a") {
|
|
94
|
-
sVal = options[sVal][valueField];
|
|
95
|
-
}
|
|
96
|
-
if (sVal !== value) {
|
|
97
|
-
valuesCopy.splice(pos, 1, sVal);
|
|
98
|
-
api.init(valuesCopy);
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
const handleTouchstart = (state) => (e) => {
|
|
102
|
-
const { clientY } = e.changedTouches[0];
|
|
103
|
-
state.touching = true;
|
|
104
|
-
state.touchStartPos = state.touchPos = { clientY };
|
|
105
|
-
state.accrueDy = 0;
|
|
106
|
-
};
|
|
107
|
-
const handleTouchend = (state) => () => {
|
|
108
|
-
state.touching = false;
|
|
109
|
-
state.touchStartPos = state.touchPos = {};
|
|
110
|
-
state.accrueDy = 0;
|
|
111
|
-
};
|
|
112
|
-
const handleTouchmove = ({ api, props, state }) => (e, pos) => {
|
|
113
|
-
if (!state.touching)
|
|
114
|
-
return;
|
|
115
|
-
const { cycleRoll, valueField } = props;
|
|
116
|
-
const { touchPos, optionHeight } = state;
|
|
117
|
-
const { clientY } = e.changedTouches[0];
|
|
118
|
-
const dy = clientY - touchPos.clientY;
|
|
119
|
-
state.touchPos = { clientY };
|
|
120
|
-
state.accrueDy += dy;
|
|
121
|
-
const absDy = Math.abs(state.accrueDy);
|
|
122
|
-
const threshold = optionHeight / 4;
|
|
123
|
-
if (absDy > threshold) {
|
|
124
|
-
const selector = state[`selector${pos}`];
|
|
125
|
-
api.calcSelector(cycleRoll, state.accrueDy, pos, selector, valueField);
|
|
126
|
-
state.accrueDy = 0;
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
const watchActionSheetVisible = ({ emit, state, vm }) => (visible) => {
|
|
1
|
+
import "../chunk-G2ADBYYC.js";
|
|
2
|
+
const watchActionSheetVisible = ({ emit, api, props }) => (visible) => {
|
|
130
3
|
emit("update:visible", visible);
|
|
131
4
|
if (!visible)
|
|
132
5
|
return;
|
|
133
|
-
|
|
134
|
-
const optionRef = vm.$el.querySelector('[data-tag="tiny-mobile-cs-option"]');
|
|
135
|
-
optionRef && (state.optionHeight = optionRef.offsetHeight);
|
|
136
|
-
});
|
|
6
|
+
api.setValue(props.modelValue);
|
|
137
7
|
};
|
|
138
8
|
const close = (state) => () => state.actionSheetVisible && (state.actionSheetVisible = false);
|
|
139
|
-
const confirm = ({ api, emit,
|
|
140
|
-
|
|
141
|
-
if (confirmDisabled)
|
|
9
|
+
const confirm = ({ api, emit, defaultValues, selectedOptions, isDisabled, vm }) => () => {
|
|
10
|
+
if (isDisabled.value)
|
|
142
11
|
return;
|
|
143
|
-
|
|
144
|
-
let
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
focusOpts = [...focusOpts];
|
|
148
|
-
values = focusOpts.map((focusOpt) => focusOpt.dataset.option);
|
|
149
|
-
values = api.parseType(values);
|
|
150
|
-
}
|
|
151
|
-
if (validArr(values) && validArr(modelValue) && values.length === modelValue.length && values.join() !== modelValue.join()) {
|
|
152
|
-
emit("update:modelValue", values);
|
|
12
|
+
let refs = vm.$refs.swipeRef;
|
|
13
|
+
let moving = false;
|
|
14
|
+
if (!Array.isArray(vm.$refs.swipeRef)) {
|
|
15
|
+
refs = [refs];
|
|
153
16
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
const { selectorCount, visibleOptionCount } = state;
|
|
160
|
-
const interOpts = Array.from({ length: selectorCount }).map((v, i) => {
|
|
161
|
-
const vOpts = state[`selector${i}`].visibleOptions;
|
|
162
|
-
return vOpts[rightShift(visibleOptionCount)];
|
|
17
|
+
defaultValues.value = refs.map((comp) => {
|
|
18
|
+
if (comp.state.moving) {
|
|
19
|
+
moving = true;
|
|
20
|
+
}
|
|
21
|
+
return comp.state.currentValue;
|
|
163
22
|
});
|
|
164
|
-
|
|
23
|
+
if (moving)
|
|
24
|
+
return;
|
|
25
|
+
emit("confirm", {
|
|
26
|
+
selectedValue: defaultValues.value.slice(),
|
|
27
|
+
selectedOptions: selectedOptions.value.slice()
|
|
28
|
+
});
|
|
29
|
+
emit("update:modelValue", defaultValues.value.slice());
|
|
30
|
+
api.close();
|
|
165
31
|
};
|
|
32
|
+
const columnStyle = ({ props, computed }) => computed(() => {
|
|
33
|
+
return {
|
|
34
|
+
height: `${+props.visibleOptionNum * +props.optionHeight}px`,
|
|
35
|
+
"--lineHeight": `${+props.optionHeight}px`
|
|
36
|
+
};
|
|
37
|
+
});
|
|
166
38
|
export {
|
|
167
|
-
calcSelector,
|
|
168
39
|
close,
|
|
169
|
-
|
|
40
|
+
columnStyle,
|
|
170
41
|
confirm,
|
|
171
|
-
handleTouchend,
|
|
172
|
-
handleTouchmove,
|
|
173
|
-
handleTouchstart,
|
|
174
|
-
init,
|
|
175
|
-
parseType,
|
|
176
|
-
statusOpt,
|
|
177
|
-
styleOpt,
|
|
178
42
|
watchActionSheetVisible
|
|
179
43
|
};
|