Compare commits

..

No commits in common. "bc3d307c4d05e4857afb53e0e749d0e2c7530cc8" and "d235ae65740e6324bcbd09ad4133dc7bdec26f8e" have entirely different histories.

30 changed files with 36 additions and 125 deletions

View File

@ -170,8 +170,7 @@ VantComponent({
defaultDate = [];
}
const [startDay, endDay] = defaultDate || [];
const startDate = getTime(startDay || now);
const start = this.limitDateRange(startDate, minDate, allowSameDay ? startDate : getPrevDay(new Date(maxDate)).getTime());
const start = this.limitDateRange(startDay || now, minDate, getPrevDay(new Date(maxDate)).getTime());
const date = getTime(endDay || now);
const end = this.limitDateRange(date, allowSameDay ? date : getNextDay(new Date(minDate)).getTime());
return [start, end];

View File

@ -14,6 +14,4 @@ export declare function getRect(context: WechatMiniprogram.Component.TrivialInst
export declare function getAllRect(context: WechatMiniprogram.Component.TrivialInstance, selector: string): Promise<WechatMiniprogram.BoundingClientRectCallbackResult[]>;
export declare function groupSetData(context: WechatMiniprogram.Component.TrivialInstance, cb: () => void): void;
export declare function toPromise(promiseLike: Promise<unknown> | unknown): Promise<unknown>;
export declare function addNumber(num1: any, num2: any): number;
export declare const clamp: (num: any, min: any, max: any) => number;
export declare function getCurrentPage<T>(): T & WechatMiniprogram.OptionalInterface<WechatMiniprogram.Page.ILifetime> & WechatMiniprogram.Page.InstanceProperties & WechatMiniprogram.Page.InstanceMethods<WechatMiniprogram.IAnyObject> & WechatMiniprogram.Page.Data<WechatMiniprogram.IAnyObject> & WechatMiniprogram.IAnyObject;

View File

@ -70,13 +70,6 @@ export function toPromise(promiseLike) {
}
return Promise.resolve(promiseLike);
}
// 浮点数精度处理
export function addNumber(num1, num2) {
const cardinal = Math.pow(10, 10);
return Math.round((num1 + num2) * cardinal) / cardinal;
}
// 限制value在[min, max]之间
export const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
export function getCurrentPage() {
const pages = getCurrentPages();
return pages[pages.length - 1];

View File

@ -2,14 +2,13 @@ import { VantComponent } from '../common/component';
import { button } from '../mixins/button';
import { link } from '../mixins/link';
VantComponent({
classes: ['icon-class', 'text-class', 'info-class'],
classes: ['icon-class', 'text-class'],
mixins: [link, button],
props: {
text: String,
dot: Boolean,
info: String,
icon: String,
size: String,
color: String,
classPrefix: {
type: String,

View File

@ -27,12 +27,10 @@
name="{{ icon }}"
dot="{{ dot }}"
info="{{ info }}"
size="{{ size }}"
color="{{ color }}"
class-prefix="{{ classPrefix }}"
class="van-goods-action-icon__icon"
custom-class="icon-class"
info-class="info-class"
/>
<slot wx:else name="icon" />
<text class="text-class">{{ text }}</text>

1
dist/icon/index.js vendored
View File

@ -1,6 +1,5 @@
import { VantComponent } from '../common/component';
VantComponent({
classes: ['info-class'],
props: {
dot: Boolean,
info: null,

View File

@ -9,7 +9,7 @@
wx:if="{{ info !== null || dot }}"
dot="{{ dot }}"
info="{{ info }}"
custom-class="van-icon__info info-class"
custom-class="van-icon__info"
/>
<image
wx:if="{{ computed.isImage(name) }}"

10
dist/slider/index.js vendored
View File

@ -1,7 +1,7 @@
import { VantComponent } from '../common/component';
import { touch } from '../mixins/touch';
import { canIUseModel } from '../common/version';
import { getRect, addUnit, nextTick, addNumber, clamp } from '../common/utils';
import { getRect, addUnit, nextTick } from '../common/utils';
const DRAG_STATUS = {
START: 'start',
MOVING: 'moving',
@ -196,12 +196,8 @@ VantComponent({
return '0%';
},
format(value) {
const min = +this.data.min;
const max = +this.data.max;
const step = +this.data.step;
value = clamp(value, min, max);
const diff = Math.round((value - min) / step) * step;
return addNumber(min, diff);
const { max, min, step } = this.data;
return Math.round(Math.max(min, Math.min(value, max)) / step) * step;
},
},
});

View File

@ -1,25 +1,4 @@
# 更新日志
### [v1.10.20](https://github.com/youzan/vant-weapp/compare/v1.10.19...v1.10.20)
`2023-07-03`
**Bug Fixes**
- calendar: 修复无法选择同一天在 range 模式下 [#5451](https://github.com/youzan/vant-weapp/issues/5451)
- slider: 修复小数精度丢失问题 [#5444](https://github.com/youzan/vant-weapp/issues/5444)
**Document**
- add @inottn and @zhousg to core team [#5453](https://github.com/youzan/vant-weapp/issues/5453)
- popup: 修复文档缺失 close-icon-position 属性 [#5389](https://github.com/youzan/vant-weapp/pull/5389)
- dialog: 修复示例代码错误问题 [#5389](https://github.com/youzan/vant-weapp/pull/5389)
**Feature**
- goods-action-icon: 增加 size 属性 [#5457](https://github.com/youzan/vant-weapp/issues/5457)
- goods-action-icon: 增加 info-class 自定义样式类 [#5457](https://github.com/youzan/vant-weapp/issues/5457)
- icon: 增加 info-class 自定义样式类 [#5458](https://github.com/youzan/vant-weapp/issues/5458)
### [v1.10.19](https://github.com/youzan/vant-weapp/compare/v1.10.18...v1.10.19)
`2023-05-19`

View File

@ -191,8 +191,7 @@ var getTime = function (date) {
defaultDate = [];
}
var _b = defaultDate || [], startDay = _b[0], endDay = _b[1];
var startDate = getTime(startDay || now);
var start = this.limitDateRange(startDate, minDate, allowSameDay ? startDate : (0, utils_1.getPrevDay)(new Date(maxDate)).getTime());
var start = this.limitDateRange(startDay || now, minDate, (0, utils_1.getPrevDay)(new Date(maxDate)).getTime());
var date = getTime(endDay || now);
var end = this.limitDateRange(date, allowSameDay ? date : (0, utils_1.getNextDay)(new Date(minDate)).getTime());
return [start, end];

View File

@ -14,6 +14,4 @@ export declare function getRect(context: WechatMiniprogram.Component.TrivialInst
export declare function getAllRect(context: WechatMiniprogram.Component.TrivialInstance, selector: string): Promise<WechatMiniprogram.BoundingClientRectCallbackResult[]>;
export declare function groupSetData(context: WechatMiniprogram.Component.TrivialInstance, cb: () => void): void;
export declare function toPromise(promiseLike: Promise<unknown> | unknown): Promise<unknown>;
export declare function addNumber(num1: any, num2: any): number;
export declare const clamp: (num: any, min: any, max: any) => number;
export declare function getCurrentPage<T>(): T & WechatMiniprogram.OptionalInterface<WechatMiniprogram.Page.ILifetime> & WechatMiniprogram.Page.InstanceProperties & WechatMiniprogram.Page.InstanceMethods<WechatMiniprogram.IAnyObject> & WechatMiniprogram.Page.Data<WechatMiniprogram.IAnyObject> & WechatMiniprogram.IAnyObject;

View File

@ -1,6 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCurrentPage = exports.clamp = exports.addNumber = exports.toPromise = exports.groupSetData = exports.getAllRect = exports.getRect = exports.pickExclude = exports.requestAnimationFrame = exports.addUnit = exports.nextTick = exports.range = exports.getSystemInfoSync = exports.isDef = void 0;
exports.getCurrentPage = exports.toPromise = exports.groupSetData = exports.getAllRect = exports.getRect = exports.pickExclude = exports.requestAnimationFrame = exports.addUnit = exports.nextTick = exports.range = exports.getSystemInfoSync = exports.isDef = void 0;
var validator_1 = require("./validator");
var version_1 = require("./version");
var validator_2 = require("./validator");
@ -90,15 +90,6 @@ function toPromise(promiseLike) {
return Promise.resolve(promiseLike);
}
exports.toPromise = toPromise;
// 浮点数精度处理
function addNumber(num1, num2) {
var cardinal = Math.pow(10, 10);
return Math.round((num1 + num2) * cardinal) / cardinal;
}
exports.addNumber = addNumber;
// 限制value在[min, max]之间
var clamp = function (num, min, max) { return Math.min(Math.max(num, min), max); };
exports.clamp = clamp;
function getCurrentPage() {
var pages = getCurrentPages();
return pages[pages.length - 1];

View File

@ -4,14 +4,13 @@ var component_1 = require("../common/component");
var button_1 = require("../mixins/button");
var link_1 = require("../mixins/link");
(0, component_1.VantComponent)({
classes: ['icon-class', 'text-class', 'info-class'],
classes: ['icon-class', 'text-class'],
mixins: [link_1.link, button_1.button],
props: {
text: String,
dot: Boolean,
info: String,
icon: String,
size: String,
color: String,
classPrefix: {
type: String,

View File

@ -27,12 +27,10 @@
name="{{ icon }}"
dot="{{ dot }}"
info="{{ info }}"
size="{{ size }}"
color="{{ color }}"
class-prefix="{{ classPrefix }}"
class="van-goods-action-icon__icon"
custom-class="icon-class"
info-class="info-class"
/>
<slot wx:else name="icon" />
<text class="text-class">{{ text }}</text>

View File

@ -2,7 +2,6 @@
Object.defineProperty(exports, "__esModule", { value: true });
var component_1 = require("../common/component");
(0, component_1.VantComponent)({
classes: ['info-class'],
props: {
dot: Boolean,
info: null,

View File

@ -9,7 +9,7 @@
wx:if="{{ info !== null || dot }}"
dot="{{ dot }}"
info="{{ info }}"
custom-class="van-icon__info info-class"
custom-class="van-icon__info"
/>
<image
wx:if="{{ computed.isImage(name) }}"

View File

@ -195,12 +195,8 @@ var DRAG_STATUS = {
return '0%';
},
format: function (value) {
var min = +this.data.min;
var max = +this.data.max;
var step = +this.data.step;
value = (0, utils_1.clamp)(value, min, max);
var diff = Math.round((value - min) / step) * step;
return (0, utils_1.addNumber)(min, diff);
var _a = this.data, max = _a.max, min = _a.min, step = _a.step;
return Math.round(Math.max(min, Math.min(value, max)) / step) * step;
},
},
});

View File

@ -1,6 +1,6 @@
{
"name": "@vant/weapp",
"version": "1.10.20",
"version": "1.10.19",
"author": "vant-ui",
"license": "MIT",
"miniprogram": "lib",

View File

@ -211,14 +211,14 @@ VantComponent({
const [startDay, endDay] = defaultDate || [];
const startDate = getTime(startDay || now);
const start = this.limitDateRange(
startDate,
startDay || now,
minDate,
allowSameDay ? startDate : getPrevDay(new Date(maxDate)).getTime()
getPrevDay(new Date(maxDate)).getTime()
);
const date = getTime(endDay || now);
const end = this.limitDateRange(
date,
allowSameDay ? date : getNextDay(new Date(minDate)).getTime()

View File

@ -96,15 +96,6 @@ export function toPromise(promiseLike: Promise<unknown> | unknown) {
return Promise.resolve(promiseLike);
}
// 浮点数精度处理
export function addNumber(num1, num2) {
const cardinal = 10 ** 10;
return Math.round((num1 + num2) * cardinal) / cardinal;
}
// 限制value在[min, max]之间
export const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
export function getCurrentPage<T>() {
const pages = getCurrentPages();
return pages[pages.length - 1] as T & WechatMiniprogram.Page.TrivialInstance;

View File

@ -3,7 +3,7 @@ import { button } from '../mixins/button';
import { link } from '../mixins/link';
VantComponent({
classes: ['icon-class', 'text-class', 'info-class'],
classes: ['icon-class', 'text-class'],
mixins: [link, button],
@ -12,7 +12,6 @@ VantComponent({
dot: Boolean,
info: String,
icon: String,
size: String,
color: String,
classPrefix: {
type: String,

View File

@ -27,12 +27,10 @@
name="{{ icon }}"
dot="{{ dot }}"
info="{{ info }}"
size="{{ size }}"
color="{{ color }}"
class-prefix="{{ classPrefix }}"
class="van-goods-action-icon__icon"
custom-class="icon-class"
info-class="info-class"
/>
<slot wx:else name="icon" />
<text class="text-class">{{ text }}</text>

View File

@ -105,7 +105,6 @@ Page({
| icon | 图标类型,可选值见`icon`组件 | _string_ | - |
| info | 图标右上角提示信息 | _string \| number_ | - |
| color `v1.10.15` | 图标颜色 | _string_ | `inherit` |
| size | 图标大小,如 20px2em默认单位为px | _string \| number_ | - |
| url | 点击后跳转的链接地址 | _string_ | - |
| link-type | 链接跳转类型,可选值为 `redirectTo` `switchTab` `reLaunch` | _string_ | `navigateTo` |
| id | 标识符 | _string_ | - |
@ -168,7 +167,6 @@ Page({
| ---------- | ---------- |
| icon-class | 图标样式类 |
| text-class | 文字样式类 |
| info-class `v1.10.20` | 图标右上角文字样式类 |
### GoodsActionButton 外部样式类

View File

@ -60,7 +60,6 @@ exports[`should render demo and match snapshot 1`] = `
<van-icon
class="van-goods-action-icon__icon"
customClass="icon-class"
infoClass="info-class"
>
<wx-view
class="custom-class van-icon van-icon-chat-o"
@ -68,7 +67,7 @@ exports[`should render demo and match snapshot 1`] = `
bind:tap="onClick"
>
<van-info
customClass="van-icon__info info-class"
customClass="van-icon__info"
/>
</wx-view>
</van-icon>
@ -126,7 +125,6 @@ exports[`should render demo and match snapshot 1`] = `
<van-icon
class="van-goods-action-icon__icon"
customClass="icon-class"
infoClass="info-class"
>
<wx-view
class="custom-class van-icon van-icon-cart-o"
@ -134,7 +132,7 @@ exports[`should render demo and match snapshot 1`] = `
bind:tap="onClick"
>
<van-info
customClass="van-icon__info info-class"
customClass="van-icon__info"
/>
</wx-view>
</van-icon>
@ -309,7 +307,6 @@ exports[`should render demo and match snapshot 1`] = `
<van-icon
class="van-goods-action-icon__icon"
customClass="icon-class"
infoClass="info-class"
>
<wx-view
class="custom-class van-icon van-icon-chat-o"
@ -317,7 +314,7 @@ exports[`should render demo and match snapshot 1`] = `
bind:tap="onClick"
>
<van-info
customClass="van-icon__info info-class"
customClass="van-icon__info"
>
<wx-view
class="van-info van-info van-info--dot custom-class"
@ -380,7 +377,6 @@ exports[`should render demo and match snapshot 1`] = `
<van-icon
class="van-goods-action-icon__icon"
customClass="icon-class"
infoClass="info-class"
>
<wx-view
class="custom-class van-icon van-icon-cart-o"
@ -388,7 +384,7 @@ exports[`should render demo and match snapshot 1`] = `
bind:tap="onClick"
>
<van-info
customClass="van-icon__info info-class"
customClass="van-icon__info"
>
<wx-view
class="van-info van-info custom-class"
@ -451,7 +447,6 @@ exports[`should render demo and match snapshot 1`] = `
<van-icon
class="van-goods-action-icon__icon"
customClass="icon-class"
infoClass="info-class"
>
<wx-view
class="custom-class van-icon van-icon-shop-o"
@ -459,7 +454,7 @@ exports[`should render demo and match snapshot 1`] = `
bind:tap="onClick"
>
<van-info
customClass="van-icon__info info-class"
customClass="van-icon__info"
/>
</wx-view>
</van-icon>
@ -630,7 +625,6 @@ exports[`should render demo and match snapshot 1`] = `
<van-icon
class="van-goods-action-icon__icon"
customClass="icon-class"
infoClass="info-class"
>
<wx-view
class="custom-class van-icon van-icon-chat-o"
@ -638,7 +632,7 @@ exports[`should render demo and match snapshot 1`] = `
bind:tap="onClick"
>
<van-info
customClass="van-icon__info info-class"
customClass="van-icon__info"
/>
</wx-view>
</van-icon>
@ -694,7 +688,6 @@ exports[`should render demo and match snapshot 1`] = `
<van-icon
class="van-goods-action-icon__icon"
customClass="icon-class"
infoClass="info-class"
>
<wx-view
class="custom-class van-icon van-icon-shop-o"
@ -702,7 +695,7 @@ exports[`should render demo and match snapshot 1`] = `
bind:tap="onClick"
>
<van-info
customClass="van-icon__info info-class"
customClass="van-icon__info"
/>
</wx-view>
</van-icon>
@ -873,7 +866,6 @@ exports[`should render demo and match snapshot 1`] = `
<van-icon
class="van-goods-action-icon__icon"
customClass="icon-class"
infoClass="info-class"
>
<wx-view
class="custom-class van-icon van-icon-chat-o"
@ -881,7 +873,7 @@ exports[`should render demo and match snapshot 1`] = `
bind:tap="onClick"
>
<van-info
customClass="van-icon__info info-class"
customClass="van-icon__info"
/>
</wx-view>
</van-icon>
@ -937,7 +929,6 @@ exports[`should render demo and match snapshot 1`] = `
<van-icon
class="van-goods-action-icon__icon"
customClass="icon-class"
infoClass="info-class"
>
<wx-view
class="custom-class van-icon van-icon-shop-o"
@ -945,7 +936,7 @@ exports[`should render demo and match snapshot 1`] = `
bind:tap="onClick"
>
<van-info
customClass="van-icon__info info-class"
customClass="van-icon__info"
/>
</wx-view>
</van-icon>

View File

@ -1174,7 +1174,7 @@ exports[`should render demo and match snapshot 1`] = `
bind:tap="onClick"
>
<van-info
customClass="van-icon__info info-class"
customClass="van-icon__info"
>
<wx-view
class="van-info van-info van-info--dot custom-class"
@ -1216,7 +1216,7 @@ exports[`should render demo and match snapshot 1`] = `
bind:tap="onClick"
>
<van-info
customClass="van-icon__info info-class"
customClass="van-icon__info"
>
<wx-view
class="van-info van-info custom-class"

View File

@ -86,7 +86,7 @@
| dot | 是否显示图标右上角小红点 | _boolean_ | `false` |
| info | 图标右上角文字提示 | _string \| number_ | - |
| color | 图标颜色 | _string_ | `inherit` |
| size `v1.10.20` | 图标大小,如 `20px``2em`,默认单位为`px` | _string \| number_ | `inherit` |
| size | 图标大小,如 `20px``2em`,默认单位为`px` | _string \| number_ | `inherit` |
| custom-style | 自定义样式 | _string_ | - |
| class-prefix | 类名前缀 | _string_ | `van-icon` |
@ -101,7 +101,6 @@
| 类名 | 说明 |
| ------------ | ------------ |
| custom-class | 根节点样式类 |
| info-class | 图标右上角文字样式类 |
## 常见问题

View File

@ -1,7 +1,6 @@
import { VantComponent } from '../common/component';
VantComponent({
classes: ['info-class'],
props: {
dot: Boolean,
info: null,

View File

@ -9,7 +9,7 @@
wx:if="{{ info !== null || dot }}"
dot="{{ dot }}"
info="{{ info }}"
custom-class="van-icon__info info-class"
custom-class="van-icon__info"
/>
<image
wx:if="{{ computed.isImage(name) }}"

View File

@ -199,7 +199,7 @@ exports[`should render demo and match snapshot 1`] = `
bind:tap="onClick"
>
<van-info
customClass="van-icon__info info-class"
customClass="van-icon__info"
>
<wx-view
class="van-info van-info van-info--dot custom-class"
@ -228,7 +228,7 @@ exports[`should render demo and match snapshot 1`] = `
bind:tap="onClick"
>
<van-info
customClass="van-icon__info info-class"
customClass="van-icon__info"
>
<wx-view
class="van-info van-info custom-class"
@ -257,7 +257,7 @@ exports[`should render demo and match snapshot 1`] = `
bind:tap="onClick"
>
<van-info
customClass="van-icon__info info-class"
customClass="van-icon__info"
>
<wx-view
class="van-info van-info custom-class"

View File

@ -1,7 +1,7 @@
import { VantComponent } from '../common/component';
import { touch } from '../mixins/touch';
import { canIUseModel } from '../common/version';
import { getRect, addUnit, nextTick, addNumber, clamp } from '../common/utils';
import { getRect, addUnit, nextTick } from '../common/utils';
type SliderValue = number | [number, number];
@ -238,13 +238,8 @@ VantComponent({
},
format(value: number) {
const min = +this.data.min;
const max = +this.data.max;
const step = +this.data.step;
value = clamp(value, min, max);
const diff = Math.round((value - min) / step) * step;
return addNumber(min, diff);
const { max, min, step } = this.data;
return Math.round(Math.max(min, Math.min(value, max)) / step) * step;
},
},
});