mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
build: compile 1.3.2
This commit is contained in:
parent
5479631403
commit
8aac1ebed0
8
dist/button/index.js
vendored
8
dist/button/index.js
vendored
@ -1,13 +1,19 @@
|
||||
import { VantComponent } from '../common/component';
|
||||
import { button } from '../mixins/button';
|
||||
import { openType } from '../mixins/open-type';
|
||||
import { canIUseFormFieldButton } from '../common/version';
|
||||
const mixins = [button, openType];
|
||||
if (canIUseFormFieldButton()) {
|
||||
mixins.push('wx://form-field-button');
|
||||
}
|
||||
VantComponent({
|
||||
mixins: [button, openType],
|
||||
mixins,
|
||||
classes: ['hover-class', 'loading-class'],
|
||||
data: {
|
||||
baseStyle: '',
|
||||
},
|
||||
props: {
|
||||
formType: String,
|
||||
icon: String,
|
||||
classPrefix: {
|
||||
type: String,
|
||||
|
1
dist/button/index.wxml
vendored
1
dist/button/index.wxml
vendored
@ -6,6 +6,7 @@
|
||||
class="custom-class {{ utils.bem('button', [type, size, { block, round, plain, square, loading, disabled, hairline, unclickable: disabled || loading }]) }} {{ hairline ? 'van-hairline--surround' : '' }}"
|
||||
hover-class="van-button--active hover-class"
|
||||
lang="{{ lang }}"
|
||||
form-type="{{ formType }}"
|
||||
style="{{ baseStyle }} {{ customStyle }}"
|
||||
open-type="{{ disabled ? '' : openType }}"
|
||||
business-id="{{ businessId }}"
|
||||
|
5
dist/calendar/index.js
vendored
5
dist/calendar/index.js
vendored
@ -276,7 +276,10 @@ VantComponent({
|
||||
return true;
|
||||
},
|
||||
onConfirm() {
|
||||
if (this.data.type === 'range' && !this.checkRange()) {
|
||||
if (
|
||||
this.data.type === 'range' &&
|
||||
!this.checkRange(this.data.currentDate)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
wx.nextTick(() => {
|
||||
|
6
dist/circle/canvas.d.ts
vendored
Normal file
6
dist/circle/canvas.d.ts
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
/// <reference types="miniprogram-api-typings" />
|
||||
declare type CanvasContext = WechatMiniprogram.CanvasContext;
|
||||
export declare function adaptor(
|
||||
ctx: CanvasRenderingContext2D
|
||||
): CanvasContext & CanvasRenderingContext2D;
|
||||
export {};
|
43
dist/circle/canvas.js
vendored
Normal file
43
dist/circle/canvas.js
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
export function adaptor(ctx) {
|
||||
// @ts-ignore
|
||||
return Object.assign(ctx, {
|
||||
setStrokeStyle(val) {
|
||||
ctx.strokeStyle = val;
|
||||
},
|
||||
setLineWidth(val) {
|
||||
ctx.lineWidth = val;
|
||||
},
|
||||
setLineCap(val) {
|
||||
ctx.lineCap = val;
|
||||
},
|
||||
setFillStyle(val) {
|
||||
ctx.fillStyle = val;
|
||||
},
|
||||
setFontSize(val) {
|
||||
ctx.font = String(val);
|
||||
},
|
||||
setGlobalAlpha(val) {
|
||||
ctx.globalAlpha = val;
|
||||
},
|
||||
setLineJoin(val) {
|
||||
ctx.lineJoin = val;
|
||||
},
|
||||
setTextAlign(val) {
|
||||
ctx.textAlign = val;
|
||||
},
|
||||
setMiterLimit(val) {
|
||||
ctx.miterLimit = val;
|
||||
},
|
||||
setShadow(offsetX, offsetY, blur, color) {
|
||||
ctx.shadowOffsetX = offsetX;
|
||||
ctx.shadowOffsetY = offsetY;
|
||||
ctx.shadowBlur = blur;
|
||||
ctx.shadowColor = color;
|
||||
},
|
||||
setTextBaseline(val) {
|
||||
ctx.textBaseline = val;
|
||||
},
|
||||
createCircularGradient() {},
|
||||
draw() {},
|
||||
});
|
||||
}
|
73
dist/circle/index.js
vendored
73
dist/circle/index.js
vendored
@ -1,6 +1,7 @@
|
||||
import { VantComponent } from '../common/component';
|
||||
import { isObj } from '../common/utils';
|
||||
import { BLUE, WHITE } from '../common/color';
|
||||
import { adaptor } from './canvas';
|
||||
function format(rate) {
|
||||
return Math.min(Math.max(rate, 0), 100);
|
||||
}
|
||||
@ -26,6 +27,9 @@ VantComponent({
|
||||
size: {
|
||||
type: Number,
|
||||
value: 100,
|
||||
observer() {
|
||||
this.drawCircle(this.currentValue);
|
||||
},
|
||||
},
|
||||
fill: String,
|
||||
layerColor: {
|
||||
@ -55,28 +59,45 @@ VantComponent({
|
||||
},
|
||||
methods: {
|
||||
getContext() {
|
||||
if (!this.ctx) {
|
||||
this.ctx = wx.createCanvasContext('van-circle', this);
|
||||
const { type } = this.data;
|
||||
if (type === '') {
|
||||
const ctx = wx.createCanvasContext('van-circle', this);
|
||||
return Promise.resolve(ctx);
|
||||
}
|
||||
return this.ctx;
|
||||
const dpr = wx.getSystemInfoSync().pixelRatio;
|
||||
return new Promise((resolve) => {
|
||||
wx.createSelectorQuery()
|
||||
.in(this)
|
||||
.select('#van-circle')
|
||||
.fields({ node: true, size: true })
|
||||
.exec((res) => {
|
||||
const canvas = res[0].node;
|
||||
const ctx = canvas.getContext(type);
|
||||
canvas.width = res[0].width * dpr;
|
||||
canvas.height = res[0].height * dpr;
|
||||
ctx.scale(dpr, dpr);
|
||||
resolve(adaptor(ctx));
|
||||
});
|
||||
});
|
||||
},
|
||||
setHoverColor() {
|
||||
const { color, size, type } = this.data;
|
||||
const context = type ? this.getContext(type) : this.getContext();
|
||||
const { color, size } = this.data;
|
||||
let hoverColor = color;
|
||||
if (isObj(color)) {
|
||||
const LinearColor = context.createLinearGradient(size, 0, 0, 0);
|
||||
Object.keys(color)
|
||||
.sort((a, b) => parseFloat(a) - parseFloat(b))
|
||||
.map((key) =>
|
||||
LinearColor.addColorStop(parseFloat(key) / 100, color[key])
|
||||
);
|
||||
hoverColor = LinearColor;
|
||||
}
|
||||
this.setData({ hoverColor });
|
||||
this.getContext().then((context) => {
|
||||
if (isObj(color)) {
|
||||
const LinearColor = context.createLinearGradient(size, 0, 0, 0);
|
||||
Object.keys(color)
|
||||
.sort((a, b) => parseFloat(a) - parseFloat(b))
|
||||
.map((key) =>
|
||||
LinearColor.addColorStop(parseFloat(key) / 100, color[key])
|
||||
);
|
||||
hoverColor = LinearColor;
|
||||
}
|
||||
this.setData({ hoverColor });
|
||||
});
|
||||
},
|
||||
presetCanvas(context, strokeStyle, beginAngle, endAngle, fill) {
|
||||
const { strokeWidth, lineCap, clockwise, size } = this.data;
|
||||
const { strokeWidth, lineCap, clockwise, size, type } = this.data;
|
||||
const position = size / 2;
|
||||
const radius = position - strokeWidth / 2;
|
||||
context.setStrokeStyle(strokeStyle);
|
||||
@ -104,15 +125,16 @@ VantComponent({
|
||||
this.presetCanvas(context, hoverColor, BEGIN_ANGLE, endAngle);
|
||||
},
|
||||
drawCircle(currentValue) {
|
||||
const { size, type } = this.data;
|
||||
const context = type ? this.getContext(type) : this.getContext();
|
||||
context.clearRect(0, 0, size, size);
|
||||
this.renderLayerCircle(context);
|
||||
const formatValue = format(currentValue);
|
||||
if (formatValue !== 0) {
|
||||
this.renderHoverCircle(context, formatValue);
|
||||
}
|
||||
context.draw();
|
||||
const { size } = this.data;
|
||||
this.getContext().then((context) => {
|
||||
context.clearRect(0, 0, size, size);
|
||||
this.renderLayerCircle(context);
|
||||
const formatValue = format(currentValue);
|
||||
if (formatValue !== 0) {
|
||||
this.renderHoverCircle(context, formatValue);
|
||||
}
|
||||
context.draw();
|
||||
});
|
||||
},
|
||||
reRender() {
|
||||
// tofector 动画暂时没有想到好的解决方案
|
||||
@ -149,7 +171,6 @@ VantComponent({
|
||||
this.drawCircle(value);
|
||||
},
|
||||
destroyed() {
|
||||
this.ctx = null;
|
||||
this.clearInterval();
|
||||
},
|
||||
});
|
||||
|
4
dist/circle/index.wxml
vendored
4
dist/circle/index.wxml
vendored
@ -1,9 +1,9 @@
|
||||
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||
|
||||
<view class="van-circle">
|
||||
<canvas class="van-circle__canvas" style="width: {{ utils.addUnit(size) }};height:{{ utils.addUnit(size) }}" canvas-id="van-circle"></canvas>
|
||||
<canvas class="van-circle__canvas" type="{{ type }}" style="width: {{ utils.addUnit(size) }};height:{{ utils.addUnit(size) }}" id="van-circle" canvas-id="van-circle"></canvas>
|
||||
<view wx:if="{{ !text }}" class="van-circle__text">
|
||||
<slot></slot>
|
||||
</view>
|
||||
<cover-view wx:else class="van-circle__text">{{ text }}</cover-view>
|
||||
</view>
|
||||
</view>
|
||||
|
1
dist/common/version.d.ts
vendored
1
dist/common/version.d.ts
vendored
@ -1 +1,2 @@
|
||||
export declare function canIUseModel(): boolean;
|
||||
export declare function canIUseFormFieldButton(): boolean;
|
||||
|
4
dist/common/version.js
vendored
4
dist/common/version.js
vendored
@ -25,3 +25,7 @@ export function canIUseModel() {
|
||||
const system = getSystemInfoSync();
|
||||
return compareVersion(system.SDKVersion, '2.9.3') >= 0;
|
||||
}
|
||||
export function canIUseFormFieldButton() {
|
||||
const system = getSystemInfoSync();
|
||||
return compareVersion(system.SDKVersion, '2.10.3') >= 0;
|
||||
}
|
||||
|
16
dist/grid-item/index.js
vendored
16
dist/grid-item/index.js
vendored
@ -13,6 +13,7 @@ VantComponent({
|
||||
icon: String,
|
||||
dot: Boolean,
|
||||
info: null,
|
||||
badge: null,
|
||||
text: String,
|
||||
useSlot: Boolean,
|
||||
},
|
||||
@ -28,7 +29,16 @@ VantComponent({
|
||||
return;
|
||||
}
|
||||
const { data, children } = this.parent;
|
||||
const { columnNum, border, square, gutter, clickable, center } = data;
|
||||
const {
|
||||
columnNum,
|
||||
border,
|
||||
square,
|
||||
gutter,
|
||||
clickable,
|
||||
center,
|
||||
direction,
|
||||
iconSize,
|
||||
} = data;
|
||||
const width = `${100 / columnNum}%`;
|
||||
const styleWrapper = [];
|
||||
styleWrapper.push(`width: ${width}`);
|
||||
@ -39,7 +49,7 @@ VantComponent({
|
||||
const gutterValue = addUnit(gutter);
|
||||
styleWrapper.push(`padding-right: ${gutterValue}`);
|
||||
const index = children.indexOf(this);
|
||||
if (index >= columnNum) {
|
||||
if (index >= columnNum && !square) {
|
||||
styleWrapper.push(`margin-top: ${gutterValue}`);
|
||||
}
|
||||
}
|
||||
@ -60,6 +70,8 @@ VantComponent({
|
||||
square,
|
||||
gutter,
|
||||
clickable,
|
||||
direction,
|
||||
iconSize,
|
||||
});
|
||||
},
|
||||
onClick() {
|
||||
|
4
dist/grid-item/index.wxml
vendored
4
dist/grid-item/index.wxml
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
<view class="custom-class {{ utils.bem('grid-item', { square }) }}" style="{{ viewStyle }}" bindtap="onClick">
|
||||
<view
|
||||
class="content-class {{ utils.bem('grid-item__content', { center, square, clickable, surround: border && gutter }) }} {{ border ? 'van-hairline--surround' : '' }}"
|
||||
class="content-class {{ utils.bem('grid-item__content', [direction, { center, square, clickable, surround: border && gutter }]) }} {{ border ? 'van-hairline--surround' : '' }}"
|
||||
style="{{ contentStyle }}"
|
||||
>
|
||||
<block wx:if="{{ useSlot }}">
|
||||
@ -10,7 +10,7 @@
|
||||
</block>
|
||||
<block wx:else>
|
||||
<view class="van-grid-item__icon icon-class">
|
||||
<van-icon wx:if="{{ icon }}" name="{{ icon }}" dot="{{ dot }}" info="{{ info }}" />
|
||||
<van-icon wx:if="{{ icon }}" name="{{ icon }}" dot="{{ dot }}" info="{{ badge || info }}" size="{{ iconSize }}" />
|
||||
<slot wx:else name="icon"></slot>
|
||||
</view>
|
||||
<view class="van-grid-item__text text-class">
|
||||
|
2
dist/grid-item/index.wxss
vendored
2
dist/grid-item/index.wxss
vendored
@ -1 +1 @@
|
||||
@import '../common/index.wxss';.van-grid-item{position:relative;float:left;box-sizing:border-box}.van-grid-item--square{height:0}.van-grid-item__content{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;box-sizing:border-box;height:100%;padding:16px 8px;padding:var(--grid-item-content-padding,16px 8px);background-color:#fff;background-color:var(--grid-item-content-background-color,#fff)}.van-grid-item__content:after{z-index:1;border-width:0 1px 1px 0;border-bottom-width:var(--border-width-base,1px);border-right-width:var(--border-width-base,1px);border-top-width:0}.van-grid-item__content--surround:after{border-width:1px;border-width:var(--border-width-base,1px)}.van-grid-item__content--center{-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center}.van-grid-item__content--square{position:absolute;top:0;right:0;left:0}.van-grid-item__content--clickable:active{background-color:#f2f3f5;background-color:var(--grid-item-content-active-color,#f2f3f5)}.van-grid-item__icon{font-size:26px;font-size:var(--grid-item-icon-size,26px)}.van-grid-item__text{word-wrap:break-word;color:#646566;color:var(--grid-item-text-color,#646566);font-size:12px;font-size:var(--grid-item-text-font-size,12px)}
|
||||
@import '../common/index.wxss';.van-grid-item{position:relative;float:left;box-sizing:border-box}.van-grid-item--square{height:0}.van-grid-item__content{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;box-sizing:border-box;height:100%;padding:16px 8px;padding:var(--grid-item-content-padding,16px 8px);background-color:#fff;background-color:var(--grid-item-content-background-color,#fff)}.van-grid-item__content:after{z-index:1;border-width:0 1px 1px 0;border-bottom-width:var(--border-width-base,1px);border-right-width:var(--border-width-base,1px);border-top-width:0}.van-grid-item__content--surround:after{border-width:1px;border-width:var(--border-width-base,1px)}.van-grid-item__content--center{-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center}.van-grid-item__content--square{position:absolute;top:0;right:0;left:0}.van-grid-item__content--horizontal{-webkit-flex-direction:row;flex-direction:row}.van-grid-item__content--horizontal .van-grid-item__icon+.van-grid-item__text{margin-top:0;margin-left:8px}.van-grid-item__content--clickable:active{background-color:#f2f3f5;background-color:var(--grid-item-content-active-color,#f2f3f5)}.van-grid-item__icon{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;font-size:26px;font-size:var(--grid-item-icon-size,26px);height:26px;height:var(--grid-item-icon-size,26px)}.van-grid-item__text{word-wrap:break-word;color:#646566;color:var(--grid-item-text-color,#646566);font-size:12px;font-size:var(--grid-item-text-font-size,12px)}
|
8
dist/grid/index.js
vendored
8
dist/grid/index.js
vendored
@ -35,6 +35,14 @@ VantComponent({
|
||||
value: true,
|
||||
observer: 'updateChildren',
|
||||
},
|
||||
direction: {
|
||||
type: String,
|
||||
observer: 'updateChildren',
|
||||
},
|
||||
iconSize: {
|
||||
type: String,
|
||||
observer: 'updateChildren',
|
||||
},
|
||||
},
|
||||
data: {
|
||||
viewStyle: '',
|
||||
|
2
dist/tag/index.wxss
vendored
2
dist/tag/index.wxss
vendored
@ -1 +1 @@
|
||||
@import '../common/index.wxss';.van-tag{display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;line-height:normal;padding:.2em .5em;padding:var(--tag-padding,.2em .5em);color:#fff;color:var(--tag-text-color,#fff);font-size:10px;font-size:var(--tag-font-size,10px);border-radius:.2em;border-radius:var(--tag-border-radius,.2em)}.van-tag:after{border-color:currentColor;border-radius:.2em * 2;border-radius:var(--tag-border-radius,.2em) * 2}.van-tag--default{background-color:#969799;background-color:var(--tag-default-color,#969799)}.van-tag--default.van-tag--plain{color:#969799;color:var(--tag-default-color,#969799)}.van-tag--danger{background-color:#ee0a24;background-color:var(--tag-dander-color,#ee0a24)}.van-tag--danger.van-tag--plain{color:#ee0a24;color:var(--tag-dander-color,#ee0a24)}.van-tag--primary{background-color:#1989fa;background-color:var(--tag-primary-color,#1989fa)}.van-tag--primary.van-tag--plain{color:#1989fa;color:var(--tag-primary-color,#1989fa)}.van-tag--success{background-color:#07c160;background-color:var(--tag-success-color,#07c160)}.van-tag--success.van-tag--plain{color:#07c160;color:var(--tag-success-color,#07c160)}.van-tag--warning{background-color:#ff976a;background-color:var(--tag-warning-color,#ff976a)}.van-tag--warning.van-tag--plain{color:#ff976a;color:var(--tag-warning-color,#ff976a)}.van-tag--plain{background-color:#fff;background-color:var(--tag-plain-background-color,#fff)}.van-tag--mark{padding-right:.7em}.van-tag--mark,.van-tag--mark:after{border-radius:0 999px 999px 0;border-radius:0 var(--tag-round-border-radius,999px) var(--tag-round-border-radius,999px) 0}.van-tag--round,.van-tag--round:after{border-radius:999px;border-radius:var(--tag-round-border-radius,999px)}.van-tag--medium{font-size:12px;font-size:var(--tag-medium-font-size,12px)}.van-tag--large{font-size:14px;font-size:var(--tag-large-font-size,14px)}.van-tag__close{margin-left:2px}
|
||||
@import '../common/index.wxss';.van-tag{display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;line-height:normal;padding:.2em .5em;padding:var(--tag-padding,.2em .5em);color:#fff;color:var(--tag-text-color,#fff);font-size:10px;font-size:var(--tag-font-size,10px);border-radius:.2em;border-radius:var(--tag-border-radius,.2em)}.van-tag:after{border-color:currentColor;border-radius:.2em * 2;border-radius:var(--tag-border-radius,.2em) * 2}.van-tag--default{background-color:#969799;background-color:var(--tag-default-color,#969799)}.van-tag--default.van-tag--plain{color:#969799;color:var(--tag-default-color,#969799)}.van-tag--danger{background-color:#ee0a24;background-color:var(--tag-danger-color,#ee0a24)}.van-tag--danger.van-tag--plain{color:#ee0a24;color:var(--tag-danger-color,#ee0a24)}.van-tag--primary{background-color:#1989fa;background-color:var(--tag-primary-color,#1989fa)}.van-tag--primary.van-tag--plain{color:#1989fa;color:var(--tag-primary-color,#1989fa)}.van-tag--success{background-color:#07c160;background-color:var(--tag-success-color,#07c160)}.van-tag--success.van-tag--plain{color:#07c160;color:var(--tag-success-color,#07c160)}.van-tag--warning{background-color:#ff976a;background-color:var(--tag-warning-color,#ff976a)}.van-tag--warning.van-tag--plain{color:#ff976a;color:var(--tag-warning-color,#ff976a)}.van-tag--plain{background-color:#fff;background-color:var(--tag-plain-background-color,#fff)}.van-tag--mark{padding-right:.7em}.van-tag--mark,.van-tag--mark:after{border-radius:0 999px 999px 0;border-radius:0 var(--tag-round-border-radius,999px) var(--tag-round-border-radius,999px) 0}.van-tag--round,.van-tag--round:after{border-radius:999px;border-radius:var(--tag-round-border-radius,999px)}.van-tag--medium{font-size:12px;font-size:var(--tag-medium-font-size,12px)}.van-tag--large{font-size:14px;font-size:var(--tag-large-font-size,14px)}.van-tag__close{margin-left:2px}
|
2
dist/uploader/index.wxml
vendored
2
dist/uploader/index.wxml
vendored
@ -42,7 +42,7 @@
|
||||
name="clear"
|
||||
class="van-uploader__preview-delete"
|
||||
data-index="{{ index }}"
|
||||
bind:tap="deleteItem"
|
||||
catch:tap="deleteItem"
|
||||
/>
|
||||
</view>
|
||||
|
||||
|
@ -3,13 +3,19 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
||||
var component_1 = require('../common/component');
|
||||
var button_1 = require('../mixins/button');
|
||||
var open_type_1 = require('../mixins/open-type');
|
||||
var version_1 = require('../common/version');
|
||||
var mixins = [button_1.button, open_type_1.openType];
|
||||
if (version_1.canIUseFormFieldButton()) {
|
||||
mixins.push('wx://form-field-button');
|
||||
}
|
||||
component_1.VantComponent({
|
||||
mixins: [button_1.button, open_type_1.openType],
|
||||
mixins: mixins,
|
||||
classes: ['hover-class', 'loading-class'],
|
||||
data: {
|
||||
baseStyle: '',
|
||||
},
|
||||
props: {
|
||||
formType: String,
|
||||
icon: String,
|
||||
classPrefix: {
|
||||
type: String,
|
||||
|
@ -6,6 +6,7 @@
|
||||
class="custom-class {{ utils.bem('button', [type, size, { block, round, plain, square, loading, disabled, hairline, unclickable: disabled || loading }]) }} {{ hairline ? 'van-hairline--surround' : '' }}"
|
||||
hover-class="van-button--active hover-class"
|
||||
lang="{{ lang }}"
|
||||
form-type="{{ formType }}"
|
||||
style="{{ baseStyle }} {{ customStyle }}"
|
||||
open-type="{{ disabled ? '' : openType }}"
|
||||
business-id="{{ businessId }}"
|
||||
|
@ -304,7 +304,10 @@ component_1.VantComponent({
|
||||
},
|
||||
onConfirm: function () {
|
||||
var _this = this;
|
||||
if (this.data.type === 'range' && !this.checkRange()) {
|
||||
if (
|
||||
this.data.type === 'range' &&
|
||||
!this.checkRange(this.data.currentDate)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
wx.nextTick(function () {
|
||||
|
47
lib/circle/canvas.js
Normal file
47
lib/circle/canvas.js
Normal file
@ -0,0 +1,47 @@
|
||||
'use strict';
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
exports.adaptor = void 0;
|
||||
function adaptor(ctx) {
|
||||
// @ts-ignore
|
||||
return Object.assign(ctx, {
|
||||
setStrokeStyle: function (val) {
|
||||
ctx.strokeStyle = val;
|
||||
},
|
||||
setLineWidth: function (val) {
|
||||
ctx.lineWidth = val;
|
||||
},
|
||||
setLineCap: function (val) {
|
||||
ctx.lineCap = val;
|
||||
},
|
||||
setFillStyle: function (val) {
|
||||
ctx.fillStyle = val;
|
||||
},
|
||||
setFontSize: function (val) {
|
||||
ctx.font = String(val);
|
||||
},
|
||||
setGlobalAlpha: function (val) {
|
||||
ctx.globalAlpha = val;
|
||||
},
|
||||
setLineJoin: function (val) {
|
||||
ctx.lineJoin = val;
|
||||
},
|
||||
setTextAlign: function (val) {
|
||||
ctx.textAlign = val;
|
||||
},
|
||||
setMiterLimit: function (val) {
|
||||
ctx.miterLimit = val;
|
||||
},
|
||||
setShadow: function (offsetX, offsetY, blur, color) {
|
||||
ctx.shadowOffsetX = offsetX;
|
||||
ctx.shadowOffsetY = offsetY;
|
||||
ctx.shadowBlur = blur;
|
||||
ctx.shadowColor = color;
|
||||
},
|
||||
setTextBaseline: function (val) {
|
||||
ctx.textBaseline = val;
|
||||
},
|
||||
createCircularGradient: function () {},
|
||||
draw: function () {},
|
||||
});
|
||||
}
|
||||
exports.adaptor = adaptor;
|
@ -3,6 +3,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
||||
var component_1 = require('../common/component');
|
||||
var utils_1 = require('../common/utils');
|
||||
var color_1 = require('../common/color');
|
||||
var canvas_1 = require('./canvas');
|
||||
function format(rate) {
|
||||
return Math.min(Math.max(rate, 0), 100);
|
||||
}
|
||||
@ -28,6 +29,9 @@ component_1.VantComponent({
|
||||
size: {
|
||||
type: Number,
|
||||
value: 100,
|
||||
observer: function () {
|
||||
this.drawCircle(this.currentValue);
|
||||
},
|
||||
},
|
||||
fill: String,
|
||||
layerColor: {
|
||||
@ -57,40 +61,59 @@ component_1.VantComponent({
|
||||
},
|
||||
methods: {
|
||||
getContext: function () {
|
||||
if (!this.ctx) {
|
||||
this.ctx = wx.createCanvasContext('van-circle', this);
|
||||
var _this = this;
|
||||
var type = this.data.type;
|
||||
if (type === '') {
|
||||
var ctx = wx.createCanvasContext('van-circle', this);
|
||||
return Promise.resolve(ctx);
|
||||
}
|
||||
return this.ctx;
|
||||
var dpr = wx.getSystemInfoSync().pixelRatio;
|
||||
return new Promise(function (resolve) {
|
||||
wx.createSelectorQuery()
|
||||
.in(_this)
|
||||
.select('#van-circle')
|
||||
.fields({ node: true, size: true })
|
||||
.exec(function (res) {
|
||||
var canvas = res[0].node;
|
||||
var ctx = canvas.getContext(type);
|
||||
canvas.width = res[0].width * dpr;
|
||||
canvas.height = res[0].height * dpr;
|
||||
ctx.scale(dpr, dpr);
|
||||
resolve(canvas_1.adaptor(ctx));
|
||||
});
|
||||
});
|
||||
},
|
||||
setHoverColor: function () {
|
||||
var _this = this;
|
||||
var _a = this.data,
|
||||
color = _a.color,
|
||||
size = _a.size,
|
||||
type = _a.type;
|
||||
var context = type ? this.getContext(type) : this.getContext();
|
||||
size = _a.size;
|
||||
var hoverColor = color;
|
||||
if (utils_1.isObj(color)) {
|
||||
var LinearColor_1 = context.createLinearGradient(size, 0, 0, 0);
|
||||
Object.keys(color)
|
||||
.sort(function (a, b) {
|
||||
return parseFloat(a) - parseFloat(b);
|
||||
})
|
||||
.map(function (key) {
|
||||
return LinearColor_1.addColorStop(
|
||||
parseFloat(key) / 100,
|
||||
color[key]
|
||||
);
|
||||
});
|
||||
hoverColor = LinearColor_1;
|
||||
}
|
||||
this.setData({ hoverColor: hoverColor });
|
||||
this.getContext().then(function (context) {
|
||||
if (utils_1.isObj(color)) {
|
||||
var LinearColor_1 = context.createLinearGradient(size, 0, 0, 0);
|
||||
Object.keys(color)
|
||||
.sort(function (a, b) {
|
||||
return parseFloat(a) - parseFloat(b);
|
||||
})
|
||||
.map(function (key) {
|
||||
return LinearColor_1.addColorStop(
|
||||
parseFloat(key) / 100,
|
||||
color[key]
|
||||
);
|
||||
});
|
||||
hoverColor = LinearColor_1;
|
||||
}
|
||||
_this.setData({ hoverColor: hoverColor });
|
||||
});
|
||||
},
|
||||
presetCanvas: function (context, strokeStyle, beginAngle, endAngle, fill) {
|
||||
var _a = this.data,
|
||||
strokeWidth = _a.strokeWidth,
|
||||
lineCap = _a.lineCap,
|
||||
clockwise = _a.clockwise,
|
||||
size = _a.size;
|
||||
size = _a.size,
|
||||
type = _a.type;
|
||||
var position = size / 2;
|
||||
var radius = position - strokeWidth / 2;
|
||||
context.setStrokeStyle(strokeStyle);
|
||||
@ -122,17 +145,17 @@ component_1.VantComponent({
|
||||
this.presetCanvas(context, hoverColor, BEGIN_ANGLE, endAngle);
|
||||
},
|
||||
drawCircle: function (currentValue) {
|
||||
var _a = this.data,
|
||||
size = _a.size,
|
||||
type = _a.type;
|
||||
var context = type ? this.getContext(type) : this.getContext();
|
||||
context.clearRect(0, 0, size, size);
|
||||
this.renderLayerCircle(context);
|
||||
var formatValue = format(currentValue);
|
||||
if (formatValue !== 0) {
|
||||
this.renderHoverCircle(context, formatValue);
|
||||
}
|
||||
context.draw();
|
||||
var _this = this;
|
||||
var size = this.data.size;
|
||||
this.getContext().then(function (context) {
|
||||
context.clearRect(0, 0, size, size);
|
||||
_this.renderLayerCircle(context);
|
||||
var formatValue = format(currentValue);
|
||||
if (formatValue !== 0) {
|
||||
_this.renderHoverCircle(context, formatValue);
|
||||
}
|
||||
context.draw();
|
||||
});
|
||||
},
|
||||
reRender: function () {
|
||||
var _this = this;
|
||||
@ -172,7 +195,6 @@ component_1.VantComponent({
|
||||
this.drawCircle(value);
|
||||
},
|
||||
destroyed: function () {
|
||||
this.ctx = null;
|
||||
this.clearInterval();
|
||||
},
|
||||
});
|
||||
|
@ -1,9 +1,9 @@
|
||||
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||
|
||||
<view class="van-circle">
|
||||
<canvas class="van-circle__canvas" style="width: {{ utils.addUnit(size) }};height:{{ utils.addUnit(size) }}" canvas-id="van-circle"></canvas>
|
||||
<canvas class="van-circle__canvas" type="{{ type }}" style="width: {{ utils.addUnit(size) }};height:{{ utils.addUnit(size) }}" id="van-circle" canvas-id="van-circle"></canvas>
|
||||
<view wx:if="{{ !text }}" class="van-circle__text">
|
||||
<slot></slot>
|
||||
</view>
|
||||
<cover-view wx:else class="van-circle__text">{{ text }}</cover-view>
|
||||
</view>
|
||||
</view>
|
||||
|
@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
exports.canIUseModel = void 0;
|
||||
exports.canIUseFormFieldButton = exports.canIUseModel = void 0;
|
||||
var utils_1 = require('./utils');
|
||||
function compareVersion(v1, v2) {
|
||||
v1 = v1.split('.');
|
||||
@ -29,3 +29,8 @@ function canIUseModel() {
|
||||
return compareVersion(system.SDKVersion, '2.9.3') >= 0;
|
||||
}
|
||||
exports.canIUseModel = canIUseModel;
|
||||
function canIUseFormFieldButton() {
|
||||
var system = utils_1.getSystemInfoSync();
|
||||
return compareVersion(system.SDKVersion, '2.10.3') >= 0;
|
||||
}
|
||||
exports.canIUseFormFieldButton = canIUseFormFieldButton;
|
||||
|
@ -15,6 +15,7 @@ component_1.VantComponent({
|
||||
icon: String,
|
||||
dot: Boolean,
|
||||
info: null,
|
||||
badge: null,
|
||||
text: String,
|
||||
useSlot: Boolean,
|
||||
},
|
||||
@ -37,7 +38,9 @@ component_1.VantComponent({
|
||||
square = data.square,
|
||||
gutter = data.gutter,
|
||||
clickable = data.clickable,
|
||||
center = data.center;
|
||||
center = data.center,
|
||||
direction = data.direction,
|
||||
iconSize = data.iconSize;
|
||||
var width = 100 / columnNum + '%';
|
||||
var styleWrapper = [];
|
||||
styleWrapper.push('width: ' + width);
|
||||
@ -48,7 +51,7 @@ component_1.VantComponent({
|
||||
var gutterValue = utils_1.addUnit(gutter);
|
||||
styleWrapper.push('padding-right: ' + gutterValue);
|
||||
var index = children.indexOf(this);
|
||||
if (index >= columnNum) {
|
||||
if (index >= columnNum && !square) {
|
||||
styleWrapper.push('margin-top: ' + gutterValue);
|
||||
}
|
||||
}
|
||||
@ -70,6 +73,8 @@ component_1.VantComponent({
|
||||
square: square,
|
||||
gutter: gutter,
|
||||
clickable: clickable,
|
||||
direction: direction,
|
||||
iconSize: iconSize,
|
||||
});
|
||||
},
|
||||
onClick: function () {
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
<view class="custom-class {{ utils.bem('grid-item', { square }) }}" style="{{ viewStyle }}" bindtap="onClick">
|
||||
<view
|
||||
class="content-class {{ utils.bem('grid-item__content', { center, square, clickable, surround: border && gutter }) }} {{ border ? 'van-hairline--surround' : '' }}"
|
||||
class="content-class {{ utils.bem('grid-item__content', [direction, { center, square, clickable, surround: border && gutter }]) }} {{ border ? 'van-hairline--surround' : '' }}"
|
||||
style="{{ contentStyle }}"
|
||||
>
|
||||
<block wx:if="{{ useSlot }}">
|
||||
@ -10,7 +10,7 @@
|
||||
</block>
|
||||
<block wx:else>
|
||||
<view class="van-grid-item__icon icon-class">
|
||||
<van-icon wx:if="{{ icon }}" name="{{ icon }}" dot="{{ dot }}" info="{{ info }}" />
|
||||
<van-icon wx:if="{{ icon }}" name="{{ icon }}" dot="{{ dot }}" info="{{ badge || info }}" size="{{ iconSize }}" />
|
||||
<slot wx:else name="icon"></slot>
|
||||
</view>
|
||||
<view class="van-grid-item__text text-class">
|
||||
|
@ -1 +1 @@
|
||||
@import '../common/index.wxss';.van-grid-item{position:relative;float:left;box-sizing:border-box}.van-grid-item--square{height:0}.van-grid-item__content{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;box-sizing:border-box;height:100%;padding:16px 8px;padding:var(--grid-item-content-padding,16px 8px);background-color:#fff;background-color:var(--grid-item-content-background-color,#fff)}.van-grid-item__content:after{z-index:1;border-width:0 1px 1px 0;border-bottom-width:var(--border-width-base,1px);border-right-width:var(--border-width-base,1px);border-top-width:0}.van-grid-item__content--surround:after{border-width:1px;border-width:var(--border-width-base,1px)}.van-grid-item__content--center{-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center}.van-grid-item__content--square{position:absolute;top:0;right:0;left:0}.van-grid-item__content--clickable:active{background-color:#f2f3f5;background-color:var(--grid-item-content-active-color,#f2f3f5)}.van-grid-item__icon{font-size:26px;font-size:var(--grid-item-icon-size,26px)}.van-grid-item__text{word-wrap:break-word;color:#646566;color:var(--grid-item-text-color,#646566);font-size:12px;font-size:var(--grid-item-text-font-size,12px)}
|
||||
@import '../common/index.wxss';.van-grid-item{position:relative;float:left;box-sizing:border-box}.van-grid-item--square{height:0}.van-grid-item__content{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;box-sizing:border-box;height:100%;padding:16px 8px;padding:var(--grid-item-content-padding,16px 8px);background-color:#fff;background-color:var(--grid-item-content-background-color,#fff)}.van-grid-item__content:after{z-index:1;border-width:0 1px 1px 0;border-bottom-width:var(--border-width-base,1px);border-right-width:var(--border-width-base,1px);border-top-width:0}.van-grid-item__content--surround:after{border-width:1px;border-width:var(--border-width-base,1px)}.van-grid-item__content--center{-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center}.van-grid-item__content--square{position:absolute;top:0;right:0;left:0}.van-grid-item__content--horizontal{-webkit-flex-direction:row;flex-direction:row}.van-grid-item__content--horizontal .van-grid-item__icon+.van-grid-item__text{margin-top:0;margin-left:8px}.van-grid-item__content--clickable:active{background-color:#f2f3f5;background-color:var(--grid-item-content-active-color,#f2f3f5)}.van-grid-item__icon{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;font-size:26px;font-size:var(--grid-item-icon-size,26px);height:26px;height:var(--grid-item-icon-size,26px)}.van-grid-item__text{word-wrap:break-word;color:#646566;color:var(--grid-item-text-color,#646566);font-size:12px;font-size:var(--grid-item-text-font-size,12px)}
|
@ -37,6 +37,14 @@ component_1.VantComponent({
|
||||
value: true,
|
||||
observer: 'updateChildren',
|
||||
},
|
||||
direction: {
|
||||
type: String,
|
||||
observer: 'updateChildren',
|
||||
},
|
||||
iconSize: {
|
||||
type: String,
|
||||
observer: 'updateChildren',
|
||||
},
|
||||
},
|
||||
data: {
|
||||
viewStyle: '',
|
||||
|
@ -1 +1 @@
|
||||
@import '../common/index.wxss';.van-tag{display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;line-height:normal;padding:.2em .5em;padding:var(--tag-padding,.2em .5em);color:#fff;color:var(--tag-text-color,#fff);font-size:10px;font-size:var(--tag-font-size,10px);border-radius:.2em;border-radius:var(--tag-border-radius,.2em)}.van-tag:after{border-color:currentColor;border-radius:.2em * 2;border-radius:var(--tag-border-radius,.2em) * 2}.van-tag--default{background-color:#969799;background-color:var(--tag-default-color,#969799)}.van-tag--default.van-tag--plain{color:#969799;color:var(--tag-default-color,#969799)}.van-tag--danger{background-color:#ee0a24;background-color:var(--tag-dander-color,#ee0a24)}.van-tag--danger.van-tag--plain{color:#ee0a24;color:var(--tag-dander-color,#ee0a24)}.van-tag--primary{background-color:#1989fa;background-color:var(--tag-primary-color,#1989fa)}.van-tag--primary.van-tag--plain{color:#1989fa;color:var(--tag-primary-color,#1989fa)}.van-tag--success{background-color:#07c160;background-color:var(--tag-success-color,#07c160)}.van-tag--success.van-tag--plain{color:#07c160;color:var(--tag-success-color,#07c160)}.van-tag--warning{background-color:#ff976a;background-color:var(--tag-warning-color,#ff976a)}.van-tag--warning.van-tag--plain{color:#ff976a;color:var(--tag-warning-color,#ff976a)}.van-tag--plain{background-color:#fff;background-color:var(--tag-plain-background-color,#fff)}.van-tag--mark{padding-right:.7em}.van-tag--mark,.van-tag--mark:after{border-radius:0 999px 999px 0;border-radius:0 var(--tag-round-border-radius,999px) var(--tag-round-border-radius,999px) 0}.van-tag--round,.van-tag--round:after{border-radius:999px;border-radius:var(--tag-round-border-radius,999px)}.van-tag--medium{font-size:12px;font-size:var(--tag-medium-font-size,12px)}.van-tag--large{font-size:14px;font-size:var(--tag-large-font-size,14px)}.van-tag__close{margin-left:2px}
|
||||
@import '../common/index.wxss';.van-tag{display:-webkit-inline-flex;display:inline-flex;-webkit-align-items:center;align-items:center;line-height:normal;padding:.2em .5em;padding:var(--tag-padding,.2em .5em);color:#fff;color:var(--tag-text-color,#fff);font-size:10px;font-size:var(--tag-font-size,10px);border-radius:.2em;border-radius:var(--tag-border-radius,.2em)}.van-tag:after{border-color:currentColor;border-radius:.2em * 2;border-radius:var(--tag-border-radius,.2em) * 2}.van-tag--default{background-color:#969799;background-color:var(--tag-default-color,#969799)}.van-tag--default.van-tag--plain{color:#969799;color:var(--tag-default-color,#969799)}.van-tag--danger{background-color:#ee0a24;background-color:var(--tag-danger-color,#ee0a24)}.van-tag--danger.van-tag--plain{color:#ee0a24;color:var(--tag-danger-color,#ee0a24)}.van-tag--primary{background-color:#1989fa;background-color:var(--tag-primary-color,#1989fa)}.van-tag--primary.van-tag--plain{color:#1989fa;color:var(--tag-primary-color,#1989fa)}.van-tag--success{background-color:#07c160;background-color:var(--tag-success-color,#07c160)}.van-tag--success.van-tag--plain{color:#07c160;color:var(--tag-success-color,#07c160)}.van-tag--warning{background-color:#ff976a;background-color:var(--tag-warning-color,#ff976a)}.van-tag--warning.van-tag--plain{color:#ff976a;color:var(--tag-warning-color,#ff976a)}.van-tag--plain{background-color:#fff;background-color:var(--tag-plain-background-color,#fff)}.van-tag--mark{padding-right:.7em}.van-tag--mark,.van-tag--mark:after{border-radius:0 999px 999px 0;border-radius:0 var(--tag-round-border-radius,999px) var(--tag-round-border-radius,999px) 0}.van-tag--round,.van-tag--round:after{border-radius:999px;border-radius:var(--tag-round-border-radius,999px)}.van-tag--medium{font-size:12px;font-size:var(--tag-medium-font-size,12px)}.van-tag--large{font-size:14px;font-size:var(--tag-large-font-size,14px)}.van-tag__close{margin-left:2px}
|
@ -42,7 +42,7 @@
|
||||
name="clear"
|
||||
class="van-uploader__preview-delete"
|
||||
data-index="{{ index }}"
|
||||
bind:tap="deleteItem"
|
||||
catch:tap="deleteItem"
|
||||
/>
|
||||
</view>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user