This commit is contained in:
sjk
2025-11-17 14:11:46 +08:00
commit ad4a600af9
1659 changed files with 171560 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]])}} 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" webp/></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>

File diff suppressed because one or more lines are too long

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:Boolean,value:!1},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:Boolean,value:!1},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{};