Skip to content

Commit 9541b24

Browse files
Boomkaaanlyyao
andauthored
fix(form): 修改form组件示例与问题 (#4283)
* fix(form): 修改form组件示例与问题 * fix(form): snap-update * fix(dropdown-menu): snap-update * chore: add form route * fix(form): form组件修改 * fix: fix cr * docs: update css vars * docs: regenerate api docs * fix: fix console warnings * fix(Form): fixed incorrect validation results --------- Co-authored-by: anlyyao <anly_yaw@163.com>
1 parent 3f62d62 commit 9541b24

38 files changed

Lines changed: 746 additions & 1179 deletions

File tree

packages/components/date-time-picker/_example/year-month-date/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Page({
6363

6464
return {
6565
value: item.value,
66-
label: item.label.slice(0, -1),
66+
label: item.label?.slice(0, -1),
6767
};
6868
},
6969
},

packages/components/date-time-picker/date-time-picker.wxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
visible="{{visible}}"
66
value="{{columnsValue}}"
77
header="{{header}}"
8-
title="{{title || globalConfig.title}}"
8+
title="{{title || globalConfig.title || ''}}"
99
auto-close="{{autoClose}}"
1010
confirm-btn="{{confirmBtn || globalConfig.confirm}}"
1111
cancel-btn="{{cancelBtn || globalConfig.cancel}}"

packages/components/dropdown-menu/__test__/__snapshots__/index.test.js.snap

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ exports[`dropdown-menu :base 1`] = `
99
class="t-dropdown-menu class t-class"
1010
id="t-bar"
1111
style="font-size: 9px;"
12-
catch:touchmove="noop"
12+
catch:touchmove=""
1313
>
1414
<wx-view
1515
ariaDisabled="{{false}}"
16-
ariaExpanded="{{true}}"
16+
ariaExpanded="{{false}}"
1717
ariaHaspopup="menu"
1818
ariaRole="button"
19-
class="t-dropdown-menu__item t-dropdown-menu__item--active t-dropdown-menu__item--0 t-class-item"
19+
class="t-dropdown-menu__item t-dropdown-menu__item--0 t-class-item"
2020
data-index="{{0}}"
2121
bind:tap="handleToggle"
2222
>
@@ -26,7 +26,7 @@ exports[`dropdown-menu :base 1`] = `
2626
菜单
2727
</wx-view>
2828
<t-icon
29-
tClass="t-dropdown-menu__icon t-dropdown-menu__icon--active t-class-icon"
29+
tClass="t-dropdown-menu__icon t-dropdown-menu__icon-- t-class-icon"
3030
bind:click=""
3131
>
3232
<wx-view
@@ -85,7 +85,7 @@ exports[`dropdown-menu :base 1`] = `
8585
>
8686
<wx-view
8787
class="t-dropdown-item__mask"
88-
hidden="{{false}}"
88+
hidden="{{true}}"
8989
style="height:0px;"
9090
bind:tap="handleMaskClick"
9191
catch:touchmove="closeDropdown"
@@ -97,7 +97,7 @@ exports[`dropdown-menu :base 1`] = `
9797
bind:visible-change="handleMaskClick"
9898
>
9999
<wx-view
100-
class="t-popup t-popup--top t-fade-enter-active t-fade-enter-to class t-class"
100+
class="t-popup t-popup--top t-fade-leave-active t-fade-leave-to class t-class"
101101
style="z-index:11601;--td-popup-transition:all 200ms ease; position: absolute;"
102102
bind:transitionend="onTransitionEnd"
103103
>
@@ -608,7 +608,7 @@ exports[`dropdown-menu :base 1`] = `
608608
<wx-view
609609
ariaLabel="关闭"
610610
ariaRole="button"
611-
class="t-overlay t-fade-enter-active t-fade-enter-to class"
611+
class="t-overlay t-fade-leave-active t-fade-leave-to class"
612612
style="--td-overlay-transition-duration:200ms; z-index:11000; top:0px; position: absolute;"
613613
bind:tap="handleClick"
614614
catch:touchmove="noop"

packages/components/dropdown-menu/__test__/index.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ describe('dropdown-menu', () => {
3636
expect($first.instance.data.wrapperVisible).toBeTruthy();
3737

3838
$item.dispatchEvent('tap');
39+
await simulate.sleep(50);
3940
expect(comp.toJSON()).toMatchSnapshot();
4041
});
4142

packages/components/form-item/README.en-US.md

Lines changed: 0 additions & 30 deletions
This file was deleted.

packages/components/form-item/README.md

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 88 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,158 +1,134 @@
11
@import '../common/style/base.less';
22

33
/* Less 支持测试 - 监听功能验证 */
4-
@form-item-prefix: ~'@{prefix}-form-item';
4+
@form: ~'@{prefix}-form';
5+
@form-item: ~'@{prefix}-form__item';
56
@form-item-horizontal-padding: var(--td-form-item-horizontal-padding, 32rpx);
67
@form-item-vertical-padding: var(--td-form-item-vertical-padding, 32rpx);
7-
@form-item-label-width: var(--td-form-item-label-width, 160rpx);
8-
@form-item-justify-content: var(--td-form-item-justify-content, space-between);
9-
.@{form-item-prefix} {
10-
position: relative;
8+
@form-item-border-color: var(--td-form-item-border-color, @component-stroke);
9+
@form-item-border-left-space: var(--td-form-item-border-left-space, @form-item-vertical-padding);
10+
@form-item-border-right-space: var(--td-form-item-border-right-space, 0);
11+
12+
.@{form-item} {
1113
display: flex;
12-
align-items: flex-start;
13-
justify-content: @form-item-justify-content;
14-
width: 100%;
15-
padding: @form-item-horizontal-padding @form-item-vertical-padding;
16-
background-color: #ffffff;
17-
--td-input-vertical-padding: 0rpx;
18-
--td-textarea-vertical-padding: 0rpx;
19-
--td-textarea-horizontal-padding: 0rpx;
2014
box-sizing: border-box;
21-
&--top {
15+
padding: @form-item-vertical-padding @form-item-horizontal-padding;
16+
position: relative;
17+
18+
// 覆盖 slot 内子组件的 padding
19+
--td-cell-vertical-padding: 0;
20+
--td-cell-horizontal-padding: 0;
21+
--td-input-vertical-padding: 0;
22+
--td-textarea-padding: 0;
23+
24+
&:not(:last-child)::after {
25+
.hairline-bottom(@form-item-border-color);
26+
27+
left: @form-item-border-left-space;
28+
right: @form-item-border-right-space;
29+
}
30+
31+
&-help,
32+
&-extra {
2233
display: flex;
23-
flex-direction: column;
34+
font-size: @font-size-s;
35+
margin: 0;
36+
width: 100%;
37+
height: auto;
38+
min-height: 40rpx;
39+
margin-top: 8rpx;
2440
}
2541

26-
&--bordered {
27-
border-bottom: 1rpx solid @border-color;
42+
&-help {
43+
color: @text-color-disabled;
2844
}
2945

3046
&--error {
31-
.@{form-item-prefix}__error {
32-
color: @error-color;
33-
}
47+
color: @error-color-6;
3448
}
3549

36-
&--success {
37-
.@{form-item-prefix}__success {
38-
color: @success-color;
39-
}
50+
&--warning {
51+
color: @warning-color-5;
4052
}
4153

42-
&__label {
43-
position: relative;
54+
&-wrap {
55+
width: 100%;
56+
display: flex;
57+
}
58+
59+
&--top {
4460
display: flex;
61+
flex-direction: column;
62+
}
63+
}
64+
65+
.@{form} {
66+
&--top {
4567
align-items: center;
46-
width: @form-item-label-width;
47-
margin-right: 16rpx;
48-
font-size: @font-size-m;
68+
}
4969

70+
&__label {
71+
padding-right: 32rpx;
72+
vertical-align: middle;
73+
line-height: 48rpx;
5074
color: @text-color-primary;
51-
line-height: 1.5;
75+
box-sizing: border-box;
76+
word-break: break-all;
5277

53-
&--required {
54-
color: @error-color;
55-
margin-right: 4rpx;
56-
}
57-
58-
&--colon {
59-
margin-left: 4rpx;
78+
&--top {
79+
padding-bottom: 16rpx;
6080
}
6181

6282
&--left {
63-
display: flex;
64-
align-items: center;
65-
justify-content: flex-start;
83+
text-align: left;
6684
}
6785

6886
&--right {
69-
display: flex;
70-
align-items: center;
71-
justify-content: flex-end;
87+
text-align: right;
7288
}
7389

74-
&--top {
75-
position: relative;
76-
// margin-bottom: 8rpx;
77-
margin-right: 0;
78-
width: 100%;
90+
&--required:not(.@{form}__label--required-right) {
91+
label::before {
92+
display: inline;
93+
margin-right: calc(@spacer / 2);
94+
color: @error-color-6;
95+
content: '*';
96+
}
97+
}
98+
99+
&--required-right {
100+
label::after {
101+
display: inline;
102+
margin-left: calc(@spacer / 2);
103+
color: @error-color-6;
104+
content: '*';
105+
}
106+
}
107+
&--colon {
108+
label::after {
109+
content: ':';
110+
position: relative;
111+
margin: 0 4rpx;
112+
}
79113
}
80114
}
81115

82116
&__controls {
83117
flex: 1;
84-
width: 100%;
85-
margin-top: 8rpx;
86-
87-
&--left {
88-
text-align: left;
89-
}
90-
91-
&--right {
92-
text-align: right;
93-
}
118+
position: relative;
94119

95120
&-content {
96-
width: 100%;
97121
display: flex;
98122
align-items: center;
99-
justify-content: space-between;
123+
min-height: 48rpx;
100124
}
101-
}
102125

103-
&__help {
104-
// margin: 4rpx 0 8rpx;
105-
font-size: @font-size-m;
106-
107-
color: @font-gray-1;
108-
line-height: 1.4;
109-
}
110-
111-
&__desc-link {
112-
margin-top: 8rpx;
113-
color: @primary-color-7;
114-
font-size: @font-size-s;
115-
line-height: 1.4;
116-
}
117-
118-
&__error {
119-
margin-top: 4rpx;
120-
font-size: @font-size-s;
121-
line-height: 1.4;
122-
123-
&--error {
124-
color: @error-color;
126+
&--left {
127+
justify-content: flex-start;
125128
}
126129

127-
&--warning {
128-
color: @warning-color;
130+
&--right {
131+
justify-content: flex-end;
129132
}
130133
}
131-
132-
&__success {
133-
margin-top: 4rpx;
134-
font-size: @font-size-s;
135-
color: @success-color;
136-
line-height: 1.4;
137-
}
138-
139-
&__arrow {
140-
display: flex;
141-
align-items: center;
142-
margin-left: 8rpx;
143-
color: @text-color-placeholder;
144-
}
145-
146-
&__extra {
147-
margin-left: 16rpx;
148-
}
149-
}
150-
151-
.desc-wrapper {
152-
display: flex;
153-
align-items: center;
154-
gap: 12rpx;
155-
height: 50rpx;
156-
--td-button-font-weight: 400;
157-
// --td-button-extra-small-height: 38rpx;
158134
}

0 commit comments

Comments
 (0)