New Huajishe Check ChaoXing
This commit is contained in:
48
HuajisheCheckChaoXing/miniprogram_npm/tdesign-miniprogram/dropdown-item/dropdown-item.d.ts
vendored
Normal file
48
HuajisheCheckChaoXing/miniprogram_npm/tdesign-miniprogram/dropdown-item/dropdown-item.d.ts
vendored
Normal 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'(): 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;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
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 } = config;
|
||||
const name = `${prefix}-dropdown-item`;
|
||||
let DropdownMenuItem = class DropdownMenuItem extends SuperComponent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.options = {
|
||||
multipleSlots: true,
|
||||
};
|
||||
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,
|
||||
classPrefix: name,
|
||||
show: false,
|
||||
top: 0,
|
||||
maskHeight: 0,
|
||||
initValue: null,
|
||||
hasChanged: false,
|
||||
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(target) {
|
||||
const { zIndex, duration, showOverlay } = target.properties;
|
||||
this.setData({
|
||||
zIndex,
|
||||
duration,
|
||||
showOverlay,
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
this.controlledProps = [
|
||||
{
|
||||
key: 'value',
|
||||
event: 'change',
|
||||
},
|
||||
];
|
||||
this.observers = {
|
||||
keys(obj) {
|
||||
this.setData({
|
||||
labelAlias: obj.label || 'label',
|
||||
valueAlias: obj.value || 'value',
|
||||
});
|
||||
},
|
||||
value(v) {
|
||||
const { options, labelAlias, valueAlias } = this.data;
|
||||
if (this.data.multiple) {
|
||||
if (!Array.isArray(v))
|
||||
throw TypeError('应传入数组类型的 value');
|
||||
}
|
||||
const target = options.find((item) => item[valueAlias] === v);
|
||||
if (target) {
|
||||
this.setData({
|
||||
computedLabel: target[labelAlias],
|
||||
});
|
||||
}
|
||||
},
|
||||
'label, computedLabel'() {
|
||||
var _a;
|
||||
(_a = this.$parent) === null || _a === void 0 ? void 0 : _a.getAllItems();
|
||||
},
|
||||
show(visible) {
|
||||
if (visible) {
|
||||
this.getParentBottom(() => {
|
||||
this.setData({ wrapperVisible: true });
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
this.methods = {
|
||||
closeDropdown() {
|
||||
var _a;
|
||||
(_a = this.$parent) === null || _a === void 0 ? void 0 : _a.setData({
|
||||
activeIdx: -1,
|
||||
});
|
||||
this.setData({
|
||||
show: false,
|
||||
});
|
||||
this.triggerEvent('close');
|
||||
},
|
||||
getParentBottom(cb) {
|
||||
getRect(this.$parent, `#${prefix}-bar`).then((rect) => {
|
||||
this.setData({
|
||||
top: rect.bottom,
|
||||
maskHeight: rect.top,
|
||||
}, cb);
|
||||
});
|
||||
},
|
||||
handleTreeClick(e) {
|
||||
const { level, value: itemValue } = e.currentTarget.dataset;
|
||||
const { value } = this.data;
|
||||
value[level] = itemValue;
|
||||
this._trigger('change', { value });
|
||||
},
|
||||
handleRadioChange(e) {
|
||||
const { value } = e.detail;
|
||||
this._trigger('change', { value });
|
||||
if (!this.data.multiple) {
|
||||
this.closeDropdown();
|
||||
}
|
||||
else {
|
||||
const firstChecked = this.data.options.find((item) => value.includes(item.value));
|
||||
if (firstChecked) {
|
||||
this.data.firstCheckedValue = firstChecked.value;
|
||||
}
|
||||
}
|
||||
},
|
||||
handleMaskClick() {
|
||||
var _a;
|
||||
if ((_a = this.$parent) === null || _a === void 0 ? void 0 : _a.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: false });
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
||||
DropdownMenuItem = __decorate([
|
||||
wxComponent()
|
||||
], DropdownMenuItem);
|
||||
export default DropdownMenuItem;
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
<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>
|
||||
@@ -0,0 +1,135 @@
|
||||
.t-float-left {
|
||||
float: left;
|
||||
}
|
||||
.t-float-right {
|
||||
float: right;
|
||||
}
|
||||
@keyframes tdesign-fade-out {
|
||||
from {
|
||||
opacity: 1;
|
||||
}
|
||||
to {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
.hotspot-expanded.relative {
|
||||
position: relative;
|
||||
}
|
||||
.hotspot-expanded::after {
|
||||
content: '';
|
||||
display: block;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
transform: scale(1.5);
|
||||
}
|
||||
/** dropdown-item */
|
||||
.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%;
|
||||
height: max-content;
|
||||
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, #ffffff)));
|
||||
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, #ffffff)));
|
||||
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(0.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__radio,
|
||||
.t-dropdown-item__checkbox {
|
||||
width: 100%;
|
||||
overflow: scroll;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.t-dropdown-item__radio-group,
|
||||
.t-dropdown-item__checkbox-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;
|
||||
}
|
||||
@@ -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,
|
||||
};
|
||||
3
HuajisheCheckChaoXing/miniprogram_npm/tdesign-miniprogram/dropdown-item/props.d.ts
vendored
Normal file
3
HuajisheCheckChaoXing/miniprogram_npm/tdesign-miniprogram/dropdown-item/props.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { TdDropdownItemProps } from './type';
|
||||
declare const props: TdDropdownItemProps;
|
||||
export default props;
|
||||
@@ -0,0 +1,41 @@
|
||||
const props = {
|
||||
disabled: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
externalClasses: {
|
||||
type: Array,
|
||||
},
|
||||
keys: {
|
||||
type: Object,
|
||||
},
|
||||
label: {
|
||||
type: String,
|
||||
value: '',
|
||||
},
|
||||
multiple: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
options: {
|
||||
type: Array,
|
||||
value: [],
|
||||
},
|
||||
optionsColumns: {
|
||||
type: null,
|
||||
value: 1,
|
||||
},
|
||||
placement: {
|
||||
type: String,
|
||||
value: 'left',
|
||||
},
|
||||
value: {
|
||||
type: null,
|
||||
value: undefined,
|
||||
},
|
||||
defaultValue: {
|
||||
type: null,
|
||||
value: undefined,
|
||||
},
|
||||
};
|
||||
export default props;
|
||||
56
HuajisheCheckChaoXing/miniprogram_npm/tdesign-miniprogram/dropdown-item/type.d.ts
vendored
Normal file
56
HuajisheCheckChaoXing/miniprogram_npm/tdesign-miniprogram/dropdown-item/type.d.ts
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
import { KeysType } from '../common/common';
|
||||
export interface TdDropdownItemProps {
|
||||
disabled?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
externalClasses?: {
|
||||
type: ArrayConstructor;
|
||||
value?: [
|
||||
't-class',
|
||||
't-class-content',
|
||||
't-class-column',
|
||||
't-class-column-item',
|
||||
't-class-column-item-label',
|
||||
't-class-footer'
|
||||
];
|
||||
};
|
||||
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>;
|
||||
@@ -0,0 +1 @@
|
||||
export {};
|
||||
Reference in New Issue
Block a user