初始化项目, 添加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,3 @@
import { TdRadioGroupProps } from './type';
declare const props: TdRadioGroupProps;
export default props;

View File

@@ -0,0 +1 @@
const props={allowUncheck:{type:Boolean,value:!1},borderless:{type:Boolean,value:!1},disabled:{type:null,value:void 0},icon:{type:null,value:"circle"},keys:{type:Object},name:{type:String,value:""},options:{type:Array},placement:{type:String,value:"left"},readonly:{type:null,value:void 0},value:{type:null,value:null},defaultValue:{type:null}};export default props;

View File

@@ -0,0 +1,27 @@
import { SuperComponent, RelationsOptions } from '../common/src/index';
export default class RadioGroup extends SuperComponent {
behaviors: string[];
externalClasses: string[];
data: {
prefix: string;
classPrefix: string;
radioOptions: any[];
};
relations: RelationsOptions;
properties: import("./type").TdRadioGroupProps<import("./type").RadioValue>;
controlledProps: {
key: string;
event: string;
}[];
observers: {
value(v: any): void;
options(): void;
disabled(v: any): void;
};
methods: {
getChildren(): any;
updateValue(value: any): void;
handleRadioChange(e: any): void;
initWithOptions(): 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-group`;let RadioGroup=class extends SuperComponent{constructor(){super(...arguments),this.behaviors=["wx://form-field"],this.externalClasses=[`${prefix}-class`],this.data={prefix:prefix,classPrefix:name,radioOptions:[]},this.relations={"../radio/radio":{type:"descendant",linked(e){const{value:t,disabled:i,readonly:o}=this.data;e.setData({checked:t===e.data.value}),e.setDisabled(i),e.setReadonly(o)}}},this.properties=props,this.controlledProps=[{key:"value",event:"change"}],this.observers={value(e){this.getChildren().forEach(t=>{t.setData({checked:e===t.data.value})})},options(){this.initWithOptions()},disabled(e){var t;(null===(t=this.data.options)||void 0===t?void 0:t.length)?this.initWithOptions():this.getChildren().forEach(t=>{t.setDisabled(e)})}},this.methods={getChildren(){let e=this.$children;return(null==e?void 0:e.length)||(e=this.selectAllComponents(`.${prefix}-radio-option`)),e},updateValue(e){this._trigger("change",{value:e})},handleRadioChange(e){const{checked:t}=e.detail,{value:i,index:o,allowUncheck:a}=e.target.dataset;this._trigger("change",!1===t&&a?{value:null,index:o}:{value:i,index:o})},initWithOptions(){const{options:e,value:t,keys:i,disabled:o,readonly:a}=this.data;if(!(null==e?void 0:e.length)||!Array.isArray(e))return void this.setData({radioOptions:[]});const s=[];try{e.forEach(e=>{var l,r,n;const d=typeof e;"number"===d||"string"===d?s.push({label:`${e}`,value:e,checked:t===e,disabled:o,readonly:a}):"object"===d&&s.push(Object.assign(Object.assign({},e),{label:e[null!==(l=null==i?void 0:i.label)&&void 0!==l?l:"label"],value:e[null!==(r=null==i?void 0:i.value)&&void 0!==r?r:"value"],checked:t===e[null!==(n=null==i?void 0:i.value)&&void 0!==n?n:"value"],disabled:e.disabled||o,readonly:e.readonly||a}))}),this.setData({radioOptions:s})}catch(e){console.error("error",e)}}}}};RadioGroup=__decorate([wxComponent()],RadioGroup);export default RadioGroup;

View File

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

View File

@@ -0,0 +1 @@
<wxs src="../common/utils.wxs" module="_"/><view style="{{_._style([style, customStyle])}}" class="{{classPrefix}} class {{prefix}}-class" aria-role="radiogroup"><slot/><block wx:for="{{radioOptions}}" wx:key="value"><t-radio class="{{prefix}}-radio-option" data-index="{{index}}" data-value="{{item.value}}" data-allow-uncheck="{{item.allowUncheck || allowUncheck}}" block="{{item.block || true}}" label="{{item.label || ''}}" value="{{item.value}}" checked="{{item.checked || false}}" content="{{item.content || ''}}" allow-uncheck="{{item.allowUncheck || allowUncheck}}" content-disabled="{{item.contentDisabled || false}}" readonly="{{item.readonly || false}}" disabled="{{item.disabled || false}}" icon="{{item.icon || icon}}" placement="{{item.placement || placement}}" max-content-row="{{item.maxContentRow || 5}}" max-label-row="{{item.maxLabelRow || 3}}" name="{{item.name || ''}}" borderless="{{borderless}}" bind:change="handleRadioChange"/></block></view>

View File

@@ -0,0 +1 @@
@import '../common/style/index.wxss';

View File

@@ -0,0 +1,56 @@
import { KeysType } from '../common/common';
export interface TdRadioGroupProps<T = RadioValue> {
allowUncheck?: {
type: BooleanConstructor;
value?: boolean;
};
borderless?: {
type: BooleanConstructor;
value?: boolean;
};
disabled?: {
type: BooleanConstructor;
value?: boolean;
};
icon?: {
type: null;
value?: 'circle' | 'line' | 'dot' | Array<string>;
};
keys?: {
type: ObjectConstructor;
value?: KeysType;
};
name?: {
type: StringConstructor;
value?: string;
};
options?: {
type: ArrayConstructor;
value?: Array<RadioOption>;
};
placement?: {
type: StringConstructor;
value?: 'left' | 'right';
};
readonly?: {
type: BooleanConstructor;
value?: boolean;
};
value?: {
type: null;
value?: T;
};
defaultValue?: {
type: null;
value?: T;
};
}
export declare type RadioOption = string | number | RadioOptionObj;
export interface RadioOptionObj {
label?: string;
value?: string | number;
readonly?: boolean;
disabled?: boolean;
allowUncheck?: boolean;
}
export declare type RadioValue = string | number | boolean;

View File

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