-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: radio 适配微信 * feat: radio 适配微信 * feat: radio 适配微信 --------- Co-authored-by: DiamondYuan <fandi.yfd@antgroup.com>
- Loading branch information
1 parent
9763cff
commit 1cec707
Showing
41 changed files
with
655 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,5 +9,5 @@ Page({ | |
this.setData({ | ||
checked: checked, | ||
}); | ||
} | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"defaultTitle": "RadioGroup", | ||
"usingComponents": { | ||
"radio-group": "../../../src/Radio/RadioGroup/index", | ||
"container": "../../../src/Container/index" | ||
"ant-radio-group": "../../../src/Radio/RadioGroup/index", | ||
"ant-container": "../../../src/Container/index" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
{ | ||
"component": true, | ||
"usingComponents": { | ||
"list-item": "../List/ListItem/index", | ||
"icon": "../Icon/index" | ||
"ant-icon": "../Icon/index" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Page({ | ||
data: { | ||
checked: false, | ||
}, | ||
onChange: function (value, e) { | ||
console.log(value, e); | ||
}, | ||
handleChange: function (checked) { | ||
this.setData({ | ||
checked: checked.detail, | ||
}); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"defaultTitle": "Radio", | ||
"usingComponents": { | ||
"radio": "../../../src/Radio/index", | ||
"container": "../../../src/Container/index", | ||
"icon": "../../../src/Icon/index" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<container title="基础用法"> | ||
<radio bind:change="onChange">Radio</radio> | ||
</container> | ||
|
||
<container title="初始值"> | ||
<radio defaultChecked="{{ true }}">Radio</radio> | ||
</container> | ||
|
||
<container title="禁用模式"> | ||
<radio disabled>Radio1</radio> | ||
<radio | ||
defaultChecked | ||
disabled> | ||
Radio2 | ||
</radio> | ||
</container> | ||
|
||
<container title="自定义颜色"> | ||
<radio | ||
color="red" | ||
defaultChecked> | ||
Radio | ||
</radio> | ||
</container> | ||
|
||
<container title="控制模式"> | ||
<radio | ||
checked="{{ checked }}" | ||
bind:change="handleChange"> | ||
Radio | ||
</radio> | ||
</container> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Page({ | ||
data: { | ||
value: 'banana', | ||
options: [ | ||
{ value: 'apple', label: '苹果' }, | ||
{ value: 'orange', label: '橘子' }, | ||
{ value: 'banana', label: '香蕉' }, | ||
], | ||
optionsWithDisabled: [ | ||
{ value: 'apple', label: '苹果' }, | ||
{ value: 'orange', label: '橘子' }, | ||
{ value: 'watermelon', label: '西瓜', disabled: true }, | ||
{ value: 'banana', label: '香蕉' }, | ||
], | ||
}, | ||
onChange: function (value, e) { | ||
console.log(value, e); | ||
}, | ||
handleChange: function (value) { | ||
this.setData({ | ||
value: value.detail, | ||
}); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"defaultTitle": "RadioGroup", | ||
"usingComponents": { | ||
"ant-radio-group": "../../../src/Radio/RadioGroup/index", | ||
"ant-container": "../../../src/Container/index" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<ant-container title="基础用法"> | ||
<ant-radio-group | ||
options="{{ options }}" | ||
bind:change="onChange" /> | ||
</ant-container> | ||
|
||
<ant-container title="初始值"> | ||
<ant-radio-group | ||
defaultValue="banana" | ||
options="{{ options }}" | ||
bind:change="onChange" /> | ||
</ant-container> | ||
|
||
<ant-container title="横向布局"> | ||
<ant-radio-group | ||
options="{{ options }}" | ||
position="horizontal" /> | ||
</ant-container> | ||
|
||
<ant-container title="禁用模式-所有禁用"> | ||
<ant-radio-group | ||
options="{{ options }}" | ||
disabled /> | ||
</ant-container> | ||
|
||
<ant-container title="禁用模式-其中有的禁用"> | ||
<ant-radio-group options="{{ optionsWithDisabled }}" /> | ||
</ant-container> | ||
|
||
<ant-container title="控制模式"> | ||
<ant-radio-group | ||
value="{{ value }}" | ||
options="{{ options }}" | ||
bind:change="handleChange" /> | ||
</ant-container> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.icon { | ||
border: 1px solid #CCCCCC; | ||
border-radius: 50vh; | ||
width: 100%; | ||
height: 100%; | ||
box-sizing: border-box; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
.checked { | ||
background-color: red; | ||
color: #fff; | ||
font-size: 14px; | ||
} | ||
.disabled { | ||
opacity: 0.4; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { mountComponent } from '../../_util/component'; | ||
import { useMixState } from '../../_util/hooks/useMixState'; | ||
import { useEvent } from 'functional-mini/component'; | ||
import { useComponentEvent } from '../../_util/hooks/useComponentEvent'; | ||
var RadioGroup = function (props) { | ||
var _a = useMixState(props.defaultValue, { | ||
value: props.value, | ||
}), value = _a[0], _b = _a[1], isControlled = _b.isControlled, update = _b.update; | ||
var triggerEvent = useComponentEvent(props).triggerEvent; | ||
useEvent('onChange', function (e) { | ||
var index = e.currentTarget.dataset.index; | ||
var value = props.options[index].value; | ||
if (!isControlled) { | ||
update(value); | ||
} | ||
triggerEvent('change', value, e); | ||
}); | ||
return { | ||
mixin: { | ||
value: value, | ||
}, | ||
}; | ||
}; | ||
mountComponent(RadioGroup, { | ||
value: null, | ||
defaultValue: null, | ||
name: '', | ||
disabled: false, | ||
color: '', | ||
position: 'vertical', | ||
options: [], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"component": true, | ||
"usingComponents": { | ||
"list": "../../List/index", | ||
"list-item": "../../List/ListItem/index", | ||
"radio": "../index" | ||
} | ||
} |
Oops, something went wrong.