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: add any type #439

Merged
merged 1 commit into from
Oct 9, 2024
Merged
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 @@ -11,7 +11,7 @@ custom-style | Object | - | CSS(Cascading Style Sheets),used to set style on v
app-parameter | String | - | \- | N
block | Boolean | false | make button to be a block-level element | N
content | String / Slot | - | button's children elements。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
custom-dataset | Object | - | Typescript:`any` | N
custom-dataset | any | - | \- | N
disabled | Boolean | undefined | disable the button, make it can not be clicked | N
ghost | Boolean | false | make background-color to be transparent | N
hover-class | String | - | \- | N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场
app-parameter | String | - | 打开 APP 时,向 APP 传递的参数,open-type=launchApp时有效 | N
block | Boolean | false | 是否为块级元素 | N
content | String / Slot | - | 按钮内容。[通用类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
custom-dataset | Object | - | 自定义 dataset,可通过 event.currentTarget.dataset.custom 获取。。TS 类型:`any` | N
custom-dataset | any | - | 自定义 dataset,可通过 event.currentTarget.dataset.custom 获取 | N
disabled | Boolean | undefined | 禁用状态。优先级:Button.disabled > Form.disabled | N
ghost | Boolean | false | 是否为幽灵按钮(镂空按钮) | N
hover-class | String | - | 指定按钮按下去的样式类,按钮不为加载或禁用状态时有效。当 `hover-class="none"` 时,没有点击态效果 | N
Expand Down
4 changes: 2 additions & 2 deletions packages/products/tdesign-miniprogram/src/button/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ const props: TdButtonProps = {
content: {
type: String,
},
/** 自定义 dataset,可通过 event.currentTarget.dataset.custom 获取 */
/** 自定义 dataset,可通过 event.currentTarget.dataset.custom 获取 */
customDataset: {
type: Object,
type: null,
},
/** 禁用状态。优先级:Button.disabled > Form.disabled */
disabled: {
Expand Down
6 changes: 3 additions & 3 deletions packages/products/tdesign-miniprogram/src/button/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ export interface TdButtonProps {
value?: string;
};
/**
* 自定义 dataset,可通过 event.currentTarget.dataset.custom 获取
* 自定义 dataset,可通过 event.currentTarget.dataset.custom 获取
*/
customDataset?: {
type: ObjectConstructor;
value?: any;
type: null;
value?: null;
};
/**
* 禁用状态。优先级:Button.disabled > Form.disabled
Expand Down
8 changes: 4 additions & 4 deletions packages/scripts/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -13886,18 +13886,18 @@
"field_category": 1,
"field_name": "customDataset",
"field_type": [
"8"
"512"
],
"field_default_value": "",
"field_enum": "",
"field_desc_zh": "自定义 dataset,可通过 event.currentTarget.dataset.custom 获取",
"field_desc_zh": "自定义 dataset,可通过 event.currentTarget.dataset.custom 获取",
"field_desc_en": null,
"field_required": 0,
"event_input": "",
"create_time": "2022-03-14 07:32:55",
"update_time": "2022-03-14 07:40:54",
"event_output": null,
"custom_field_type": "any",
"custom_field_type": "",
"syntactic_sugar": null,
"readonly": 1,
"html_attribute": 0,
Expand All @@ -13911,7 +13911,7 @@
"Miniprogram"
],
"field_type_text": [
"Object"
"any"
]
},
{
Expand Down
4 changes: 4 additions & 0 deletions packages/scripts/map.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@
{
"label": "File",
"value": "256"
},
{
"label": "any",
"value": "512"
}
],
"components": [
Expand Down
5 changes: 3 additions & 2 deletions packages/scripts/types/miniprogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ function getMiniprogramType(type, tsType, required) {
boolean: 'BooleanConstructor',
Array: 'ArrayConstructor',
Object: 'ObjectConstructor',
any: 'null',
};
const types = [];
['string', 'number', 'boolean', 'Object', 'Array'].forEach((val) => {
['string', 'number', 'boolean', 'Object', 'Array', 'any'].forEach((val) => {
const reg = new RegExp(val, 'i');
if (reg.test(type)) {
types.push(MP_PROP_TYPES[val]);
}
});
const valueStr = ['function', 'Function'].includes(tsType) ? 'null' : tsType;
const valueStr = ['function', 'Function', 'any'].includes(tsType) ? 'null' : tsType;

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

Expand Down
7 changes: 4 additions & 3 deletions packages/scripts/types/vue-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,11 @@ function formatNormalProps(api, cmp, extraParams = {}) {
// && content.push(`optionalTypes: [${optionalTypes.join()}]`);
content.push(`${indent}type: null`);
} else {
let tType = types
let tType = types

if (isMiniprogram){
if ('Function' === types ){
if (isMiniprogram) {
const SPECIAL_TYPE = ['Function', 'any'];
if (SPECIAL_TYPE.includes(types)) {
tType = 'null'
}
if ('Boolean' === types && api.field_default_value === 'undefined'){
Expand Down
2 changes: 2 additions & 0 deletions packages/server/controllers/ComponentApi/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const FUNCTION = 32;
const TNODE = 64;
const Date = 128;
const FILE = 256;
const ANY = 512;

const P_VUE_PC = 1;
const P_REACT_PC = 2;
Expand Down Expand Up @@ -69,6 +70,7 @@ export const FIELD_TYPE_MAP: MapOptions = {
[TNODE]: 'TNode',
[Date]: 'Date',
[FILE]: 'File',
[ANY]: 'any',
};

export const PLATFORM_FRAMEWORK: MapOptions = {
Expand Down
Loading