初始化项目, 添加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,48 @@
import { RelationsOptions, SuperComponent } from '../common/src/index';
import type { TdDropdownItemProps } from './type';
export interface DropdownItemProps extends TdDropdownItemProps {
}
export default class DropdownMenuItem extends SuperComponent {
options: {
multipleSlots: boolean;
};
externalClasses: string[];
properties: TdDropdownItemProps;
data: {
prefix: string;
classPrefix: string;
show: boolean;
top: number;
maskHeight: number;
initValue: any;
hasChanged: boolean;
duration: string | number;
zIndex: number;
overlay: boolean;
labelAlias: string;
valueAlias: string;
computedLabel: string;
firstCheckedValue: string;
};
relations: RelationsOptions;
controlledProps: {
key: string;
event: string;
}[];
observers: {
keys(obj: any): void;
value(v: any): void;
'label, computedLabel, disabled'(): void;
show(visible: any): void;
};
methods: {
closeDropdown(): void;
getParentBottom(cb: any): void;
handleTreeClick(e: any): void;
handleRadioChange(e: any): void;
handleMaskClick(): void;
handleReset(): void;
handleConfirm(): void;
onLeaved(): 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";import menuProps from"../dropdown-menu/props";import{getRect}from"../common/utils";const{prefix:prefix}=config,name=`${prefix}-dropdown-item`;let DropdownMenuItem=class extends SuperComponent{constructor(){super(...arguments),this.options={multipleSlots:!0},this.externalClasses=[`${prefix}-class`,`${prefix}-class-content`,`${prefix}-class-column`,`${prefix}-class-column-item`,`${prefix}-class-column-item-label`,`${prefix}-class-footer`],this.properties=props,this.data={prefix:prefix,classPrefix:name,show:!1,top:0,maskHeight:0,initValue:null,hasChanged:!1,duration:menuProps.duration.value,zIndex:menuProps.zIndex.value,overlay:menuProps.showOverlay.value,labelAlias:"label",valueAlias:"value",computedLabel:"",firstCheckedValue:""},this.relations={"../dropdown-menu/dropdown-menu":{type:"parent",linked(e){const{zIndex:t,duration:a,showOverlay:s}=e.properties;this.setData({zIndex:t,duration:a,showOverlay:s})}}},this.controlledProps=[{key:"value",event:"change"}],this.observers={keys(e){this.setData({labelAlias:e.label||"label",valueAlias:e.value||"value"})},value(e){const{options:t,labelAlias:a,valueAlias:s}=this.data;if(this.data.multiple&&!Array.isArray(e))throw TypeError("应传入数组类型的 value");const o=t.find(t=>t[s]===e);o&&this.setData({computedLabel:o[a]})},"label, computedLabel, disabled"(){var e;null===(e=this.$parent)||void 0===e||e.getAllItems()},show(e){e&&this.getParentBottom(()=>{this.setData({wrapperVisible:!0})})}},this.methods={closeDropdown(){var e;null===(e=this.$parent)||void 0===e||e.setData({activeIdx:-1}),this.setData({show:!1}),this.triggerEvent("close")},getParentBottom(e){getRect(this.$parent,`#${prefix}-bar`).then(t=>{this.setData({top:t.bottom,maskHeight:t.top},e)})},handleTreeClick(e){const{level:t,value:a}=e.currentTarget.dataset,{value:s}=this.data;s[t]=a,this._trigger("change",{value:s})},handleRadioChange(e){const{value:t}=e.detail;if(this._trigger("change",{value:t}),this.data.multiple){const e=this.data.options.find(e=>t.includes(e.value));e&&(this.data.firstCheckedValue=e.value)}else this.closeDropdown()},handleMaskClick(){var e;(null===(e=this.$parent)||void 0===e?void 0:e.properties.closeOnClickOverlay)&&this.closeDropdown()},handleReset(){this._trigger("change",{value:[]}),this._trigger("reset")},handleConfirm(){this._trigger("confirm",{value:this.data.value}),this.closeDropdown(),this.setData({firstCheckedValue:this.data.firstCheckedValue})},onLeaved(){this.setData({wrapperVisible:!1})}}}};DropdownMenuItem=__decorate([wxComponent()],DropdownMenuItem);export default DropdownMenuItem;

View File

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

View File

@@ -0,0 +1 @@
<wxs module="_this" src="./index.wxs"/><wxs module="_" src="../common/utils.wxs"/><view wx:if="{{wrapperVisible}}" class="{{classPrefix}} class {{prefix}}-class" style="{{_._style([_this.getStyles(top, zIndex), style, customStyle])}}"><view class="{{ classPrefix }}__mask" hidden="{{!show}}" style="{{_._style(['height:' + maskHeight + 'px', style, customStyle])}}" bind:tap="handleMaskClick" catchtouchmove="closeDropdown"></view><t-popup visible="{{show}}" z-index="{{zIndex + 1}}" duration="{{duration}}" show-overlay="{{showOverlay}}" custom-style="position: absolute" overlay-props="{{ { style: 'position: absolute' } }}" bind:leaved="onLeaved" bind:visible-change="handleMaskClick" t-class="{{classPrefix}}__popup-host" t-class-content="{{classPrefix}}__content {{prefix}}-class-content"><view class="{{classPrefix}}__body"><scroll-view wx:if="{{!multiple && options && options.length > 0}}" class="{{classPrefix}}__scroll" scroll-y scroll-into-view="id_{{value}}"><t-radio-group class="{{classPrefix}}__radio {{prefix}}-class-column" t-class="{{classPrefix}}__radio-group" style="grid-template-columns: repeat({{optionsColumns}}, 1fr)" value="{{value}}" bind:change="handleRadioChange"><view wx:for="{{options}}" wx:key="index" id="id_{{item[valueAlias]}}"><t-radio placement="{{placement}}" tabindex="0" icon="line" class="{{classPrefix}}__radio-item {{prefix}}-class-column-item" t-class="radio" t-class-label="{{prefix}}-class-column-item-label" value="{{item[valueAlias]}}" label="{{item[labelAlias]}}" disabled="{{item.disabled}}"/></view></t-radio-group></scroll-view><scroll-view wx:if="{{multiple && options && options.length > 0}}" class="{{classPrefix}}__scroll" scroll-y scroll-into-view="id_{{firstCheckedValue}}"><t-checkbox-group class="{{classPrefix}}__checkbox {{prefix}}-class-column" t-class="{{classPrefix}}__checkbox-group" style="grid-template-columns: repeat({{optionsColumns}}, 1fr)" value="{{value ? value : []}}" bind:change="handleRadioChange"><view wx:for="{{options}}" wx:key="index" id="id_{{item[valueAlias]}}"><t-checkbox tabindex="0" class="{{classPrefix}}__checkbox-item {{prefix}}-class-column-item" theme="tag" value="{{item[valueAlias]}}" label="{{item[labelAlias]}}" disabled="{{item.disabled}}"></t-checkbox></view></t-checkbox-group></scroll-view><slot/></view><view class="{{classPrefix}}__footer {{prefix}}-class-footer"><slot name="footer"/><block wx:if="{{multiple}}"><t-button block class="{{classPrefix}}__footer-btn {{classPrefix}}__reset-btn" theme="light" content="重置" disabled="{{value.length == 0}}" bindtap="handleReset"/><t-button block class="{{classPrefix}}__footer-btn {{classPrefix}}__confirm-btn" theme="primary" content="确定" disabled="{{value.length == 0}}" bindtap="handleConfirm"/></block></view></t-popup></view>

View File

@@ -0,0 +1,20 @@
@import '../common/style/index.wxss';.t-dropdown-item{position:fixed;right:0;left:0;top:0;overflow:hidden;bottom:0;}
.t-dropdown-item__content{display:flex;flex-direction:column;z-index:11600;overflow:hidden;}
.t-dropdown-item__popup-host{display:block;width:100%;overflow:hidden;position:absolute;left:0;top:0;}
.t-dropdown-item__body{flex:1;background:var(--td-dropdown-menu-bg-color,var(--td-bg-color-container,var(--td-font-white-1,#fff)));overflow:auto;max-height:var(--td-dropdown-body-max-height,560rpx);}
.t-dropdown-item__body--tree{display:flex;overflow:hidden;}
.t-dropdown-item__body--multi{padding-top:var(--td-spacer,16rpx);padding-bottom:var(--td-spacer,16rpx);overflow-y:auto;}
.t-dropdown-item__scroll{max-height:var(--td-dropdown-body-max-height,560rpx);}
.t-dropdown-item__footer{display:flex;background:var(--td-dropdown-menu-bg-color,var(--td-bg-color-container,var(--td-font-white-1,#fff)));padding:32rpx;position:relative;}
.t-dropdown-item__footer::after{content:'';display:block;position:absolute;top:0;bottom:unset;left:unset;right:unset;background-color:var(--td-component-border,var(--td-gray-color-4,#dcdcdc));}
.t-dropdown-item__footer::after{height:1px;left:0;right:0;transform:scaleY(.5);}
.t-dropdown-item__footer-btn{flex:1;}
.t-dropdown-item__footer-btn+.t-dropdown-item__footer-btn{margin-left:32rpx;}
.t-dropdown-item__body:empty,.t-dropdown-item__footer:empty{display:none;}
.t-dropdown-item__checkbox,.t-dropdown-item__radio{width:100%;overflow:scroll;box-sizing:border-box;}
.t-dropdown-item__checkbox-group,.t-dropdown-item__radio-group{display:grid;grid-gap:24rpx;}
.t-dropdown-item__radio-group{display:grid;grid-gap:0rpx;}
.t-dropdown-item__checkbox-group{padding:32rpx;}
.t-dropdown-item__tree-item{height:var(--td-tree-item-height,96rpx);line-height:var(--td-tree-item-height,96rpx);font-size:var(--td-tree-item-font-size,32rpx);padding-left:32rpx;}
.t-dropdown-item__tree-item--active{color:var(--td-tree-item-active-color,var(--td-brand-color,var(--td-primary-color-7,#0052d9)));}
.t-dropdown-item__mask{position:fixed;width:100vh;top:0;left:0;}

View File

@@ -0,0 +1,9 @@
var getStyles = function (top, zIndex) {
var topStyle = top ? 'top:' + top + 'px;' : '';
var zIndexStyle = zIndex ? 'z-index:' + zIndex + ';' : '';
return topStyle + zIndexStyle;
};
module.exports = {
getStyles: getStyles,
};

View File

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

View File

@@ -0,0 +1 @@
const props={disabled:{type:Boolean,value:!1},keys:{type:Object},label:{type:String,value:""},multiple:{type:Boolean,value:!1},options:{type:Array,value:[]},optionsColumns:{type:null,value:1},placement:{type:String,value:"left"},value:{type:null,value:void 0},defaultValue:{type:null,value:void 0}};export default props;

View File

@@ -0,0 +1,45 @@
import { KeysType } from '../common/common';
export interface TdDropdownItemProps {
disabled?: {
type: BooleanConstructor;
value?: boolean;
};
keys?: {
type: ObjectConstructor;
value?: KeysType;
};
label?: {
type: StringConstructor;
value?: string;
};
multiple?: {
type: BooleanConstructor;
value?: boolean;
};
options?: {
type: ArrayConstructor;
value?: Array<DropdownOption>;
};
optionsColumns?: {
type: null;
value?: string | number;
};
placement?: {
type: StringConstructor;
value?: 'left' | 'right';
};
value?: {
type: null;
value?: DropdownValue;
};
defaultValue?: {
type: null;
value?: DropdownValue;
};
}
export interface DropdownOption {
label: string;
disabled: boolean;
value: DropdownValue;
}
export declare type DropdownValue = string | number | Array<DropdownValue>;

View File

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