This commit is contained in:
Ling53666
2025-08-18 09:11:51 +08:00
commit 02554225da
2516 changed files with 133155 additions and 0 deletions

View File

@ -0,0 +1,70 @@
<import-sjs
from="../index.sjs"
name="componentUtils"
></import-sjs>
<list
className="ant-radio-group {{className ? className : ''}} ant-radio-group-{{position}}"
style="{{style}}"
>
<radio-group
name="{{name}}"
value="{{mixin.value}}"
>
<view class="ant-radio-group-body">
<block a:if="{{position === 'vertical'}}">
<block
a:for="{{options}}"
a:for-index="index"
a:for-item="item"
>
<list-item>
<radio
checked="{{componentUtils.getChecked(index, options, mixin.value)}}"
data-index="{{index}}"
value="{{item.value}}"
disabled="{{disabled || item.disabled}}"
color="{{item.color || color}}"
onChange="onChange"
>
<slot
name="label"
value="{{item}}"
index="{{index}}"
>
<view class="ant-radio-group-item-label-default">
{{item.label}}
</view>
</slot>
</radio>
</list-item>
</block>
</block>
<block a:else>
<block
a:for="{{options}}"
a:for-index="index"
a:for-item="item"
>
<radio
checked="{{componentUtils.getChecked(index, options, mixin.value)}}"
data-index="{{index}}"
value="{{item.value}}"
disabled="{{disabled || item.disabled}}"
color="{{item.color || color}}"
onChange="onChange"
>
<slot
name="label"
value="{{item}}"
index="{{index}}"
>
<view class="ant-radio-group-item-label-default">
{{item.label}}
</view>
</slot>
</radio>
</block>
</block>
</view>
</radio-group>
</list>

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,16 @@
import { Component, triggerEvent, getValueFromProps } from '../../_util/simply';
import { RadioGroupDefaultProps } from './props';
import mixinValue from '../../mixins/value';
Component(RadioGroupDefaultProps, {
onChange: function (_, e) {
var event;
event = e;
var index = event.currentTarget.dataset.index;
var options = getValueFromProps(this, 'options');
var value = options[index].value;
if (!this.isControlled()) {
this.update(value);
}
triggerEvent(this, 'change', value, event);
},
}, null, [mixinValue()]);

View File

@ -0,0 +1,8 @@
{
"component": true,
"usingComponents": {
"list": "../../List/index",
"list-item": "../../List/ListItem/index",
"radio": "../index"
}
}

View File

@ -0,0 +1,50 @@
@import (reference) '../variable.less';
@radioGroupPrefix: ant-radio-group;
.@{radioGroupPrefix} {
&-horizontal {
.@{radioGroupPrefix}-body {
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
.ant-list-item-line {
padding-right: 0;
}
.ant-radio-item {
flex-flow: 0;
}
.ant-list-item-line::after {
display: none;
}
}
}
&-header:empty,
&-footer:empty {
display: none;
}
&-header,
&-footer {
display: flex;
align-items: center;
padding: @v-spacing-standard @v-spacing-large;
line-height: 1.4;
font-size: 30 * @rpx;
color: @radio-header-color;
}
&-body {
position: relative;
overflow: hidden;
.ant-radio-item-content {
.ant-radio-group-item-label-default:not(:nth-child(1)) {
display: none;
}
}
}
}

View File

@ -0,0 +1,17 @@
import { IBaseProps } from '../../_util/base';
export interface IRadioGroupProps extends IBaseProps {
value: string;
defaultValue: string;
name: string;
disabled?: boolean;
color: string;
position: 'horizontal' | 'vertical';
onChange?: (value: string, e: any) => void;
options: {
label?: string;
value?: string;
disabled?: boolean;
color?: string;
}[];
}
export declare const RadioGroupDefaultProps: Partial<IRadioGroupProps>;

View File

@ -0,0 +1,9 @@
export var RadioGroupDefaultProps = {
value: null,
defaultValue: null,
name: '',
disabled: false,
color: '',
position: 'vertical',
options: [],
};

View File

@ -0,0 +1,35 @@
<import-sjs
from="./index.sjs"
name="componentUtils"
></import-sjs>
<label
class="ant-radio-item {{className || ''}}"
style="{{style}}"
>
<view class="ant-radio-item-container">
<view class="ant-radio-item-wrap">
<radio
value="{{value}}"
class="ant-radio-item-base"
onChange="onChange"
checked="{{mixin.value}}"
disabled="{{disabled}}"
></radio>
<view class="ant-radio-item-fake">
<view
class="ant-radio-item-fake-{{componentUtils.getClassName(mixin.value, disabled)}}"
style="{{mixin.value && !disabled && color ? 'background:' + color : ''}}"
>
<ant-icon
a:if="{{mixin.value}}"
type="CheckOutline"
className="ant-radio-item-fake-{{componentUtils.getClassName(mixin.value, disabled)}}-icon"
></ant-icon>
</view>
</view>
</view>
<view class="ant-radio-item-content {{disabled ? 'ant-radio-item-disabled' : ''}}">
<slot></slot>
</view>
</view>
</label>

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,17 @@
import { Component, triggerEvent } from '../_util/simply';
import { RadioDefaultProps } from './props';
import mixinValue from '../mixins/value';
Component(RadioDefaultProps, {
onChange: function (e) {
var value = e.detail.value;
if (!this.isControlled()) {
this.update(value);
}
triggerEvent(this, 'change', value, e);
},
}, null, [
mixinValue({
valueKey: 'checked',
defaultValueKey: 'defaultChecked',
}),
]);

View File

@ -0,0 +1,6 @@
{
"component": true,
"usingComponents": {
"ant-icon": "../Icon/index"
}
}

View File

@ -0,0 +1,98 @@
@import (reference) './variable.less';
@radioItemPrefix: ant-radio-item;
.@{radioItemPrefix} {
color: @COLOR_TEXT_PRIMARY;
margin-right: 16 * @rpx;
&-container {
display: flex;
align-items: center;
}
&-content {
padding-left: 10 * @rpx;
text-align: left;
}
&-wrap {
position: relative;
width: @radio-size;
height: @radio-size;
flex: 0 0 @radio-size;
}
&-base {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 2;
opacity: 0;
}
&-fake {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
overflow: hidden;
pointer-events: none;
display: flex;
justify-content: center;
align-items: center;
&-icon {
background-color: @COLOR_CARD;
border: @radio-border-width solid @radio-border-color;
border-radius: @radio-corner-radius;
width: 100%;
height: 100%;
box-sizing: border-box;
}
&-checkedIcon {
border-radius: @radio-corner-radius;
background-color: @radio-background-color;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
&-icon {
color: @COLOR_WHITE;
font-size: 28 * @rpx;
}
}
&-disbaledIcon {
box-sizing: border-box;
border: @radio-border-width solid @radio-border-color;
border-radius: @radio-corner-radius;
width: 100%;
height: 100%;
background-color: @radio-disabled-background;
}
&-disabledCheckedIcon {
box-sizing: border-box;
border: @radio-border-width solid @radio-border-color;
background-color: @radio-disabled-background;
border-radius: @radio-corner-radius;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
&-icon {
color: @radio-border-color;
font-size: 28 * @rpx;
}
}
}
&-disabled {
opacity: @opacity-disabled;
}
// .ant-list-item-image-container {
// display: flex;
// justify-content: center;
// align-items: center;
// }
}

View File

@ -0,0 +1,24 @@
function getClassName(checked, disabled) {
if (!checked && !disabled) {
return 'icon';
}
if (checked && !disabled) {
return 'checkedIcon';
}
if (!checked && disabled) {
return 'disbaledIcon';
}
if (checked && disabled) {
return 'disabledCheckedIcon';
}
}
function getChecked(index, options, value) {
if (options[index].value === value) {
return true;
}
return false;
}
export default {
getClassName: getClassName,
getChecked: getChecked
};

View File

@ -0,0 +1,16 @@
import { IBaseProps } from '../_util/base';
export interface IRadioProps extends IBaseProps {
/**
* @description 组件值,选中时 change 事件会携带的 value。
*/
value?: string;
defaultChecked?: boolean;
/**
* @description radio 的颜色,同 CSS 色值。
*/
color?: string;
checked?: boolean;
disabled?: boolean;
onChange?: (checked: boolean, e: any) => void;
}
export declare const RadioDefaultProps: Partial<IRadioProps>;

View File

@ -0,0 +1,7 @@
export var RadioDefaultProps = {
value: null,
defaultChecked: null,
color: '',
checked: null,
disabled: false,
};

View File

@ -0,0 +1,21 @@
@import (reference) '../style/themes/index.less';
// header 颜色
@radio-header-color: @COLOR_TEXT_ASSIST;
/* size | 大小 */
@radio-size: @icon-size-sm;
/* corner-radius | 圆角 */
@radio-corner-radius: @corner-radius-circle;
/* border-width | 边框宽度 */
@radio-border-width: @border-width-standard;
/* color | 边框颜色 */
@radio-border-color: @COLOR_TEXT_WEAK;
/* color | check状态背景色 */
@radio-background-color: @COLOR_BRAND1;
/* color | disabled状态背景色 */
@radio-disabled-background: @COLOR_GREY_CARD;