初始化项目, 添加TDesign等包

This commit is contained in:
zhengw
2025-11-28 16:49:36 +08:00
commit 3e53beb7bb
980 changed files with 39201 additions and 0 deletions

View File

@@ -0,0 +1,100 @@
import { SuperComponent, ComponentsOptionsType, RelationsOptions } from '../common/src/index';
export default class CheckBox extends SuperComponent {
externalClasses: string[];
behaviors: string[];
relations: RelationsOptions;
options: ComponentsOptionsType;
properties: {
theme: {
type: StringConstructor;
value: string;
};
tId: {
type: StringConstructor;
};
block?: {
type: BooleanConstructor;
value?: boolean;
};
borderless?: {
type: BooleanConstructor;
value?: boolean;
};
checkAll?: {
type: BooleanConstructor;
value?: boolean;
};
checked?: {
type: BooleanConstructor;
value?: boolean;
};
defaultChecked?: {
type: BooleanConstructor;
value?: boolean;
};
content?: {
type: StringConstructor;
value?: string;
};
contentDisabled?: {
type: BooleanConstructor;
value?: boolean;
};
disabled?: {
type: BooleanConstructor;
value?: boolean;
};
icon?: {
type: null;
value?: string[] | "rectangle" | "circle" | "line";
};
indeterminate?: {
type: BooleanConstructor;
value?: boolean;
};
label?: {
type: StringConstructor;
value?: string;
};
maxContentRow?: {
type: NumberConstructor;
value?: number;
};
maxLabelRow?: {
type: NumberConstructor;
value?: number;
};
name?: {
type: StringConstructor;
value?: string;
};
placement?: {
type: StringConstructor;
value?: "left" | "right";
};
readonly?: {
type: BooleanConstructor;
value?: boolean;
};
value?: {
type: null;
value?: string | number | boolean;
};
};
data: {
prefix: string;
classPrefix: string;
_disabled: boolean;
};
observers: {
disabled(v: any): void;
};
controlledProps: {
key: string;
event: string;
}[];
methods: {
handleTap(e: WechatMiniprogram.TouchEvent): void;
setDisabled(disabled: Boolean): void;
};
}

View File

@@ -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}-checkbox`;let CheckBox=class extends SuperComponent{constructor(){super(...arguments),this.externalClasses=[`${prefix}-class`,`${prefix}-class-label`,`${prefix}-class-icon`,`${prefix}-class-content`,`${prefix}-class-border`],this.behaviors=["wx://form-field"],this.relations={"../checkbox-group/checkbox-group":{type:"ancestor",linked(e){const{value:t,disabled:s,borderless:a}=e.data,i=new Set(t),o=i.has(this.data.value),c={_disabled:null==this.data.disabled?s:this.data.disabled};a&&(c.borderless=!0),c.checked=this.data.checked||o,this.data.checked&&e.updateValue(this.data),this.data.checkAll&&(c.checked=i.size>0),this.setData(c)}}},this.options={multipleSlots:!0},this.properties=Object.assign(Object.assign({},Props),{theme:{type:String,value:"default"},tId:{type:String}}),this.data={prefix:prefix,classPrefix:name,_disabled:!1},this.observers={disabled(e){this.setData({_disabled:e})}},this.controlledProps=[{key:"checked",event:"change"}],this.methods={handleTap(e){const{_disabled:t,readonly:s,contentDisabled:a}=this.data,{target:i}=e.currentTarget.dataset;if(t||s||"text"===i&&a)return;const{value:o,label:c}=this.data,d=!this.data.checked,r=this.$parent;r?r.updateValue(Object.assign(Object.assign({},this.data),{checked:d,item:{label:c,value:o,checked:d}})):this._trigger("change",{context:{value:o,label:c},checked:d})},setDisabled(e){this.setData({_disabled:this.data.disabled||e})}}}};CheckBox=__decorate([wxComponent()],CheckBox);export default CheckBox;

View File

@@ -0,0 +1 @@
{"component":true,"styleIsolation":"apply-shared","usingComponents":{"t-icon":"../icon/icon"}}

View File

@@ -0,0 +1 @@
<wxs src="../common/utils.wxs" module="_"/><view id="{{tId}}" style="{{_._style([style, customStyle])}}" class="{{_.cls(classPrefix, [placement, theme, ['checked', checked], ['block', block], ['disabled', _disabled]])}} class {{prefix}}-class" aria-role="checkbox" aria-checked="{{checked ? (indeterminate ? 'mixed' : true) : false}}" aria-disabled="{{_disabled ? true : false}}" mut-bind:tap="handleTap" tabindex="{{tabindex}}"><view wx:if="{{theme == 'default'}}" class="{{_.cls(classPrefix + '__icon', [placement, ['checked', checked], ['disabled', _disabled]])}} {{prefix}}-class-icon"><slot name="icon" wx:if="{{icon === 'slot'}}"/><view wx:elif="{{_.isArray(icon)}}" class="{{classPrefix}}__icon"><image src="{{checked ? indeterminate && icon[2] ? icon[2] : icon[0] : icon[1]}}" class="{{classPrefix}}__icon-image"/></view><block wx:else><t-icon wx:if="{{checked && (icon == 'circle' || icon == 'rectangle')}}" name="{{indeterminate ? ('minus-' + icon + '-filled') : ('check-' + icon + '-filled')}}" class="{{_.cls(classPrefix + '__icon-wrapper', [])}}"/><t-icon wx:if="{{checked && icon == 'line'}}" name="{{indeterminate ? ('minus-' + icon + '-filled') : 'check'}}" class="{{_.cls(classPrefix + '__icon-wrapper', [])}}"/><view wx:elif="{{!checked && (icon == 'circle' || icon == 'rectangle')}}" class="{{_.cls(classPrefix + '__icon-' + icon, [['disabled', _disabled]])}}"/><view wx:if="{{!checked && icon == 'line'}}" class="placeholder"></view></block></view><view class="{{classPrefix}}__content" data-target="text" mut-bind:tap="handleTap"><view class="{{_.cls(classPrefix + '__title', [['disabled', _disabled], ['checked', checked]])}} {{prefix}}-class-label" style="-webkit-line-clamp:{{maxLabelRow}}"><block wx:if="{{label}}">{{label}}</block><slot/><slot name="label"/></view><view class="{{_.cls(classPrefix + '__description', [['disabled', _disabled]])}} {{prefix}}-class-content" style="-webkit-line-clamp:{{maxContentRow}}"><block wx:if="{{content}}">{{content}}</block><slot name="content"/></view></view><view wx:if="{{theme == 'default' && !borderless}}" class="{{_.cls(classPrefix + '__border', [placement])}} {{prefix}}-class-border"/></view>

View File

@@ -0,0 +1,34 @@
@import '../common/style/index.wxss';.t-checkbox{display:inline-flex;vertical-align:middle;position:relative;font-size:var(--td-checkbox-font-size,32rpx);background:var(--td-checkbox-bg-color,var(--td-bg-color-container,var(--td-font-white-1,#fff)));}
.t-checkbox:focus{outline:0;}
.t-checkbox--block{display:flex;padding:var(--td-checkbox-vertical-padding,32rpx);}
.t-checkbox--right{flex-direction:row-reverse;}
.t-checkbox .limit-title-row{display:-webkit-box;-webkit-box-orient:vertical;overflow:hidden;}
.t-checkbox .image-center{position:absolute;top:50%;transform:translateY(-50%);}
.t-checkbox__icon-left{margin-right:20rpx;width:40rpx;}
.t-checkbox__icon-right{right:0;display:contents;position:absolute;top:50%;transform:translateY(-50%);}
.t-checkbox__icon-image{width:var(--td-checkbox-icon-size,48rpx);height:var(--td-checkbox-icon-size,48rpx);vertical-align:top;}
.t-checkbox__icon{position:relative;display:block;width:var(--td-checkbox-icon-size,48rpx);height:var(--td-checkbox-icon-size,48rpx);color:var(--td-checkbox-icon-color,var(--td-component-border,var(--td-gray-color-4,#dcdcdc)));font-size:var(--td-checkbox-icon-size,48rpx);margin-top:calc((var(--td-checkbox-title-line-height,48rpx) - var(--td-checkbox-icon-size,48rpx))/ 2);}
.t-checkbox__icon:empty{display:none;}
.t-checkbox__icon--checked{color:var(--td-checkbox-icon-checked-color,var(--td-brand-color,var(--td-primary-color-7,#0052d9)));}
.t-checkbox__icon--disabled{cursor:not-allowed;color:var(--td-checkbox-icon-disabled-color,var(--td-brand-color-disabled,var(--td-primary-color-3,#b5c7ff)));}
.t-checkbox__icon--left{margin-right:16rpx;}
.t-checkbox__icon-circle{width:calc((var(--td-checkbox-icon-size,48rpx) - 4rpx) * 2);height:calc((var(--td-checkbox-icon-size,48rpx) - 4rpx) * 2);border:calc(4rpx * 2) solid var(--td-checkbox-icon-color,var(--td-component-border,var(--td-gray-color-4,#dcdcdc)));border-radius:50%;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%) scale(.5);box-sizing:border-box;}
.t-checkbox__icon-circle--disabled{background:var(--td-checkbox-icon-disabled-bg-color,var(--td-bg-color-component-disabled,var(--td-gray-color-2,#eee)));}
.t-checkbox__icon-rectangle{width:calc((var(--td-checkbox-icon-size,48rpx) - 4rpx * 2) * 2);height:calc((var(--td-checkbox-icon-size,48rpx) - 4rpx * 2) * 2);border:calc(4rpx * 2) solid var(--td-checkbox-icon-color,var(--td-component-border,var(--td-gray-color-4,#dcdcdc)));position:absolute;top:50%;left:50%;transform:translate(-50%,-50%) scale(.5);box-sizing:border-box;}
.t-checkbox__icon-rectangle--disabled{background:var(--td-checkbox-icon-disabled-bg-color,var(--td-bg-color-component-disabled,var(--td-gray-color-2,#eee)));}
.t-checkbox__icon-line::after,.t-checkbox__icon-line::before{content:'';display:block;position:absolute;width:5rpx;border-radius:2rpx;background:var(--td-checkbox-icon-checked-color,var(--td-brand-color,var(--td-primary-color-7,#0052d9)));transform-origin:top center;}
.t-checkbox__icon-line::before{height:16rpx;left:8rpx;top:22rpx;transform:rotate(-45deg);}
.t-checkbox__icon-line::after{height:26rpx;right:8rpx;top:14rpx;transform:rotate(45deg);}
.t-checkbox__icon-line--disabled::after,.t-checkbox__icon-line--disabled::before{background:var(--td-checkbox-icon-disabled-color,var(--td-brand-color-disabled,var(--td-primary-color-3,#b5c7ff)));}
.t-checkbox__content{flex:1;}
.t-checkbox__title{color:var(--td-checkbox-title-color,var(--td-text-color-primary,var(--td-font-gray-1,rgba(0,0,0,.9))));line-height:var(--td-checkbox-title-line-height,48rpx);display:-webkit-box;-webkit-box-orient:vertical;overflow:hidden;}
.t-checkbox__title--disabled{color:var(--td-checkbox-title-disabled-color,var(--td-text-color-disabled,var(--td-font-gray-4,rgba(0,0,0,.26))));}
.t-checkbox__description{color:var(--td-checkbox-description-color,var(--td-text-color-secondary,var(--td-font-gray-2,rgba(0,0,0,.6))));display:-webkit-box;-webkit-box-orient:vertical;overflow:hidden;font-size:28rpx;line-height:var(--td-checkbox-description-line-height,44rpx);}
.t-checkbox__description--disabled{color:var(--td-checkbox-description-disabled-color,var(--td-text-color-disabled,var(--td-font-gray-4,rgba(0,0,0,.26))));}
.t-checkbox__title+.t-checkbox__description:not(:empty){margin-top:8rpx;}
.t-checkbox__border{position:absolute;bottom:0;left:96rpx;right:0;height:1px;background:var(--td-checkbox-border-color,var(--td-component-stroke,var(--td-gray-color-3,#e7e7e7)));transform:scaleY(.5);}
.t-checkbox__border--right{left:32rpx;}
.t-checkbox--tag{font-size:28rpx;padding-top:16rpx;padding-bottom:16rpx;text-align:center;background-color:var(--td-bg-color-secondarycontainer,var(--td-gray-color-1,#f3f3f3));border-radius:12rpx;}
.t-checkbox--tag.t-checkbox--checked{color:var(--td-checkbox-tag-active-color,var(--td-brand-color,var(--td-primary-color-7,#0052d9)));background-color:var(--td-checkbox-tag-active-bg-color,var(--td-brand-color-light,var(--td-primary-color-1,#f2f3ff)));}
.t-checkbox--tag .t-checkbox__title--checked{color:var(--td-checkbox-tag-active-color,var(--td-brand-color,var(--td-primary-color-7,#0052d9)));}
.t-checkbox--tag .t-checkbox__content{margin-right:0;}

View File

@@ -0,0 +1,3 @@
import { TdCheckboxProps } from './type';
declare const props: TdCheckboxProps;
export default props;

View File

@@ -0,0 +1 @@
const props={block:{type:Boolean,value:!0},borderless:{type:null,value:void 0},checkAll:{type:Boolean,value:!1},checked:{type:Boolean,value:null},defaultChecked:{type:Boolean,value:!1},content:{type:String},contentDisabled:{type:Boolean},disabled:{type:null,value:void 0},icon:{type:null,value:"circle"},indeterminate:{type:Boolean,value:!1},label:{type:String},maxContentRow:{type:Number,value:5},maxLabelRow:{type:Number,value:3},name:{type:String,value:""},placement:{type:String,value:"left"},readonly:{type:null,value:void 0},value:{type:null}};export default props;

View File

@@ -0,0 +1,70 @@
export interface TdCheckboxProps {
block?: {
type: BooleanConstructor;
value?: boolean;
};
borderless?: {
type: BooleanConstructor;
value?: boolean;
};
checkAll?: {
type: BooleanConstructor;
value?: boolean;
};
checked?: {
type: BooleanConstructor;
value?: boolean;
};
defaultChecked?: {
type: BooleanConstructor;
value?: boolean;
};
content?: {
type: StringConstructor;
value?: string;
};
contentDisabled?: {
type: BooleanConstructor;
value?: boolean;
};
disabled?: {
type: BooleanConstructor;
value?: boolean;
};
icon?: {
type: null;
value?: 'circle' | 'line' | 'rectangle' | string[];
};
indeterminate?: {
type: BooleanConstructor;
value?: boolean;
};
label?: {
type: StringConstructor;
value?: string;
};
maxContentRow?: {
type: NumberConstructor;
value?: number;
};
maxLabelRow?: {
type: NumberConstructor;
value?: number;
};
name?: {
type: StringConstructor;
value?: string;
};
placement?: {
type: StringConstructor;
value?: 'left' | 'right';
};
readonly?: {
type: BooleanConstructor;
value?: boolean;
};
value?: {
type: null;
value?: string | number | boolean;
};
}

View File

@@ -0,0 +1 @@
export{};