@nutui/nutui 3.1.10 → 3.1.12-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 +17 -0
- package/dist/nutui.d.ts +5 -1
- package/dist/nutui.es.js +4041 -3518
- package/dist/nutui.umd.js +4084 -3627
- package/dist/packages/_es/ActionSheet.js +13 -12
- package/dist/packages/_es/Address.js +63 -49
- package/dist/packages/_es/Avatar.js +4 -5
- package/dist/packages/_es/BackTop.js +72 -109
- package/dist/packages/_es/Badge.js +4 -5
- package/dist/packages/_es/Barrage.js +63 -57
- package/dist/packages/_es/Button.js +5 -6
- package/dist/packages/_es/Calendar.js +27 -18
- package/dist/packages/_es/Card.js +104 -0
- package/dist/packages/_es/Cell.js +5 -13
- package/dist/packages/_es/CellGroup.js +4 -5
- package/dist/packages/_es/Checkbox.js +3 -3
- package/dist/packages/_es/CheckboxGroup.js +9 -4
- package/dist/packages/_es/CircleProgress.js +142 -46
- package/dist/packages/_es/Col.js +4 -5
- package/dist/packages/_es/Collapse.js +35 -10
- package/dist/packages/_es/CollapseItem.js +80 -35
- package/dist/packages/_es/CountDown.js +7 -5
- package/dist/packages/_es/CountUp.js +34 -31
- package/dist/packages/_es/DatePicker.js +451 -219
- package/dist/packages/_es/Dialog.js +13 -87
- package/dist/packages/_es/Divider.js +5 -6
- package/dist/packages/_es/Drag.js +76 -50
- package/dist/packages/_es/Elevator.js +81 -52
- package/dist/packages/_es/FixedNav.js +8 -9
- package/dist/packages/_es/Form.js +137 -0
- package/dist/packages/_es/FormItem.js +109 -0
- package/dist/packages/_es/Icon.js +6 -40
- package/dist/packages/_es/ImagePreview.js +23 -21
- package/dist/packages/_es/InfiniteLoading.js +95 -109
- package/dist/packages/_es/Input.js +22 -21
- package/dist/packages/_es/InputNumber.js +24 -18
- package/dist/packages/_es/Layout.js +2 -2
- package/dist/packages/_es/Menu.js +89 -171
- package/dist/packages/_es/MenuItem.js +155 -18
- package/dist/packages/_es/Navbar.js +7 -7
- package/dist/packages/_es/NoticeBar.js +39 -26
- package/dist/packages/_es/Notify.js +30 -166
- package/dist/packages/_es/NumberKeyboard.js +10 -6
- package/dist/packages/_es/OverLay.js +22 -29
- package/dist/packages/_es/Pagination.js +8 -9
- package/dist/packages/_es/Picker.js +61 -447
- package/dist/packages/_es/Popover.js +146 -25
- package/dist/packages/_es/Popup.js +18 -39
- package/dist/packages/_es/Price.js +18 -7
- package/dist/packages/_es/Progress.js +23 -12
- package/dist/packages/_es/Radio.js +20 -7
- package/dist/packages/_es/RadioGroup.js +7 -3
- package/dist/packages/_es/Range.js +38 -59
- package/dist/packages/_es/Rate.js +16 -20
- package/dist/packages/_es/Row.js +4 -5
- package/dist/packages/_es/SearchBar.js +7 -5
- package/dist/packages/_es/ShortPassword.js +89 -59
- package/dist/packages/_es/Signature.js +70 -71
- package/dist/packages/_es/Sku.js +508 -0
- package/dist/packages/_es/Step.js +10 -8
- package/dist/packages/_es/Steps.js +2 -2
- package/dist/packages/_es/Swipe.js +42 -27
- package/dist/packages/_es/Swiper.js +17 -418
- package/dist/packages/_es/SwiperItem.js +14 -39
- package/dist/packages/_es/Switch.js +4 -5
- package/dist/packages/_es/TabPane.js +4 -5
- package/dist/packages/_es/Tabbar.js +4 -5
- package/dist/packages/_es/TabbarItem.js +8 -9
- package/dist/packages/_es/Tabs.js +23 -17
- package/dist/packages/_es/Tag.js +5 -6
- package/dist/packages/_es/TextArea.js +16 -12
- package/dist/packages/_es/TimeDetail.js +7 -5
- package/dist/packages/_es/TimePannel.js +7 -5
- package/dist/packages/_es/TimeSelect.js +12 -7
- package/dist/packages/_es/Toast.js +41 -163
- package/dist/packages/_es/Uploader.js +210 -164
- package/dist/packages/_es/commonProps.js +30 -0
- package/dist/packages/_es/component.js +1 -1
- package/dist/packages/_es/index.js +1 -1
- package/dist/packages/_es/index.taro.vue_vue&type=script&lang.js +44 -0
- package/dist/packages/_es/index2.js +44 -8
- package/dist/packages/_es/index3.js +419 -0
- package/dist/packages/_es/pxCheck.js +1 -1
- package/dist/packages/_es/raf.js +1 -1
- package/dist/packages/_es/use-lock-scroll.js +23 -0
- package/dist/packages/_es/util.js +47 -0
- package/dist/packages/button/index.scss +9 -0
- package/dist/packages/card/index.scss +97 -0
- package/dist/packages/checkbox/index.scss +1 -1
- package/dist/packages/form/index.scss +2 -0
- package/dist/packages/formitem/index.scss +60 -0
- package/dist/packages/menu/index.scss +32 -60
- package/dist/packages/menuitem/index.scss +36 -99
- package/dist/packages/numberkeyboard/index.scss +1 -1
- package/dist/packages/progress/index.scss +2 -0
- package/dist/packages/radio/index.scss +32 -4
- package/dist/packages/radiogroup/index.scss +20 -0
- package/dist/packages/sku/index.scss +147 -0
- package/dist/packages/switch/index.scss +1 -1
- package/dist/packages/uploader/index.scss +95 -8
- package/dist/style.css +1 -1
- package/dist/style.es.js +1 -2
- package/dist/styles/mixins/index.scss +0 -4
- package/dist/styles/themes/default.scss +34 -30
- package/dist/styles/variables.scss +45 -3
- package/package.json +3 -2
- package/dist/packages/_es/Video.js +0 -405
- package/dist/packages/_es/plugin-vue_export-helper.js +0 -12
- package/dist/packages/_es/style.css +0 -160
|
@@ -17,266 +17,498 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __require = typeof require !== "undefined" ? require : (x) => {
|
|
21
|
+
throw new Error('Dynamic require of "' + x + '" is not supported');
|
|
22
|
+
};
|
|
20
23
|
/*!
|
|
21
|
-
* @nutui/nutui v3.1.
|
|
24
|
+
* @nutui/nutui v3.1.11 Wed Nov 24 2021 14:54:38 GMT+0800 (中国标准时间)
|
|
22
25
|
* (c) 2021 @jdf2e.
|
|
23
26
|
* Released under the MIT License.
|
|
24
27
|
*/
|
|
25
|
-
import { reactive, computed, onMounted, watch, toRefs, resolveComponent,
|
|
26
|
-
import picker from "./Picker.js";
|
|
28
|
+
import { ref, reactive, computed, onMounted, watch, toRefs, openBlock, createElementBlock, normalizeStyle, createElementVNode, Fragment, renderList, toDisplayString, toRaw, resolveComponent, normalizeClass, createVNode, withCtx, createBlock, renderSlot } from "vue";
|
|
27
29
|
import { c as createComponent } from "./component.js";
|
|
28
|
-
import {
|
|
29
|
-
import "./
|
|
30
|
-
import "./
|
|
31
|
-
import "./
|
|
32
|
-
import "./Icon.js";
|
|
30
|
+
import { u as useTouch } from "./index.js";
|
|
31
|
+
import { c as commonProps } from "./commonProps.js";
|
|
32
|
+
import { a as _sfc_main$3, p as popupProps } from "./index3.js";
|
|
33
|
+
import "./use-lock-scroll.js";
|
|
33
34
|
import "./pxCheck.js";
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
const MOMENTUM_LIMIT_DISTANCE = 15;
|
|
36
|
+
const MOMENTUM_LIMIT_TIME = 300;
|
|
37
|
+
const DEFAULT_DURATION = 200;
|
|
38
|
+
const { create: create$2 } = createComponent("picker-column");
|
|
39
|
+
function range(num, min, max) {
|
|
40
|
+
return Math.min(Math.max(num, min), max);
|
|
38
41
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
function stopPropagation(event) {
|
|
43
|
+
event.stopPropagation();
|
|
44
|
+
}
|
|
45
|
+
function preventDefault(event, isStopPropagation) {
|
|
46
|
+
if (typeof event.cancelable !== "boolean" || event.cancelable) {
|
|
47
|
+
event.preventDefault();
|
|
48
|
+
}
|
|
49
|
+
if (isStopPropagation) {
|
|
50
|
+
stopPropagation(event);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function getElementTranslateY(element) {
|
|
54
|
+
const style = window.getComputedStyle(element);
|
|
55
|
+
const transform = style.transform || style.webkitTransform;
|
|
56
|
+
const translateY = transform.slice(7, transform.length - 1).split(", ")[5];
|
|
57
|
+
return Number(translateY);
|
|
58
|
+
}
|
|
59
|
+
function isObject(val) {
|
|
60
|
+
return val !== null && typeof val === "object";
|
|
61
|
+
}
|
|
62
|
+
function isOptionDisabled(option) {
|
|
63
|
+
return isObject(option) && option.disabled;
|
|
64
|
+
}
|
|
65
|
+
var _sfc_main$2 = create$2({
|
|
66
|
+
props: __spreadValues({
|
|
67
|
+
dataType: String
|
|
68
|
+
}, commonProps),
|
|
69
|
+
emits: ["click", "change"],
|
|
70
|
+
setup(props, { emit }) {
|
|
71
|
+
const wrapper = ref();
|
|
72
|
+
const state = reactive({
|
|
73
|
+
index: props.defaultIndex,
|
|
74
|
+
offset: 0,
|
|
75
|
+
duration: 0,
|
|
76
|
+
options: props.listData,
|
|
77
|
+
moving: false,
|
|
78
|
+
startOffset: 0,
|
|
79
|
+
touchStartTime: 0,
|
|
80
|
+
momentumOffset: 0,
|
|
81
|
+
transitionEndTrigger: null
|
|
82
|
+
});
|
|
83
|
+
const touch = useTouch();
|
|
84
|
+
const wrapperStyle = computed(() => ({
|
|
85
|
+
transform: `translate3d(0, ${state.offset + baseOffset()}px, 0)`,
|
|
86
|
+
transitionDuration: `${state.duration}ms`,
|
|
87
|
+
transitionProperty: state.duration ? "all" : "none"
|
|
88
|
+
}));
|
|
89
|
+
const getIndexByOffset = (offset) => {
|
|
90
|
+
return range(Math.round(-offset / +props.itemHeight), 0, state.options.length - 1);
|
|
91
|
+
};
|
|
92
|
+
const baseOffset = () => {
|
|
93
|
+
return +props.itemHeight * (+props.visibleItemCount - 1) / 2;
|
|
94
|
+
};
|
|
95
|
+
const stopMomentum = () => {
|
|
96
|
+
state.moving = false;
|
|
97
|
+
state.duration = 0;
|
|
98
|
+
if (state.transitionEndTrigger) {
|
|
99
|
+
state.transitionEndTrigger();
|
|
100
|
+
state.transitionEndTrigger = null;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const adjustIndex = (index) => {
|
|
104
|
+
index = range(index, 0, state.options.length);
|
|
105
|
+
for (let i = index; i < state.options.length; i++) {
|
|
106
|
+
if (!isOptionDisabled(state.options[i]))
|
|
107
|
+
return i;
|
|
108
|
+
}
|
|
109
|
+
for (let i = index - 1; i >= 0; i--) {
|
|
110
|
+
if (!isOptionDisabled(state.options[i]))
|
|
111
|
+
return i;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
const setIndex = (index, emitChange = false) => {
|
|
115
|
+
index = adjustIndex(index) || 0;
|
|
116
|
+
const offset = -index * +props.itemHeight;
|
|
117
|
+
const trigger = () => {
|
|
118
|
+
if (index !== state.index) {
|
|
119
|
+
state.index = index;
|
|
120
|
+
if (emitChange) {
|
|
121
|
+
emit("change", index);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
if (state.moving && offset !== state.offset) {
|
|
126
|
+
state.transitionEndTrigger = trigger;
|
|
127
|
+
} else {
|
|
128
|
+
trigger();
|
|
129
|
+
}
|
|
130
|
+
state.offset = offset;
|
|
131
|
+
};
|
|
132
|
+
const momentum = (distance, duration) => {
|
|
133
|
+
const speed = Math.abs(distance / duration);
|
|
134
|
+
distance = state.offset + speed / 0.03 * (distance < 0 ? -1 : 1);
|
|
135
|
+
const index = getIndexByOffset(distance);
|
|
136
|
+
setIndex(index, true);
|
|
137
|
+
};
|
|
138
|
+
const onTouchStart = (event) => {
|
|
139
|
+
if (props.readonly) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
touch.start(event);
|
|
143
|
+
if (state.moving) {
|
|
144
|
+
const translateY = getElementTranslateY(wrapper.value);
|
|
145
|
+
state.offset = Math.min(0, translateY - baseOffset());
|
|
146
|
+
state.startOffset = state.offset;
|
|
147
|
+
} else {
|
|
148
|
+
state.startOffset = state.offset;
|
|
149
|
+
}
|
|
150
|
+
state.duration = 0;
|
|
151
|
+
state.touchStartTime = Date.now();
|
|
152
|
+
state.momentumOffset = state.startOffset;
|
|
153
|
+
state.transitionEndTrigger = null;
|
|
154
|
+
};
|
|
155
|
+
const onTouchMove = (event) => {
|
|
156
|
+
if (props.readonly) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
state.moving = true;
|
|
160
|
+
touch.move(event);
|
|
161
|
+
if (touch.isVertical()) {
|
|
162
|
+
state.moving = true;
|
|
163
|
+
preventDefault(event, true);
|
|
164
|
+
}
|
|
165
|
+
const moveOffset = state.startOffset + touch.deltaY.value;
|
|
166
|
+
if (moveOffset > props.itemHeight) {
|
|
167
|
+
state.offset = props.itemHeight;
|
|
168
|
+
} else {
|
|
169
|
+
state.offset = state.startOffset + touch.deltaY.value;
|
|
170
|
+
}
|
|
171
|
+
const now = Date.now();
|
|
172
|
+
if (now - state.touchStartTime > MOMENTUM_LIMIT_TIME) {
|
|
173
|
+
state.touchStartTime = now;
|
|
174
|
+
state.momentumOffset = state.offset;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
const onTouchEnd = () => {
|
|
178
|
+
const index = getIndexByOffset(state.offset);
|
|
179
|
+
state.duration = DEFAULT_DURATION;
|
|
180
|
+
setIndex(index, true);
|
|
181
|
+
const distance = state.offset - state.momentumOffset;
|
|
182
|
+
const duration = Date.now() - state.touchStartTime;
|
|
183
|
+
const allowMomentum = duration < MOMENTUM_LIMIT_TIME && Math.abs(distance) > MOMENTUM_LIMIT_DISTANCE;
|
|
184
|
+
if (allowMomentum) {
|
|
185
|
+
momentum(distance, duration);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
onMounted(() => {
|
|
190
|
+
setIndex(+props.defaultIndex);
|
|
191
|
+
});
|
|
192
|
+
watch(() => props.listData, (val) => {
|
|
193
|
+
if (val) {
|
|
194
|
+
state.options = val;
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
watch(() => props.defaultIndex, (val) => {
|
|
198
|
+
setIndex(+val);
|
|
199
|
+
});
|
|
200
|
+
return __spreadProps(__spreadValues({}, toRefs(state)), {
|
|
201
|
+
wrapper,
|
|
202
|
+
onTouchStart,
|
|
203
|
+
onTouchMove,
|
|
204
|
+
onTouchEnd,
|
|
205
|
+
wrapperStyle,
|
|
206
|
+
stopMomentum,
|
|
207
|
+
columns: state.options,
|
|
208
|
+
height: Number(props.visibleItemCount) * +props.itemHeight
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
213
|
+
return openBlock(), createElementBlock("view", {
|
|
214
|
+
class: "nut-picker__content",
|
|
215
|
+
style: normalizeStyle({ height: _ctx.height + "px" }),
|
|
216
|
+
onTouchstart: _cache[0] || (_cache[0] = (...args) => _ctx.onTouchStart && _ctx.onTouchStart(...args)),
|
|
217
|
+
onTouchmove: _cache[1] || (_cache[1] = (...args) => _ctx.onTouchMove && _ctx.onTouchMove(...args)),
|
|
218
|
+
onTouchend: _cache[2] || (_cache[2] = (...args) => _ctx.onTouchEnd && _ctx.onTouchEnd(...args)),
|
|
219
|
+
onTouchcancel: _cache[3] || (_cache[3] = (...args) => _ctx.onTouchEnd && _ctx.onTouchEnd(...args)),
|
|
220
|
+
onTransitionend: _cache[4] || (_cache[4] = (...args) => _ctx.stopMomentum && _ctx.stopMomentum(...args))
|
|
221
|
+
}, [
|
|
222
|
+
createElementVNode("view", {
|
|
223
|
+
class: "nut-picker__wrapper",
|
|
224
|
+
ref: "wrapper",
|
|
225
|
+
style: normalizeStyle(_ctx.wrapperStyle)
|
|
226
|
+
}, [
|
|
227
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.options, (item, index) => {
|
|
228
|
+
return openBlock(), createElementBlock("view", {
|
|
229
|
+
class: "nut-picker__item",
|
|
230
|
+
key: index
|
|
231
|
+
}, toDisplayString(_ctx.dataType === "cascade" ? item.text : item), 1);
|
|
232
|
+
}), 128))
|
|
233
|
+
], 4)
|
|
234
|
+
], 36);
|
|
235
|
+
}
|
|
236
|
+
_sfc_main$2.render = _sfc_render$2;
|
|
237
|
+
const { create: create$1, componentName } = createComponent("picker");
|
|
238
|
+
var _sfc_main$1 = create$1({
|
|
48
239
|
components: {
|
|
49
|
-
[
|
|
240
|
+
[_sfc_main$2.name]: _sfc_main$2,
|
|
241
|
+
[_sfc_main$3.name]: _sfc_main$3
|
|
50
242
|
},
|
|
51
|
-
props: {
|
|
52
|
-
modelValue: null,
|
|
53
|
-
visible: {
|
|
54
|
-
type: Boolean,
|
|
55
|
-
default: false
|
|
56
|
-
},
|
|
243
|
+
props: __spreadValues(__spreadProps(__spreadValues({}, popupProps), {
|
|
57
244
|
title: {
|
|
58
245
|
type: String,
|
|
59
246
|
default: ""
|
|
60
247
|
},
|
|
61
|
-
|
|
248
|
+
cancelText: {
|
|
62
249
|
type: String,
|
|
63
|
-
default: "
|
|
64
|
-
},
|
|
65
|
-
isShowChinese: {
|
|
66
|
-
type: Boolean,
|
|
67
|
-
default: true
|
|
250
|
+
default: "\u53D6\u6D88"
|
|
68
251
|
},
|
|
69
|
-
|
|
70
|
-
type:
|
|
71
|
-
default:
|
|
72
|
-
},
|
|
73
|
-
minDate: {
|
|
74
|
-
type: Date,
|
|
75
|
-
default: () => new Date(currentYear - 10, 0, 1),
|
|
76
|
-
validator: isDate
|
|
77
|
-
},
|
|
78
|
-
maxDate: {
|
|
79
|
-
type: Date,
|
|
80
|
-
default: () => new Date(currentYear + 10, 11, 31),
|
|
81
|
-
validator: isDate
|
|
252
|
+
okText: {
|
|
253
|
+
type: String,
|
|
254
|
+
default: "\u786E\u5B9A"
|
|
82
255
|
}
|
|
83
|
-
},
|
|
84
|
-
emits: ["
|
|
256
|
+
}), commonProps),
|
|
257
|
+
emits: ["close", "change", "confirm", "update:visible"],
|
|
85
258
|
setup(props, { emit }) {
|
|
259
|
+
const childrenKey = "children";
|
|
260
|
+
const valuesKey = "values";
|
|
86
261
|
const state = reactive({
|
|
87
262
|
show: false,
|
|
88
|
-
|
|
89
|
-
|
|
263
|
+
formattedColumns: props.listData,
|
|
264
|
+
defaultIndex: props.defaultIndex
|
|
90
265
|
});
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
let timestmp = Math.max(value.getTime(), props.minDate.getTime());
|
|
96
|
-
timestmp = Math.min(timestmp, props.maxDate.getTime());
|
|
97
|
-
return new Date(timestmp);
|
|
98
|
-
};
|
|
99
|
-
function getMonthEndDay(year, month) {
|
|
100
|
-
return 32 - new Date(year, month - 1, 32).getDate();
|
|
101
|
-
}
|
|
102
|
-
const getBoundary = (type, value) => {
|
|
103
|
-
const boundary = props[`${type}Date`];
|
|
104
|
-
const year = boundary.getFullYear();
|
|
105
|
-
let month = 1;
|
|
106
|
-
let date = 1;
|
|
107
|
-
let hour = 0;
|
|
108
|
-
let minute = 0;
|
|
109
|
-
if (type === "max") {
|
|
110
|
-
month = 12;
|
|
111
|
-
date = getMonthEndDay(value.getFullYear(), value.getMonth() + 1);
|
|
112
|
-
hour = 23;
|
|
113
|
-
minute = 59;
|
|
114
|
-
}
|
|
115
|
-
const seconds = minute;
|
|
116
|
-
if (value.getFullYear() === year) {
|
|
117
|
-
month = boundary.getMonth() + 1;
|
|
118
|
-
if (value.getMonth() + 1 === month) {
|
|
119
|
-
date = boundary.getDate();
|
|
120
|
-
if (value.getDate() === date) {
|
|
121
|
-
hour = boundary.getHours();
|
|
122
|
-
if (value.getHours() === hour) {
|
|
123
|
-
minute = boundary.getMinutes();
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
266
|
+
let _defaultIndex = props.defaultIndex;
|
|
267
|
+
let defaultIndexList = [];
|
|
268
|
+
const classes = computed(() => {
|
|
269
|
+
const prefixCls = componentName;
|
|
128
270
|
return {
|
|
129
|
-
[
|
|
130
|
-
[`${type}Month`]: month,
|
|
131
|
-
[`${type}Date`]: date,
|
|
132
|
-
[`${type}Hour`]: hour,
|
|
133
|
-
[`${type}Minute`]: minute,
|
|
134
|
-
[`${type}Seconds`]: seconds
|
|
271
|
+
[prefixCls]: true
|
|
135
272
|
};
|
|
136
|
-
};
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
range: [minDate, maxDate]
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
type: "hour",
|
|
155
|
-
range: [minHour, maxHour]
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
type: "minute",
|
|
159
|
-
range: [minMinute, maxMinute]
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
type: "seconds",
|
|
163
|
-
range: [minSeconds, maxSeconds]
|
|
273
|
+
});
|
|
274
|
+
const top = computed(() => {
|
|
275
|
+
return Number(+props.visibleItemCount - 1) / 2 * +props.itemHeight;
|
|
276
|
+
});
|
|
277
|
+
const height = computed(() => {
|
|
278
|
+
return Number(props.visibleItemCount) * +props.itemHeight;
|
|
279
|
+
});
|
|
280
|
+
const dataType = computed(() => {
|
|
281
|
+
const firstColumn = state.formattedColumns[0];
|
|
282
|
+
if (typeof firstColumn === "object") {
|
|
283
|
+
if (firstColumn[childrenKey]) {
|
|
284
|
+
return "cascade";
|
|
285
|
+
} else if (firstColumn == null ? void 0 : firstColumn[valuesKey]) {
|
|
286
|
+
addDefaultIndexList(props.listData);
|
|
287
|
+
return "multipleColumns";
|
|
164
288
|
}
|
|
165
|
-
];
|
|
166
|
-
switch (props.type) {
|
|
167
|
-
case "date":
|
|
168
|
-
result = result.slice(0, 3);
|
|
169
|
-
break;
|
|
170
|
-
case "datetime":
|
|
171
|
-
result = result.slice(0, 5);
|
|
172
|
-
break;
|
|
173
|
-
case "time":
|
|
174
|
-
result = result.slice(3, 6);
|
|
175
|
-
break;
|
|
176
|
-
case "month-day":
|
|
177
|
-
result = result.slice(1, 3);
|
|
178
|
-
break;
|
|
179
|
-
case "datehour":
|
|
180
|
-
result = result.slice(0, 4);
|
|
181
|
-
break;
|
|
182
289
|
}
|
|
183
|
-
return
|
|
290
|
+
return "text";
|
|
184
291
|
});
|
|
185
|
-
const
|
|
186
|
-
if (
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
if (props.type === "date") {
|
|
196
|
-
state.currentDate = formatValue(new Date(formatDate[0], formatDate[1] - 1, Math.min(formatDate[2], getMonthEndDay(formatDate[0], formatDate[1]))));
|
|
197
|
-
} else if (props.type === "datetime") {
|
|
198
|
-
state.currentDate = formatValue(new Date(formatDate[0], formatDate[1] - 1, Math.min(formatDate[2], getMonthEndDay(formatDate[0], formatDate[1])), formatDate[3], formatDate[4]));
|
|
199
|
-
}
|
|
292
|
+
const columnList = computed(() => {
|
|
293
|
+
if (dataType.value === "text") {
|
|
294
|
+
return [
|
|
295
|
+
{ values: state.formattedColumns, defaultIndex: state.defaultIndex }
|
|
296
|
+
];
|
|
297
|
+
} else if (dataType.value === "multipleColumns") {
|
|
298
|
+
return state.formattedColumns;
|
|
299
|
+
} else if (dataType.value === "cascade") {
|
|
300
|
+
return formatCascade(state.formattedColumns, state.defaultIndex);
|
|
200
301
|
}
|
|
302
|
+
return state.formattedColumns;
|
|
303
|
+
});
|
|
304
|
+
const addDefaultIndexList = (listData) => {
|
|
305
|
+
defaultIndexList = [];
|
|
306
|
+
listData.forEach((res) => {
|
|
307
|
+
defaultIndexList.push(res.defaultIndex || 0);
|
|
308
|
+
});
|
|
201
309
|
};
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
if (type === "minute") {
|
|
214
|
-
min += props.minuteStep;
|
|
215
|
-
} else {
|
|
216
|
-
min++;
|
|
217
|
-
}
|
|
218
|
-
if (min <= val) {
|
|
219
|
-
index2++;
|
|
220
|
-
}
|
|
310
|
+
const formatCascade = (listData, defaultIndex) => {
|
|
311
|
+
const formatted = [];
|
|
312
|
+
let children = listData;
|
|
313
|
+
children.defaultIndex = defaultIndex;
|
|
314
|
+
while (children) {
|
|
315
|
+
formatted.push({
|
|
316
|
+
values: children,
|
|
317
|
+
defaultIndex: children.defaultIndex || 0
|
|
318
|
+
});
|
|
319
|
+
children = children == null ? void 0 : children[children.defaultIndex || 0].children;
|
|
221
320
|
}
|
|
222
|
-
|
|
321
|
+
addDefaultIndexList(formatted);
|
|
322
|
+
return formatted;
|
|
223
323
|
};
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
} else if (type === "minute") {
|
|
234
|
-
return state.currentDate.getMinutes();
|
|
235
|
-
} else if (type === "seconds") {
|
|
236
|
-
return state.currentDate.getSeconds();
|
|
324
|
+
const getCascadeData = (listData, defaultIndex) => {
|
|
325
|
+
var _a;
|
|
326
|
+
let arr = listData;
|
|
327
|
+
arr.defaultIndex = defaultIndex;
|
|
328
|
+
const dataList = [];
|
|
329
|
+
while (arr) {
|
|
330
|
+
const item = arr[(_a = arr.defaultIndex) != null ? _a : 0];
|
|
331
|
+
dataList.push(item.text);
|
|
332
|
+
arr = item.children;
|
|
237
333
|
}
|
|
238
|
-
return
|
|
334
|
+
return dataList;
|
|
239
335
|
};
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
return generateValue(res.range[0], res.range[1], getDateIndex(res.type), res.type);
|
|
243
|
-
});
|
|
244
|
-
return val;
|
|
245
|
-
});
|
|
246
|
-
const closeHandler = () => {
|
|
336
|
+
const close = () => {
|
|
337
|
+
emit("close");
|
|
247
338
|
emit("update:visible", false);
|
|
248
339
|
};
|
|
249
|
-
const
|
|
340
|
+
const changeHandler = (columnIndex, dataIndex) => {
|
|
341
|
+
if (dataType.value === "cascade") {
|
|
342
|
+
let cursor = state.formattedColumns;
|
|
343
|
+
if (columnIndex === 0) {
|
|
344
|
+
state.defaultIndex = dataIndex;
|
|
345
|
+
}
|
|
346
|
+
let i = 0;
|
|
347
|
+
while (cursor) {
|
|
348
|
+
if (i === columnIndex) {
|
|
349
|
+
cursor.defaultIndex = dataIndex;
|
|
350
|
+
} else if (i > columnIndex) {
|
|
351
|
+
cursor.defaultIndex = 0;
|
|
352
|
+
}
|
|
353
|
+
cursor = cursor[cursor.defaultIndex || 0].children;
|
|
354
|
+
i++;
|
|
355
|
+
}
|
|
356
|
+
} else if (dataType.value === "text") {
|
|
357
|
+
_defaultIndex = dataIndex;
|
|
358
|
+
} else if (dataType.value === "multipleColumns") {
|
|
359
|
+
defaultIndexList[columnIndex] = dataIndex;
|
|
360
|
+
const val = defaultIndexList.map((res, i) => toRaw(state.formattedColumns)[i].values[res]);
|
|
361
|
+
emit("change", val);
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
const confirm2 = () => {
|
|
365
|
+
if (dataType.value === "text") {
|
|
366
|
+
state.defaultIndex = _defaultIndex;
|
|
367
|
+
emit("confirm", state.formattedColumns[_defaultIndex]);
|
|
368
|
+
} else if (dataType.value === "multipleColumns") {
|
|
369
|
+
for (let i = 0; i < defaultIndexList.length; i++) {
|
|
370
|
+
state.formattedColumns[i].defaultIndex = defaultIndexList[i];
|
|
371
|
+
}
|
|
372
|
+
const checkedArr = toRaw(state.formattedColumns).map((res) => res.values && res.values[res.defaultIndex]);
|
|
373
|
+
emit("confirm", checkedArr);
|
|
374
|
+
} else if (dataType.value === "cascade") {
|
|
375
|
+
emit("confirm", getCascadeData(toRaw(state.formattedColumns), state.defaultIndex));
|
|
376
|
+
}
|
|
250
377
|
emit("update:visible", false);
|
|
251
|
-
emit("confirm", val);
|
|
252
378
|
};
|
|
253
|
-
onMounted(() => {
|
|
254
|
-
state.currentDate = formatValue(props.modelValue);
|
|
255
|
-
});
|
|
256
|
-
watch(() => props.title, (val) => {
|
|
257
|
-
state.title = val;
|
|
258
|
-
});
|
|
259
379
|
watch(() => props.visible, (val) => {
|
|
260
380
|
state.show = val;
|
|
261
381
|
});
|
|
262
|
-
|
|
382
|
+
watch(() => props.listData, (val) => {
|
|
383
|
+
state.formattedColumns = val;
|
|
384
|
+
});
|
|
385
|
+
return __spreadProps(__spreadValues({
|
|
386
|
+
classes
|
|
387
|
+
}, toRefs(state)), {
|
|
388
|
+
column: _sfc_main$2,
|
|
389
|
+
dataType,
|
|
390
|
+
columnList,
|
|
391
|
+
top,
|
|
392
|
+
height,
|
|
393
|
+
close,
|
|
263
394
|
changeHandler,
|
|
264
|
-
|
|
265
|
-
confirm,
|
|
266
|
-
columns
|
|
395
|
+
confirm: confirm2
|
|
267
396
|
});
|
|
268
397
|
}
|
|
269
398
|
});
|
|
399
|
+
const _hoisted_1 = { class: "nut-picker__bar" };
|
|
400
|
+
const _hoisted_2 = { class: "nut-picker__column" };
|
|
401
|
+
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
402
|
+
const _component_nut_picker_column = resolveComponent("nut-picker-column");
|
|
403
|
+
const _component_nut_popup = resolveComponent("nut-popup");
|
|
404
|
+
return openBlock(), createElementBlock("view", {
|
|
405
|
+
class: normalizeClass(_ctx.classes)
|
|
406
|
+
}, [
|
|
407
|
+
createVNode(_component_nut_popup, {
|
|
408
|
+
position: "bottom",
|
|
409
|
+
style: normalizeStyle({ height: _ctx.height + 56 + "px" }),
|
|
410
|
+
visible: _ctx.show,
|
|
411
|
+
"onUpdate:visible": _cache[2] || (_cache[2] = ($event) => _ctx.show = $event),
|
|
412
|
+
teleport: _ctx.teleport,
|
|
413
|
+
"lock-scroll": _ctx.lockScroll,
|
|
414
|
+
"close-on-click-overlay": _ctx.closeOnClickOverlay,
|
|
415
|
+
onClose: _ctx.close
|
|
416
|
+
}, {
|
|
417
|
+
default: withCtx(() => [
|
|
418
|
+
createElementVNode("view", _hoisted_1, [
|
|
419
|
+
createElementVNode("view", {
|
|
420
|
+
class: "nut-picker__left nut-picker__button",
|
|
421
|
+
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.close && _ctx.close(...args))
|
|
422
|
+
}, toDisplayString(_ctx.cancelText), 1),
|
|
423
|
+
createElementVNode("view", null, toDisplayString(_ctx.title), 1),
|
|
424
|
+
createElementVNode("view", {
|
|
425
|
+
class: "nut-picker__button",
|
|
426
|
+
onClick: _cache[1] || (_cache[1] = ($event) => _ctx.confirm())
|
|
427
|
+
}, toDisplayString(_ctx.okText), 1)
|
|
428
|
+
]),
|
|
429
|
+
createElementVNode("view", _hoisted_2, [
|
|
430
|
+
createElementVNode("view", {
|
|
431
|
+
class: "nut-picker__mask",
|
|
432
|
+
style: normalizeStyle({ backgroundSize: `100% ${_ctx.top}px` })
|
|
433
|
+
}, null, 4),
|
|
434
|
+
createElementVNode("view", {
|
|
435
|
+
class: "nut-picker__hairline",
|
|
436
|
+
style: normalizeStyle({ top: ` ${_ctx.top}px` })
|
|
437
|
+
}, null, 4),
|
|
438
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.columnList, (item, columnIndex) => {
|
|
439
|
+
return openBlock(), createElementBlock("view", {
|
|
440
|
+
class: "nut-picker__columnitem",
|
|
441
|
+
key: columnIndex
|
|
442
|
+
}, [
|
|
443
|
+
createVNode(_component_nut_picker_column, {
|
|
444
|
+
"list-data": item.values,
|
|
445
|
+
readonly: _ctx.readonly,
|
|
446
|
+
"default-index": item.defaultIndex,
|
|
447
|
+
"visible-item-count": _ctx.visibleItemCount,
|
|
448
|
+
"item-height": _ctx.itemHeight,
|
|
449
|
+
"data-type": _ctx.dataType,
|
|
450
|
+
onChange: (dataIndex) => {
|
|
451
|
+
_ctx.changeHandler(columnIndex, dataIndex);
|
|
452
|
+
}
|
|
453
|
+
}, null, 8, ["list-data", "readonly", "default-index", "visible-item-count", "item-height", "data-type", "onChange"])
|
|
454
|
+
]);
|
|
455
|
+
}), 128))
|
|
456
|
+
])
|
|
457
|
+
]),
|
|
458
|
+
_: 1
|
|
459
|
+
}, 8, ["style", "visible", "teleport", "lock-scroll", "close-on-click-overlay", "onClose"])
|
|
460
|
+
], 2);
|
|
461
|
+
}
|
|
462
|
+
_sfc_main$1.render = _sfc_render$1;
|
|
463
|
+
const { create } = createComponent("datepicker");
|
|
464
|
+
var _sfc_main = create({
|
|
465
|
+
components: {
|
|
466
|
+
[_sfc_main$1.name]: [_sfc_main$1]
|
|
467
|
+
},
|
|
468
|
+
props: {
|
|
469
|
+
value: {
|
|
470
|
+
type: String,
|
|
471
|
+
default: new Date()
|
|
472
|
+
},
|
|
473
|
+
start: {
|
|
474
|
+
type: String,
|
|
475
|
+
default: "1970-01-01"
|
|
476
|
+
},
|
|
477
|
+
end: {
|
|
478
|
+
type: String,
|
|
479
|
+
default: "2999-01-01"
|
|
480
|
+
},
|
|
481
|
+
fields: {
|
|
482
|
+
type: String,
|
|
483
|
+
default: "day"
|
|
484
|
+
}
|
|
485
|
+
},
|
|
486
|
+
emits: ["onChange"],
|
|
487
|
+
setup(props, { emit }) {
|
|
488
|
+
const onChange = (e) => {
|
|
489
|
+
emit("onChange", e.detail.value);
|
|
490
|
+
};
|
|
491
|
+
return __spreadValues({
|
|
492
|
+
confirm,
|
|
493
|
+
onChange
|
|
494
|
+
}, toRefs(props));
|
|
495
|
+
}
|
|
496
|
+
});
|
|
270
497
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
271
|
-
const
|
|
272
|
-
return openBlock(), createBlock(
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
},
|
|
498
|
+
const _component_picker = resolveComponent("picker");
|
|
499
|
+
return openBlock(), createBlock(_component_picker, {
|
|
500
|
+
mode: "date",
|
|
501
|
+
onChange: _ctx.onChange,
|
|
502
|
+
value: _ctx.value,
|
|
503
|
+
start: _ctx.start,
|
|
504
|
+
end: _ctx.end,
|
|
505
|
+
fields: _ctx.fields
|
|
506
|
+
}, {
|
|
507
|
+
default: withCtx(() => [
|
|
508
|
+
renderSlot(_ctx.$slots, "default")
|
|
509
|
+
]),
|
|
510
|
+
_: 3
|
|
511
|
+
}, 8, ["onChange", "value", "start", "end", "fields"]);
|
|
280
512
|
}
|
|
281
|
-
|
|
282
|
-
export {
|
|
513
|
+
_sfc_main.render = _sfc_render;
|
|
514
|
+
export { _sfc_main as default };
|