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: tooltip 支持 slot #1034

Merged
merged 2 commits into from
Jan 22, 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
17 changes: 17 additions & 0 deletions compiled/alipay/demo/pages/Form/index.axml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@
tooltip="用户名说明"
allowClear
ref="handleRef" />
<form-input
label="密码"
name="password"
placeholder="请输入密码"
allowClear
ref="handleRef">
<view slot="tooltip">
<icon
onTap="showToast"
type="QuestionCircleOutline" />
</view>
</form-input>
<form-input
label="地址"
name="address"
Expand Down Expand Up @@ -88,3 +100,8 @@
</ant-button>
<ant-button onTap="reset">重置</ant-button>
</view>

<toast
content="密码的自定义 tooltip"
visible="{{toastShow}}"
onClose="handleCloseToast" />
11 changes: 11 additions & 0 deletions compiled/alipay/demo/pages/Form/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Page({
{ value: 'football', text: '⚽️' },
{ value: 'badminton', text: '🏸️' },
],
toastShow: false,
},
onLoad() {
this.form = new Form();
Expand All @@ -44,4 +45,14 @@ Page({
}, 2000);
});
},
showToast() {
this.setData({
toastShow: true,
});
},
handleCloseToast() {
this.setData({
toastShow: false,
});
},
});
4 changes: 3 additions & 1 deletion compiled/alipay/demo/pages/Form/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"form-upload-image": "../../../src/Form/FormImageUpload/index",
"form-rate": "../../../src/Form/FormRate/index",
"form-textarea": "../../../src/Form/FormTextarea/index",
"ant-button": "../../../src/Button/index"
"ant-button": "../../../src/Button/index",
"icon": "../../../src/Icon/index",
"toast": "../../../src/Toast/index"
}
}
6 changes: 6 additions & 0 deletions compiled/alipay/src/Form/FormCascaderPicker/index.axml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@
</cascader-picker>
</view>

<view
a:if="{{ !tooltip }}"
slot="tooltip">
<slot name="tooltip" />
</view>

<view slot="extra">
<slot name="extra">{{ extra }}</slot>
</view>
Expand Down
5 changes: 5 additions & 0 deletions compiled/alipay/src/Form/FormCheckboxGroup/index.axml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
index="{{ props.index }}" />
</checkbox-group>
</view>
<view
a:if="{{ !tooltip }}"
slot="tooltip">
<slot name="tooltip" />
</view>
<view slot="extra">
<slot name="extra">{{ extra }}</slot>
</view>
Expand Down
5 changes: 5 additions & 0 deletions compiled/alipay/src/Form/FormDatePicker/index.axml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
slot="suffix" />
</date-picker>
</view>
<view
a:if="{{ !tooltip }}"
slot="tooltip">
<slot name="tooltip" />
</view>
<view slot="extra">
<slot name="extra">{{ extra }}</slot>
</view>
Expand Down
5 changes: 5 additions & 0 deletions compiled/alipay/src/Form/FormImageUpload/index.axml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
onPreview="onPreview"
onBeforeUpload="{{ handleBeforeUpload ? handleBeforeUpload : 'handleBeforeUpload' }}"
onChooseImageError="onChooseImageError" />
<view
a:if="{{ !tooltip }}"
slot="tooltip">
<slot name="tooltip" />
</view>
<view slot="extra">
<slot name="extra">{{ extra }}</slot>
</view>
Expand Down
5 changes: 5 additions & 0 deletions compiled/alipay/src/Form/FormInput/index.axml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
slot="suffix"
name="suffix" />
</ant-input>
<view
a:if="{{ !tooltip }}"
slot="tooltip">
<slot name="tooltip" />
</view>
<view slot="extra">
<slot name="extra">{{ extra }}</slot>
</view>
Expand Down
3 changes: 3 additions & 0 deletions compiled/alipay/src/Form/FormItem/index.axml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
</view>
<ant-icon type="QuestionCircleOutline" />
</popover>
<slot
a:else
name="tooltip" />
</view>
<view class="ant-form-item-field ant-form-item-field-{{ position }}">
<slot />
Expand Down
5 changes: 5 additions & 0 deletions compiled/alipay/src/Form/FormPicker/index.axml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
slot="suffix" />
</picker>
</view>
<view
a:if="{{ !tooltip }}"
slot="tooltip">
<slot name="tooltip" />
</view>
<view slot="extra">
<slot name="extra">{{ extra }}</slot>
</view>
Expand Down
6 changes: 6 additions & 0 deletions compiled/alipay/src/Form/FormRadioGroup/index.axml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
</radio-group>
</view>

<view
a:if="{{ !tooltip }}"
slot="tooltip">
<slot name="tooltip" />
</view>

<view slot="extra">
<slot name="extra">{{ extra }}</slot>
</view>
Expand Down
5 changes: 5 additions & 0 deletions compiled/alipay/src/Form/FormRangePicker/index.axml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
slot="suffix" />
</range-picker>
</view>
<view
a:if="{{ !tooltip }}"
slot="tooltip">
<slot name="tooltip" />
</view>
<view slot="extra">
<slot name="extra">{{ extra }}</slot>
</view>
Expand Down
5 changes: 5 additions & 0 deletions compiled/alipay/src/Form/FormRate/index.axml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
</slot>
</view>
</rate>
<view
a:if="{{ !tooltip }}"
slot="tooltip">
<slot name="tooltip" />
</view>
<view slot="extra">
<slot name="extra">{{ extra }}</slot>
</view>
Expand Down
5 changes: 5 additions & 0 deletions compiled/alipay/src/Form/FormSelector/index.axml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
onSelectMin="onSelectMin"
onChange="onChange" />
</view>
<view
a:if="{{ !tooltip }}"
slot="tooltip">
<slot name="tooltip" />
</view>
<view slot="extra">
<slot name="extra">{{ extra }}</slot>
</view>
Expand Down
5 changes: 5 additions & 0 deletions compiled/alipay/src/Form/FormSlider/index.axml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
onChange="onChange"
onAfterChange="onAfterChange" />
</view>
<view
a:if="{{ !tooltip }}"
slot="tooltip">
<slot name="tooltip" />
</view>
<view slot="extra">
<slot name="extra">{{ extra }}</slot>
</view>
Expand Down
5 changes: 5 additions & 0 deletions compiled/alipay/src/Form/FormStepper/index.axml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
onConfirm="onConfirm"
onFocus="onFocus" />
</view>
<view
a:if="{{ !tooltip }}"
slot="tooltip">
<slot name="tooltip" />
</view>
<view slot="extra">
<slot name="extra">{{ extra }}</slot>
</view>
Expand Down
6 changes: 6 additions & 0 deletions compiled/alipay/src/Form/FormSwitch/index.axml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
onChange="onChange" />
</view>

<view
a:if="{{ !tooltip }}"
slot="tooltip">
<slot name="tooltip" />
</view>

<view slot="extra">
<slot name="extra">{{ extra }}</slot>
</view>
Expand Down
5 changes: 5 additions & 0 deletions compiled/alipay/src/Form/FormTextarea/index.axml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
onBlur="onBlur"
onFocus="onFocus"
onConfirm="onConfirm" />
<view
a:if="{{ !tooltip }}"
slot="tooltip">
<slot name="tooltip" />
</view>
<view slot="extra">
<slot name="extra">{{ extra }}</slot>
</view>
Expand Down
2 changes: 1 addition & 1 deletion compiled/alipay/src/Form/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Form 表单。包含数据录入、校验以及对应样式。Form 组件需要
| validateStatus | 校验状态,如不设置,则会根据校验规则自动生成,可选 `default` `success` `error` `validating` | string | - |
| help | 提示信息,如不设置,则会根据校验规则自动生成 | string | - |
| header | 顶部 slot,接收 errors、status | slot | - |
| tooltip | 表单项提示信息 | string | - |
| tooltip | 表单项提示信息 | string\|slot | - |
| required | 必填样式设置。如不设置,则会根据校验规则自动生成 | boolean | false |
| message | 校验错误信息。如不设置,则会根据校验规则自动生成 | string | false |
| requiredMark | 必填选填的标记样式,可选 `asterisk` `text-required` `text-optional` | string | asterisk |
Expand Down
11 changes: 11 additions & 0 deletions compiled/wechat/demo/pages/Form/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Page({
{ value: 'football', text: '⚽️' },
{ value: 'badminton', text: '🏸️' },
],
toastShow: false,
},
onLoad: function () {
var _this = this;
Expand Down Expand Up @@ -95,4 +96,14 @@ Page({
});
});
},
showToast: function () {
this.setData({
toastShow: true,
});
},
handleCloseToast: function () {
this.setData({
toastShow: false,
});
},
});
4 changes: 3 additions & 1 deletion compiled/wechat/demo/pages/Form/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"form-upload-image": "../../../src/Form/FormImageUpload/index",
"form-rate": "../../../src/Form/FormRate/index",
"form-textarea": "../../../src/Form/FormTextarea/index",
"ant-button": "../../../src/Button/index"
"ant-button": "../../../src/Button/index",
"icon": "../../../src/Icon/index",
"toast": "../../../src/Toast/index"
}
}
17 changes: 17 additions & 0 deletions compiled/wechat/demo/pages/Form/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@
tooltip="用户名说明"
allowClear
bind:ref="handleRef" />
<form-input
label="密码"
name="password"
placeholder="请输入密码"
allowClear
bind:ref="handleRef">
<view slot="tooltip">
<icon
bind:tap="showToast"
type="QuestionCircleOutline" />
</view>
</form-input>
<form-input
label="地址"
name="address"
Expand Down Expand Up @@ -88,3 +100,8 @@
</ant-button>
<ant-button bind:tap="reset">重置</ant-button>
</view>

<toast
content="密码的自定义 tooltip"
visible="{{toastShow}}"
onClose="handleCloseToast" />
6 changes: 6 additions & 0 deletions compiled/wechat/src/Form/FormCascaderPicker/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@
</cascader-picker>
</view>

<view
wx:if="{{ !tooltip }}"
slot="tooltip">
<slot name="tooltip" />
</view>

<view slot="extra">
<slot name="extra">{{ extra }}</slot>
</view>
Expand Down
5 changes: 5 additions & 0 deletions compiled/wechat/src/Form/FormCheckboxGroup/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
index="{{ props.index }}" />
</checkbox-group>
</view>
<view
wx:if="{{ !tooltip }}"
slot="tooltip">
<slot name="tooltip" />
</view>
<view slot="extra">
<slot name="extra">{{ extra }}</slot>
</view>
Expand Down
5 changes: 5 additions & 0 deletions compiled/wechat/src/Form/FormDatePicker/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
slot="suffix" />
</date-picker>
</view>
<view
wx:if="{{ !tooltip }}"
slot="tooltip">
<slot name="tooltip" />
</view>
<view slot="extra">{{ extra }}</view>
<view
slot="header"
Expand Down
5 changes: 5 additions & 0 deletions compiled/wechat/src/Form/FormImageUpload/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
onPreview="onPreview"
onBeforeUpload="{{ handleBeforeUpload ? handleBeforeUpload : 'handleBeforeUpload' }}"
onChooseImageError="onChooseImageError" />
<view
wx:if="{{ !tooltip }}"
slot="tooltip">
<slot name="tooltip" />
</view>
<view slot="extra">{{ extra }}</view>
<view
slot="header"
Expand Down
5 changes: 5 additions & 0 deletions compiled/wechat/src/Form/FormInput/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
slot="suffix"
name="suffix" />
</ant-input>
<view
wx:if="{{ !tooltip }}"
slot="tooltip">
<slot name="tooltip" />
</view>
<view slot="extra">{{ extra }}</view>
<view
slot="header"
Expand Down
3 changes: 3 additions & 0 deletions compiled/wechat/src/Form/FormItem/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
</view>
<ant-icon type="QuestionCircleOutline" />
</popover>
<slot
wx:else
name="tooltip" />
</view>
<view class="ant-form-item-field ant-form-item-field-{{ position }}">
<slot />
Expand Down
5 changes: 5 additions & 0 deletions compiled/wechat/src/Form/FormPicker/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
slot="suffix" />
</picker>
</view>
<view
wx:if="{{ !tooltip }}"
slot="tooltip">
<slot name="tooltip" />
</view>
<view slot="extra">{{ extra }}</view>
<view
slot="header"
Expand Down
Loading
Loading