Compare commits

...

9 Commits

Author SHA1 Message Date
landluck
bc3d307c4d docs(changelog): @vant/weapp 1.10.20 2023-07-03 19:09:22 +08:00
landluck
a3117538b3 release: 1.10.20 2023-07-03 17:44:59 +08:00
landluck
d72580fe7d build: compile 1.10.20 2023-07-03 17:44:54 +08:00
johnsonwong666
3d1d27641b
feat(icon): add_icon_info_class (#5458) 2023-07-03 17:08:16 +08:00
johnsonwong666
22acb8ddbc
feat(goods-action-icon): add size prop (#5457) 2023-07-03 17:06:35 +08:00
landluck
35d8346647
Merge pull request #5445 from johnsonwong666/hotfix/fix_issue_5444
fix(Slider): fix decimal value
2023-07-03 15:10:28 +08:00
landluck
a232ec525f
Merge pull request #5456 from johnsonwong666/hotfix/fix_issue_5451
fix(Calendar): fix startDay with range type and allow same day
2023-07-03 15:09:23 +08:00
johnsonwong666
35b199f9f6 fix(Calendar): fix startDay with range type and allow same day 2023-06-26 16:00:43 +08:00
johnsonwong666
e8ed007d89 fix(Slider): fix decimal value 2023-06-19 20:26:53 +08:00
30 changed files with 125 additions and 36 deletions

View File

@ -170,7 +170,8 @@ VantComponent({
defaultDate = [];
}
const [startDay, endDay] = defaultDate || [];
const start = this.limitDateRange(startDay || now, minDate, getPrevDay(new Date(maxDate)).getTime());
const startDate = getTime(startDay || now);
const start = this.limitDateRange(startDate, minDate, allowSameDay ? startDate : 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,4 +14,6 @@ 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,6 +70,13 @@ 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,13 +2,14 @@ import { VantComponent } from '../common/component';
import { button } from '../mixins/button';
import { link } from '../mixins/link';
VantComponent({
classes: ['icon-class', 'text-class'],
classes: ['icon-class', 'text-class', 'info-class'],
mixins: [link, button],
props: {
text: String,
dot: Boolean,
info: String,
icon: String,
size: String,
color: String,
classPrefix: {
type: String,

View File

@ -27,10 +27,12 @@
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,5 +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"
custom-class="van-icon__info info-class"
/>
<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 } from '../common/utils';
import { getRect, addUnit, nextTick, addNumber, clamp } from '../common/utils';
const DRAG_STATUS = {
START: 'start',
MOVING: 'moving',
@ -196,8 +196,12 @@ VantComponent({
return '0%';
},
format(value) {
const { max, min, step } = this.data;
return Math.round(Math.max(min, Math.min(value, max)) / step) * step;
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);
},
},
});

View File

@ -1,4 +1,25 @@
# 更新日志
### [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,7 +191,8 @@ var getTime = function (date) {
defaultDate = [];
}
var _b = defaultDate || [], startDay = _b[0], endDay = _b[1];
var start = this.limitDateRange(startDay || now, minDate, (0, utils_1.getPrevDay)(new Date(maxDate)).getTime());
var startDate = getTime(startDay || now);
var start = this.limitDateRange(startDate, minDate, allowSameDay ? startDate : (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,4 +14,6 @@ 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.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.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;
var validator_1 = require("./validator");
var version_1 = require("./version");
var validator_2 = require("./validator");
@ -90,6 +90,15 @@ 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,13 +4,14 @@ 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'],
classes: ['icon-class', 'text-class', 'info-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,10 +27,12 @@
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,6 +2,7 @@
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"
custom-class="van-icon__info info-class"
/>
<image
wx:if="{{ computed.isImage(name) }}"

View File

@ -195,8 +195,12 @@ var DRAG_STATUS = {
return '0%';
},
format: function (value) {
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;
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);
},
},
});

View File

@ -1,6 +1,6 @@
{
"name": "@vant/weapp",
"version": "1.10.19",
"version": "1.10.20",
"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(
startDay || now,
startDate,
minDate,
getPrevDay(new Date(maxDate)).getTime()
allowSameDay ? startDate : 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,6 +96,15 @@ 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'],
classes: ['icon-class', 'text-class', 'info-class'],
mixins: [link, button],
@ -12,6 +12,7 @@ VantComponent({
dot: Boolean,
info: String,
icon: String,
size: String,
color: String,
classPrefix: {
type: String,

View File

@ -27,10 +27,12 @@
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,6 +105,7 @@ 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_ | - |
@ -167,6 +168,7 @@ Page({
| ---------- | ---------- |
| icon-class | 图标样式类 |
| text-class | 文字样式类 |
| info-class `v1.10.20` | 图标右上角文字样式类 |
### GoodsActionButton 外部样式类

View File

@ -60,6 +60,7 @@ 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"
@ -67,7 +68,7 @@ exports[`should render demo and match snapshot 1`] = `
bind:tap="onClick"
>
<van-info
customClass="van-icon__info"
customClass="van-icon__info info-class"
/>
</wx-view>
</van-icon>
@ -125,6 +126,7 @@ 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"
@ -132,7 +134,7 @@ exports[`should render demo and match snapshot 1`] = `
bind:tap="onClick"
>
<van-info
customClass="van-icon__info"
customClass="van-icon__info info-class"
/>
</wx-view>
</van-icon>
@ -307,6 +309,7 @@ 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"
@ -314,7 +317,7 @@ exports[`should render demo and match snapshot 1`] = `
bind:tap="onClick"
>
<van-info
customClass="van-icon__info"
customClass="van-icon__info info-class"
>
<wx-view
class="van-info van-info van-info--dot custom-class"
@ -377,6 +380,7 @@ 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"
@ -384,7 +388,7 @@ exports[`should render demo and match snapshot 1`] = `
bind:tap="onClick"
>
<van-info
customClass="van-icon__info"
customClass="van-icon__info info-class"
>
<wx-view
class="van-info van-info custom-class"
@ -447,6 +451,7 @@ 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"
@ -454,7 +459,7 @@ exports[`should render demo and match snapshot 1`] = `
bind:tap="onClick"
>
<van-info
customClass="van-icon__info"
customClass="van-icon__info info-class"
/>
</wx-view>
</van-icon>
@ -625,6 +630,7 @@ 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"
@ -632,7 +638,7 @@ exports[`should render demo and match snapshot 1`] = `
bind:tap="onClick"
>
<van-info
customClass="van-icon__info"
customClass="van-icon__info info-class"
/>
</wx-view>
</van-icon>
@ -688,6 +694,7 @@ 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"
@ -695,7 +702,7 @@ exports[`should render demo and match snapshot 1`] = `
bind:tap="onClick"
>
<van-info
customClass="van-icon__info"
customClass="van-icon__info info-class"
/>
</wx-view>
</van-icon>
@ -866,6 +873,7 @@ 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"
@ -873,7 +881,7 @@ exports[`should render demo and match snapshot 1`] = `
bind:tap="onClick"
>
<van-info
customClass="van-icon__info"
customClass="van-icon__info info-class"
/>
</wx-view>
</van-icon>
@ -929,6 +937,7 @@ 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"
@ -936,7 +945,7 @@ exports[`should render demo and match snapshot 1`] = `
bind:tap="onClick"
>
<van-info
customClass="van-icon__info"
customClass="van-icon__info info-class"
/>
</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"
customClass="van-icon__info info-class"
>
<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"
customClass="van-icon__info info-class"
>
<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 | 图标大小,如 `20px``2em`,默认单位为`px` | _string \| number_ | `inherit` |
| size `v1.10.20` | 图标大小,如 `20px``2em`,默认单位为`px` | _string \| number_ | `inherit` |
| custom-style | 自定义样式 | _string_ | - |
| class-prefix | 类名前缀 | _string_ | `van-icon` |
@ -101,6 +101,7 @@
| 类名 | 说明 |
| ------------ | ------------ |
| custom-class | 根节点样式类 |
| info-class | 图标右上角文字样式类 |
## 常见问题

View File

@ -1,6 +1,7 @@
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"
custom-class="van-icon__info info-class"
/>
<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"
customClass="van-icon__info info-class"
>
<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"
customClass="van-icon__info info-class"
>
<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"
customClass="van-icon__info info-class"
>
<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 } from '../common/utils';
import { getRect, addUnit, nextTick, addNumber, clamp } from '../common/utils';
type SliderValue = number | [number, number];
@ -238,8 +238,13 @@ VantComponent({
},
format(value: number) {
const { max, min, step } = this.data;
return Math.round(Math.max(min, Math.min(value, max)) / step) * step;
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);
},
},
});