@nutui/nutui 3.1.12-beta.1 → 3.1.12
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 +27 -0
- package/dist/nutui.d.ts +1 -1
- package/dist/nutui.es.js +3219 -2562
- package/dist/nutui.umd.js +3292 -2565
- package/dist/packages/_es/ActionSheet.js +12 -13
- package/dist/packages/_es/Address.js +49 -63
- package/dist/packages/_es/Avatar.js +5 -4
- package/dist/packages/_es/BackTop.js +109 -72
- package/dist/packages/_es/Badge.js +5 -4
- package/dist/packages/_es/Barrage.js +57 -63
- package/dist/packages/_es/Button.js +6 -5
- package/dist/packages/_es/Calendar.js +18 -27
- package/dist/packages/_es/Card.js +8 -7
- package/dist/packages/_es/Cell.js +13 -5
- package/dist/packages/_es/CellGroup.js +14 -7
- package/dist/packages/_es/Checkbox.js +3 -3
- package/dist/packages/_es/CheckboxGroup.js +4 -9
- package/dist/packages/_es/CircleProgress.js +46 -142
- package/dist/packages/_es/Col.js +5 -4
- package/dist/packages/_es/Collapse.js +10 -35
- package/dist/packages/_es/CollapseItem.js +35 -80
- package/dist/packages/_es/CountDown.js +5 -7
- package/dist/packages/_es/CountUp.js +31 -34
- package/dist/packages/_es/DatePicker.js +219 -451
- package/dist/packages/_es/Dialog.js +98 -46
- package/dist/packages/_es/Divider.js +6 -5
- package/dist/packages/_es/Drag.js +50 -76
- package/dist/packages/_es/Elevator.js +52 -81
- package/dist/packages/_es/FixedNav.js +9 -8
- package/dist/packages/_es/Form.js +6 -5
- package/dist/packages/_es/FormItem.js +5 -4
- package/dist/packages/_es/Icon.js +40 -6
- package/dist/packages/_es/ImagePreview.js +158 -44
- package/dist/packages/_es/InfiniteLoading.js +109 -95
- package/dist/packages/_es/Input.js +21 -22
- package/dist/packages/_es/InputNumber.js +18 -24
- package/dist/packages/_es/Layout.js +2 -2
- package/dist/packages/_es/Menu.js +14 -16
- package/dist/packages/_es/MenuItem.js +11 -9
- package/dist/packages/_es/Navbar.js +7 -7
- package/dist/packages/_es/NoticeBar.js +26 -39
- package/dist/packages/_es/Notify.js +166 -30
- package/dist/packages/_es/NumberKeyboard.js +7 -9
- package/dist/packages/_es/OverLay.js +29 -22
- package/dist/packages/_es/Pagination.js +9 -8
- package/dist/packages/_es/Picker.js +447 -61
- package/dist/packages/_es/Popover.js +34 -161
- package/dist/packages/_es/Popup.js +77 -17
- package/dist/packages/_es/Price.js +7 -18
- package/dist/packages/_es/Progress.js +12 -23
- package/dist/packages/_es/Radio.js +3 -3
- package/dist/packages/_es/RadioGroup.js +2 -2
- package/dist/packages/_es/Range.js +31 -38
- package/dist/packages/_es/Rate.js +35 -17
- package/dist/packages/_es/Row.js +5 -4
- package/dist/packages/_es/SearchBar.js +5 -7
- package/dist/packages/_es/ShortPassword.js +59 -89
- package/dist/packages/_es/Signature.js +71 -70
- package/dist/packages/_es/Sku.js +43 -53
- package/dist/packages/_es/Step.js +8 -10
- package/dist/packages/_es/Steps.js +2 -2
- package/dist/packages/_es/Swipe.js +28 -43
- package/dist/packages/_es/Swiper.js +418 -17
- package/dist/packages/_es/SwiperItem.js +39 -14
- package/dist/packages/_es/Switch.js +32 -11
- package/dist/packages/_es/TabPane.js +5 -4
- package/dist/packages/_es/Tabbar.js +5 -4
- package/dist/packages/_es/TabbarItem.js +9 -8
- package/dist/packages/_es/Tabs.js +16 -22
- package/dist/packages/_es/Tag.js +6 -5
- package/dist/packages/_es/TextArea.js +12 -16
- package/dist/packages/_es/TimeDetail.js +5 -7
- package/dist/packages/_es/TimePannel.js +5 -7
- package/dist/packages/_es/TimeSelect.js +7 -12
- package/dist/packages/_es/Toast.js +178 -46
- package/dist/packages/_es/Uploader.js +149 -109
- package/dist/packages/_es/Video.js +405 -0
- package/dist/packages/_es/component.js +1 -1
- package/dist/packages/_es/index.js +7 -58
- package/dist/packages/_es/index2.js +58 -43
- package/dist/packages/_es/index3.js +28 -411
- package/dist/packages/_es/plugin-vue_export-helper.js +13 -0
- package/dist/packages/_es/pxCheck.js +1 -1
- package/dist/packages/_es/raf.js +1 -1
- package/dist/packages/_es/util.js +1 -1
- package/dist/packages/cellgroup/index.scss +9 -0
- package/dist/packages/dialog/index.scss +17 -0
- package/dist/packages/drag/index.scss +4 -0
- package/dist/packages/fixednav/index.scss +6 -1
- package/dist/packages/formitem/index.scss +3 -0
- package/dist/packages/icon/index.scss +2 -1
- package/dist/packages/numberkeyboard/index.scss +1 -1
- package/dist/packages/popover/index.scss +2 -2
- package/dist/packages/rate/index.scss +1 -0
- package/dist/packages/textarea/index.scss +1 -0
- package/dist/packages/timedetail/index.scss +1 -2
- package/dist/packages/timeselect/index.scss +3 -0
- package/dist/packages/toast/index.scss +6 -0
- package/dist/style.css +1 -1
- package/dist/style.es.js +2 -1
- package/dist/styles/font/config.json +2 -1
- package/dist/styles/font/demo_index.html +26 -3
- package/dist/styles/font/iconfont.css +7 -3
- package/dist/styles/font/iconfont.js +31 -32
- package/dist/styles/font/iconfont.json +7 -0
- package/dist/styles/font/iconfont.ttf +0 -0
- package/dist/styles/font/iconfont.woff +0 -0
- package/dist/styles/font/iconfont.woff2 +0 -0
- package/dist/styles/themes/default.scss +38 -38
- package/dist/styles/variables.scss +5 -1
- package/package.json +1 -1
- package/dist/packages/_es/commonProps.js +0 -30
- package/dist/packages/_es/index.taro.vue_vue&type=script&lang.js +0 -44
- package/dist/packages/_es/use-lock-scroll.js +0 -23
|
@@ -17,498 +17,266 @@ 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
|
-
};
|
|
23
20
|
/*!
|
|
24
|
-
* @nutui/nutui v3.1.
|
|
21
|
+
* @nutui/nutui v3.1.12 Sat Nov 27 2021 11:30:43 GMT+0800 (中国标准时间)
|
|
25
22
|
* (c) 2021 @jdf2e.
|
|
26
23
|
* Released under the MIT License.
|
|
27
24
|
*/
|
|
28
|
-
import {
|
|
25
|
+
import { reactive, computed, onMounted, watch, toRefs, resolveComponent, openBlock, createBlock } from "vue";
|
|
26
|
+
import picker from "./Picker.js";
|
|
29
27
|
import { c as createComponent } from "./component.js";
|
|
30
|
-
import {
|
|
31
|
-
import
|
|
32
|
-
import
|
|
33
|
-
import "./
|
|
28
|
+
import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
|
|
29
|
+
import "./index2.js";
|
|
30
|
+
import "./Popup.js";
|
|
31
|
+
import "./OverLay.js";
|
|
32
|
+
import "./Icon.js";
|
|
34
33
|
import "./pxCheck.js";
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
function range(num, min, max) {
|
|
40
|
-
return Math.min(Math.max(num, min), max);
|
|
41
|
-
}
|
|
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);
|
|
34
|
+
const { componentName, create } = createComponent("datepicker");
|
|
35
|
+
const currentYear = new Date().getFullYear();
|
|
36
|
+
function isDate(val) {
|
|
37
|
+
return Object.prototype.toString.call(val) === "[object Date]" && !isNaN(val.getTime());
|
|
235
38
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
39
|
+
const zhCNType = {
|
|
40
|
+
day: "\u65E5",
|
|
41
|
+
year: "\u5E74",
|
|
42
|
+
month: "\u6708",
|
|
43
|
+
hour: "\u65F6",
|
|
44
|
+
minute: "\u5206",
|
|
45
|
+
seconds: "\u79D2"
|
|
46
|
+
};
|
|
47
|
+
const _sfc_main = create({
|
|
239
48
|
components: {
|
|
240
|
-
[
|
|
241
|
-
[_sfc_main$3.name]: _sfc_main$3
|
|
49
|
+
[picker.name]: picker
|
|
242
50
|
},
|
|
243
|
-
props:
|
|
51
|
+
props: {
|
|
52
|
+
modelValue: null,
|
|
53
|
+
visible: {
|
|
54
|
+
type: Boolean,
|
|
55
|
+
default: false
|
|
56
|
+
},
|
|
244
57
|
title: {
|
|
245
58
|
type: String,
|
|
246
59
|
default: ""
|
|
247
60
|
},
|
|
248
|
-
|
|
61
|
+
type: {
|
|
249
62
|
type: String,
|
|
250
|
-
default: "
|
|
63
|
+
default: "date"
|
|
251
64
|
},
|
|
252
|
-
|
|
253
|
-
type:
|
|
254
|
-
default:
|
|
65
|
+
isShowChinese: {
|
|
66
|
+
type: Boolean,
|
|
67
|
+
default: true
|
|
68
|
+
},
|
|
69
|
+
minuteStep: {
|
|
70
|
+
type: Number,
|
|
71
|
+
default: 1
|
|
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
|
|
255
82
|
}
|
|
256
|
-
}
|
|
257
|
-
emits: ["
|
|
83
|
+
},
|
|
84
|
+
emits: ["click", "update:visible", "confirm"],
|
|
258
85
|
setup(props, { emit }) {
|
|
259
|
-
const childrenKey = "children";
|
|
260
|
-
const valuesKey = "values";
|
|
261
86
|
const state = reactive({
|
|
262
87
|
show: false,
|
|
263
|
-
|
|
264
|
-
|
|
88
|
+
currentDate: new Date(),
|
|
89
|
+
title: props.title
|
|
265
90
|
});
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
91
|
+
const formatValue = (value) => {
|
|
92
|
+
if (!isDate(value)) {
|
|
93
|
+
value = props.minDate;
|
|
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
|
+
}
|
|
270
128
|
return {
|
|
271
|
-
[
|
|
129
|
+
[`${type}Year`]: year,
|
|
130
|
+
[`${type}Month`]: month,
|
|
131
|
+
[`${type}Date`]: date,
|
|
132
|
+
[`${type}Hour`]: hour,
|
|
133
|
+
[`${type}Minute`]: minute,
|
|
134
|
+
[`${type}Seconds`]: seconds
|
|
272
135
|
};
|
|
273
|
-
}
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
|
|
136
|
+
};
|
|
137
|
+
const ranges = computed(() => {
|
|
138
|
+
const { maxYear, maxDate, maxMonth, maxHour, maxMinute, maxSeconds } = getBoundary("max", state.currentDate);
|
|
139
|
+
const { minYear, minDate, minMonth, minHour, minMinute, minSeconds } = getBoundary("min", state.currentDate);
|
|
140
|
+
let result = [
|
|
141
|
+
{
|
|
142
|
+
type: "year",
|
|
143
|
+
range: [minYear, maxYear]
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
type: "month",
|
|
147
|
+
range: [minMonth, maxMonth]
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
type: "day",
|
|
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]
|
|
288
164
|
}
|
|
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;
|
|
289
182
|
}
|
|
290
|
-
return
|
|
183
|
+
return result;
|
|
291
184
|
});
|
|
292
|
-
const
|
|
293
|
-
if (
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
185
|
+
const changeHandler = (val) => {
|
|
186
|
+
if (["date", "datetime"].includes(props.type)) {
|
|
187
|
+
let formatDate = [];
|
|
188
|
+
if (props.isShowChinese) {
|
|
189
|
+
formatDate = val.map((res) => {
|
|
190
|
+
return Number(res.slice(0, res.length - 1));
|
|
191
|
+
});
|
|
192
|
+
} else {
|
|
193
|
+
formatDate = val;
|
|
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
|
+
}
|
|
301
200
|
}
|
|
302
|
-
return state.formattedColumns;
|
|
303
|
-
});
|
|
304
|
-
const addDefaultIndexList = (listData) => {
|
|
305
|
-
defaultIndexList = [];
|
|
306
|
-
listData.forEach((res) => {
|
|
307
|
-
defaultIndexList.push(res.defaultIndex || 0);
|
|
308
|
-
});
|
|
309
201
|
};
|
|
310
|
-
const
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
}
|
|
319
|
-
|
|
202
|
+
const generateValue = (min, max, val, type) => {
|
|
203
|
+
if (!(max > min))
|
|
204
|
+
return;
|
|
205
|
+
const arr = [];
|
|
206
|
+
let index2 = 0;
|
|
207
|
+
while (min <= max) {
|
|
208
|
+
if (props.isShowChinese) {
|
|
209
|
+
arr.push(min + zhCNType[type]);
|
|
210
|
+
} else {
|
|
211
|
+
arr.push(min);
|
|
212
|
+
}
|
|
213
|
+
if (type === "minute") {
|
|
214
|
+
min += props.minuteStep;
|
|
215
|
+
} else {
|
|
216
|
+
min++;
|
|
217
|
+
}
|
|
218
|
+
if (min <= val) {
|
|
219
|
+
index2++;
|
|
220
|
+
}
|
|
320
221
|
}
|
|
321
|
-
|
|
322
|
-
return formatted;
|
|
222
|
+
return { values: arr, defaultIndex: index2 };
|
|
323
223
|
};
|
|
324
|
-
const
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
224
|
+
const getDateIndex = (type) => {
|
|
225
|
+
if (type === "year") {
|
|
226
|
+
return state.currentDate.getFullYear();
|
|
227
|
+
} else if (type === "month") {
|
|
228
|
+
return state.currentDate.getMonth() + 1;
|
|
229
|
+
} else if (type === "day") {
|
|
230
|
+
return state.currentDate.getDate();
|
|
231
|
+
} else if (type === "hour") {
|
|
232
|
+
return state.currentDate.getHours();
|
|
233
|
+
} else if (type === "minute") {
|
|
234
|
+
return state.currentDate.getMinutes();
|
|
235
|
+
} else if (type === "seconds") {
|
|
236
|
+
return state.currentDate.getSeconds();
|
|
333
237
|
}
|
|
334
|
-
return
|
|
238
|
+
return 0;
|
|
335
239
|
};
|
|
336
|
-
const
|
|
337
|
-
|
|
240
|
+
const columns = computed(() => {
|
|
241
|
+
const val = ranges.value.map((res) => {
|
|
242
|
+
return generateValue(res.range[0], res.range[1], getDateIndex(res.type), res.type);
|
|
243
|
+
});
|
|
244
|
+
return val;
|
|
245
|
+
});
|
|
246
|
+
const closeHandler = () => {
|
|
338
247
|
emit("update:visible", false);
|
|
339
248
|
};
|
|
340
|
-
const
|
|
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
|
-
}
|
|
249
|
+
const confirm = (val) => {
|
|
377
250
|
emit("update:visible", false);
|
|
251
|
+
emit("confirm", val);
|
|
378
252
|
};
|
|
253
|
+
onMounted(() => {
|
|
254
|
+
state.currentDate = formatValue(props.modelValue);
|
|
255
|
+
});
|
|
256
|
+
watch(() => props.title, (val) => {
|
|
257
|
+
state.title = val;
|
|
258
|
+
});
|
|
379
259
|
watch(() => props.visible, (val) => {
|
|
380
260
|
state.show = val;
|
|
381
261
|
});
|
|
382
|
-
|
|
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,
|
|
262
|
+
return __spreadProps(__spreadValues({}, toRefs(state)), {
|
|
394
263
|
changeHandler,
|
|
395
|
-
|
|
396
|
-
});
|
|
397
|
-
}
|
|
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({
|
|
264
|
+
closeHandler,
|
|
492
265
|
confirm,
|
|
493
|
-
|
|
494
|
-
}
|
|
266
|
+
columns
|
|
267
|
+
});
|
|
495
268
|
}
|
|
496
269
|
});
|
|
497
270
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
498
|
-
const
|
|
499
|
-
return openBlock(), createBlock(
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
},
|
|
507
|
-
default: withCtx(() => [
|
|
508
|
-
renderSlot(_ctx.$slots, "default")
|
|
509
|
-
]),
|
|
510
|
-
_: 3
|
|
511
|
-
}, 8, ["onChange", "value", "start", "end", "fields"]);
|
|
271
|
+
const _component_nut_picker = resolveComponent("nut-picker");
|
|
272
|
+
return openBlock(), createBlock(_component_nut_picker, {
|
|
273
|
+
visible: _ctx.show,
|
|
274
|
+
onClose: _ctx.closeHandler,
|
|
275
|
+
"list-data": _ctx.columns,
|
|
276
|
+
onChange: _ctx.changeHandler,
|
|
277
|
+
title: _ctx.title,
|
|
278
|
+
onConfirm: _ctx.confirm
|
|
279
|
+
}, null, 8, ["visible", "onClose", "list-data", "onChange", "title", "onConfirm"]);
|
|
512
280
|
}
|
|
513
|
-
_sfc_main
|
|
514
|
-
export {
|
|
281
|
+
var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
282
|
+
export { index as default };
|