@opentiny/vue-renderless 3.12.0 → 3.13.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 +20 -13
- package/action-sheet/vue.js +8 -7
- package/alert/index.js +50 -1
- package/alert/vue.js +36 -9
- 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 +20 -6
- package/calendar-view/index.js +10 -12
- package/calendar-view/vue.js +17 -4
- package/cascader/index.js +80 -34
- package/cascader/vue.js +49 -19
- package/cascader-menu/index.js +7 -7
- package/cascader-menu/vue.js +2 -3
- package/cascader-mobile/index.js +37 -24
- package/cascader-mobile/vue.js +7 -1
- 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/cascader-view/index.js +1 -1
- 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 +17 -0
- package/checkbox/vue.js +16 -7
- package/checkbox-group/vue.js +2 -0
- package/col/index.js +7 -2
- 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 +2 -0
- package/common/deps/dom.js +19 -4
- package/common/deps/popper.js +48 -5
- package/common/deps/touch-emulator.js +4 -1
- package/common/deps/tree-model/node.js +1 -1
- package/common/deps/tree-model/tree-store.js +2 -13
- package/common/deps/useRect.js +25 -0
- package/common/deps/vue-popper.js +22 -10
- package/common/index.js +1 -1
- package/common/runtime.js +1 -1
- 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/container/index.js +17 -1
- package/container/vue.js +12 -3
- 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 +12 -5
- package/date-table/index.js +5 -0
- package/date-table/vue.js +3 -1
- package/dialog-box/index.js +17 -6
- package/dialog-select/index.js +6 -3
- package/dialog-select/vue.js +8 -4
- package/drawer/index.js +26 -5
- package/drawer/vue.js +13 -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 +21 -8
- 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 +47 -12
- package/file-upload/vue.js +38 -8
- package/filter-box/index.js +1 -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 +3 -1
- package/form-item/index.js +4 -4
- package/form-item/vue.js +3 -1
- package/fullscreen/index.js +5 -5
- package/fullscreen/vue.js +3 -3
- package/grid/utils/common.js +10 -5
- package/grid/utils/dom.js +7 -1
- package/image/index.js +6 -0
- package/image/vue.js +6 -3
- package/image-viewer/index.js +62 -51
- package/image-viewer/vue.js +17 -5
- package/input/index.js +89 -22
- package/input/vue.js +52 -21
- package/ip-address/index.js +61 -19
- package/ip-address/vue.js +22 -4
- package/label/index.js +56 -0
- package/label/vue.js +26 -0
- package/link/vue.js +3 -1
- package/loading/vue.js +8 -2
- package/logout/index.js +1 -1
- package/mask/index.js +13 -0
- package/mask/vue.js +18 -0
- package/mind-map/index.js +47 -0
- package/mind-map/vue.js +53 -0
- package/multi-select/index.js +150 -10
- package/multi-select/vue.js +46 -11
- package/multi-select-item/index.js +17 -0
- package/multi-select-item/vue.js +31 -0
- package/numeric/index.js +51 -9
- package/numeric/vue.js +44 -14
- package/option/index.js +12 -5
- package/option/vue.js +15 -7
- package/option-group/index.js +3 -3
- package/package.json +1 -1
- package/pager/index.js +372 -0
- package/pager/vue.js +125 -2
- package/picker/index.js +253 -48
- package/picker/mb.js +42 -0
- package/picker/vue.js +70 -17
- package/picker-column/index.js +1 -1
- package/pop-upload/index.js +0 -2
- package/pop-upload/vue.js +3 -4
- package/popconfirm/index.js +3 -6
- package/popconfirm/vue.js +1 -1
- package/popeditor/index.js +55 -24
- 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 +57 -65
- package/pull-refresh/vue.js +23 -7
- 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-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 +1 -1
- package/search/vue.js +3 -1
- package/select/index.js +185 -113
- package/select/vue.js +105 -20
- package/select-dropdown/index.js +62 -4
- package/select-dropdown/vue.js +85 -8
- package/select-view/index.js +3 -1
- 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 +27 -7
- package/slider/vue.js +26 -7
- package/split/index.js +1 -1
- 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 +9 -4
- package/tab-nav/vue.js +6 -2
- package/tabbar/vue.js +9 -3
- package/tabbar-item/vue.js +3 -2
- package/tabs/index.js +1 -1
- package/tabs/vue.js +1 -0
- package/tabs-mf/index.js +20 -6
- package/tabs-mf/vue-nav.js +26 -11
- package/tabs-mf/vue.js +7 -7
- package/tag/index.js +1 -1
- package/tag/vue.js +5 -1
- package/tag-group/index.js +2 -1
- package/tall-storage/index.js +4 -5
- package/time/index.js +4 -1
- package/time/vue.js +1 -1
- package/time-line/vue.js +1 -1
- package/time-picker-mobile/index.js +24 -5
- package/time-picker-mobile/vue.js +17 -7
- package/time-range/index.js +2 -0
- package/time-spinner/index.js +0 -3
- package/time-spinner/vue.js +2 -3
- package/timeline-item/vue.js +1 -1
- package/tooltip/index.js +1 -2
- package/tooltip/vue.js +3 -3
- 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 +27 -3
- package/tree-menu/vue.js +27 -14
- package/tree-node/index.js +12 -10
- package/tree-node/vue.js +6 -5
- package/types/action-menu.type.d.ts +5 -0
- package/types/action-sheet.type.d.ts +118 -1
- package/types/alert.type.d.ts +16 -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.type.d.ts +5 -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 +327 -1
- package/types/checkbox.type.d.ts +9 -0
- package/types/collapse.type.d.ts +19 -2
- package/types/date-picker.type.d.ts +33 -0
- package/types/dialog-box.type.d.ts +5 -1
- package/types/drawer.type.d.ts +132 -1
- package/types/{dropdown-item.type-bf83e929.d.ts → dropdown-item.type-8475a549.d.ts} +8 -14
- package/types/dropdown-item.type.d.ts +1 -1
- package/types/dropdown-menu.type.d.ts +1 -1
- package/types/dropdown.type.d.ts +2 -5
- package/types/fall-menu.type.d.ts +94 -1
- package/types/file-upload.type.d.ts +1 -1
- package/types/form-item.type.d.ts +1 -1
- package/types/{form.type-d0fd42f3.d.ts → form.type-d88482e4.d.ts} +3 -0
- package/types/form.type.d.ts +1 -1
- package/types/input.type.d.ts +23 -9
- package/types/ip-address.type.d.ts +160 -1
- package/types/label.type.d.ts +81 -0
- package/types/link.type.d.ts +6 -3
- package/types/mind-map.type.d.ts +20 -0
- package/types/modal.type.d.ts +4 -2
- package/types/numeric.type.d.ts +36 -9
- package/types/pager.type.d.ts +171 -1
- package/types/picker.type.d.ts +14 -0
- package/types/popconfirm.type.d.ts +85 -1
- package/types/popeditor.type.d.ts +4 -0
- package/types/popover.type.d.ts +3 -3
- 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 +8 -1
- package/types/steps.type.d.ts +14 -3
- package/types/tab-item.type.d.ts +0 -1
- package/types/tab-nav.type.d.ts +6 -1
- package/types/tabs.type.d.ts +5 -0
- package/types/tag-group.type.d.ts +64 -1
- package/types/tag.type.d.ts +12 -0
- package/types/tooltip.type.d.ts +1 -1
- package/types/transfer.type.d.ts +183 -1
- package/types/tree-menu.type.d.ts +210 -1
- package/types/upload-dragger.type.d.ts +1 -1
- package/types/{upload-list.type-343e8c11.d.ts → upload-list.type-1078fba2.d.ts} +27 -6
- package/types/upload-list.type.d.ts +1 -1
- package/types/upload.type.d.ts +1 -1
- package/types/wizard.type.d.ts +1 -0
- package/upload/index.js +59 -29
- package/upload/vue.js +6 -4
- package/upload-list/index.js +14 -14
- package/upload-list/vue.js +5 -2
- package/user/index.js +5 -4
- package/user-head/index.js +1 -1
- package/wheel/index.js +3 -0
- package/wizard/vue.js +4 -2
package/cascader-mobile/index.js
CHANGED
|
@@ -6,16 +6,13 @@ const close = ({ state, emit }) => () => {
|
|
|
6
6
|
emit("close", false);
|
|
7
7
|
};
|
|
8
8
|
const syncCheckStatus = ({ state, props, api }) => (value) => {
|
|
9
|
-
const { valueField, textField, modelValue: propsModelValue
|
|
9
|
+
const { valueField, textField, modelValue: propsModelValue } = props;
|
|
10
10
|
const { lazy, isLeaf: leafField } = api.getNodeConfig();
|
|
11
11
|
let currentData;
|
|
12
12
|
let navList = [];
|
|
13
13
|
let modelValue = value || propsModelValue || [];
|
|
14
14
|
let len = modelValue.length;
|
|
15
15
|
let isLeaf;
|
|
16
|
-
if (!visible) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
16
|
for (let i = 0; i < len; i++) {
|
|
20
17
|
const id = modelValue[i];
|
|
21
18
|
currentData = state.store.getNode(id);
|
|
@@ -42,7 +39,6 @@ const watchVisible = ({ emit, state, props, api }) => (visible) => {
|
|
|
42
39
|
const { modelValue } = props;
|
|
43
40
|
if (visible) {
|
|
44
41
|
api.watchModelValue(modelValue);
|
|
45
|
-
api.initTreeStore();
|
|
46
42
|
}
|
|
47
43
|
setTimeout(() => {
|
|
48
44
|
state.toggle = visible;
|
|
@@ -78,7 +74,7 @@ const selectOption = ({ emit, state, props, api }) => (option) => {
|
|
|
78
74
|
option.loading = false;
|
|
79
75
|
state.loading = false;
|
|
80
76
|
option.loaded = true;
|
|
81
|
-
nodes.
|
|
77
|
+
nodes.forEach((data) => {
|
|
82
78
|
state.store.append(data, option.data);
|
|
83
79
|
index = waitLoadList.indexOf(data[valueField]);
|
|
84
80
|
if (index !== -1) {
|
|
@@ -115,19 +111,35 @@ const loopSearchOption = ({
|
|
|
115
111
|
textField,
|
|
116
112
|
prefixValue,
|
|
117
113
|
prefixText,
|
|
118
|
-
textSplit = "/"
|
|
114
|
+
textSplit = "/",
|
|
115
|
+
filterMethod,
|
|
116
|
+
level,
|
|
117
|
+
checkStrictly
|
|
119
118
|
}) => {
|
|
120
119
|
const list = [];
|
|
121
120
|
options.forEach((item) => {
|
|
121
|
+
if (item.disabled) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
122
124
|
const text = item[textField];
|
|
123
125
|
const textNavStr = prefixText ? prefixText + textSplit + text : text;
|
|
124
126
|
const value = [...prefixValue, item[valueField]];
|
|
125
127
|
const children = item[childrenField];
|
|
126
|
-
if (
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
if (checkStrictly === true || !children || children.length === 0) {
|
|
129
|
+
if (typeof filterMethod === "function") {
|
|
130
|
+
const matched = filterMethod({ data: item, label: item.label, value: item.value, level }, input);
|
|
131
|
+
if (matched) {
|
|
132
|
+
list.push({
|
|
133
|
+
[valueField]: value,
|
|
134
|
+
[textField]: textNavStr
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
} else if (text.includes(input)) {
|
|
138
|
+
list.push({
|
|
139
|
+
[valueField]: value,
|
|
140
|
+
[textField]: textNavStr
|
|
141
|
+
});
|
|
142
|
+
}
|
|
131
143
|
}
|
|
132
144
|
if (children && children.length) {
|
|
133
145
|
const arr = loopSearchOption({
|
|
@@ -138,7 +150,10 @@ const loopSearchOption = ({
|
|
|
138
150
|
textField,
|
|
139
151
|
prefixValue: value,
|
|
140
152
|
prefixText: textNavStr,
|
|
141
|
-
textSplit
|
|
153
|
+
textSplit,
|
|
154
|
+
filterMethod,
|
|
155
|
+
level: level + 1,
|
|
156
|
+
checkStrictly
|
|
142
157
|
});
|
|
143
158
|
list.push(...arr);
|
|
144
159
|
}
|
|
@@ -160,7 +175,10 @@ const searchMethod = ({ state, props, api }) => () => {
|
|
|
160
175
|
valueField,
|
|
161
176
|
textField,
|
|
162
177
|
prefixValue: [],
|
|
163
|
-
prefixText: ""
|
|
178
|
+
prefixText: "",
|
|
179
|
+
filterMethod: searchConfig.filterMethod,
|
|
180
|
+
level: 0,
|
|
181
|
+
checkStrictly: props.nodeConfig.checkStrictly
|
|
164
182
|
});
|
|
165
183
|
}
|
|
166
184
|
if (typeof list.then === "function") {
|
|
@@ -169,12 +187,12 @@ const searchMethod = ({ state, props, api }) => () => {
|
|
|
169
187
|
state.search.filterOptions = list;
|
|
170
188
|
}
|
|
171
189
|
};
|
|
172
|
-
const searchBoxToggle = ({ state, props, api }) => (
|
|
190
|
+
const searchBoxToggle = ({ state, props, api }) => (isShow) => {
|
|
173
191
|
const { searchConfig = {} } = props;
|
|
174
192
|
const { lazy } = api.getNodeConfig();
|
|
175
|
-
state.search.show =
|
|
193
|
+
state.search.show = isShow;
|
|
176
194
|
state.search.input = "";
|
|
177
|
-
if (
|
|
195
|
+
if (isShow) {
|
|
178
196
|
state.search.options = !lazy && searchConfig.options && searchConfig.options.length ? searchConfig.options : state.store.getAllData();
|
|
179
197
|
api.searchMethod();
|
|
180
198
|
}
|
|
@@ -198,8 +216,7 @@ const created = ({ api }) => () => {
|
|
|
198
216
|
api.initTreeStore();
|
|
199
217
|
};
|
|
200
218
|
const loadData = ({ props, state }) => (data) => {
|
|
201
|
-
|
|
202
|
-
if (!visible) {
|
|
219
|
+
if (!props.visible) {
|
|
203
220
|
return;
|
|
204
221
|
}
|
|
205
222
|
state.store.setData(data);
|
|
@@ -230,7 +247,7 @@ const getNodeConfig = ({ constants, props }) => () => {
|
|
|
230
247
|
return Object.assign({ nodeKey: valueField }, constants.defaultNodeConfig, nodeConfig);
|
|
231
248
|
};
|
|
232
249
|
const initTreeStore = ({ props, state, api }) => () => {
|
|
233
|
-
const { data, textField
|
|
250
|
+
const { data, textField } = props;
|
|
234
251
|
const {
|
|
235
252
|
nodeKey,
|
|
236
253
|
lazy,
|
|
@@ -247,10 +264,6 @@ const initTreeStore = ({ props, state, api }) => () => {
|
|
|
247
264
|
defaultExpandAll,
|
|
248
265
|
filterNodeMethod
|
|
249
266
|
} = api.getNodeConfig();
|
|
250
|
-
if (!visible || state.store) {
|
|
251
|
-
api.syncCheckStatus();
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
267
|
state.store = new TreeStore({
|
|
255
268
|
key: nodeKey,
|
|
256
269
|
data,
|
package/cascader-mobile/vue.js
CHANGED
|
@@ -53,7 +53,7 @@ const renderless = (props, { computed, reactive, watch }, { emit, constants }) =
|
|
|
53
53
|
options: computed(() => {
|
|
54
54
|
let arr;
|
|
55
55
|
let list = [state.rootData];
|
|
56
|
-
state.navList.
|
|
56
|
+
state.navList.forEach((option) => {
|
|
57
57
|
arr = option.childNodes;
|
|
58
58
|
arr && arr.length && list.push(arr);
|
|
59
59
|
});
|
|
@@ -67,6 +67,11 @@ const renderless = (props, { computed, reactive, watch }, { emit, constants }) =
|
|
|
67
67
|
computedNavList: computed(() => api2.computedNavListHandler()),
|
|
68
68
|
showButton: computed(() => {
|
|
69
69
|
const len = state.navList.length;
|
|
70
|
+
if (!props.nodeConfig.checkStrictly) {
|
|
71
|
+
if (state.level < len - 1) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
70
75
|
return len && (props.nodeConfig.checkStrictly || state.navList[len - 1].isLeaf);
|
|
71
76
|
})
|
|
72
77
|
});
|
|
@@ -92,6 +97,7 @@ const renderless = (props, { computed, reactive, watch }, { emit, constants }) =
|
|
|
92
97
|
isSelected: isSelected({ state, api: api2, props })
|
|
93
98
|
});
|
|
94
99
|
api2.created();
|
|
100
|
+
api2.syncCheckStatus();
|
|
95
101
|
watch(() => props.visible, api2.watchVisible);
|
|
96
102
|
watch(() => props.modelValue, api2.watchModelValue, { immediate: true, deep: true });
|
|
97
103
|
watch(() => props.data, api2.loadData, { deep: true });
|
package/cascader-node/index.js
CHANGED
|
@@ -15,9 +15,11 @@ const handleExpand = ({ api, parent, props, state }) => () => {
|
|
|
15
15
|
if (!state.isLeaf) {
|
|
16
16
|
api.handleExpand();
|
|
17
17
|
}
|
|
18
|
-
if (multiple) {
|
|
18
|
+
if (multiple && state.isLeaf) {
|
|
19
19
|
const checked = state.isLeaf ? props.node.checked : false;
|
|
20
20
|
api.handleMultiCheckChange(Boolean(checked));
|
|
21
|
+
} else {
|
|
22
|
+
parent.handleExpand(props.node);
|
|
21
23
|
}
|
|
22
24
|
});
|
|
23
25
|
} else {
|
|
@@ -37,10 +39,20 @@ const isInPath = (props) => (pathNodes) => {
|
|
|
37
39
|
const selectedPathNode = pathNodes[props.node.level - 1] || {};
|
|
38
40
|
return selectedPathNode.uid === props.node.uid;
|
|
39
41
|
};
|
|
42
|
+
const handleNodeClick = ({ state, api }) => () => {
|
|
43
|
+
if (!state.isDisabled) {
|
|
44
|
+
if (state.isLeaf) {
|
|
45
|
+
api.handleCheckChange();
|
|
46
|
+
} else {
|
|
47
|
+
api.handleExpand();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
40
51
|
export {
|
|
41
52
|
comptCheckPath,
|
|
42
53
|
handleCheckChange,
|
|
43
54
|
handleExpand,
|
|
44
55
|
handleMultiCheckChange,
|
|
56
|
+
handleNodeClick,
|
|
45
57
|
isInPath
|
|
46
58
|
};
|
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
|
+
};
|