初始化项目, 添加TDesign等包
This commit is contained in:
3
miniprogram/miniprogram_npm/tdesign-miniprogram/stepper/props.d.ts
vendored
Normal file
3
miniprogram/miniprogram_npm/tdesign-miniprogram/stepper/props.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { TdStepperProps } from './type';
|
||||
declare const props: TdStepperProps;
|
||||
export default props;
|
||||
@@ -0,0 +1 @@
|
||||
const props={disableInput:{type:Boolean,value:!1},disabled:{type:null,value:void 0},inputWidth:{type:Number},integer:{type:Boolean,value:!0},max:{type:Number,value:100},min:{type:Number,value:0},size:{type:String,value:"medium"},step:{type:Number,value:1},theme:{type:String,value:"normal"},value:{type:null,value:null},defaultValue:{type:null,value:0}};export default props;
|
||||
79
miniprogram/miniprogram_npm/tdesign-miniprogram/stepper/stepper.d.ts
vendored
Normal file
79
miniprogram/miniprogram_npm/tdesign-miniprogram/stepper/stepper.d.ts
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
import { SuperComponent } from '../common/src/index';
|
||||
export default class Stepper extends SuperComponent {
|
||||
externalClasses: string[];
|
||||
properties: {
|
||||
disableInput?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
disabled?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
inputWidth?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
integer?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
max?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
min?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
size?: {
|
||||
type: StringConstructor;
|
||||
value?: import("../common/common").SizeEnum;
|
||||
};
|
||||
step?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
theme?: {
|
||||
type: StringConstructor;
|
||||
value?: "outline" | "filled" | "normal";
|
||||
};
|
||||
value?: {
|
||||
type: null;
|
||||
value?: string | number;
|
||||
};
|
||||
defaultValue?: {
|
||||
type: null;
|
||||
value?: string | number;
|
||||
};
|
||||
};
|
||||
controlledProps: {
|
||||
key: string;
|
||||
event: string;
|
||||
}[];
|
||||
observers: {
|
||||
value(v: any): void;
|
||||
};
|
||||
data: {
|
||||
currentValue: number;
|
||||
classPrefix: string;
|
||||
prefix: string;
|
||||
};
|
||||
lifetimes: {
|
||||
attached(): void;
|
||||
};
|
||||
methods: {
|
||||
isDisabled(type: any): boolean;
|
||||
getLen(num: number): number;
|
||||
add(a: number, b: number): number;
|
||||
format(value: any): string;
|
||||
setValue(value: any): void;
|
||||
minusValue(): boolean;
|
||||
plusValue(): boolean;
|
||||
filterIllegalChar(value: string | number): string;
|
||||
updateCurrentValue(value: any): void;
|
||||
handleFocus(e: any): void;
|
||||
handleInput(e: any): void;
|
||||
handleBlur(e: any): void;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
import{__decorate}from"tslib";import{SuperComponent,wxComponent}from"../common/src/index";import config from"../common/config";import props from"./props";const{prefix:prefix}=config,name=`${prefix}-stepper`;let Stepper=class extends SuperComponent{constructor(){super(...arguments),this.externalClasses=[`${prefix}-class`,`${prefix}-class-input`,`${prefix}-class-minus`,`${prefix}-class-plus`],this.properties=Object.assign({},props),this.controlledProps=[{key:"value",event:"change"}],this.observers={value(e){this.preValue=Number(e),this.updateCurrentValue(this.format(this.preValue))}},this.data={currentValue:0,classPrefix:name,prefix:prefix},this.lifetimes={attached(){const{value:e,min:t}=this.properties;this.updateCurrentValue(e?Number(e):t)}},this.methods={isDisabled(e){const{min:t,max:s,disabled:r}=this.properties,{currentValue:i}=this.data;return!!r||("minus"===e&&i<=t||"plus"===e&&i>=s)},getLen(e){const t=e.toString();return-1===t.indexOf(".")?0:t.split(".")[1].length},add(e,t){const s=Math.max(this.getLen(e),this.getLen(t)),r=Math.pow(10,s);return Math.round(e*r+t*r)/r},format(e){const{min:t,max:s,step:r}=this.properties,i=Math.max(this.getLen(r),this.getLen(e));return Math.max(Math.min(s,e,Number.MAX_SAFE_INTEGER),t,Number.MIN_SAFE_INTEGER).toFixed(i)},setValue(e){const t=Number(this.format(e));this.updateCurrentValue(t),this.preValue!==t&&(this.preValue=t,this._trigger("change",{value:t}))},minusValue(){if(this.isDisabled("minus"))return this.triggerEvent("overlimit",{type:"minus"}),!1;const{currentValue:e,step:t}=this.data;this.setValue(this.add(e,-t))},plusValue(){if(this.isDisabled("plus"))return this.triggerEvent("overlimit",{type:"plus"}),!1;const{currentValue:e,step:t}=this.data;this.setValue(this.add(e,t))},filterIllegalChar(e){const t=String(e).replace(/[^0-9.]/g,""),s=t.indexOf(".");return this.properties.integer&&-1!==s?t.split(".")[0]:this.properties.integer||-1===s||s===t.lastIndexOf(".")?t:t.split(".",2).join(".")},updateCurrentValue(e){this.setData({currentValue:e})},handleFocus(e){const{value:t}=e.detail;this.triggerEvent("focus",{value:t})},handleInput(e){const{value:t}=e.detail;if(""===t)return;const s=this.filterIllegalChar(t),r=this.format(s);this.updateCurrentValue(this.data.integer?r:s),(this.data.integer||/\.\d+/.test(s))&&this.setValue(s)},handleBlur(e){const{value:t}=e.detail,s=this.format(t);this.setValue(s),this.triggerEvent("blur",{value:s})}}}};Stepper=__decorate([wxComponent()],Stepper);export default Stepper;
|
||||
@@ -0,0 +1 @@
|
||||
{"component":true,"styleIsolation":"apply-shared","usingComponents":{"t-cell":"../cell/cell","t-icon":"../icon/icon"}}
|
||||
@@ -0,0 +1 @@
|
||||
<wxs src="../common/utils.wxs" module="_"/><view style="{{_._style([style, customStyle])}}" class="{{classPrefix}} {{classPrefix}}--{{size}} class {{prefix}}-class"><view class="{{classPrefix}}__minus {{classPrefix}}__minus--{{theme}} {{classPrefix}}__icon--{{size}} {{ disabled || disableMinus || currentValue <= min ? classPrefix + '--' + theme + '-disabled': ''}} {{prefix}}-class-minus" catchtap="minusValue" aria-label="{{'减少' + step}}" aria-role="button" aria-disabled="{{disabled || disableMinus || currentValue <= min}}"><t-icon name="remove"/></view><view class="{{classPrefix}}__input--{{theme}} {{ disabled || disableInput ? classPrefix + '--' + theme + '-disabled': ''}}"><input style="{{inputWidth? 'width:' + inputWidth + 'px;': ''}}" class="{{classPrefix}}__input {{classPrefix}}__input--{{size}} {{prefix}}-class-input" disabled="{{ disabled || disableInput }}" type="{{ integer ? 'number' : 'digit' }}" value="{{ currentValue }}" catchinput="handleInput" catchfocus="handleFocus" catchblur="handleBlur"/></view><view class="{{classPrefix}}__plus {{classPrefix}}__plus--{{theme}} {{classPrefix}}__icon--{{size}} {{ disabled || disablePlus|| currentValue >= max ? classPrefix + '--' + theme + '-disabled': ''}} {{prefix}}-class-plus" catchtap="plusValue" aria-label="{{'增加' + step}}" aria-role="button" aria-disabled="{{disabled || disablePlus|| currentValue >= max}}"><t-icon name="add"/></view></view>
|
||||
@@ -0,0 +1,23 @@
|
||||
@import '../common/style/index.wxss';.t-stepper{display:flex;align-items:center;color:var(--td-stepper-input-color,var(--td-text-color-primary,var(--td-font-gray-1,rgba(0,0,0,.9))));}
|
||||
.t-stepper__input{margin:0 8rpx;text-align:center;vertical-align:top;height:inherit;min-height:inherit;}
|
||||
.t-stepper__minus,.t-stepper__plus{padding:8rpx;box-sizing:border-box;}
|
||||
.t-stepper__input,.t-stepper__minus-icon,.t-stepper__plus-icon{color:inherit;}
|
||||
.t-stepper__input--filled,.t-stepper__input--normal,.t-stepper__input--outline{height:inherit;box-sizing:border-box;}
|
||||
.t-stepper--small{height:40rpx;font-size:20rpx;}
|
||||
.t-stepper--medium{height:48rpx;font-size:24rpx;}
|
||||
.t-stepper--large{height:56rpx;font-size:32rpx;}
|
||||
.t-stepper__input--small{width:68rpx;}
|
||||
.t-stepper__input--medium{height:48rpx;width:76rpx;}
|
||||
.t-stepper__input--large{width:90rpx;}
|
||||
.t-stepper__icon--small{width:40rpx;height:40rpx;font-size:24rpx;}
|
||||
.t-stepper__icon--medium{width:48rpx;height:48rpx;font-size:32rpx;}
|
||||
.t-stepper__icon--large{width:56rpx;height:56rpx;font-size:40rpx;}
|
||||
.t-stepper__minus--outline,.t-stepper__plus--outline{border:2rpx solid var(--td-stepper-border-color,var(--td-component-border,var(--td-gray-color-4,#dcdcdc)));}
|
||||
.t-stepper__input--outline{border:none;border-top:2rpx solid var(--td-stepper-border-color,var(--td-component-border,var(--td-gray-color-4,#dcdcdc)));border-bottom:2rpx solid var(--td-stepper-border-color,var(--td-component-border,var(--td-gray-color-4,#dcdcdc)));}
|
||||
.t-stepper__minus--filled,.t-stepper__minus--outline{border-radius:0;border-top-left-radius:var(--td-stepper-border-radius,var(--td-radius-small,6rpx));border-bottom-left-radius:var(--td-stepper-border-radius,var(--td-radius-small,6rpx));}
|
||||
.t-stepper__plus--filled,.t-stepper__plus--outline{border-radius:0;border-top-right-radius:var(--td-stepper-border-radius,var(--td-radius-small,6rpx));border-bottom-right-radius:var(--td-stepper-border-radius,var(--td-radius-small,6rpx));}
|
||||
.t-stepper__minus--filled,.t-stepper__plus--filled{background-color:var(--td-bg-color-secondarycontainer,var(--td-gray-color-1,#f3f3f3));}
|
||||
.t-stepper__input--filled{background-color:var(--td-bg-color-secondarycontainer,var(--td-gray-color-1,#f3f3f3));margin:0 8rpx;}
|
||||
.t-stepper__input--filled .t-stepper__input{margin:0;}
|
||||
.t-stepper--normal-disabled{color:var(--td-stepper-input-disabled-color,var(--td-text-color-disabled,var(--td-font-gray-4,rgba(0,0,0,.26))));}
|
||||
.t-stepper--filled-disabled,.t-stepper--outline-disabled{color:var(--td-stepper-input-disabled-color,var(--td-text-color-disabled,var(--td-font-gray-4,rgba(0,0,0,.26))));background-color:var(--td-stepper-input-disabled-bg,var(--td-bg-color-component-disabled,var(--td-gray-color-2,#eee)));}
|
||||
47
miniprogram/miniprogram_npm/tdesign-miniprogram/stepper/type.d.ts
vendored
Normal file
47
miniprogram/miniprogram_npm/tdesign-miniprogram/stepper/type.d.ts
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
import { SizeEnum } from '../common/common';
|
||||
export interface TdStepperProps {
|
||||
disableInput?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
disabled?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
inputWidth?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
integer?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
max?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
min?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
size?: {
|
||||
type: StringConstructor;
|
||||
value?: SizeEnum;
|
||||
};
|
||||
step?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
theme?: {
|
||||
type: StringConstructor;
|
||||
value?: 'normal' | 'filled' | 'outline';
|
||||
};
|
||||
value?: {
|
||||
type: null;
|
||||
value?: string | number;
|
||||
};
|
||||
defaultValue?: {
|
||||
type: null;
|
||||
value?: string | number;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export{};
|
||||
Reference in New Issue
Block a user