papayaui 0.2.7 → 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.
- package/components/calendar/props.ts +1 -1
- package/components/search/props.ts +2 -1
- package/components/search/search.vue +1 -0
- package/components/slider/props.ts +6 -0
- package/components/slider/slider.scss +1 -1
- package/components/slider/slider.vue +12 -5
- package/core/useCalendar/index.ts +3 -3
- package/package.json +1 -1
- package/utils/object.ts +12 -0
|
@@ -165,7 +165,7 @@ export const calendarWrapperEmits = {
|
|
|
165
165
|
export const calendarEmits = {
|
|
166
166
|
...popupEmits,
|
|
167
167
|
confirm: (value: CalendarValue) => isDate(value) || isArray(value),
|
|
168
|
-
select: (value:
|
|
168
|
+
select: (value: Date) => isDate(value),
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
export type CalendarProps = ExtractPropTypes<typeof calendarProps>
|
|
@@ -51,7 +51,8 @@ export const searchEmits = {
|
|
|
51
51
|
'update:modelValue': (value: string) => isString(value),
|
|
52
52
|
change: (value: string) => isString(value),
|
|
53
53
|
confirm: (value: EventDetail<{ value: string }>) => isObject(value),
|
|
54
|
-
|
|
54
|
+
focus: (_value: unknown) => true,
|
|
55
|
+
blur: (_value: unknown) => true,
|
|
55
56
|
clear: () => true,
|
|
56
57
|
'click-input': () => true,
|
|
57
58
|
}
|
|
@@ -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
|
{
|
package/package.json
CHANGED
package/utils/object.ts
CHANGED
|
@@ -10,6 +10,18 @@ export const pick = <T extends object, U extends keyof T>(object: T, keys: Array
|
|
|
10
10
|
}, {} as Pick<T, U>)
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* @description 反向版 pick,这个方法返回忽略属性之外的自身和继承的可枚举属性
|
|
15
|
+
*/
|
|
16
|
+
export const omit = <T extends object, U extends keyof T>(object: T, keys: Array<U>) => {
|
|
17
|
+
return (Object.keys(object) as U[]).reduce((newObject, key) => {
|
|
18
|
+
if (!keys.includes(key)) {
|
|
19
|
+
newObject[key] = object[key]
|
|
20
|
+
}
|
|
21
|
+
return newObject
|
|
22
|
+
}, {} as Pick<T, U>)
|
|
23
|
+
}
|
|
24
|
+
|
|
13
25
|
/**
|
|
14
26
|
* @description 递归合并 sources 来源对象自身和继承的可枚举属性到 object 目标对象
|
|
15
27
|
*/
|