papayaui 0.2.8 → 0.2.9
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.
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { defaultNamespace } from '../../core'
|
|
2
|
+
|
|
3
|
+
const Dialog = () => {
|
|
4
|
+
const node = uni
|
|
5
|
+
.createSelectorQuery()
|
|
6
|
+
.select(`#${defaultNamespace}-dialog`)
|
|
7
|
+
.node((result) => {
|
|
8
|
+
console.log('result', result)
|
|
9
|
+
})
|
|
10
|
+
.exec()
|
|
11
|
+
console.log(node)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default Dialog
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
height: 100%;
|
|
78
78
|
color: _var(slider-button-tip-font-color, _var(color-black));
|
|
79
79
|
font-size: _var(slider-button-tip-font-size, 12px);
|
|
80
|
-
transform: translate3d(0, -100%, 0);
|
|
80
|
+
transform: _var(slider-button-tip-transform, translate3d(0, -100%, 0));
|
|
81
81
|
user-select: none;
|
|
82
82
|
}
|
|
83
83
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<view :class="ns.b('container')">
|
|
3
|
-
<text v-if="showRange" :class="ns.e('min')">{{ min }}</text>
|
|
3
|
+
<text v-if="showRange" :class="ns.e('min')">{{ formatVal(min) }}</text>
|
|
4
4
|
<view
|
|
5
5
|
:class="[ns.b(), ns.is('show-range', showRange), ns.is('disabled', disabled)]"
|
|
6
6
|
:style="ns.style({ backgroundColor: inactiveColor })"
|
|
@@ -34,14 +34,14 @@
|
|
|
34
34
|
<slot v-if="$slots.button" name="button" />
|
|
35
35
|
<view v-else :class="ns.e('button')">
|
|
36
36
|
<text v-if="showTag" :class="ns.e('button-number')">{{
|
|
37
|
-
Array.isArray(modelValue) ? modelValue[index] : modelValue
|
|
37
|
+
Array.isArray(modelValue) ? formatVal(modelValue[index]) : formatVal(modelValue)
|
|
38
38
|
}}</text>
|
|
39
39
|
</view>
|
|
40
40
|
</view>
|
|
41
41
|
</template>
|
|
42
42
|
</view>
|
|
43
43
|
</view>
|
|
44
|
-
<text v-if="showRange" :class="ns.e('max')">{{ max }}</text>
|
|
44
|
+
<text v-if="showRange" :class="ns.e('max')">{{ formatVal(max) }}</text>
|
|
45
45
|
</view>
|
|
46
46
|
</template>
|
|
47
47
|
|
|
@@ -84,6 +84,10 @@ export default defineComponent({
|
|
|
84
84
|
return value <= props.modelValue
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
const formatVal = (value: number) => {
|
|
88
|
+
return typeof props.formatter === 'function' ? props.formatter(value) : value
|
|
89
|
+
}
|
|
90
|
+
|
|
87
91
|
const updateModelValue = (value: number | number[]) => {
|
|
88
92
|
isDragging = true
|
|
89
93
|
// TODO: wxs的bug,为0时会变成{}, 要特殊处理
|
|
@@ -114,6 +118,7 @@ export default defineComponent({
|
|
|
114
118
|
wxsProps,
|
|
115
119
|
wxsModelValue,
|
|
116
120
|
isWithinRange,
|
|
121
|
+
formatVal,
|
|
117
122
|
updateModelValue,
|
|
118
123
|
emitChange,
|
|
119
124
|
}
|
|
@@ -161,7 +166,8 @@ function touchmove(event, ownInstance) {
|
|
|
161
166
|
] : calcValueByOffsetPercent(offset.right, state.min, state.max, state.step)
|
|
162
167
|
state._modelValue = newModelValue
|
|
163
168
|
// 值没有变化不触发事件
|
|
164
|
-
if (newModelValue.toString() !== state.
|
|
169
|
+
if (newModelValue.toString() !== state.__valueStr) {
|
|
170
|
+
state.__valueStr = newModelValue.toString()
|
|
165
171
|
ownInstance.callMethod('updateModelValue', newModelValue)
|
|
166
172
|
}
|
|
167
173
|
return false
|
|
@@ -177,7 +183,8 @@ function touchend(event, ownInstance) {
|
|
|
177
183
|
function calcOffsetPercent(offsetX, width, step) {
|
|
178
184
|
if (offsetX <= 0) return 0
|
|
179
185
|
var percentage = Math.floor((offsetX / width) * 100)
|
|
180
|
-
|
|
186
|
+
var remain = percentage % step
|
|
187
|
+
percentage = percentage - remain + (remain >= step / 2 ? step : 0)
|
|
181
188
|
return percentage
|
|
182
189
|
}
|
|
183
190
|
|
|
@@ -89,7 +89,7 @@ export function useCalendar(props: IncludeRefs<UseCalendarProps>) {
|
|
|
89
89
|
return new Array(date.daysInMonth()).fill(0).map<DayItem>((_, dayIndex) => {
|
|
90
90
|
const day = date.add(dayIndex, 'day').startOf('day')
|
|
91
91
|
const type = getDayType(day)
|
|
92
|
-
const dayItem = {
|
|
92
|
+
const dayItem: DayItem = {
|
|
93
93
|
date: day,
|
|
94
94
|
type,
|
|
95
95
|
text: day.date().toString(),
|
|
@@ -149,7 +149,7 @@ export function useCalendar(props: IncludeRefs<UseCalendarProps>) {
|
|
|
149
149
|
// 最多可选天数
|
|
150
150
|
if (
|
|
151
151
|
typeof state.maxRange !== 'undefined' &&
|
|
152
|
-
Math.abs(selectedItems.value[0].diff(value, 'day'))
|
|
152
|
+
Math.abs(selectedItems.value[0].diff(value, 'day')) >= state.maxRange
|
|
153
153
|
) {
|
|
154
154
|
value = selectedItems.value[0].add(state.maxRange - 1, 'day')
|
|
155
155
|
}
|
|
@@ -173,7 +173,7 @@ export function useCalendar(props: IncludeRefs<UseCalendarProps>) {
|
|
|
173
173
|
const timestamps = Array.isArray(newVal) ? newVal : [newVal]
|
|
174
174
|
onClear()
|
|
175
175
|
timestamps.forEach((timestamp) => {
|
|
176
|
-
onSelect(dayjs(timestamp))
|
|
176
|
+
onSelect(dayjs(timestamp).startOf('day'))
|
|
177
177
|
})
|
|
178
178
|
},
|
|
179
179
|
{
|