初始化项目, 添加TDesign等包
This commit is contained in:
38
miniprogram/miniprogram_npm/tdesign-miniprogram/input/input.d.ts
vendored
Normal file
38
miniprogram/miniprogram_npm/tdesign-miniprogram/input/input.d.ts
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
import { SuperComponent } from '../common/src/index';
|
||||
export default class Input extends SuperComponent {
|
||||
options: {
|
||||
multipleSlots: boolean;
|
||||
};
|
||||
externalClasses: string[];
|
||||
behaviors: string[];
|
||||
properties: import("./type").TdInputProps;
|
||||
data: {
|
||||
prefix: string;
|
||||
classPrefix: string;
|
||||
classBasePrefix: string;
|
||||
showClearIcon: boolean;
|
||||
};
|
||||
lifetimes: {
|
||||
ready(): void;
|
||||
};
|
||||
observers: {
|
||||
prefixIcon(v: any): void;
|
||||
suffixIcon(v: any): void;
|
||||
clearable(v: any): void;
|
||||
'clearTrigger, clearable, disabled, readonly'(): void;
|
||||
};
|
||||
methods: {
|
||||
updateValue(value: any): void;
|
||||
updateClearIconVisible(value?: boolean): void;
|
||||
onInput(e: any): void;
|
||||
onChange(e: any): void;
|
||||
onFocus(e: any): void;
|
||||
onBlur(e: any): void;
|
||||
onConfirm(e: any): void;
|
||||
onSuffixClick(): void;
|
||||
onSuffixIconClick(): void;
|
||||
clearInput(e: any): void;
|
||||
onKeyboardHeightChange(e: any): void;
|
||||
onNickNameReview(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";import{getCharacterLength,calcIcon}from"../common/utils";import{isDef}from"../common/validator";const{prefix:prefix}=config,name=`${prefix}-input`;let Input=class extends SuperComponent{constructor(){super(...arguments),this.options={multipleSlots:!0},this.externalClasses=[`${prefix}-class`,`${prefix}-class-prefix-icon`,`${prefix}-class-label`,`${prefix}-class-input`,`${prefix}-class-clearable`,`${prefix}-class-suffix`,`${prefix}-class-suffix-icon`,`${prefix}-class-tips`],this.behaviors=["wx://form-field"],this.properties=props,this.data={prefix:prefix,classPrefix:name,classBasePrefix:prefix,showClearIcon:!0},this.lifetimes={ready(){var e;const{value:t,defaultValue:i}=this.properties;this.updateValue(null!==(e=null!=t?t:i)&&void 0!==e?e:"")}},this.observers={prefixIcon(e){this.setData({_prefixIcon:calcIcon(e)})},suffixIcon(e){this.setData({_suffixIcon:calcIcon(e)})},clearable(e){this.setData({_clearIcon:calcIcon(e,"close-circle-filled")})},"clearTrigger, clearable, disabled, readonly"(){this.updateClearIconVisible()}},this.methods={updateValue(e){const{allowInputOverMax:t,maxcharacter:i,maxlength:a}=this.properties;if(!t&&i&&i>0&&!Number.isNaN(i)){const{length:t,characters:a}=getCharacterLength("maxcharacter",e,i);this.setData({value:a,count:t})}else if(!t&&a&&a>0&&!Number.isNaN(a)){const{length:t,characters:i}=getCharacterLength("maxlength",e,a);this.setData({value:i,count:t})}else this.setData({value:e,count:isDef(e)?String(e).length:0})},updateClearIconVisible(e=!1){const{clearTrigger:t,disabled:i,readonly:a}=this.properties;i||a?this.setData({showClearIcon:!1}):this.setData({showClearIcon:e||"always"===t})},onInput(e){const{value:t,cursor:i,keyCode:a}=e.detail;this.updateValue(t),this.triggerEvent("change",{value:this.data.value,cursor:i,keyCode:a})},onChange(e){if("nickname"!==this.properties.type)return;const{value:t}=e.detail;this.updateValue(t),this.triggerEvent("change",{value:this.data.value})},onFocus(e){this.updateClearIconVisible(!0),this.triggerEvent("focus",e.detail)},onBlur(e){if(this.updateClearIconVisible(),"function"==typeof this.properties.format){const t=this.properties.format(e.detail.value);return this.updateValue(t),void this.triggerEvent("blur",{value:this.data.value,cursor:this.data.count})}this.triggerEvent("blur",e.detail)},onConfirm(e){this.triggerEvent("enter",e.detail)},onSuffixClick(){this.triggerEvent("click",{trigger:"suffix"})},onSuffixIconClick(){this.triggerEvent("click",{trigger:"suffix-icon"})},clearInput(e){this.triggerEvent("clear",e.detail),this.setData({value:""})},onKeyboardHeightChange(e){this.triggerEvent("keyboardheightchange",e.detail)},onNickNameReview(e){this.triggerEvent("nicknamereview",e.detail)}}}};Input=__decorate([wxComponent()],Input);export default Input;
|
||||
@@ -0,0 +1 @@
|
||||
{"component":true,"styleIsolation":"apply-shared","usingComponents":{"t-icon":"../icon/icon"}}
|
||||
@@ -0,0 +1 @@
|
||||
<import src="../common/template/icon.wxml"/><wxs src="../common/utils.wxs" module="_"/><wxs src="./input.wxs" module="_this"/><view style="{{_._style([style, customStyle])}}" class="{{_.cls(classPrefix, [['border', !borderless]])}} {{classPrefix}}--layout-{{layout}} class {{prefix}}-class" aria-describedby><view class="{{classPrefix}}__wrap--prefix"><view class="{{classPrefix}}__icon--prefix"><slot name="prefix-icon"/><template wx:if="{{_prefixIcon}}" is="icon" data="{{tClass: prefix + '-class-prefix-icon', ariaHidden: true, ..._prefixIcon}}"/></view><view class="{{classPrefix}}__label {{prefix}}-class-label" aria-hidden><slot name="label"/><block wx:if="{{label}}">{{label}}</block></view></view><view class="{{classPrefix}}__wrap"><view class="{{classPrefix}}__content {{classPrefix}}--{{status}}"><input class="{{_this.getInputClass(classPrefix, suffix, align, disabled)}} {{prefix}}-class-input" maxlength="{{allowInputOverMax ? -1 : maxlength}}" disabled="{{disabled || readonly}}" placeholder="{{placeholder}}" placeholder-style="{{placeholderStyle}}" placeholder-class="{{_.cls(classPrefix + '__placeholder', [['disabled', disabled]])}} {{placeholderClass}}" value="{{value}}" password="{{type === 'password'}}" type="{{type === 'password' ? 'text' : type}}" focus="{{focus}}" confirm-type="{{confirmType}}" confirm-hold="{{confirmHold}}" cursor="{{cursor}}" cursor-color="{{cursorColor}}" cursor-spacing="{{cursorSpacing}}" adjust-position="{{adjustPosition}}" auto-focus="{{autoFocus}}" always-embed="{{alwaysEmbed}}" selection-start="{{selectionStart}}" selection-end="{{selectionEnd}}" hold-keyboard="{{holdKeyboard}}" safe-password-cert-path="{{safePasswordCertPath}}" safe-password-length="{{safePasswordLength}}" safe-password-time-stamp="{{safePasswordTimeStamp}}" safe-password-nonce="{{safePasswordNonce}}" safe-password-salt="{{safePasswordSalt}}" safe-password-custom-hash="{{safePasswordCustomHash}}" aria-role="textbox" aria-label="{{label}}" aria-roledescription="{{label}}" bindinput="onInput" bindchange="onChange" bindfocus="onFocus" bindblur="onBlur" bindconfirm="onConfirm" bindkeyboardheightchange="onKeyboardHeightChange" bindnicknamereview="onNickNameReview"/><view wx:if="{{_clearIcon && value.length > 0 && showClearIcon}}" class="{{classPrefix}}__wrap--clearable-icon" bind:tap="clearInput"><template is="icon" data="{{tClass: prefix + '-class-clearable', ariaRole: 'button', ariaLabel: '清除', ..._clearIcon }}"/></view><view class="{{classPrefix}}__wrap--suffix {{prefix}}-class-suffix" bind:tap="onSuffixClick"><text wx:if="{{suffix}}">{{suffix}}</text><slot name="suffix"/></view><view class="{{classPrefix}}__wrap--suffix-icon" bind:tap="onSuffixIconClick"><slot name="suffix-icon"/><template wx:if="{{_suffixIcon}}" is="icon" data="{{tClass: prefix + '-class-suffix-icon', ariaRole: 'button', ..._suffixIcon }}"/></view></view><view wx:if="{{tips && tips.length > 0}}" class="{{classPrefix}}__tips {{classPrefix}}--{{align}} {{prefix}}-class-tips">{{tips}}</view><slot name="tips"/></view><slot name="extra"/></view>
|
||||
@@ -0,0 +1,16 @@
|
||||
function getInputClass(classPrefix, suffix, align, disabled) {
|
||||
var className = [classPrefix + '__control'];
|
||||
|
||||
if (align) {
|
||||
className.push(classPrefix + '--' + align);
|
||||
}
|
||||
|
||||
if (disabled) {
|
||||
className.push(classPrefix + '__control--disabled');
|
||||
}
|
||||
return className.join(' ');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getInputClass: getInputClass,
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
@import '../common/style/index.wxss';.t-input{background-color:var(--td-input-bg-color,var(--td-bg-color-container,var(--td-font-white-1,#fff)));display:flex;align-items:var(--td-input-align-items,center);flex:1;padding:var(--td-input-vertical-padding,32rpx);overflow:hidden;}
|
||||
.t-input--border{position:relative;}
|
||||
.t-input--border::after{content:'';display:block;position:absolute;top:unset;bottom:0;left:unset;right:unset;background-color:var(--td-input-border-color,var(--td-component-stroke,var(--td-gray-color-3,#e7e7e7)));}
|
||||
.t-input--border::after{height:1px;left:0;right:0;transform:scaleY(.5);}
|
||||
.t-input--border:after{left:var(--td-input-border-left-space,32rpx);right:var(--td-input-border-right-space,0);}
|
||||
.t-input--layout-vertical{flex-direction:column;align-items:start;}
|
||||
.t-input__wrap--prefix{display:flex;}
|
||||
.t-input__icon--prefix{font-size:48rpx;color:var(--td-input-prefix-icon-color,var(--td-text-color-primary,var(--td-font-gray-1,rgba(0,0,0,.9))));}
|
||||
.t-input__label:not(:empty){min-width:var(--td-input-label-min-width,2em);max-width:var(--td-input-label-max-width,5em);font-size:var(--td-font-size-m,32rpx);line-height:48rpx;color:var(--td-input-label-text-color,var(--td-text-color-primary,var(--td-font-gray-1,rgba(0,0,0,.9))));margin-right:var(--td-spacer-2,32rpx);word-wrap:break-word;}
|
||||
.t-input--layout-vertical .t-input__label:not(:empty){font-size:var(--td-font-size-base,28rpx);padding-bottom:8rpx;}
|
||||
.t-input__icon--prefix:not(:empty)+.t-input__label:not(:empty){padding-left:8rpx;}
|
||||
.t-input__label:not(:empty)+.t-input__wrap{margin-left:var(--td-spacer-2,32rpx);}
|
||||
.t-input__icon--prefix:not(:empty)+.t-input__label:empty{margin-right:var(--td-spacer-2,32rpx);}
|
||||
.t-input__wrap{width:100%;display:flex;flex-direction:column;flex-wrap:wrap;justify-content:center;flex-shrink:1;flex:1;}
|
||||
.t-input__wrap .t-input__content{display:flex;width:100%;align-items:center;line-height:48rpx;font-size:var(--td-font-size-m,32rpx);}
|
||||
.t-input__wrap--clearable-icon,.t-input__wrap--suffix,.t-input__wrap--suffix-icon{flex:0 0 auto;padding-left:var(--td-spacer-1,24rpx);}
|
||||
.t-input__wrap--clearable-icon:empty,.t-input__wrap--suffix-icon:empty,.t-input__wrap--suffix:empty{display:none;}
|
||||
.t-input__wrap--clearable-icon,.t-input__wrap--suffix-icon{font-size:48rpx;color:var(--td-input-suffix-icon-color,var(--td-text-color-placeholder,var(--td-font-gray-3,rgba(0,0,0,.4))));}
|
||||
.t-input__wrap--suffix{font-size:var(--td-font-size-m,32rpx);color:var(--td-input-suffix-text-color,var(--td-text-color-primary,var(--td-font-gray-1,rgba(0,0,0,.9))));}
|
||||
.t-input__icon--prefix:empty,.t-input__tips:empty,.t-input__wrap--clearable-icon:empty,.t-input__wrap--suffix-icon:empty,.t-input__wrap--suffix:empty{display:none;}
|
||||
.t-input__control{display:block;box-sizing:border-box;width:100%;min-width:0;min-height:48rpx;margin:0;padding:0;color:var(--td-input-default-text-color,var(--td-text-color-primary,var(--td-font-gray-1,rgba(0,0,0,.9))));line-height:inherit;background-color:transparent;border:0;resize:none;font-size:inherit;}
|
||||
.t-input__control--disabled{color:var(--td-input-disabled-text-color,var(--td-text-color-disabled,var(--td-font-gray-4,rgba(0,0,0,.26))));cursor:not-allowed;opacity:1;-webkit-text-fill-color:currentColor;}
|
||||
.t-input__control--read-only{cursor:default;}
|
||||
.t-input--left{text-align:left;}
|
||||
.t-input--right{text-align:right;}
|
||||
.t-input--center{text-align:center;}
|
||||
.t-input__placeholder{color:var(--td-input-placeholder-text-color,var(--td-text-color-placeholder,var(--td-font-gray-3,rgba(0,0,0,.4))));font-size:var(--td-input-placeholder-text-font-size,var(--td-font-size-m,32rpx));}
|
||||
.t-input__placeholder--disabled{color:var(--td-input-disabled-text-color,var(--td-text-color-disabled,var(--td-font-gray-4,rgba(0,0,0,.26))));}
|
||||
.t-input__tips{font-size:var(--td-font-size-s,24rpx);line-height:40rpx;padding-top:8rpx;}
|
||||
.t-input--default+.t-input__tips{color:var(--td-input-default-tips-color,var(--td-text-color-placeholder,var(--td-font-gray-3,rgba(0,0,0,.4))));}
|
||||
.t-input--success+.t-input__tips{color:var(--td-input-success-tips-color,var(--td-success-color,var(--td-success-color-5,#2ba471)));}
|
||||
.t-input--warning+.t-input__tips{color:var(--td-input-warning-tips-color,var(--td-warning-color,var(--td-warning-color-5,#e37318)));}
|
||||
.t-input--error+.t-input__tips{color:var(--td-input-error-tips-color,var(--td-error-color,var(--td-error-color-6,#d54941)));}
|
||||
3
miniprogram/miniprogram_npm/tdesign-miniprogram/input/props.d.ts
vendored
Normal file
3
miniprogram/miniprogram_npm/tdesign-miniprogram/input/props.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { TdInputProps } from './type';
|
||||
declare const props: TdInputProps;
|
||||
export default props;
|
||||
@@ -0,0 +1 @@
|
||||
const props={adjustPosition:{type:Boolean,value:!0},align:{type:String,value:"left"},allowInputOverMax:{type:Boolean,value:!1},alwaysEmbed:{type:Boolean,value:!1},autoFocus:{type:Boolean,value:!1},borderless:{type:Boolean,value:!1},clearTrigger:{type:String,value:"always"},clearable:{type:null,value:!1},confirmHold:{type:Boolean,value:!1},confirmType:{type:String,value:"done"},cursor:{type:Number,value:-1,required:!0},cursorColor:{type:String,value:"#0052d9"},cursorSpacing:{type:Number,value:0},disabled:{type:null,value:void 0},focus:{type:Boolean,value:!1},format:{type:null},holdKeyboard:{type:Boolean,value:!1},label:{type:String},layout:{type:String,value:"horizontal"},maxcharacter:{type:Number},maxlength:{type:Number,value:-1},placeholder:{type:String,value:void 0},placeholderClass:{type:String,value:"input-placeholder"},placeholderStyle:{type:String,value:"",required:!0},prefixIcon:{type:null},readonly:{type:null,value:void 0},safePasswordCertPath:{type:String,value:""},safePasswordCustomHash:{type:String,value:""},safePasswordLength:{type:Number},safePasswordNonce:{type:String,value:""},safePasswordSalt:{type:String,value:""},safePasswordTimeStamp:{type:Number},selectionEnd:{type:Number,value:-1},selectionStart:{type:Number,value:-1},status:{type:String,value:"default"},suffix:{type:String},suffixIcon:{type:null},tips:{type:String},type:{type:String,value:"text"},value:{type:null}};export default props;
|
||||
166
miniprogram/miniprogram_npm/tdesign-miniprogram/input/type.d.ts
vendored
Normal file
166
miniprogram/miniprogram_npm/tdesign-miniprogram/input/type.d.ts
vendored
Normal file
@@ -0,0 +1,166 @@
|
||||
export interface TdInputProps {
|
||||
adjustPosition?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
align?: {
|
||||
type: StringConstructor;
|
||||
value?: 'left' | 'center' | 'right';
|
||||
};
|
||||
allowInputOverMax?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
alwaysEmbed?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
autoFocus?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
borderless?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
clearTrigger?: {
|
||||
type: StringConstructor;
|
||||
value?: 'always' | 'focus';
|
||||
};
|
||||
clearable?: {
|
||||
type: null;
|
||||
value?: boolean | object;
|
||||
};
|
||||
confirmHold?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
confirmType?: {
|
||||
type: StringConstructor;
|
||||
value?: 'send' | 'search' | 'next' | 'go' | 'done';
|
||||
};
|
||||
cursor: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
required?: boolean;
|
||||
};
|
||||
cursorColor?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
cursorSpacing?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
disabled?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
focus?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
format?: {
|
||||
type: undefined;
|
||||
value?: InputFormatType;
|
||||
};
|
||||
holdKeyboard?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
label?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
layout?: {
|
||||
type: StringConstructor;
|
||||
value?: 'vertical' | 'horizontal';
|
||||
};
|
||||
maxcharacter?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
maxlength?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
placeholder?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
placeholderClass?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
placeholderStyle: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
required?: boolean;
|
||||
};
|
||||
prefixIcon?: {
|
||||
type: null;
|
||||
value?: string | object;
|
||||
};
|
||||
readonly?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
safePasswordCertPath?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
safePasswordCustomHash?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
safePasswordLength?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
safePasswordNonce?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
safePasswordSalt?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
safePasswordTimeStamp?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
selectionEnd?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
selectionStart?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
status?: {
|
||||
type: StringConstructor;
|
||||
value?: 'default' | 'success' | 'warning' | 'error';
|
||||
};
|
||||
suffix?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
suffixIcon?: {
|
||||
type: null;
|
||||
value?: string | object;
|
||||
};
|
||||
tips?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
type?: {
|
||||
type: StringConstructor;
|
||||
value?: 'text' | 'number' | 'idcard' | 'digit' | 'safe-password' | 'password' | 'nickname';
|
||||
};
|
||||
value?: {
|
||||
type: null;
|
||||
value?: InputValue;
|
||||
};
|
||||
}
|
||||
export declare type InputFormatType = (value: InputValue) => string;
|
||||
export declare type InputValue = string | number;
|
||||
@@ -0,0 +1 @@
|
||||
export{};
|
||||
Reference in New Issue
Block a user