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,3 @@
import { TdRadioProps } from './type';
declare const props: TdRadioProps;
export default props;

View File

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

View File

@@ -0,0 +1,107 @@
import { SuperComponent, RelationsOptions } from '../common/src/index';
export default class Radio extends SuperComponent {
externalClasses: string[];
behaviors: string[];
relations: RelationsOptions;
options: {
multipleSlots: boolean;
};
lifetimes: {
attached(): void;
};
properties: {
borderless: {
type: BooleanConstructor;
value: boolean;
};
tId: {
type: StringConstructor;
};
allowUncheck?: {
type: BooleanConstructor;
value?: boolean;
};
block?: {
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[] | "circle" | "line" | "dot";
};
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?: import("./type").RadioValue;
};
};
controlledProps: {
key: string;
event: string;
}[];
data: {
prefix: string;
classPrefix: string;
customIcon: boolean;
slotIcon: boolean;
optionLinked: boolean;
iconVal: any[];
_placement: string;
_disabled: boolean;
_readonly: boolean;
};
observers: {
disabled(v: any): void;
readonly(v: any): void;
};
methods: {
handleTap(e: any): void;
doChange(): void;
init(): void;
setDisabled(disabled: Boolean): void;
setReadonly(readonly: Boolean): void;
};
}

View File

@@ -0,0 +1 @@
import{__decorate}from"tslib";import config from"../common/config";import{SuperComponent,wxComponent}from"../common/src/index";import Props from"./props";const{prefix:prefix}=config,name=`${prefix}-radio`;let Radio=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={"../radio-group/radio-group":{type:"ancestor",linked(e){e.data.borderless&&this.setData({borderless:!0})}}},this.options={multipleSlots:!0},this.lifetimes={attached(){this.init()}},this.properties=Object.assign(Object.assign({},Props),{borderless:{type:Boolean,value:!1},tId:{type:String}}),this.controlledProps=[{key:"checked",event:"change"}],this.data={prefix:prefix,classPrefix:name,customIcon:!1,slotIcon:!1,optionLinked:!1,iconVal:[],_placement:"",_disabled:!1,_readonly:!1},this.observers={disabled(e){this.setData({_disabled:e})},readonly(e){this.setData({_readonly:e})}},this.methods={handleTap(e){const{_disabled:t,_readonly:a,contentDisabled:o}=this.data,{target:s}=e.currentTarget.dataset;t||a||"text"===s&&o||this.doChange()},doChange(){var e;const{value:t,checked:a,allowUncheck:o}=this.data,s=Boolean(o||(null===(e=this.$parent)||void 0===e?void 0:e.data.allowUncheck));this.$parent?this.$parent.updateValue(a&&s?null:t):this._trigger("change",{checked:!s||!a})},init(){var e,t,a,o;const{icon:s}=this.data,i=Array.isArray((null===(e=this.$parent)||void 0===e?void 0:e.icon)||s);this.setData({customIcon:i,slotIcon:"slot"===s,iconVal:i?(null===(t=this.$parent)||void 0===t?void 0:t.icon)||s:[],_placement:this.data.placement||(null===(o=null===(a=this.$parent)||void 0===a?void 0:a.data)||void 0===o?void 0:o.placement)||"left"})},setDisabled(e){this.setData({_disabled:this.data.disabled||e})},setReadonly(e){this.setData({_readonly:this.data.readonly||e})}}}};Radio=__decorate([wxComponent()],Radio);export default Radio;

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, ['block', block]])}} class {{prefix}}-class" disabled="{{_disabled}}" aria-role="radio" aria-checked="{{checked}}" aria-label="{{label + content}}" aria-disabled="{{_disabled}}" tabindex="{{tabindex}}" mut-bind:tap="handleTap"><view class="{{_.cls(classPrefix + '__icon', [_placement, ['checked', checked], ['disabled', _disabled]])}} {{prefix}}-class-icon"><slot name="icon" wx:if="{{slotIcon}}"/><view wx:elif="{{customIcon}}" class="{{classPrefix}}__image"><image src="{{checked ? iconVal[0] : iconVal[1]}}" class="{{classPrefix}}-icon__image" webp/></view><block wx:else><t-icon wx:if="{{checked && (icon == 'circle' || icon == 'line')}}" name="{{icon == 'circle' ? 'check-circle-filled' : 'check'}}" class="{{classPrefix}}__icon-wrap"/><view wx:if="{{checked && icon == 'dot'}}" class="{{_.cls(classPrefix + '__icon-' + icon, [['disabled', _disabled]])}}"/><view wx:if="{{!checked && (icon == 'circle' || icon == 'dot')}}" class="{{_.cls(classPrefix + '__icon-circle', [['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], ['checked', checked]])}} {{prefix}}-class-content" style="-webkit-line-clamp:{{maxContentRow}}"><block wx:if="{{content}}">{{content}}</block><slot name="content"/></view></view><view wx:if="{{!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,63 @@
export interface TdRadioProps<T = RadioValue> {
allowUncheck?: {
type: BooleanConstructor;
value?: boolean;
};
block?: {
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' | 'dot' | Array<string>;
};
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?: T;
};
}
export declare type RadioValue = string | number | boolean;

View File

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