Skip to content

Commit 0a4de19

Browse files
authored
feat: add any type (#439)
1 parent d88314c commit 0a4de19

File tree

10 files changed

+24
-16
lines changed

10 files changed

+24
-16
lines changed

db/TDesign.db

0 Bytes
Binary file not shown.

packages/products/tdesign-miniprogram/src/button/README.en-US.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ custom-style | Object | - | CSS(Cascading Style Sheets),used to set style on v
1111
app-parameter | String | - | \- | N
1212
block | Boolean | false | make button to be a block-level element | N
1313
content | String / Slot | - | button's children elements。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
14-
custom-dataset | Object | - | Typescript:`any` | N
14+
custom-dataset | any | - | \- | N
1515
disabled | Boolean | undefined | disable the button, make it can not be clicked | N
1616
ghost | Boolean | false | make background-color to be transparent | N
1717
hover-class | String | - | \- | N

packages/products/tdesign-miniprogram/src/button/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场
1111
app-parameter | String | - | 打开 APP 时,向 APP 传递的参数,open-type=launchApp时有效 | N
1212
block | Boolean | false | 是否为块级元素 | N
1313
content | String / Slot | - | 按钮内容。[通用类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
14-
custom-dataset | Object | - | 自定义 dataset,可通过 event.currentTarget.dataset.custom 获取。。TS 类型:`any` | N
14+
custom-dataset | any | - | 自定义 dataset,可通过 event.currentTarget.dataset.custom 获取 | N
1515
disabled | Boolean | undefined | 禁用状态。优先级:Button.disabled > Form.disabled | N
1616
ghost | Boolean | false | 是否为幽灵按钮(镂空按钮) | N
1717
hover-class | String | - | 指定按钮按下去的样式类,按钮不为加载或禁用状态时有效。当 `hover-class="none"` 时,没有点击态效果 | N

packages/products/tdesign-miniprogram/src/button/props.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ const props: TdButtonProps = {
2020
content: {
2121
type: String,
2222
},
23-
/** 自定义 dataset,可通过 event.currentTarget.dataset.custom 获取 */
23+
/** 自定义 dataset,可通过 event.currentTarget.dataset.custom 获取 */
2424
customDataset: {
25-
type: Object,
25+
type: null,
2626
},
2727
/** 禁用状态。优先级:Button.disabled > Form.disabled */
2828
disabled: {

packages/products/tdesign-miniprogram/src/button/type.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ export interface TdButtonProps {
3131
value?: string;
3232
};
3333
/**
34-
* 自定义 dataset,可通过 event.currentTarget.dataset.custom 获取
34+
* 自定义 dataset,可通过 event.currentTarget.dataset.custom 获取
3535
*/
3636
customDataset?: {
37-
type: ObjectConstructor;
38-
value?: any;
37+
type: null;
38+
value?: null;
3939
};
4040
/**
4141
* 禁用状态。优先级:Button.disabled > Form.disabled

packages/scripts/api.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13886,18 +13886,18 @@
1388613886
"field_category": 1,
1388713887
"field_name": "customDataset",
1388813888
"field_type": [
13889-
"8"
13889+
"512"
1389013890
],
1389113891
"field_default_value": "",
1389213892
"field_enum": "",
13893-
"field_desc_zh": "自定义 dataset,可通过 event.currentTarget.dataset.custom 获取",
13893+
"field_desc_zh": "自定义 dataset,可通过 event.currentTarget.dataset.custom 获取",
1389413894
"field_desc_en": null,
1389513895
"field_required": 0,
1389613896
"event_input": "",
1389713897
"create_time": "2022-03-14 07:32:55",
1389813898
"update_time": "2022-03-14 07:40:54",
1389913899
"event_output": null,
13900-
"custom_field_type": "any",
13900+
"custom_field_type": "",
1390113901
"syntactic_sugar": null,
1390213902
"readonly": 1,
1390313903
"html_attribute": 0,
@@ -13911,7 +13911,7 @@
1391113911
"Miniprogram"
1391213912
],
1391313913
"field_type_text": [
13914-
"Object"
13914+
"any"
1391513915
]
1391613916
},
1391713917
{

packages/scripts/map.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@
129129
{
130130
"label": "File",
131131
"value": "256"
132+
},
133+
{
134+
"label": "any",
135+
"value": "512"
132136
}
133137
],
134138
"components": [

packages/scripts/types/miniprogram.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@ function getMiniprogramType(type, tsType, required) {
99
boolean: 'BooleanConstructor',
1010
Array: 'ArrayConstructor',
1111
Object: 'ObjectConstructor',
12+
any: 'null',
1213
};
1314
const types = [];
14-
['string', 'number', 'boolean', 'Object', 'Array'].forEach((val) => {
15+
['string', 'number', 'boolean', 'Object', 'Array', 'any'].forEach((val) => {
1516
const reg = new RegExp(val, 'i');
1617
if (reg.test(type)) {
1718
types.push(MP_PROP_TYPES[val]);
1819
}
1920
});
20-
const valueStr = ['function', 'Function'].includes(tsType) ? 'null' : tsType;
21+
const valueStr = ['function', 'Function', 'any'].includes(tsType) ? 'null' : tsType;
2122

2223
const isRequired = required ? `required?: boolean;` : '';
2324

packages/scripts/types/vue-props.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,11 @@ function formatNormalProps(api, cmp, extraParams = {}) {
170170
// && content.push(`optionalTypes: [${optionalTypes.join()}]`);
171171
content.push(`${indent}type: null`);
172172
} else {
173-
let tType = types
173+
let tType = types
174174

175-
if (isMiniprogram){
176-
if ('Function' === types ){
175+
if (isMiniprogram) {
176+
const SPECIAL_TYPE = ['Function', 'any'];
177+
if (SPECIAL_TYPE.includes(types)) {
177178
tType = 'null'
178179
}
179180
if ('Boolean' === types && api.field_default_value === 'undefined'){

packages/server/controllers/ComponentApi/const.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const FUNCTION = 32;
1616
const TNODE = 64;
1717
const Date = 128;
1818
const FILE = 256;
19+
const ANY = 512;
1920

2021
const P_VUE_PC = 1;
2122
const P_REACT_PC = 2;
@@ -69,6 +70,7 @@ export const FIELD_TYPE_MAP: MapOptions = {
6970
[TNODE]: 'TNode',
7071
[Date]: 'Date',
7172
[FILE]: 'File',
73+
[ANY]: 'any',
7274
};
7375

7476
export const PLATFORM_FRAMEWORK: MapOptions = {

0 commit comments

Comments
 (0)