初始化项目, 添加TDesign等包
This commit is contained in:
3
miniprogram/miniprogram_npm/tdesign-miniprogram/textarea/props.d.ts
vendored
Normal file
3
miniprogram/miniprogram_npm/tdesign-miniprogram/textarea/props.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { TdTextareaProps } from './type';
|
||||
declare const props: TdTextareaProps;
|
||||
export default props;
|
||||
@@ -0,0 +1 @@
|
||||
const props={adjustPosition:{type:Boolean,value:!0},allowInputOverMax:{type:Boolean,value:!1},autofocus:{type:Boolean,value:!1},autosize:{type:null,value:!1},bordered:{type:Boolean,value:!1},confirmHold:{type:Boolean,value:!1},confirmType:{type:String,value:"return"},cursor:{type:Number,value:-1},cursorColor:{type:String,value:"#0052d9"},cursorSpacing:{type:Number,value:0},disableDefaultPadding:{type:Boolean,value:!1},disabled:{type:null,value:void 0},fixed:{type:Boolean,value:!1},focus:{type:Boolean,value:!1},holdKeyboard:{type:Boolean,value:!1},indicator:{type:Boolean,value:!1},label:{type:String},maxcharacter:{type:Number},maxlength:{type:Number,value:-1},placeholder:{type:String,value:void 0},placeholderClass:{type:String,value:"textarea-placeholder"},placeholderStyle:{type:String,value:""},readonly:{type:null,value:void 0},selectionEnd:{type:Number,value:-1},selectionStart:{type:Number,value:-1},showConfirmBar:{type:Boolean,value:!0},value:{type:null,value:null},defaultValue:{type:null}};export default props;
|
||||
34
miniprogram/miniprogram_npm/tdesign-miniprogram/textarea/textarea.d.ts
vendored
Normal file
34
miniprogram/miniprogram_npm/tdesign-miniprogram/textarea/textarea.d.ts
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import { SuperComponent } from '../common/src/index';
|
||||
export default class Textarea extends SuperComponent {
|
||||
options: {
|
||||
multipleSlots: boolean;
|
||||
};
|
||||
behaviors: string[];
|
||||
externalClasses: string[];
|
||||
properties: import("./type").TdTextareaProps;
|
||||
data: {
|
||||
prefix: string;
|
||||
classPrefix: string;
|
||||
count: number;
|
||||
};
|
||||
observers: {
|
||||
value(val: any): void;
|
||||
};
|
||||
lifetimes: {
|
||||
ready(): void;
|
||||
};
|
||||
methods: {
|
||||
updateCount(val: any): void;
|
||||
updateValue(val: any): void;
|
||||
calculateValue(value: any, maxcharacter: any, maxlength: any): {
|
||||
value: any;
|
||||
count: number;
|
||||
};
|
||||
onInput(event: any): void;
|
||||
onFocus(event: any): void;
|
||||
onBlur(event: any): void;
|
||||
onConfirm(event: any): void;
|
||||
onLineChange(event: any): void;
|
||||
onKeyboardHeightChange(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}from"../common/utils";const{prefix:prefix}=config,name=`${prefix}-textarea`;let Textarea=class extends SuperComponent{constructor(){super(...arguments),this.options={multipleSlots:!0},this.behaviors=["wx://form-field"],this.externalClasses=[`${prefix}-class`,`${prefix}-class-textarea`,`${prefix}-class-label`,`${prefix}-class-indicator`],this.properties=props,this.data={prefix:prefix,classPrefix:name,count:0},this.observers={value(e){this.updateCount(null!=e?e:this.properties.defaultValue)}},this.lifetimes={ready(){var e;const{value:t,defaultValue:a}=this.properties;this.updateValue(null!==(e=null!=t?t:a)&&void 0!==e?e:"")}},this.methods={updateCount(e){const{maxcharacter:t,maxlength:a}=this.properties,{count:r}=this.calculateValue(e,t,a);this.setData({count:r})},updateValue(e){const{maxcharacter:t,maxlength:a}=this.properties,{value:r,count:s}=this.calculateValue(e,t,a);this.setData({value:r,count:s})},calculateValue(e,t,a){const{allowInputOverMax:r}=this.properties;if(t>0&&!Number.isNaN(t)){const{length:a,characters:s}=getCharacterLength("maxcharacter",e,r?1/0:t);return{value:s,count:a}}if(a>0&&!Number.isNaN(a)){const{length:t,characters:s}=getCharacterLength("maxlength",e,r?1/0:a);return{value:s,count:t}}return{value:e,count:e?String(e).length:0}},onInput(e){const{value:t,cursor:a}=e.detail;this.updateValue(t),this.triggerEvent("change",{value:this.data.value,cursor:a})},onFocus(e){this.triggerEvent("focus",Object.assign({},e.detail))},onBlur(e){this.triggerEvent("blur",Object.assign({},e.detail))},onConfirm(e){this.triggerEvent("enter",Object.assign({},e.detail))},onLineChange(e){this.triggerEvent("line-change",Object.assign({},e.detail))},onKeyboardHeightChange(e){this.triggerEvent("keyboardheightchange",e.detail)}}}};Textarea=__decorate([wxComponent()],Textarea);export default Textarea;
|
||||
@@ -0,0 +1 @@
|
||||
{"component":true,"styleIsolation":"apply-shared","usingComponents":{}}
|
||||
@@ -0,0 +1 @@
|
||||
<wxs src="../common/utils.wxs" module="_"/><wxs src="./textarea.wxs" module="_this"/><view style="{{_._style([style, customStyle])}}" class="{{classPrefix}} {{bordered? classPrefix + '--border' : ''}} class {{prefix}}-class"><view class="{{classPrefix}}__label {{prefix}}-class-label"><block wx:if="{{label}}">{{ label }}</block><slot name="label"/></view><view class="{{classPrefix}}__wrapper"><textarea class="{{classPrefix}}__wrapper-inner {{disabled? prefix + '-is-disabled' : ''}} {{prefix}}-class-textarea" style="{{_this.textareaStyle(autosize)}}" maxlength="{{allowInputOverMax ? -1 : maxlength}}" disabled="{{disabled || readonly}}" placeholder="{{placeholder}}" placeholder-class="{{classPrefix}}__placeholder {{placeholderClass}}" placeholder-style="{{placeholderStyle}}" value="{{value}}" auto-height="{{!!autosize}}" auto-focus="{{autofocus}}" fixed="{{fixed}}" focus="{{focus}}" cursor="{{cursor}}" cursor-spacing="{{cursorSpacing}}" cursor-color="{{cursorColor}}" adjust-position="{{adjustPosition}}" confirm-type="{{confirmType}}" confirm-hold="{{confirmHold}}" disable-default-padding="{{disableDefaultPadding}}" show-confirm-bar="{{showConfirmBar}}" selection-start="{{selectionStart}}" selection-end="{{selectionEnd}}" hold-keyboard="{{holdKeyboard}}" bindinput="onInput" bindfocus="onFocus" bindblur="onBlur" bindconfirm="onConfirm" bindlinechange="onLineChange" bind:keyboardheightchange="onKeyboardHeightChange"/><view wx:if="{{indicator && (maxcharacter > 0 || maxlength > 0 )}}" class="{{classPrefix}}__indicator {{prefix}}-class-indicator">{{count}} / {{maxcharacter || maxlength}}</view></view></view>
|
||||
@@ -0,0 +1,15 @@
|
||||
var utils = require('../common/utils.wxs');
|
||||
|
||||
function textareaStyle(autosize) {
|
||||
if (autosize && autosize.constructor === 'Object') {
|
||||
return utils._style({
|
||||
'min-height': utils.addUnit(autosize.minHeight),
|
||||
'max-height': utils.addUnit(autosize.maxHeight),
|
||||
});
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
textareaStyle: textareaStyle,
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
@import '../common/style/index.wxss';.t-textarea{display:flex;flex-direction:column;box-sizing:border-box;padding:var(--td-textarea-padding,32rpx);background-color:var(--td-textarea-background-color,var(--td-bg-color-container,var(--td-font-white-1,#fff)));}
|
||||
.t-textarea__label:not(:empty){font-size:var(--td-font-size-base,28rpx);color:var(--td-textarea-label-color,var(--td-text-color-primary,var(--td-font-gray-1,rgba(0,0,0,.9))));flex-shrink:0;line-height:44rpx;padding-bottom:var(--td-spacer,16rpx);overflow:hidden;white-space:nowrap;text-overflow:ellipsis;}
|
||||
.t-textarea__wrapper{display:flex;flex-direction:column;width:100%;flex:1 1 auto;overflow:hidden;}
|
||||
.t-textarea__wrapper-inner{flex:1 1 auto;box-sizing:border-box;width:inherit;min-width:0;min-height:20px;margin:0;padding:0;text-align:left;background-color:transparent;border:0;resize:none;font-size:var(--td-font-size-m,32rpx);color:var(--td-textarea-text-color,var(--td-text-color-primary,var(--td-font-gray-1,rgba(0,0,0,.9))));line-height:48rpx;}
|
||||
.t-textarea__placeholder{color:var(--td-textarea-placeholder-color,var(--td-text-color-placeholder,var(--td-font-gray-3,rgba(0,0,0,.4))));font-size:var(--td-font-size-m,32rpx);}
|
||||
.t-textarea__indicator:not(:empty){flex-shrink:0;color:var(--td-textarea-indicator-text-color,var(--td-text-color-placeholder,var(--td-font-gray-3,rgba(0,0,0,.4))));font-size:var(--td-spacer-1,24rpx);text-align:right;line-height:40rpx;padding-top:var(--td-spacer,16rpx);}
|
||||
.t-textarea--border{border-radius:var(--td-textarea-border-radius,var(--td-radius-default,12rpx));position:relative;}
|
||||
.t-textarea--border::after{content:'';position:absolute;top:0;left:0;right:0;bottom:0;border:2rpx solid var(--td-textarea-border-color,var(--td-component-border,var(--td-gray-color-4,#dcdcdc)));border-radius:inherit;pointer-events:none;}
|
||||
.t-textarea .t-is-disabled{color:var(--td-textarea-disabled-text-color,var(--td-text-color-disabled,var(--td-font-gray-4,rgba(0,0,0,.26))));}
|
||||
118
miniprogram/miniprogram_npm/tdesign-miniprogram/textarea/type.d.ts
vendored
Normal file
118
miniprogram/miniprogram_npm/tdesign-miniprogram/textarea/type.d.ts
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
export interface TdTextareaProps {
|
||||
adjustPosition?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
allowInputOverMax?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
autofocus?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
autosize?: {
|
||||
type: null;
|
||||
value?: boolean | {
|
||||
maxHeight?: number;
|
||||
minHeight?: number;
|
||||
};
|
||||
};
|
||||
bordered?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
confirmHold?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
confirmType?: {
|
||||
type: StringConstructor;
|
||||
value?: 'return' | 'send' | 'search' | 'next' | 'go' | 'done';
|
||||
};
|
||||
cursor?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
cursorColor?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
cursorSpacing?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
disableDefaultPadding?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
disabled?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
fixed?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
focus?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
holdKeyboard?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
indicator?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
label?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
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;
|
||||
};
|
||||
readonly?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
selectionEnd?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
selectionStart?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
showConfirmBar?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
value?: {
|
||||
type: null;
|
||||
value?: TextareaValue;
|
||||
};
|
||||
defaultValue?: {
|
||||
type: null;
|
||||
value?: TextareaValue;
|
||||
};
|
||||
}
|
||||
export declare type TextareaValue = string | number;
|
||||
@@ -0,0 +1 @@
|
||||
export{};
|
||||
Reference in New Issue
Block a user