@nutui/nutui 3.1.18-beta.0 → 3.1.19-beta.1
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/CHANGELOG.md +41 -0
- package/LICENSE +1 -1
- package/README.md +6 -0
- package/dist/nutui.d.ts +39 -36
- package/dist/nutui.es.js +13149 -11288
- package/dist/nutui.umd.js +13156 -11381
- package/dist/packages/_es/ActionSheet.js +13 -19
- package/dist/packages/_es/Address.js +70 -55
- package/dist/packages/_es/Audio.js +13 -13
- package/dist/packages/_es/AudioOperate.js +125 -0
- package/dist/packages/_es/Avatar.js +4 -4
- package/dist/packages/_es/BackTop.js +69 -108
- package/dist/packages/_es/Badge.js +4 -4
- package/dist/packages/_es/Barrage.js +63 -56
- package/dist/packages/_es/Button.js +3 -3
- package/dist/packages/_es/Calendar.js +30 -702
- package/dist/packages/_es/CalendarItem.js +10 -0
- package/dist/packages/_es/Card.js +7 -6
- package/dist/packages/_es/Cascader.js +8 -8
- package/dist/packages/_es/Cell.js +27 -27
- package/dist/packages/_es/CellGroup.js +2 -2
- package/dist/packages/_es/Checkbox.js +4 -4
- package/dist/packages/_es/CheckboxGroup.js +3 -3
- package/dist/packages/_es/CircleProgress.js +150 -41
- package/dist/packages/_es/Col.js +2 -2
- package/dist/packages/_es/Collapse.js +35 -9
- package/dist/packages/_es/CollapseItem.js +79 -38
- package/dist/packages/_es/CountDown.js +8 -6
- package/dist/packages/_es/CountUp.js +31 -30
- package/dist/packages/_es/DatePicker.js +81 -44
- package/dist/packages/_es/Dialog.js +7 -83
- package/dist/packages/_es/Divider.js +5 -5
- package/dist/packages/_es/Drag.js +93 -55
- package/dist/packages/_es/Elevator.js +75 -50
- package/dist/packages/_es/Empty.js +4 -4
- package/dist/packages/_es/FixedNav.js +6 -6
- package/dist/packages/_es/Form.js +11 -9
- package/dist/packages/_es/FormItem.js +9 -6
- package/dist/packages/_es/Grid.js +2 -2
- package/dist/packages/_es/GridItem.js +9 -27
- package/dist/packages/_es/Icon.js +2 -2
- package/dist/packages/_es/ImagePreview.js +14 -83
- package/dist/packages/_es/Indicator.js +4 -4
- package/dist/packages/_es/InfiniteLoading.js +94 -108
- package/dist/packages/_es/Input.js +297 -73
- package/dist/packages/_es/InputNumber.js +24 -17
- package/dist/packages/_es/Layout.js +2 -2
- package/dist/packages/_es/List.js +131 -0
- package/dist/packages/_es/Menu.js +16 -13
- package/dist/packages/_es/MenuItem.js +8 -8
- package/dist/packages/_es/Navbar.js +17 -12
- package/dist/packages/_es/NoticeBar.js +47 -39
- package/dist/packages/_es/Notify.js +28 -163
- package/dist/packages/_es/NumberKeyboard.js +4 -4
- package/dist/packages/_es/OldPicker.js +486 -0
- package/dist/packages/_es/OverLay.js +6 -26
- package/dist/packages/_es/Pagination.js +8 -8
- package/dist/packages/_es/Picker.js +192 -163
- package/dist/packages/_es/Popover.js +155 -30
- package/dist/packages/_es/Popup.js +7 -70
- package/dist/packages/_es/Price.js +18 -6
- package/dist/packages/_es/Progress.js +29 -27
- package/dist/packages/_es/PullRefresh.js +363 -0
- package/dist/packages/_es/Radio.js +4 -4
- package/dist/packages/_es/RadioGroup.js +2 -2
- package/dist/packages/_es/Range.js +169 -46
- package/dist/packages/_es/Rate.js +17 -20
- package/dist/packages/_es/Row.js +2 -2
- package/dist/packages/_es/SearchBar.js +9 -7
- package/dist/packages/_es/ShortPassword.js +90 -68
- package/dist/packages/_es/SideNavBar.js +6 -17
- package/dist/packages/_es/SideNavBarItem.js +2 -2
- package/dist/packages/_es/Signature.js +70 -70
- package/dist/packages/_es/Skeleton.js +9 -12
- package/dist/packages/_es/Sku.js +40 -31
- package/dist/packages/_es/Step.js +28 -12
- package/dist/packages/_es/Steps.js +8 -3
- package/dist/packages/_es/Sticky.js +29 -24
- package/dist/packages/_es/SubSideNavBar.js +2 -2
- package/dist/packages/_es/Swipe.js +40 -27
- package/dist/packages/_es/Swiper.js +32 -14
- package/dist/packages/_es/SwiperItem.js +2 -2
- package/dist/packages/_es/Switch.js +4 -4
- package/dist/packages/_es/TabPane.js +2 -2
- package/dist/packages/_es/Tabbar.js +4 -4
- package/dist/packages/_es/TabbarItem.js +28 -23
- package/dist/packages/_es/Table.js +14 -14
- package/dist/packages/_es/Tabs.js +19 -15
- package/dist/packages/_es/Tag.js +14 -8
- package/dist/packages/_es/TextArea.js +49 -15
- package/dist/packages/_es/TimeDetail.js +5 -4
- package/dist/packages/_es/TimePannel.js +4 -4
- package/dist/packages/_es/TimeSelect.js +9 -8
- package/dist/packages/_es/Toast.js +42 -171
- package/dist/packages/_es/Uploader.js +108 -139
- package/dist/packages/_es/Video.js +14 -10
- package/dist/packages/_es/common.js +2 -2
- package/dist/packages/_es/component.js +2 -2
- package/dist/packages/_es/index.js +45 -7
- package/dist/packages/_es/index.taro.js +719 -0
- package/dist/packages/_es/index2.js +2 -2
- package/dist/packages/_es/index3.js +57 -29
- package/dist/packages/_es/index4.js +414 -57
- package/dist/packages/_es/plugin-vue_export-helper.js +2 -2
- package/dist/packages/_es/pxCheck.js +2 -2
- package/dist/packages/_es/use-lock-scroll.js +23 -0
- package/dist/packages/_es/util.js +2 -2
- package/dist/packages/badge/index.scss +11 -13
- package/dist/packages/button/index.scss +1 -0
- package/dist/packages/calendar/index.scss +9 -4
- package/dist/packages/calendaritem/index.scss +0 -207
- package/dist/packages/cell/index.scss +6 -6
- package/dist/packages/checkbox/index.scss +4 -3
- package/dist/packages/collapseitem/index.scss +21 -11
- package/dist/packages/countdown/index.scss +3 -1
- package/dist/packages/divider/index.scss +8 -8
- package/dist/packages/elevator/index.scss +36 -36
- package/dist/packages/formitem/index.scss +15 -8
- package/dist/packages/indicator/index.scss +1 -1
- package/dist/packages/input/index.scss +70 -24
- package/dist/packages/inputnumber/index.scss +4 -2
- package/dist/packages/list/index.scss +24 -0
- package/dist/packages/menu/index.scss +3 -3
- package/dist/packages/navbar/index.scss +28 -8
- package/dist/packages/noticebar/index.scss +7 -8
- package/dist/packages/notify/index.scss +9 -0
- package/dist/packages/numberkeyboard/index.scss +22 -21
- package/dist/packages/oldpicker/index.scss +131 -0
- package/dist/packages/picker/index.scss +38 -32
- package/dist/packages/progress/index.scss +6 -5
- package/dist/packages/radio/index.scss +7 -6
- package/dist/packages/range/index.scss +109 -2
- package/dist/packages/searchbar/index.scss +7 -7
- package/dist/packages/sidenavbaritem/index.scss +5 -5
- package/dist/packages/step/index.scss +29 -29
- package/dist/packages/subsidenavbar/index.scss +10 -8
- package/dist/packages/tabbaritem/index.scss +15 -0
- package/dist/packages/timedetail/index.scss +13 -13
- package/dist/packages/timepannel/index.scss +7 -7
- package/dist/packages/timeselect/index.scss +3 -3
- package/dist/packages/uploader/index.scss +6 -6
- package/dist/style.css +1 -1
- package/dist/styles/themes/default.scss +64 -62
- package/dist/styles/themes/jdt.scss +91 -0
- package/dist/styles/variables-jdt.scss +728 -0
- package/dist/styles/variables.scss +250 -44
- package/package.json +2 -1
- package/dist/packages/_es/raf.js +0 -19
- package/dist/styles/themes/jdd.scss +0 -2
|
@@ -18,56 +18,50 @@ var __spreadValues = (a, b) => {
|
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
/*!
|
|
21
|
-
* @nutui/nutui v3.1.
|
|
22
|
-
* (c)
|
|
21
|
+
* @nutui/nutui v3.1.19-beta.1 Sat Apr 02 2022 16:26:37 GMT+0800 (中国标准时间)
|
|
22
|
+
* (c) 2022 @jdf2e.
|
|
23
23
|
* Released under the MIT License.
|
|
24
24
|
*/
|
|
25
|
-
import { ref, reactive, computed, watch, onMounted, toRefs, openBlock, createElementBlock, createElementVNode, normalizeStyle, Fragment, renderList, normalizeClass, toDisplayString, createCommentVNode,
|
|
25
|
+
import { ref, reactive, computed, watch, onMounted, toRefs, openBlock, createElementBlock, createElementVNode, normalizeStyle, Fragment, renderList, normalizeClass, toDisplayString, createCommentVNode, onBeforeUnmount, resolveComponent, createVNode, withCtx } from "vue";
|
|
26
26
|
import { c as createComponent } from "./component.js";
|
|
27
|
+
import { popupProps } from "./Popup.js";
|
|
28
|
+
import { u as useTaroRect } from "./index.js";
|
|
29
|
+
import Taro from "@tarojs/taro";
|
|
27
30
|
import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
|
|
28
|
-
import
|
|
31
|
+
import "./use-lock-scroll.js";
|
|
29
32
|
import "./OverLay.js";
|
|
30
33
|
import "./Icon.js";
|
|
31
34
|
import "./pxCheck.js";
|
|
32
|
-
const commonProps = {
|
|
33
|
-
listData: {
|
|
34
|
-
type: Array,
|
|
35
|
-
default: () => {
|
|
36
|
-
return [];
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
readonly: {
|
|
40
|
-
type: Boolean,
|
|
41
|
-
default: false
|
|
42
|
-
},
|
|
43
|
-
defaultIndex: {
|
|
44
|
-
type: [Number, String],
|
|
45
|
-
default: 0
|
|
46
|
-
},
|
|
47
|
-
itemHeight: {
|
|
48
|
-
type: [Number, String],
|
|
49
|
-
default: 35
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
35
|
const { create: create$1 } = createComponent("picker-column");
|
|
53
36
|
const _sfc_main$1 = create$1({
|
|
54
|
-
props:
|
|
55
|
-
|
|
37
|
+
props: {
|
|
38
|
+
value: [String, Number],
|
|
39
|
+
columnsType: String,
|
|
56
40
|
itemShow: {
|
|
57
41
|
type: Boolean,
|
|
58
42
|
default: false
|
|
43
|
+
},
|
|
44
|
+
column: {
|
|
45
|
+
type: Array,
|
|
46
|
+
default: () => []
|
|
47
|
+
},
|
|
48
|
+
readonly: {
|
|
49
|
+
type: Boolean,
|
|
50
|
+
default: false
|
|
59
51
|
}
|
|
60
|
-
},
|
|
52
|
+
},
|
|
61
53
|
emits: ["click", "change"],
|
|
62
54
|
setup(props, { emit }) {
|
|
63
55
|
const wrapper = ref();
|
|
56
|
+
const itemref = ref();
|
|
64
57
|
const state = reactive({
|
|
65
58
|
touchParams: {
|
|
66
59
|
startY: 0,
|
|
67
60
|
endY: 0,
|
|
68
61
|
startTime: 0,
|
|
69
62
|
endTime: 0,
|
|
70
|
-
lastY: 0
|
|
63
|
+
lastY: 0,
|
|
64
|
+
lastTime: 0
|
|
71
65
|
},
|
|
72
66
|
currIndex: 1,
|
|
73
67
|
transformY: 0,
|
|
@@ -78,7 +72,7 @@ const _sfc_main$1 = create$1({
|
|
|
78
72
|
});
|
|
79
73
|
const roller = ref(null);
|
|
80
74
|
const list = ref(null);
|
|
81
|
-
const
|
|
75
|
+
const listitem = ref(null);
|
|
82
76
|
const touchDeg = ref(0);
|
|
83
77
|
const touchTime = ref(0);
|
|
84
78
|
const touchTranslateY = ref(0);
|
|
@@ -113,7 +107,7 @@ const _sfc_main$1 = create$1({
|
|
|
113
107
|
event.preventDefault();
|
|
114
108
|
let changedTouches = event.changedTouches[0];
|
|
115
109
|
state.touchParams.lastY = changedTouches.pageY;
|
|
116
|
-
state.touchParams.lastTime = event.
|
|
110
|
+
state.touchParams.lastTime = event.timeStamp || Date.now();
|
|
117
111
|
let move = state.touchParams.lastY - state.touchParams.startY;
|
|
118
112
|
let moveTime = state.touchParams.lastTime - state.touchParams.startTime;
|
|
119
113
|
if (moveTime <= 300) {
|
|
@@ -150,8 +144,8 @@ const _sfc_main$1 = create$1({
|
|
|
150
144
|
if (updateMove > 0) {
|
|
151
145
|
updateMove = 0;
|
|
152
146
|
}
|
|
153
|
-
if (updateMove < -(props.
|
|
154
|
-
updateMove = -(props.
|
|
147
|
+
if (updateMove < -(props.column.length - 1) * state.lineSpacing) {
|
|
148
|
+
updateMove = -(props.column.length - 1) * state.lineSpacing;
|
|
155
149
|
}
|
|
156
150
|
let endMove = Math.round(updateMove / state.lineSpacing) * state.lineSpacing;
|
|
157
151
|
let deg = `${(Math.abs(Math.round(endMove / state.lineSpacing)) + 1) * state.rotation}deg`;
|
|
@@ -173,45 +167,63 @@ const _sfc_main$1 = create$1({
|
|
|
173
167
|
}
|
|
174
168
|
};
|
|
175
169
|
const setChooseValue = () => {
|
|
176
|
-
emit("change", state.currIndex - 1);
|
|
170
|
+
emit("change", props.column[state.currIndex - 1]);
|
|
177
171
|
};
|
|
178
172
|
const modifyStatus = (type) => {
|
|
179
|
-
|
|
173
|
+
const { column: column2 } = props;
|
|
174
|
+
let index = column2.findIndex((columnItem) => columnItem.value == props.value);
|
|
180
175
|
state.currIndex = index === -1 ? 1 : index + 1;
|
|
181
176
|
let move = index === -1 ? 0 : index * state.lineSpacing;
|
|
182
177
|
type && setChooseValue();
|
|
183
178
|
setMove(-move);
|
|
184
179
|
};
|
|
185
|
-
|
|
180
|
+
const getReference = async () => {
|
|
181
|
+
const refe = await useTaroRect(list, Taro);
|
|
182
|
+
state.lineSpacing = refe.height / props.column.length;
|
|
183
|
+
modifyStatus(true);
|
|
184
|
+
};
|
|
185
|
+
watch(() => props.column, (val) => {
|
|
186
186
|
state.transformY = 0;
|
|
187
187
|
modifyStatus(false);
|
|
188
188
|
}, {
|
|
189
189
|
deep: true
|
|
190
190
|
});
|
|
191
|
-
watch(() => props.
|
|
192
|
-
|
|
193
|
-
|
|
191
|
+
watch(() => props.itemShow, (val) => {
|
|
192
|
+
if (val) {
|
|
193
|
+
setTimeout(() => {
|
|
194
|
+
getReference();
|
|
195
|
+
}, 200);
|
|
196
|
+
}
|
|
197
|
+
}, {
|
|
198
|
+
deep: true
|
|
194
199
|
});
|
|
195
200
|
onMounted(() => {
|
|
196
|
-
|
|
201
|
+
setTimeout(() => {
|
|
202
|
+
getReference();
|
|
203
|
+
}, 200);
|
|
197
204
|
});
|
|
205
|
+
const refRandomId = Math.random().toString(36).slice(-8);
|
|
198
206
|
return __spreadProps(__spreadValues(__spreadValues({}, toRefs(state)), toRefs(props)), {
|
|
199
207
|
wrapper,
|
|
208
|
+
itemref,
|
|
200
209
|
setRollerStyle,
|
|
201
210
|
isHidden,
|
|
202
211
|
roller,
|
|
203
212
|
list,
|
|
204
|
-
|
|
213
|
+
listitem,
|
|
205
214
|
onTouchStart,
|
|
206
215
|
onTouchMove,
|
|
207
216
|
onTouchEnd,
|
|
208
217
|
touchRollerStyle,
|
|
209
|
-
touchListStyle
|
|
218
|
+
touchListStyle,
|
|
219
|
+
setMove,
|
|
220
|
+
refRandomId
|
|
210
221
|
});
|
|
211
222
|
}
|
|
212
223
|
});
|
|
213
224
|
const _hoisted_1$1 = { class: "nut-picker-content" };
|
|
214
|
-
const _hoisted_2$1 =
|
|
225
|
+
const _hoisted_2$1 = ["id"];
|
|
226
|
+
const _hoisted_3$1 = {
|
|
215
227
|
key: 0,
|
|
216
228
|
class: "nut-picker-placeholder"
|
|
217
229
|
};
|
|
@@ -227,39 +239,43 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
227
239
|
ref: "roller",
|
|
228
240
|
style: normalizeStyle(_ctx.touchRollerStyle)
|
|
229
241
|
}, [
|
|
230
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.
|
|
242
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.column, (item, index) => {
|
|
231
243
|
return openBlock(), createElementBlock("view", {
|
|
232
244
|
class: normalizeClass(["nut-picker-roller-item", { "nut-picker-roller-item-hidden": _ctx.isHidden(index + 1) }]),
|
|
233
245
|
style: normalizeStyle(_ctx.setRollerStyle(index + 1)),
|
|
234
|
-
key: item.
|
|
235
|
-
}, toDisplayString(
|
|
246
|
+
key: item.value ? item.value : index
|
|
247
|
+
}, toDisplayString(item.text), 7);
|
|
236
248
|
}), 128))
|
|
237
249
|
], 4),
|
|
238
250
|
createElementVNode("view", _hoisted_1$1, [
|
|
239
251
|
createElementVNode("view", {
|
|
240
252
|
class: "nut-picker-list-panel",
|
|
241
253
|
ref: "list",
|
|
254
|
+
id: "list" + _ctx.refRandomId,
|
|
242
255
|
style: normalizeStyle(_ctx.touchListStyle)
|
|
243
256
|
}, [
|
|
244
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.
|
|
257
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.column, (item, index) => {
|
|
245
258
|
return openBlock(), createElementBlock("view", {
|
|
246
|
-
class: "nut-picker-item nut-picker-item-ref",
|
|
247
|
-
key: item.
|
|
248
|
-
}, toDisplayString(
|
|
259
|
+
class: normalizeClass(["nut-picker-item", "nut-picker-item-ref", item.className]),
|
|
260
|
+
key: item.value ? item.value : index
|
|
261
|
+
}, toDisplayString(item.text), 3);
|
|
249
262
|
}), 128)),
|
|
250
|
-
_ctx.
|
|
251
|
-
],
|
|
263
|
+
_ctx.column && _ctx.column.length === 1 ? (openBlock(), createElementBlock("view", _hoisted_3$1)) : createCommentVNode("", true)
|
|
264
|
+
], 12, _hoisted_2$1)
|
|
252
265
|
])
|
|
253
266
|
], 32);
|
|
254
267
|
}
|
|
255
268
|
var column = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
|
|
256
|
-
const {
|
|
269
|
+
const { componentName, create } = createComponent("picker");
|
|
257
270
|
const _sfc_main = create({
|
|
258
271
|
components: {
|
|
259
|
-
[column.name]: column
|
|
260
|
-
[Popup.name]: Popup
|
|
272
|
+
[column.name]: column
|
|
261
273
|
},
|
|
262
|
-
props:
|
|
274
|
+
props: __spreadProps(__spreadValues({}, popupProps), {
|
|
275
|
+
modelValue: {
|
|
276
|
+
type: Array,
|
|
277
|
+
default: () => []
|
|
278
|
+
},
|
|
263
279
|
title: {
|
|
264
280
|
type: String,
|
|
265
281
|
default: ""
|
|
@@ -271,144 +287,158 @@ const _sfc_main = create({
|
|
|
271
287
|
okText: {
|
|
272
288
|
type: String,
|
|
273
289
|
default: "\u786E\u5B9A"
|
|
290
|
+
},
|
|
291
|
+
columns: {
|
|
292
|
+
type: Array,
|
|
293
|
+
default: () => {
|
|
294
|
+
return [];
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
readonly: {
|
|
298
|
+
type: Boolean,
|
|
299
|
+
default: false
|
|
274
300
|
}
|
|
275
|
-
}),
|
|
276
|
-
emits: ["close", "change", "confirm", "update:visible"],
|
|
301
|
+
}),
|
|
302
|
+
emits: ["close", "change", "confirm", "update:visible", "update:modelValue"],
|
|
277
303
|
setup(props, { emit }) {
|
|
278
|
-
const childrenKey = "children";
|
|
279
|
-
const valuesKey = "values";
|
|
280
304
|
const state = reactive({
|
|
281
305
|
show: false,
|
|
282
|
-
formattedColumns: props.
|
|
283
|
-
defaultIndex: props.defaultIndex
|
|
306
|
+
formattedColumns: props.columns
|
|
284
307
|
});
|
|
285
|
-
let
|
|
286
|
-
let defaultIndexList = [];
|
|
308
|
+
let defaultValues = ref(props.modelValue);
|
|
287
309
|
const classes = computed(() => {
|
|
288
310
|
const prefixCls = componentName;
|
|
289
311
|
return {
|
|
290
312
|
[prefixCls]: true
|
|
291
313
|
};
|
|
292
314
|
});
|
|
293
|
-
const
|
|
315
|
+
const selectedOptions = computed(() => {
|
|
316
|
+
let optins = [];
|
|
317
|
+
columnsList.value.map((column2, index) => {
|
|
318
|
+
let currOptions = [];
|
|
319
|
+
currOptions = column2.filter((item) => item.value == defaultValues.value[index]);
|
|
320
|
+
optins.push(currOptions[0]);
|
|
321
|
+
});
|
|
322
|
+
return optins;
|
|
323
|
+
});
|
|
324
|
+
const columnsType = computed(() => {
|
|
294
325
|
const firstColumn = state.formattedColumns[0];
|
|
295
|
-
if (
|
|
296
|
-
if (firstColumn
|
|
326
|
+
if (firstColumn) {
|
|
327
|
+
if (Array.isArray(firstColumn)) {
|
|
328
|
+
return "multiple";
|
|
329
|
+
}
|
|
330
|
+
if ("children" in firstColumn) {
|
|
297
331
|
return "cascade";
|
|
298
|
-
} else if (firstColumn == null ? void 0 : firstColumn[valuesKey]) {
|
|
299
|
-
addDefaultIndexList(props.listData);
|
|
300
|
-
return "multipleColumns";
|
|
301
332
|
}
|
|
302
333
|
}
|
|
303
|
-
return "
|
|
334
|
+
return "single";
|
|
304
335
|
});
|
|
305
|
-
const
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
336
|
+
const columnsList = computed(() => {
|
|
337
|
+
switch (columnsType.value) {
|
|
338
|
+
case "multiple":
|
|
339
|
+
return state.formattedColumns;
|
|
340
|
+
case "cascade":
|
|
341
|
+
return formatCascade(state.formattedColumns, defaultValues.value);
|
|
342
|
+
default:
|
|
343
|
+
return [state.formattedColumns];
|
|
313
344
|
}
|
|
314
|
-
return state.formattedColumns;
|
|
315
345
|
});
|
|
316
|
-
const
|
|
317
|
-
defaultIndexList = [];
|
|
318
|
-
listData.forEach((res) => {
|
|
319
|
-
defaultIndexList.push(res.defaultIndex || 0);
|
|
320
|
-
});
|
|
321
|
-
};
|
|
322
|
-
const formatCascade = (listData, defaultIndex) => {
|
|
346
|
+
const formatCascade = (columns, defaultValues2) => {
|
|
323
347
|
const formatted = [];
|
|
324
|
-
let
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
348
|
+
let cursor = {
|
|
349
|
+
text: "",
|
|
350
|
+
value: "",
|
|
351
|
+
children: columns
|
|
352
|
+
};
|
|
353
|
+
let columnIndex = 0;
|
|
354
|
+
while (cursor && cursor.children) {
|
|
355
|
+
const options = cursor.children;
|
|
356
|
+
const value = defaultValues2[columnIndex];
|
|
357
|
+
let index = options.findIndex((columnItem) => columnItem.value == value);
|
|
358
|
+
if (index == -1)
|
|
359
|
+
index = 0;
|
|
360
|
+
cursor = cursor.children[index];
|
|
361
|
+
columnIndex++;
|
|
362
|
+
formatted.push(options);
|
|
332
363
|
}
|
|
333
|
-
addDefaultIndexList(formatted);
|
|
334
364
|
return formatted;
|
|
335
365
|
};
|
|
336
|
-
const getCascadeData = (listData, defaultIndex) => {
|
|
337
|
-
var _a;
|
|
338
|
-
let arr = listData;
|
|
339
|
-
arr.defaultIndex = defaultIndex;
|
|
340
|
-
const dataList = [];
|
|
341
|
-
while (arr) {
|
|
342
|
-
const item = arr[(_a = arr.defaultIndex) != null ? _a : 0];
|
|
343
|
-
dataList.push(item.text);
|
|
344
|
-
arr = item.children;
|
|
345
|
-
}
|
|
346
|
-
return dataList;
|
|
347
|
-
};
|
|
348
366
|
const close = () => {
|
|
349
367
|
emit("close");
|
|
350
368
|
emit("update:visible", false);
|
|
351
369
|
};
|
|
352
|
-
const changeHandler = (columnIndex,
|
|
353
|
-
if (
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
cursor
|
|
362
|
-
} else if (i > columnIndex) {
|
|
363
|
-
cursor.defaultIndex = 0;
|
|
370
|
+
const changeHandler = (columnIndex, option) => {
|
|
371
|
+
if (option && Object.keys(option).length) {
|
|
372
|
+
if (columnsType.value === "cascade") {
|
|
373
|
+
defaultValues.value[columnIndex] = option.value ? option.value : "";
|
|
374
|
+
let index = columnIndex;
|
|
375
|
+
let cursor = option;
|
|
376
|
+
while (cursor && cursor.children) {
|
|
377
|
+
defaultValues.value[index + 1] = cursor.children[0].value;
|
|
378
|
+
index++;
|
|
379
|
+
cursor = cursor.children[0];
|
|
364
380
|
}
|
|
365
|
-
|
|
366
|
-
|
|
381
|
+
} else {
|
|
382
|
+
defaultValues.value[columnIndex] = option.value ? option.value : "";
|
|
367
383
|
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
emit("change", val, columnIndex, dataIndex);
|
|
384
|
+
emit("change", {
|
|
385
|
+
columnIndex,
|
|
386
|
+
selectedValue: defaultValues.value,
|
|
387
|
+
selectedOptions: selectedOptions.value
|
|
388
|
+
});
|
|
374
389
|
}
|
|
375
390
|
};
|
|
376
|
-
const
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
}
|
|
381
|
-
for (let i = 0; i < defaultIndexList.length; i++) {
|
|
382
|
-
state.formattedColumns[i].defaultIndex = defaultIndexList[i];
|
|
383
|
-
}
|
|
384
|
-
const checkedArr = toRaw(state.formattedColumns).map((res) => res.values && res.values[res.defaultIndex]);
|
|
385
|
-
emit("confirm", checkedArr);
|
|
386
|
-
} else if (dataType.value === "cascade") {
|
|
387
|
-
emit("confirm", getCascadeData(toRaw(state.formattedColumns), state.defaultIndex));
|
|
388
|
-
}
|
|
391
|
+
const confirmHandler = () => {
|
|
392
|
+
emit("confirm", {
|
|
393
|
+
selectedValue: defaultValues.value,
|
|
394
|
+
selectedOptions: selectedOptions.value
|
|
395
|
+
});
|
|
389
396
|
emit("update:visible", false);
|
|
390
397
|
};
|
|
398
|
+
onMounted(() => {
|
|
399
|
+
if (props.visible)
|
|
400
|
+
state.show = props.visible;
|
|
401
|
+
});
|
|
402
|
+
onBeforeUnmount(() => {
|
|
403
|
+
if (props.visible)
|
|
404
|
+
state.show = false;
|
|
405
|
+
});
|
|
406
|
+
watch(() => props.modelValue, (newValues) => {
|
|
407
|
+
const isSameValue = JSON.stringify(newValues) === JSON.stringify(defaultValues.value);
|
|
408
|
+
if (!isSameValue) {
|
|
409
|
+
defaultValues.value = newValues;
|
|
410
|
+
}
|
|
411
|
+
}, { deep: true });
|
|
412
|
+
watch(defaultValues, (newValues) => {
|
|
413
|
+
const isSameValue = JSON.stringify(newValues) === JSON.stringify(props.modelValue);
|
|
414
|
+
if (!isSameValue) {
|
|
415
|
+
emit("update:modelValue", newValues);
|
|
416
|
+
}
|
|
417
|
+
}, { immediate: true });
|
|
391
418
|
watch(() => props.visible, (val) => {
|
|
392
419
|
state.show = val;
|
|
393
420
|
});
|
|
394
|
-
watch(() => props.
|
|
395
|
-
|
|
421
|
+
watch(() => props.columns, (val) => {
|
|
422
|
+
if (val.length)
|
|
423
|
+
state.formattedColumns = val;
|
|
396
424
|
});
|
|
397
425
|
return __spreadProps(__spreadValues({
|
|
398
426
|
classes
|
|
399
427
|
}, toRefs(state)), {
|
|
400
428
|
column,
|
|
401
|
-
|
|
402
|
-
|
|
429
|
+
columnsType,
|
|
430
|
+
columnsList,
|
|
403
431
|
close,
|
|
404
432
|
changeHandler,
|
|
405
|
-
|
|
433
|
+
confirmHandler,
|
|
434
|
+
defaultValues
|
|
406
435
|
});
|
|
407
436
|
}
|
|
408
437
|
});
|
|
409
438
|
const _hoisted_1 = { class: "nut-picker__bar" };
|
|
410
|
-
const _hoisted_2 = { class: "nut-
|
|
411
|
-
const _hoisted_3 =
|
|
439
|
+
const _hoisted_2 = { class: "nut-picker__title" };
|
|
440
|
+
const _hoisted_3 = { class: "nut-picker__column" };
|
|
441
|
+
const _hoisted_4 = /* @__PURE__ */ createElementVNode("view", { class: "nut-picker__hairline" }, null, -1);
|
|
412
442
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
413
443
|
const _component_nut_picker_column = resolveComponent("nut-picker-column");
|
|
414
444
|
const _component_nut_popup = resolveComponent("nut-popup");
|
|
@@ -428,33 +458,32 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
428
458
|
default: withCtx(() => [
|
|
429
459
|
createElementVNode("view", _hoisted_1, [
|
|
430
460
|
createElementVNode("view", {
|
|
431
|
-
class: "nut-picker__left nut-picker__button",
|
|
461
|
+
class: "nut-picker__cancel nut-picker__left nut-picker__button",
|
|
432
462
|
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.close && _ctx.close(...args))
|
|
433
463
|
}, toDisplayString(_ctx.cancelText), 1),
|
|
434
|
-
createElementVNode("view",
|
|
464
|
+
createElementVNode("view", _hoisted_2, toDisplayString(_ctx.title), 1),
|
|
435
465
|
createElementVNode("view", {
|
|
436
|
-
class: "nut-picker__button",
|
|
437
|
-
onClick: _cache[1] || (_cache[1] = ($event) => _ctx.
|
|
466
|
+
class: "nut-picker__confirm nut-picker__right nut-picker__button",
|
|
467
|
+
onClick: _cache[1] || (_cache[1] = ($event) => _ctx.confirmHandler())
|
|
438
468
|
}, toDisplayString(_ctx.okText), 1)
|
|
439
469
|
]),
|
|
440
|
-
createElementVNode("view",
|
|
441
|
-
|
|
442
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.
|
|
470
|
+
createElementVNode("view", _hoisted_3, [
|
|
471
|
+
_hoisted_4,
|
|
472
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.columnsList, (column2, columnIndex) => {
|
|
443
473
|
return openBlock(), createElementBlock("view", {
|
|
444
474
|
class: "nut-picker__columnitem",
|
|
445
475
|
key: columnIndex
|
|
446
476
|
}, [
|
|
447
477
|
createVNode(_component_nut_picker_column, {
|
|
448
478
|
itemShow: _ctx.show,
|
|
449
|
-
|
|
479
|
+
column: column2,
|
|
450
480
|
readonly: _ctx.readonly,
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
_ctx.changeHandler(columnIndex, dataIndex);
|
|
481
|
+
columnsType: _ctx.columnsType,
|
|
482
|
+
value: _ctx.defaultValues[columnIndex],
|
|
483
|
+
onChange: (option) => {
|
|
484
|
+
_ctx.changeHandler(columnIndex, option);
|
|
456
485
|
}
|
|
457
|
-
}, null, 8, ["itemShow", "
|
|
486
|
+
}, null, 8, ["itemShow", "column", "readonly", "columnsType", "value", "onChange"])
|
|
458
487
|
]);
|
|
459
488
|
}), 128))
|
|
460
489
|
])
|
|
@@ -463,5 +492,5 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
463
492
|
}, 8, ["visible", "teleport", "lock-scroll", "close-on-click-overlay", "onClose"])
|
|
464
493
|
], 2);
|
|
465
494
|
}
|
|
466
|
-
var
|
|
467
|
-
export {
|
|
495
|
+
var nutPicker = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
496
|
+
export { nutPicker as default };
|