project init & fix ui
This commit is contained in:
29
miniprogram_npm/tdesign-miniprogram/picker/README.en-US.md
Normal file
29
miniprogram_npm/tdesign-miniprogram/picker/README.en-US.md
Normal file
@@ -0,0 +1,29 @@
|
||||
:: BASE_DOC ::
|
||||
|
||||
## API
|
||||
|
||||
### Picker Props
|
||||
|
||||
name | type | default | description | required
|
||||
-- | -- | -- | -- | --
|
||||
auto-close | Boolean | true | \- | N
|
||||
cancel-btn | String / Boolean / Object | true | Typescript:`boolean \| string \| ButtonProps` | N
|
||||
columns | Array / Function | [] | required。Typescript:`Array<PickerColumn> \| ((item: Array<PickerValue>) => Array<PickerColumn>)` `type PickerColumn = PickerColumnItem[]` `interface PickerColumnItem { label: string,value: string}`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/picker/type.ts) | Y
|
||||
confirm-btn | String / Boolean / Object | true | Typescript:`boolean \| string \| ButtonProps`,[Button API Documents](./button?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/picker/type.ts) | N
|
||||
custom-style `v0.25.0` | String | - | \- | N
|
||||
footer | Slot | - | \- | N
|
||||
header | Boolean / Slot | true | \- | N
|
||||
render-label | String / Function | - | Typescript:`(item: PickerColumnItem) => string` | N
|
||||
title | String | '' | \- | N
|
||||
value | Array | - | Typescript:`Array<PickerValue>` `type PickerValue = string \| number`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/picker/type.ts) | N
|
||||
default-value | Array | undefined | uncontrolled property。Typescript:`Array<PickerValue>` `type PickerValue = string \| number`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/picker/type.ts) | N
|
||||
visible | Boolean | false | \- | N
|
||||
|
||||
### Picker Events
|
||||
|
||||
name | params | description
|
||||
-- | -- | --
|
||||
cancel | - | \-
|
||||
change | `(detail: { value: Array<PickerValue>; columns: Array<{ column: number; index: number }> })` | \-
|
||||
confirm | `(value: Array<PickerValue>, context: {index: number[] })` | \-
|
||||
pick | `(value: Array<PickerValue>,context: PickerContext)` | \-
|
||||
74
miniprogram_npm/tdesign-miniprogram/picker/README.md
Normal file
74
miniprogram_npm/tdesign-miniprogram/picker/README.md
Normal file
@@ -0,0 +1,74 @@
|
||||
---
|
||||
title: Picker 选择器
|
||||
description: 用于一组预设数据中的选择。
|
||||
spline: form
|
||||
isComponent: true
|
||||
---
|
||||
|
||||
<span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20lines-91%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20functions-90%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20statements-92%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20branches-89%25-blue" /></span>
|
||||
## 引入
|
||||
|
||||
全局引入,在 miniprogram 根目录下的`app.json`中配置,局部引入,在需要引入的页面或组件的`index.json`中配置。
|
||||
|
||||
```json
|
||||
"usingComponents": {
|
||||
"t-picker": "tdesign-miniprogram/picker/picker",
|
||||
"t-picker-item": "tdesign-miniprogram/picker/picker-item",
|
||||
}
|
||||
```
|
||||
|
||||
## 代码演示
|
||||
|
||||
### 组件类型
|
||||
#### 基础选择器
|
||||
|
||||
单项和多选选择
|
||||
|
||||
{{ base }}
|
||||
|
||||
#### 地区选择器
|
||||
|
||||
支持省市区切换,支持数据联动
|
||||
|
||||
{{ area }}
|
||||
|
||||
### 组件状态
|
||||
|
||||
是否带标题
|
||||
|
||||
{{ with-title }}
|
||||
|
||||
## API
|
||||
### Picker Props
|
||||
|
||||
名称 | 类型 | 默认值 | 说明 | 必传
|
||||
-- | -- | -- | -- | --
|
||||
auto-close | Boolean | true | 自动关闭;在确认、取消、点击遮罩层自动关闭,不需要手动设置 visible | N
|
||||
cancel-btn | String / Boolean / Object | true | 取消按钮文字。TS 类型:`boolean \| string \| ButtonProps` | N
|
||||
columns | Array / Function | [] | 必需。配置每一列的选项。TS 类型:`Array<PickerColumn> \| ((item: Array<PickerValue>) => Array<PickerColumn>)` `type PickerColumn = PickerColumnItem[]` `interface PickerColumnItem { label: string,value: string}`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/picker/type.ts) | Y
|
||||
confirm-btn | String / Boolean / Object | true | 确定按钮文字。TS 类型:`boolean \| string \| ButtonProps`,[Button API Documents](./button?tab=api)。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/picker/type.ts) | N
|
||||
custom-style `v0.25.0` | String | - | 自定义组件样式 | N
|
||||
footer | Slot | - | 底部内容 | N
|
||||
header | Boolean / Slot | true | 头部内容。值为 true 显示空白头部,值为 false 不显示任何内容,值类型为 TNode 表示自定义头部内容 | N
|
||||
render-label | String / Function | - | 自定义label。TS 类型:`(item: PickerColumnItem) => string` | N
|
||||
title | String | '' | 标题 | N
|
||||
value | Array | - | 选中值。TS 类型:`Array<PickerValue>` `type PickerValue = string \| number`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/picker/type.ts) | N
|
||||
default-value | Array | undefined | 选中值。非受控属性。TS 类型:`Array<PickerValue>` `type PickerValue = string \| number`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/picker/type.ts) | N
|
||||
visible | Boolean | false | 是否显示 | N
|
||||
|
||||
### Picker Events
|
||||
|
||||
名称 | 参数 | 描述
|
||||
-- | -- | --
|
||||
cancel | - | 点击取消按钮时触发
|
||||
change | `(detail: { value: Array<PickerValue>; columns: Array<{ column: number; label: string; index: number }> })` | 选中变化时候触发
|
||||
confirm | `(detail: { value: Array<PickerValue>; columns: Array<{ column: number; label: string; index: number }> })` | 选中变化时候触发
|
||||
pick | `(detail: { value: Array<PickerValue>; label: string; index: number; column: number;})` | 任何一列选中都会触发,不同的列参数不同。`context.column` 表示第几列变化,`context.index` 表示变化那一列的选中项下标
|
||||
|
||||
### PickerItem Props
|
||||
|
||||
名称 | 类型 | 默认值 | 说明 | 必传
|
||||
-- | -- | -- | -- | --
|
||||
custom-style `v0.25.0` | String | - | 自定义组件样式 | N
|
||||
format | Function | - | 格式化标签。TS 类型:`(option: PickerItemOption) => string` | N
|
||||
options | Array | [] | 数据源。TS 类型:`Array<PickerItemOption>` `interface PickerItemOption { label: string; value: string | number }`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/picker/type.ts) | N
|
||||
3
miniprogram_npm/tdesign-miniprogram/picker/picker-item-props.d.ts
vendored
Normal file
3
miniprogram_npm/tdesign-miniprogram/picker/picker-item-props.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { TdPickerItemProps } from './type';
|
||||
declare const props: TdPickerItemProps;
|
||||
export default props;
|
||||
@@ -0,0 +1,14 @@
|
||||
const props = {
|
||||
customStyle: {
|
||||
type: String,
|
||||
value: '',
|
||||
},
|
||||
format: {
|
||||
type: null,
|
||||
},
|
||||
options: {
|
||||
type: Array,
|
||||
value: [],
|
||||
},
|
||||
};
|
||||
export default props;
|
||||
25
miniprogram_npm/tdesign-miniprogram/picker/picker-item.d.ts
vendored
Normal file
25
miniprogram_npm/tdesign-miniprogram/picker/picker-item.d.ts
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
import { SuperComponent, RelationsOptions } from '../common/src/index';
|
||||
export default class PickerItem extends SuperComponent {
|
||||
relations: RelationsOptions;
|
||||
properties: import("./type").TdPickerItemProps;
|
||||
observers: {
|
||||
options(this: PickerItem): void;
|
||||
};
|
||||
data: {
|
||||
classPrefix: string;
|
||||
offset: number;
|
||||
duration: number;
|
||||
value: string;
|
||||
curIndex: number;
|
||||
};
|
||||
methods: {
|
||||
onTouchStart(event: any): void;
|
||||
onTouchMove(event: any): void;
|
||||
onTouchEnd(): void;
|
||||
update(): void;
|
||||
resetOrigin(): void;
|
||||
getCount(): any;
|
||||
};
|
||||
calculateViewDeltaY(touchDeltaY: number): number;
|
||||
created(): void;
|
||||
}
|
||||
117
miniprogram_npm/tdesign-miniprogram/picker/picker-item.js
Normal file
117
miniprogram_npm/tdesign-miniprogram/picker/picker-item.js
Normal file
@@ -0,0 +1,117 @@
|
||||
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 './picker-item-props';
|
||||
const { prefix } = config;
|
||||
const name = `${prefix}-picker-item`;
|
||||
const itemHeight = 80;
|
||||
const DefaultDuration = 240;
|
||||
const { windowWidth } = wx.getSystemInfoSync();
|
||||
const rpx2px = (rpx) => Math.floor((windowWidth * rpx) / 750);
|
||||
const range = function (num, min, max) {
|
||||
return Math.min(Math.max(num, min), max);
|
||||
};
|
||||
let PickerItem = class PickerItem extends SuperComponent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.relations = {
|
||||
'./picker': {
|
||||
type: 'parent',
|
||||
linked(parent) {
|
||||
this.parent = parent;
|
||||
},
|
||||
},
|
||||
};
|
||||
this.properties = props;
|
||||
this.observers = {
|
||||
options() {
|
||||
this.update();
|
||||
},
|
||||
};
|
||||
this.data = {
|
||||
classPrefix: name,
|
||||
offset: 0,
|
||||
duration: 0,
|
||||
value: '',
|
||||
curIndex: 0,
|
||||
};
|
||||
this.methods = {
|
||||
onTouchStart(event) {
|
||||
this.StartY = event.touches[0].clientY;
|
||||
this.StartOffset = this.data.offset;
|
||||
this.setData({ duration: 0 });
|
||||
},
|
||||
onTouchMove(event) {
|
||||
const { StartY, StartOffset, itemHeight } = this;
|
||||
const touchDeltaY = event.touches[0].clientY - StartY;
|
||||
const deltaY = this.calculateViewDeltaY(touchDeltaY);
|
||||
this.setData({
|
||||
offset: range(StartOffset + deltaY, -(this.getCount() * itemHeight), 0),
|
||||
duration: DefaultDuration,
|
||||
});
|
||||
},
|
||||
onTouchEnd() {
|
||||
const { offset } = this.data;
|
||||
const { options } = this.properties;
|
||||
if (offset === this.StartOffset) {
|
||||
return;
|
||||
}
|
||||
const index = range(Math.round(-offset / this.itemHeight), 0, this.getCount() - 1);
|
||||
this.setData({
|
||||
curIndex: index,
|
||||
offset: -index * this.itemHeight,
|
||||
});
|
||||
if (index === this._selectedIndex) {
|
||||
return;
|
||||
}
|
||||
wx.nextTick(() => {
|
||||
var _a, _b, _c;
|
||||
this._selectedIndex = index;
|
||||
this._selectedValue = (_a = options[index]) === null || _a === void 0 ? void 0 : _a.value;
|
||||
this._selectedLabel = (_b = options[index]) === null || _b === void 0 ? void 0 : _b.label;
|
||||
(_c = this.parent) === null || _c === void 0 ? void 0 : _c.triggerColumnChange({
|
||||
index,
|
||||
column: this.columnIndex || 0,
|
||||
});
|
||||
});
|
||||
},
|
||||
update() {
|
||||
var _a, _b;
|
||||
const { options, value } = this.data;
|
||||
const index = options.findIndex((item) => item.value === value);
|
||||
const selectedIndex = index > 0 ? index : 0;
|
||||
this.setData({
|
||||
offset: -selectedIndex * this.itemHeight,
|
||||
curIndex: selectedIndex,
|
||||
});
|
||||
this._selectedIndex = selectedIndex;
|
||||
this._selectedValue = (_a = options[selectedIndex]) === null || _a === void 0 ? void 0 : _a.value;
|
||||
this._selectedLabel = (_b = options[selectedIndex]) === null || _b === void 0 ? void 0 : _b.label;
|
||||
},
|
||||
resetOrigin() {
|
||||
this.update();
|
||||
},
|
||||
getCount() {
|
||||
var _a, _b;
|
||||
return (_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.length;
|
||||
},
|
||||
};
|
||||
}
|
||||
calculateViewDeltaY(touchDeltaY) {
|
||||
return Math.abs(touchDeltaY) > itemHeight ? 1.2 * touchDeltaY : touchDeltaY;
|
||||
}
|
||||
created() {
|
||||
this.StartY = 0;
|
||||
this.StartOffset = 0;
|
||||
this.itemHeight = rpx2px(itemHeight);
|
||||
}
|
||||
};
|
||||
PickerItem = __decorate([
|
||||
wxComponent()
|
||||
], PickerItem);
|
||||
export default PickerItem;
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
24
miniprogram_npm/tdesign-miniprogram/picker/picker-item.wxml
Normal file
24
miniprogram_npm/tdesign-miniprogram/picker/picker-item.wxml
Normal file
@@ -0,0 +1,24 @@
|
||||
<wxs src="../common/utils.wxs" module="_" />
|
||||
<view
|
||||
style="{{ customStyle }}"
|
||||
class="{{_.cls(classPrefix + '__group', [['narrow', siblingCount > 4], ['roomy', siblingCount <= 2]])}}"
|
||||
bind:touchstart="onTouchStart"
|
||||
catch:touchmove="onTouchMove"
|
||||
bind:touchend="onTouchEnd"
|
||||
bind:touchcancel="onTouchEnd"
|
||||
>
|
||||
<view
|
||||
class="{{classPrefix}}__wrapper"
|
||||
style="transition: transform {{ duration }}ms cubic-bezier(0.215, 0.61, 0.355, 1); transform: translate3d(0, {{ offset }}px, 0)"
|
||||
>
|
||||
<view
|
||||
class="{{_.cls(classPrefix + '__item', [['active', curIndex == index]])}}"
|
||||
wx:for="{{options}}"
|
||||
wx:key="index"
|
||||
wx:for-item="option"
|
||||
data-index="{{ index }}"
|
||||
>
|
||||
{{option.label}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
58
miniprogram_npm/tdesign-miniprogram/picker/picker-item.wxss
Normal file
58
miniprogram_npm/tdesign-miniprogram/picker/picker-item.wxss
Normal file
@@ -0,0 +1,58 @@
|
||||
.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);
|
||||
}
|
||||
:host {
|
||||
display: flex;
|
||||
}
|
||||
.t-picker-item__group {
|
||||
height: var(--td-picker-group-height, 400rpx);
|
||||
overflow: hidden;
|
||||
flex: 1;
|
||||
z-index: 1;
|
||||
padding: 0 40rpx;
|
||||
}
|
||||
.t-picker-item__group--roomy {
|
||||
padding: 0 64rpx;
|
||||
}
|
||||
.t-picker-item__group--narrow {
|
||||
padding: 0 16rpx;
|
||||
}
|
||||
.t-picker-item__wrapper {
|
||||
padding: 144rpx 0;
|
||||
}
|
||||
.t-picker-item__item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: var(--td-picker-item-height, 80rpx);
|
||||
line-height: var(--td-picker-item-height, 80rpx);
|
||||
color: var(--td-picker-item-color, var(--td-font-gray-2, rgba(0, 0, 0, 0.6)));
|
||||
}
|
||||
.t-picker-item__item--active {
|
||||
color: var(--td-picker-item-active-color, var(--td-font-gray-1, rgba(0, 0, 0, 0.9)));
|
||||
font-weight: 600;
|
||||
}
|
||||
30
miniprogram_npm/tdesign-miniprogram/picker/picker.d.ts
vendored
Normal file
30
miniprogram_npm/tdesign-miniprogram/picker/picker.d.ts
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
import { SuperComponent, RelationsOptions } from '../common/src/index';
|
||||
export default class Picker extends SuperComponent {
|
||||
properties: import("./type").TdPickerProps;
|
||||
externalClasses: string[];
|
||||
options: {
|
||||
multipleSlots: boolean;
|
||||
};
|
||||
relations: RelationsOptions;
|
||||
observers: {
|
||||
value(): void;
|
||||
};
|
||||
data: {
|
||||
prefix: string;
|
||||
classPrefix: string;
|
||||
};
|
||||
methods: {
|
||||
updateChildren(): void;
|
||||
getSelectedValue(): any[];
|
||||
getColumnIndexes(): any;
|
||||
onConfirm(): void;
|
||||
triggerColumnChange({ column, index }: {
|
||||
column: any;
|
||||
index: any;
|
||||
}): void;
|
||||
onCancel(): void;
|
||||
onPopupChange(e: any): void;
|
||||
close(): void;
|
||||
};
|
||||
ready(): void;
|
||||
}
|
||||
96
miniprogram_npm/tdesign-miniprogram/picker/picker.js
Normal file
96
miniprogram_npm/tdesign-miniprogram/picker/picker.js
Normal file
@@ -0,0 +1,96 @@
|
||||
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';
|
||||
const { prefix } = config;
|
||||
const name = `${prefix}-picker`;
|
||||
let Picker = class Picker extends SuperComponent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.properties = props;
|
||||
this.externalClasses = [`${prefix}-class`, `${prefix}-class-confirm`, `${prefix}-class-cancel`, `${prefix}-class-title`];
|
||||
this.options = {
|
||||
multipleSlots: true,
|
||||
};
|
||||
this.relations = {
|
||||
'./picker-item': {
|
||||
type: 'child',
|
||||
linked() {
|
||||
this.updateChildren();
|
||||
},
|
||||
},
|
||||
};
|
||||
this.observers = {
|
||||
value() {
|
||||
this.updateChildren();
|
||||
},
|
||||
};
|
||||
this.data = {
|
||||
prefix,
|
||||
classPrefix: name,
|
||||
};
|
||||
this.methods = {
|
||||
updateChildren() {
|
||||
const { value } = this.properties;
|
||||
this.$children.forEach((child, index) => {
|
||||
child.setData({
|
||||
value: (value === null || value === void 0 ? void 0 : value[index]) || '',
|
||||
siblingCount: this.$children.length,
|
||||
});
|
||||
child.update();
|
||||
});
|
||||
},
|
||||
getSelectedValue() {
|
||||
const value = this.$children.map((item) => item._selectedValue);
|
||||
const label = this.$children.map((item) => item._selectedLabel);
|
||||
return [value, label];
|
||||
},
|
||||
getColumnIndexes() {
|
||||
const columns = this.$children.map((pickerColumn, columnIndex) => {
|
||||
return {
|
||||
column: columnIndex,
|
||||
index: pickerColumn._selectedIndex,
|
||||
};
|
||||
});
|
||||
return columns;
|
||||
},
|
||||
onConfirm() {
|
||||
const [value, label] = this.getSelectedValue();
|
||||
const columns = this.getColumnIndexes();
|
||||
this.close();
|
||||
this.triggerEvent('change', { value, label, columns });
|
||||
this.triggerEvent('confirm', { value, label, columns });
|
||||
},
|
||||
triggerColumnChange({ column, index }) {
|
||||
const [value, label] = this.getSelectedValue();
|
||||
this.triggerEvent('pick', { value, label, column, index });
|
||||
},
|
||||
onCancel() {
|
||||
this.close();
|
||||
this.triggerEvent('cancel');
|
||||
},
|
||||
onPopupChange(e) {
|
||||
const { visible } = e.detail;
|
||||
this.close();
|
||||
this.triggerEvent('visible-change', { visible });
|
||||
},
|
||||
close() {
|
||||
if (this.data.autoClose) {
|
||||
this.setData({ visible: false });
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
ready() {
|
||||
this.$children.map((column, index) => (column.columnIndex = index));
|
||||
}
|
||||
};
|
||||
Picker = __decorate([
|
||||
wxComponent()
|
||||
], Picker);
|
||||
export default Picker;
|
||||
6
miniprogram_npm/tdesign-miniprogram/picker/picker.json
Normal file
6
miniprogram_npm/tdesign-miniprogram/picker/picker.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"t-popup": "../popup/popup"
|
||||
}
|
||||
}
|
||||
25
miniprogram_npm/tdesign-miniprogram/picker/picker.wxml
Normal file
25
miniprogram_npm/tdesign-miniprogram/picker/picker.wxml
Normal file
@@ -0,0 +1,25 @@
|
||||
<wxs src="../common/utils.wxs" module="_" />
|
||||
|
||||
<t-popup visible="{{visible}}" placement="bottom" bind:visible-change="onPopupChange">
|
||||
<view slot="content" style="{{ customStyle }}" class="{{classPrefix}} {{prefix}}-class">
|
||||
<view class="{{classPrefix}}__toolbar" wx:if="{{header}}">
|
||||
<view class="{{classPrefix}}__cancel {{prefix}}-class-cancel" wx:if="{{cancelBtn}}" bindtap="onCancel"
|
||||
>{{cancelBtn}}</view
|
||||
>
|
||||
<view class="{{classPrefix}}__title {{prefix}}-class-title">{{title}}</view>
|
||||
<view class="{{classPrefix}}__confirm {{prefix}}-class-confirm" wx:if="{{confirmBtn}}" bindtap="onConfirm"
|
||||
>{{confirmBtn}}</view
|
||||
>
|
||||
</view>
|
||||
<!-- 扩展插槽 -->
|
||||
<slot name="header" />
|
||||
<view class="{{_.cls(classPrefix + '__main', [])}}">
|
||||
<slot />
|
||||
<view class="{{classPrefix}}__mask {{classPrefix}}__mask--top" />
|
||||
<view class="{{classPrefix}}__mask {{classPrefix}}__mask--bottom" />
|
||||
<view class="{{classPrefix}}__indicator"></view>
|
||||
</view>
|
||||
<!-- 扩展插槽 -->
|
||||
<slot name="footer" />
|
||||
</view>
|
||||
</t-popup>
|
||||
104
miniprogram_npm/tdesign-miniprogram/picker/picker.wxss
Normal file
104
miniprogram_npm/tdesign-miniprogram/picker/picker.wxss
Normal file
@@ -0,0 +1,104 @@
|
||||
.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-picker {
|
||||
position: relative;
|
||||
background-color: var(--td-picker-bg-color, var(--td-bg-color-block, #fff));
|
||||
padding-bottom: constant(safe-area-inset-bottom);
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
border-top-left-radius: var(--td-picker-border-radius, 24rpx);
|
||||
border-top-right-radius: var(--td-picker-border-radius, 24rpx);
|
||||
}
|
||||
.t-picker__toolbar {
|
||||
background-color: #fff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
overflow: hidden;
|
||||
height: var(--td-picker-toolbar-height, 116rpx);
|
||||
}
|
||||
.t-picker__title {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
color: var(--td-picker-title-color, var(--td-font-gray-1, rgba(0, 0, 0, 0.9)));
|
||||
line-height: var(--td-picker-title-line-height, 52rpx);
|
||||
font-weight: var(--td-picker-title-font-weight, 600);
|
||||
font-size: var(--td-picker-title-font-size, 36rpx);
|
||||
}
|
||||
.t-picker__cancel,
|
||||
.t-picker__confirm {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
user-select: none;
|
||||
font-size: var(--td-picker-button-font-size, 32rpx);
|
||||
height: 100%;
|
||||
padding: 0 32rpx;
|
||||
}
|
||||
.t-picker__cancel {
|
||||
color: var(--td-picker-cancel-color, var(--td-font-gray-2, rgba(0, 0, 0, 0.6)));
|
||||
}
|
||||
.t-picker__confirm {
|
||||
color: var(--td-picker-confirm-color, var(--td-primary-color, #0052d9));
|
||||
}
|
||||
.t-picker__main {
|
||||
background-color: #fff;
|
||||
position: relative;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
.t-picker__mask {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 3;
|
||||
backface-visibility: hidden;
|
||||
pointer-events: none;
|
||||
height: 96rpx;
|
||||
}
|
||||
.t-picker__mask--top {
|
||||
top: 0;
|
||||
background: linear-gradient(180deg, #fff 0%, rgba(255, 255, 255, 0) 100%);
|
||||
}
|
||||
.t-picker__mask--bottom {
|
||||
bottom: 0;
|
||||
background: linear-gradient(180deg, #fff 0%, rgba(255, 255, 255, 0) 100%);
|
||||
transform: matrix(1, 0, 0, -1, 0, 0);
|
||||
}
|
||||
.t-picker__indicator {
|
||||
height: var(--td-picker-item-height, 80rpx);
|
||||
position: absolute;
|
||||
left: 32rpx;
|
||||
right: 32rpx;
|
||||
top: 144rpx;
|
||||
pointer-events: none;
|
||||
background-color: var(--td-picker-indicator-bg-color, var(--td-gray-color-1, #f3f3f3));
|
||||
border-radius: var(--td-picker-indicator-border-radius, 12rpx);
|
||||
}
|
||||
3
miniprogram_npm/tdesign-miniprogram/picker/props.d.ts
vendored
Normal file
3
miniprogram_npm/tdesign-miniprogram/picker/props.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { TdPickerProps } from './type';
|
||||
declare const props: TdPickerProps;
|
||||
export default props;
|
||||
49
miniprogram_npm/tdesign-miniprogram/picker/props.js
Normal file
49
miniprogram_npm/tdesign-miniprogram/picker/props.js
Normal file
@@ -0,0 +1,49 @@
|
||||
const props = {
|
||||
autoClose: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
cancelBtn: {
|
||||
type: null,
|
||||
value: true,
|
||||
},
|
||||
columns: {
|
||||
type: null,
|
||||
value: [],
|
||||
},
|
||||
confirmBtn: {
|
||||
type: null,
|
||||
value: true,
|
||||
},
|
||||
customStyle: {
|
||||
type: String,
|
||||
value: '',
|
||||
},
|
||||
footer: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
header: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
renderLabel: {
|
||||
type: null,
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
value: '',
|
||||
},
|
||||
value: {
|
||||
type: Array,
|
||||
value: null,
|
||||
},
|
||||
defaultValue: {
|
||||
type: Array,
|
||||
},
|
||||
visible: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
};
|
||||
export default props;
|
||||
71
miniprogram_npm/tdesign-miniprogram/picker/type.d.ts
vendored
Normal file
71
miniprogram_npm/tdesign-miniprogram/picker/type.d.ts
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
import { ButtonProps } from '../button/index';
|
||||
export interface TdPickerProps {
|
||||
autoClose?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
cancelBtn?: {
|
||||
type: null;
|
||||
value?: boolean | string | ButtonProps;
|
||||
};
|
||||
columns: {
|
||||
type: ArrayConstructor;
|
||||
value?: Array<PickerColumn> | ((item: Array<PickerValue>) => Array<PickerColumn>);
|
||||
};
|
||||
confirmBtn?: {
|
||||
type: null;
|
||||
value?: boolean | string | ButtonProps;
|
||||
};
|
||||
customStyle?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
footer?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
header?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
renderLabel?: {
|
||||
type: StringConstructor;
|
||||
value?: (item: PickerColumnItem) => string;
|
||||
};
|
||||
title?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
value?: {
|
||||
type: ArrayConstructor;
|
||||
value?: Array<PickerValue>;
|
||||
};
|
||||
defaultValue?: {
|
||||
type: ArrayConstructor;
|
||||
value?: Array<PickerValue>;
|
||||
};
|
||||
visible?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
}
|
||||
export interface TdPickerItemProps {
|
||||
customStyle?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
format?: {
|
||||
type: null;
|
||||
value?: (option: PickerColumnItem) => string;
|
||||
};
|
||||
options?: {
|
||||
type: ArrayConstructor;
|
||||
value?: Array<PickerColumnItem>;
|
||||
};
|
||||
}
|
||||
export declare type PickerColumn = PickerColumnItem[];
|
||||
export interface PickerColumnItem {
|
||||
label: string;
|
||||
value: string;
|
||||
}
|
||||
export declare type PickerValue = string | number;
|
||||
1
miniprogram_npm/tdesign-miniprogram/picker/type.js
Normal file
1
miniprogram_npm/tdesign-miniprogram/picker/type.js
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
Reference in New Issue
Block a user