Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(DateTimePicker): add formatter props #562

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified db/TDesign.db
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ end | String / Number | - | \- | N
filter | Function | - | Typescript:`(type: TimeModeValues, columns: DateTimePickerColumn) => DateTimePickerColumn` `type DateTimePickerColumn = DateTimePickerColumnItem[]` `interface DateTimePickerColumnItem { label: string,value: string}`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/date-time-picker/type.ts) | N
footer | Slot | - | [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
format | String | 'YYYY-MM-DD HH:mm:ss' | \- | N
formatter | Function | - | Typescript:`(option: DateTimePickerColumnItem, columnIndex: number) => DateTimePickerColumnItem` | N
header | Boolean / Slot | true | [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
mode | String / Array | 'date' | Typescript:`DateTimePickerMode` `type DateTimePickerMode = TimeModeValues \| Array<TimeModeValues> ` `type TimeModeValues = 'year' \| 'month' \| 'date' \| 'hour' \| 'minute' \| 'second'`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/date-time-picker/type.ts) | N
popup-props | Object | {} | popup properties。Typescript:`PopupProps`,[Popup API Documents](./popup?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/date-time-picker/type.ts) | N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ end | String / Number | - | 选择器的最大可选时间,默认为当前时
filter | Function | - | 列选项过滤函数,支持自定义列内容。(type 值可为: year, month, date, hour, minute, second)。TS 类型:`(type: TimeModeValues, columns: DateTimePickerColumn) => DateTimePickerColumn` `type DateTimePickerColumn = DateTimePickerColumnItem[]` `interface DateTimePickerColumnItem { label: string,value: string}`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/date-time-picker/type.ts) | N
footer | Slot | - | 底部内容。[通用类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
format | String | 'YYYY-MM-DD HH:mm:ss' | 用于格式化 pick、change、confirm 事件返回的值,[详细文档](https://day.js.org/docs/en/display/format) | N
formatter | Function | - | 格式化标签。TS 类型:`(option: DateTimePickerColumnItem, columnIndex: number) => DateTimePickerColumnItem` | N
header | Boolean / Slot | true | 头部内容。值为 true 显示空白头部,值为 false 不显示任何内容。[通用类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
mode | String / Array | 'date' | year = 年;month = 年月;date = 年月日;hour = 年月日时; minute = 年月日时分;当类型为数组时,第一个值控制年月日,第二个值控制时分秒。TS 类型:`DateTimePickerMode` `type DateTimePickerMode = TimeModeValues \| Array<TimeModeValues> ` `type TimeModeValues = 'year' \| 'month' \| 'date' \| 'hour' \| 'minute' \| 'second'`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/date-time-picker/type.ts) | N
popup-props | Object | {} | 透传 Popup 组件全部属性。TS 类型:`PopupProps`,[Popup API Documents](./popup?tab=api)。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/date-time-picker/type.ts) | N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ const props: TdDateTimePickerProps = {
type: String,
value: 'YYYY-MM-DD HH:mm:ss',
},
/** 格式化标签 */
formatter: {
type: null,
},
/** 头部内容。值为 true 显示空白头部,值为 false 不显示任何内容 */
header: {
type: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ export interface TdDateTimePickerProps {
type: StringConstructor;
value?: string;
};
/**
* 格式化标签
*/
formatter?: {
type: undefined;
value?: (option: DateTimePickerColumnItem, columnIndex: number) => DateTimePickerColumnItem;
};
/**
* 头部内容。值为 true 显示空白头部,值为 false 不显示任何内容
* @default true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface TdPickerItemProps {
*/
format?: {
type: undefined;
value?: (option: PickerItemOption) => string;
value?: (option: PickerItemOption, columnIndex: number) => PickerItemOption;
};
/**
* 数据源
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ name | type | default | description | required
-- | -- | -- | -- | --
style | Object | - | CSS(Cascading Style Sheets) | N
custom-style | Object | - | CSS(Cascading Style Sheets),used to set style on virtual component | N
format | Function | - | Typescript:`(option: PickerItemOption) => string` | N
format | Function | - | Typescript:`(option: PickerItemOption, columnIndex: number) => PickerItemOption` | N
options | Array | [] | Typescript:`PickerItemOption[]` `interface PickerItemOption { label: string; value: string \| number }`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/picker-item/type.ts) | N
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ pick | `(value: Array<PickerValue>, label: string, column: number, index: number
-- | -- | -- | -- | --
style | Object | - | 样式 | N
custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场景 | N
format | Function | - | 格式化标签。TS 类型:`(option: PickerItemOption) => string` | N
format | Function | - | 格式化标签。TS 类型:`(option: PickerItemOption, columnIndex: number) => PickerItemOption` | N
options | Array | [] | 数据源。TS 类型:`PickerItemOption[]` `interface PickerItemOption { label: string; value: string \| number }`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/picker-item/type.ts) | N
39 changes: 38 additions & 1 deletion packages/scripts/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -36291,6 +36291,43 @@
"String"
]
},
{
"id": 1740731296,
"platform_framework": [
"64"
],
"component": "DateTimePicker",
"field_category": 1,
"field_name": "formatter",
"field_type": [
"32"
],
"field_default_value": "",
"field_enum": "",
"field_desc_zh": "格式化标签",
"field_desc_en": null,
"field_required": 0,
"event_input": "",
"create_time": "2025-02-28 08:28:16",
"update_time": "2025-02-28 08:28:16",
"event_output": null,
"custom_field_type": "(option: DateTimePickerColumnItem, columnIndex: number) => DateTimePickerColumnItem",
"syntactic_sugar": null,
"readonly": 1,
"html_attribute": 0,
"trigger_elements": "",
"deprecated": 0,
"version": "",
"test_description": null,
"support_default_value": 0,
"field_category_text": "Props",
"platform_framework_text": [
"Miniprogram"
],
"field_type_text": [
"Function"
]
},
{
"id": 2509,
"platform_framework": [
Expand Down Expand Up @@ -81576,7 +81613,7 @@
"create_time": "2023-01-09 06:35:32",
"update_time": "2023-01-09 06:35:32",
"event_output": null,
"custom_field_type": "(option: PickerItemOption) => string",
"custom_field_type": "(option: PickerItemOption, columnIndex: number) => PickerItemOption",
"syntactic_sugar": null,
"readonly": 1,
"html_attribute": 0,
Expand Down