初始化项目, 添加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,39 @@
import { SuperComponent, RelationsOptions } from '../common/src/index';
export default class CheckBoxGroup extends SuperComponent {
externalClasses: string[];
behaviors: string[];
relations: RelationsOptions;
data: {
prefix: string;
classPrefix: string;
checkboxOptions: any[];
};
properties: import("./type").TdCheckboxGroupProps<import("./type").CheckboxGroupValue>;
observers: {
value(): void;
options(): void;
disabled(v: any): void;
};
lifetimes: {
ready(): void;
};
controlledProps: {
key: string;
event: string;
}[];
$checkAll: any;
methods: {
getChildren(): any;
updateChildren(): void;
updateValue({ value, checked, checkAll, item, indeterminate }: {
value: any;
checked: any;
checkAll: any;
item: any;
indeterminate: any;
}): void;
initWithOptions(): void;
handleInnerChildChange(e: any): void;
setCheckall(): 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-group`;let CheckBoxGroup=class extends SuperComponent{constructor(){super(...arguments),this.externalClasses=[`${prefix}-class`],this.behaviors=["wx://form-field"],this.relations={"../checkbox/checkbox":{type:"descendant"}},this.data={prefix:prefix,classPrefix:name,checkboxOptions:[]},this.properties=props,this.observers={value(){this.updateChildren()},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.lifetimes={ready(){this.setCheckall()}},this.controlledProps=[{key:"value",event:"change"}],this.$checkAll=null,this.methods={getChildren(){let e=this.$children;return e.length||(e=this.selectAllComponents(`.${prefix}-checkbox-option`)),e||[]},updateChildren(){const e=this.getChildren(),{value:t}=this.data;e.length>0&&(e.forEach(e=>{!e.data.checkAll&&e.setData({checked:null==t?void 0:t.includes(e.data.value)})}),e.some(e=>e.data.checkAll)&&this.setCheckall())},updateValue({value:e,checked:t,checkAll:i,item:l,indeterminate:a}){let{value:s}=this.data;const{max:n}=this.data,c=new Set(this.getChildren().map(e=>e.data.value));if(s=s.filter(e=>c.has(e)),!n||!t||s.length!==n){if(i){const e=this.getChildren();s=!t&&a?e.filter(({data:e})=>!(e.disabled&&!s.includes(e.value))).map(e=>e.data.value):e.filter(({data:e})=>e.disabled?s.includes(e.value):t&&!e.checkAll).map(({data:e})=>e.value)}else if(t)s=s.concat(e);else{const t=s.findIndex(t=>t===e);s.splice(t,1)}this._trigger("change",{value:s,context:l})}},initWithOptions(){const{options:e,value:t,keys:i}=this.data;if(!(null==e?void 0:e.length)||!Array.isArray(e))return;const l=e.map(e=>{var l,a,s;return["number","string"].includes(typeof e)?{label:`${e}`,value:e,checked:null==t?void 0:t.includes(e)}:Object.assign(Object.assign({},e),{label:e[null!==(l=null==i?void 0:i.label)&&void 0!==l?l:"label"],value:e[null!==(a=null==i?void 0:i.value)&&void 0!==a?a:"value"],checked:null==t?void 0:t.includes(e[null!==(s=null==i?void 0:i.value)&&void 0!==s?s:"value"])})});this.setData({checkboxOptions:l})},handleInnerChildChange(e){var t;const{item:i}=e.target.dataset,{checked:l}=e.detail,a={};i.checkAll&&(a.indeterminate=null===(t=this.$checkAll)||void 0===t?void 0:t.data.indeterminate),this.updateValue(Object.assign(Object.assign(Object.assign({},i),{checked:l,item:i}),a))},setCheckall(){const e=this.getChildren();if(this.$checkAll||(this.$checkAll=e.find(e=>e.data.checkAll)),!this.$checkAll)return;const{value:t}=this.data,i=new Set(null==t?void 0:t.filter(e=>e!==this.$checkAll.data.value)),l=e.every(e=>!!e.data.checkAll||i.has(e.data.value));this.$checkAll.setData({checked:i.size>0,indeterminate:!l})}}}};CheckBoxGroup=__decorate([wxComponent()],CheckBoxGroup);export default CheckBoxGroup;

View File

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

View File

@@ -0,0 +1 @@
<wxs src="../common/utils.wxs" module="_"/><view class="{{ classPrefix }} class {{prefix}}-class" style="{{_._style([style, customStyle])}}"><slot/><block wx:for="{{checkboxOptions}}" wx:key="value"><t-checkbox class="{{prefix}}-checkbox-option" data-item="{{item}}" label="{{item.label || item.text || ''}}" value="{{item.value == null ? '' : item.value}}" block="{{item.block || true}}" check-all="{{item.checkAll || false}}" checked="{{item.checked || false}}" content="{{item.content || ''}}" content-disabled="{{item.contentDisabled || false}}" icon="{{item.icon || 'circle'}}" indeterminate="{{item.indeterminate || false}}" disabled="{{ item.disabled == null ? disabled : item.disabled }}" max-content-row="{{item.maxContentRow || 5}}" max-label-row="{{item.maxLabelRow || 3}}" name="{{item.name || ''}}" borderless="{{borderless}}" readonly="{{item.readonly || false}}" bind:change="handleInnerChildChange" placement="{{item.placement || 'left'}}"/></block></view>

View File

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

View File

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

View File

@@ -0,0 +1 @@
const props={borderless:{type:Boolean,value:!1},disabled:{type:null,value:void 0},keys:{type:Object},max:{type:Number,value:void 0},name:{type:String,value:""},options:{type:Array,value:[]},readonly:{type:null,value:void 0},value:{type:Array,value:null},defaultValue:{type:Array,value:[]}};export default props;

View File

@@ -0,0 +1,47 @@
import { KeysType } from '../common/common';
export interface TdCheckboxGroupProps<T = CheckboxGroupValue> {
borderless?: {
type: BooleanConstructor;
value?: boolean;
};
disabled?: {
type: BooleanConstructor;
value?: boolean;
};
keys?: {
type: ObjectConstructor;
value?: KeysType;
};
max?: {
type: NumberConstructor;
value?: number;
};
name?: {
type: StringConstructor;
value?: string;
};
options?: {
type: ArrayConstructor;
value?: Array<CheckboxOption>;
};
readonly?: {
type: BooleanConstructor;
value?: boolean;
};
value?: {
type: ArrayConstructor;
value?: T;
};
defaultValue?: {
type: ArrayConstructor;
value?: T;
};
}
export declare type CheckboxOption = string | number | CheckboxOptionObj;
export interface CheckboxOptionObj {
label?: string;
value?: string | number;
disabled?: boolean;
checkAll?: true;
}
export declare type CheckboxGroupValue = Array<string | number | boolean>;

View File

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