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

View File

@@ -0,0 +1 @@
const props={action:{type:String,value:""},adjustPosition:{type:Boolean,value:!0},alwaysEmbed:{type:Boolean,value:!1},center:{type:Boolean,value:!1},clearTrigger:{type:String,value:"always"},clearable:{type:Boolean,value:!0},confirmHold:{type:Boolean,value:!1},confirmType:{type:String,value:"search"},cursor:{type:Number,value:-1,required:!0},cursorSpacing:{type:Number,value:0},disabled:{type:Boolean,value:!1},focus:{type:Boolean,value:!1},holdKeyboard:{type:Boolean,value:!1},leftIcon:{type:String,value:"search"},maxcharacter:{type:Number},maxlength:{type:Number,value:-1},placeholder:{type:String,value:""},placeholderClass:{type:String,value:"input-placeholder"},placeholderStyle:{type:String,value:"",required:!0},readonly:{type:null,value:void 0},resultList:{type:Array,value:[]},selectionEnd:{type:Number,value:-1},selectionStart:{type:Number,value:-1},shape:{type:String,value:"square"},type:{type:String,value:"text"},value:{type:String,value:""}};export default props;

View File

@@ -0,0 +1,27 @@
import { SuperComponent } from '../common/src/index';
export default class Search extends SuperComponent {
externalClasses: string[];
options: {
multipleSlots: boolean;
};
properties: import("./type").TdSearchProps;
observers: {
resultList(val: any): void;
'clearTrigger, clearable, disabled, readonly'(): void;
};
data: {
classPrefix: string;
prefix: string;
isShowResultList: boolean;
isSelected: boolean;
showClearIcon: boolean;
};
updateClearIconVisible(value?: boolean): void;
onInput(e: any): void;
onFocus(e: any): void;
onBlur(e: any): void;
handleClear(): void;
onConfirm(e: any): void;
onActionClick(): void;
onSelectResultItem(e: any): 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{getCharacterLength}from"../common/utils";const{prefix:prefix}=config,name=`${prefix}-search`;let Search=class extends SuperComponent{constructor(){super(...arguments),this.externalClasses=[`${prefix}-class`,`${prefix}-class-input-container`,`${prefix}-class-input`,`${prefix}-class-action`,`${prefix}-class-left`,`${prefix}-class-clear`],this.options={multipleSlots:!0},this.properties=props,this.observers={resultList(e){const{isSelected:t}=this.data;e.length?t?this.setData({isShowResultList:!1,isSelected:!1}):this.setData({isShowResultList:!0}):this.setData({isShowResultList:!1})},"clearTrigger, clearable, disabled, readonly"(){this.updateClearIconVisible()}},this.data={classPrefix:name,prefix:prefix,isShowResultList:!1,isSelected:!1,showClearIcon:!0}}updateClearIconVisible(e=!1){const{clearTrigger:t,disabled:s,readonly:i}=this.properties;s||i?this.setData({showClearIcon:!1}):this.setData({showClearIcon:e||"always"===String(t)})}onInput(e){let{value:t}=e.detail;const{maxcharacter:s}=this.properties;if(s&&"number"==typeof s&&s>0){const{characters:e}=getCharacterLength("maxcharacter",t,s);t=e}this.setData({value:t}),this.triggerEvent("change",{value:t})}onFocus(e){const{value:t}=e.detail;this.updateClearIconVisible(!0),this.triggerEvent("focus",{value:t})}onBlur(e){const{value:t}=e.detail;this.updateClearIconVisible(),this.triggerEvent("blur",{value:t})}handleClear(){this.setData({value:""}),this.triggerEvent("clear",{value:""}),this.triggerEvent("change",{value:""})}onConfirm(e){const{value:t}=e.detail;this.triggerEvent("submit",{value:t})}onActionClick(){this.triggerEvent("action-click")}onSelectResultItem(e){const{index:t}=e.currentTarget.dataset,s=this.properties.resultList[t];this.setData({value:s,isSelected:!0}),this.triggerEvent("change",{value:s}),this.triggerEvent("selectresult",{index:t,item:s})}};Search=__decorate([wxComponent()],Search);export default Search;

View File

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

View File

@@ -0,0 +1 @@
<wxs src="../common/utils.wxs" module="_"/><wxs src="./search.wxs" module="_this"></wxs><view style="{{_._style([style, customStyle])}}" class="class {{classPrefix}} {{prefix}}-class"><view class="{{classPrefix}}__input-box {{prefix}}-{{focus ? 'is-focused' : 'not-focused'}} {{classPrefix}}__input-box--{{center ? 'center' : ''}} {{classPrefix}}__input-box--{{shape}} {{prefix}}-class-input-container"><t-icon wx:if="{{leftIcon}}" name="{{leftIcon}}" class="{{prefix}}-icon {{prefix}}-class-left" aria-hidden="{{true}}"/><slot wx:else name="left-icon"/><input type="{{type}}" name="input" maxlength="{{maxlength}}" disabled="{{disabled || readonly}}" class="{{prefix}}-input__keyword {{prefix}}-class-input {{ disabled ? prefix + '-input--disabled' : ''}}" focus="{{focus}}" value="{{value}}" confirm-type="{{confirmType}}" confirm-hold="{{confirmHold}}" cursor="{{cursor}}" adjust-position="{{adjustPosition}}" always-embed="{{alwaysEmbed}}" selection-start="{{selectionStart}}" selection-end="{{selectionEnd}}" hold-keyboard="{{holdKeyboard}}" cursor-spacing="{{cursorSpacing}}" placeholder="{{placeholder}}" placeholder-style="{{placeholderStyle}}" placeholder-class="{{placeholderClass}} {{classPrefix}}__placeholder {{classPrefix}}__placeholder--{{center ? 'center': 'normal'}}" bind:input="onInput" bind:focus="onFocus" bind:blur="onBlur" bind:confirm="onConfirm"/><view wx:if="{{value !=='' && clearable && showClearIcon}}" class="{{classPrefix}}__clear hotspot-expanded {{prefix}}-class-clear" catch:tap="handleClear" aria-role="button" aria-label="清除"><t-icon name="close-circle-filled" size="inherit" color="inherit"/></view></view><view wx:if="{{action}}" class="{{classPrefix}}__search-action {{prefix}}-class-action" catch:tap="onActionClick" aria-role="button">{{action}}</view><slot wx:else name="action"/></view><view wx:if="{{isShowResultList && !isSelected}}" class="{{classPrefix}}__result-list" aria-role="listbox"><t-cell wx:for="{{resultList}}" wx:key="index" data-index="{{index}}" class="{{classPrefix}}__result-item" hover bind:tap="onSelectResultItem" aria-role="option"><rich-text slot="title" nodes="{{_this.highLight(item, value)}}"></rich-text></t-cell></view>

View File

@@ -0,0 +1,6 @@
var highLight = function (label, keyword) {
return label.replace(keyword, '<span class="t-search__result-item--highLight">' + keyword + '</span>');
};
module.exports = {
highLight: highLight,
};

View File

@@ -0,0 +1,17 @@
@import '../common/style/index.wxss';.t-search{display:flex;justify-content:space-between;align-items:center;}
.t-search__label{padding:8rpx;color:var(--td-search-label-color,var(--td-text-color-primary,var(--td-font-gray-1,rgba(0,0,0,.9))));}
.t-search__input-box{flex:1;box-sizing:border-box;display:flex;height:var(--td-search-height,80rpx);align-items:center;border:2rpx solid var(--td-search-bg-color,var(--td-bg-color-secondarycontainer,var(--td-gray-color-1,#f3f3f3)));background:var(--td-search-bg-color,var(--td-bg-color-secondarycontainer,var(--td-gray-color-1,#f3f3f3)));padding:var(--td-search-padding,16rpx 24rpx);}
.t-search__input-box.t-is-focused{border-color:var(--td-search-bg-color,var(--td-bg-color-secondarycontainer,var(--td-gray-color-1,#f3f3f3)));}
.t-search__input-box--round{border-radius:calc(var(--td-search-height,80rpx)/ 2);}
.t-search__input-box--square{border-radius:var(--td-search-square-radius,var(--td-radius-default,12rpx));}
.t-search__input-box--center{text-align:center;}
.t-search__input-box .t-input__keyword{display:inline-block;flex:1;color:var(--td-search-text-color,var(--td-text-color-primary,var(--td-font-gray-1,rgba(0,0,0,.9))));font-size:var(--td-search-font-size,var(--td-font-size-m,32rpx));padding-left:10rpx;min-height:48rpx;line-height:48rpx;}
.t-search__input-box .t-input--disabled{color:var(--td-search-disabled-text-color,var(--td-text-color-disabled,var(--td-font-gray-4,rgba(0,0,0,.26))));cursor:not-allowed;opacity:1;-webkit-text-fill-color:currentColor;}
.t-search__input-box .t-icon{color:var(--td-search-icon-color,var(--td-text-color-placeholder,var(--td-font-gray-3,rgba(0,0,0,.4))));font-size:var(--td-search-icon-font-size,48rpx);}
.t-search__clear{position:relative;margin-left:10px;font-size:var(--td-search-clear-icon-font-size,48rpx);color:var(--td-search-clear-icon-color,var(--td-text-color-placeholder,var(--td-font-gray-3,rgba(0,0,0,.4))));}
.t-search__search-action{margin-left:30rpx;font-size:var(--td-search-font-size,var(--td-font-size-m,32rpx));color:var(--td-search-action-color,var(--td-brand-color,var(--td-primary-color-7,#0052d9)));}
.t-search__placeholder{color:var(--td-search-placeholder-color,var(--td-text-color-placeholder,var(--td-font-gray-3,rgba(0,0,0,.4))));}
.t-search__placeholder--center{text-align:center;}
.t-search__result-item--highLight{color:var(--td-search-result-high-light-color,var(--td-brand-color,var(--td-primary-color-7,#0052d9)));}
.t-search__result-list .t-search__result-item{padding-left:0;}
.t-search__result-list .t-search__result-item::after{left:0;}

View File

@@ -0,0 +1,108 @@
export interface TdSearchProps {
action?: {
type: StringConstructor;
value?: string;
};
adjustPosition?: {
type: BooleanConstructor;
value?: boolean;
};
alwaysEmbed?: {
type: BooleanConstructor;
value?: boolean;
};
center?: {
type: BooleanConstructor;
value?: boolean;
};
clearTrigger?: {
type: StringConstructor;
value?: 'always' | 'focus';
};
clearable?: {
type: BooleanConstructor;
value?: boolean;
};
confirmHold?: {
type: BooleanConstructor;
value?: boolean;
};
confirmType?: {
type: StringConstructor;
value?: 'send' | 'search' | 'next' | 'go' | 'done';
};
cursor: {
type: NumberConstructor;
value?: number;
required?: boolean;
};
cursorSpacing?: {
type: NumberConstructor;
value?: number;
};
disabled?: {
type: BooleanConstructor;
value?: boolean;
};
focus?: {
type: BooleanConstructor;
value?: boolean;
};
holdKeyboard?: {
type: BooleanConstructor;
value?: boolean;
};
leftIcon?: {
type: StringConstructor;
value?: string;
};
maxcharacter?: {
type: NumberConstructor;
value?: number;
};
maxlength?: {
type: NumberConstructor;
value?: number;
};
placeholder?: {
type: StringConstructor;
value?: string;
};
placeholderClass?: {
type: StringConstructor;
value?: string;
};
placeholderStyle: {
type: StringConstructor;
value?: string;
required?: boolean;
};
readonly?: {
type: BooleanConstructor;
value?: boolean;
};
resultList?: {
type: ArrayConstructor;
value?: Array<string>;
};
selectionEnd?: {
type: NumberConstructor;
value?: number;
};
selectionStart?: {
type: NumberConstructor;
value?: number;
};
shape?: {
type: StringConstructor;
value?: 'square' | 'round';
};
type?: {
type: StringConstructor;
value?: 'text' | 'number' | 'idcard' | 'digit' | 'nickname';
};
value?: {
type: StringConstructor;
value?: string;
};
}

View File

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