New Huajishe Check ChaoXing
This commit is contained in:
31
HuajisheCheckChaoXing/miniprogram_npm/tdesign-miniprogram/grid-item/grid-item.d.ts
vendored
Normal file
31
HuajisheCheckChaoXing/miniprogram_npm/tdesign-miniprogram/grid-item/grid-item.d.ts
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
import { SuperComponent, RelationsOptions } from '../common/src/index';
|
||||
export default class GridItem extends SuperComponent {
|
||||
externalClasses: string[];
|
||||
options: {
|
||||
multipleSlots: boolean;
|
||||
};
|
||||
relations: RelationsOptions;
|
||||
properties: import("./type").TdGridItemProps;
|
||||
data: {
|
||||
prefix: string;
|
||||
classPrefix: string;
|
||||
gridItemStyle: string;
|
||||
gridItemWrapperStyle: string;
|
||||
gridItemContentStyle: string;
|
||||
align: string;
|
||||
column: number;
|
||||
describedbyID: string;
|
||||
};
|
||||
observers: {
|
||||
icon(icon: any): void;
|
||||
};
|
||||
lifetimes: {
|
||||
ready(): void;
|
||||
};
|
||||
updateStyle(): void;
|
||||
getWidthStyle(): string;
|
||||
getPaddingStyle(): string;
|
||||
getBorderStyle(): string;
|
||||
onClick(e: any): void;
|
||||
jumpLink(): void;
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
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, isObject } from '../common/src/index';
|
||||
import config from '../common/config';
|
||||
import props from './props';
|
||||
import { uniqueFactory, setIcon } from '../common/utils';
|
||||
const { prefix } = config;
|
||||
const name = `${prefix}-grid-item`;
|
||||
const getUniqueID = uniqueFactory('grid_item');
|
||||
var LinkTypes;
|
||||
(function (LinkTypes) {
|
||||
LinkTypes["redirect-to"] = "redirectTo";
|
||||
LinkTypes["switch-tab"] = "switchTab";
|
||||
LinkTypes["relaunch"] = "reLaunch";
|
||||
LinkTypes["navigate-to"] = "navigateTo";
|
||||
})(LinkTypes || (LinkTypes = {}));
|
||||
let GridItem = class GridItem extends SuperComponent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.externalClasses = [
|
||||
`${prefix}-class`,
|
||||
`${prefix}-class-content`,
|
||||
`${prefix}-class-image`,
|
||||
`${prefix}-class-text`,
|
||||
`${prefix}-class-description`,
|
||||
];
|
||||
this.options = {
|
||||
multipleSlots: true,
|
||||
};
|
||||
this.relations = {
|
||||
'../grid/grid': {
|
||||
type: 'ancestor',
|
||||
linked(target) {
|
||||
this.parent = target;
|
||||
this.updateStyle();
|
||||
this.setData({
|
||||
column: target.data.column,
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
this.properties = props;
|
||||
this.data = {
|
||||
prefix,
|
||||
classPrefix: name,
|
||||
gridItemStyle: '',
|
||||
gridItemWrapperStyle: '',
|
||||
gridItemContentStyle: '',
|
||||
align: 'center',
|
||||
column: 0,
|
||||
describedbyID: '',
|
||||
};
|
||||
this.observers = {
|
||||
icon(icon) {
|
||||
const obj = setIcon('icon', icon, '');
|
||||
this.setData(Object.assign({}, obj));
|
||||
},
|
||||
};
|
||||
this.lifetimes = {
|
||||
ready() {
|
||||
this.setData({
|
||||
describedbyID: getUniqueID(),
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
updateStyle() {
|
||||
const { hover, align } = this.parent.properties;
|
||||
const gridItemStyles = [];
|
||||
const gridItemWrapperStyles = [];
|
||||
const gridItemContentStyles = [];
|
||||
const widthStyle = this.getWidthStyle();
|
||||
const paddingStyle = this.getPaddingStyle();
|
||||
const borderStyle = this.getBorderStyle();
|
||||
widthStyle && gridItemStyles.push(widthStyle);
|
||||
paddingStyle && gridItemWrapperStyles.push(paddingStyle);
|
||||
borderStyle && gridItemContentStyles.push(borderStyle);
|
||||
this.setData({
|
||||
gridItemStyle: `${gridItemStyles.join(';')}`,
|
||||
gridItemWrapperStyle: gridItemWrapperStyles.join(';'),
|
||||
gridItemContentStyle: gridItemContentStyles.join(';'),
|
||||
hover,
|
||||
layout: this.properties.layout,
|
||||
align: align,
|
||||
});
|
||||
}
|
||||
getWidthStyle() {
|
||||
const { column } = this.parent.properties;
|
||||
return column > 0 ? `width:${(1 / column) * 100}%` : '';
|
||||
}
|
||||
getPaddingStyle() {
|
||||
const { gutter } = this.parent.properties;
|
||||
if (gutter)
|
||||
return `padding-left:${gutter}rpx;padding-top:${gutter}rpx`;
|
||||
return '';
|
||||
}
|
||||
getBorderStyle() {
|
||||
const { gutter } = this.parent.properties;
|
||||
let { border } = this.parent.properties;
|
||||
if (!border)
|
||||
return '';
|
||||
if (!isObject(border))
|
||||
border = {};
|
||||
const { color = '#266FE8', width = 2, style = 'solid' } = border;
|
||||
if (gutter)
|
||||
return `border:${width}rpx ${style} ${color}`;
|
||||
return `border-top:${width}rpx ${style} ${color};border-left:${width}rpx ${style} ${color}`;
|
||||
}
|
||||
onClick(e) {
|
||||
const { item } = e.currentTarget.dataset;
|
||||
this.triggerEvent('click', item);
|
||||
this.jumpLink();
|
||||
}
|
||||
jumpLink() {
|
||||
const { url, jumpType } = this.properties;
|
||||
if (url && jumpType) {
|
||||
if (LinkTypes[jumpType]) {
|
||||
wx[LinkTypes[jumpType]]({ url });
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
GridItem = __decorate([
|
||||
wxComponent()
|
||||
], GridItem);
|
||||
export default GridItem;
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"component": true,
|
||||
"styleIsolation": "apply-shared",
|
||||
"usingComponents": {
|
||||
"t-image": "../image/image",
|
||||
"t-icon": "../icon/icon",
|
||||
"t-badge": "../badge/badge"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<import src="../common/template/image.wxml" />
|
||||
<import src="../common/template/icon.wxml" />
|
||||
<wxs module="util">
|
||||
module.exports.getImageSize = function(column) { if (column >= 5) return 'small'; if (column == 4) return 'middle';
|
||||
return 'large'; }
|
||||
</wxs>
|
||||
<wxs module="_" src="../common/utils.wxs" />
|
||||
|
||||
<view
|
||||
class="{{_.cls(classPrefix, [['auto-size', column == 0]])}} class {{prefix}}-class"
|
||||
style="{{_._style([gridItemStyle, style, customStyle])}}"
|
||||
hover-class="{{hover ? classPrefix + '--hover':''}}"
|
||||
hover-stay-time="{{200}}"
|
||||
bindtap="onClick"
|
||||
aria-role="{{ariaRole || 'button'}}"
|
||||
aria-label="{{ariaLabel}}"
|
||||
aria-describedby="{{describedbyID}}"
|
||||
>
|
||||
<view class="{{_.cls(classPrefix + '__wrapper', [layout])}}" style="{{gridItemWrapperStyle}}">
|
||||
<view
|
||||
class="{{_.cls(classPrefix + '__content', [align, layout])}} {{prefix}}-class-content"
|
||||
style="{{gridItemContentStyle}}"
|
||||
>
|
||||
<slot />
|
||||
<t-badge
|
||||
wx:if="{{image || icon}}"
|
||||
color="{{badgeProps.color || ''}}"
|
||||
content="{{badgeProps.content || ''}}"
|
||||
count="{{badgeProps.count || 0}}"
|
||||
dot="{{badgeProps.dot || false}}"
|
||||
max-count="{{badgeProps.maxCount || 99}}"
|
||||
offset="{{badgeProps.offset || []}}"
|
||||
shape="{{badgeProps.shape || 'circle'}}"
|
||||
show-zero="{{badgeProps.showZero || false}}"
|
||||
size="{{badgeProps.size || 'medium'}}"
|
||||
t-class="{{badgeProps.tClass}}"
|
||||
t-class-content="{{badgeProps.tClassContent}}"
|
||||
t-class-count="{{badgeProps.tClassCount}}"
|
||||
>
|
||||
<view
|
||||
class="{{_.cls(classPrefix + '__image', [util.getImageSize(column), ['icon', icon]])}} {{prefix}}-class-image"
|
||||
>
|
||||
<block wx:if="{{image && image != 'slot'}}">
|
||||
<template
|
||||
is="image"
|
||||
data="{{ src: image, shape: 'round', mode: 'widthFix', tClass: _.cls(classPrefix + '__image', [util.getImageSize(column)]) + ' ' + prefix + '-class-image', ...imageProps }}"
|
||||
/>
|
||||
</block>
|
||||
<slot name="image" />
|
||||
<template
|
||||
wx:if="{{iconName || _.isNoEmptyObj(iconData)}}"
|
||||
is="icon"
|
||||
data="{{tClass: classPrefix + '__icon', name: iconName, ...iconData}}"
|
||||
/>
|
||||
</view>
|
||||
</t-badge>
|
||||
<view
|
||||
class="{{_.cls(classPrefix + '__words', [layout])}}"
|
||||
id="{{describedbyID}}"
|
||||
aria-label="{{ ariaLabel || (badgeProps.dot || badgeProps.count ? text + ',' + description + ',' + _.getBadgeAriaLabel({ ...badgeProps }) : '') }}"
|
||||
>
|
||||
<view
|
||||
wx:if="{{text}}"
|
||||
class="{{_.cls(classPrefix + '__text', [util.getImageSize(column), layout])}} {{prefix}}-class-text"
|
||||
>
|
||||
{{text}}
|
||||
</view>
|
||||
<slot name="text" />
|
||||
<view
|
||||
wx:if="{{description}}"
|
||||
class="{{_.cls(classPrefix + '__description', [util.getImageSize(column), layout])}} {{prefix}}-class-description"
|
||||
>
|
||||
{{description}}
|
||||
</view>
|
||||
<slot name="description" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,130 @@
|
||||
.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);
|
||||
}
|
||||
.t-grid-item {
|
||||
box-sizing: border-box;
|
||||
height: 100%;
|
||||
display: inline-block;
|
||||
vertical-align: top;
|
||||
background-color: var(--td-grid-item-bg-color, var(--td-bg-color-container, var(--td-font-white-1, #ffffff)));
|
||||
}
|
||||
.t-grid-item--hover {
|
||||
background-color: var(--td-grid-item-hover-bg-color, var(--td-bg-color-secondarycontainer, var(--td-gray-color-1, #f3f3f3)));
|
||||
}
|
||||
.t-grid-item--auto-size {
|
||||
width: 168rpx;
|
||||
}
|
||||
.t-grid-item__content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
padding: var(--td-grid-item-padding, 32rpx) 0 24rpx;
|
||||
}
|
||||
.t-grid-item__content--horizontal {
|
||||
flex-direction: row;
|
||||
padding-left: var(--td-grid-item-padding, 32rpx);
|
||||
}
|
||||
.t-grid-item__content--left {
|
||||
justify-self: flex-start;
|
||||
align-items: flex-start;
|
||||
}
|
||||
.t-grid-item__content--left .t-grid-item__words {
|
||||
text-align: left;
|
||||
}
|
||||
.t-grid-item__words {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
flex-direction: column;
|
||||
display: flex;
|
||||
flex: 1;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.t-grid-item__words--horizontal {
|
||||
margin-left: 24rpx;
|
||||
}
|
||||
.t-grid-item__words:empty {
|
||||
display: none;
|
||||
}
|
||||
.t-grid-item__image:not(:empty) {
|
||||
width: var(--td-grid-item-image-width, 96rpx);
|
||||
height: var(--td-grid-item-image-width, 96rpx);
|
||||
}
|
||||
.t-grid-item__image:not(:empty).t-grid-item__image--small {
|
||||
width: var(--td-grid-item-image-small-width, 64rpx);
|
||||
height: var(--td-grid-item-image-small-width, 64rpx);
|
||||
}
|
||||
.t-grid-item__image:not(:empty).t-grid-item__image--middle {
|
||||
width: var(--td-grid-item-image-middle-width, 80rpx);
|
||||
height: var(--td-grid-item-image-middle-width, 80rpx);
|
||||
}
|
||||
.t-grid-item__image:not(:empty) .t-grid__image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.t-grid-item__image--icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: var(--td-bg-color-secondarycontainer, var(--td-gray-color-1, #f3f3f3));
|
||||
border-radius: var(--td-radius-default, 12rpx);
|
||||
}
|
||||
.t-grid-item__text {
|
||||
width: inherit;
|
||||
color: var(--td-grid-item-text-color, var(--td-text-color-primary, var(--td-font-gray-1, rgba(0, 0, 0, 0.9))));
|
||||
font-size: var(--td-grid-item-text-font-size, 28rpx);
|
||||
line-height: var(--td-grid-item-text-line-height, 44rpx);
|
||||
padding-top: var(--td-grid-item-text-padding-top, 16rpx);
|
||||
}
|
||||
.t-grid-item__text--small {
|
||||
font-size: var(--td-grid-item-text-small-font-size, 24rpx);
|
||||
}
|
||||
.t-grid-item__text--middle {
|
||||
font-size: var(--td-grid-item-text-middle-font-size, 24rpx);
|
||||
}
|
||||
.t-grid-item__text--horizontal {
|
||||
padding-top: 0;
|
||||
text-align: left;
|
||||
}
|
||||
.t-grid-item__description {
|
||||
padding-top: var(--td-grid-item-description-padding-top, 0);
|
||||
width: inherit;
|
||||
color: var(--td-grid-item-description-color, var(--td-text-color-placeholder, var(--td-font-gray-3, rgba(0, 0, 0, 0.4))));
|
||||
font-size: var(--td-grid-item-description-font-size, 24rpx);
|
||||
line-height: var(--td-grid-item-description-line-height, 40rpx);
|
||||
}
|
||||
.t-grid-item__description--horizontal {
|
||||
margin-top: var(--td-grid-item-horizontal-text-description-top, 0);
|
||||
padding-left: var(--td-grid-item-horizontal-text-padding-left, 0);
|
||||
text-align-last: left;
|
||||
}
|
||||
.t-grid-item__icon {
|
||||
font-size: 48rpx;
|
||||
}
|
||||
3
HuajisheCheckChaoXing/miniprogram_npm/tdesign-miniprogram/grid-item/props.d.ts
vendored
Normal file
3
HuajisheCheckChaoXing/miniprogram_npm/tdesign-miniprogram/grid-item/props.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { TdGridItemProps } from './type';
|
||||
declare const props: TdGridItemProps;
|
||||
export default props;
|
||||
@@ -0,0 +1,34 @@
|
||||
const props = {
|
||||
badgeProps: {
|
||||
type: Object,
|
||||
value: null,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
},
|
||||
icon: {
|
||||
type: null,
|
||||
},
|
||||
image: {
|
||||
type: String,
|
||||
},
|
||||
imageProps: {
|
||||
type: Object,
|
||||
},
|
||||
jumpType: {
|
||||
type: String,
|
||||
value: 'navigate-to',
|
||||
},
|
||||
layout: {
|
||||
type: String,
|
||||
value: 'vertical',
|
||||
},
|
||||
text: {
|
||||
type: String,
|
||||
},
|
||||
url: {
|
||||
type: String,
|
||||
value: '',
|
||||
},
|
||||
};
|
||||
export default props;
|
||||
40
HuajisheCheckChaoXing/miniprogram_npm/tdesign-miniprogram/grid-item/type.d.ts
vendored
Normal file
40
HuajisheCheckChaoXing/miniprogram_npm/tdesign-miniprogram/grid-item/type.d.ts
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
import { BadgeProps } from '../badge/index';
|
||||
import { ImageProps } from '../image/index';
|
||||
export interface TdGridItemProps {
|
||||
badgeProps?: {
|
||||
type: ObjectConstructor;
|
||||
value?: BadgeProps;
|
||||
};
|
||||
description?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
icon?: {
|
||||
type: null;
|
||||
value?: string | object;
|
||||
};
|
||||
image?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
imageProps?: {
|
||||
type: ObjectConstructor;
|
||||
value?: ImageProps;
|
||||
};
|
||||
jumpType?: {
|
||||
type: StringConstructor;
|
||||
value?: 'redirect-to' | 'switch-tab' | 'relaunch' | 'navigate-to';
|
||||
};
|
||||
layout?: {
|
||||
type: StringConstructor;
|
||||
value?: 'vertical' | 'horizontal';
|
||||
};
|
||||
text?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
url?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export {};
|
||||
Reference in New Issue
Block a user